/* ── Theme tokens ───────────────────────────────────────────────────────────
   Default = dark. data-theme="light" overrides below. Custom themes can
   redefine any token via :root[data-theme="<name>"] { ... } — the page
   already inherits everything through these vars, so a new theme is purely
   token-level.
*/
:root,
:root[data-theme="dark"] {
  --bg:      #0d0d0f;
  --surface: #161618;
  --raised:  #1e1e22;
  --border:  #2a2a30;
  --ink:     #f0eadc;
  --muted:   #7a7580;
  --dim:     #3d3a45;
  --accent:  #e8894a;
  --accent2: #c86090;
  --green:   #3db87a;

  /* Semantic tokens for stateful UI — added so light mode can flip safely
     without losing readability. Use these instead of raw hexes. */
  --text:        var(--ink);
  --text-soft:   #d4cfc1;
  --text-mute:   var(--muted);
  --link:        var(--accent);
  --link-hover:  #f3a06a;
  --bg-alt:      var(--surface);
  --bg-hover:    var(--raised);
  --shadow:      rgba(0,0,0,0.4);
  --shadow-soft: rgba(0,0,0,0.18);
  --tint-good:   rgba(61,184,122,0.18);
  --tint-good-edge: rgba(61,184,122,0.4);
  --tint-warn:   rgba(232,137,74,0.16);
  --tint-warn-edge: rgba(232,137,74,0.4);
  --tint-bad:    rgba(232,72,80,0.16);
  --tint-bad-edge: rgba(232,72,80,0.4);
  --overlay:     rgba(0,0,0,0.7);

  --page-w:  min(860px, 94vw);
  --radius:  14px;
  --font-serif: 'Iowan Old Style', 'Palatino Linotype', Georgia, serif;
  --font-mono:  ui-monospace, 'SF Mono', Menlo, monospace;
}

:root[data-theme="light"] {
  --bg:      #faf8f3;
  --surface: #ffffff;
  --raised:  #f5f1e8;
  --border:  #d8d2c4;
  --ink:     #1a1816;
  --muted:   #6b665d;
  --dim:     #b5af9f;
  --accent:  #c46a2d;
  --accent2: #a8447a;
  --green:   #2a8957;

  --text:        var(--ink);
  --text-soft:   #2e2a26;
  --text-mute:   var(--muted);
  --link:        var(--accent);
  --link-hover:  #a8551e;
  --bg-alt:      var(--surface);
  --bg-hover:    var(--raised);
  --shadow:      rgba(60,50,30,0.10);
  --shadow-soft: rgba(60,50,30,0.05);
  --tint-good:   rgba(42,137,87,0.10);
  --tint-good-edge: rgba(42,137,87,0.35);
  --tint-warn:   rgba(196,106,45,0.10);
  --tint-warn-edge: rgba(196,106,45,0.35);
  --tint-bad:    rgba(220,38,38,0.10);
  --tint-bad-edge: rgba(220,38,38,0.35);
  --overlay:     rgba(40,30,20,0.45);
}

/* Honor system preference if user hasn't picked one yet (no data-theme set).
   The toggle script in app.js writes data-theme=dark|light on click, which
   wins via specificity. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) {
    --bg:      #faf8f3;
    --surface: #ffffff;
    --raised:  #f5f1e8;
    --border:  #d8d2c4;
    --ink:     #1a1816;
    --muted:   #6b665d;
    --dim:     #b5af9f;
    --accent:  #c46a2d;
    --accent2: #a8447a;
    --green:   #2a8957;
    --text:        var(--ink);
    --text-soft:   #2e2a26;
    --text-mute:   var(--muted);
    --link:        var(--accent);
    --link-hover:  #a8551e;
    --bg-alt:      var(--surface);
    --bg-hover:    var(--raised);
    --shadow:      rgba(60,50,30,0.10);
    --shadow-soft: rgba(60,50,30,0.05);
    --tint-good:   rgba(42,137,87,0.10);
    --tint-good-edge: rgba(42,137,87,0.35);
    --tint-warn:   rgba(196,106,45,0.10);
    --tint-warn-edge: rgba(196,106,45,0.35);
    --tint-bad:    rgba(220,38,38,0.10);
    --tint-bad-edge: rgba(220,38,38,0.35);
    --overlay:     rgba(40,30,20,0.45);
  }
}

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

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-serif);
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ──────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--dim); border-radius: 3px; }

/* ── Header ─────────────────────────────────── */
.top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.top-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--ink);
}
.top-logo .wordmark { font-size: 20px; font-weight: 700; letter-spacing: 0.5px; }
.top-logo .spark {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.top .spacer { flex: 1; }
.top .storage-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--muted);
  padding: 3px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.back-link {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  font-family: var(--font-mono);
}
.back-link:hover { color: var(--ink); }

/* ── Hero / Create ───────────────────────────── */
.hero {
  max-width: var(--page-w);
  margin: 56px auto 40px;
  padding: 0 16px;
}
.hero-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 20px;
}
.create-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.create-card textarea {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 16px;
  font-family: var(--font-serif);
  resize: vertical;
  min-height: 90px;
  outline: none;
  transition: border-color 0.15s;
}
.create-card textarea:focus { border-color: var(--accent); }
.create-card textarea::placeholder { color: var(--dim); }

.create-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.create-hint { color: var(--muted); font-size: 12px; font-family: var(--font-mono); }
.btn-primary {
  padding: 10px 22px;
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-serif);
  background: var(--accent);
  color: #0d0d0f;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.88; }
.btn-primary:disabled { opacity: 0.4; cursor: progress; }

/* ── Library ─────────────────────────────────── */
.library {
  max-width: var(--page-w);
  margin: 0 auto 100px;
  padding: 0 16px;
}
.section-head {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 16px;
}
.grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
}

/* Netflix-style horizontal scroll row. Used by every homepage section so
   the page reads as rows of covers like a streaming UI. Each `.row-scroller`
   is a horizontal flexbox that overflows-scrolls; cards inside are fixed-
   width so the visual rhythm stays consistent. Mobile keeps the scroll
   gesture; desktop gets snap-points + edge-fade for a finished feel. */
.row-section { margin-bottom: 36px; }
.row-scroller {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-padding: 4px;
  padding: 4px 4px 16px 4px;
  margin: -4px -4px 0 -4px; /* let card hover lift not clip */
  scrollbar-width: thin;
}
.row-scroller::-webkit-scrollbar { height: 8px; }
.row-scroller::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.row-scroller > .card,
.row-scroller > .share-card {
  flex: 0 0 auto;
  width: 220px;
  scroll-snap-align: start;
}
.row-scroller > .card.list-card { width: 240px; }
.row-scroller .empty {
  color: var(--text-mute);
  font-size: 13px;
  padding: 12px 4px;
}
@media (max-width: 720px) {
  .row-scroller > .card,
  .row-scroller > .share-card,
  .row-scroller > .card.list-card { width: 180px; }
}

/* List cards (Netflix row of mood-boards). The big glyph stack stands in
   for a cover so the row reads as "lists" not "covers". */
.list-card { background: var(--surface); }
.list-card .list-card-stack {
  aspect-ratio: 4/3;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 56px;
  background-color: var(--raised);
  color: var(--accent);
}
.list-card-favorites .list-card-stack { color: #d6336c; background-color: var(--tint-bad); }
.list-card-new .list-card-stack { color: var(--muted); background-color: var(--raised); font-size: 40px; font-weight: 200; }

/* Follow button — used on creator profile + feed cards. */
.follow-btn {
  background: var(--accent);
  color: var(--accent-on);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.follow-btn:hover { filter: brightness(1.05); }
.follow-btn.following {
  background: transparent;
  color: var(--accent);
}
.follow-btn.following::before { content: '✓ '; }
.follow-btn.following:hover::before { content: '✕ '; }
.follow-btn.following:hover { color: #d63838; border-color: #d63838; }

/* Creator chip — small "by @sloth-dad" link on cards / feed rows */
.creator-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  color: var(--text-mute);
  text-decoration: none;
  font-family: var(--font-mono);
}
.creator-chip:hover { color: var(--accent); text-decoration: underline; }

/* Feed page */
.feed-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 16px 0 24px;
}
.feed-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.feed-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  overflow: hidden;
  transition: border-color 0.15s, transform 0.15s;
  position: relative;
}
.feed-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.feed-card .cover { aspect-ratio: 4/3; background: var(--raised); overflow: hidden; }
.feed-card .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.feed-card .feed-body { padding: 12px 14px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.feed-card .feed-meta-line { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-mute); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; }
.feed-card .feed-title { font-weight: 700; font-size: 15px; line-height: 1.3; color: var(--text); }
.feed-card .feed-syn { font-size: 12.5px; color: var(--muted); line-height: 1.4; }
.feed-card .feed-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; padding-top: 10px; }
.feed-card .heart-count { font-size: 12px; color: var(--text-mute); font-family: var(--font-mono); }
.feed-card .heart-count.filled { color: #d6336c; }

/* Profile page */
.creator-hero {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  padding: 28px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 28px;
}
.creator-avatar {
  width: 96px; height: 96px; border-radius: 50%;
  background: var(--raised);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono);
  font-size: 32px;
  color: var(--accent);
  border: 1px solid var(--border);
  flex: 0 0 96px;
  background-size: cover;
  background-position: center;
}
.creator-info { flex: 1; min-width: 0; }
.creator-info h1 { margin: 0 0 4px 0; font-size: 28px; }
.creator-info .creator-handle { color: var(--text-mute); font-family: var(--font-mono); font-size: 13px; }
.creator-info .creator-bio { margin-top: 12px; line-height: 1.55; color: var(--text-soft); font-size: 14px; max-width: 60ch; }
.creator-counts { display: flex; gap: 18px; margin: 12px 0; font-size: 13px; color: var(--text-mute); font-family: var(--font-mono); }
.creator-counts strong { color: var(--text); font-size: 16px; display: block; }
.creator-actions { display: flex; gap: 8px; margin-top: 14px; }

