/* ==========================================================================
   Mai Read: Stylesheet (Conforming strictly to MAI READ-UI-SPEC.md)
   Minimal, calm, premium document reading workspace.
   Zero emojis, zero decorative gradients, zero blur islands.
   ========================================================================== */

/* ── 1. Design Tokens ─────────────────────────────────────────────────────── */
:root {
  --bg: #F6F5F1;          /* app background */
  --surface: #FFFFFF;     /* cards, lists */
  --surface-2: #F1EFE8;   /* segmented track, skeletons */
  --reader-bg: #E8E6DF;   /* area around the paper */
  --paper: #FDFCF9;
  --paper-ink: #26241E;
  --ink: #15140F;
  --ink-2: #4F4D45;
  --muted: #6B685E;
  --line: #E3E0D6;
  --line-strong: #DAD7CC;
  --hl: #F3D56B;          /* highlighter */
  --danger: #A23B2B;      /* always paired with an icon + text */
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --radius-pill: 999px;
  --shadow-paper: 0 1px 2px rgba(21, 20, 15, 0.06), 0 12px 40px rgba(21, 20, 15, 0.08);
  --shadow-float: 0 12px 32px rgba(21, 20, 15, 0.12);
  --shadow-subtle: 0 1px 3px rgba(21, 20, 15, 0.08);
  --shadow-thumb: 0 1px 4px rgba(21, 20, 15, 0.16);
  --font-ui: 'Geist', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif: 'Fraunces', 'Newsreader', Georgia, serif;
  --font-display: 'Fraunces', 'Newsreader', Georgia, serif;
  --accent: #B5792F;
  --accent-soft: rgba(181, 121, 47, 0.12);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --paper-brightness: 1;

  /* Aliases for docs and utility compatibility */
  --app-bg: var(--bg);
  --control-bg: var(--surface);
  --control-border: var(--line);
  --control-border-hover: var(--line-strong);
  --button-bg: var(--surface);
  --button-hover-bg: var(--surface-2);
  --paper-bg: var(--paper);
  --font-sans: var(--font-ui);
  --ink-secondary: var(--ink-2);

  /* Apple Liquid Glass Tokens */
  --liquid-blur: blur(28px) saturate(190%);
  --liquid-glass-bg: rgba(255, 255, 255, 0.76);
  --liquid-glass-border: rgba(255, 255, 255, 0.65);
  --liquid-glass-border-subtle: rgba(255, 255, 255, 0.4);
  --liquid-specular: inset 0 1px 1px 0 rgba(255, 255, 255, 0.9), 0 8px 32px 0 rgba(21, 20, 15, 0.08);
  --liquid-specular-sm: inset 0 1px 0 0 rgba(255, 255, 255, 0.8), 0 2px 8px 0 rgba(21, 20, 15, 0.04);
  --liquid-card-bg: rgba(255, 255, 255, 0.85);
  --liquid-card-border: rgba(227, 224, 214, 0.75);
  --liquid-pill-bg: rgba(241, 239, 232, 0.82);
  --liquid-pill-active: #FFFFFF;
  --liquid-pill-shadow: 0 2px 8px rgba(21, 20, 15, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  --apple-ease: cubic-bezier(0.16, 1, 0.3, 1);
  --apple-squircle-sm: 12px;
  --apple-squircle-md: 18px;
  --apple-squircle-lg: 24px;
  --apple-squircle-xl: 32px;
}

:root[data-resolved-theme="dark"] {
  --bg: #111111;          /* neutral obsidian background */
  --surface: #181818;     /* clean neutral dark surface */
  --surface-2: #242424;   /* neutral dark segmented track, chips, skeletons */
  --reader-bg: #0C0C0C;   /* deep pure charcoal reading surround */
  --paper: #161616;       /* neutral dark paper */
  --paper-ink: #ECECEC;   /* crisp neutral paper text - no yellow tint */
  --ink: #F5F5F7;         /* crisp clean neutral ink */
  --ink-2: #A1A1A6;       /* crisp neutral secondary ink */
  --muted: #737378;       /* crisp neutral muted text */
  --line: #262626;        /* crisp neutral hairline border - no olive/yellow tint */
  --line-strong: #383838; /* crisp neutral strong border */
  --hl-dark-bg: rgba(243, 213, 107, 0.22);
  --hl-dark-ink: #FFF8E1;
  --shadow-subtle: 0 1px 3px rgba(0, 0, 0, 0.45);
  --shadow-thumb: 0 1px 4px rgba(0, 0, 0, 0.5);
  --shadow-paper: 0 1px 3px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-float: 0 12px 32px rgba(0, 0, 0, 0.6);

  /* Apple Liquid Glass Dark Tokens */
  --liquid-glass-bg: rgba(22, 22, 26, 0.78);
  --liquid-glass-border: rgba(255, 255, 255, 0.12);
  --liquid-glass-border-subtle: rgba(255, 255, 255, 0.08);
  --liquid-specular: inset 0 1px 0 0 rgba(255, 255, 255, 0.2), 0 12px 40px 0 rgba(0, 0, 0, 0.55);
  --liquid-specular-sm: inset 0 1px 0 0 rgba(255, 255, 255, 0.14), 0 4px 14px 0 rgba(0, 0, 0, 0.4);
  --liquid-card-bg: rgba(26, 26, 30, 0.85);
  --liquid-card-border: rgba(255, 255, 255, 0.08);
  --liquid-pill-bg: rgba(38, 38, 44, 0.7);
  --liquid-pill-active: rgba(56, 56, 64, 0.95);
  --liquid-pill-shadow: 0 2px 10px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* ── 2. Reset & Base Typography ───────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100dvh;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  overflow-x: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  background-color: var(--bg);
}

:root[data-resolved-theme="dark"] body {
  background-color: var(--bg);
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: none;
}

a {
  color: inherit;
  text-decoration: none;
}

svg {
  display: block;
  flex-shrink: 0;
}

/* Accessible visible focus ring */
:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* Motion standard (150-200ms cubic-bezier) */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.hidden {
  display: none !important;
}

/* ── 3. Shared Components ─────────────────────────────────────────────────── */

/* Wordmark */
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
}

.wordmark-mark {
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
}

.wordmark-text {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ink);
}

/* Primary Button */
.btn-primary,
.nb-primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 24px;
  background-color: var(--ink);
  color: var(--bg);
  border-radius: var(--radius-pill);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: opacity 160ms cubic-bezier(0.16, 1, 0.3, 1), transform 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-primary:hover,
.nb-primary-btn:hover {
  opacity: 0.92;
}

.btn-primary:active,
.nb-primary-btn:active {
  transform: scale(0.985);
}

/* Secondary Button */
.btn-secondary,
.nb-secondary-btn,
.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 22px;
  background-color: transparent;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 160ms cubic-bezier(0.16, 1, 0.3, 1), border-color 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-secondary:hover,
.nb-secondary-btn:hover,
.secondary-btn:hover {
  background-color: var(--surface-2);
  border-color: var(--ink-2);
}

/* Icon Button */
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink);
  border: none;
  cursor: pointer;
  transition: background-color 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.icon-button:hover {
  background-color: var(--surface-2);
}

/* Text Button */
.text-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 4px;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.text-button:hover {
  color: var(--muted);
}

/* Key Hint */
.key-hint {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 2px 5px;
  line-height: 1;
}

@media (max-width: 640px) {
  .key-hint {
    display: none !important;
  }
}

/* Segmented Control */
.segmented {
  display: inline-flex;
  align-items: center;
  background-color: var(--surface-2);
  padding: 3px;
  border-radius: 13px;
  width: 100%;
}

.segmented button,
.mode-button,
.theme-seg-btn {
  flex: 1;
  min-height: 38px;
  border-radius: 10px;
  font-family: var(--font-ui);
  font-size: 13.5px;
  font-weight: 400;
  color: var(--ink-2);
  background: transparent;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 160ms cubic-bezier(0.16, 1, 0.3, 1), color 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.segmented button.selected,
.mode-button.selected,
.theme-seg-btn.selected,
.segmented button[aria-pressed="true"] {
  background-color: var(--surface);
  color: var(--ink);
  font-weight: 500;
  box-shadow: var(--shadow-subtle);
}

:root[data-resolved-theme="dark"] .segmented button.selected,
:root[data-resolved-theme="dark"] .mode-button.selected,
:root[data-resolved-theme="dark"] .theme-seg-btn.selected {
  background-color: #2D2D30;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

/* Range Input */
input[type="range"].range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  background: var(--line);
  border-radius: 999px;
  outline: none;
  margin: 10px 0;
  accent-color: var(--ink);
}

input[type="range"].range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-thumb);
  border: none;
}

input[type="range"].range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ink);
  cursor: pointer;
  border: none;
  box-shadow: var(--shadow-thumb);
}

/* File Badge */
.doc-badge,
.nb-file-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 42px;
  padding: 0 6px;
  border-radius: 6px;
  background-color: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Hairline Progress */
.progress-hairline {
  width: 56px;
  height: 3px;
  background-color: var(--line);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}

.progress-hairline-fill {
  height: 100%;
  background-color: var(--ink);
  border-radius: 999px;
}

/* Eyebrow Label */
.eyebrow,
.welcome-eyebrow,
.nb-eyebrow {
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--sab) + 24px);
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background-color: #15140F;
  color: #FAF9F5;
  padding: 12px 20px;
  border-radius: 14px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-float);
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms cubic-bezier(0.16, 1, 0.3, 1), transform 180ms cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 90vw;
  text-align: center;
}

:root[data-resolved-theme="dark"] .toast {
  background-color: #222225;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.55);
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

/* ── 4. Home View (#welcome) ──────────────────────────────────────────────── */
.welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px calc(var(--sab) + 40px);
  width: 100%;
}

.welcome-inner {
  width: 100%;
  max-width: 1040px;
  display: flex;
  flex-direction: column;
  gap: 36px;
}

/* Top bar row */
.welcome-topbar {
  width: 100%;
  max-width: 1040px;
  padding: 24px 0 16px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.welcome-wordmark {
  justify-self: start;
}

.welcome-nav-pill-group {
  justify-self: center;
}

.welcome-topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  justify-self: end;
  gap: 6px;
}

.topbar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  min-width: 42px;
  min-height: 42px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: transparent;
  transition: background-color 160ms cubic-bezier(0.16, 1, 0.3, 1), transform 160ms ease;
  position: relative;
  text-decoration: none;
}

.topbar-icon-btn:hover {
  background-color: var(--surface-2);
}

.topbar-icon-btn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.topbar-icon-btn .nav-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  min-width: 14px;
  height: 14px;
  padding: 0 3px;
  border-radius: var(--radius-pill);
  background-color: var(--accent);
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--bg);
  pointer-events: none;
  line-height: 1;
}

.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  background: transparent;
  transition: background-color 160ms cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.topbar-btn:hover {
  background-color: var(--surface-2);
}

.topbar-theme-btn {
  margin-left: 2px;
}

/* Hero Section */
.welcome-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
  padding: 20px 0 10px;
}

.welcome-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background-color: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.welcome-badge-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent);
  box-shadow: 0 0 8px rgba(181, 121, 47, 0.5);
}

.welcome-display-title {
  font-family: var(--font-display);
  font-size: clamp(38px, 6.5vw, 68px);
  font-weight: 400;
  line-height: 1.05;
  letter-spacing: -0.03em;
  color: var(--ink);
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 820px;
}

.welcome-subtitle {
  font-size: clamp(16px, 2vw, 18.5px);
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 580px;
  margin: 0 auto;
}

/* Minimal Hero Action Area (Apple Liquid Drop Card) */
.welcome-action-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 24px;
  background: var(--liquid-card-bg);
  backdrop-filter: var(--liquid-blur);
  -webkit-backdrop-filter: var(--liquid-blur);
  border: 1px solid var(--liquid-glass-border);
  box-shadow: var(--liquid-specular);
  border-radius: var(--apple-squircle-xl);
  padding: 40px 32px 34px;
  max-width: 520px;
  width: 100%;
  box-sizing: border-box;
  gap: 16px;
  transition: transform 0.25s var(--apple-ease), box-shadow 0.25s var(--apple-ease), border-color 0.25s ease;
}

.welcome-action-area:hover {
  border-color: var(--liquid-glass-border);
  box-shadow: var(--liquid-specular), 0 16px 40px rgba(0, 0, 0, 0.08);
}

