:root {
  --bg: #f6f1e9;
  --surface: #fffdf8;
  --ink: #1f1a14;
  --muted: #6e6457;
  --line: #e4dccf;
  --accent: #c2542d;
  --accent-ink: #fff8f2;
  --highlight: #f7d9b8;
  --highlight-ink: #1f1a14;
  --error: #a3261b;
  --shadow: 0 1px 2px rgb(31 26 20 / 6%), 0 8px 24px rgb(31 26 20 / 8%);
  --serif: 'Iowan Old Style', 'Charter', 'Bitstream Charter', 'Noto Serif', Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --radius: 14px;
  --gutter: 16px;
  --player-h: 244px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #16130f;
    --surface: #211d18;
    --ink: #efe7db;
    --muted: #a69a8a;
    --line: #362f27;
    --accent: #ec7b4f;
    --accent-ink: #1a0f08;
    --highlight: #5a3b22;
    --highlight-ink: #fff3e6;
    --error: #ff8a7a;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 8px 24px rgb(0 0 0 / 35%);
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --bg: #16130f;
  --surface: #211d18;
  --ink: #efe7db;
  --muted: #a69a8a;
  --line: #362f27;
  --accent: #ec7b4f;
  --accent-ink: #1a0f08;
  --highlight: #5a3b22;
  --highlight-ink: #fff3e6;
  --error: #ff8a7a;
  color-scheme: dark;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

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

a { color: inherit; }

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

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Top bar ---------- */

.topbar {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) var(--gutter) 6px;
}

.brand {
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none; font-weight: 650; letter-spacing: -0.01em;
}
.brand svg { width: 28px; height: 28px; }

.view { max-width: 720px; margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- Home ---------- */

.intake { padding: 8px 0 20px; }

.intake h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); font-weight: 600; margin: 0 0 10px;
}

/* ---------- Author store (home) ---------- */

.store { padding: 26px 0 18px; }
.store-head { display: flex; align-items: center; gap: 14px; margin-bottom: 20px; }
.store-avatar { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; flex: none; box-shadow: var(--shadow); }
.store-id { flex: 1; min-width: 0; }
.store-kicker { margin: 0; font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent); font-weight: 600; }
.store-id h1 {
  margin: 2px 0 0; font-family: var(--serif); font-size: clamp(28px, 7vw, 40px); line-height: 1.05;
  letter-spacing: -0.02em; font-weight: 600;
}
.follow { flex: none; }
.follow[aria-pressed='true'] { background: var(--ink); color: var(--bg); box-shadow: none; }

.store-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.store-list li:first-child { grid-column: 1 / -1; }
@media (max-width: 560px) { .store-list { grid-template-columns: 1fr; } }
.store-card {
  display: grid; gap: 10px; width: 100%; padding: 0; border: 0; background: none; color: inherit;
  text-align: left; cursor: pointer; font: inherit;
}
.store-card .card-art { position: relative; }
.store-card .cover { border-radius: 12px; box-shadow: 0 2px 6px rgb(0 0 0 / 10%), 0 12px 32px rgb(0 0 0 / 16%); transition: transform 200ms ease; }
.store-card:hover .cover { transform: translateY(-2px); }
.store-card:active .cover { transform: scale(0.99); }
.card-play {
  position: absolute; right: 12px; bottom: 12px; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow);
}
.store-list li:first-child .card-play { width: 56px; height: 56px; }
.card-play svg { width: 22px; height: 22px; fill: currentColor; margin-left: 2px; }
.store-card.opening .card-play::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  border: 2.5px solid transparent; border-top-color: var(--accent-ink); animation: spin 0.9s linear infinite;
}
.card-new {
  position: absolute; left: 12px; top: 12px; padding: 3px 9px; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
}
.card-meta { font-size: 12px; color: var(--muted); }
.card-title { font-family: var(--serif); font-size: 19px; line-height: 1.25; font-weight: 600; }
.store-list li:first-child .card-title { font-size: clamp(22px, 5vw, 28px); }
.card-subtitle { font-size: 14px; color: var(--muted); line-height: 1.4; }

