/* ==========================================================================
   小羊上山 L1 · A3 海報與裸讀純文字網頁版
   Design system:
   - Default 70% desktop width (expands cleanly on tablet/mobile)
   - Warm dark reading studio default + optional low-glare warm paper theme
   - 1 CJK reading font family, strict 3-size body scale, tabular-nums
   - Modern <dialog> top-layer animation + overscroll containment
   ========================================================================== */

:root {
  color-scheme: dark;

  --font-sans: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;

  /* 3-size body scale (brand h1 & user-adjustable story reading text exempt) */
  --text-heading: 1.1875rem;
  --text-body: 1rem;
  --text-sm: 0.875rem;

  /* Warm dark reading studio tokens */
  --bg-page: #151412;
  --bg-surface: #1f1d1a;
  --bg-card: #26231f;
  --bg-card-hover: #2d2924;
  --bg-control: #1a1815;
  --border-subtle: #38332c;
  --border-strong: #4d453b;

  --text-primary: #f2ece1;
  --text-secondary: #b7ac9c;
  --text-on-accent: #1a1410;

  --accent: #e57a4c;
  --accent-hover: #ee8c61;
  --star-empty: #5a5247;
  --star-lit: #f2be3e;
  --done-color: #63bf7f;
  --done-bg: rgba(99, 191, 127, 0.14);

  --header-bg: rgba(21, 20, 18, 0.9);
  --backdrop-bg: rgba(10, 9, 8, 0.78);
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.28);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  --story-font-size: 1.5rem;
  --story-line-height: 1.9;
}

html[data-theme="light"] {
  color-scheme: light;

  /* Low-glare warm paper palette with zero stark white glare */
  --bg-page: #efe9dc;
  --bg-surface: #f5f0e4;
  --bg-card: #faf6ec;
  --bg-card-hover: #f3ecdd;
  --bg-control: #e6dfd0;
  --border-subtle: #d8cebc;
  --border-strong: #bfb29b;

  --text-primary: #2b241d;
  --text-secondary: #685b4d;
  --text-on-accent: #faf6ec;

  --accent: #cc5a2c;
  --accent-hover: #b84c20;
  --star-empty: #c5b8a4;
  --star-lit: #e09a16;
  --done-color: #2e854d;
  --done-bg: rgba(46, 133, 77, 0.12);

  --header-bg: rgba(239, 233, 220, 0.92);
  --backdrop-bg: rgba(34, 28, 22, 0.68);
  --shadow-card: 0 6px 18px rgba(58, 46, 32, 0.08);
}

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

html {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  min-height: 100dvh;
  background-color: var(--bg-page);
  color: var(--text-primary);
  font-size: var(--text-body);
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  transition: background-color 200ms var(--ease-out), color 200ms var(--ease-out);
}

[hidden] {
  display: none !important;
}

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

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 70% Desktop Centered Container */
.shell {
  width: 70%;
  max-width: 70vw;
  margin-inline: auto;
}

@media (max-width: 1024px) {
  .shell {
    width: 90%;
    max-width: 90vw;
  }
}

@media (max-width: 768px) {
  .shell {
    width: 94%;
    max-width: 94vw;
  }
}

/* ==========================================================================
   Header
   ========================================================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background-color: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color 200ms var(--ease-out), border-color 200ms var(--ease-out);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-block: 14px;
}

.brand-group {
  display: flex;
  align-items: baseline;
  gap: 16px;
  min-width: 0;
}

.brand-title {
  margin: 0;
  font-size: clamp(1.25rem, 1.8vw, 1.55rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
}

.header-summary {
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  white-space: nowrap;
}

.header-summary strong {
  color: var(--text-primary);
  font-weight: 700;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Segmented Controls */
.segmented {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  background-color: var(--bg-control);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  gap: 2px;
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 7px 14px;
  border-radius: calc(var(--radius-md) - 3px);
  white-space: nowrap;
  transition: background-color 180ms var(--ease-out), color 180ms var(--ease-out);
}

.seg-btn:hover {
  color: var(--text-primary);
}