.welcome-action-icon-wrap {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: var(--liquid-pill-bg);
  border: 1px solid var(--liquid-glass-border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  box-shadow: var(--liquid-specular-sm);
  transition: transform 0.25s var(--apple-ease);
}

.welcome-action-area:hover .welcome-action-icon-wrap {
  transform: translateY(-2px) scale(1.05);
}

.welcome-primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 52px;
  padding: 0 34px;
  background-color: var(--ink);
  color: var(--bg);
  border-radius: var(--radius-pill);
  font-size: 15px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(21, 20, 15, 0.16);
  transition: transform 160ms var(--apple-ease), box-shadow 160ms ease, opacity 160ms ease;
}

.welcome-primary-btn:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 8px 24px rgba(21, 20, 15, 0.22);
  opacity: 0.96;
}

.welcome-primary-btn:active {
  transform: scale(0.96);
}

.welcome-drop-caption {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

/* Continue reading section */
.continue-reading-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.continue-reading-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.continue-reading-card {
  background: var(--liquid-card-bg);
  backdrop-filter: var(--liquid-blur);
  -webkit-backdrop-filter: var(--liquid-blur);
  border: 1px solid var(--liquid-glass-border);
  border-radius: var(--apple-squircle-lg);
  box-shadow: var(--liquid-specular-sm);
  overflow: hidden;
}

.continue-reading-items {
  display: flex;
  flex-direction: column;
}

.continue-reading-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 64px;
  padding: 14px 20px;
  width: 100%;
  text-align: left;
  border-bottom: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  transition: background-color 160ms var(--apple-ease), transform 160ms var(--apple-ease);
}

.continue-reading-row:last-child {
  border-bottom: none;
}

.continue-reading-row:hover {
  background-color: var(--liquid-pill-bg);
}

.continue-row-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.continue-row-name {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.continue-row-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: var(--muted);
}

.continue-row-time {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* Topbar Segmented Pill Navigation */
.welcome-nav-pill-group {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 4px 6px;
}

@media (max-width: 680px) {
  .welcome-topbar {
    display: flex;
    justify-content: space-between;
  }
  .welcome-nav-pill-group {
    display: none;
  }
}

.nav-pill-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  transition: all 140ms ease;
}

.nav-pill-item:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.nav-pill-item.active {
  color: var(--ink);
  background: var(--surface-2);
  font-weight: 600;
}

/* Pretitle & Hero Refinements */
.welcome-pretitle {
  font-size: 14px;
  color: var(--muted);
  letter-spacing: -0.01em;
  margin-bottom: -6px;
}

.drop-circle-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  margin-bottom: 2px;
}

.drop-card-divider {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 480px;
  margin: 4px auto;
  gap: 14px;
}

.divider-line {
  flex: 1;
  height: 1px;
  background: var(--line);
}

.divider-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-transform: uppercase;
}

/* Tactile Pill Buttons */
.welcome-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, background-color 140ms ease;
}

.welcome-pill-btn.white-pill {
  background: #FFFFFF;
  color: #121214;
  border: none;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.welcome-pill-btn.white-pill:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.welcome-pill-btn.dark-pill {
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line-strong);
}

.welcome-pill-btn.dark-pill:hover {
  background: var(--surface);
  border-color: var(--ink);
  transform: translateY(-1px);
}

/* Two-column Bottom Section (Continue Reading & Quick Features) */
.welcome-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  align-items: start;
}

@media (max-width: 820px) {
  .welcome-bottom-grid {
    grid-template-columns: 1fr;
  }
}

.welcome-section-title {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
}

.continue-reading-empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 32px 20px;
  color: var(--muted);
  font-size: 13.5px;
  text-align: center;
}

.quick-features-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.02);
}

.quick-features-header {
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 4px 2px;
}

.quick-features-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.quick-feature-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--ink);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: background-color 140ms ease, transform 140ms ease;
  border: 1px solid transparent;
  cursor: pointer;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
}

.quick-feature-row:hover {
  background: var(--surface);
  border-color: var(--line-strong);
  transform: translateX(2px);
}

.quick-feature-label-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quick-feature-chevron {
  color: var(--muted);
  flex-shrink: 0;
}

/* Privacy lock line */
.welcome-privacy-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  padding: 4px 0;
}

.welcome-privacy-line svg {
  color: var(--muted);
}

/* Collapsed SEO details */
.welcome-seo-details {
  border-top: 1px solid var(--line);
  padding-top: 24px;
  margin-top: 12px;
  color: var(--ink-2);
  font-size: 13.5px;
}

.welcome-seo-summary {
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  user-select: none;
  margin-bottom: 12px;
}

.welcome-seo-details article {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 8px;
  line-height: 1.6;
}

.welcome-seo-details h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  margin-top: 8px;
}

.welcome-seo-details ul {
  padding-left: 20px;
}

/* Footer */
.welcome-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 32px 0 16px;
  font-size: 13px;
  color: var(--muted);
}

.welcome-foot-link {
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  transition: color 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.welcome-foot-link:hover {
  color: var(--ink);
}

.welcome-foot-copy {
  margin-left: auto;
}

/* Mobile Bottom Nav */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: var(--bg);
  border-top: 1px solid var(--line);
  padding-bottom: calc(var(--sab) + 6px);
  z-index: 100;
}

.mobile-nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 52px;
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 500;
}

.mobile-nav-item:active,
.mobile-nav-item.active {
  color: var(--ink);
}

/* ── 5. Document Reader View (#reader) ────────────────────────────────────── */
.reader {
  position: fixed;
  inset: 0;
  display: flex;
  background-color: var(--reader-bg);
  z-index: 50;
  overflow: hidden;
}

/* Two-column layout on desktop >= 1100px */
.reading-surface {
  flex: 1;
  min-width: 0;
  height: 100dvh;
  overflow-y: scroll;
  scrollbar-gutter: stable;
  overflow-x: auto;
  display: block;
  position: relative;
  scroll-behavior: auto;
  padding: 60px 24px calc(var(--sab) + 130px);
  box-sizing: border-box;
}

/* Document Header Bar */
.doc-title,
#doc-title {
  position: fixed;
  top: calc(var(--sat) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(-140%);
  opacity: 0;
  pointer-events: none;
  height: 42px;
  padding: 0 8px 0 12px;
  background: var(--liquid-glass-bg);
  backdrop-filter: var(--liquid-blur);
  -webkit-backdrop-filter: var(--liquid-blur);
  border: 1px solid var(--liquid-glass-border);
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  z-index: 85;
  box-shadow: var(--liquid-specular);
  max-width: min(580px, calc(100vw - 24px - var(--sal) - var(--sar)));
  width: auto;
  transition: transform 260ms var(--apple-ease), opacity 200ms ease;
}

.doc-title.top-bar-visible,
#doc-title.top-bar-visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
  z-index: 95;
}

:root[data-resolved-theme="dark"] .doc-title,
:root[data-resolved-theme="dark"] #doc-title {
  background: var(--liquid-glass-bg);
  border-color: var(--liquid-glass-border);
  box-shadow: var(--liquid-specular);
}

.doc-title-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.doc-title-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.reader-top-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  width: 32px;
  padding: 0;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms ease;
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
}

.reader-top-action-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line-strong);
}

.reader-top-action-btn.active {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: var(--accent);
}

.reader-top-action-btn.icon-only {
  width: 32px;
  height: 32px;
  padding: 0;
  justify-content: center;
}

.reader-top-action-btn.convert-txt-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.reader-top-action-btn.convert-txt-pill-btn.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.reader-top-action-btn.convert-txt-pill-btn.active svg {
  stroke: var(--bg);
}

.reader-top-action-btn .header-hl-indicator {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--hl, #f3d56b);
  border: 1px solid var(--surface);
  display: inline-block;
}

.reader-top-action-btn .header-notes-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--accent);
  border: 1px solid var(--surface);
  display: inline-block;
}

.doc-title-text {
  flex: 1;
  min-width: 0;
  max-width: clamp(120px, 40vw, 360px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.doc-page-chip {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  flex-shrink: 0;
  border: 1px solid var(--line);
}

.doc-title-back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-left: -6px;
  border-radius: var(--radius-pill);
  border: none;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 150ms ease, color 150ms ease, transform 150ms ease;
}

.doc-title-back-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
  transform: translateX(-1px);
}

.doc-title-back-btn:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

/* Paper Surface */
.paper {
  background-color: var(--paper);
  color: var(--paper-ink);
  width: fit-content;
  max-width: none;
  min-width: min-content;
  box-shadow: var(--shadow-paper);
  border-radius: 4px;
  margin: 0 auto;
  display: block;
  filter: brightness(var(--paper-brightness, 1));
  transition: filter 160ms cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  cursor: text;
}

.page-node,
.document-page {
  position: relative;
  width: fit-content;
  max-width: none;
  margin: 0 auto 24px;
  display: block;
  cursor: text;
}

.document-page.pdf-page {
  width: calc(var(--page-w, 600px) * var(--doc-zoom, 1)) !important;
  height: calc(var(--page-h, 800px) * var(--doc-zoom, 1)) !important;
  margin: 0 auto 24px;
  box-sizing: border-box;
}

#reader.is-zooming #reading-surface {
  scroll-behavior: auto !important;
}

#reader.is-zooming .textLayer {
  pointer-events: none;
}

.document-page.docx-page {
  width: 100%;
  max-width: 820px;
}

.page-node canvas,
.document-page canvas {
  display: block;
  max-width: none;
  height: auto;
}

.document-page.pdf-page canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* PDF.js Text Layer */
.textLayer {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  overflow: hidden;
  opacity: 1;
  line-height: 1;
  -webkit-text-size-adjust: none;
  -moz-text-size-adjust: none;
  text-size-adjust: none;
  forced-color-adjust: none;
  transform-origin: 0 0;
  z-index: 4;
  cursor: text !important;
  pointer-events: auto !important;
  user-select: text !important;
  -webkit-user-select: text !important;
}

.textLayer span,
.textLayer br {
  color: transparent !important;
  position: absolute;
  white-space: pre;
  cursor: text !important;
  transform-origin: 0% 0%;
  user-select: text !important;
  -webkit-user-select: text !important;
}

/* Beautiful High-Contrast Selection (Light & Dark) */
::selection {
  background: rgba(243, 195, 45, 0.58) !important;
  color: inherit;
}

.textLayer ::selection,
.textLayer *::selection,
.textLayer span::selection {
  background: rgba(243, 195, 45, 0.62) !important;
  color: transparent !important;
}

:root[data-resolved-theme="dark"] ::selection {
  background: rgba(243, 213, 107, 0.48) !important;
  color: inherit;
}

:root[data-resolved-theme="dark"] .textLayer ::selection,
:root[data-resolved-theme="dark"] .textLayer *::selection,
:root[data-resolved-theme="dark"] .textLayer span::selection {
  background: rgba(243, 213, 107, 0.58) !important;
  color: transparent !important;
}

/* Document Highlighting System */
.text-highlight-wrap {
  position: absolute;
  inset: 0;
  pointer-events: none !important;
  z-index: 3;
}

.text-highlight-band {
  position: absolute;
  background-color: rgba(243, 213, 107, 0.52);
  border-radius: 3px;
  pointer-events: none !important;
  mix-blend-mode: multiply;
  transition: background-color 150ms ease;
}

.text-highlight-band.hl-amber { background-color: rgba(243, 213, 107, 0.52); }
.text-highlight-band.hl-green { background-color: rgba(130, 215, 140, 0.48); }
.text-highlight-band.hl-blue  { background-color: rgba(125, 190, 255, 0.48); }
.text-highlight-band.hl-rose  { background-color: rgba(255, 145, 175, 0.48); }

:root[data-resolved-theme="dark"] .text-highlight-band {
  background-color: rgba(243, 213, 107, 0.4);
  mix-blend-mode: screen;
}
:root[data-resolved-theme="dark"] .text-highlight-band.hl-amber { background-color: rgba(243, 213, 107, 0.4); }
:root[data-resolved-theme="dark"] .text-highlight-band.hl-green { background-color: rgba(130, 215, 140, 0.38); }
:root[data-resolved-theme="dark"] .text-highlight-band.hl-blue  { background-color: rgba(125, 190, 255, 0.38); }
:root[data-resolved-theme="dark"] .text-highlight-band.hl-rose  { background-color: rgba(255, 145, 175, 0.38); }

