/*
 * ValentineDesigns Reader
 * --------------------
 * The UI is token-driven so theme fixes happen once and apply everywhere.
 * Story artwork lives inside .page-frame and does not inherit interface colors.
 */

:root {
  color-scheme: dark;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: Georgia, "Times New Roman", serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --ui-scale: 1;
  --bg: #050506;
  --bg-raised: #0a0b0e;
  --surface: #0e0f13;
  --surface-2: #15171d;
  --surface-3: #1b1e26;
  --text: #f3f1ec;
  --text-soft: #b0b1b7;
  --text-faint: #94969f;
  --line: #272a32;
  --line-strong: #3a3e49;
  --accent: #c53250;
  --accent-strong: #ee4569;
  --accent-soft: rgb(197 50 80 / 18%);
  --focus: #9bd5ff;
  --good: #5bc798;
  --warning: #e8b75f;
  --danger: #ff6b7e;
  --shadow: 0 24px 70px rgb(0 0 0 / 55%);
  --text-outline: 0 1px 1px rgb(0 0 0 / 62%);
  --topbar-height: 68px;
  --controls-height: 74px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

html[data-theme="dark"] {
  --bg: #101116;
  --bg-raised: #17191f;
  --surface: #1c1f26;
  --surface-2: #242832;
  --surface-3: #2c313c;
  --text-faint: #a7a9b2;
  --line: #383d48;
  --line-strong: #4d5361;
  --shadow: 0 24px 70px rgb(0 0 0 / 38%);
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #f1eee8;
  --bg-raised: #f9f7f3;
  --surface: #fffdfa;
  --surface-2: #ece8e1;
  --surface-3: #ddd8cf;
  --text: #16171a;
  --text-soft: #505159;
  --text-faint: #5f6068;
  --line: #d1ccc3;
  --line-strong: #aaa49a;
  --accent: #a92342;
  --accent-strong: #83172f;
  --accent-soft: rgb(169 35 66 / 12%);
  --focus: #005ea8;
  --good: #16734e;
  --warning: #8b5a00;
  --danger: #a71936;
  --shadow: 0 24px 70px rgb(35 28 20 / 20%);
  --text-outline: none;
}

html[data-theme="contrast"] {
  color-scheme: dark;
  --bg: #000;
  --bg-raised: #000;
  --surface: #000;
  --surface-2: #090909;
  --surface-3: #111;
  --text: #fff;
  --text-soft: #fff;
  --text-faint: #ddd;
  --line: #fff;
  --line-strong: #fff;
  --accent: #ff315b;
  --accent-strong: #ffec3d;
  --accent-soft: rgb(255 236 61 / 18%);
  --focus: #49eaff;
  --good: #76ffb4;
  --warning: #ffec3d;
  --danger: #ff5b74;
  --shadow: 0 0 0 2px #fff;
  --text-outline: 0 1px 0 #000, 1px 0 0 #000, 0 -1px 0 #000, -1px 0 0 #000;
}

html[data-theme="contrast"] .primary-button,
html[data-theme="contrast"] .control-button--primary {
  color: #000;
  text-shadow: none;
}

html[data-text-scale="small"] { --ui-scale: 0.9; }
html[data-text-scale="large"] { --ui-scale: 1.14; }
html[data-text-scale="largest"] { --ui-scale: 1.32; }
html[data-outline="strong"] { --text-outline: 0 1px 1px #000, 1px 0 1px #000, 0 -1px 1px #000, -1px 0 1px #000; }

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; height: 100dvh; margin: 0; }

html {
  background: var(--bg);
  font-size: calc(16px * var(--ui-scale));
  overflow: hidden;
  text-rendering: optimizeLegibility;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  min-width: 280px;
  overflow: hidden;
  text-shadow: var(--text-outline);
}

button, input, select { font: inherit; }
button, select, input[type="range"] { color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

button:disabled { cursor: not-allowed; opacity: 0.38; }

svg {
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.7;
}

h1, h2, h3, p { margin-top: 0; }
h2 { font-family: var(--font-display); font-size: clamp(1.55rem, 5vw, 2.15rem); font-weight: 500; letter-spacing: -0.035em; margin-bottom: 0; overflow-wrap: anywhere; }
h3 { font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase; }
p { color: var(--text-soft); line-height: 1.58; overflow-wrap: anywhere; }
code { background: var(--surface-3); border: 1px solid var(--line); border-radius: 4px; font-family: var(--font-mono); padding: 0.12em 0.34em; }

.sr-only {
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  height: 1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

.skip-link {
  background: var(--text);
  color: var(--bg);
  left: 1rem;
  padding: 0.7rem 1rem;
  position: fixed;
  top: -5rem;
  z-index: 1000;
}
.skip-link:focus { top: 1rem; }

.app-shell { height: 100%; height: 100dvh; isolation: isolate; overflow: hidden; position: relative; }

.topbar {
  align-items: center;
  background: color-mix(in srgb, var(--bg-raised) 92%, transparent);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 1.2fr) minmax(220px, 1fr);
  height: calc(var(--topbar-height) + var(--safe-top));
  left: 0;
  padding: var(--safe-top) max(0.85rem, var(--safe-right)) 0 max(0.85rem, var(--safe-left));
  position: fixed;
  right: 0;
  top: 0;
  z-index: 30;
}

.topbar__left, .topbar__actions { align-items: center; display: flex; gap: 0.65rem; min-width: 0; }
.topbar__actions { justify-self: end; }

.wordmark { align-items: center; color: inherit; display: flex; gap: 0.55rem; line-height: 1; min-width: 0; text-decoration: none; text-transform: uppercase; }
.wordmark > img { flex: 0 0 36px; height: 36px; object-fit: contain; width: 36px; }
.wordmark > span { display: flex; flex-direction: column; min-width: 0; }
.wordmark__brand { color: var(--accent-strong); font-size: max(0.58rem, 11px); font-weight: 800; letter-spacing: 0.28em; overflow: hidden; text-overflow: ellipsis; }
.wordmark__product { font-size: 0.88rem; font-weight: 730; letter-spacing: 0.075em; margin-top: 0.28rem; white-space: nowrap; }
.wordmark__product i { color: var(--text-faint); font-size: max(0.63rem, 11px); font-style: normal; font-weight: 650; }

.book-heading { min-width: 0; text-align: center; }
.book-heading strong, .book-heading span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-heading strong { font-family: var(--font-display); font-size: 1rem; font-weight: 500; }
.book-heading span { color: var(--text-faint); font-size: max(0.55rem, 11px); font-weight: 760; letter-spacing: 0.14em; margin-top: 0.26rem; }

.icon-button, .control-button {
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text-soft);
  cursor: pointer;
  display: inline-flex;
  flex: 0 0 auto;
  height: 42px;
  justify-content: center;
  min-width: 42px;
  padding: 0.55rem;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}
.icon-button:hover, .control-button:hover { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.icon-button:active, .control-button:active { transform: scale(0.94); }
.icon-button svg, .control-button svg { height: 21px; width: 21px; }
.icon-button--small { height: 36px; min-width: 36px; padding: 0.45rem; }
.icon-button--small svg { height: 18px; width: 18px; }

#sound-toggle .sound-off { display: none; }
#sound-toggle[aria-pressed="false"] .sound-on { display: none; }
#sound-toggle[aria-pressed="false"] .sound-off { display: block; }

.topbar-button, .primary-button, .secondary-button, .text-button {
  border-radius: 6px;
  cursor: pointer;
  font-size: max(0.69rem, 11px);
  font-weight: 780;
  letter-spacing: 0.08em;
  max-width: 100%;
  overflow-wrap: anywhere;
  padding: 0.75rem 0.95rem;
  text-transform: uppercase;
  transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
}
.topbar-button { background: var(--surface-2); border: 1px solid var(--line); }
.primary-button { background: var(--accent); border: 1px solid var(--accent); color: #fff; text-shadow: 0 1px 1px #5a0a1d; }
.primary-button:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.secondary-button { background: transparent; border: 1px solid var(--line-strong); color: var(--text); }
.secondary-button:hover { background: var(--surface-2); }
.text-button { background: transparent; border: 0; color: var(--text-soft); padding: 0.55rem 0; text-align: left; }
.text-button:hover { color: var(--accent-strong); }
.primary-button:active, .secondary-button:active, .topbar-button:active { transform: translateY(1px); }

.reader {
  background: var(--bg);
  bottom: 0;
  left: 0;
  overflow: hidden;
  position: fixed;
  right: 0;
  top: calc(var(--topbar-height) + var(--safe-top));
}

.ambient-background {
  background: radial-gradient(circle at 60% 25%, #161c27, var(--bg) 58%);
  inset: 0;
  opacity: 0.9;
  position: absolute;
  transform: scale(1.04);
  transition: background 800ms ease, opacity 500ms ease;
}
.ambient-background::after {
  background: linear-gradient(90deg, var(--bg) 0, transparent 24%, transparent 76%, var(--bg) 100%);
  content: "";
  inset: 0;
  position: absolute;
}

.reader-viewport {
  bottom: calc(var(--controls-height) + var(--safe-bottom));
  display: grid;
  inset-inline: 0;
  overflow: auto;
  overscroll-behavior: contain;
  place-items: center;
  position: absolute;
  top: 0;
}

.reader-stage {
  --page-zoom: 1;
  --stage-padding: clamp(0.7rem, 2.5vw, 1.6rem);
  --tilt-x: 0;
  --tilt-y: 0;
  align-items: safe center;
  display: flex;
  height: 100%;
  justify-content: safe center;
  min-height: 0;
  min-width: 100%;
  padding: var(--stage-padding);
  padding-left: max(var(--stage-padding), var(--safe-left));
  padding-right: max(var(--stage-padding), var(--safe-right));
  position: relative;
  touch-action: auto;
}
.reader-stage:focus-visible { box-shadow: inset 0 0 0 2px var(--focus); }
.reader[data-swipe="on"] .reader-stage { touch-action: pan-y pinch-zoom; }
.reader[data-pan-x="true"] .reader-stage { touch-action: pan-x pan-y pinch-zoom; }
.reader[data-fit="width"] .reader-stage,
.reader[data-zoomed="true"] .reader-stage { align-items: flex-start; }
.reader[data-fit="width"] .page-frame,
.reader[data-zoomed="true"] .page-frame { margin-inline: auto; }

.page-frame {
  aspect-ratio: var(--page-ratio, 2 / 3);
  background: #07080b;
  box-shadow: 0 20px 60px rgb(0 0 0 / 56%), 0 0 0 1px rgb(255 255 255 / 10%);
  overflow: hidden;
  position: relative;
  transition: width 180ms ease, height 180ms ease, zoom 170ms ease;
  zoom: var(--page-zoom);
}

.page-background, .panel-layer, .page-grain { inset: 0; position: absolute; }
.page-background { background: #090b10; background-position: center; background-repeat: no-repeat; background-size: cover; transition: background 620ms ease; }
.panel-layer { transform-style: preserve-3d; }
.page-grain { background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.18'/%3E%3C/svg%3E"); mix-blend-mode: soft-light; opacity: 0.16; pointer-events: none; z-index: 900; }

.story-panel {
  align-items: center;
  border-radius: calc(var(--panel-radius, 0) * 1%);
  display: flex;
  justify-content: center;
  left: calc(var(--panel-x) * 1%);
  min-height: 1px;
  overflow: hidden;
  position: absolute;
  top: calc(var(--panel-y) * 1%);
  transform: translate3d(calc(var(--tilt-x) * var(--panel-depth) * 1px), calc(var(--tilt-y) * var(--panel-depth) * 1px), 0) rotate(calc(var(--panel-rotation) * 1deg));
  transition: opacity var(--reveal-duration) ease, transform var(--reveal-duration) cubic-bezier(.2,.8,.2,1), filter var(--reveal-duration) ease;
  width: calc(var(--panel-width) * 1%);
  height: calc(var(--panel-height) * 1%);
}
.story-panel:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.story-panel > img, .story-panel > video, .story-panel > canvas { display: block; height: 100%; object-fit: var(--panel-fit); width: 100%; }
.story-panel > video { background: #000; }
.story-panel--error { background: #18090d; border: 1px solid #a92d48; color: #fff; font-size: 0.7rem; padding: 0.7rem; text-align: center; }
.story-panel--text {
  align-items: flex-start;
  background: rgb(5 6 10 / 82%);
  border: 1px solid rgb(255 255 255 / 17%);
  color: #f7f5f0;
  font-family: var(--font-display);
  font-size: clamp(0.62rem, calc(var(--ui-scale) * 1.45vw), 1.35rem);
  line-height: 1.35;
  justify-content: flex-start;
  overflow: auto;
  padding: clamp(0.55rem, 2vw, 1.2rem);
  text-wrap: balance;
  text-shadow: 0 2px 3px #000, 0 0 2px #000;
}
.story-panel--text p { color: inherit; margin: 0; }

.story-panel.is-entering[data-transition="fade"] { opacity: 0; }
.story-panel.is-entering[data-transition="rise"] { opacity: 0; transform: translate3d(0, 24px, 0); }
.story-panel.is-entering[data-transition="slide-left"] { opacity: 0; transform: translate3d(-45px, 0, 0); }
.story-panel.is-entering[data-transition="slide-right"] { opacity: 0; transform: translate3d(45px, 0, 0); }
.story-panel.is-entering[data-transition="ink"] { filter: blur(8px) contrast(1.8); opacity: 0; transform: scale(0.94); }
.story-panel.is-entering[data-transition="focus"] { filter: blur(14px); opacity: 0; transform: scale(1.12); }

.panel-layer.has-focus .story-panel:not(.is-focused) { filter: blur(2px) brightness(0.35); opacity: 0.18; pointer-events: none; }
.panel-layer.has-focus .story-panel.is-focused {
  border-radius: 0;
  filter: none;
  height: 94% !important;
  left: 3% !important;
  top: 3% !important;
  transform: none !important;
  width: 94% !important;
  z-index: 1200 !important;
}
.panel-layer.has-focus .story-panel.is-focused > img,
.panel-layer.has-focus .story-panel.is-focused > video,
.panel-layer.has-focus .story-panel.is-focused > canvas { object-fit: contain !important; }

.motion-on .story-panel[data-animation="drift"] > :first-child { animation: panel-drift var(--animation-duration) ease-in-out infinite alternate; }
.motion-on .story-panel[data-animation="pulse"] { animation: panel-pulse var(--animation-duration) ease-in-out infinite; }
.motion-on .story-panel[data-animation="float"] { animation: panel-float var(--animation-duration) ease-in-out infinite alternate; }
.motion-on .story-panel[data-animation="pan"] > :first-child { animation: panel-pan var(--animation-duration) ease-in-out infinite alternate; }
.motion-on .story-panel[data-animation="breathe"] { animation: panel-breathe var(--animation-duration) ease-in-out infinite; }

@keyframes panel-drift { to { transform: scale(1.025) translate3d(0.5%, -0.4%, 0); } }
@keyframes panel-pan { from { transform: scale(1.035) translateX(-0.8%); } to { transform: scale(1.035) translateX(0.8%); } }
@keyframes panel-pulse { 50% { filter: brightness(1.15); } }
@keyframes panel-float { to { translate: 0 -3px; } }
@keyframes panel-breathe { 50% { filter: brightness(1.13); scale: 1.012; } }

.page-loading {
  align-items: center;
  background: rgb(5 6 8 / 82%);
  color: #e8e8e8;
  display: flex;
  flex-direction: column;
  font-size: max(0.66rem, 11px);
  gap: 0.75rem;
  inset: 0;
  justify-content: center;
  letter-spacing: 0.11em;
  position: absolute;
  text-transform: uppercase;
  z-index: 950;
}
.loading-ring { animation: spin 700ms linear infinite; border: 2px solid rgb(255 255 255 / 18%); border-radius: 50%; border-top-color: var(--accent-strong); height: 28px; width: 28px; }
@keyframes spin { to { transform: rotate(360deg); } }

.gesture-feedback { border: 2px solid var(--accent-strong); border-radius: 50%; height: 40px; opacity: 0; pointer-events: none; position: fixed; transform: translate(-50%, -50%) scale(0.45); width: 40px; z-index: 999; }
.gesture-feedback.is-visible { animation: tap-feedback 360ms ease-out; }
@keyframes tap-feedback { 0% { opacity: 0.8; transform: translate(-50%, -50%) scale(0.45); } 100% { opacity: 0; transform: translate(-50%, -50%) scale(1.45); } }

.drag-overlay { align-items: center; backdrop-filter: blur(12px); background: rgb(7 8 12 / 86%); border: 2px dashed var(--accent-strong); display: flex; flex-direction: column; gap: 0.35rem; inset: 1rem; justify-content: center; position: absolute; z-index: 1000; }
.drag-overlay strong { font-family: var(--font-display); font-size: 1.8rem; font-weight: 500; }
.drag-overlay span { color: var(--text-soft); }

.cue-caption { background: var(--surface); border: 1px solid var(--line-strong); border-radius: 6px; bottom: calc(var(--controls-height) + var(--safe-bottom) + 1rem); box-shadow: var(--shadow); color: var(--text); left: 50%; max-width: min(82vw, 520px); overflow-wrap: anywhere; padding: 0.65rem 0.9rem; position: fixed; text-align: center; transform: translateX(-50%); z-index: 26; }

.reader-controls {
  align-items: center;
  background: color-mix(in srgb, var(--bg-raised) 94%, transparent);
  border-top: 1px solid var(--line);
  bottom: 0;
  display: flex;
  gap: 0.42rem;
  height: calc(var(--controls-height) + var(--safe-bottom));
  justify-content: center;
  left: 0;
  padding: 0.5rem max(0.65rem, var(--safe-right)) var(--safe-bottom) max(0.65rem, var(--safe-left));
  position: absolute;
  right: 0;
  z-index: 25;
}

.control-button { border-color: var(--line); border-radius: 50%; height: 42px; min-width: 42px; }
.control-button--primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.control-button--primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.auto-button { border-radius: 8px; gap: 0.35rem; padding-inline: 0.7rem; }
.auto-button svg { height: 14px; width: 14px; }
.auto-button span { font-size: max(0.57rem, 11px); font-weight: 850; letter-spacing: 0.12em; }
.auto-button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent-strong); color: var(--accent-strong); }

.progress-cluster { display: flex; flex-direction: column; gap: 0.38rem; margin: 0 0.4rem; min-width: min(30vw, 230px); }
.page-indicator { background: transparent; border: 0; color: var(--text-soft); cursor: pointer; min-width: 0; padding: 0; }
.page-indicator span, .page-indicator strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-indicator span { font-size: max(0.57rem, 11px); font-weight: 800; letter-spacing: 0.14em; }
.page-indicator strong { color: var(--text); font-size: max(0.68rem, 11px); margin-top: 0.18rem; }
.progress-track { background: var(--line); height: 2px; overflow: hidden; }
.progress-track i { background: var(--accent-strong); display: block; height: 100%; transform: scaleX(0); transform-origin: left; transition: transform 280ms ease; }
.control-divider { background: var(--line); height: 28px; margin: 0 0.2rem; width: 1px; }
.zoom-label { color: var(--text-faint); font-family: var(--font-mono); font-size: max(0.59rem, 11px); min-width: 3rem; text-align: center; }

.drawer, .timeline {
  background: var(--surface);
  box-shadow: var(--shadow);
  color: var(--text);
  position: fixed;
  transition: transform 280ms cubic-bezier(.2,.8,.2,1), visibility 280ms;
  visibility: hidden;
  z-index: 60;
}
.drawer { bottom: 0; display: flex; flex-direction: column; max-width: calc(100vw - 1rem); top: 0; width: min(390px, 92vw); }
.drawer--left { left: 0; padding-left: var(--safe-left); transform: translateX(-105%); }
.drawer--right { padding-right: var(--safe-right); right: 0; transform: translateX(105%); }
.drawer.is-open { transform: translateX(0); visibility: visible; }
.drawer__header, .timeline__header, .dialog header {
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  min-height: calc(var(--topbar-height) + var(--safe-top));
  padding: calc(1rem + var(--safe-top)) 1rem 1rem;
}
.drawer__header { flex: 0 0 auto; }
.drawer__header > div, .timeline__header > div, .dialog header > div { min-width: 0; }
.eyebrow { color: var(--accent-strong); display: block; font-size: max(0.55rem, 11px); font-weight: 850; letter-spacing: 0.18em; margin-bottom: 0.45rem; text-transform: uppercase; }

.import-card { border-bottom: 1px solid var(--line); display: grid; gap: 0.85rem; grid-template-columns: auto 1fr; padding: 1.25rem 1rem; }
.import-card__mark { align-items: center; background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 60%, var(--line)); border-radius: 50%; color: var(--accent-strong); display: flex; font-size: 1.25rem; height: 42px; justify-content: center; width: 42px; }
.import-card strong { display: block; overflow-wrap: anywhere; }
.import-card p { font-size: 0.76rem; margin: 0.35rem 0 0; }
.import-card .primary-button { grid-column: 1 / -1; }

.library-section { padding: 1.1rem 1rem; }
.section-heading { align-items: baseline; display: flex; gap: 0.8rem; justify-content: space-between; }
.section-heading h3 { margin: 0; }
.section-heading span { color: var(--text-faint); font-size: max(0.59rem, 11px); text-align: right; }
.library-section:has(.local-books) { display: flex; flex: 1 1 auto; flex-direction: column; min-height: 0; }
.local-books {
  align-content: start;
  display: grid;
  flex: 1 1 auto;
  gap: 0.55rem;
  grid-auto-rows: max-content;
  margin-top: 0.8rem;
  min-height: 0;
  overflow: auto;
}
.empty-copy { border: 1px dashed var(--line); border-radius: 7px; font-size: 0.76rem; margin: 0; padding: 0.9rem; }
.book-row { align-items: center; align-self: start; background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; display: grid; gap: 0.2rem 0.65rem; grid-template-columns: 1fr auto; min-height: 3.75rem; padding: 0.7rem; }
.book-row button { background: transparent; border: 0; color: var(--text); cursor: pointer; min-width: 0; padding: 0; text-align: left; }
.book-row strong, .book-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.book-row small { color: var(--text-faint); font-size: max(0.62rem, 11px); margin-top: 0.22rem; }
.book-row .book-delete { border-radius: 5px; color: var(--text-faint); font-size: 1rem; padding: 0.4rem; }
.book-row .book-delete:hover { background: var(--accent-soft); color: var(--danger); }
.library-section--bottom { border-top: 1px solid var(--line); display: grid; flex: 0 0 auto; margin-top: auto; position: static; width: 100%; }

.settings-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; padding-bottom: max(1rem, var(--safe-bottom)); }
.settings details { border-bottom: 1px solid var(--line); }
.settings summary { cursor: pointer; font-size: max(0.68rem, 11px); font-weight: 850; letter-spacing: 0.12em; list-style: none; padding: 1rem; text-transform: uppercase; }
.settings summary::-webkit-details-marker { display: none; }
.settings summary::after { color: var(--text-faint); content: "+"; float: right; font-size: 1rem; }
.settings details[open] summary::after { content: "−"; }
.setting-group { display: grid; gap: 0.3rem; padding: 0 0.75rem 1rem; }
.setting-row, .toggle-row { align-items: center; border-radius: 7px; display: flex; gap: 0.9rem; justify-content: space-between; min-width: 0; padding: 0.72rem 0.35rem; }
.setting-row > span:first-child, .toggle-row > span:first-child { min-width: 0; }
.setting-row strong, .toggle-row strong { display: block; font-size: 0.76rem; overflow-wrap: anywhere; }
.setting-row small, .toggle-row small { color: var(--text-faint); display: block; font-size: max(0.64rem, 11px); line-height: 1.45; margin-top: 0.22rem; overflow-wrap: anywhere; }
.setting-row select { background: var(--surface-2); border: 1px solid var(--line); border-radius: 5px; flex: 0 0 auto; font-size: max(0.68rem, 11px); max-width: 42%; padding: 0.52rem 1.6rem 0.52rem 0.55rem; }
.setting-row--stacked { align-items: stretch; flex-direction: column; }
.orientation-setting { background: color-mix(in srgb, var(--accent) 6%, transparent); border: 1px solid var(--line); margin-block: 0.2rem; padding-inline: 0.65rem; }
.orientation-setting select:disabled { cursor: not-allowed; }

.toggle-row input { height: 1px; opacity: 0; position: absolute; width: 1px; }
.toggle-row > i { background: var(--surface-3); border: 1px solid var(--line-strong); border-radius: 999px; flex: 0 0 auto; height: 24px; position: relative; transition: background 160ms ease, border-color 160ms ease; width: 42px; }
.toggle-row > i::after { background: var(--text-soft); border-radius: 50%; content: ""; height: 16px; left: 3px; position: absolute; top: 3px; transition: transform 160ms ease, background 160ms ease; width: 16px; }
.toggle-row input:checked + i { background: var(--accent-soft); border-color: var(--accent); }
.toggle-row input:checked + i::after { background: var(--accent-strong); transform: translateX(18px); }
.toggle-row input:focus-visible + i { outline: 2px solid var(--focus); outline-offset: 3px; }
.toggle-row--boxed { background: var(--surface-2); border: 1px solid var(--line); padding: 0.9rem; }

.choice-fieldset { border: 0; margin: 0; min-width: 0; padding: 0.65rem 0.35rem; }
.choice-fieldset legend { font-size: 0.76rem; font-weight: 750; margin-bottom: 0.6rem; }
.choice-grid { display: grid; gap: 0.4rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.choice-grid label { min-width: 0; }
.choice-grid input { height: 1px; opacity: 0; position: absolute; width: 1px; }
.choice-grid span { align-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; display: flex; font-size: max(0.65rem, 11px); font-weight: 750; justify-content: center; min-height: 42px; overflow-wrap: anywhere; padding: 0.55rem; text-align: center; }
.choice-grid input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-strong); }
.choice-grid input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.range-row { align-items: center; display: flex; gap: 0.7rem; }
.range-row input { accent-color: var(--accent-strong); min-width: 0; width: 100%; }
.range-row output { color: var(--text-faint); font-family: var(--font-mono); font-size: max(0.64rem, 11px); min-width: 3rem; }

.timeline { bottom: calc(var(--controls-height) + var(--safe-bottom) + 0.75rem); left: 50%; max-height: min(66vh, 650px); max-width: calc(100vw - 1.4rem); overflow: hidden; transform: translate(-50%, calc(100% + var(--controls-height) + 2rem)); width: min(740px, calc(100vw - 2rem)); }
.timeline.is-open { transform: translate(-50%, 0); visibility: visible; }
.timeline__header { min-height: auto; padding: 0.9rem 1rem; }
.timeline__header h2 { font-size: 1.35rem; }
.timeline__list { display: grid; gap: 0.55rem; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); max-height: calc(66vh - 90px); overflow: auto; padding: 0.8rem; }
.timeline-page { background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; color: var(--text); cursor: pointer; min-width: 0; padding: 0.75rem; text-align: left; }
.timeline-page:hover { border-color: var(--line-strong); }
.timeline-page.is-current { background: var(--accent-soft); border-color: var(--accent); }
.timeline-page span, .timeline-page strong, .timeline-page small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.timeline-page span { color: var(--accent-strong); font-size: max(0.55rem, 11px); font-weight: 850; letter-spacing: 0.12em; }
.timeline-page strong { font-family: var(--font-display); font-size: 0.9rem; font-weight: 500; margin-top: 0.35rem; }
.timeline-page small { color: var(--text-faint); font-size: max(0.6rem, 11px); margin-top: 0.35rem; }

.scrim { background: rgb(0 0 0 / 58%); inset: 0; position: fixed; z-index: 50; }

.dialog {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: var(--shadow);
  color: var(--text);
  max-height: calc(100dvh - 2rem);
  max-width: calc(100vw - 1rem);
  padding: 0;
  width: min(520px, calc(100vw - 1.5rem));
}
.dialog::backdrop { backdrop-filter: blur(5px); background: rgb(0 0 0 / 66%); }
.dialog form { margin: 0; }
.dialog header { min-height: auto; padding: 1rem; }
.dialog header h2 { font-size: 1.55rem; }
.dialog__body { max-height: calc(100dvh - 220px); overflow: auto; padding: 1rem; }
.dialog__body > p { font-size: 0.86rem; }
.dialog footer { border-top: 1px solid var(--line); display: flex; gap: 0.65rem; justify-content: flex-end; padding: 0.9rem 1rem; }
.dialog--wide { width: min(760px, calc(100vw - 1.5rem)); }
.import-warning { background: color-mix(in srgb, var(--warning) 13%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warning) 50%, var(--line)); border-radius: 6px; color: var(--text); font-size: 0.75rem; line-height: 1.5; margin-top: 0.8rem; overflow-wrap: anywhere; padding: 0.75rem; }
.hook-grid { display: grid; gap: 0.65rem; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 1rem 0; }
.hook-grid article { background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; padding: 0.8rem; }
.hook-grid strong { display: block; font-size: 0.75rem; }
.hook-grid span { color: var(--text-soft); display: block; font-size: 0.7rem; line-height: 1.5; margin-top: 0.35rem; }
.inline-link { display: inline-block; text-decoration: none; }

.toast-stack { bottom: calc(var(--controls-height) + var(--safe-bottom) + 1rem); display: grid; gap: 0.45rem; max-width: min(420px, calc(100vw - 2rem)); pointer-events: none; position: fixed; right: max(1rem, var(--safe-right)); z-index: 200; }
.toast { animation: toast-in 240ms ease both; background: var(--surface); border: 1px solid var(--line-strong); border-left: 3px solid var(--accent-strong); border-radius: 6px; box-shadow: var(--shadow); color: var(--text); font-size: 0.73rem; line-height: 1.45; overflow-wrap: anywhere; padding: 0.72rem 0.85rem; }
.toast[data-tone="error"] { border-left-color: var(--danger); }
.toast[data-tone="good"] { border-left-color: var(--good); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

@media (max-width: 760px) {
  :root { --topbar-height: 58px; --controls-height: 68px; }
  .topbar { grid-template-columns: minmax(0, 1fr) auto; }
  .book-heading { background: rgb(5 6 8 / 78%); border: 1px solid rgb(255 255 255 / 12%); border-radius: 8px; bottom: calc(var(--controls-height) + var(--safe-bottom) + 0.55rem); left: 50%; max-width: 70vw; padding: 0.28rem 0.55rem; pointer-events: none; position: fixed; transform: translateX(-50%); z-index: 20; }
  .book-heading strong { color: #f3f1ec; display: block; font-size: max(0.68rem, 11px); text-shadow: 0 1px 1px #000; }
  .book-heading span { color: #c7c8cc; font-size: max(0.52rem, 10px); margin-top: 0.12rem; text-shadow: 0 1px 1px #000; }
  .topbar__actions { grid-column: 2; }
  #fullscreen-button { display: none; }
  .install-button { font-size: max(0.58rem, 11px); padding: 0.55rem 0.65rem; }
  .reader-stage { --stage-padding: 0.55rem; }
  .reader-controls { gap: 0.28rem; }
  .progress-cluster { margin: 0 0.1rem; min-width: 26vw; }
  .control-divider, #zoom-out, #zoom-in, .zoom-label { display: none; }
  .auto-button { padding-inline: 0.5rem; }
  .drawer { width: min(370px, 94vw); }
  .story-panel--text { font-size: clamp(0.58rem, 3.1vw, 1rem); }
  .timeline { bottom: calc(var(--controls-height) + var(--safe-bottom)); max-height: 72vh; width: 100vw; max-width: 100vw; }
  .timeline__list { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: calc(72vh - 85px); }
}

@media (max-width: 430px) {
  .wordmark { gap: 0.35rem; }
  .wordmark > img { flex-basis: 32px; height: 32px; width: 32px; }
  .wordmark__brand { font-size: 11px; }
  .wordmark__product { font-size: 0.75rem; }
  .topbar { padding-inline: max(0.45rem, var(--safe-left)) max(0.45rem, var(--safe-right)); }
  .topbar__left, .topbar__actions { gap: 0.2rem; }
  .topbar .icon-button { height: 38px; min-width: 38px; padding: 0.5rem; }
  .page-indicator span, .page-indicator strong { font-size: 11px; }
  .progress-cluster { min-width: 24vw; }
  .auto-button span { display: none; }
  .hook-grid { grid-template-columns: 1fr; }
  .dialog footer { flex-wrap: wrap; }
  .dialog footer button { flex: 1 1 120px; }
}

@media (orientation: landscape) and (max-height: 620px) {
  :root { --topbar-height: 52px; --controls-height: 58px; }
  .wordmark__brand { display: none; }
  .wordmark__product { margin-top: 0; }
  .reader-stage { --stage-padding: 0.35rem; }
  .book-heading span { display: none; }
  .control-button { height: 38px; min-width: 38px; }
  .drawer__header { padding-top: calc(0.65rem + var(--safe-top)); }
}

@media (pointer: coarse) {
  .icon-button, .control-button { min-height: 44px; min-width: 44px; }
  .topbar-button, .primary-button, .secondary-button, .text-button { min-height: 44px; }
  .book-row button { min-height: 44px; }
  .book-row .book-delete { min-width: 44px; text-align: center; }
}

html[data-text-scale="largest"] .setting-row { align-items: stretch; flex-direction: column; }
html[data-text-scale="largest"] .setting-row select { max-width: 100%; width: 100%; }

@media (max-width: 430px) {
  .setting-row { align-items: stretch; flex-direction: column; }
  .setting-row select { max-width: 100%; width: 100%; }
}

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

html[data-reduce-motion="true"] *, html[data-reduce-motion="true"] *::before, html[data-reduce-motion="true"] *::after {
  scroll-behavior: auto !important;
  transition-duration: 0.01ms !important;
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
}

@media (forced-colors: active) {
  .page-frame, .story-panel { forced-color-adjust: none; }
  button, select, input { forced-color-adjust: auto; }
}

/* Prose is a sibling reading system, not a comic page stretched around text. */
.comic-experience { display: contents; }

.prose-reader {
  --prose-measure: 68ch;
  --prose-size: 1.25rem;
  --prose-leading: 1.72;
  --prose-spacing: 1.15em;
  --prose-accent: #61d8e6;
  --prose-accent-text: #75e1ec;
  --prose-accent-active: #8eeaf3;
  background: #080a0e;
  display: grid;
  grid-template-columns: minmax(280px, 34.5vw) minmax(0, 1fr);
  inset: 0;
  overflow: hidden;
  position: absolute;
  transition: grid-template-columns 280ms cubic-bezier(.22, 1, .36, 1);
  z-index: 2;
}

html[data-prose-font="sans"] .prose-reader { --prose-font: var(--font-ui); }
html:not([data-prose-font="sans"]) .prose-reader { --prose-font: Georgia, "Times New Roman", serif; }
html[data-prose-size="small"] .prose-reader { --prose-size: 1.08rem; }
html[data-prose-size="large"] .prose-reader { --prose-size: 1.42rem; }
html[data-prose-size="largest"] .prose-reader { --prose-size: 1.62rem; }
html[data-prose-leading="compact"] .prose-reader { --prose-leading: 1.55; }
html[data-prose-leading="airy"] .prose-reader { --prose-leading: 1.9; }
html[data-prose-measure="narrow"] .prose-reader { --prose-measure: 58ch; }
html[data-prose-measure="wide"] .prose-reader { --prose-measure: 78ch; }
html[data-prose-spacing="compact"] .prose-reader { --prose-spacing: 0.78em; }
html[data-prose-spacing="open"] .prose-reader { --prose-spacing: 1.55em; }

.prose-art {
  background: linear-gradient(145deg, #090d14, #020305 70%);
  border-right: 1px solid rgb(255 255 255 / 12%);
  min-width: 0;
  overflow: hidden;
  position: relative;
}

.prose-art > img {
  height: 100%;
  inset: 0;
  object-fit: cover;
  object-position: center;
  position: absolute;
  transition: filter 280ms ease, transform 280ms cubic-bezier(.22, 1, .36, 1);
  width: 100%;
}

.prose-art__shade {
  background: linear-gradient(180deg, rgb(2 4 7 / 12%) 0%, rgb(2 4 7 / 42%) 42%, rgb(2 4 7 / 92%) 100%);
  inset: 0;
  position: absolute;
}

.prose-art__identity {
  bottom: clamp(2rem, 7vh, 4.5rem);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  left: clamp(1.5rem, 4vw, 3.25rem);
  max-width: calc(100% - 3rem);
  position: absolute;
  right: 1.5rem;
  text-shadow: 0 2px 8px #000;
}

.prose-art__identity span {
  color: #61d8e6;
  font-size: max(0.66rem, 11px);
  font-weight: 750;
  letter-spacing: 0.25em;
  text-transform: uppercase;
}

.prose-eyebrow {
  color: var(--prose-accent);
  font-size: max(0.66rem, 11px);
  font-weight: 750;
  letter-spacing: 0.25em;
  text-transform: uppercase;
}

.prose-art__identity strong {
  color: #f2ebdd;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4.6vw, 4.4rem);
  font-weight: 500;
  letter-spacing: -0.045em;
  line-height: 0.98;
  overflow-wrap: anywhere;
}

.prose-art__identity small { color: #d7d3cc; font-size: 0.92rem; line-height: 1.45; }

.prose-workspace {
  background: color-mix(in srgb, var(--bg) 96%, #101826);
  min-width: 0;
  overflow: hidden;
  position: relative;
}

.prose-toolbar {
  align-items: center;
  background: color-mix(in srgb, var(--bg-raised) 94%, transparent);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 0.7rem;
  height: 72px;
  justify-content: flex-end;
  left: 0;
  overflow-x: auto;
  padding: 0.8rem max(1rem, var(--safe-right)) 0.8rem max(1rem, var(--safe-left));
  position: absolute;
  right: 0;
  scrollbar-width: thin;
  top: 0;
  z-index: 4;
}

.prose-toolbar button {
  align-items: center;
  display: inline-flex;
  flex: 0 0 auto;
  gap: 0.5rem;
  min-height: 44px;
  text-transform: none;
}

.prose-toolbar button.is-active,
.prose-toolbar button[aria-pressed="true"] {
  background: color-mix(in srgb, var(--prose-accent) 12%, transparent);
  border-color: var(--prose-accent);
  color: var(--prose-accent-active);
}

.prose-scroll {
  bottom: 4px;
  left: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding-inline: var(--safe-left) var(--safe-right);
  position: absolute;
  right: 0;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
  top: 72px;
}

.prose-opening,
.prose-document {
  color: var(--text);
  margin-inline: auto;
  max-width: calc(var(--prose-measure) + clamp(2.8rem, 12vw, 11rem));
  padding: clamp(3rem, 9vh, 6rem) clamp(1.4rem, 6vw, 5.5rem) 6rem;
  text-shadow: none;
}

.prose-opening h1,
.prose-document__header h1 {
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3.4rem, 7vw, 6.7rem);
  font-weight: 500;
  letter-spacing: -0.055em;
  line-height: 0.96;
  margin: 1.2rem 0 0.75rem;
  overflow-wrap: anywhere;
}

.prose-subtitle { color: var(--text-soft); font-size: clamp(1.08rem, 2vw, 1.5rem); margin-bottom: 0.7rem; }
.prose-byline, .prose-document__header > p:last-child { color: var(--text-faint); font-size: 0.95rem; }

.prose-progress-summary {
  align-items: center;
  display: grid;
  gap: 0.9rem;
  grid-template-columns: minmax(80px, 1fr) auto auto;
  margin: clamp(2rem, 5vh, 3.4rem) 0;
}

.prose-progress-track { background: var(--line); height: 3px; overflow: hidden; }
.prose-progress-track i,
.prose-reading-progress i { background: linear-gradient(90deg, var(--prose-accent), var(--prose-accent) 70%, #d4505d); display: block; height: 100%; transform: scaleX(0.002); transform-origin: left; transition: transform 180ms ease; }
.prose-progress-summary > span { color: var(--text-faint); font-family: var(--font-mono); font-size: max(0.68rem, 11px); }
.prose-progress-summary > span:first-of-type { color: var(--prose-accent); }

.prose-deck {
  color: var(--text);
  font-family: var(--prose-font);
  font-size: clamp(1.65rem, 3vw, 2.45rem);
  line-height: 1.45;
  margin-bottom: clamp(2rem, 5vh, 3.5rem);
}

.prose-continue {
  align-items: center;
  background: transparent;
  border: 1px solid var(--prose-accent);
  border-radius: 6px;
  color: var(--prose-accent-text);
  cursor: pointer;
  display: inline-flex;
  gap: 1rem;
  min-height: 56px;
  padding: 0.8rem 1.5rem;
}
.prose-continue:hover { background: rgb(97 216 230 / 10%); }
.prose-continue > span { color: var(--text); font-size: 2rem; font-weight: 300; }
.prose-continue strong { font-size: 1rem; letter-spacing: 0.03em; }
.prose-local-note { color: var(--text-faint); font-size: 0.8rem; margin-top: 1.5rem; }

.prose-document { padding-top: clamp(2.2rem, 5vh, 3.8rem); }
.prose-document__header { border-bottom: 1px solid var(--line); margin-bottom: clamp(2.5rem, 6vh, 4rem); padding-bottom: 1.7rem; }
.prose-document__header h1 { font-size: clamp(2rem, 4.5vw, 3.8rem); }

.prose-chapter { margin-bottom: clamp(5rem, 12vh, 9rem); scroll-margin-top: 2rem; }
.prose-chapter > h2 {
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.75rem, 4vw, 2.8rem);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.15;
  margin: 0 0 2.4rem;
}
.prose-chapter > h3 {
  color: var(--text);
  font-family: var(--prose-font);
  font-size: calc(var(--prose-size) * 1.12);
  letter-spacing: 0;
  margin: 2.4em 0 0.9em;
  text-transform: none;
}
.prose-chapter > p,
.prose-chapter > blockquote,
.prose-chapter > ul {
  color: var(--text);
  font-family: var(--prose-font);
  font-size: var(--prose-size);
  line-height: var(--prose-leading);
  margin: 0 0 var(--prose-spacing);
  overflow-wrap: anywhere;
  text-wrap: pretty;
}
.prose-chapter > blockquote { border-left: 2px solid var(--prose-accent); color: var(--text-soft); font-style: italic; margin-block: 2em; padding-left: 1.4rem; }
.prose-chapter > ul { padding-left: 1.4em; }
.prose-chapter > ul li + li { margin-top: 0.45em; }
.prose-chapter > hr { border: 0; color: var(--accent-strong); height: 4rem; margin: 2rem 0; position: relative; }
.prose-chapter > hr::after { content: "◆"; font-size: 0.65rem; left: 50%; position: absolute; top: 50%; transform: translate(-50%, -50%); }
.prose-chapter code { font-size: 0.86em; }

.prose-end { align-items: center; border-top: 1px solid var(--line); color: var(--text-faint); display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; padding: 2.5rem 0 4rem; }
.prose-reading-progress { background: var(--line); bottom: 0; height: 4px; left: 0; overflow: hidden; position: absolute; right: 0; z-index: 5; }

.prose-reader.is-reading { grid-template-columns: 56px minmax(0, 1fr); }
.prose-reader.is-reading .prose-art > img { filter: saturate(0.35) brightness(0.45); transform: scale(1.08); }
.prose-reader.is-reading .prose-art__shade { background: rgb(2 4 7 / 68%); }
.prose-reader.is-reading .prose-art__identity { align-items: center; inset: 1rem 0; justify-content: flex-end; max-width: none; }
.prose-reader.is-reading .prose-art__identity strong,
.prose-reader.is-reading .prose-art__identity small { display: none; }
.prose-reader.is-reading .prose-art__identity span { font-size: 10px; letter-spacing: 0.15em; writing-mode: vertical-rl; }

.context-scroll { display: flex; flex-direction: column; gap: 2rem; overflow: auto; padding: 1rem 1rem calc(2rem + var(--safe-bottom)); }
.context-scroll > section + section { border-top: 1px solid var(--line); padding-top: 1.5rem; }
.context-list, .bookmark-list { display: grid; gap: 0.75rem; }
.context-list article { border: 1px solid var(--line); border-radius: 6px; padding: 1rem; }
.context-list article > span { color: var(--prose-accent); font-size: max(0.58rem, 11px); font-weight: 750; letter-spacing: 0.13em; text-transform: uppercase; }
.context-list h4 { font-family: var(--font-display); font-size: 1.1rem; font-weight: 500; margin: 0.55rem 0; }
.context-list p { font-size: 0.84rem; margin: 0; }
.bookmark-row { align-items: stretch; border: 1px solid var(--line); border-radius: 6px; display: grid; grid-template-columns: minmax(0, 1fr) 44px; overflow: hidden; }
.bookmark-row > button { background: transparent; border: 0; color: var(--text); cursor: pointer; min-height: 44px; padding: 0.7rem; text-align: left; }
.bookmark-row > button:hover { background: var(--surface-2); }
.bookmark-row > .book-delete { border-left: 1px solid var(--line); text-align: center; }

@media (max-width: 980px) {
  .prose-reader { grid-template-columns: minmax(230px, 30vw) minmax(0, 1fr); }
  .prose-toolbar { gap: 0.4rem; }
  .prose-toolbar button { padding-inline: 0.7rem; }
}

@media (max-width: 760px) {
  .prose-reader { grid-template-columns: 1fr; grid-template-rows: min(34vh, 280px) minmax(0, 1fr); }
  .prose-art { border-bottom: 1px solid rgb(255 255 255 / 12%); border-right: 0; }
  .prose-art__identity { bottom: 1.25rem; gap: 0.55rem; left: max(1.25rem, var(--safe-left)); }
  .prose-art__identity strong { font-size: clamp(2rem, 11vw, 3.4rem); }
  .prose-art__identity small { font-size: 0.78rem; }
  .prose-workspace { grid-row: 2; }
  .prose-toolbar { height: 58px; justify-content: flex-start; }
  .prose-toolbar button { min-height: 42px; }
  .prose-toolbar button span:not([aria-hidden="true"]) { display: none; }
  .prose-scroll { top: 58px; }
  .prose-opening, .prose-document { padding: 2.5rem max(1.25rem, var(--safe-right)) 5rem max(1.25rem, var(--safe-left)); }
  .prose-opening h1 { font-size: clamp(2.8rem, 15vw, 4.5rem); }
  .prose-deck { font-size: clamp(1.4rem, 7vw, 2rem); }
  .prose-reader.is-reading { grid-template-columns: 1fr; grid-template-rows: 44px minmax(0, 1fr); }
  .prose-reader.is-reading .prose-art { grid-row: 1; }
  .prose-reader.is-reading .prose-art__identity { align-items: flex-start; inset: 0; justify-content: center; left: max(1rem, var(--safe-left)); }
  .prose-reader.is-reading .prose-art__identity span { writing-mode: horizontal-tb; }
  .prose-reader.is-reading .prose-workspace { grid-row: 2; }
  .prose-progress-summary { grid-template-columns: 1fr auto; }
  .prose-progress-summary > span:last-child { grid-column: 1 / -1; }
  .prose-chapter > p, .prose-chapter > blockquote, .prose-chapter > ul { font-size: max(1.18rem, var(--prose-size)); }
  .app-shell[data-content-kind="prose"] .book-heading { display: none; }
  .app-shell[data-content-kind="prose"] .timeline { bottom: var(--safe-bottom); }
}

@media (max-width: 430px) {
  .prose-toolbar button { font-size: 11px; }
  .prose-toolbar button > span[aria-hidden="true"] { display: none; }
  .prose-opening, .prose-document { padding-inline: max(1rem, var(--safe-left)) max(1rem, var(--safe-right)); }
}

html[data-theme="light"] .prose-reader {
  --prose-accent: #006273;
  --prose-accent-text: #005565;
  --prose-accent-active: #004957;
  background: #f1eee8;
}
html[data-theme="light"] .prose-art__identity { text-shadow: 0 2px 8px #000; }
html[data-theme="contrast"] .prose-reader {
  --prose-accent: #fff;
  --prose-accent-text: #fff;
  --prose-accent-active: #fff;
}
html[data-theme="contrast"] .prose-art { border-color: #fff; }
html[data-theme="contrast"] .prose-art__shade { background: rgb(0 0 0 / 72%); }

@media (forced-colors: active) {
  .prose-art { forced-color-adjust: none; }
  .prose-reader :is(button, select) { forced-color-adjust: auto; }
}

@media (prefers-reduced-motion: reduce) {
  .prose-reader,
  .prose-art > img,
  .prose-progress-track i,
  .prose-reading-progress i {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}

html[data-reduce-motion="true"] :is(
  .prose-reader,
  .prose-art > img,
  .prose-progress-track i,
  .prose-reading-progress i
) {
  scroll-behavior: auto !important;
  transition: none !important;
}
