/* ==========================================================================
   SnapLex · 实景英语图鉴 — Apple Minimalist Light Design System
   Clean #F5F5F7 Canvas + Frosted Glass + Airy Pure-White Open Book + SF Pro
   ========================================================================== */

:root {
  --bg-canvas: #F5F5F7;
  --bg-elevated: #FFFFFF;
  --bg-subtle: #F2F2F7;
  --bg-hover: #E8E8ED;

  --border-hairline: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.14);

  --ink-primary: #1D1D1F;
  --ink-secondary: #515154;
  --ink-muted: #86868B;

  --accent: #0071E3;
  --accent-hover: #0077ED;
  --accent-soft: rgba(0, 113, 227, 0.1);

  --green: #248A3D;
  --green-soft: rgba(52, 199, 89, 0.12);
  --danger: #D70015;
  --danger-soft: rgba(255, 59, 48, 0.1);
  --amber: #B25000;
  --amber-soft: rgba(255, 159, 10, 0.14);

  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Helvetica Neue", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-ipa: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Lucida Sans Unicode", "Segoe UI", "DejaVu Sans", sans-serif;

  --shadow-book: 0 20px 60px rgba(0, 0, 0, 0.08), 0 2px 10px rgba(0, 0, 0, 0.04);
  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.06);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: var(--font-sans);
  color: var(--ink-primary);
  background: var(--bg-canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

button, input, select {
  font-family: inherit;
  color: inherit;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   App Shell & Frosted Glass Top Bar
   ========================================================================== */

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  gap: 12px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border-hairline);
  position: sticky;
  top: 0;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  user-select: none;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.brand-text h1 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink-primary);
  line-height: 1.15;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--ink-muted);
  letter-spacing: 0.02em;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Prominent Top Bar Page Switcher */
.top-pager {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-hairline);
}

.top-pager-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--ink-primary);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.top-pager-btn:hover:not(:disabled) {
  background: #FFFFFF;
  color: var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.top-pager-btn:disabled {
  color: var(--ink-muted);
  opacity: 0.35;
  cursor: not-allowed;
}

.top-pager .page-indicator {
  min-width: 52px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-primary);
  font-variant-numeric: tabular-nums;
  padding: 0 4px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 15px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.16s ease;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--ink-primary);
  color: #FFFFFF;
}

.btn-secondary:hover {
  background: #333336;
}

.btn-ghost {
  background: rgba(0, 0, 0, 0.04);
  border-color: transparent;
  color: var(--ink-primary);
}

.btn-ghost:hover {
  background: rgba(0, 0, 0, 0.08);
}

.btn-danger-ghost {
  background: transparent;
  border-color: rgba(215, 0, 21, 0.22);
  color: var(--danger);
}

.btn-danger-ghost:hover {
  background: var(--danger-soft);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.pill-badge {
  background: rgba(0, 0, 0, 0.07);
  color: var(--ink-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 99px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #FF9F0A;
  display: inline-block;
}

.status-dot.ready {
  background: #34C759;
  box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.2);
}

/* ==========================================================================
   Desk Stage & Airy Pure-White Open Book
   ========================================================================== */

.desk-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px 18px 28px;
  position: relative;
  gap: 14px;
}

.page-nav-edge {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border-hairline);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink-primary);
  font-size: 1.55rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.18s ease;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
  flex-shrink: 0;
}

.page-nav-edge:hover:not(:disabled) {
  background: #FFFFFF;
  color: var(--accent);
  transform: scale(1.06);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.1);
}

.page-nav-edge:disabled {
  opacity: 0.28;
  cursor: not-allowed;
  box-shadow: none;
}

.book-frame {
  position: relative;
  width: 100%;
  max-width: 1220px;
  border-radius: 22px;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-book);
  border: 1px solid var(--border-hairline);
  perspective: 1800px;
  overflow: hidden;
}

.book-spread {
  position: relative;
  display: grid;
  grid-template-columns: 1.24fr 1fr;
  grid-template-rows: minmax(0, 1fr);
  height: min(81vh, 740px);
  min-height: 520px;
  background: #FFFFFF;
  transform-style: preserve-3d;
}

