.eb-card {
  background: rgba(255, 253, 249, 0.92);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(10px);
  transition: transform 200ms ease-out, box-shadow 200ms ease-out, border-color 180ms ease-out;
}

.eb-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card-hover);
}

.eb-skip-link {
  position: absolute;
  top: 0;
  left: 16px;
  z-index: 50;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--color-text);
  color: var(--color-white);
  transform: translateY(-140%);
  opacity: 0;
  pointer-events: none;
}

.eb-skip-link:focus {
  top: 12px;
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.eb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 16px;
  border-radius: var(--radius-control);
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 120ms ease-out, box-shadow 180ms ease-out, background 180ms ease-out, border-color 180ms ease-out;
}

.eb-btn:hover {
  box-shadow: 0 8px 18px rgba(47, 62, 70, 0.08);
}

.eb-btn:active {
  transform: translateY(1px);
}

.eb-btn-primary {
  background: var(--color-primary);
  color: var(--color-white);
  box-shadow: var(--shadow-primary);
}

.eb-btn-ghost {
  background: var(--color-white);
  color: var(--color-text);
  border-color: var(--color-line);
}

.eb-btn-danger {
  background: var(--color-danger);
  color: var(--color-white);
}

.eb-btn:disabled,
.eb-link-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  box-shadow: none;
}

.eb-link-btn:disabled,
.eb-link-btn.is-disabled {
  color: var(--color-muted);
  pointer-events: none;
  text-decoration: none;
}

body.eb-ai-busy [data-solve-one],
body.eb-ai-busy [data-solve-all],
body.eb-ai-busy [data-drawer-solve],
body.eb-ai-busy [data-refresh-advice],
body.eb-ai-busy #btn-analyze-all {
  opacity: 0.45;
  cursor: not-allowed !important;
  pointer-events: none;
  box-shadow: none !important;
  filter: saturate(0.65);
}

.eb-input,
.eb-select {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: var(--radius-control);
  border: 1px solid var(--color-line);
  background: rgba(255, 255, 255, 0.92);
  color: var(--color-text);
  transition: border-color 180ms ease-out, box-shadow 180ms ease-out;
}

textarea.eb-input {
  resize: vertical;
}

.eb-input:focus,
.eb-select:focus,
.eb-btn:focus,
.eb-link-btn:focus,
.eb-skip-link:focus,
summary:focus {
  outline: 3px solid rgba(255, 217, 163, 0.9);
  outline-offset: 2px;
}

.eb-tag,
.eb-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 13px;
}

.eb-tag {
  background: var(--color-highlight);
}

.eb-tag--kp a {
  margin-left: 4px;
  font-weight: 700;
}

.eb-badge--muted {
  background: #eff3f4;
  color: var(--color-muted);
}

.eb-badge--success {
  background: rgba(79, 184, 164, 0.16);
  color: #227767;
}

.eb-badge--warning {
  background: rgba(255, 217, 163, 0.42);
  color: #8c5d1d;
}
.eb-badge--warn { background: #fff3cd; color: #856404; }

.eb-badge--danger {
  background: rgba(255, 138, 122, 0.18);
  color: #b54c3f;
}

.eb-empty-state {
  text-align: center;
  padding: 36px 24px;
}

.eb-empty-state .eb-capybara,
.eb-empty-state .eb-capybara--sleep,
.eb-empty-state .eb-capybara--sun,
.eb-empty-state .eb-capybara--peek {
  width: 140px;
  max-width: 100%;
  margin: 0 auto;
}

.eb-empty-state__text {
  margin: 14px 0 18px;
  color: var(--color-muted);
}

.eb-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.eb-field {
  display: grid;
  gap: 8px;
}

.eb-field--wide {
  grid-column: span 2;
}

.eb-field__label {
  font-size: 13px;
  color: var(--color-muted);
}

.eb-check,
.eb-inline-check {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.eb-link-btn {
  border: 0;
  background: transparent;
  color: var(--color-primary);
  cursor: pointer;
  padding: 0;
  font-size: 13px;
  line-height: 1.2;
}

.eb-link-btn--danger {
  color: var(--color-danger);
}

.eb-link-btn:hover:not(:disabled) {
  text-decoration: underline;
}

.eb-toast-root {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 40;
}

.eb-toast {
  margin-bottom: 10px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(47, 62, 70, 0.9);
  color: var(--color-white);
  box-shadow: var(--shadow-modal);
  animation: eb-toast-in 200ms ease-out;
}

.eb-table-shell {
  overflow-x: auto;
}

.eb-table {
  width: 100%;
  border-collapse: collapse;
}

.eb-table th,
.eb-table td {
  padding: 14px 12px;
  border-bottom: 1px solid rgba(229, 224, 215, 0.8);
  text-align: left;
  vertical-align: top;
}

.eb-table th {
  font-size: 13px;
  color: var(--color-muted);
}

.eb-view-switch {
  display: inline-flex;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  border: 1px solid var(--color-line);
}

.eb-view-switch__btn {
  min-width: 72px;
  padding: 8px 14px;
  border: 0;
  background: transparent;
  border-radius: 999px;
  color: var(--color-muted);
  cursor: pointer;
}

.eb-view-switch__btn.is-active {
  background: rgba(79, 184, 164, 0.16);
  color: var(--color-text);
}

.eb-select-bar {
  position: sticky;
  bottom: 88px;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-top: 18px;
  padding: 16px 20px;
  border-radius: 18px;
  border: 1px solid rgba(79, 184, 164, 0.22);
  background: rgba(255, 253, 249, 0.96);
  box-shadow: var(--shadow-modal);
}

.eb-select-bar__hint {
  margin-left: 8px;
  color: var(--color-muted);
  font-size: 14px;
}

.eb-drawer[hidden],
.eb-modal[hidden] {
  display: none;
}

.eb-drawer {
  position: fixed;
  inset: 0;
  z-index: 35;
}

.eb-drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(47, 62, 70, 0.35);
}

.eb-drawer__panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(100%, 460px);
  height: 100%;
  padding: 24px;
  background: var(--color-card);
  box-shadow: var(--shadow-modal);
  overflow-y: auto;
  animation: eb-drawer-in 220ms ease-out;
}