.highlight-box {
  position: absolute;
  background-color: rgba(243, 213, 107, 0.42);
  border: 1.5px solid rgba(220, 175, 40, 0.85);
  border-radius: 4px;
  pointer-events: none;
  z-index: 7;
  mix-blend-mode: multiply;
  transition: none !important;
}

.highlight-box.hl-amber { background-color: rgba(243, 213, 107, 0.42); border-color: rgba(220, 175, 40, 0.85); }
.highlight-box.hl-green { background-color: rgba(130, 215, 140, 0.40); border-color: rgba(90, 185, 105, 0.85); }
.highlight-box.hl-blue  { background-color: rgba(125, 190, 255, 0.40); border-color: rgba(80, 155, 230, 0.85); }
.highlight-box.hl-rose  { background-color: rgba(255, 145, 175, 0.40); border-color: rgba(235, 105, 140, 0.85); }

:root[data-resolved-theme="dark"] .highlight-box {
  background-color: rgba(243, 213, 107, 0.32);
  border-color: rgba(243, 213, 107, 0.7);
  mix-blend-mode: screen;
  transition: none !important;
}
:root[data-resolved-theme="dark"] .highlight-box.hl-amber { background-color: rgba(243, 213, 107, 0.32); border-color: rgba(243, 213, 107, 0.7); }
:root[data-resolved-theme="dark"] .highlight-box.hl-green { background-color: rgba(130, 215, 140, 0.30); border-color: rgba(130, 215, 140, 0.7); }
:root[data-resolved-theme="dark"] .highlight-box.hl-blue  { background-color: rgba(125, 190, 255, 0.30); border-color: rgba(125, 190, 255, 0.7); }
:root[data-resolved-theme="dark"] .highlight-box.hl-rose  { background-color: rgba(255, 145, 175, 0.30); border-color: rgba(255, 145, 175, 0.7); }

.highlight-box.highlight-drawing {
  border-style: dashed;
  will-change: left, top, width, height;
  contain: layout style;
  pointer-events: none;
}

/* Reflowed Word DOCX text typography & Book Page Proportions */
.document-page.docx-page {
  width: 100%;
  max-width: 820px;
  margin: 32px auto 64px;
  background: var(--paper-bg, #ffffff);
  color: var(--paper-ink, #212529);
  border: 1px solid var(--line, rgba(0, 0, 0, 0.08));
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05), 0 1px 3px rgba(0, 0, 0, 0.03);
  padding: 64px 72px 96px;
  box-sizing: border-box;
  font-family: var(--font-serif, "Newsreader", Georgia, serif);
  font-size: 18px;
  line-height: 1.8;
  letter-spacing: 0.005em;
  position: relative;
  zoom: var(--doc-zoom, 1);
  transform-origin: top center;
}

:root[data-resolved-theme="dark"] .document-page.docx-page {
  background: var(--paper-bg, #1a1b1e);
  color: var(--paper-ink, #e6edf3);
  border-color: var(--line, rgba(255, 255, 255, 0.08));
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

.document-page.docx-page p {
  margin: 0 0 1.25em;
  line-height: 1.8;
}

.document-page.docx-page h1 {
  font-family: var(--font-serif, "Newsreader", Georgia, serif);
  font-size: 1.85em;
  font-weight: 700;
  line-height: 1.25;
  margin: 1.8em 0 0.6em;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.document-page.docx-page h1:first-child {
  margin-top: 0.2em;
}

.document-page.docx-page h2 {
  font-family: var(--font-serif, "Newsreader", Georgia, serif);
  font-size: 1.45em;
  font-weight: 600;
  line-height: 1.35;
  margin: 1.6em 0 0.6em;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
}

.document-page.docx-page h3 {
  font-family: var(--font-serif, "Newsreader", Georgia, serif);
  font-size: 1.2em;
  font-weight: 600;
  line-height: 1.4;
  margin: 1.4em 0 0.5em;
  color: var(--ink);
}

.document-page.docx-page ul,
.document-page.docx-page ol {
  padding-left: 28px;
  margin: 0 0 1.25em;
}

.document-page.docx-page li {
  margin: 0.4em 0;
  line-height: 1.7;
}

.document-page.docx-page strong,
.document-page.docx-page b {
  font-weight: 600;
  color: var(--ink);
}

.document-page.docx-page blockquote {
  margin: 1.5em 0;
  padding: 12px 20px;
  border-left: 3px solid var(--accent);
  background: var(--surface);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
}

/* Text Selection Highlights */
::selection {
  background: var(--hl);
  color: #15140F;
}

:root[data-resolved-theme="dark"] ::selection {
  background: var(--hl-dark-bg);
  color: var(--hl-dark-ink);
}

.highlight-span {
  background-color: var(--hl);
  border-radius: 2px;
}

:root[data-resolved-theme="dark"] .highlight-span {
  background-color: var(--hl-dark-bg);
  color: var(--hl-dark-ink);
}

/* Selection Tooltip */
.selection-tooltip {
  position: fixed;
  z-index: 150;
  background-color: var(--ink);
  color: var(--bg);
  border-radius: 14px;
  padding: 4px;
  display: flex;
  align-items: center;
  gap: 2px;
  box-shadow: var(--shadow-float);
  transform: translate(-50%, -100%);
  transition: opacity 160ms cubic-bezier(0.16, 1, 0.3, 1), transform 160ms cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

.selection-tooltip.tooltip-below {
  transform: translate(-50%, 0);
}

/* Highlighter Mode: Text Highlight Mode */
#reading-surface.highlighting-mode {
  user-select: text;
  -webkit-user-select: text;
}

#reading-surface.highlighting-mode .textLayer {
  pointer-events: auto !important;
  user-select: text !important;
  -webkit-user-select: text !important;
  cursor: text;
}

/* Freehand Drawing Mode (Only when Draw Box submode is active) */
#reading-surface.highlighting-mode.highlighting-mode-draw {
  cursor: crosshair !important;
  user-select: none !important;
  -webkit-user-select: none !important;
  touch-action: none !important;
}

#reading-surface.highlighting-mode.highlighting-mode-draw .document-page,
#reading-surface.highlighting-mode.highlighting-mode-draw .paper {
  cursor: crosshair !important;
  touch-action: none !important;
}

#reading-surface.highlighting-mode.highlighting-mode-draw .textLayer {
  pointer-events: none !important;
  user-select: none !important;
  -webkit-user-select: none !important;
}

/* Notebook Mode: Hide standalone floating doc-title chip */
.reader.in-notebook-mode #doc-title {
  display: none !important;
}

/* Empty Notebook State in Reader */
.notebook-reader-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 56px 28px;
  max-width: 480px;
  margin: 40px auto;
  background: var(--surface);
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-subtle);
}

.notebook-reader-empty-icon {
  color: var(--accent);
  margin-bottom: 16px;
}

.notebook-reader-empty-title {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 500;
  color: var(--ink);
  margin-bottom: 8px;
}

.notebook-reader-empty-desc {
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.55;
  margin-bottom: 16px;
}

.tooltip-btn {
  height: 36px;
  padding: 0 12px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  border: none;
  cursor: pointer;
}

.tooltip-btn:hover {
  background-color: rgba(255, 255, 255, 0.15);
}

.tooltip-hl-swatch,
.tooltip-swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--hl);
  border: 1px solid rgba(0, 0, 0, 0.2);
}

/* Active Highlighter & Drawing Ribbon */
.highlight-bar {
  position: fixed;
  top: calc(var(--sat) + 68px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 180;
  background: var(--liquid-glass-bg);
  backdrop-filter: var(--liquid-blur);
  -webkit-backdrop-filter: var(--liquid-blur);
  border: 1px solid var(--liquid-glass-border);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  box-shadow: var(--liquid-specular);
  max-width: calc(100vw - 24px);
}

:root[data-resolved-theme="dark"] .highlight-bar {
  background: var(--liquid-glass-bg);
  border-color: var(--liquid-glass-border);
  box-shadow: var(--liquid-specular);
}

.hl-bar-pill-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.hl-bar-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--accent);
  padding-right: 6px;
  border-right: 1px solid var(--line);
}

.hl-mode-switcher {
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  padding: 2px;
  border-radius: var(--radius-pill);
  gap: 2px;
}

.hl-mode-btn {
  border: none;
  background: transparent;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  transition: all 140ms ease;
}

.hl-mode-btn:hover {
  color: var(--ink);
}

.hl-mode-btn.active {
  background: var(--bg);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  font-weight: 600;
}

.hl-color-palette {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
}

.hl-color-btn {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--c);
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease;
}

.hl-color-btn:hover {
  transform: scale(1.15);
}

.hl-color-btn.active {
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--c);
  transform: scale(1.12);
}

.hl-bar-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hl-bar-action-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 140ms ease;
}

.hl-bar-action-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.hl-bar-done-btn {
  border: none;
  background: var(--ink);
  color: var(--bg);
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 140ms ease;
}

.hl-bar-done-btn:hover {
  opacity: 0.9;
}

.hl-bar-instruction {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

/* Bottom-Center Reader Dock (Apple Liquid Style) */
.reader-dock {
  position: fixed;
  bottom: calc(var(--sab) + 20px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  background: var(--liquid-glass-bg);
  backdrop-filter: var(--liquid-blur);
  -webkit-backdrop-filter: var(--liquid-blur);
  border: 1px solid var(--liquid-glass-border);
  border-radius: var(--radius-pill);
  padding: 5px 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: var(--liquid-specular);
  transition: transform 300ms var(--apple-ease), opacity 300ms var(--apple-ease);
  max-width: min(560px, calc(100vw - 20px - var(--sal) - var(--sar)));
  will-change: transform, opacity;
}

.reader-dock.dock-hidden {
  transform: translateX(-50%) translateY(24px) scale(0.96);
  opacity: 0;
  pointer-events: none;
}

.dock-sep {
  width: 1px;
  height: 22px;
  background-color: var(--line);
  margin: 0 4px;
  opacity: 0.6;
}

.reader-dock .dock-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
  border: none;
  background: transparent;
  cursor: pointer;
  transition: background-color 160ms var(--apple-ease), color 160ms ease, transform 160ms var(--apple-ease);
}

.reader-dock .dock-btn:hover {
  background-color: var(--liquid-pill-bg);
  color: var(--ink);
}

.reader-dock .dock-btn:active {
  transform: scale(0.90);
}

.reader-dock .dock-btn.active,
#control-toggle.active {
  background-color: var(--ink);
  color: var(--bg);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* In-Document Search Box */
.search-box {
  position: fixed;
  bottom: calc(var(--sab) + 80px);
  left: 50%;
  transform: translateX(-50%);
  width: min(420px, calc(100vw - 32px));
  background: var(--liquid-glass-bg);
  backdrop-filter: var(--liquid-blur);
  -webkit-backdrop-filter: var(--liquid-blur);
  border: 1px solid var(--liquid-glass-border);
  border-radius: var(--apple-squircle-md);
  box-shadow: var(--liquid-specular);
  padding: 12px;
  z-index: 85;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 180ms var(--apple-ease), opacity 180ms ease;
}

.search-box.hidden {
  display: none;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  height: 42px;
  border: 1px solid transparent;
}

.search-input-wrap:focus-within {
  border-color: var(--ink);
}

.search-input-wrap input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 14.5px;
  font-family: var(--font-ui);
  outline: none;
}

.search-icon {
  color: var(--muted);
  flex-shrink: 0;
}

.search-results {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.search-result-item {
  padding: 8px 10px;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  text-align: left;
  border: none;
  font-family: var(--font-ui);
  transition: background 120ms ease;
}

.search-result-item:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.search-meta-msg {
  padding: 10px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

/* Live Zoom Percentage Indicator Pill */
.zoom-indicator-pill {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(21, 20, 15, 0.88);
  color: #FFFFFF;
  font-family: var(--font-ui);
  font-size: 15px;
  font-weight: 500;
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-float);
  z-index: 100;
  pointer-events: none;
  opacity: 1;
  transition: opacity 250ms ease;
}

:root[data-resolved-theme="dark"] .zoom-indicator-pill {
  background: rgba(255, 255, 255, 0.92);
  color: #111111;
}

.zoom-indicator-pill.fading {
  opacity: 0;
}

/* Password Unlock Form */
.pdf-password-card {
  max-width: 420px;
  margin: 40px auto;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-subtle);
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
}

.pdf-password-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  margin: 0;
}