.book-spread.flip-next {
  animation: pageFlipNext 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.book-spread.flip-prev {
  animation: pageFlipPrev 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes pageFlipNext {
  0% { opacity: 0.78; transform: translateX(10px); }
  100% { opacity: 1; transform: translateX(0); }
}

@keyframes pageFlipPrev {
  0% { opacity: 0.78; transform: translateX(-10px); }
  100% { opacity: 1; transform: translateX(0); }
}

/* Minimalist subtle open-book spine crease */
.book-spine-gutter {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 55.35%;
  transform: translateX(-50%);
  width: 34px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(0, 0, 0, 0.022) 32%,
    rgba(0, 0, 0, 0.055) 49%,
    rgba(255, 255, 255, 0.9) 51%,
    rgba(0, 0, 0, 0.035) 55%,
    rgba(0, 0, 0, 0.012) 78%,
    transparent 100%
  );
  pointer-events: none;
  z-index: 15;
}

/* Individual Book Pages */
.book-page {
  position: relative;
  display: flex;
  flex-direction: column;
  padding: 20px 26px 16px;
  min-height: 0;
  overflow: hidden;
  background: #FFFFFF;
}

.book-page-left {
  padding-right: 28px;
  border-right: 1px solid rgba(0, 0, 0, 0.05);
}

.book-page-right {
  padding-left: 30px;
}

/* ==========================================================================
   Left Page: Interactive Photo Canvas (Apple Photos Markup Aesthetic)
   ========================================================================== */

.page-header-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.plate-label {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ink-muted);
  text-transform: uppercase;
}

.canvas-quick-toggles {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.chip-toggle {
  padding: 4px 11px;
  border-radius: 99px;
  border: 1px solid var(--border-hairline);
  background: var(--bg-subtle);
  color: var(--ink-secondary);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-toggle:hover {
  background: var(--bg-hover);
}

.chip-toggle.active {
  background: var(--ink-primary);
  border-color: var(--ink-primary);
  color: #FFFFFF;
}

.photo-stage-wrap {
  flex: 1;
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-canvas);
  border-radius: 16px;
  padding: 10px;
  position: relative;
  overflow: hidden;
}

.photo-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  max-height: 100%;
  line-height: 0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.09);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.photo-stage.adding-pin {
  cursor: crosshair;
}

.stage-image {
  display: block;
  max-width: 100%;
  max-height: calc(min(81vh, 740px) - 165px);
  width: auto;
  height: auto;
  object-fit: contain;
  pointer-events: none;
}

.leader-layer,
.pins-layer,
.tags-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.leader-layer {
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.18s ease;
}

.pins-layer {
  pointer-events: none;
  z-index: 3;
  transition: opacity 0.18s ease;
}

/* By default hide guides for pure Apple Photos clean look; reveal when user toggles or drags */
.photo-stage.hide-guides .leader-layer,
.photo-stage.hide-guides .pins-layer {
  opacity: 0;
  pointer-events: none;
}

.photo-stage.hide-guides.is-dragging .leader-layer,
.photo-stage.hide-guides.is-dragging .pins-layer {
  opacity: 0.72;
}

.tags-layer {
  z-index: 4;
  pointer-events: none;
}

/* Minimal Anchor Pin (visible only when guides enabled or dragging) */
.anchor-pin {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  background: #FFFFFF;
  border: 2px solid var(--accent);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.32);
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.15s ease;
}

.anchor-pin:hover,
.anchor-pin.active {
  transform: translate(-50%, -50%) scale(1.35);
  z-index: 12;
}

/* ==========================================================================
   Direct Text on Photo — Apple Photos / iOS Markup Natural Clean Typography
   Line 1 (centered): English + space + Chinese (regular/medium weight)
   Line 2 (centered): /IPA/ (regular weight, clean subtle shadow, ZERO heavy stroke)
   ========================================================================== */

.callout-tag {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: grab;
  padding: 2px 5px;
  border-radius: 7px;
  background: transparent;
  border: 1px solid transparent;
  text-align: center;
  max-width: 270px;
  min-width: 48px;
  line-height: 1.28;
  touch-action: none;
  transition: transform 0.14s ease, border-color 0.14s ease;
  z-index: 5;
}

.callout-tag:hover {
  transform: translate(-50%, -50%) scale(1.03);
  z-index: 14;
}

.callout-tag.active {
  border-color: rgba(255, 255, 255, 0.65);
  border-style: dashed;
  z-index: 16;
}

.callout-tag.dragging {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.05);
  z-index: 30;
}

.callout-tag .tag-main-line {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 400;
  letter-spacing: 0.005em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.16s ease, text-shadow 0.16s ease;
}

.callout-tag .tag-ipa-line {
  display: block;
  font-family: var(--font-ipa);
  font-size: 0.75rem;
  font-weight: 400;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.94;
  transition: color 0.16s ease, text-shadow 0.16s ease;
}