/* Save-to-list modal (popover from heart on book cards) */
.list-picker {
  position: absolute;
  z-index: 100;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 12px 40px rgba(0,0,0,0.18);
  padding: 8px 0;
  min-width: 240px;
  max-height: 360px;
  overflow-y: auto;
}
.list-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  user-select: none;
  font-size: 13.5px;
}
.list-picker-row:hover { background: var(--raised); }
.list-picker-row .lp-check { width: 16px; text-align: center; color: var(--accent); }
.list-picker-row .lp-name { flex: 1; }
.list-picker-row .lp-vis { font-size: 11px; color: var(--text-mute); font-family: var(--font-mono); }
.list-picker-divider { border-top: 1px solid var(--border); margin: 6px 0; }
.list-picker-row.create { color: var(--accent); }

/* Lists index page */
.lists-toolbar { display: flex; align-items: center; gap: 10px; margin: 12px 0 24px; }
.list-detail-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 24px 0;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.list-detail-head h1 { margin: 0; font-size: 26px; }
.list-detail-head .meta-row { color: var(--text-mute); font-size: 13px; margin-top: 4px; }

/* Resume banner — shown on book.html / podcast.html when sf_progress has a
   prior session to pick back up. Sticks to the bottom-center so it doesn't
   block the cover; tap Resume / Start over / × to dismiss.

   Mobile sticks to the bottom edge; desktop floats above the nav-bar. */
.resume-banner {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 999px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
  font-size: 13px;
  max-width: calc(100vw - 32px);
}
.resume-banner .resume-msg {
  color: var(--text);
  white-space: normal;
  line-height: 1.35;
}
.resume-banner button[data-action="dismiss"] {
  background: transparent;
  border: none;
  color: var(--text-mute);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.resume-banner button[data-action="dismiss"]:hover { color: var(--text); }
@media (max-width: 600px) {
  .resume-banner {
    bottom: 80px;
    border-radius: 14px;
    flex-wrap: wrap;
    justify-content: center;
    text-align: center;
    padding: 12px 14px;
  }
  .resume-banner .resume-msg { flex: 1 1 100%; }
}

/* Card progress chip — shown on book/podcast cards with sf_progress data.
   Sits in the bottom-left corner of the cover; ✓ Read for completed,
   N% for in-progress, hidden for never-opened. */
.progress-chip {
  position: absolute;
  left: 8px;
  bottom: 8px;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  z-index: 1;
}
.progress-chip.completed { background: rgba(34, 139, 34, 0.78); }

/* Continue-row tweak: the cover gets a small gradient overlay so the chip
   stays legible on a light cover. */
.row-scroller .card .cover { position: relative; }

/* Profile editor inline */
.profile-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  max-width: 560px;
}
.profile-card label { display: block; font-size: 12px; color: var(--text-mute); margin: 12px 0 4px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em; }
.profile-card input, .profile-card textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}
.profile-card textarea { resize: vertical; min-height: 80px; }
.profile-card .profile-actions { margin-top: 18px; display: flex; gap: 10px; align-items: center; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card .cover {
  aspect-ratio: 4/3;
  background: var(--raised);
  overflow: hidden;
  position: relative;
}
.card .cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  background: var(--raised);
}
.card .cover.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  text-transform: uppercase;
}
.card .meta { padding: 12px 14px; flex: 1; }
.card .meta .t { font-weight: 700; font-size: 14px; margin-bottom: 4px; line-height: 1.3; }
.card .meta .s { color: var(--muted); font-size: 12px; line-height: 1.35; margin-bottom: 8px; }
.status-pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--raised);
  color: var(--muted);
}
.status-pill.ready { background: var(--tint-good); color: var(--green); border: 1px solid var(--tint-good-edge); }
.status-pill.generating, .status-pill.illustrating { background: var(--tint-warn); color: var(--accent); border: 1px solid var(--tint-warn-edge); }
.status-pill.failed { background: var(--tint-bad); color: #d63838; border: 1px solid var(--tint-bad-edge); }

/* ── Toast ───────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--raised);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 20px;
  font-family: var(--font-mono);
  font-size: 13px;
  transition: transform 0.25s;
  z-index: 100;
  white-space: nowrap;
}
#toast.show { transform: translateX(-50%) translateY(0); }

/* ── Book Reader ─────────────────────────────── */
.reader-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}
.reader-header .book-title {
  font-size: 16px;
  font-weight: 700;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.page-counter {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

/* Reader frame — narrow mode (default, stacked) */
.reader-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: calc(100vh - 57px);
  background: var(--bg);
  padding-bottom: 100px;
}

.book-stage {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
}

.spread {
  display: none;
  flex-direction: column;
  width: 100%;
}
.spread.active { display: flex; }

/* Cover spread (narrow) */
.spread.cover-spread .cover-img {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--raised);
  display: block;
  overflow: hidden;
}
.spread.cover-spread .cover-img img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.spread.cover-spread .cover-img.empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--dim); font-family: var(--font-mono); font-size: 12px; letter-spacing: 2px;
}
.spread.cover-spread .cover-text { padding: 36px 40px 28px; }
.spread.cover-spread .cover-text h1 { margin: 0 0 10px; font-size: 36px; line-height: 1.15; }
.spread.cover-spread .cover-text .synopsis { color: var(--muted); font-size: 16px; line-height: 1.5; font-style: italic; }
.spread.cover-spread .cover-text .prompt-tag { margin-top: 14px; font-family: var(--font-mono); font-size: 11px; color: var(--dim); }
.spread.cover-spread .cover-text .cover-date { margin-top: 8px; font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--dim); opacity: 0.75; cursor: help; }

/* Story page spread (narrow) — image on top, text below, one spread per page */
.spread.page-spread {
  min-height: calc(100vh - 57px);
}
.spread.page-spread .page-img {
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--raised);
  display: block;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.spread.page-spread .page-img img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.spread.page-spread .page-img.page-img-exercise img { object-fit: contain; }
.spread.page-spread .page-img.empty {
  display: flex; align-items: center; justify-content: center;
  color: var(--dim); font-family: var(--font-mono); font-size: 12px; letter-spacing: 2px;
}
.spread.page-spread .page-img.loading { position: relative; overflow: hidden; }
.spread.page-spread .page-img.loading::after {
  content: ''; position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0, rgba(255,255,255,0.04) 50%, transparent 100%);
  animation: shimmer 1.4s infinite; background-size: 200% 100%;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.spread.page-spread .page-text { padding: 32px 40px; }
.spread.page-spread .page-num {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 3px; text-transform: uppercase;
  color: var(--muted); margin-bottom: 14px; display: block;
}
.spread.page-spread .page-body { font-size: 19px; line-height: 1.65; }

/* ── Wide-screen layout (≥1100px): image left 2/3, text right 1/3, no scroll ──
   The active spread owns the full viewport height so the text column can
   overflow internally — no page scroll needed. Image is 'contain' so the
   full illustration is visible without cropping. */
