/* ==========================================================================
   Mai-Reads: Stylesheet (Conforming strictly to MAI-READS-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);
}

: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);
}

/* ── 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;
}

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: flex;
  align-items: center;
  justify-content: space-between;
}

.welcome-topbar-actions {
  display: flex;
  align-items: center;
  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;
}

/* Artistic Tactile Drop Card */
.welcome-drop-card {
  width: 100%;
  max-width: 780px;
  margin: 6px auto 0;
  background-color: var(--surface);
  border: 2px dashed var(--line-strong);
  border-radius: 28px;
  padding: 40px 32px 34px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 18px;
  transition: border-color 200ms cubic-bezier(0.16, 1, 0.3, 1), transform 200ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 200ms cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 20px rgba(35, 30, 20, 0.04);
  position: relative;
  overflow: hidden;
}

.welcome-drop-card:hover {
  border-color: var(--ink);
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(35, 30, 20, 0.08);
}

:root[data-resolved-theme="dark"] .welcome-drop-card {
  border-color: #333333;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

:root[data-resolved-theme="dark"] .welcome-drop-card:hover {
  border-color: #666666;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6);
}

.drop-illustration-wrap {
  width: 68px;
  height: 68px;
  border-radius: 20px;
  background-color: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.06);
}

.drop-card-headings {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.drop-card-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.015em;
}

.drop-card-sub {
  font-size: 14.5px;
  color: var(--muted);
}

/* Floating File Format Chips (Trailer Reference) */
.welcome-chip-stack {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.file-chip {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 14px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
  pointer-events: none;
}

.chip-tag {
  font-size: 11px;
  font-weight: 700;
  border-radius: 5px;
  padding: 2px 6px;
  letter-spacing: 0.04em;
}

.chip-pdf {
  background-color: #C0453A;
  color: #FFFFFF;
}

.chip-docx {
  background-color: #3A6FC0;
  color: #FFFFFF;
}

.welcome-hero-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* 3-Pillar Feature Cards Grid */
.welcome-features-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  width: 100%;
  max-width: 980px;
  margin: 12px auto 0;
}

.feature-card {
  background-color: var(--surface);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
  transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1), border-color 200ms cubic-bezier(0.16, 1, 0.3, 1), box-shadow 200ms cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 2px 10px rgba(35, 30, 20, 0.03);
  text-decoration: none;
  color: inherit;
}

.feature-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: 0 10px 24px rgba(35, 30, 20, 0.07);
}

:root[data-resolved-theme="dark"] .feature-card {
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

:root[data-resolved-theme="dark"] .feature-card:hover {
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
}

.feature-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background-color: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  flex-shrink: 0;
}

.feature-card-content {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.feature-card-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 500;
  color: var(--ink);
  letter-spacing: -0.015em;
}

.feature-card-desc {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-2);
}

/* 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-color: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  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 18px;
  width: 100%;
  text-align: left;
  border-bottom: 1px solid var(--line);
  background: transparent;
  cursor: pointer;
  transition: background-color 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

.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;
}

/* 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: 44px;
  padding: 0 8px 0 14px;
  background: rgba(246, 245, 241, 0.94);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  z-index: 85;
  box-shadow: var(--shadow-subtle);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  max-width: min(780px, calc(100vw - 24px - var(--sal) - var(--sar)));
  width: calc(100vw - 32px);
  transition: transform 260ms cubic-bezier(0.16, 1, 0.3, 1), opacity 200ms ease;
}

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

:root[data-resolved-theme="dark"] .doc-title,
:root[data-resolved-theme="dark"] #doc-title {
  background: rgba(24, 24, 26, 0.94);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

.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 .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-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;
}

#reading-surface.highlighting-mode.highlighting-mode-draw .document-page,
#reading-surface.highlighting-mode.highlighting-mode-draw .paper {
  cursor: crosshair !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-color: var(--bg);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  padding: 6px 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  box-shadow: var(--shadow-float);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  max-width: calc(100vw - 24px);
}

:root[data-resolved-theme="dark"] .highlight-bar {
  background-color: rgba(26, 26, 30, 0.96);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.55);
}

.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 */
.reader-dock {
  position: fixed;
  bottom: calc(var(--sab) + 20px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: var(--shadow-float);
  transition: transform 300ms cubic-bezier(0.16, 1, 0.3, 1), opacity 300ms cubic-bezier(0.16, 1, 0.3, 1);
  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: 24px;
  background-color: var(--line);
  margin: 0 2px;
}

.reader-dock .dock-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  transition: background-color 160ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

.reader-dock .dock-btn.active,
#control-toggle.active {
  background-color: var(--ink);
  color: var(--bg);
}

/* 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(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-float);
  padding: 12px;
  z-index: 85;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 180ms cubic-bezier(0.16, 1, 0.3, 1), 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: 34px;
  font-weight: 400;
  color: var(--ink);
  line-height: 1;
}

.page-readout .slash {
  display: none;
}

.page-readout-of {
  font-size: 15px;
  color: var(--muted);
}

#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-fit-chips {
  display: flex;
  gap: 8px;
}

.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 Row 7: Rows (button + chevron) */
.panel-link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 0 4px;
  width: 100%;
  font-size: 14px;
  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;
}

/* Table of Contents */
.outline {
  border: none;
}

.outline summary {
  cursor: pointer;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  list-style: none;
}

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

.outline-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 0;
  max-height: 240px;
  overflow-y: auto;
}

.outline-item {
  font-size: 13.5px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--ink-2);
  cursor: pointer;
  text-align: left;
}

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

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

.btn-primary-block {
  width: 100%;
  min-height: 48px;
  background-color: var(--ink);
  color: var(--bg);
  border-radius: var(--radius-pill);
  font-size: 14px;
  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);
}

.btn-primary-block:hover {
  opacity: 0.92;
}

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

.action-trio .secondary-btn {
  min-height: 40px;
  padding: 0 8px;
  font-size: 12.5px;
  border-radius: 10px;
}

.privacy-note {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  margin-top: 4px;
}

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

.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;
}

/* ── 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-color: var(--bg);
  border-right: 1px solid var(--line);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 200;
  transform: translateX(-100%);
  transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-float);
  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-color: var(--bg);
  border-left: 1px solid var(--line);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 200;
  transform: translateX(100%);
  transition: transform 200ms cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-float);
  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: 250;
  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;
  }
  .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(246, 245, 241, 0.92);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.drop-overlay-box {
  width: 100%;
  max-width: 520px;
  height: 320px;
  border: 1.5px dashed var(--ink);
  border-radius: var(--radius-xl);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

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

.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(--line);
    border-radius: 24px 24px 0 0;
    padding: 16px 20px calc(var(--sab) + 16px);
    box-shadow: var(--shadow-float);
    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(--line);
    border-radius: 24px 24px 0 0;
    padding: 18px 20px calc(var(--sab) + 16px);
    box-shadow: var(--shadow-float);
    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(--line);
    border-bottom: none;
    padding: 20px 24px calc(var(--sab) + 20px);
    box-shadow: var(--shadow-float);
    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);
}