/* ---------- Author page ---------- */

.author { padding-bottom: 64px; }
.author h1 { font-family: var(--serif); font-size: clamp(28px, 6vw, 38px); margin: 2px 0 6px; letter-spacing: -0.02em; }
.author-who { color: var(--muted); font-size: 14px; margin: 0 0 18px; }
.author-card {
  display: grid; gap: 10px; margin: 16px 0; padding: 18px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.author-card h2 { margin: 0; font-size: 18px; }
.author-card label { font-size: 14px; color: var(--muted); }
.author-card select, .author-card input[type='url'] {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
.author-card .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.author-card form.row input { flex: 1; min-width: 180px; }
.author-articles { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.author-article { display: grid; grid-template-columns: 112px 1fr; gap: 14px; align-items: start; padding-top: 14px; border-top: 1px solid var(--line); }
.author-cover .cover { font-size: 10px; border-radius: 6px; }
.author-info { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; min-width: 0; }
.author-info strong { font-family: var(--serif); font-size: 17px; line-height: 1.3; }
.author-controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.author-controls select { width: auto; flex: 1 1 160px; padding: 7px 10px; font-size: 13px; }
.author-controls .check { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--ink); }
.author-illus { grid-column: 1 / -1; min-width: 0; }
.illus-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.illus-head .check { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--ink); }
.button.small { padding: 5px 12px; font-size: 13px; }
.author-card input[type='text'] {
  width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
.voice-actions { justify-content: flex-start !important; }
.voice-timer { font-variant-numeric: tabular-nums; font-size: 15px; color: var(--ink); }
.voice-timer.enough { color: var(--accent); font-weight: 600; }
.voice-level { width: 120px; height: 10px; }
.voice-upload { font-size: 14px; cursor: pointer; }
.voice-review { display: grid; gap: 10px; }
.voice-review audio, #own-voice-sample { width: 100%; }
.voice-consent { display: flex !important; gap: 10px; align-items: flex-start; color: var(--ink) !important; line-height: 1.4; }
.voice-consent input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.voice-script { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--bg); }
.voice-script summary { cursor: pointer; font-size: 14px; color: var(--muted); }
.voice-script div { max-height: 280px; overflow-y: auto; margin-top: 8px; font-family: var(--serif); font-size: 17px; line-height: 1.6; }
.voice-script p { margin: 0 0 12px; }
.illus-strip {
  list-style: none; margin: 10px 0 4px; padding: 0 0 6px; display: grid; grid-auto-flow: column;
  grid-auto-columns: 168px; gap: 10px; overflow-x: auto; scroll-snap-type: x proximity;
}
.illus-scene { display: grid; gap: 4px; scroll-snap-align: start; font-size: 12px; }
.illus-frame { aspect-ratio: 16 / 9; border-radius: 8px; overflow: hidden; background: #fff; box-shadow: inset 0 0 0 1px var(--line); }
.illus-frame img, .illus-frame video { width: 100%; height: 100%; object-fit: cover; display: block; }
.illus-caption { color: var(--muted); line-height: 1.3; }
.illus-error { color: var(--error); font-size: 11px; line-height: 1.3; }
.illus-scene .link-button { justify-self: start; font-size: 12px; }
.illus-scene .link-button:disabled { color: var(--muted); text-decoration: none; cursor: default; }
@media (max-width: 440px) { .author-article { grid-template-columns: 80px 1fr; } }

.author-link { text-align: center; font-size: 13px; padding: 8px 0 48px; }
.author-link a { color: var(--muted); }

#intake-form {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: var(--shadow);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
#intake-form.dragging {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent), var(--shadow);
}
.drop-hint {
  position: absolute; inset: 0; display: grid; place-items: center;
  border-radius: inherit; background: color-mix(in srgb, var(--surface) 92%, transparent);
  font-weight: 600; color: var(--accent);
  opacity: 0; pointer-events: none; transition: opacity 160ms ease;
}
#intake-form.dragging .drop-hint { opacity: 1; }
#intake-form.busy #intake-input { opacity: 0.6; }

#intake-input {
  display: block; width: 100%;
  border: 0; background: transparent; resize: none;
  padding: 12px 12px 8px;
  font-size: 17px; min-height: 52px;
  outline: none;
}
#intake-input::placeholder { color: var(--muted); }