@media (min-width: 1100px) {
  .book-stage {
    max-width: none;
    padding: 0 24px;
  }
  .spread.active {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(360px, 1fr);
    gap: 28px;
    height: calc(100vh - 57px - 80px); /* header + nav bar */
    padding: 16px 0 0;
  }
  .spread.cover-spread .cover-img,
  .spread.page-spread .page-img {
    width: 100%;
    height: 100%;
    aspect-ratio: auto;
    border-bottom: none;
    border-radius: 8px;
    background-size: contain;  /* feature the image whole */
    background-color: var(--bg);
  }
  .spread.cover-spread .cover-text,
  .spread.page-spread .page-text {
    overflow-y: auto;
    padding: 8px 24px 24px 0;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .spread.cover-spread .cover-text h1 { font-size: 42px; }
  .spread.page-spread .page-body { font-size: 20px; }
  /* Subtle scrollbar so the text column feels intentional, not broken */
  .spread .page-text::-webkit-scrollbar,
  .spread .cover-text::-webkit-scrollbar { width: 6px; }
  .spread .page-text::-webkit-scrollbar-thumb,
  .spread .cover-text::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.1); border-radius: 3px;
  }
}

/* ── Navigation ──────────────────────────────── */
.nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 14px 20px;
  z-index: 20;
}
.nav-btn {
  background: var(--raised);
  border: 1px solid var(--border);
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 20px;
  font-size: 20px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1;
}
.nav-btn:hover:not(:disabled) { background: var(--dim); border-color: var(--muted); }
.nav-btn:disabled { opacity: 0.3; cursor: default; }
.nav-dots {
  display: flex;
  gap: 6px;
  align-items: center;
}
.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dim);
  transition: background 0.15s, width 0.15s;
  cursor: pointer;
}
.nav-dot.active { background: var(--accent); width: 18px; border-radius: 3px; }