.seg-btn[aria-selected="true"],
.seg-btn[aria-checked="true"] {
  background-color: var(--accent);
  color: var(--text-on-accent);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 180ms var(--ease-out), border-color 180ms var(--ease-out);
}

.theme-toggle:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--border-strong);
}

/* ==========================================================================
   Toolbar & Progress Rail
   ========================================================================== */
.workspace {
  padding-top: 22px;
  padding-bottom: 48px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.toolbar-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.auto-hide-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: 600;
}

.auto-hide-switch input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch-track {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background-color: var(--bg-control);
  border: 1px solid var(--border-strong);
  transition: background-color 180ms var(--ease-out), border-color 180ms var(--ease-out);
}

.switch-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: var(--text-secondary);
  transition: transform 180ms var(--ease-out), background-color 180ms var(--ease-out);
}

.auto-hide-switch input:checked + .switch-track {
  background-color: var(--done-bg);
  border-color: var(--done-color);
}

.auto-hide-switch input:checked + .switch-track .switch-thumb {
  transform: translateX(18px);
  background-color: var(--done-color);
}

.auto-hide-switch input:focus-visible + .switch-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.progress-rail {
  height: 4px;
  width: 100%;
  background-color: var(--bg-surface);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 24px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--star-lit));
  border-radius: 999px;
  transition: width 260ms var(--ease-out);
}

/* ==========================================================================
   Book Grid & Cards
   ========================================================================== */
.book-grid {
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.book-grid[data-mode="text"][data-size="xl"] {
  grid-template-columns: 1fr;
}

@media (max-width: 860px) {
  .book-grid {
    grid-template-columns: 1fr;
  }
}

.book-card {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition:
    transform 200ms var(--ease-out),
    opacity 200ms var(--ease-out),
    border-color 180ms var(--ease-out),
    background-color 180ms var(--ease-out);
}

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

.book-card.is-done {
  border-color: rgba(99, 191, 127, 0.45);
}

.book-card.is-hiding {
  opacity: 0;
  transform: scale(0.96) translateY(-6px);
  pointer-events: none;
}

.card-accent-bar {
  height: 4px;
  width: 100%;
  background-color: var(--book-color, var(--accent));
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 12px;
}

.card-title-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.book-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: var(--book-color, var(--accent));
  color: #faf6ec;
  font-size: var(--text-sm);
  font-weight: 800;
  flex-shrink: 0;
}

.book-title {
  margin: 0;
  font-size: var(--text-heading);
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Poster Preview Surface */
.poster-trigger {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  background-color: var(--bg-surface);
  overflow: hidden;
  aspect-ratio: 1080 / 764;
}

.poster-thumb {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 240ms var(--ease-out);
}

.poster-trigger:hover .poster-thumb {
  transform: scale(1.018);
}

.poster-zoom-hint {
  position: absolute;
  right: 12px;
  bottom: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background-color: rgba(21, 20, 18, 0.78);
  color: #f2ece1;
  font-size: var(--text-sm);
  font-weight: 600;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out);
  pointer-events: none;
}

.poster-trigger:hover .poster-zoom-hint,
.poster-trigger:focus-visible .poster-zoom-hint {
  opacity: 1;
  transform: translateY(0);
}

/* Pure-Text Reading Surface */
.text-sheet {
  flex: 1;
  padding: 6px 20px 18px;
  border-top: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background-color 180ms var(--ease-out);
}

.text-sheet:hover {
  background-color: var(--bg-card-hover);
}

.story-lines {
  max-width: 65ch;
  font-size: var(--story-font-size);
  line-height: var(--story-line-height);
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.story-lines p {
  margin: 0;
}

.story-lines p + p {
  margin-top: 0.42em;
}

/* Card Footer Controls: Stars + Done Checkbox */
.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
}

.star-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.star-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--star-empty);
  transition: transform 160ms var(--ease-out), color 160ms var(--ease-out), background-color 160ms var(--ease-out);
}

.star-btn:hover {
  background-color: rgba(242, 190, 62, 0.14);
  transform: scale(1.12);
}

.star-btn[aria-pressed="true"] {
  color: var(--star-lit);
}