.pdf-password-desc {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.pdf-password-row {
  display: flex;
  gap: 8px;
}

.pdf-password-input {
  flex: 1;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 14px;
  outline: none;
}

.pdf-password-input:focus {
  border-color: var(--ink);
}

.pdf-password-error {
  font-size: 12.5px;
  color: var(--danger);
}

/* Page Render Error Slot */
.page-render-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  background: var(--surface-2);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-md);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

/* ── 6. Controls Panel (#controls) ────────────────────────────────────────── */
.controls {
  width: 344px;
  height: 100dvh;
  background-color: var(--bg);
  border-left: 1px solid var(--line);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow-y: auto;
  z-index: 90;
  flex-shrink: 0;
  transition: transform 180ms cubic-bezier(0.16, 1, 0.3, 1), opacity 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Panel Row 1: Page Readout */
.control-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.page-readout {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.page-readout strong,
#page-current {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 400;
  color: var(--ink);
  line-height: 1;
}

.page-readout .slash,
.page-readout-slash {
  display: inline;
  font-size: 15px;
  color: var(--muted);
}

.page-readout-of,
#page-total {
  font-size: 16px;
  color: var(--muted);
  font-weight: 500;
}

#close-controls {
  align-self: flex-start;
}

/* Panel Row 2: Page Slider */
.page-range {
  margin: -6px 0 0;
}

/* Panel Row 3: Zoom */
.control-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.control-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
}

.zoom-stepper-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.zoom-step-btn {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  font-size: 18px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.zoom-step-btn:hover {
  background-color: var(--surface-2);
}

.zoom-value-btn {
  flex: 1;
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--ink);
  font-size: 14.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.zoom-value-btn:hover {
  background-color: var(--surface-2);
}

.zoom-chips-row,
.zoom-fit-chips {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.chip-btn {
  flex: 1;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 160ms cubic-bezier(0.16, 1, 0.3, 1), border-color 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.chip-btn:hover {
  background-color: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--ink);
}

.zoom-hint {
  font-size: 12px;
  color: var(--muted);
}

/* Panel Details Rows (Table of contents, Bookmarks, Highlights) */
.control-rows-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.panel-row-details {
  border-bottom: 1px solid var(--line);
}

.panel-row-summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  list-style: none;
  padding: 0 2px;
  user-select: none;
  transition: color 150ms ease;
}

.panel-row-summary::-webkit-details-marker {
  display: none;
}

.panel-row-summary::marker {
  display: none;
  content: "";
}

.panel-row-summary:hover {
  color: var(--accent);
}

.panel-row-summary .chevron-icon {
  color: var(--muted);
  transition: transform 180ms cubic-bezier(0.16, 1, 0.3, 1), color 150ms ease;
  flex-shrink: 0;
}

.panel-row-details[open] .panel-row-summary .chevron-icon {
  transform: rotate(90deg);
  color: var(--ink);
}

.bookmark-list,
.outline-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0 12px;
  max-height: 220px;
  overflow-y: auto;
}

.bookmark-item,
.outline-item {
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--ink-2);
  cursor: pointer;
  text-align: left;
  transition: background-color 140ms ease, color 140ms ease;
}

.bookmark-item:hover,
.outline-item:hover {
  background-color: var(--surface-2);
  color: var(--ink);
}

.highlights-panel-content {
  padding: 4px 2px 14px;
}

.highlights-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 8px;
}

.highlights-empty-summary {
  font-size: 12.5px;
  color: var(--muted);
  padding: 6px 2px;
}

.highlight-summary-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 34px;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background-color 140ms ease;
}

.highlight-summary-item:hover {
  background-color: var(--surface-2);
}

.highlight-summary-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  text-align: left;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-size: 13px;
  color: var(--ink);
  overflow: hidden;
}

.highlight-summary-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.highlight-summary-dot.hl-amber { background-color: #f3d56b; }
.highlight-summary-dot.hl-green { background-color: #9dd9a3; }
.highlight-summary-dot.hl-blue  { background-color: #92c7f7; }
.highlight-summary-dot.hl-rose  { background-color: #f7a6b8; }

.highlight-summary-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.highlight-summary-page {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  flex-shrink: 0;
}

/* Paper Tint Variants */
.tint-segmented {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  padding: 3px;
  border-radius: var(--radius-sm);
}

.tint-seg-btn {
  flex: 1;
  height: 34px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 9px;
  border: none;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}

.tint-seg-btn.selected {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-subtle);
  font-weight: 600;
}

:root[data-paper-tint="sepia"] {
  --paper: #F8F1E5;
  --paper-ink: #3B3224;
}
:root[data-paper-tint="sepia"] .paper {
  background-color: #F8F1E5 !important;
  color: #3B3224 !important;
}

:root[data-paper-tint="sage"] {
  --paper: #EFEFE9;
  --paper-ink: #28302B;
}
:root[data-paper-tint="sage"] .paper {
  background-color: #EFEFE9 !important;
  color: #28302B !important;
}

:root[data-paper-tint="smart-dark"] .paper {
  filter: invert(0.92) hue-rotate(180deg) brightness(var(--paper-brightness, 1)) !important;
}

/* Panel Row 7: Legacy link row */
.panel-link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 44px;
  padding: 0 4px;
  width: 100%;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
}

.panel-link-row:hover {
  color: var(--muted);
}

.panel-row-count {
  font-size: 12.5px;
  color: var(--muted);
  margin-left: auto;
  margin-right: 8px;
}

/* Panel Bottom Action Block */
.control-bottom-block,
.control-actions-block {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.btn-primary.btn-block,
.btn-primary-block {
  width: 100%;
  min-height: 44px;
  background-color: var(--ink);
  color: var(--bg);
  border-radius: var(--radius-pill);
  font-size: 13.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: none;
  transition: opacity 160ms cubic-bezier(0.16, 1, 0.3, 1), transform 140ms ease;
}

.btn-primary.btn-block:hover,
.btn-primary-block:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.control-trio-row,
.action-trio {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.btn-secondary.trio-btn,
.action-trio .secondary-btn {
  min-height: 38px;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease;
  white-space: nowrap;
}

.btn-secondary.trio-btn:hover,
.action-trio .secondary-btn:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--ink);
}

.controls-privacy-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

.privacy-note {
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
}

.clear-data-btn,
.clear-data-text-btn {
  font-size: 11.5px;
  color: var(--muted);
  text-decoration: underline;
  background: none;
  border: none;
  cursor: pointer;
  margin: 0 auto;
  transition: color 150ms ease;
}

.clear-data-btn:hover,
.clear-data-text-btn:hover {
  color: var(--danger);
}

/* ── 7. Notebook Reader Chrome (inside #reader) ───────────────────────────── */
.notebook-tabs-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  transform: translateY(-110%);
  opacity: 0;
  pointer-events: none;
  background-color: var(--bg);
  border-bottom: 1px solid var(--line);
  padding: calc(var(--sat) + 8px) 16px 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 210;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: transform 260ms cubic-bezier(0.16, 1, 0.3, 1), opacity 200ms ease;
}

.notebook-tabs-bar.top-bar-visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.notebook-tab-items {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
  min-width: 0;
}

.notebook-tab-items::-webkit-scrollbar {
  display: none;
}

.notebook-tab {
  height: 38px;
  padding: 0 12px 0 14px;
  border-radius: 10px;
  background-color: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  max-width: 220px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 160ms cubic-bezier(0.16, 1, 0.3, 1);
  flex-shrink: 0;
}

.notebook-tab:hover {
  border-color: var(--line-strong);
  color: var(--ink);
  background-color: var(--surface-2);
  transform: translateY(-1px);
}

.notebook-tab.active {
  background-color: var(--ink);
  border-color: var(--ink);
  color: var(--bg);
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.notebook-tab-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notebook-tab-close {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: inherit;
  opacity: 0.6;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  transition: opacity 150ms ease, background-color 150ms ease;
}

.notebook-tab-close:hover {
  opacity: 1;
  background-color: rgba(255, 255, 255, 0.2);
}

.notebook-tab-action-btn {
  height: 38px;
  min-width: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  cursor: pointer;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.notebook-tab-action-btn:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--ink);
  transform: translateY(-1px);
}

.notebook-tab-action-btn.active,
.notebook-tab-action-btn:active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.binder-btn-text {
  font-weight: 500;
}

@media (max-width: 768px) {
  .notebook-tabs-bar {
    padding: calc(var(--sat) + 6px) 10px 6px;
    gap: 6px;
  }

  /* Keep upper bar strictly for documents on mobile - hide all action tool clutter */
  #notebook-add-file-btn,
  #notebook-binder-toggle-btn,
  #nb-tab-hl-btn,
  #nb-tab-focus-btn,
  #nb-tab-download-btn {
    display: none !important;
  }

  #notebook-exit-link {
    width: 32px;
    min-width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 8px;
    flex-shrink: 0;
  }

  .notebook-tab-items {
    flex: 1 1 auto;
    min-width: 0;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
  }

  .notebook-tab {
    height: 32px;
    padding: 0 12px;
    border-radius: 8px;
    font-size: 12.5px;
    max-width: 170px;
    flex-shrink: 0;
  }

  /* Prevent accidental deletion of tabs on small touchscreens */
  .notebook-tab .notebook-tab-close {
    display: none !important;
  }
}

/* ── Binder & Scratchpad Sidebar Drawer Panel ───────────────────────────── */
.notebook-binder-panel {
  position: fixed;
  top: calc(var(--sat) + 54px);
  left: 0;
  bottom: 0;
  width: 360px;
  max-width: calc(100vw - 32px);
  background: var(--liquid-glass-bg);
  backdrop-filter: var(--liquid-blur);
  -webkit-backdrop-filter: var(--liquid-blur);
  border-right: 1px solid var(--liquid-glass-border);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 200;
  transform: translateX(-100%);
  transition: transform 220ms var(--apple-ease);
  box-shadow: 10px 0 40px rgba(0, 0, 0, 0.2);
  overflow-y: auto;
}

.notebook-binder-panel.open {
  transform: translateX(0);
}

.binder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 2px;
}

.binder-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent);
}

.binder-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
}

/* Segmented View Switcher: Documents / Scratchpad */
.binder-view-switcher {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 4px;
  gap: 4px;
}

.binder-view-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 160ms cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.binder-view-btn:hover {
  color: var(--ink);
}

.binder-view-btn.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

:root[data-resolved-theme="dark"] .binder-view-btn.active {
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5);
}

.binder-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

.binder-file-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
}

.binder-file-item {
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 160ms cubic-bezier(0.16, 1, 0.3, 1);
  color: var(--ink);
  position: relative;
  text-align: left;
}

.binder-file-item:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.04);
}

.binder-file-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  background-color: var(--surface);
}

.binder-file-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.binder-file-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.binder-file-meta {
  font-size: 12px;
  color: var(--muted);
}

.binder-file-del-btn {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 150ms ease;
}

.binder-file-del-btn:hover {
  background: rgba(162, 59, 43, 0.12);
  color: var(--danger);
}

.binder-add-zone {
  margin-top: 4px;
}

.binder-add-btn {
  width: 100%;
  height: 44px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 12px;
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 160ms ease;
}

.binder-add-btn:hover {
  border-color: var(--ink);
  color: var(--ink);
  background: var(--surface-2);
}

.binder-notes-wrap {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.binder-notes-area {
  width: 100%;
  flex: 1;
  min-height: 280px;
  padding: 16px;
  border-radius: 14px;
  background-color: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 150ms ease;
}

.binder-notes-area:focus {
  border-color: var(--ink);
}

.binder-notes-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--muted);
}

.binder-notes-status {
  font-style: italic;
}

.binder-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.binder-footer a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 40px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 160ms ease;
}

.binder-footer a:hover {
  color: var(--ink);
  border-color: var(--line-strong);
  background: var(--surface);
}

/* ── Universal Document Study Scratchpad Panel ─────────────────────────── */
#doc-scratchpad-panel {
  left: auto;
  right: 0;
  border-left: 1px solid var(--line);
  border-right: none;
  transform: translateX(100%);
  z-index: 200;
}

#doc-scratchpad-panel.open {
  transform: translateX(0);
}

.scratchpad-doc-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--ink-2);
  gap: 8px;
}

.scratchpad-doc-name {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  max-width: 220px;
}

.doc-scratchpad-wrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  gap: 10px;
}