.intake-actions { display: flex; align-items: center; gap: 8px; padding: 4px; }
.intake-actions .spacer { flex: 1; }
#file-button { display: inline-flex; align-items: center; gap: 6px; padding-inline: 12px 14px; }
#file-button svg { width: 18px; height: 18px; fill: currentColor; }
.formats { margin: 10px 4px 0; font-size: 13px; color: var(--muted); }
.intake-actions .button { white-space: nowrap; }

@media (max-width: 440px) {
  .intake-actions { flex-wrap: wrap; }
  #intake-submit { flex: 1 1 100%; order: 1; padding-block: 12px; }
}

.button {
  border: 0; border-radius: 10px; cursor: pointer;
  padding: 10px 18px; font-weight: 600; font-size: 15px;
  transition: transform 120ms ease, background-color 160ms ease, opacity 160ms;
}
.button:active { transform: scale(0.97); }
.button:disabled { opacity: 0.6; cursor: progress; }
.button.primary { background: var(--accent); color: var(--accent-ink); }
.button.ghost { background: transparent; color: var(--muted); box-shadow: inset 0 0 0 1px var(--line); }
.button.ghost:hover:not(:disabled) { color: var(--ink); box-shadow: inset 0 0 0 1px var(--muted); }

.error { color: var(--error); margin: 6px 12px 10px; font-size: 15px; }

.notice {
  margin-top: 16px; padding: 12px 14px; border-radius: 10px;
  background: var(--highlight); color: var(--highlight-ink); font-size: 15px;
}