.star-btn svg {
  width: 24px;
  height: 24px;
  display: block;
}

.star-btn.just-lit {
  animation: star-pop 280ms var(--ease-out);
}

@keyframes star-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.32); }
  100% { transform: scale(1); }
}

.card-foot-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.focus-text-btn {
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  transition: color 160ms var(--ease-out), border-color 160ms var(--ease-out), background-color 160ms var(--ease-out);
}

.focus-text-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
  background-color: var(--bg-card-hover);
}

/* Done Checkbox Button */
.done-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background-color: var(--bg-card);
  color: var(--text-primary);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background-color 180ms var(--ease-out), border-color 180ms var(--ease-out), color 180ms var(--ease-out);
}

.done-check:hover {
  border-color: var(--done-color);
}

.done-check input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.check-box {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 2px solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background-color 160ms var(--ease-out), border-color 160ms var(--ease-out);
}

.done-check input:checked + .check-box {
  background-color: var(--done-color);
  border-color: var(--done-color);
}

.done-check input:checked + .check-box::after {
  content: "";
  width: 5px;
  height: 9px;
  border: solid #121c15;
  border-width: 0 2.2px 2.2px 0;
  transform: rotate(45deg) translate(-0.5px, -1px);
}

.done-check:has(input:checked) {
  background-color: var(--done-bg);
  border-color: var(--done-color);
  color: var(--done-color);
}

.done-check:has(input:focus-visible) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ==========================================================================
   Empty State & Collapsible Guide
   ========================================================================== */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background-color: var(--bg-surface);
}

.empty-stars {
  font-size: 2rem;
  color: var(--star-lit);
  letter-spacing: 0.25em;
  margin-bottom: 12px;
}

.empty-title {
  margin: 0 0 8px;
  font-size: var(--text-heading);
  font-weight: 700;
}

.empty-desc {
  margin: 0 auto 20px;
  max-width: 44ch;
  color: var(--text-secondary);
  font-size: var(--text-body);
}

.primary-btn {
  border: 0;
  border-radius: var(--radius-md);
  background-color: var(--accent);
  color: var(--text-on-accent);
  font-size: var(--text-body);
  font-weight: 700;
  padding: 10px 22px;
  transition: background-color 180ms var(--ease-out), transform 160ms var(--ease-out);
}

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

.guide-details {
  margin-top: 32px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  padding: 12px 18px;
}

.guide-details summary {
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-secondary);
  user-select: none;
}

.guide-details[open] summary {
  color: var(--text-primary);
  margin-bottom: 12px;
}

.guide-body ul {
  margin: 0;
  padding-left: 20px;
  color: var(--text-secondary);
  font-size: var(--text-body);
}

.guide-body li + li {
  margin-top: 6px;
}

.guide-actions {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.reset-btn {
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  transition: color 160ms var(--ease-out), border-color 160ms var(--ease-out);
}

.reset-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.site-footer {
  padding-block: 18px 34px;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.site-footer p {
  margin: 0;
}

/* ==========================================================================
   Modal Dialog Viewer (Top-Layer Entry/Exit + Scroll Containment)
   ========================================================================== */
.viewer-dialog {
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background-color: var(--bg-page);
  color: var(--text-primary);
  overflow: hidden;
  overscroll-behavior: contain;

  /* Top-layer exit/base state */
  opacity: 0;
  transition-property: opacity, transform, display, overlay;
  transition-duration: 200ms;
  transition-timing-function: var(--ease-out);
  transition-behavior: allow-discrete;
}

@media (prefers-reduced-motion: no-preference) {
  .viewer-dialog {
    transform: scale(0.985);
  }
}

.viewer-dialog::backdrop {
  background-color: rgba(10, 9, 8, 0);
  overflow: hidden;
  overscroll-behavior: contain;
  transition-property: background-color, display, overlay;
  transition-duration: 220ms;
  transition-timing-function: var(--ease-out);
  transition-behavior: allow-discrete;
}

:is(.viewer-dialog[open]):where(:not([data-closing])) {
  opacity: 1;

  @starting-style {
    opacity: 0;
  }

  @media (prefers-reduced-motion: no-preference) {
    transform: scale(1);

    @starting-style {
      transform: scale(0.985);
    }
  }

  &::backdrop {
    background-color: var(--backdrop-bg);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);

    @starting-style {
      background-color: rgba(10, 9, 8, 0);
    }
  }
}

.viewer-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

.viewer-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 14px;
  background-color: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
  transition: transform 200ms var(--ease-out), opacity 180ms var(--ease-out);
}