/* Adaptive Per-Label Tone (Default 'auto' mode) & Explicit Light/Dark Modes */
.photo-stage.theme-plain-light .callout-tag .tag-main-line,
.photo-stage.theme-plain-light .callout-tag .tag-ipa-line,
.photo-stage.theme-auto .callout-tag.tone-light .tag-main-line,
.photo-stage.theme-auto .callout-tag.tone-light .tag-ipa-line {
  color: #FFFFFF;
  text-shadow:
    0 1px 3px rgba(0, 0, 0, 0.58),
    0 0 10px rgba(0, 0, 0, 0.28);
}

.photo-stage.theme-auto .callout-tag.tone-light.tone-mid .tag-main-line,
.photo-stage.theme-auto .callout-tag.tone-light.tone-mid .tag-ipa-line {
  color: #FFFFFF;
  text-shadow:
    0 1px 4px rgba(0, 0, 0, 0.78),
    0 0 12px rgba(0, 0, 0, 0.45);
}

.photo-stage.theme-plain-dark .callout-tag.active,
.photo-stage.theme-auto .callout-tag.tone-dark.active {
  border-color: rgba(0, 113, 227, 0.55);
}

.photo-stage.theme-plain-dark .callout-tag .tag-main-line,
.photo-stage.theme-plain-dark .callout-tag .tag-ipa-line,
.photo-stage.theme-auto .callout-tag.tone-dark .tag-main-line,
.photo-stage.theme-auto .callout-tag.tone-dark .tag-ipa-line {
  color: #1D1D1F;
  text-shadow:
    0 1px 4px rgba(255, 255, 255, 0.88),
    0 0 10px rgba(255, 255, 255, 0.72);
}

/* Style 3 (Optional): Subtle Apple Frosted Glass Pill */
.photo-stage.theme-glass .callout-tag {
  padding: 4px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
}

.photo-stage.theme-glass .callout-tag.active {
  border-style: solid;
  border-color: var(--accent);
}

.photo-stage.theme-glass .callout-tag .tag-main-line {
  color: var(--ink-primary);
  font-weight: 500;
  font-size: 0.8rem;
}

.photo-stage.theme-glass .callout-tag .tag-ipa-line {
  color: var(--ink-secondary);
  font-size: 0.7rem;
}

/* Quiz Mode: masked tag */
.callout-tag.quiz-masked .tag-main-line,
.callout-tag.quiz-masked .tag-ipa-line {
  filter: blur(6px);
  opacity: 0.25;
  user-select: none;
}

.callout-tag.quiz-masked::after {
  content: "轻点揭晓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 500;
  color: #FFFFFF;
  background: rgba(29, 29, 31, 0.68);
  backdrop-filter: blur(6px);
  border-radius: 99px;
  padding: 0 10px;
}

.add-pin-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(29, 29, 31, 0.86);
  backdrop-filter: blur(10px);
  color: #FFFFFF;
  padding: 7px 16px;
  border-radius: 99px;
  font-size: 0.8rem;
  line-height: 1.3;
  z-index: 25;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.link-btn {
  background: none;
  border: none;
  color: #64D2FF;
  text-decoration: underline;
  cursor: pointer;
  padding: 0 4px;
  font-size: inherit;
}

/* Canvas Bottom Toolbar */
.canvas-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-btn {
  padding: 6px 12px;
  border-radius: 99px;
  border: 1px solid var(--border-hairline);
  background: var(--bg-subtle);
  color: var(--ink-primary);
  font-size: 0.79rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tool-btn:hover {
  background: var(--bg-hover);
}

.tool-btn.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.tool-btn-accent {
  background: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}

.tool-btn-accent:hover {
  background: var(--accent-hover);
}

.page-footer-num {
  margin-top: 8px;
  font-size: 0.74rem;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

/* Empty state */
.empty-stage {
  text-align: center;
  padding: 36px 24px;
  max-width: 340px;
}

.empty-illustration {
  font-size: 2.5rem;
  margin-bottom: 10px;
}

.empty-stage h3 {
  margin: 0 0 8px;
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--ink-primary);
}

.empty-stage p {
  margin: 0 0 18px;
  font-size: 0.86rem;
  color: var(--ink-secondary);
  line-height: 1.6;
}

/* ==========================================================================
   Right Page: Scene Meta & Clean Vocabulary Cards
   ========================================================================== */

.scene-meta-header {
  border-bottom: 1px solid var(--border-hairline);
  padding-bottom: 14px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.scene-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.scene-tag-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.scene-tag-badge {
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 99px;
}

.scene-date-text {
  font-size: 0.75rem;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

.accent-pill {
  font-size: 0.7rem;
  color: var(--ink-secondary);
  background: var(--bg-subtle);
  padding: 2px 8px;
  border-radius: 99px;
  font-weight: 500;
}

.scene-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink-primary);
  line-height: 1.3;
  cursor: pointer;
}

.scene-title:hover {
  color: var(--accent);
}

.scene-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-subtle);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: var(--bg-hover);
}