.eb-drawer__head,
.eb-modal__head,
.eb-modal__foot {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.eb-drawer__body,
.eb-modal__body {
  display: grid;
  gap: 16px;
  margin-top: 16px;
}

.eb-modal {
  border: 0;
  padding: 0;
  background: transparent;
  width: min(100%, 640px);
}

.eb-modal::backdrop {
  background: rgba(47, 62, 70, 0.35);
}

.eb-modal__panel {
  padding: 24px;
  border-radius: 24px;
  background: var(--color-card);
  box-shadow: var(--shadow-modal);
  animation: eb-modal-in 220ms ease-out;
}

.eb-radio-card {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 12px;
  align-items: start;
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--color-line);
  background: rgba(255, 255, 255, 0.8);
}

.eb-radio-card small {
  display: block;
  margin-top: 4px;
  color: var(--color-muted);
}

@keyframes eb-toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes eb-drawer-in {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes eb-modal-in {
  from { opacity: 0; transform: translateY(18px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 767px) {
  .eb-select-bar {
    bottom: 88px;
    flex-direction: column;
    align-items: stretch;
  }

  .eb-field--wide {
    grid-column: span 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .eb-card,
  .eb-btn,
  .eb-toast,
  .eb-drawer__panel,
  .eb-modal__panel {
    animation: none !important;
    transition: none !important;
    transform: none !important;
  }
}

/* Elements that only appear in printed output — hidden on screen.
 * The screen-side rule must live here (components.css is loaded for
 * media="all"); the print-side reveal lives in print.css. */
.print-only { display: none; }

/* ───── Lightbox (original paper image viewer) ─────────────────────────── */
.eb-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20, 20, 25, 0.92);
  padding: 24px;
  cursor: zoom-out;
  overflow: hidden;
  touch-action: none;
}
.eb-lightbox.is-open {
  display: flex;
}
.eb-lightbox__img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  cursor: zoom-in;
  background: #fff;
  transform-origin: center center;
  transition: transform 80ms ease-out;
  will-change: transform;
  user-select: none;
  -webkit-user-drag: none;
}
.eb-lightbox__close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}
.eb-lightbox__close:hover {
  background: rgba(255, 255, 255, 0.28);
}
.eb-lightbox__zoom-controls {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(6px);
  z-index: 2;
}
.eb-lightbox__zoom-btn {
  min-width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.eb-lightbox__zoom-btn:hover {
  background: rgba(255, 255, 255, 0.32);
}
.eb-lightbox__zoom-level {
  min-width: 56px;
  text-align: center;
  color: #fff;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.eb-lightbox__hint {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  background: rgba(0, 0, 0, 0.32);
  padding: 6px 12px;
  border-radius: 999px;
  pointer-events: none;
}
.eb-lightbox__spinner {
  color: #fff;
  font-size: 14px;
}

/* ── Crop lightbox (draw-to-select on original paper) ────────────── */
.eb-crop {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20, 20, 25, 0.92);
  padding: 48px 24px 72px;
  touch-action: none;
}
.eb-crop.is-open { display: flex; }
.eb-crop__stage {
  position: relative;
  width: 100%;
  height: calc(100vh - 140px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;       /* zoomed-out-of-bounds content is clipped */
  cursor: crosshair;
  user-select: none;
}
.eb-crop__content {
  position: relative;
  display: inline-block;
  transform-origin: center center;
  will-change: transform;
}
.eb-crop__img {
  display: block;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 140px);
  object-fit: contain;
  background: #fff;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}
.eb-crop__rect {
  position: absolute;
  border: 2px solid #ff3b30;
  background: rgba(255, 59, 48, 0.12);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  display: none;
}
.eb-crop__rect.is-active { display: block; }
.eb-crop__bar {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(6px);
  z-index: 2;
}
.eb-crop__hint {
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
  padding: 0 6px;
}
.eb-crop__close {
  position: absolute;
  top: 16px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
  z-index: 2;
}
.eb-crop__close:hover { background: rgba(255, 255, 255, 0.28); }

/* ── Figure-source chooser modal (shown after clicking 上传配图) ──
 * Small centered dialog with 3 actions: 取消 / 重新上传 / 从原卷裁切. */
.eb-choice-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
}
.eb-choice-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
}
.eb-choice-modal__panel {
  position: relative;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 45px rgba(15, 23, 42, 0.25);
  padding: 20px 22px;
  max-width: 420px;
  width: calc(100% - 40px);
}
.eb-choice-modal__panel h4 {
  margin: 0 0 8px;
  font-size: 16px;
}
.eb-choice-modal__panel p {
  margin: 0 0 16px;
  color: #475569;
  font-size: 13px;
  line-height: 1.5;
}
.eb-choice-modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