/* ── Generating status ───────────────────────── */
.status-bar {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.status-bar .pulse { color: var(--accent); }

/* ── Footer / ODC badge ──────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 24px 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
}
.odc-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.5px;
  text-decoration: none;
  transition: border-color 0.15s, color 0.15s;
}
.odc-badge:hover { border-color: var(--green); color: var(--green); }
.odc-badge .check {
  width: 12px;
  height: 12px;
  background: var(--green);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0d0d0f;
  font-size: 8px;
  font-weight: 900;
  flex-shrink: 0;
}

/* ── Empty state ──────────────────────────────── */
.empty {
  text-align: center;
  padding: 48px 0;
  color: var(--muted);
  font-size: 14px;
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 600px) {
  .top { padding: 14px 18px; }
  .hero, .library { padding: 0 12px; }
  .create-card { padding: 20px; }
  .spread.page-spread .page-text { padding: 22px 22px; }
  .spread.page-spread .page-body { font-size: 17px; }
  .spread.cover-spread .cover-text { padding: 24px 22px 20px; }
  .spread.cover-spread .cover-text h1 { font-size: 26px; }
  .create-footer { flex-direction: column; align-items: flex-end; }
}

/* ── Auth ──────────────────────────────── */
.auth-slot { display: flex; align-items: center; gap: 10px; }
.auth-email {
  font-size: 12px; color: var(--muted); font-family: 'Iowan Old Style', 'Palatino', Georgia, serif;
}
.auth-initials {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 999px;
  background: var(--accent); color: #0d0d0f;
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
  cursor: default; user-select: none;
}
.btn-compact {
  padding: 6px 12px; font-size: 12px; border-radius: 6px;
}
.btn-ghost {
  background: transparent; color: var(--fg);
  border: 1px solid rgba(255,255,255,0.15); cursor: pointer;
  font-family: inherit;
}
.btn-ghost:hover { border-color: rgba(255,255,255,0.35); background: rgba(255,255,255,0.04); }
.btn-danger { color: #d63838; border-color: var(--tint-bad-edge); }
:root[data-theme="dark"] .btn-danger { color: #f87171; }
.btn-danger:hover { background: rgba(248,113,113,0.08); border-color: rgba(248,113,113,0.5); }

.auth-card input[type="email"], .auth-card input[type="password"] {
  width: 100%;
  background: rgba(255,255,255,0.04); color: var(--fg);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px; padding: 12px 14px; font-size: 14px;
  font-family: inherit; margin-bottom: 10px;
}
.auth-card input:focus { outline: none; border-color: var(--accent); }
.auth-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.auth-tab {
  flex: 0 0 auto; padding: 6px 14px; font-size: 12px; font-family: inherit;
  background: transparent; color: var(--muted);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 999px;
  cursor: pointer;
}
.auth-tab.active { color: #0d0d0f; background: var(--accent); border-color: var(--accent); font-weight: 700; }

/* ── Visibility toggle on create form ──── */
.visibility-toggle {
  display: inline-flex; align-items: center; gap: 6px; margin-right: 14px;
  font-size: 12px; color: var(--muted); cursor: pointer;
}
.visibility-toggle input { margin: 0; }

/* ── Book card pills ──────────────────────────────── */
.card .pills { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.vis-pill {
  font-size: 10px; padding: 2px 8px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 700;
  font-family: 'Geist Mono', 'JetBrains Mono', monospace;
}
.vis-pill.private { background: var(--tint-bad); color: #d63838; }
.vis-pill.yours   { background: var(--tint-warn); color: var(--accent); }
:root[data-theme="dark"] .vis-pill.private { color: #fca5a5; }
:root[data-theme="dark"] .vis-pill.yours   { color: #fbbf24; }

/* ── Reader owner controls ──────────── */
.owner-controls { display: flex; gap: 6px; align-items: center; }
.owner-controls button { font-family: inherit; }

/* ── Listen button ──────────────────────────────── */
.listen-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; font-size: 13px; font-family: inherit; font-weight: 600;
  background: rgba(255,255,255,0.04); color: var(--fg);
  border: 1px solid rgba(255,255,255,0.12); border-radius: 999px;
  cursor: pointer; transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.listen-btn:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.25); }
.listen-btn:active { transform: scale(0.97); }
.listen-btn.active {
  background: var(--accent); color: #0d0d0f; border-color: var(--accent);
}
.listen-btn.active .listen-icon { animation: listen-pulse 1.2s ease-in-out infinite; }
@keyframes listen-pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}
.listen-icon { font-size: 15px; line-height: 1; }
@media (max-width: 600px) {
  .listen-btn .listen-label { display: none; }
  .listen-btn { padding: 6px 10px; }
}

/* Failure-state block on cover */
.fail-box {
  margin-top: 18px; padding: 14px 16px;
  border: 1px solid rgba(248,113,113,0.3); border-radius: 10px;
  background: rgba(248,113,113,0.06);
}
.fail-row { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; }
.fail-pill {
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 4px; letter-spacing: 0.06em;
  text-transform: uppercase;
  background: var(--tint-bad); color: #d63838; flex-shrink: 0; margin-top: 1px;
}
:root[data-theme="dark"] .fail-icon { color: #fca5a5; }
.fail-msg { font-family: var(--font-mono); font-size: 11.5px; color: #d63838; line-height: 1.45; word-break: break-word; }
:root[data-theme="dark"] .fail-msg { color: #fca5a5; }
.fail-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.fail-actions .btn-primary { padding: 8px 16px; font-size: 13px; }

/* ── Live-progress tile ─────────────── */
.card.card-inflight {
  border-color: rgba(232,137,74,0.45);
  box-shadow: 0 0 0 1px rgba(232,137,74,0.15), 0 0 24px rgba(232,137,74,0.08);
  animation: card-breathe 2.2s ease-in-out infinite;
}
@keyframes card-breathe {
  0%, 100% { box-shadow: 0 0 0 1px rgba(232,137,74,0.15), 0 0 24px rgba(232,137,74,0.06); }
  50%      { box-shadow: 0 0 0 1px rgba(232,137,74,0.4), 0 0 28px rgba(232,137,74,0.16); }
}
.progress-line {
  margin: 6px 0 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent);
  letter-spacing: 0.02em;
}
.card-spinner {
  display: inline-block;
  width: 28px; height: 28px;
  border: 3px solid rgba(232,137,74,0.15);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Clickable toast variants ─────────────── */
#toast.clickable { cursor: pointer; transition: transform 0.25s, background-color 0.15s; }
#toast.clickable:hover { background: var(--accent); color: #0d0d0f; border-color: var(--accent); }
#toast.toast-ready { border-color: var(--green); background: var(--tint-good); }
#toast.toast-ready:hover { background: var(--green); color: #0d0d0f; border-color: var(--green); }
#toast.toast-failed { border-color: var(--tint-bad-edge); background: var(--tint-bad); color: #d63838; }
:root[data-theme="dark"] #toast.toast-failed { color: #fca5a5; background: #2a1515; }

/* ── Header overflow menu (Exercise mode toggle) ── */
.menu-wrap { position: relative; display: flex; align-items: center; }
.menu-trigger {
  background: transparent; color: var(--muted);
  border: 1px solid var(--border); border-radius: 8px;
  width: 30px; height: 30px; padding: 0;
  font-size: 18px; line-height: 1; cursor: pointer;
  font-family: var(--font-mono);
}
.menu-trigger:hover { color: var(--ink); border-color: var(--accent); }
.menu-panel {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px;
  min-width: 240px; z-index: 20;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}
.menu-panel[hidden] { display: none; }
.menu-item {
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; cursor: pointer; color: var(--ink);
}
.menu-item input[type="checkbox"] { accent-color: var(--accent); width: 14px; height: 14px; }
.menu-hint {
  margin: 8px 0 0; padding-top: 8px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--muted); font-family: var(--font-mono); line-height: 1.4;
}

.menu-link {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0; font-size: 13px; color: var(--ink);
  text-decoration: none;
}
.menu-link:hover { color: var(--accent); }
.menu-link .heart-icon { color: var(--accent); font-size: 14px; }
.menu-divider {
  height: 1px; background: var(--border); margin: 8px -4px;
}

/* Exercise-mode UI is hidden by default; revealed when the body opts in. */
.exercise-ui { display: none !important; }
body.exercise-on .mode-tabs.exercise-ui { display: flex !important; }
body.exercise-on .chip.exercise-ui { display: inline-block !important; }

/* ── Favorite heart on cards + reader ─────── */
.fav-btn {
  position: absolute; top: 10px; right: 10px;
  background: rgba(13,13,15,0.78); color: var(--ink);
  border: 1px solid var(--border); border-radius: 999px;
  width: 32px; height: 32px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1; cursor: pointer; z-index: 2;
  backdrop-filter: blur(6px);
  transition: transform 100ms ease, color 150ms ease, border-color 150ms ease;
}
.fav-btn:hover { color: var(--accent); border-color: var(--accent); }
.fav-btn.faved { color: var(--accent); border-color: var(--accent); }
.fav-btn:active { transform: scale(0.92); }
.card { position: relative; }

.see-all-link {
  font-family: var(--font-mono); font-size: 11px;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); text-decoration: none;
  background: transparent; border: 0; cursor: pointer; padding: 0;
}
.see-all-link:hover { color: var(--accent); }

.section-sub {
  margin: -10px 0 16px; color: var(--muted); font-size: 13px;
  font-style: italic;
}
.template-picker {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; margin-top: 16px;
}
.template-head {
  margin: 0 0 12px; font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted);
}
.template-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px; margin-bottom: 16px;
}
.template-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; cursor: pointer;
  text-align: left; font-family: var(--font-serif); color: var(--ink);
  font-size: 13px; line-height: 1.4;
  transition: border-color 0.12s, transform 0.12s;
}
.template-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.template-card .t { font-weight: 700; display: block; margin-bottom: 3px; }
.template-card .d { color: var(--muted); font-size: 12px; }
.template-card.active { border-color: var(--accent); background: rgba(232,137,74,0.06); }
.template-custom textarea {
  width: 100%; background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; font-size: 14px; font-family: var(--font-serif);
  resize: vertical; min-height: 70px; outline: none; margin-bottom: 12px;
}
.template-custom textarea:focus { border-color: var(--accent); }

/* ── Character canon page ─────────────── */
.character-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 18px;
}
.character-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color 0.15s, transform 0.15s;
}
.character-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.character-portrait {
  aspect-ratio: 1/1; background: var(--raised); position: relative;
  display: flex; align-items: center; justify-content: center;
}
.character-portrait img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.character-portrait .portrait-fallback {
  display: none; font-family: var(--font-mono); font-size: 36px;
  color: var(--accent); letter-spacing: 2px;
}
.character-portrait.portrait-pending .portrait-fallback { display: block; }
.character-meta { padding: 18px 20px 22px; flex: 1; display: flex; flex-direction: column; }
.character-meta h2 { margin: 0 0 4px; font-size: 22px; }
.character-meta .char-role {
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 1px;
  text-transform: uppercase; color: var(--muted); margin: 0 0 12px;
}
.character-meta .char-tagline {
  font-style: italic; color: var(--ink); margin: 0 0 10px; font-size: 14px;
}
.character-meta .char-backstory {
  color: var(--muted); font-size: 13px; line-height: 1.5; margin: 0 0 12px;
}
.character-meta .char-quirks {
  margin: 0 0 12px; padding-left: 18px; color: var(--ink); font-size: 13px;
  line-height: 1.5;
}
.character-meta .char-quirks li { margin-bottom: 2px; }
.character-meta .char-tags {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px;
}
.char-tag {
  background: var(--bg); color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 3px 10px; font-size: 10px; letter-spacing: 1px; text-transform: uppercase;
  font-family: var(--font-mono);
}
.character-meta .char-cta { margin-top: auto; }

.reader-fav-btn {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 12px; font-size: 14px; cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  font-family: var(--font-serif);
}
.reader-fav-btn:hover { color: var(--accent); border-color: var(--accent); }
.reader-fav-btn.faved { color: var(--accent); border-color: var(--accent); background: rgba(232,137,74,0.08); }

/* ── View / Edit mode toggle (reader) ─────────────────────────────────────
   Default state is VIEW: owner controls, revise bar, and per-page edit
   actions are hidden so the reader is clean and immersive. Owners flip the
   "✎ Edit" button to reveal the editing surface; clicking again ("✓ Done")
   returns to view mode. */
.edit-mode-btn {
  background: var(--surface); color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 12px; font-size: 12px; cursor: pointer;
  font-family: var(--font-mono); letter-spacing: 0.5px;
}
.edit-mode-btn:hover { color: var(--ink); border-color: var(--accent); }
.edit-mode-btn.active { color: var(--accent); border-color: var(--accent); background: rgba(232,137,74,0.08); }

/* In view mode: hide owner controls, revise bar, and per-page edit actions. */
body:not(.edit-mode) .owner-controls { display: none !important; }
body:not(.edit-mode) .revise-bar { display: none !important; }
body:not(.edit-mode) .page-actions { display: none !important; }

/* ── Mode tabs (story / exercise) ─────────── */
.mode-tabs {
  display: flex; gap: 4px; margin-bottom: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px; width: fit-content;
}
.mode-tab {
  background: transparent; color: var(--muted);
  border: none; border-radius: 999px;
  padding: 8px 18px; font-size: 13px; letter-spacing: 0.5px;
  cursor: pointer; font-family: var(--font-serif); font-weight: 700;
}
.mode-tab:hover { color: var(--ink); }
.mode-tab.active { background: var(--accent); color: #0d0d0f; }

/* ── Library header + filter chips ─────────── */
.library-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.library-head .section-head { margin-bottom: 0; }
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--surface); color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 5px 12px; font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
  cursor: pointer; font-family: var(--font-mono);
}
.chip:hover { color: var(--ink); border-color: var(--accent); }
.chip.active { background: var(--accent); color: #0d0d0f; border-color: var(--accent); }

/* ── Card classification badges ─────────── */
.badges { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0 4px; }
.badge {
  display: inline-block; padding: 2px 7px; border-radius: 4px;
  font-size: 9.5px; letter-spacing: 1px; text-transform: uppercase; font-weight: 700;
  border: 1px solid var(--border); background: var(--raised); color: var(--ink);
  font-family: var(--font-mono);
}
/* Rating badges: theme-adaptive tints. Same hue family per category, but
   readable in both dark and light. */
.badge-kids              { background: rgba(72,176,120,0.18); color: var(--green); border-color: rgba(72,176,120,0.35); }
.badge-children          { background: rgba(74,128,200,0.18); color: #4a80c8; border-color: rgba(74,128,200,0.35); }
.badge-teen              { background: rgba(214,140,68,0.18); color: var(--accent); border-color: rgba(214,140,68,0.35); }
.badge-adult_educational { background: rgba(160,120,200,0.18); color: #8a5fb8; border-color: rgba(160,120,200,0.35); }
.badge-adult             { background: rgba(208,72,72,0.18); color: #c84040; border-color: rgba(208,72,72,0.35); }
.badge-review        { background: var(--tint-warn); color: var(--accent); border-color: var(--tint-warn-edge); }
.badge-unpub         { background: var(--raised); color: var(--text-mute); border-color: var(--border); }
.badge-edu           { background: rgba(80,160,160,0.16); color: #2d8484; border-color: rgba(80,160,160,0.35); }
.badge-mode-exercise { background: rgba(74,128,200,0.16); color: #4a80c8; border-color: rgba(74,128,200,0.35); }
.themes { color: var(--muted); font-size: 11px; margin: 4px 0; letter-spacing: 0.3px; font-family: var(--font-mono); }

/* ── Exercise page rendering ─────────── */
.spread.page-spread .page-img.page-img-exercise { background-color: #f3ecda; }
.ex-name { font-size: 22px; margin: 4px 0 14px; line-height: 1.2; font-weight: 700; }
.ex-steps { padding-left: 20px; margin: 0 0 14px; line-height: 1.5; font-size: 16px; }
.ex-steps li { margin-bottom: 6px; }
.ex-row { margin: 8px 0; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 14px; }
.ex-label {
  color: var(--muted); font-size: 11px; letter-spacing: 1.5px;
  text-transform: uppercase; margin-right: 4px; font-family: var(--font-mono);
}
.ex-tag {
  background: var(--raised); border: 1px solid var(--border); border-radius: 999px;
  padding: 2px 10px; font-size: 12px;
}
.ex-callout {
  background: var(--raised); border-left: 3px solid var(--accent);
  padding: 10px 14px; margin-top: 10px; font-size: 14px; line-height: 1.5;
  border-radius: 4px;
}
.ex-callout.safety { border-left-color: #d97a7a; }
.ex-callout strong { color: var(--accent); margin-right: 4px; }
.ex-callout.safety strong { color: #d97a7a; }

/* ── Page-level edit UI ─────────── */
textarea.edit-area {
  width: 100%; min-height: 180px; resize: vertical;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 10px;
  padding: 14px; font-size: 17px; line-height: 1.6; font-family: var(--font-serif);
  margin-top: 8px; outline: none;
}
textarea.edit-area:focus { border-color: var(--accent); }
.page-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.page-actions button {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 14px; font-size: 11px; letter-spacing: 1px; text-transform: uppercase;
  cursor: pointer; font-family: var(--font-mono); font-weight: 700;
}
.page-actions button:hover { border-color: var(--accent); color: var(--accent); }
.page-actions button.primary {
  background: var(--accent); color: #0d0d0f; border-color: var(--accent);
}
.page-actions button.primary:hover { opacity: 0.88; color: #0d0d0f; }
.page-actions button:disabled { opacity: 0.5; cursor: progress; }

/* ── Revise bar (AI-assisted edit) ─────────── */
.revise-bar {
  max-width: 900px; margin: 14px auto 0; padding: 12px 16px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  display: flex; gap: 10px; align-items: stretch;
}
.revise-bar input {
  flex: 1; background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; font-size: 14px; font-family: var(--font-serif); outline: none;
}
.revise-bar input:focus { border-color: var(--accent); }
.revise-bar button {
  background: var(--accent); color: #0d0d0f;
  border: none; border-radius: 999px; padding: 0 20px;
  font-size: 12px; letter-spacing: 1px; text-transform: uppercase;
  cursor: pointer; font-family: var(--font-mono); font-weight: 700;
}
.revise-bar button:hover { opacity: 0.88; }
.revise-bar button:disabled { opacity: 0.5; cursor: progress; }
.revise-bar.busy { border-color: var(--accent); }
@media (max-width: 600px) {
  .revise-bar { margin: 10px 12px 0; }
}

/* ── Slim anonymous sign-in banner ─────────── */
.auth-banner {
  max-width: var(--page-w);
  margin: 24px auto 32px;
  padding: 14px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}
/* The HTML `hidden` attribute is overridden by class display: rules unless
   we re-assert it. Without this, the auth banner stays visible after sign-in
   because .auth-banner sets display: flex. */
[hidden] { display: none !important; }
.auth-banner-msg { flex: 1; font-size: 14px; color: var(--muted); min-width: 240px; }
.auth-banner-msg strong { color: var(--ink); font-weight: 700; }
.auth-banner-actions { display: flex; gap: 8px; flex-shrink: 0; }
@media (max-width: 520px) {
  .auth-banner { margin: 16px 12px; padding: 12px 14px; }
  .auth-banner-actions { width: 100%; }
  .auth-banner-actions button { flex: 1; }
}

/* ── Personal cast chips (library create form) ─────────────────────────────
   Auto-include happens via name-mention — typing "Lark and Willa" in the
   prompt puts them in the book regardless of this strip. So this is now a
   tiny footer line (no card chrome, sits below the prompt + adhoc strip)
   that opens inline only when someone wants to chip-pick characters they
   haven't named in the prompt. */
.my-cast-chips {
  display: block;
  background: transparent;
  border: none;
}
.cast-mini { margin-top: 4px; }
.cast-chips-summary {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 4px 6px;
  background: transparent; border: none;
  color: var(--muted); cursor: pointer;
  font-family: inherit; text-align: left;
  border-radius: 6px;
  font-size: 11px;
}
.cast-chips-summary:hover { background: rgba(255,255,255,0.03); color: var(--ink); }
:root[data-theme="light"] .cast-chips-summary:hover { background: rgba(0,0,0,0.025); }
.cast-chips-label {
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.08em; text-transform: uppercase; color: inherit;
}
.cast-chips-count {
  font-family: var(--font-mono); font-size: 10px;
  color: inherit; opacity: 0.7;
}
.cast-chips-summary-spacer { flex: 1; }
.cast-chips-toggle-glyph {
  color: inherit; opacity: 0.6;
  font-size: 10px;
  transition: transform 0.15s;
  display: inline-block;
}
.cast-chips-summary[aria-expanded="true"] .cast-chips-toggle-glyph {
  transform: rotate(180deg);
}
.cast-chips-body {
  padding: 6px 4px 4px;
  /* No top border — the summary above is already a thin one-line affordance. */
}
.cast-chips {
  display: flex; flex-wrap: nowrap; gap: 6px;
  overflow-x: auto;
  overflow-y: visible; /* let × button overflow upward */
  padding: 8px 4px 4px;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}
.cast-chips-link {
  font-family: var(--font-mono); font-size: 10px; color: var(--accent);
  text-decoration: none; letter-spacing: 0.06em; text-transform: uppercase;
}
.cast-chips-link:hover { color: var(--ink); }
.cast-chip-wrap {
  position: relative; flex-shrink: 0;
}
.cast-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px 4px 4px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 999px;
  font-family: var(--font-serif); font-size: 13px;
  cursor: pointer; transition: all 0.12s;
  white-space: nowrap;
}
.cast-chip:hover { border-color: var(--accent); }
.cast-chip.selected { background: var(--accent); color: #0d0d0f; border-color: var(--accent); }
.cast-chip-avatar {
  width: 22px; height: 22px; border-radius: 999px;
  background-color: var(--raised); background-size: cover; background-position: center;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 9px; font-weight: 700;
  color: var(--muted); flex-shrink: 0;
}
.cast-chip.selected .cast-chip-avatar-fallback { color: var(--surface); background: rgba(0,0,0,0.18); }
/* × remove-from-cast button — only shows on hover (desktop) and always
   visible on touch devices (no hover state). Stops propagation in JS so
   tapping it doesn't also toggle chip selection. */
.cast-chip-remove {
  position: absolute;
  top: -2px; right: -2px;
  width: 18px; height: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px; line-height: 1;
  padding: 0;
  display: none;
  align-items: center; justify-content: center;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.cast-chip-wrap:hover .cast-chip-remove,
.cast-chip-remove:focus-visible {
  display: inline-flex;
}
.cast-chip-remove:hover {
  background: #ef4444;
  color: white;
  border-color: #ef4444;
}
@media (hover: none), (max-width: 600px) {
  /* Touch devices have no hover — keep × visible always so it's reachable. */
  .cast-chip-remove { display: inline-flex; }
}

/* ── /my-characters page extras ─────────── */
.cast-actions { display: flex; gap: 10px; margin: 0 0 22px; flex-wrap: wrap; }
.btn-ghost {
  padding: 9px 18px;
  background: transparent; color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px;
  font-family: var(--font-serif); font-size: 14px; cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-ghost.btn-compact { padding: 5px 12px; font-size: 12px; }
.btn-danger {
  padding: 9px 18px; background: transparent; color: #d97a7a;
  border: 1px solid #4a2a2a; border-radius: 8px; cursor: pointer;
  font-family: var(--font-serif); font-size: 14px;
}
.btn-danger:hover { background: var(--tint-bad); }

.character-card.my-char .character-portrait {
  display: flex; align-items: center; justify-content: center;
  background: var(--raised); aspect-ratio: 1; overflow: hidden;
}
.character-card.my-char .character-portrait img {
  width: 100%; height: 100%; object-fit: cover;
}
.character-card.my-char .portrait-fallback {
  font-family: var(--font-mono); font-size: 36px; font-weight: 700;
  color: var(--muted);
}
.char-style-line {
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
  letter-spacing: 1px; text-transform: uppercase; margin: 8px 0 0;
}
.char-actions { margin-top: 10px; }

/* ── Modal (editor + extract) ─────────── */
.modal {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  padding: 20px; overflow-y: auto;
}
.modal-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); width: 100%; max-width: 640px;
  max-height: 90vh; display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 18px; font-weight: 700; }
.modal-close {
  background: transparent; border: none; color: var(--muted);
  font-size: 28px; line-height: 1; cursor: pointer; padding: 0 8px;
}
.modal-close:hover { color: var(--ink); }
.modal-body {
  padding: 18px 22px; overflow-y: auto; flex: 1;
  display: flex; flex-direction: column; gap: 14px;
}
.modal-body label {
  display: flex; flex-direction: column; gap: 6px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 1.5px;
  text-transform: uppercase; color: var(--muted);
}
.modal-body label .lbl-hint {
  text-transform: none; letter-spacing: 0; font-size: 11px;
  color: var(--dim); margin-left: 6px;
}
.modal-body input[type="text"], .modal-body select, .modal-body textarea {
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; font-size: 14px; font-family: var(--font-serif);
  outline: none; transition: border-color 0.12s;
}
.modal-body input[type="text"]:focus,
.modal-body select:focus,
.modal-body textarea:focus { border-color: var(--accent); }
.modal-body textarea { resize: vertical; min-height: 60px; }
.modal-body .row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.photo-row .photo-stack {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.photo-row #photoPreview {
  width: 80px; height: 80px; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--border);
}
.modal-foot {
  padding: 14px 22px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; align-items: center;
}
.modal-foot .spacer { flex: 1; }

/* Extract modal */
.modal-body .hint { color: var(--muted); font-size: 13px; line-height: 1.5; margin: 0 0 6px; }
.modal-body .hint strong { color: var(--ink); }
.modal-body details { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; }
.modal-body details summary { cursor: pointer; font-family: var(--font-mono); font-size: 12px; color: var(--accent); }
.modal-body details textarea { width: 100%; margin-top: 10px; min-height: 120px; font-family: var(--font-mono); font-size: 11px; color: var(--muted); }
.extract-result { margin-top: 14px; }
.extract-cards { display: flex; flex-direction: column; gap: 12px; margin: 12px 0; }
.extract-card {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; opacity: 0.5;
  display: flex; flex-direction: column; gap: 8px;
}
.extract-card.selected { opacity: 1; border-color: var(--accent); }
.extract-toggle {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  font-family: var(--font-serif); font-size: 14px;
  text-transform: none; letter-spacing: 0; color: var(--ink);
}
.extract-toggle strong { font-size: 15px; }
.extract-toggle .extract-meta { color: var(--muted); font-size: 12px; }
.extract-card input[type="text"], .extract-card textarea {
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 6px 10px; font-size: 13px; font-family: var(--font-serif);
}
.extract-card textarea { resize: vertical; min-height: 50px; }

/* ─────────────────────────────────────────────────────────────────────────
   Podcasts — solid colors only, follows the app's existing dark theme.
   ───────────────────────────────────────────────────────────────────────── */

.top-nav { display: flex; align-items: center; gap: 4px; margin-left: 18px; }
.top-nav-link {
  padding: 6px 12px; border-radius: 6px;
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); text-decoration: none;
  border: 1px solid transparent;
}
.top-nav-link:hover { color: var(--ink); border-color: var(--border); }
.top-nav-link.active { color: var(--ink); border-color: var(--accent); }

.podcast-controls {
  display: flex; gap: 18px; flex-wrap: wrap;
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--border);
}
.control-group {
  display: flex; flex-direction: column; gap: 6px;
  flex: 1; min-width: 180px;
}
.control-label {
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted);
}
.control-select {
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; font-size: 14px;
  font-family: var(--font-serif);
}
.control-select:focus { outline: none; border-color: var(--accent); }
.voice-vibe {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--muted); margin-top: 2px;
  font-style: italic;
}

.podcast-card .card-row {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-bottom: 6px;
}
.length-badge {
  display: inline-block;
  background: var(--accent); color: #0d0d0f;
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 4px;
  font-weight: 700;
}
.badge-private, .badge-owned {
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 4px;
  border: 1px solid var(--border); color: var(--muted);
}
.badge-owned { color: var(--accent); border-color: var(--accent); }
.card-status {
  font-family: var(--font-mono); font-size: 10px;
  color: var(--muted); font-style: italic;
}
.tag {
  display: inline-block;
  background: var(--surface); color: var(--muted);
  border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 10px;
  padding: 2px 8px; border-radius: 4px;
  letter-spacing: 0.04em;
}
.pills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

body.podcast-page { padding-bottom: 120px; }
.podcast-stage { max-width: 760px; margin: 0 auto; padding: 24px 24px 80px; }

.podcast-hero {
  display: grid; grid-template-columns: 280px 1fr;
  gap: 28px; padding: 24px 0 32px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 32px;
}
@media (max-width: 640px) { .podcast-hero { grid-template-columns: 1fr; } }

.podcast-cover-wrap { aspect-ratio: 1 / 1; position: relative; }
.podcast-cover {
  width: 100%; height: 100%; object-fit: cover;
  border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); display: block;
}
.podcast-cover-fallback {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
  background: var(--surface);
  border-radius: 12px; border: 1px solid var(--border);
  color: var(--muted);
  font-family: var(--font-mono); font-size: 12px;
}
.podcast-cover-fallback .spark { color: var(--accent); font-size: 32px; }

.podcast-meta { display: flex; flex-direction: column; }
.podcast-eyebrow {
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--muted); margin: 0 0 8px 0;
}
.podcast-h1 {
  font-family: var(--font-serif);
  font-size: 32px; line-height: 1.15; font-weight: 700;
  color: var(--ink); margin: 0 0 12px 0;
}
.podcast-synopsis {
  font-family: var(--font-serif); font-size: 16px;
  line-height: 1.5; color: var(--muted); margin: 0 0 16px 0;
}
.podcast-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 18px; }

.btn-play {
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--accent); color: #0d0d0f;
  border: none; border-radius: 999px;
  padding: 10px 22px;
  font-family: var(--font-mono); font-size: 13px;
  letter-spacing: 0.06em; text-transform: uppercase;
  font-weight: 700; cursor: pointer;
  transition: transform 0.1s ease;
  align-self: flex-start;
}
.btn-play:hover:not(:disabled) { transform: translateY(-1px); }
.btn-play:disabled { opacity: 0.4; cursor: not-allowed; }
.play-glyph { font-size: 16px; }
.play-hint {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--muted); margin: 8px 0 0 0; font-style: italic;
}