.library { padding: 12px 0 64px; }
.library-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.library h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); font-weight: 600; margin: 0;
}
.chips { display: flex; gap: 6px; }
.chip {
  height: 30px; padding: 0 12px; border-radius: 15px; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 13px; font-weight: 600;
}
.chip[aria-pressed='true'] { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.library-list { list-style: none; margin: 0; padding: 0; }
.library-item {
  position: relative; border-top: 1px solid var(--line);
}
.library-item:last-child { border-bottom: 1px solid var(--line); }
.library-link {
  display: grid; grid-template-columns: 128px 1fr; gap: 14px; align-items: center;
  padding: 14px 44px 14px 0; text-decoration: none;
}
.library-cover { width: 128px; }
.library-text { display: grid; gap: 2px; min-width: 0; }
@media (max-width: 440px) {
  .library-link { grid-template-columns: 100px 1fr; gap: 12px; }
  .library-cover { width: 100px; }
  .library-title { font-size: 17px; }
}
.library-site { font-size: 13px; color: var(--muted); }
.library-title {
  font-family: var(--serif); font-size: 19px; line-height: 1.3; font-weight: 600;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.library-status {
  font-size: 13px; color: var(--muted); margin-top: 4px;
  display: flex; align-items: center; gap: 10px;
}
.library-status::after {
  content: ''; flex: 0 0 64px; height: 3px; border-radius: 2px;
  background: linear-gradient(var(--accent), var(--accent)) 0 0 / var(--pct, 0%) 100% no-repeat, var(--line);
}
.library-link:hover .library-title { color: var(--accent); }
.remove {
  position: absolute; right: 0; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); font-size: 22px; cursor: pointer;
}
.remove:hover { background: var(--line); color: var(--ink); }
.empty { color: var(--muted); font-size: 15px; margin: 8px 0; }

/* ---------- Covers ---------- */

/* Article artwork: the page's preview image, or a generated cover with the title. */
.cover {
  position: relative; aspect-ratio: 16 / 9; width: 100%;
  border-radius: 8px; overflow: hidden; background: var(--line);
}
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover.generated {
  display: flex; flex-direction: column; justify-content: flex-end; gap: 4px; padding: 8%;
  background:
    radial-gradient(circle at 85% 15%, hsl(var(--hue) 70% 70% / 0.55), transparent 55%),
    linear-gradient(135deg, hsl(var(--hue) 45% 32%), hsl(calc(var(--hue) + 40) 50% 18%));
  color: #fff8f0;
}
.cover-source {
  font: 600 0.62em/1 var(--sans); letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.8;
}
.cover-title {
  font: 600 1.05em/1.15 var(--serif);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.library-cover .cover { font-size: 12px; border-radius: 6px; }
.library-cover .cover-title { -webkit-line-clamp: 2; }

.artwork { margin: 0 0 22px; }
.artwork .cover {
  border-radius: 14px; font-size: clamp(18px, 5vw, 30px);
  box-shadow: 0 2px 6px rgb(0 0 0 / 12%), 0 18px 48px rgb(0 0 0 / 22%);
}
.artwork .cover-source { font-size: 0.45em; }

/* Story illustrations: pinned at the top while the narration plays. The
   pictures are drawn on white, so the frame stays white in dark mode too. */
.artwork.stage {
  position: sticky; top: 0; z-index: 2;
  margin: 0 calc(-1 * var(--gutter)) 22px; padding: calc(8px + env(safe-area-inset-top)) var(--gutter) 10px;
  background: var(--bg);
}
.stage-frame {
  position: relative; aspect-ratio: 16 / 9; max-height: 38vh; margin: 0 auto;
  border-radius: 14px; overflow: hidden; background: #fff;
  box-shadow: 0 2px 6px rgb(0 0 0 / 10%), 0 14px 36px rgb(0 0 0 / 18%);
}
.stage-layer { position: absolute; inset: 0; opacity: 0; }
.stage-layer.shown { opacity: 1; animation: draw-in 700ms cubic-bezier(0.2, 0.7, 0.2, 1); }
.stage-layer img, .stage-layer video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.stage-layer video { opacity: 0; transition: opacity 250ms ease; }
.stage-layer.moving video { opacity: 1; }
/* While the narration plays, stills drift slowly and their lines "boil" like a hand-drawn cartoon. */
.stage.playing:not(.still) .stage-layer.shown:not(.moving) img {
  animation: boil 0.42s steps(1) infinite, drift 18s ease-in-out infinite alternate;
}
/* After a shot's clip has played, its last frame holds and keeps wobbling. */
.stage.playing:not(.still) .stage-layer.held video { animation: boil 0.42s steps(1) infinite; }
@keyframes draw-in {
  from { clip-path: inset(0 100% 0 0); }
  to { clip-path: inset(0 0 0 0); }
}
@keyframes boil {
  0% { filter: url(#boil-0); }
  33.3% { filter: url(#boil-1); }
  66.6% { filter: url(#boil-2); }
}
@keyframes drift {
  from { transform: scale(1.01) translate(0, 0); }
  to { transform: scale(1.06) translate(-1.2%, -0.8%); }
}

/* ---------- Reader ---------- */

#reader { padding-bottom: calc(var(--player-h) + 40px + env(safe-area-inset-bottom)); }

.article { max-width: 640px; margin: 0 auto; padding-top: 18px; }

.back {
  display: inline-block; text-decoration: none; color: var(--muted);
  font-size: 15px; padding: 6px 0; margin-bottom: 18px;
}
.back:hover { color: var(--ink); }

.article-site {
  margin: 0 0 6px; font-size: 13px; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--accent); font-weight: 600;
}
.article h1 {
  font-family: var(--serif); font-size: clamp(28px, 6vw, 40px); line-height: 1.15;
  letter-spacing: -0.02em; margin: 0 0 12px; text-wrap: balance;
}
.article-meta {
  display: flex; flex-wrap: wrap; gap: 4px 14px;
  color: var(--muted); font-size: 14px; margin: 0 0 28px;
  padding-bottom: 20px; border-bottom: 1px solid var(--line);
}
.article-meta a { color: var(--muted); }

.article-subtitle {
  margin: -4px 0 12px; font-family: var(--serif); font-size: 19px; line-height: 1.45; color: var(--muted);
}

.article-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  margin: -12px 0 26px;
}
.action-button {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 14px 0 11px;
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface); cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--ink);
  transition: border-color 160ms ease, color 160ms ease, transform 120ms ease;
}
.action-button:hover { border-color: var(--muted); }
.action-button:active { transform: scale(0.97); }
.action-button:disabled { opacity: 0.75; cursor: progress; }
.action-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; }
#export-button svg { fill: currentColor; stroke: none; }
#favorite-button[aria-pressed='true'] { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
#favorite-button[aria-pressed='true'] svg { fill: currentColor; }
#export-button { margin-left: auto; }

.rating { display: inline-flex; }
.style-picker { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.style-picker select {
  height: 36px; padding: 0 10px; border-radius: 18px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font-weight: 600; font-size: 14px;
}
.style-picker select:disabled { opacity: 0.5; }
.star {
  width: 30px; height: 36px; border: 0; background: none; cursor: pointer; padding: 0;
  font-size: 22px; line-height: 1; color: var(--line); transition: color 120ms ease, transform 120ms ease;
}
.star.on { color: #e8a33d; }
.star:hover { transform: scale(1.12); }
@media (max-width: 440px) {
  #export-button { margin-left: 0; }
}

.lang-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  margin: -14px 0 24px; padding: 10px 14px; border-radius: 10px;
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
  font-size: 14px; color: var(--ink);
}
.lang-bar.working #lang-bar-text::before {
  content: ''; display: inline-block; width: 12px; height: 12px; margin-right: 8px; vertical-align: -1px;
  border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
.lang-bar.error { background: color-mix(in srgb, var(--error) 12%, var(--surface)); }
.link-button {
  border: 0; background: none; padding: 2px 0; cursor: pointer;
  color: var(--accent); font-weight: 600; font-size: 14px; text-decoration: underline; text-underline-offset: 3px;
}
.article-body.pending { opacity: 0.45; }

/* Ratings and comments under a store article (reviews.js). */
.rating-summary { color: var(--muted); text-decoration: none; font-weight: 600; }
.rating-summary:hover { color: var(--ink); }
.reviews {
  margin: 40px 0 0; padding-top: 24px; border-top: 1px solid var(--line);
  display: grid; gap: 14px; scroll-margin-top: 16px;
}
.reviews h2 { font-family: var(--serif); font-size: 24px; letter-spacing: -0.01em; margin: 0; }
.reviews-summary { margin: -8px 0 0; color: var(--muted); font-size: 15px; font-weight: 600; }
.reviews-you, .reviews-signin {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; font-size: 14px; color: var(--muted);
}
.reviews-you .link-button { margin-left: auto; color: var(--muted); }
.reviews-form { display: grid; gap: 8px; }
.reviews-form textarea {
  width: 100%; box-sizing: border-box; resize: vertical; min-height: 84px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 15px; line-height: 1.45;
}
.reviews-form textarea:focus { border-color: var(--muted); outline: none; }
.reviews-form-row { display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
.reviews-count { color: var(--muted); font-size: 13px; }
.reviews-form .action-button { padding: 0 16px; }
.reviews-form .action-button:disabled { cursor: default; opacity: 0.5; }
.reviews-note { margin: 0; color: var(--error); font-size: 14px; }
.reviews-empty { margin: 0; color: var(--muted); font-size: 15px; }
.reviews-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 18px; }
.reviews-comment { display: grid; gap: 4px; }
.reviews-comment.is-hidden { opacity: 0.6; }
.reviews-comment-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 0; font-size: 14px; }
.reviews-when { color: var(--muted); font-size: 13px; }
.reviews-badge {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 2px 7px; border-radius: 999px; color: var(--accent-ink); background: var(--accent);
}
.reviews-badge.muted { color: var(--muted); background: color-mix(in srgb, var(--muted) 16%, transparent); }
.reviews-comment-text { margin: 0; font-size: 16px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.reviews-comment-actions { display: flex; gap: 14px; }
.reviews-comment-actions .link-button { font-size: 13px; color: var(--muted); }

.article-body {
  font-family: var(--serif); font-size: 19px; line-height: 1.7;
}
.article-body p { margin: 0 0 1.1em; }
.article-body h2 { font-size: 1.2em; line-height: 1.35; margin: 1.6em 0 0.6em; }

.chunk {
  border-radius: 4px; cursor: pointer;
  transition: background-color 200ms ease, color 200ms ease;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.chunk:hover { background: color-mix(in srgb, var(--highlight) 45%, transparent); }
.chunk.active { background: var(--highlight); color: var(--highlight-ink); box-shadow: 0 0 0 2px var(--highlight); }

/* ---------- Player ---------- */

.player {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  padding: 12px var(--gutter) calc(10px + env(safe-area-inset-bottom));
}
.player-inner { max-width: 640px; margin: 0 auto; }

.now-playing { display: flex; align-items: center; gap: 12px; }
.mini-art { width: 64px; flex: none; }
.mini-art .cover { border-radius: 5px; font-size: 6px; }
.mini-art .cover-title { display: none; }
.now-playing-text { min-width: 0; flex: 1; }
.np-title, .np-sub { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.np-title { font-size: 15px; font-weight: 650; }
.np-sub { font-size: 13px; color: var(--muted); }

.progress {
  --fill: 0%;
  display: block; width: 100%; margin: 8px 0 0;
  height: 22px; background: transparent; appearance: none; -webkit-appearance: none; cursor: pointer;
}
/* Favourite voices: one-tap voice + style shortcuts in the player. */
.favourite-voices {
  display: flex; gap: 8px; overflow-x: auto; margin: 10px calc(-1 * var(--gutter)) 0; padding: 0 var(--gutter) 2px;
  scrollbar-width: none;
}
.favourite-voices::-webkit-scrollbar { display: none; }
.fav-chip {
  flex: none; height: 32px; padding: 0 12px; border-radius: 16px; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 600;
}
.fav-chip[aria-pressed='true'] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.favourites-manage { display: grid; gap: 8px; }
.favourite-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.favourite-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 6px 6px 6px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px;
}
.favourite-list button {
  width: 30px; height: 30px; border: 0; border-radius: 50%; background: none; color: var(--muted); cursor: pointer; font-size: 18px;
}
.favourite-list button:hover { background: var(--line); color: var(--ink); }

.times {
  display: flex; justify-content: space-between; margin-top: -2px;
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.progress::-webkit-slider-runnable-track {
  height: 4px; border-radius: 2px;
  background: linear-gradient(var(--accent), var(--accent)) 0 0 / var(--fill) 100% no-repeat, var(--line);
}
.progress::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line); }
.progress::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
.progress::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px;
  border-radius: 50%; background: var(--accent); border: 0;
}
.progress::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 0; }

.player-row {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-top: 2px;
}
.pill-spacer { width: 64px; }
.player-row > :first-child { justify-self: start; }
.player-row > :last-child { justify-self: end; }

.transport { display: flex; align-items: center; gap: 22px; }
.icon-button.skip { width: 48px; height: 48px; }
.icon-button.skip svg { width: 30px; height: 30px; }
.icon-button.skip text { font: 700 7.5px/1 var(--sans); fill: currentColor; }

.icon-button, .play-button {
  display: grid; place-items: center; border: 0; cursor: pointer;
  transition: transform 120ms ease, background-color 160ms ease;
}
.icon-button:active, .play-button:active { transform: scale(0.94); }
.icon-button {
  width: 44px; height: 44px; border-radius: 50%; background: transparent; color: var(--ink);
}
.icon-button:hover { background: var(--line); }
.icon-button svg { width: 22px; height: 22px; fill: currentColor; }

.play-button {
  width: 60px; height: 60px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow);
}
.play-button svg { width: 28px; height: 28px; fill: currentColor; }
.play-button .icon-pause, .play-button.playing .icon-play { display: none; }
.play-button.playing .icon-pause { display: block; }
.play-button:disabled { opacity: 0.4; cursor: not-allowed; }
.play-button { position: relative; }
.play-button.loading::after {
  content: ''; position: absolute; inset: -5px; border-radius: 50%;
  border: 2.5px solid transparent; border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pill {
  min-width: 64px; height: 36px; padding: 0 14px; border-radius: 18px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums;
}
.pill:hover { border-color: var(--muted); }

.player-status {
  margin: 4px 0 0; min-height: 1.2em;
  text-align: center; font-size: 13px; color: var(--muted);
}
.player-status:empty { display: none; }

/* ---------- Update prompt ---------- */

.toast {
  position: fixed; z-index: 30; left: 50%; transform: translateX(-50%);
  top: calc(12px + env(safe-area-inset-top));
  width: min(560px, calc(100vw - 2 * var(--gutter)));
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px;
  padding: 12px 12px 12px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  animation: toast-in 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast p { margin: 0; font-size: 14px; line-height: 1.4; flex: 1 1 220px; }
.toast p span { color: var(--muted); }
.toast-actions { display: flex; gap: 8px; margin-left: auto; }
.toast .button { padding: 8px 14px; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, -8px); } }

.sheet .version { text-align: center; font-size: 12px; }

/* ---------- Voice sheet ---------- */

.sheet {
  border: 0; border-radius: 18px; padding: 0;
  width: min(440px, calc(100vw - 2 * var(--gutter)));
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
.sheet::backdrop { background: rgb(0 0 0 / 40%); }
.sheet form { display: grid; gap: 12px; padding: 22px; }
.sheet h2 { margin: 0; font-size: 20px; }
.sheet label { font-size: 14px; color: var(--muted); }
.sheet select {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg);
}
.hint { margin: 0; font-size: 13px; color: var(--muted); }
.sheet .check {
  display: flex; gap: 10px; align-items: flex-start; cursor: pointer;
  font-size: 14px; color: var(--ink); line-height: 1.4;
}
.sheet .check input { margin-top: 2px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.sheet select + label, .sheet select + .hint, .lang-picker + label { margin-top: 2px; }
.lang-picker { display: grid; gap: 6px; }
.lang-picker input {
  width: 100%; padding: 10px 12px; border-radius: 10px; font: inherit;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
  .stage-layer.shown, .stage.playing .stage-layer.shown:not(.moving) img, .stage-layer.held video { animation: none !important; }
}

/* The story's animated film */
.film-button svg { fill: var(--accent); }
.card-film {
  position: absolute; left: 10px; bottom: 10px; padding: 4px 10px; border-radius: 999px;
  background: rgb(27 25 21 / 82%); color: #fff8f0; font: 600 12px/1.4 var(--sans); letter-spacing: 0.02em;
}
.film-sheet {
  width: min(100vw, 1280px); max-width: 100vw; max-height: 100dvh; padding: 0; border: 0;
  background: #000; border-radius: 14px; overflow: hidden;
}
.film-sheet::backdrop { background: rgb(0 0 0 / 85%); }
.film-sheet video { display: block; width: 100%; max-height: 100dvh; background: #000; }
.film-close {
  position: absolute; top: 10px; right: 10px; width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: rgb(255 255 255 / 85%); color: #1b1915; font-size: 28px; line-height: 1; cursor: pointer;
}
@media (max-width: 640px) { .film-sheet { border-radius: 0; } }

/* Reading from Substack */
.substack-card {
  position: relative; margin: 0 0 14px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow);
}
.substack-row { display: flex; align-items: center; gap: 10px; }
.substack-mark { width: 30px; height: 30px; flex: none; border-radius: 8px; background: #ff6719; display: grid; place-items: center; }
.substack-mark svg { width: 18px; height: 18px; fill: #fff; }
.substack-title { margin: 0; flex: 1; font-weight: 600; }
.substack-open { text-decoration: none; white-space: nowrap; }
.substack-tip { margin: 10px 0 0; color: var(--muted); font-size: 15px; line-height: 1.45; }
.substack-tip b { color: var(--ink); }
.substack-dismiss { margin-top: 6px; font-size: 14px; }
.substack-card.compact { padding: 10px 14px; }
.return-banner {
  position: fixed; left: 50%; top: calc(12px + env(safe-area-inset-top)); transform: translateX(-50%); z-index: 40;
  width: min(560px, calc(100vw - 24px)); padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
}
.return-banner p { margin: 0; flex: 1 1 220px; font-weight: 600; }