.icon-btn.danger:hover {
  background: var(--danger-soft);
}

.vocab-list-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vocab-list-scroll::-webkit-scrollbar {
  width: 5px;
}

.vocab-list-scroll::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.14);
  border-radius: 99px;
}

.vocab-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-canvas);
  border: 1px solid transparent;
  transition: all 0.15s ease;
  cursor: pointer;
}

.vocab-card:hover {
  background: #EFEFF4;
}

.vocab-card.active {
  background: rgba(0, 113, 227, 0.06);
  border-color: rgba(0, 113, 227, 0.28);
}

.vocab-card-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.vocab-index {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #FFFFFF;
  color: var(--ink-secondary);
  font-size: 0.72rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.vocab-card.active .vocab-index {
  background: var(--accent);
  color: #FFFFFF;
}

.vocab-text {
  min-width: 0;
  flex: 1;
}

.vocab-en-line {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.vocab-en {
  font-size: 0.96rem;
  font-weight: 500;
  color: var(--ink-primary);
}

.vocab-ipa {
  font-family: var(--font-ipa);
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.vocab-zh {
  font-size: 0.82rem;
  color: var(--ink-secondary);
  margin-top: 2px;
}

.vocab-card.quiz-hidden .vocab-en,
.vocab-card.quiz-hidden .vocab-ipa {
  filter: blur(6px);
  opacity: 0.3;
}

.vocab-card-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.mini-action-btn {
  width: 29px;
  height: 29px;
  border-radius: 50%;
  border: none;
  background: transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  color: var(--ink-muted);
  transition: all 0.14s ease;
}

.mini-action-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--ink-primary);
}

.mini-action-btn.starred {
  color: #FF9F0A;
}

.inline-pager {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border-hairline);
}

.pager-btn {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  padding: 5px 10px;
  border-radius: 99px;
}

.pager-btn:hover:not(:disabled) {
  background: var(--accent-soft);
}

.pager-btn:disabled {
  color: var(--ink-muted);
  opacity: 0.35;
  cursor: not-allowed;
}

.page-indicator {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--ink-muted);
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Mobile Sticky Bottom Bar (Hidden on Desktop)
   ========================================================================== */

.mobile-bottom-bar {
  display: none;
}

/* ==========================================================================
   Modals (Apple Clean Sheet Style)
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  animation: fadeIn 0.16s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  background: #FFFFFF;
  border-radius: 20px;
  border: 1px solid var(--border-hairline);
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-small {
  max-width: 420px;
}

.modal-export {
  max-width: 680px;
}

.modal-toc {
  max-width: 760px;
  height: min(86vh, 680px);
}

.modal-settings {
  max-width: 640px;
}

.modal-loading {
  max-width: 360px;
  text-align: center;
  padding: 28px 24px;
  align-items: center;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border-hairline);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.04rem;
  font-weight: 600;
  color: var(--ink-primary);
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--bg-subtle);
  font-size: 0.85rem;
  color: var(--ink-secondary);
  cursor: pointer;
}

.modal-close:hover {
  background: var(--bg-hover);
}

.modal-body {
  padding: 18px 22px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 12px 22px;
  border-top: 1px solid var(--border-hairline);
  background: #FAFAFC;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.modal-footer.space-between,
.toc-footer {
  justify-content: space-between;
}

.footer-btns {
  display: flex;
  gap: 8px;
}

/* Drop Zone */
.drop-zone {
  border: 1.5px dashed var(--border-strong);
  border-radius: 16px;
  padding: 26px 18px;
  text-align: center;
  background: var(--bg-canvas);
  transition: all 0.18s ease;
}

.drop-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.drop-zone-icon {
  font-size: 2rem;
  margin-bottom: 6px;
}

.drop-zone-title {
  margin: 0;
  font-weight: 600;
  font-size: 0.96rem;
  color: var(--ink-primary);
}