.podcast-body { display: flex; flex-direction: column; gap: 28px; }
.pod-section {
  font-family: var(--font-serif);
  font-size: 17px; line-height: 1.7;
  color: var(--ink); padding: 4px 0;
  transition: border-color 0.2s, padding-left 0.2s;
}
.pod-section.active {
  border-left: 3px solid var(--accent);
  padding-left: 16px; margin-left: -16px;
}
.pod-section p { margin: 0 0 14px 0; }

/* Section headings are clickable buttons — click to play from that section.
   Look indistinguishable from a static heading at rest; reveal the "▶ play
   from here" affordance only on hover (or always on touch since there's no
   hover state). */
.pod-heading {
  display: inline-flex; align-items: baseline; gap: 12px;
  font-family: var(--font-mono); font-size: 12px;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--accent); margin: 0 0 12px 0;
  background: transparent; border: none;
  padding: 4px 8px 4px 0;
  cursor: pointer;
  text-align: left;
  border-radius: 4px;
  transition: background 0.12s, color 0.12s;
}
.pod-heading:hover { background: rgba(232,137,74,0.08); color: var(--ink); }
:root[data-theme="light"] .pod-heading:hover { background: rgba(232,137,74,0.1); }
.pod-heading-text { color: inherit; }
.pod-heading-play {
  font-family: var(--font-mono); font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.12s;
}
.pod-heading:hover .pod-heading-play { opacity: 1; }
@media (hover: none) {
  /* Touch — no hover, so always show the play affordance (subtler than hover). */
  .pod-heading-play { opacity: 0.5; }
}
.pod-intro { font-size: 19px; }
.pod-intro p:first-child::first-letter {
  font-size: 56px; float: left; line-height: 1;
  margin: 4px 8px 0 0; color: var(--accent);
  font-family: var(--font-serif); font-weight: 700;
}
.pod-outro {
  border-top: 1px solid var(--border);
  padding-top: 20px; margin-top: 8px;
  color: var(--muted); font-style: italic;
}