.doc-scratchpad-wrap .binder-notes-area {
  flex: 1;
  min-height: 280px;
  resize: none;
}

.doc-scratchpad-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.doc-scratchpad-actions-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── 8. Overlays & Modals ─────────────────────────────────────────────────── */
.history-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 360px;
  max-width: calc(100vw - 32px);
  background: var(--liquid-glass-bg);
  backdrop-filter: var(--liquid-blur);
  -webkit-backdrop-filter: var(--liquid-blur);
  border-left: 1px solid var(--liquid-glass-border);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.2);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 200;
  transform: translateX(100%);
  transition: transform 220ms var(--apple-ease);
  overflow-y: auto;
}

.history-panel.open {
  transform: translateX(0);
}

.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 2px;
}

.history-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
}

.history-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.history-count-badge {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  padding: 2px 8px;
}

.history-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 150ms ease;
}

.history-close-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line-strong);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
}

.history-item {
  width: 100%;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  cursor: pointer;
  transition: all 160ms cubic-bezier(0.16, 1, 0.3, 1);
  color: var(--ink);
  position: relative;
}

.history-item:hover {
  border-color: var(--line-strong);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.04);
}

.history-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
  background-color: var(--surface);
}

.history-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.history-item-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.history-progress-pill {
  font-weight: 500;
}

.history-item-del {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 150ms ease;
}

.history-item-del:hover {
  background: rgba(162, 59, 43, 0.12);
  color: var(--danger);
}

.doc-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 6px;
  border-radius: 6px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.doc-badge-pdf {
  background-color: rgba(198, 40, 40, 0.12);
  color: #C62828;
}

.doc-badge-docx {
  background-color: rgba(21, 101, 192, 0.12);
  color: #1565C0;
}

.history-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  margin-top: auto;
  font-size: 13px;
}

.history-docs-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 12.5px;
  transition: color 150ms ease;
}

.history-docs-link:hover {
  color: var(--ink);
}

.history-clear-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 12.5px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: all 150ms ease;
}

.history-clear-btn:hover {
  color: var(--danger);
  background: rgba(162, 59, 43, 0.08);
}

.history-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 12px;
  padding: 48px 16px;
  color: var(--muted);
}

.history-empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.history-empty-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
}

.history-empty-desc {
  font-size: 13px;
  line-height: 1.5;
  color: var(--ink-2);
}

.history-empty-btn {
  margin-top: 6px;
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms ease;
}

.history-empty-btn:hover {
  background: var(--surface-2);
  border-color: var(--ink);
}

.history-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 6, 0.35);
  z-index: 190;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

.history-backdrop.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── Feedback & Centered Modal Dialogs ───────────────────────────────────── */
.feedback-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 12, 14, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 550;
  opacity: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  transition: opacity 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

.feedback-modal-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.feedback-modal {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  padding: 26px 28px;
  width: 100%;
  max-width: 500px;
  box-shadow: 0 20px 48px -10px rgba(0, 0, 0, 0.35);
  position: relative;
  display: flex;
  flex-direction: column;
  transform: translateY(12px) scale(0.97);
  transition: transform 220ms cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
  margin: auto;
}

.feedback-modal-backdrop.open .feedback-modal {
  transform: translateY(0) scale(1);
}

.feedback-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 4px;
}

.feedback-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.feedback-icon {
  color: var(--accent);
  flex-shrink: 0;
}

.feedback-modal-title {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 500;
  color: var(--ink);
  margin: 0;
  line-height: 1.25;
}

.feedback-modal-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  border: none;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 150ms ease, color 150ms ease;
  margin-top: -4px;
  margin-right: -4px;
}

.feedback-modal-close:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.feedback-modal-subtitle {
  font-size: 13.5px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 16px;
}

#feedback-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin: 0;
}

.feedback-field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.feedback-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

/* Category Pills */
.feedback-category-pills {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.feedback-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 6px;
  font-size: 11.5px;
  font-weight: 500;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--ink-2);
  cursor: pointer;
  transition: all 160ms cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.feedback-pill .pill-icon {
  flex-shrink: 0;
  stroke-width: 2;
}

.feedback-pill:hover {
  border-color: var(--line-strong);
  color: var(--ink);
  background: var(--surface);
}

.feedback-pill.selected {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.feedback-pill.selected .pill-icon {
  stroke: var(--bg);
}

/* Anti-Spam Honeypot Field */
.feedback-honey {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
  z-index: -1 !important;
}

/* Textarea & Inputs */
.feedback-textarea,
.feedback-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.feedback-textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.5;
}

.feedback-textarea:focus,
.feedback-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-subtle, rgba(232, 93, 34, 0.15));
}

.feedback-textarea::placeholder,
.feedback-input::placeholder {
  color: var(--muted);
}

/* Modal Footer Actions */
.feedback-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.feedback-secondary-btn {
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: transparent;
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

.feedback-secondary-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.feedback-primary-btn {
  height: 38px;
  padding: 0 18px;
  border-radius: var(--radius-pill);
  border: none;
  background: var(--ink);
  color: var(--bg);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: opacity 150ms ease, transform 150ms ease;
}

.feedback-primary-btn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
}

.feedback-primary-btn:active {
  transform: translateY(0);
}

.feedback-primary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Success State */
.feedback-success-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 12px;
  gap: 14px;
}

.feedback-success-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-subtle);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.feedback-success-title {
  font-family: var(--font-serif);
  font-size: 22px;
  color: var(--ink);
  margin: 0;
}

.feedback-success-desc {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0 0 12px;
  max-width: 400px;
}

@media (max-width: 540px) {
  .feedback-modal {
    padding: 20px 18px;
    margin: 12px;
    max-height: min(92dvh, 680px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
  }
  .feedback-category-pills {
    grid-template-columns: repeat(2, 1fr);
  }
  .feedback-modal-footer {
    flex-wrap: wrap;
    gap: 8px;
  }
}

/* Drop Overlay */
.drop-overlay,
#drop-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(12, 12, 14, 0.48);
  backdrop-filter: var(--liquid-blur);
  -webkit-backdrop-filter: var(--liquid-blur);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.drop-overlay-box,
.drop-card {
  width: 100%;
  max-width: 520px;
  min-height: 280px;
  background: var(--liquid-card-bg);
  backdrop-filter: var(--liquid-blur);
  -webkit-backdrop-filter: var(--liquid-blur);
  border: 1.5px dashed var(--accent);
  box-shadow: var(--liquid-specular);
  border-radius: var(--apple-squircle-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 40px 32px;
  text-align: center;
}

.drop-icon-wrap {
  width: 68px;
  height: 68px;
  border-radius: 20px;
  background: var(--liquid-pill-bg);
  border: 1px solid var(--liquid-glass-border-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  box-shadow: var(--liquid-specular-sm);
}

.drop-title,
.drop-overlay-title {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 500;
  color: var(--ink);
}

.drop-hint,
.drop-overlay-sub {
  font-size: 14px;
  color: var(--muted);
}

/* ── 9. Responsive Rules & Breakpoints ────────────────────────────────────── */

/* Ultra-Compact (< 380px, e.g. Foldable Cover Screens) */
@media (max-width: 380px) {
  .welcome-inner {
    padding-left: 6px;
    padding-right: 6px;
  }

  .welcome-display-title {
    font-size: 30px;
  }

  .welcome-subtitle {
    font-size: 14px;
  }

  .continue-reading-row {
    padding: 10px 12px;
    min-height: 54px;
    gap: 10px;
  }

  .continue-row-title {
    font-size: 13.5px;
  }

  .continue-row-meta {
    font-size: 11.5px;
  }

  .reader-dock {
    padding: 4px;
    gap: 2px;
  }

  .reader-dock .dock-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .doc-title, #doc-title {
    padding: 0 10px;
    gap: 6px;
    height: 36px;
    font-size: 12px;
  }

  .docx-body {
    padding: 24px 14px;
    font-size: 15px;
  }
}

/* Mobile Portrait (<= 640px) */
@media (max-width: 640px) {
  .welcome-topbar {
    padding: calc(var(--sat) + 12px) 0 8px;
  }

  /* Bottom nav handles History & Notebooks cleanly on mobile */
  #history-toggle-welcome,
  #welcome-notebooks-link {
    display: none !important;
  }

  .topbar-btn span,
  .topbar-btn kbd {
    display: none;
  }

  .welcome-hero {
    align-items: center;
    text-align: center;
    padding: 16px 0 8px;
  }

  .welcome-drop-card {
    padding: 28px 18px 24px;
    border-radius: 22px;
  }

  .welcome-features-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .welcome-hero-actions {
    width: 100%;
    flex-direction: column;
    gap: 10px;
  }

  .btn-primary,
  .btn-secondary {
    width: 100%;
    min-height: 52px;
    border-radius: 16px;
    font-size: 15px;
  }

  .mobile-bottom-nav {
    display: flex;
  }

  .welcome {
    padding-bottom: calc(var(--sab) + 88px);
  }

  /* Mobile Reader Surface */
  .reading-surface {
    padding: 68px calc(12px + var(--sar)) calc(var(--sab) + 84px) calc(12px + var(--sal));
  }

  .paper {
    padding: 0;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .docx-body {
    padding: 28px 16px;
    font-size: 16px;
    line-height: 1.65;
  }

  /* In-Document Search Box on Mobile */
  .search-box {
    bottom: calc(var(--sab) + 76px);
    width: calc(100vw - 24px);
    border-radius: var(--radius-md);
  }

  .search-input-wrap input {
    font-size: 16px; /* Prevents unwanted iOS Safari auto-zoom */
  }

  /* Bottom Sheet Reading Controls */
  .controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    height: auto;
    max-height: 68vh;
    border-left: none;
    border-top: 1px solid var(--liquid-glass-border);
    border-radius: 24px 24px 0 0;
    padding: 16px 20px calc(var(--sab) + 16px);
    background: var(--liquid-glass-bg);
    backdrop-filter: var(--liquid-blur);
    -webkit-backdrop-filter: var(--liquid-blur);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.12);
    transform: translateY(0);
    z-index: 95;
  }

  .controls.hidden {
    display: none !important;
    transform: translateY(100%);
  }

  .sheet-drag-handle {
    width: 36px;
    height: 4px;
    border-radius: 999px;
    background-color: var(--line-strong);
    margin: 0 auto 12px;
    display: block;
    flex-shrink: 0;
  }

  /* Notebook Binder Drawer on Mobile */
  .notebook-binder-panel {
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 75vh;
    border-left: none;
    border-top: 1px solid var(--liquid-glass-border);
    border-radius: 24px 24px 0 0;
    padding: 18px 20px calc(var(--sab) + 16px);
    background: var(--liquid-glass-bg);
    backdrop-filter: var(--liquid-blur);
    -webkit-backdrop-filter: var(--liquid-blur);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.12);
    z-index: 250;
  }
}

/* Tablet & Folded Screen Viewports (641px - 1099px) */
@media (min-width: 641px) and (max-width: 1099px) {
  .reading-surface {
    padding: 76px calc(24px + var(--sar)) calc(var(--sab) + 88px) calc(24px + var(--sal));
  }

  /* Bottom sheet drawer prevents squishing paper on tablets */
  .controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    max-width: 580px;
    margin: 0 auto;
    max-height: 62vh;
    border-radius: 24px 24px 0 0;
    border: 1px solid var(--liquid-glass-border);
    border-bottom: none;
    padding: 20px 24px calc(var(--sab) + 20px);
    background: var(--liquid-glass-bg);
    backdrop-filter: var(--liquid-blur);
    -webkit-backdrop-filter: var(--liquid-blur);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.14);
    z-index: 95;
    transform: translateY(0);
  }

  .controls.hidden {
    display: none !important;
    transform: translateY(100%);
  }

  .sheet-drag-handle {
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background-color: var(--line-strong);
    margin: 0 auto 12px;
    display: block;
  }

  .notebook-binder-panel {
    position: fixed;
    top: calc(var(--sat) + 54px);
    right: 0;
    bottom: 0;
    width: min(380px, 80vw);
    box-shadow: var(--shadow-float);
    z-index: 200;
  }
}

/* Desktop Docked Panel Layout (>= 1100px) */
@media (min-width: 1100px) {
  .controls {
    position: relative;
    top: auto;
    bottom: auto;
    left: auto;
    right: auto;
    width: 344px;
    height: 100dvh;
    border-radius: 0;
    border-top: none;
    border-left: 1px solid var(--line);
    box-shadow: none;
    transform: none;
  }

  .controls.hidden {
    display: none !important;
  }

  .sheet-drag-handle {
    display: none;
  }
}