.drop-zone-sub {
  margin: 4px 0 16px;
  font-size: 0.8rem;
  color: var(--ink-muted);
}

.drop-zone-btns {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.upload-options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 16px;
}

.field-group label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-secondary);
  margin-bottom: 6px;
}

.segmented {
  display: flex;
  background: var(--bg-subtle);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.segmented button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 6px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-secondary);
  cursor: pointer;
}

.segmented button.active {
  background: #FFFFFF;
  color: var(--ink-primary);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.info-banner {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--amber-soft);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.82rem;
}

.info-banner p {
  margin: 4px 0 0;
  color: var(--ink-secondary);
  line-height: 1.45;
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 14px;
  font-size: 0.83rem;
  color: var(--ink-secondary);
  cursor: pointer;
  line-height: 1.45;
}

.checkbox-row input {
  margin-top: 3px;
  accent-color: var(--accent);
}

/* Loading Animation */
.loading-book-anim {
  position: relative;
  width: 48px;
  height: 48px;
  margin-bottom: 14px;
}

.spinner-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid var(--bg-subtle);
  border-top-color: var(--accent);
  animation: spin 0.85s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.modal-loading h3 {
  margin: 0 0 6px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink-primary);
}

.modal-loading p {
  margin: 0 0 14px;
  font-size: 0.82rem;
  color: var(--ink-muted);
}

.loading-preview-wrap {
  width: 140px;
  height: 96px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border-hairline);
  margin-bottom: 14px;
  background: var(--bg-subtle);
}

.loading-preview-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Export Preview */
.export-options-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.mini-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--ink-secondary);
  cursor: pointer;
}

.mini-check input {
  accent-color: var(--accent);
}

.mini-select {
  padding: 4px 8px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: #FFFFFF;
  font-size: 0.8rem;
  color: var(--ink-primary);
}

.export-preview-frame {
  background: var(--bg-canvas);
  border-radius: 14px;
  padding: 10px;
  text-align: center;
  max-height: 54vh;
  overflow: auto;
}

.export-preview-frame img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
}

.mobile-save-tip {
  margin: 10px 0 14px;
  font-size: 0.8rem;
  color: var(--ink-muted);
  text-align: center;
}

.export-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* TOC & Starred Vocab */
.toc-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-hairline);
  padding: 0 22px;
  gap: 16px;
}

.toc-tab {
  border: none;
  background: transparent;
  padding: 11px 4px;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--ink-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.toc-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.toc-search-bar {
  display: flex;
  gap: 8px;
  padding: 12px 22px 0;
}

.toc-search-bar input,
.toc-search-bar select,
.form-row input,
.form-row select {
  width: 100%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: #FFFFFF;
  font-size: 0.86rem;
  outline: none;
}

.toc-search-bar select {
  width: 136px;
  flex-shrink: 0;
}

.toc-search-bar input:focus,
.form-row input:focus,
.form-row select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.toc-pages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(195px, 1fr));
  gap: 12px;
}

.toc-page-card {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border-hairline);
  background: #FFFFFF;
  cursor: pointer;
  transition: all 0.16s ease;
  display: flex;
  flex-direction: column;
}

.toc-page-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
  border-color: var(--accent);
}

.toc-page-card.current {
  border: 2px solid var(--accent);
}

.toc-thumb {
  height: 120px;
  background: var(--bg-canvas);
  position: relative;
  overflow: hidden;
}

.toc-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.toc-thumb-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(29, 29, 31, 0.72);
  backdrop-filter: blur(6px);
  color: #FFFFFF;
  font-size: 0.68rem;
  padding: 2px 8px;
  border-radius: 99px;
}

.toc-card-info {
  padding: 10px 12px;
}

.toc-card-title {
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toc-card-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.74rem;
  color: var(--ink-muted);
  margin-top: 4px;
}

.toc-starred-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.starred-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--bg-canvas);
}

.starred-source-link {
  font-size: 0.75rem;
  color: var(--accent);
  background: var(--accent-soft);
  border: none;
  border-radius: 99px;
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
}

.starred-source-link:hover {
  background: var(--accent);
  color: #FFFFFF;
}

.toc-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--ink-muted);
  font-size: 0.88rem;
}

/* Settings */
.settings-section {
  margin-bottom: 20px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section h4 {
  margin: 0 0 10px;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink-primary);
}

.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.preset-card {
  text-align: left;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1.5px solid var(--border-hairline);
  background: var(--bg-canvas);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: all 0.15s ease;
}

.preset-card:hover {
  border-color: var(--border-strong);
}