.player-bar {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 24px;
  display: flex; align-items: center; gap: 18px;
  z-index: 50;
}
.player-info { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.player-now {
  font-family: var(--font-serif); font-size: 14px; color: var(--ink);
  font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.player-progress {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--muted); letter-spacing: 0.06em;
}
.player-controls { display: flex; align-items: center; gap: 8px; }
.player-btn {
  background: transparent; border: 1px solid var(--border);
  color: var(--ink); cursor: pointer;
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
  transition: border-color 0.15s, color 0.15s;
}
.player-btn:hover { border-color: var(--accent); color: var(--accent); }
.player-btn-speed { width: auto; min-width: 36px; padding: 0 10px; border-radius: 18px; font-size: 12px; font-variant-numeric: tabular-nums; }
.player-btn-primary {
  background: var(--accent); color: #0d0d0f;
  border-color: var(--accent);
  width: 44px; height: 44px; font-size: 16px;
}

.empty {
  color: var(--muted);
  font-family: var(--font-serif);
  font-size: 14px; font-style: italic;
  padding: 20px; text-align: center;
}

/* Category + refresh badges (additions in migration 008) */
.badge-category {
  display: inline-block;
  background: transparent; color: var(--muted);
  border: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 4px;
}
/* Brand-color overrides for the well-known categories. Anything else falls
   back to the muted default. */
.badge-cat-work       { color: #5f9aff; border-color: rgba(95,154,255,0.4); }
.badge-cat-consulting { color: #c79bff; border-color: rgba(199,155,255,0.4); }
.badge-cat-personal   { color: #6ad9b1; border-color: rgba(106,217,177,0.4); }
.badge-cat-learning   { color: var(--accent); border-color: rgba(232,137,74,0.4); }

.badge-refresh {
  display: inline-block;
  background: transparent; color: var(--accent);
  border: 1px solid rgba(232,137,74,0.4);
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.06em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 4px;
}

/* Living-podcast disclosure on the create form */
.refresh-source-disclosure {
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--border);
}
.refresh-source-disclosure summary {
  cursor: pointer;
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); padding: 4px 0;
  list-style: none;
}
.refresh-source-disclosure summary::-webkit-details-marker { display: none; }
.refresh-source-disclosure summary::before { content: '+ '; color: var(--accent); }
.refresh-source-disclosure[open] summary::before { content: '− '; }
.refresh-source-disclosure summary:hover { color: var(--ink); }

.refresh-source-help {
  font-family: var(--font-serif); font-size: 13px;
  color: var(--muted); line-height: 1.5;
  margin: 12px 0;
}
.refresh-source-disclosure textarea {
  width: 100%; box-sizing: border-box;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 10px 12px; font-size: 13px;
  font-family: var(--font-serif); line-height: 1.5;
  resize: vertical; min-height: 80px;
}
.refresh-source-disclosure textarea:focus { outline: none; border-color: var(--accent); }
.refresh-source-row {
  display: flex; gap: 12px; flex-wrap: wrap;
  align-items: center; margin-top: 12px;
}
.refresh-source-row input[type="text"] {
  flex: 1; min-width: 200px;
  background: var(--bg); color: var(--ink);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 10px; font-size: 13px;
}
.refresh-source-row input[type="text"]:focus { outline: none; border-color: var(--accent); }

/* ─────────────────────────────────────────────────────────────────────────
   Ad-hoc characters — pasted/dropped photos on the picturebook create form.
   Visual goal: looks like the prompt textarea grew a row of polaroids,
   doesn't add any visible structure when no photos are attached.
   ───────────────────────────────────────────────────────────────────────── */

.adhoc-hint {
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.04em; color: var(--muted);
  margin: 8px 0 0 0; opacity: 0.7;
}

.adhoc-chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 10px;
}
.adhoc-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 4px 4px 4px;
  position: relative;
  transition: border-color 0.15s;
}
.adhoc-chip:hover { border-color: var(--accent); }
.adhoc-chip-error {
  border-color: var(--red, #ef4444);
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.3);
}
.adhoc-chip img {
  width: 36px; height: 36px;
  border-radius: 6px;
  object-fit: cover;
  display: block;
  background: var(--surface);
  flex-shrink: 0;
}
.adhoc-chip .adhoc-name {
  background: transparent;
  border: none;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 13px;
  width: 130px;
  padding: 4px 6px;
  outline: none;
}
.adhoc-chip .adhoc-name::placeholder {
  color: var(--muted); opacity: 0.6; font-style: italic;
}
.adhoc-chip .adhoc-name:focus { color: var(--ink); }
.adhoc-chip .adhoc-remove {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 6px;
  opacity: 0.6;
  transition: opacity 0.15s, color 0.15s;
}
.adhoc-chip .adhoc-remove:hover {
  opacity: 1;
  color: var(--red, #ef4444);
}

/* Drop-zone affordance — subtle dashed accent border when a file is dragged
   over the prompt textarea or the chips strip. */
#prompt.drop-hover, .adhoc-chips.drop-hover {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

/* ── Mobile header — keep everything inside a 375px viewport ────────────────
   The full desktop header (spark + wordmark + Books/Podcasts/Feed nav + theme
   toggle + bell + auth + menu) overflows on phones. Below 600px we hide the
   wordmark and tighten gaps; below 520px we drop the Feed link to the
   overflow menu (still reachable via ⋯); below 420px we cut padding further
   so the row stays inside any iPhone width. */
@media (max-width: 600px) {
  .top { gap: 8px; padding: 12px 14px; }
  .top-logo .wordmark { display: none; }
  .top-logo .spark { font-size: 22px; }
  .top-nav { margin-left: 4px; gap: 2px; }
  .top-nav-link { padding: 5px 8px; font-size: 10px; letter-spacing: 0.04em; }
  .theme-toggle { width: 32px; height: 32px; }
  .menu-trigger { width: 32px; height: 32px; }
  .auth-initials { font-size: 11px; }
}
@media (max-width: 520px) {
  /* Drop Feed from the top-nav on small phones — it's always in the ⋯
     menu, so the row stays at 2 links (Books/Podcasts) per the original
     mobile-header contract. */
  .top-nav-link[href="/feed"] { display: none; }
}
@media (max-width: 420px) {
  .top { gap: 4px; padding: 10px 10px; }
  .top-nav-link { padding: 4px 6px; font-size: 9px; }
}

/* ── Theme toggle ─────────────────────────────────────────────────────────── */
.theme-toggle {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 99px;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1;
  color: var(--text);
  cursor: pointer;
  margin-right: 8px;
  transition: border-color .15s ease, background .15s ease, transform .12s ease;
  position: relative;
  overflow: hidden;
}
.theme-toggle:hover { border-color: var(--accent); }
.theme-toggle:active { transform: scale(0.94); }
.theme-toggle-sun, .theme-toggle-moon {
  position: absolute; inset: 0;
  display: inline-flex; align-items: center; justify-content: center;
  transition: opacity .18s ease, transform .25s cubic-bezier(.5,1.6,.4,1);
}
:root[data-theme="light"] .theme-toggle-sun { opacity: 1; transform: scale(1); }
:root[data-theme="light"] .theme-toggle-moon { opacity: 0; transform: scale(0.6) rotate(40deg); }
:root[data-theme="dark"] .theme-toggle-sun { opacity: 0; transform: scale(0.6) rotate(-40deg); }
:root[data-theme="dark"] .theme-toggle-moon { opacity: 1; transform: scale(1); }
:root:not([data-theme]) .theme-toggle-sun { opacity: 0; }
:root:not([data-theme]) .theme-toggle-moon { opacity: 1; }
@media (prefers-color-scheme: light) {
  :root:not([data-theme]) .theme-toggle-sun { opacity: 1; }
  :root:not([data-theme]) .theme-toggle-moon { opacity: 0; }
}

/* ── Updates / Feedback page shells ─────────────────────────────────────── */
.page-shell { max-width: var(--page-w); margin: 0 auto; padding: 28px 20px 80px; }
.page-shell h1 { font-size: 28px; margin: 0 0 8px; color: var(--text); }
.page-shell .lede { color: var(--text-mute); font-size: 15px; margin: 0 0 24px; max-width: 640px; line-height: 1.55; }

.update-card, .feedback-form {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 22px; margin-bottom: 14px;
  box-shadow: 0 1px 3px var(--shadow-soft);
}
.update-card .uh { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 6px; flex-wrap: wrap; }
.update-card .ut { font-size: 16px; font-weight: 700; color: var(--text); }
.update-card .ud { font-size: 12px; color: var(--text-mute); font-family: var(--font-mono); }
.update-card .ub { font-size: 14px; color: var(--text-soft); line-height: 1.6; }
.update-tag { display: inline-block; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; padding: 2px 8px; border-radius: 99px; font-family: var(--font-mono); background: var(--tint-warn); color: var(--accent); border: 1px solid var(--tint-warn-edge); margin-right: 4px; }
.update-tag.new-feature { background: var(--tint-good); color: var(--green); border-color: var(--tint-good-edge); }
.update-tag.bug-fix { background: var(--tint-bad); color: #d63838; border-color: var(--tint-bad-edge); }
.update-tag.enhancement { background: var(--tint-warn); color: var(--accent); border-color: var(--tint-warn-edge); }

.feedback-form label { display: block; font-size: 12px; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.08em; font-family: var(--font-mono); margin-bottom: 6px; }
.feedback-form textarea, .feedback-form input[type="text"] {
  width: 100%; box-sizing: border-box;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; color: var(--text); font-family: var(--font-serif); font-size: 15px;
  margin-bottom: 14px; resize: vertical;
}
.feedback-form textarea:focus, .feedback-form input:focus { outline: 2px solid var(--accent); outline-offset: -2px; }
.feedback-form .row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.feedback-form .submit-btn { background: var(--accent); color: #0d0d0f; border: none; padding: 10px 20px; border-radius: 10px; font-weight: 700; cursor: pointer; font-family: var(--font-mono); font-size: 13px; }
.feedback-form .submit-btn:hover { background: var(--link-hover); }

/* My reports list (feedback history) */
.my-reports-list .report-item {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; margin-bottom: 8px;
}
.my-reports-list .report-meta { font-size: 11px; color: var(--text-mute); font-family: var(--font-mono); margin-bottom: 4px; display: flex; gap: 10px; }
.my-reports-list .report-body { font-size: 14px; color: var(--text-soft); line-height: 1.5; }

/* Admin section */
.admin-section { margin-bottom: 28px; }
.admin-section h3 { font-size: 13px; font-weight: 700; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.08em; font-family: var(--font-mono); margin: 0 0 10px; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.admin-stat { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: 10px; padding: 14px 18px; }
.admin-stat .num { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1; }
.admin-stat .lab { font-size: 11px; color: var(--text-mute); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 4px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-top: 8px; }
.admin-table th, .admin-table td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--border); color: var(--text-soft); }
.admin-table th { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-mute); font-family: var(--font-mono); }

/* Share button (book + podcast pages) */
.share-btn {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  padding: 8px 14px; border-radius: 99px; cursor: pointer;
  font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.04em;
  display: inline-flex; align-items: center; gap: 6px;
  transition: border-color .15s ease, background .15s ease;
}
.share-btn:hover { border-color: var(--accent); }
.share-btn.copied { background: var(--tint-good); border-color: var(--tint-good-edge); color: var(--green); }
.share-btn .share-icon { font-size: 14px; }

/* ── Footer ───────────────────────────────────────────────────────────── */
.pb-footer {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  flex-wrap: wrap;
  padding: 26px 20px 36px; margin-top: 48px;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 11px; color: var(--text-mute);
  letter-spacing: 0.04em;
}
.pb-footer a { color: var(--text-mute); }
.pb-footer a:hover { color: var(--accent); }
.pb-footer .pb-footer-sep { color: var(--dim); }

/* ── Notifications bell ──────────────────────────────────────────────── */
.alert-bell {
  position: relative;
  background: var(--surface); border: 1px solid var(--border); border-radius: 99px;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; line-height: 1; cursor: pointer;
  margin-right: 6px;
  transition: border-color .15s ease, background .15s ease;
}
.alert-bell:hover { border-color: var(--accent); }
.alert-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--accent); color: #0d0d0f; font-family: var(--font-mono);
  font-size: 9px; font-weight: 800; min-width: 16px; height: 16px;
  border-radius: 99px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0 4px; box-shadow: 0 0 0 2px var(--bg);
}
.alert-panel {
  position: absolute; top: 60px; right: 24px;
  width: min(380px, calc(100vw - 48px));
  max-height: 70vh; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: 0 12px 32px var(--shadow);
  z-index: 100;
  display: flex; flex-direction: column;
}
.alert-panel-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 11px; color: var(--text-mute);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.alert-mark-all {
  background: transparent; border: none; color: var(--accent); cursor: pointer;
  font-family: var(--font-mono); font-size: 11px;
}
.alert-mark-all:hover { color: var(--link-hover); }
.alert-list { overflow-y: auto; }
.alert-empty { padding: 24px 16px; color: var(--text-mute); font-size: 13px; text-align: center; }
.alert-row {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto auto; gap: 4px 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border-dim, var(--border));
  text-decoration: none; color: var(--text); cursor: pointer;
  transition: background .12s ease;
}
.alert-row:hover { background: var(--bg-hover); text-decoration: none; }
.alert-row.unread { background: rgba(232,137,74,0.04); }
.alert-row.unread .alert-title::before {
  content: ''; display: inline-block; width: 6px; height: 6px; background: var(--accent);
  border-radius: 50%; margin-right: 6px; vertical-align: middle;
}
.alert-type {
  grid-row: 1 / 4; align-self: start; margin-top: 3px;
  font-family: var(--font-mono); font-size: 9px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.06em;
  padding: 3px 7px; border-radius: 99px;
  background: var(--tint-warn); color: var(--accent); border: 1px solid var(--tint-warn-edge);
  white-space: nowrap;
}
.alert-type-share { background: var(--tint-good); color: var(--green); border-color: var(--tint-good-edge); }
.alert-type-changelog { background: var(--tint-warn); color: var(--accent); border-color: var(--tint-warn-edge); }
.alert-type-broadcast { background: rgba(167,139,250,0.16); color: var(--accent2); border-color: rgba(167,139,250,0.4); }
.alert-title { grid-column: 2; font-size: 13px; font-weight: 700; color: var(--text); }
.alert-body { grid-column: 2; font-size: 12px; color: var(--text-soft); line-height: 1.4; }
.alert-when { grid-column: 2; font-size: 10px; color: var(--text-mute); font-family: var(--font-mono); }