/* Mobile Landscape Ergonomics (< 520px Height) */
@media (max-height: 520px) and (orientation: landscape) {
  .welcome-topbar {
    padding: calc(var(--sat) + 8px) 0 8px;
  }

  .welcome-hero {
    padding: 12px 0 6px;
    gap: 8px;
  }

  .welcome-display-title {
    font-size: 30px;
  }

  .welcome-hero-actions {
    flex-direction: row;
  }

  .btn-primary, .btn-secondary {
    min-height: 44px;
    width: auto;
  }

  .welcome-drop-hint {
    display: none;
  }

  .doc-title, #doc-title {
    top: calc(var(--sat) + 8px);
    height: 34px;
    font-size: 12.5px;
  }

  .reader-dock {
    bottom: calc(var(--sab) + 8px);
    padding: 4px;
  }

  .reader-dock .dock-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .reading-surface {
    padding: 50px calc(24px + var(--sar)) calc(var(--sab) + 52px) calc(24px + var(--sal));
  }

  /* Side overlay panel on landscape preserves vertical reading height */
  .controls {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: auto;
    width: min(320px, 85vw);
    height: 100dvh;
    border-radius: 20px 0 0 20px;
    border-top: none;
    border-left: 1px solid var(--line);
    padding: calc(var(--sat) + 14px) calc(var(--sar) + 14px) calc(var(--sab) + 14px) 16px;
    max-height: 100dvh;
    z-index: 95;
    transform: translateX(0);
  }

  .controls.hidden {
    display: none !important;
    transform: translateX(100%);
  }

  .sheet-drag-handle {
    display: none;
  }
}

/* Hover Guard: Prevent sticky hover on mobile touchscreens */
@media (hover: hover) and (pointer: fine) {
  .topbar-btn:hover {
    background-color: var(--surface-2);
  }

  .continue-reading-row:hover {
    background-color: var(--surface-2);
  }

  .reader-dock .dock-btn:hover {
    background-color: var(--surface-2);
  }

  .doc-title-back-btn:hover {
    background: var(--surface-2);
    color: var(--ink);
  }
}

/* ── Pulse Hint: Guide attention to a button (e.g. binder re-add) ─────────── */
@keyframes pulse-hint {
  0%   { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 55%, transparent); transform: scale(1); }
  50%  { box-shadow: 0 0 0 8px color-mix(in srgb, var(--accent) 0%, transparent); transform: scale(1.07); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 0%, transparent); transform: scale(1); }
}

.pulse-hint {
  animation: pulse-hint 0.65s ease-in-out 3;
}

/* ── Plain-Sight Download / Export Buttons ───────────────────────────────── */
#header-download-btn {
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 500;
  border-color: var(--line-strong);
}

#header-download-btn:hover {
  background: var(--ink);
  color: var(--bg);
}

.hl-bar-action-btn.hl-download-btn {
  background: var(--ink);
  color: var(--bg);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-color: var(--ink);
}

.hl-bar-action-btn.hl-download-btn:hover {
  opacity: 0.88;
}

/* ── Print / Save as PDF Styles (Clean Vector Export with Highlights) ─────── */
@media print {
  @page {
    margin: 18mm 16mm 18mm 16mm;
    size: auto;
  }

  *, *::before, *::after {
    box-shadow: none !important;
    text-shadow: none !important;
  }

  body, html {
    background: #ffffff !important;
    color: #111111 !important;
    font-size: 12pt !important;
    line-height: 1.6 !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
  }

  /* Hide all app chrome, dock, panels, buttons */
  #welcome,
  #doc-title,
  #reader-dock,
  #controls,
  #doc-scratchpad-panel,
  #doc-scratchpad-backdrop,
  #highlight-bar,
  #selection-tooltip,
  #history-panel,
  #history-backdrop,
  #binder-panel,
  #binder-backdrop,
  #search-box,
  .theme-pill,
  #toast,
  .notebook-tabs-bar,
  .reader-top-action-btn,
  .zoom-indicator-pill {
    display: none !important;
    visibility: hidden !important;
  }

  #reader-view,
  #reading-surface,
  #paper,
  .pages {
    display: block !important;
    position: static !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: auto !important;
    overflow: visible !important;
    background: transparent !important;
  }

  .document-page.docx-page {
    border: none !important;
    box-shadow: none !important;
    margin: 0 !important;
    padding: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    zoom: 1 !important;
    background: transparent !important;
    color: #111111 !important;
    font-size: 12pt !important;
    line-height: 1.65 !important;
  }

  .document-page.docx-page h1,
  .document-page.docx-page h2,
  .document-page.docx-page h3 {
    color: #000000 !important;
    break-after: avoid;
    page-break-after: avoid;
  }

  .document-page.docx-page p,
  .document-page.docx-page li,
  .document-page.docx-page blockquote {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* Ensure highlights print with exact color */
  .text-highlight-band {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
    opacity: 0.75 !important;
    mix-blend-mode: multiply !important;
  }

  .text-highlight-band.hl-amber {
    background-color: #fce588 !important;
  }
  .text-highlight-band.hl-green {
    background-color: #bbf0c2 !important;
  }
  .text-highlight-band.hl-blue {
    background-color: #bfe0fd !important;
  }
  .text-highlight-band.hl-rose {
    background-color: #fec5d2 !important;
  }
}

/* ── Contextual Highlight Action Popover ─────────────────────────────────── */
.highlight-action-menu {
  position: fixed;
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  background: var(--bg-surface-elevated, #ffffff);
  border: 1px solid var(--border-color, rgba(0, 0, 0, 0.1));
  border-radius: 9999px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.16), 0 2px 6px rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transform: translate(-50%, -100%);
  animation: hlMenuPop 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: auto;
}

:root[data-resolved-theme="dark"] .highlight-action-menu {
  background: rgba(28, 28, 30, 0.94);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.highlight-action-menu.menu-below {
  transform: translate(-50%, 8px);
}

@keyframes hlMenuPop {
  from { opacity: 0; transform: translate(-50%, -90%) scale(0.92); }
  to { opacity: 1; transform: translate(-50%, -100%) scale(1); }
}

.highlight-action-menu.menu-below {
  animation: hlMenuPopBelow 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes hlMenuPopBelow {
  from { opacity: 0; transform: translate(-50%, 0px) scale(0.92); }
  to { opacity: 1; transform: translate(-50%, 8px) scale(1); }
}

.hl-menu-colors {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 2px;
}

.hl-menu-color-btn {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
  padding: 0;
}

.hl-menu-color-btn:hover {
  transform: scale(1.18);
}

.hl-menu-color-btn.active {
  border-color: var(--text-primary);
  transform: scale(1.15);
}

.hl-menu-color-btn.hl-amber { background: #facc15; }
.hl-menu-color-btn.hl-green { background: #4ade80; }
.hl-menu-color-btn.hl-blue  { background: #60a5fa; }
.hl-menu-color-btn.hl-rose  { background: #f472b6; }

.hl-menu-divider {
  width: 1px;
  height: 18px;
  background: var(--border-color, rgba(0, 0, 0, 0.12));
  margin: 0 2px;
}

.hl-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 8px;
  border-radius: 9999px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.hl-menu-btn:hover {
  background: var(--hover-bg, rgba(0, 0, 0, 0.06));
  color: var(--text-primary);
}

.hl-menu-btn.hl-menu-delete:hover {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

/* ── Scratchpad Formatting Helpers ───────────────────────────────────────── */
.scratchpad-format-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 0 8px 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.scratchpad-format-row::-webkit-scrollbar {
  display: none;
}

.sp-format-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 9999px;
  border: 1px solid var(--border-color, rgba(0, 0, 0, 0.1));
  background: var(--hover-bg, rgba(0, 0, 0, 0.03));
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.sp-format-chip:hover {
  background: var(--active-bg, rgba(0, 0, 0, 0.08));
  color: var(--text-primary);
  border-color: var(--text-muted);
}

/* ── Graceful Document Error Recovery Card ───────────────────────────────── */
#error.error {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  max-width: 480px;
  width: calc(100% - 32px);
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

.doc-error-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 36px 28px;
  background: var(--bg-surface-elevated, #ffffff);
  border: 1px solid var(--border-color, rgba(0, 0, 0, 0.1));
  border-radius: 20px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.12);
  animation: errorCardIn 0.22s ease-out;
}

:root[data-resolved-theme="dark"] .doc-error-card {
  background: #1c1c1e;
  border-color: rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 56px rgba(0, 0, 0, 0.45);
}

@keyframes errorCardIn {
  from { opacity: 0; transform: scale(0.95) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.doc-error-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.doc-error-title {
  margin: 0 0 8px 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.doc-error-desc {
  margin: 0 0 24px 0;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text-secondary);
  max-width: 380px;
}

.doc-error-actions {
  display: flex;
  gap: 10px;
  width: 100%;
  justify-content: center;
}

.doc-error-actions .btn-primary,
.doc-error-actions .btn-secondary {
  height: 42px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
}

/* ── Keyboard Shortcuts Modal ────────────────────────────────────────────── */
.shortcuts-modal-card {
  max-width: 520px;
}

.shortcuts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  padding: 18px 24px 24px 24px;
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.shortcut-item kbd {
  display: inline-block;
  padding: 3px 7px;
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  color: var(--text-primary);
  background: var(--hover-bg, rgba(0, 0, 0, 0.05));
  border: 1px solid var(--border-color, rgba(0, 0, 0, 0.15));
  border-radius: 6px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
}

:root[data-resolved-theme="dark"] .shortcut-item kbd {
  background: #2c2c2e;
  border-color: rgba(255, 255, 255, 0.16);
}

/* ── Zoom Boundary Disabled Feedback ─────────────────────────────────────── */
.zoom-btn:disabled,
.zoom-btn[aria-disabled="true"] {
  opacity: 0.35 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
}

/* ── Notebook Tab Bar Actions ────────────────────────────────────────────── */
.notebook-tabs-bar .notebook-tab-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
}

.notebook-tabs-bar .notebook-tab-action-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line-strong);
}

.notebook-tabs-bar .notebook-tab-action-btn.active {
  background: var(--accent-subtle);
  color: var(--accent);
  border-color: var(--accent);
}

.notebook-tabs-bar .notebook-tab-action-btn.icon-only {
  width: 32px;
  height: 32px;
  padding: 0;
}

.notebook-tabs-bar .notebook-tab-action-btn .header-hl-indicator {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--hl, #f3d56b);
  border: 1px solid var(--surface);
}

/* ── Focus Mode System ─────────────────────────────────────────────────────── */
.topbar-focus-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 13px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 160ms cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
  text-decoration: none;
}

.topbar-focus-btn:hover {
  background: var(--surface-2);
  color: var(--ink);
  border-color: var(--line-strong);
}

.topbar-focus-btn.active,
:root[data-focus-mode="true"] .topbar-focus-btn {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.topbar-focus-btn.active svg,
:root[data-focus-mode="true"] .topbar-focus-btn svg {
  stroke: var(--bg);
}

.reader-top-action-btn.focus-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  height: 32px;
  transition: all 160ms cubic-bezier(0.16, 1, 0.3, 1);
  background: transparent;
  color: var(--ink);
  border: 1px solid transparent;
}

.reader-top-action-btn.focus-toggle-btn:hover {
  background: var(--surface-2);
}

.reader-top-action-btn.focus-toggle-btn.active,
:root[data-focus-mode="true"] .reader-top-action-btn.focus-toggle-btn {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.reader-top-action-btn.focus-toggle-btn.active svg,
:root[data-focus-mode="true"] .reader-top-action-btn.focus-toggle-btn svg {
  stroke: var(--bg);
}

.notebook-tabs-bar .focus-toggle-btn.active,
:root[data-focus-mode="true"] .notebook-tabs-bar .focus-toggle-btn {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.notebook-tabs-bar .focus-toggle-btn.active svg,
:root[data-focus-mode="true"] .notebook-tabs-bar .focus-toggle-btn svg {
  stroke: var(--bg);
}

#controls-focus-toggle.active,
:root[data-focus-mode="true"] #controls-focus-toggle {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

/* Hide everything other than PDF, history, and notebook when Focus Mode is active */
:root[data-focus-mode="true"] #header-feedback-btn,
:root[data-focus-mode="true"] #feedback-toggle-welcome,
:root[data-focus-mode="true"] #welcome-feedback-btn,
:root[data-focus-mode="true"] #feedback-toggle-nb,
:root[data-focus-mode="true"] #controls-feedback-btn,
:root[data-focus-mode="true"] #header-library-btn,
:root[data-focus-mode="true"] #library-toggle-welcome,
:root[data-focus-mode="true"] #welcome-explore-library-btn,
:root[data-focus-mode="true"] #library-toggle-nb,
:root[data-focus-mode="true"] #feedback-modal-backdrop,
:root[data-focus-mode="true"] #library-modal-backdrop,
:root[data-focus-mode="true"] .welcome-features-grid,
:root[data-focus-mode="true"] .welcome-seo-details,
:root[data-focus-mode="true"] .welcome-footer,
:root[data-focus-mode="true"] .welcome-nav-pill-group a[href*="library"],
:root[data-focus-mode="true"] .welcome-hero-actions a[href*="library"],
:root[data-focus-mode="true"] a[href="/library"],
:root[data-focus-mode="true"] a[href*="/library"],
:root[data-focus-mode="true"] .nav-pill-item[href*="library"],
:root[data-focus-mode="true"] [data-action="library"] {
  display: none !important;
}

:root[data-focus-mode="true"] .welcome-hero {
  padding-bottom: 72px;
}

@media (max-width: 600px) {
  .topbar-focus-btn {
    padding: 0 10px;
    height: 36px;
    font-size: 12px;
  }
  .header-focus-label {
    display: none;
  }
  .reader-top-action-btn.focus-toggle-btn {
    padding: 0;
    width: 32px;
    justify-content: center;
  }
  .reader-top-action-btn.convert-txt-pill-btn .convert-txt-label {
    display: none;
  }
  .reader-top-action-btn.convert-txt-pill-btn {
    padding: 0;
    width: 32px;
    justify-content: center;
  }
}

/* ── Universal Command Palette (Ctrl+K / Cmd+K) ───────────────────────────── */
.cmd-palette-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 12, 14, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 280;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 24px;
  box-sizing: border-box;
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.cmd-palette-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.cmd-palette-modal {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  width: 100%;
  max-width: 620px;
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(-8px) scale(0.98);
  transition: transform 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

.cmd-palette-backdrop.open .cmd-palette-modal {
  transform: translateY(0) scale(1);
}

.cmd-palette-search-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.cmd-palette-icon {
  color: var(--muted);
  flex-shrink: 0;
}

.cmd-palette-input {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 15.5px;
  color: var(--ink);
  outline: none;
  min-width: 0;
}

.cmd-palette-input::placeholder {
  color: var(--muted);
}

.cmd-palette-kbd kbd {
  font-family: inherit;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
}

.cmd-palette-results {
  max-height: 380px;
  overflow-y: auto;
  padding: 8px 6px;
}

.cmd-group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  padding: 8px 12px 4px;
}

.cmd-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--ink);
  transition: all 100ms ease;
  user-select: none;
}

.cmd-item:hover,
.cmd-item.selected {
  background: var(--surface-2);
  color: var(--accent);
}

.cmd-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.cmd-item-icon {
  color: var(--muted);
  flex-shrink: 0;
  transition: color 100ms ease;
}

.cmd-item:hover .cmd-item-icon,
.cmd-item.selected .cmd-item-icon {
  color: var(--accent);
}

.cmd-item-title {
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cmd-item-shortcut {
  font-size: 11px;
  color: var(--muted);
}

.cmd-palette-footer {
  padding: 10px 18px;
  background: var(--surface-2);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--muted);
}

.cmd-footer-hints {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cmd-footer-hints kbd {
  font-family: inherit;
  padding: 1px 4px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
}

.cmd-footer-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  font-weight: 500;
}

/* ── Storage Dashboard & Backup / Restore ─────────────────────────────────── */
.storage-modal {
  max-width: 580px;
}

.storage-modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  max-height: 70vh;
}

.storage-meter-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
}

.storage-meter-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.storage-meter-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  display: block;
  margin-bottom: 2px;
}

.storage-meter-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
}

.storage-meter-pct {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
}

.storage-progress-bar-wrap {
  height: 8px;
  background: var(--line);
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: 12px;
}

.storage-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-pill);
  transition: width 300ms ease;
}