.viewer-shell.bar-visible .viewer-bar,
.viewer-bar:focus-within {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.viewer-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.viewer-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: var(--accent);
  color: #faf6ec;
  font-size: var(--text-sm);
  font-weight: 800;
  flex-shrink: 0;
}

.viewer-title {
  margin: 0;
  font-size: var(--text-heading);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.zoom-controls,
.nav-controls {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background-color: var(--bg-card);
  overflow: hidden;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--text-primary);
  font-size: 1.125rem;
  font-weight: 700;
  transition: background-color 150ms var(--ease-out);
}

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

.zoom-readout {
  border: 0;
  border-inline: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: 600;
  min-width: 58px;
  height: 36px;
  padding: 0 8px;
}

.zoom-readout:hover {
  color: var(--text-primary);
}

.close-btn {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background-color: var(--bg-card);
}

.viewer-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-page);
}

.poster-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  cursor: zoom-in;
}

.poster-viewport.is-zoomed {
  cursor: grab;
}

.poster-viewport.is-dragging {
  cursor: grabbing;
}

.viewer-poster-img {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 0;
  box-shadow: none;
  transform-origin: center center;
  will-change: transform;
  transition: transform 160ms var(--ease-out);
}

.poster-viewport.is-dragging .viewer-poster-img {
  transition: none;
}

/* Focus Pure-Text Reader inside Dialog: 100% full-screen, auto-fitted, zero scroll */
.text-focus-sheet {
  width: 100%;
  height: 100%;
  overflow: hidden;
  padding: clamp(18px, 2.8vh, 36px) clamp(24px, 3.5vw, 56px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

.text-focus-sheet.allow-scroll {
  overflow-y: auto;
  justify-content: flex-start;
  overscroll-behavior: contain;
}

.text-focus-body {
  width: 100%;
  max-width: 100%;
  font-size: 44px;
  line-height: 1.48;
  letter-spacing: 0.025em;
  color: var(--text-primary);
}

.text-focus-heading {
  display: flex;
  align-items: center;
  gap: 0.4em;
  margin: 0 0 0.45em;
  padding-bottom: 0.25em;
  border-bottom: 2px solid var(--border-subtle);
  font-size: 1.12em;
  font-weight: 800;
  line-height: 1.25;
  color: var(--text-primary);
}

.text-focus-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.45em;
  height: 1.45em;
  padding: 0 0.25em;
  border-radius: 999px;
  background-color: var(--focus-color, var(--accent));
  color: #faf6ec;
  font-size: 0.72em;
  font-weight: 800;
  flex-shrink: 0;
}

.text-focus-body p {
  margin: 0;
}

.text-focus-body p + p {
  margin-top: 0.22em;
}

/* ==========================================================================
   Undo Toast
   ========================================================================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 40;
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  background-color: var(--bg-card);
  border: 1px solid var(--border-strong);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  font-size: var(--text-sm);
}

.toast[hidden] {
  display: none;
}

.toast-undo {
  border: 0;
  background-color: var(--accent);
  color: var(--text-on-accent);
  font-weight: 700;
  font-size: var(--text-sm);
  padding: 5px 12px;
  border-radius: var(--radius-sm);
}

/* ==========================================================================
   Responsive & Reduced Motion
   ========================================================================== */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .brand-group {
    justify-content: space-between;
  }

  .header-controls {
    justify-content: space-between;
  }

  .viewer-dialog {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    border: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .viewer-dialog,
  .viewer-dialog::backdrop {
    transition-duration: 90ms;
  }

  .book-card,
  .poster-thumb,
  .star-btn,
  .progress-fill {
    transition-duration: 1ms;
    animation: none;
  }
}