.preset-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.preset-card strong {
  font-size: 0.84rem;
  color: var(--ink-primary);
}

.preset-card small {
  font-size: 0.72rem;
  color: var(--ink-muted);
}

.preset-badge {
  align-self: flex-start;
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.06);
  color: var(--ink-secondary);
}

.preset-badge.free {
  background: var(--green-soft);
  color: var(--green);
}

.preset-badge.best {
  background: var(--accent-soft);
  color: var(--accent);
}

.guide-box {
  padding: 10px 13px;
  border-radius: 10px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-hairline);
  font-size: 0.8rem;
  color: var(--ink-secondary);
  line-height: 1.55;
  margin-bottom: 12px;
}

.guide-box a {
  color: var(--accent);
  font-weight: 600;
}

.form-row {
  margin-bottom: 10px;
}

.form-row label {
  display: block;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-secondary);
  margin-bottom: 5px;
}

.muted-inline,
.muted-note {
  font-weight: 400;
  font-size: 0.75rem;
  color: var(--ink-muted);
}

.form-row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.input-with-btn {
  display: flex;
  gap: 6px;
}

.data-actions-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.test-result-box {
  margin-top: 8px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 0.8rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.test-result-box.ok {
  background: var(--green-soft);
  color: var(--green);
}

.test-result-box.err {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: rgba(29, 29, 31, 0.92);
  backdrop-filter: blur(12px);
  color: #FFFFFF;
  padding: 10px 18px;
  border-radius: 14px;
  font-size: 0.83rem;
  font-weight: 400;
  line-height: 1.48;
  max-width: min(92vw, 560px);
  text-align: center;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  animation: toastIn 0.2s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Responsive Mobile Layout (< 900px)
   ========================================================================== */

@media (max-width: 899px) {
  .top-bar {
    padding: 9px 14px;
    gap: 8px;
  }

  .brand {
    gap: 8px;
    min-width: 0;
  }

  .brand-logo {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
  }

  .brand-text h1 {
    font-size: 1rem;
  }

  .brand-sub {
    display: none;
  }

  .top-pager {
    padding: 2px;
    gap: 1px;
  }

  .top-pager-btn {
    padding: 5px 9px;
    font-size: 0.95rem;
  }

  .top-pager-btn .pager-txt {
    display: none;
  }

  .top-pager .page-indicator {
    min-width: 38px;
    font-size: 0.78rem;
  }

  .top-actions {
    gap: 5px;
    flex-shrink: 0;
  }

  .top-actions .btn {
    padding: 6px 8px;
    font-size: 0.8rem;
  }

  .hide-sm,
  #btnNewSnapTop,
  #btnToc .label,
  #btnRandomPage {
    display: none;
  }

  .desk-stage {
    padding: 10px 10px 84px;
    align-items: flex-start;
  }

  .page-nav-edge,
  .book-spine-gutter {
    display: none;
  }

  .book-frame {
    border-radius: 18px;
  }

  .book-spread {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    height: auto;
    min-height: auto;
    max-height: none;
    overflow: visible;
  }

  .book-page {
    padding: 14px 12px 12px;
    overflow: visible;
  }

  .book-page-left {
    padding-right: 12px;
    border-right: none;
    border-bottom: 1px solid var(--border-hairline);
  }

  .book-page-right {
    padding-left: 12px;
  }

  .photo-stage-wrap {
    padding: 4px;
    min-height: auto;
    border-radius: 12px;
  }

  .stage-image {
    max-height: 55vh;
  }

  .callout-tag {
    padding: 2px 4px;
    max-width: 140px;
  }

  .callout-tag .tag-main-line {
    font-size: 0.7rem;
  }

  .callout-tag .tag-ipa-line {
    font-size: 0.62rem;
  }

  .vocab-list-scroll {
    max-height: none;
    overflow-y: visible;
  }

  .upload-options-grid,
  .form-row-2col {
    grid-template-columns: 1fr;
  }

  .mobile-bottom-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-top: 1px solid var(--border-hairline);
  }

  .mob-btn {
    border: none;
    background: transparent;
    border-radius: 12px;
    padding: 5px 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--ink-secondary);
    cursor: pointer;
    font-size: 1.08rem;
    line-height: 1;
  }

  .mob-btn small {
    font-size: 0.66rem;
    font-weight: 500;
  }

  .mob-btn-primary {
    background: var(--accent);
    color: #FFFFFF;
  }

  .toast-container {
    bottom: 78px;
  }
}