.storage-breakdown-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 12px;
  color: var(--ink-2);
}

.storage-breakdown-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.breakdown-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.breakdown-dot.pdf {
  background: var(--accent);
}

.breakdown-dot.nb {
  background: #3B82F6;
}

.storage-actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

@media (max-width: 580px) {
  .storage-actions-grid {
    grid-template-columns: 1fr;
  }
}

.storage-action-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.storage-action-header {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

.storage-action-header h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
}

.storage-action-card p {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
  margin: 0;
  flex: 1;
}

.storage-danger-zone {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.danger-zone-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.danger-zone-text strong {
  font-size: 13px;
  color: var(--ink);
}

.danger-zone-text span {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.35;
}

.storage-danger-btn {
  height: 32px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(162, 59, 43, 0.35);
  background: rgba(162, 59, 43, 0.08);
  color: var(--danger);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 140ms ease;
}

.storage-danger-btn:hover {
  background: var(--danger);
  color: #FFFFFF;
}

/* ── Local PC Folder Vault & Emergency Purge ────────────────────────────── */
.storage-folder-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.storage-folder-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.storage-folder-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.storage-folder-info h3 {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
  margin: 0;
}

.storage-folder-info p {
  font-size: 11.5px;
  color: var(--muted);
  margin: 0;
  line-height: 1.4;
}

.storage-linked-folder-details {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 10px;
  font-size: 12px;
}

.folder-badge {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.storage-linked-folder-details strong {
  color: var(--ink);
  flex: 1;
  word-break: break-all;
}

.folder-unlink-btn {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.folder-unlink-btn:hover {
  text-decoration: underline;
  background: rgba(162, 59, 43, 0.08);
}

.storage-danger-zone.purge-zone {
  background: rgba(229, 72, 77, 0.05);
  border: 1px solid rgba(229, 72, 77, 0.25);
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 6px;
}

.danger-zone-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
}

.storage-purge-btn {
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(229, 72, 77, 0.5);
  background: rgba(229, 72, 77, 0.12);
  color: #E5484D;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 140ms ease;
}

.storage-purge-btn:hover {
  background: #E5484D;
  color: #FFFFFF;
  box-shadow: 0 2px 10px rgba(229, 72, 77, 0.35);
}

.storage-purge-btn svg {
  stroke: currentColor;
}

/* ── Nuclear Flush Confirmation Warning Modal ────────────────────────────── */
.flush-confirm-modal {
  max-width: 500px;
  border: 1px solid rgba(229, 72, 77, 0.4);
  box-shadow: 0 20px 48px rgba(229, 72, 77, 0.16), 0 8px 24px rgba(0, 0, 0, 0.2);
}

.flush-warning-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(229, 72, 77, 0.08);
  border: 1px solid rgba(229, 72, 77, 0.2);
  border-radius: 12px;
  color: #E5484D;
  font-size: 12.5px;
  line-height: 1.45;
}

.flush-warning-banner strong {
  display: block;
  font-size: 13.5px;
  margin-bottom: 2px;
}

.flush-data-list {
  list-style: none;
  padding: 0;
  margin: 12px 0 0 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.flush-data-list li {
  font-size: 12px;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 8px;
}

.flush-data-list li svg {
  stroke: #E5484D;
  flex-shrink: 0;
}

.flush-confirm-execute-btn {
  background: #E5484D !important;
  color: #FFFFFF !important;
  border: none !important;
  font-weight: 600 !important;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  height: 38px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 140ms ease;
}

.flush-confirm-execute-btn:hover {
  background: #C73B40 !important;
  box-shadow: 0 2px 12px rgba(229, 72, 77, 0.4);
}

/* ── Academic Citation & Markdown Export ──────────────────────────────────── */
.citation-modal {
  max-width: 580px;
}

.citation-modal-body {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.citation-format-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.citation-tab {
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 140ms ease;
}

.citation-tab:hover {
  color: var(--ink);
}

.citation-tab.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
  font-weight: 600;
}

.citation-preview-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.citation-preview-code {
  font-family: var(--font-sans, system-ui);
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.citation-copy-btn {
  align-self: flex-start;
  height: 34px;
  padding: 0 14px;
  font-size: 13px;
}

.markdown-export-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.markdown-export-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.markdown-export-info strong {
  font-size: 13.5px;
  color: var(--ink);
}

.markdown-export-info span {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.35;
}

/* ── Text-to-Speech (TTS) Reader Bar ──────────────────────────────────────── */
.tts-player-bar {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  padding: 6px 14px 6px 18px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 180;
  transition: all 180ms ease;
}

.tts-player-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tts-pulse-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: tts-pulse 1.4s infinite ease-in-out;
}

@keyframes tts-pulse {
  0%, 100% { transform: scale(0.9); opacity: 0.6; }
  50% { transform: scale(1.35); opacity: 1; }
}

.tts-player-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  white-space: nowrap;
}

.tts-player-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tts-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  transition: all 140ms ease;
}

.tts-btn:hover {
  background: var(--surface);
  border-color: var(--line-strong);
}

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

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

.tts-select {
  height: 28px;
  padding: 0 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 12px;
  outline: none;
  cursor: pointer;
}

/* ── Pomodoro Focus Timer ─────────────────────────────────────────────────── */
.pomodoro-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: all 140ms ease;
  user-select: none;
}

.pomodoro-pill:hover {
  background: var(--surface);
  border-color: var(--line-strong);
}

.pomodoro-pill.running {
  border-color: rgba(232, 93, 34, 0.4);
  background: rgba(232, 93, 34, 0.08);
  color: var(--accent);
}

.pomodoro-time {
  font-family: var(--font-mono, monospace);
  font-size: 12.5px;
  letter-spacing: 0.04em;
}

/* ── Reading Ruler (ADHD / Dyslexia Focus Guide) ─────────────────────────── */
.reading-ruler {
  position: fixed;
  left: 0;
  right: 0;
  height: 38px;
  pointer-events: none;
  background: rgba(232, 93, 34, 0.08);
  border-top: 2px solid rgba(232, 93, 34, 0.35);
  border-bottom: 2px solid rgba(232, 93, 34, 0.35);
  z-index: 9999;
  transition: top 50ms ease-out;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.22);
}

:root[data-theme="dark"] .reading-ruler {
  background: rgba(232, 93, 34, 0.12);
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
}

/* ── Flashcard Study Desk & Spaced Repetition ────────────────────────────── */
.flashcard-modal {
  max-width: 620px;
}

.flashcard-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  padding: 10px 0;
}

.flashcard-card-box {
  width: 100%;
  min-height: 220px;
  perspective: 1000px;
  cursor: pointer;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  min-height: 220px;
  text-align: center;
  transition: transform 0.4s ease;
  transform-style: preserve-3d;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.flashcard-inner.flipped {
  transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
  width: 100%;
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
}

.flashcard-back {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 24px;
  transform: rotateY(180deg);
  background: var(--surface-2);
  border-radius: 16px;
}

.flashcard-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.flashcard-text {
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  max-height: 160px;
  overflow-y: auto;
}

.recall-btn-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 10px;
}