/* ── Share dialog (email + copy) ─────────────────────────────────────── */
.share-modal-backdrop {
  position: fixed; inset: 0; background: var(--overlay); z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.share-modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 22px 26px; width: min(420px, calc(100vw - 32px));
  box-shadow: 0 24px 48px var(--shadow);
}
.share-modal h3 { margin: 0 0 6px; font-size: 16px; color: var(--text); }
.share-modal .sm-sub { color: var(--text-mute); font-size: 13px; margin: 0 0 14px; }
.share-modal label { display: block; font-size: 10px; color: var(--text-mute); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.08em; margin: 12px 0 4px; }
.share-modal input[type="email"], .share-modal input[type="text"], .share-modal textarea {
  width: 100%; box-sizing: border-box;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 12px; color: var(--text); font-family: var(--font-serif); font-size: 14px;
}
.share-modal textarea { min-height: 60px; resize: vertical; }
.share-modal .sm-row { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.share-modal .sm-btn-primary { background: var(--accent); color: #0d0d0f; border: none; padding: 9px 16px; border-radius: 8px; font-weight: 700; cursor: pointer; font-family: var(--font-mono); font-size: 12px; }
.share-modal .sm-btn-primary:hover { background: var(--link-hover); }
.share-modal .sm-btn-secondary { background: transparent; color: var(--text-soft); border: 1px solid var(--border); padding: 9px 14px; border-radius: 8px; cursor: pointer; font-family: var(--font-mono); font-size: 12px; }
.share-modal .sm-btn-secondary:hover { border-color: var(--text-mute); }
.share-modal .sm-status { font-size: 12px; color: var(--text-mute); font-family: var(--font-mono); margin-left: auto; }

/* ── Shared with me section ────────────────────────────────────────── */
.shared-with-me .share-card {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent2);
  border-radius: var(--radius); padding: 16px 18px; margin-bottom: 10px;
  display: flex; gap: 14px; align-items: flex-start; text-decoration: none;
  color: var(--text); transition: transform .12s ease, border-color .12s ease;
}
.shared-with-me .share-card:hover { border-color: var(--accent); transform: translateY(-1px); text-decoration: none; }
.shared-with-me .share-card .sw-meta { font-size: 11px; color: var(--text-mute); font-family: var(--font-mono); margin-bottom: 4px; }
.shared-with-me .share-card .sw-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.shared-with-me .share-card .sw-msg { font-size: 12.5px; color: var(--text-soft); line-height: 1.5; }

/* ── Inline sign-in card (pbAuthUI) — rendered in place when a page's data
      needs auth, instead of bouncing to the homepage. grid-column spans the
      full row when mounted inside a card grid. ─────────────────────────────── */
.pb-inline-auth { max-width: 480px; margin: 28px auto; width: 100%; grid-column: 1 / -1; }
.pb-inline-auth .hero-label { margin-bottom: 10px; text-align: center; }