.recall-btn {
  flex: 1;
  height: 38px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 140ms ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.recall-btn.again { background: rgba(229, 72, 77, 0.1); color: #E5484D; border-color: rgba(229, 72, 77, 0.3); }
.recall-btn.hard { background: rgba(245, 158, 11, 0.1); color: #D97706; border-color: rgba(245, 158, 11, 0.3); }
.recall-btn.good { background: rgba(59, 130, 246, 0.1); color: #2563EB; border-color: rgba(59, 130, 246, 0.3); }
.recall-btn.easy { background: rgba(16, 149, 93, 0.1); color: #10955D; border-color: rgba(16, 149, 93, 0.3); }

.recall-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}


/* ── Page Thumbnails Sidebar ─────────────────────────────────────────────── */
.thumbnails-sidebar {
  position: fixed;
  top: 56px;
  left: 0;
  bottom: 0;
  width: 140px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  z-index: 100;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  box-shadow: 2px 0 12px rgba(0,0,0,0.06);
}

.thumbnail-page-btn {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 4px;
  cursor: pointer;
  text-align: center;
  transition: all 140ms ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.thumbnail-page-btn:hover {
  border-color: var(--accent);
  background: var(--surface);
}

.thumbnail-page-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(232, 93, 34, 0.25);
}

.thumbnail-page-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
}

/* ── Plain Text & Markdown Reader Surface ─────────────────────────────────── */
.text-document-view {
  max-width: 820px;
  margin: 32px auto;
  padding: 40px 48px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.06);
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── Comic, Manga & Webtoon Reader Engine ────────────────────────────────── */
.document-page.comic-page {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 16px auto;
  background: var(--paper-bg, #111113);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
  border-radius: var(--radius-sm, 4px);
  overflow: hidden;
  max-width: 900px;
  width: 100%;
}

.document-page.comic-page .comic-page-img {
  width: 100%;
  height: auto;
  display: block;
  user-select: none;
  -webkit-user-select: none;
  pointer-events: auto;
}

/* Webtoon / Manhwa Continuous Strip Mode: Zero margins, seamless flow */
#reading-surface.mode-webtoon .paper {
  gap: 0 !important;
  row-gap: 0 !important;
}

#reading-surface.mode-webtoon .document-page.comic-page {
  margin: 0 auto !important;
  padding: 0 !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  background: transparent !important;
  max-width: 800px;
}

#reading-surface.mode-webtoon .document-page.comic-page .comic-page-img {
  width: 100% !important;
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  line-height: 0 !important;
}

/* Manga Right-to-Left Mode */
#reading-surface.mode-manga {
  direction: ltr;
}

.segmented.segmented-modes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}
@media (min-width: 480px) {
  .segmented.segmented-modes {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* ==========================================================================
   Navigation & Dock System
   ========================================================================== */

/* ── 1. Mobile Navigation Bar ────────────────────────────────────────────── */
.liquid-mobile-tabbar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--liquid-glass-bg);
  backdrop-filter: var(--liquid-blur);
  -webkit-backdrop-filter: var(--liquid-blur);
  border-top: 1px solid var(--liquid-glass-border);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45), 0 -8px 24px rgba(0, 0, 0, 0.05);
  padding-bottom: calc(var(--sab) + 4px);
  z-index: 250;
  align-items: center;
  justify-content: space-around;
  height: calc(56px + var(--sab));
  box-sizing: border-box;
}

@media (max-width: 767px) {
  .liquid-mobile-tabbar {
    display: flex;
  }
  /* Ensure page content has bottom clearance above the lower panel */
  body,
  .library-page-body,
  .welcome,
  .docs-page,
  .notebook-page {
    padding-bottom: calc(var(--sab) + 72px) !important;
  }
}

.liquid-tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 100%;
  color: var(--muted);
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 4px 0;
  transition: transform 0.16s var(--apple-ease), color 0.16s ease;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.liquid-tab-item:active {
  transform: scale(0.90);
}

.liquid-tab-icon {
  width: 22px;
  height: 22px;
  display: block;
  pointer-events: none;
  transition: stroke-width 0.16s ease, transform 0.16s var(--apple-ease);
}

.liquid-tab-label {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1;
  pointer-events: none;
  transition: font-weight 0.16s ease;
}

.liquid-tab-item.active {
  color: var(--ink);
}

.liquid-tab-item.active .liquid-tab-icon {
  stroke-width: 2.35;
  transform: translateY(-1px);
}

.liquid-tab-item.active .liquid-tab-label {
  font-weight: 600;
}

/* ── 2. Desktop Navigation Dock ─────────────────────────────────────────── */
.liquid-desktop-dock {
  display: none;
  position: sticky;
  top: 14px;
  margin: 14px auto 20px;
  max-width: 1060px;
  width: calc(100% - 32px);
  height: 54px;
  background: var(--liquid-glass-bg);
  backdrop-filter: var(--liquid-blur);
  -webkit-backdrop-filter: var(--liquid-blur);
  border: 1px solid var(--liquid-glass-border);
  border-radius: var(--radius-pill);
  box-shadow: var(--liquid-specular);
  align-items: center;
  justify-content: space-between;
  padding: 0 10px 0 20px;
  z-index: 180;
  box-sizing: border-box;
  transition: all 0.25s var(--apple-ease);
}

@media (min-width: 768px) {
  .liquid-desktop-dock {
    display: flex;
  }
}

.liquid-dock-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 600;
  font-size: 15.5px;
  letter-spacing: -0.015em;
}

.liquid-brand-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.liquid-brand-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
}

.liquid-dock-track {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--liquid-pill-bg);
  border: 1px solid var(--liquid-glass-border-subtle);
  border-radius: var(--radius-pill);
  padding: 3px 4px;
}

.liquid-dock-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.18s var(--apple-ease);
  user-select: none;
}

.liquid-dock-pill:hover {
  color: var(--ink);
}

.liquid-dock-pill.active {
  color: var(--ink);
  background: var(--liquid-pill-active);
  font-weight: 600;
  box-shadow: var(--liquid-pill-shadow);
}

.liquid-dock-pill:active {
  transform: scale(0.96);
}

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

.liquid-action-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  text-decoration: none;
  transition: all 0.18s var(--apple-ease);
}

.liquid-action-pill:hover {
  background: var(--surface-2);
  transform: translateY(-1px);
}

.liquid-fire-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
  transition: all 0.18s var(--apple-ease);
}

.liquid-fire-btn:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
  color: var(--ink);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

[data-resolved-theme="dark"] .liquid-fire-btn:hover {
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.liquid-fire-btn:active {
  transform: scale(0.96);
}

.liquid-fire-btn svg {
  flex-shrink: 0;
  stroke: currentColor;
}

/* Clear Local Data Modal */
.liquid-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 12, 14, 0.45);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.22s;
}

.liquid-modal-backdrop.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.liquid-fire-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--apple-squircle-xl, 24px);
  padding: 32px 28px 24px;
  box-shadow: var(--shadow-floating, 0 24px 60px rgba(0, 0, 0, 0.18));
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  text-align: center;
  position: relative;
  animation: appleModalPop 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes appleModalPop {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.liquid-fire-badge {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  border: 1px solid var(--line);
}

.liquid-fire-title {
  margin: 0 0 10px 0;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.liquid-fire-desc {
  margin: 0 0 24px 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink-secondary, #666);
}

.liquid-fire-actions {
  display: flex;
  gap: 12px;
  justify-content: stretch;
}

.liquid-fire-cancel {
  flex: 1;
  height: 42px;
  border-radius: var(--apple-squircle-md, 14px);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s var(--apple-ease);
}

.liquid-fire-cancel:hover {
  background: var(--surface-3, var(--line));
  transform: translateY(-1px);
}

.liquid-fire-burn {
  flex: 1.2;
  height: 42px;
  border-radius: var(--apple-squircle-md, 14px);
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--bg);
  font-size: 13.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.18s var(--apple-ease);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
}

.liquid-fire-burn:hover {
  opacity: 0.92;
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

.liquid-fire-burn:active {
  transform: scale(0.97);
}

.liquid-theme-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--line);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.18s var(--apple-ease);
}

.liquid-theme-btn:hover {
  transform: translateY(-1px) scale(1.04);
  border-color: var(--line-strong);
}

.liquid-theme-btn:active {
  transform: scale(0.94);
}

.liquid-theme-btn .moon-icon {
  display: none;
}
:root[data-resolved-theme="dark"] .liquid-theme-btn .sun-icon {
  display: none;
}
:root[data-resolved-theme="dark"] .liquid-theme-btn .moon-icon {
  display: block;
}

/* ── 3. Settings Sheet & Modal ─────────────────────────────────────────── */
.liquid-settings-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(12, 12, 14, 0.4);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 350;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  box-sizing: border-box;
  opacity: 1;
  visibility: visible;
  transition: opacity 0.22s var(--apple-ease), visibility 0.22s;
}

.liquid-settings-backdrop.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.liquid-settings-sheet {
  background: var(--liquid-glass-bg);
  backdrop-filter: var(--liquid-blur);
  -webkit-backdrop-filter: var(--liquid-blur);
  border: 1px solid var(--liquid-glass-border);
  box-shadow: var(--liquid-specular);
  border-radius: var(--apple-squircle-lg);
  width: 100%;
  max-width: 440px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 22px 24px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 20px;
  transform: translateY(0) scale(1);
  transition: transform 0.24s var(--apple-ease);
}

.liquid-settings-backdrop.hidden .liquid-settings-sheet {
  transform: translateY(16px) scale(0.96);
}

@media (max-width: 640px) {
  .liquid-settings-backdrop {
    align-items: flex-end;
    padding: 0;
  }
  .liquid-settings-sheet {
    max-width: 100%;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 26px;
    border-top-right-radius: 26px;
    padding-bottom: calc(var(--sab) + 26px);
    transform: translateY(0);
  }
  .liquid-settings-backdrop.hidden .liquid-settings-sheet {
    transform: translateY(100%);
  }
}

.settings-sheet-handle {
  display: none;
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: var(--line-strong);
  margin: -8px auto 4px;
}

@media (max-width: 640px) {
  .settings-sheet-handle {
    display: block;
  }
}

.settings-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.settings-sheet-title {
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 500;
  color: var(--ink);
  margin: 0;
  line-height: 1.2;
}

.settings-sheet-sub {
  font-size: 12px;
  color: var(--muted);
  display: block;
  margin-top: 2px;
}

.settings-close-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.16s var(--apple-ease);
}

.settings-close-btn:hover {
  color: var(--ink);
  background: var(--surface);
}

.settings-sheet-content {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-group-title {
  font-size: 11.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

/* Apple-style Segmented Theme Track */
.settings-theme-segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.settings-segmented-btn {
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.16s var(--apple-ease);
  text-align: center;
}

.settings-segmented-btn:hover {
  color: var(--ink);
}

.settings-segmented-btn.active {
  background: var(--surface);
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--apple-squircle-md);
  gap: 12px;
}

.settings-nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--apple-squircle-md);
  text-decoration: none;
  color: var(--ink);
  gap: 12px;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.settings-nav-row:hover {
  background: var(--surface-2);
  border-color: var(--line-strong);
}

button.settings-nav-row {
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  box-sizing: border-box;
}

.settings-row-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.settings-row-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

.settings-row-desc {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.35;
}

/* Apple-Style Switch */
.apple-switch {
  width: 44px;
  height: 26px;
  border-radius: 13px;
  background: var(--line-strong);
  position: relative;
  border: none;
  cursor: pointer;
  transition: background-color 0.22s ease;
  flex-shrink: 0;
}

.apple-switch.active {
  background: #34C759;
}

.apple-switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
  transition: transform 0.22s var(--apple-ease);
}

.apple-switch.active .apple-switch-thumb {
  transform: translateX(18px);
}

.settings-danger-btn {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  color: var(--danger);
  background: rgba(162, 59, 43, 0.08);
  border: 1px solid rgba(162, 59, 43, 0.2);
  cursor: pointer;
  transition: background-color 0.16s ease;
  flex-shrink: 0;
}

.settings-danger-btn:hover {
  background: rgba(162, 59, 43, 0.16);
}

/* Refined shared navigation and interaction finish. */
.liquid-desktop-dock {
  max-width: 1160px;
  height: 58px;
  margin-top: 18px;
  margin-bottom: 24px;
  border-color: var(--line);
  box-shadow: 0 10px 32px rgba(21, 20, 15, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.liquid-dock-pill {
  min-height: 40px;
  padding-inline: 16px;
}

.liquid-dock-pill.active {
  color: var(--accent);
}

.liquid-brand-icon {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  background: #29271f;
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 12px rgba(21, 20, 15, 0.14), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.liquid-mobile-tabbar {
  border-top-color: var(--line);
  box-shadow: 0 -8px 28px rgba(21, 20, 15, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.62);
}

.liquid-tab-item.active { color: var(--accent); }

.liquid-tab-item.active .liquid-tab-icon { transform: translateY(-1px); }

.liquid-action-pill,
.liquid-fire-btn,
.liquid-theme-btn {
  transition: transform 160ms var(--apple-ease), background-color 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

@media (max-width: 767px) {
  .liquid-mobile-tabbar {
    height: calc(62px + var(--sab));
    padding-top: 4px;
    padding-bottom: calc(var(--sab) + 5px);
  }

  .liquid-tab-item { gap: 4px; }

  .liquid-tab-label {
    font-size: 10px;
    letter-spacing: 0;
  }
}

