/* Copied from web/src/styles (base.css + screens.css) for the homepage tour. */
/* ==========================================================================
   Featherbound — design system (ported from prototype-v1)
   Cozy enchanted library: warm parchment, deep jewel tones, soft magic.
   ========================================================================== */

:root {
  /* Surfaces */
  --parchment: #fbf4e4;
  --parchment-2: #f4e8cd;
  --parchment-3: #ead9b4;
  --paper: #fffdf7;
  --wood: #8a5a3b;
  --wood-dark: #5f3c27;
  --wood-light: #b07d55;

  /* Ink */
  --ink: #2b2140;
  --ink-soft: #5e5373;
  --ink-faint: #716a80; /* 4.5:1 on paper and parchment (WCAG AA) */

  /* Jewels */
  --plum: #4b2e83;
  --plum-deep: #2e1b55;
  --plum-soft: #ece4f8;
  --lavender: #b9a5e3;
  --gold: #d4a23a;
  --gold-deep: #835d0f; /* 4.5:1 on gold-soft */
  --gold-soft: #f6e3ae;
  --emerald: #2f7d62;
  --emerald-soft: #dcefe6;
  --sapphire: #3462a8;
  --sapphire-soft: #dde7f6;
  --ruby: #b23a52;
  --ruby-soft: #f7dfe4;
  --rose: #f6b8c6;
  --sky: #cfe3f5;

  /* Lines & shadows */
  --line: rgba(43, 33, 64, 0.12);
  --line-strong: rgba(43, 33, 64, 0.22);
  --shadow-sm: 0 1px 2px rgba(46, 27, 85, 0.08), 0 2px 6px rgba(46, 27, 85, 0.06);
  --shadow-md: 0 4px 10px rgba(46, 27, 85, 0.08), 0 12px 28px rgba(46, 27, 85, 0.1);
  --shadow-lg: 0 10px 30px rgba(46, 27, 85, 0.16), 0 30px 60px rgba(46, 27, 85, 0.12);

  /* Type */
  /* Font families are self-hosted by next/font and exposed as --fb-* variables in the root layout. */
  --font-display: var(--fb-fraunces), 'Georgia', serif;
  --font-ui: var(--fb-nunito), system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-read: var(--fb-literata), 'Georgia', serif;
  --font-lexend: var(--fb-lexend), system-ui, sans-serif;
  --font-hyperlegible: var(--fb-atkinson), system-ui, sans-serif;

  /* Shape & rhythm */
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --r-xl: 32px;
  --gutter: clamp(16px, 4vw, 40px);
  --maxw: 1240px;

  color-scheme: light;
}

* { box-sizing: border-box; }
html, body, #root { min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--parchment);
  background-image:
    radial-gradient(1200px 600px at 10% -10%, rgba(185, 165, 227, 0.28), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(246, 227, 174, 0.55), transparent 60%),
    radial-gradient(800px 600px at 50% 120%, rgba(207, 227, 245, 0.45), transparent 60%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-variation-settings: 'SOFT' 100, 'WONK' 0;
  font-weight: 650;
  line-height: 1.15;
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--plum-deep);
}
h1 { font-size: clamp(28px, 4vw, 40px); }
h2 { font-size: clamp(22px, 3vw, 28px); }
h3 { font-size: 19px; }
h4 { font-size: 16px; }
p { margin: 0; }
a { color: var(--plum); }
button { font: inherit; color: inherit; }
img, svg { display: block; }

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
  border-radius: 6px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- Layout ---------- */

.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 24px var(--gutter) 120px;
}
.page-narrow { max-width: 920px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.stack-lg { display: flex; flex-direction: column; gap: 28px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.spacer { flex: 1; }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }
.small { font-size: 14px; }
.tiny { font-size: 12.5px; }
.center { text-align: center; }
.mono { font-variant-numeric: tabular-nums; }

/* ---------- Top bar & nav ---------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  background: rgba(251, 244, 228, 0.82);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 10px var(--gutter);
  display: flex; align-items: center; gap: 16px;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--plum-deep);
}
.brand-name {
  font-family: var(--font-display);
  font-variation-settings: 'SOFT' 100, 'WONK' 1;
  font-weight: 700; font-size: 24px; letter-spacing: -0.02em;
}
.nav { display: flex; gap: 4px; margin-left: 12px; }
.nav a {
  text-decoration: none; color: var(--ink-soft); font-weight: 700;
  padding: 8px 14px; border-radius: 999px; font-size: 15px;
}
.nav a:hover { background: rgba(75, 46, 131, 0.07); color: var(--plum); }
.nav a.active { background: var(--plum); color: #fff; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold-soft), var(--rose));
  display: grid; place-items: center; font-weight: 800; color: var(--plum-deep);
  border: 2px solid #fff; box-shadow: var(--shadow-sm);
}

.bottom-nav {
  display: none;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: rgba(255, 253, 247, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  justify-content: space-around;
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11.5px; font-weight: 800; text-decoration: none; color: var(--ink-faint);
  padding: 6px 10px; border-radius: 14px; min-width: 64px;
}
.bottom-nav a.active { color: var(--plum); background: var(--plum-soft); }

@media (max-width: 760px) {
  .nav, .topbar .hide-mobile { display: none; }
  .bottom-nav { display: flex; }
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; cursor: pointer; text-decoration: none;
  font-weight: 800; font-size: 15px; line-height: 1;
  padding: 12px 18px; border-radius: 999px;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease;
  white-space: nowrap;
  min-height: 44px;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn-primary {
  color: #fff;
  background: linear-gradient(180deg, #6a46b0, var(--plum));
  box-shadow: 0 2px 0 var(--plum-deep), var(--shadow-sm);
}
.btn-primary:hover { background: linear-gradient(180deg, #7650bd, #553494); }
.btn-gold {
  color: var(--plum-deep);
  background: linear-gradient(180deg, #f2c35c, var(--gold));
  box-shadow: 0 2px 0 var(--gold-deep), var(--shadow-sm);
}
.btn-secondary {
  background: var(--paper); color: var(--plum);
  box-shadow: inset 0 0 0 1.5px var(--line-strong), var(--shadow-sm);
}
.btn-secondary:hover { box-shadow: inset 0 0 0 1.5px var(--plum), var(--shadow-sm); }
.btn-ghost { background: transparent; color: var(--plum); }
.btn-ghost:hover { background: rgba(75, 46, 131, 0.08); }
.btn-danger { background: var(--ruby); color: #fff; box-shadow: 0 2px 0 #7d2236; }
.btn-sm { padding: 8px 12px; font-size: 13.5px; min-height: 36px; }
.btn-icon { padding: 0; width: 44px; height: 44px; border-radius: 50%; }
.btn-icon.btn-sm { width: 36px; height: 36px; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------- Cards, chips, badges ---------- */

.card {
  background: var(--paper);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line);
  padding: 20px;
}
.card-lg { padding: 28px; }
.card-tinted { background: linear-gradient(180deg, #fffaf0, #fbf1dc); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 800;
  padding: 4px 10px; border-radius: 999px;
  background: var(--plum-soft); color: var(--plum);
  white-space: nowrap;
}
.chip-gold { background: var(--gold-soft); color: var(--gold-deep); }
.chip-emerald { background: var(--emerald-soft); color: #2b735a; }
.chip-sapphire { background: var(--sapphire-soft); color: var(--sapphire); }
.chip-ruby { background: var(--ruby-soft); color: var(--ruby); }
.chip-plain { background: rgba(43, 33, 64, 0.06); color: var(--ink-soft); }
.chip-outline { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-strong); color: var(--ink-soft); }

.badge-version {
  font-family: var(--font-ui); font-weight: 800; font-size: 12px;
  padding: 3px 8px; border-radius: 6px;
  background: var(--plum-deep); color: var(--gold-soft);
  letter-spacing: 0.02em;
}

.dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; display: inline-block; }

.divider { height: 1px; background: var(--line); border: 0; margin: 4px 0; }

/* ---------- Forms ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-weight: 800; font-size: 14px; color: var(--ink); }
.hint { font-size: 13px; color: var(--ink-soft); }
.input, .select, .textarea {
  font: inherit; color: var(--ink);
  background: #fff;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-md);
  padding: 11px 14px;
  min-height: 44px;
  width: 100%;
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--plum); box-shadow: 0 0 0 4px rgba(75, 46, 131, 0.14); }

.segmented {
  display: inline-flex; padding: 4px; gap: 2px;
  background: rgba(43, 33, 64, 0.06);
  border-radius: 999px;
}
.segmented button {
  border: none; background: transparent; cursor: pointer;
  font-weight: 800; font-size: 13.5px; color: var(--ink-soft);
  padding: 8px 14px; border-radius: 999px; min-height: 36px;
  display: inline-flex; align-items: center; gap: 6px;
}
.segmented button.on { background: #fff; color: var(--plum); box-shadow: var(--shadow-sm); }
.segmented button.on.keep { color: var(--emerald); }
.segmented button.on.soften { color: var(--gold-deep); }
.segmented button.on.remove { color: var(--ruby); }

.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; margin: 0; z-index: 1; }
.switch span {
  position: absolute; inset: 0; border-radius: 999px; background: rgba(43, 33, 64, 0.18);
  transition: background 0.2s;
}
.switch span::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow-sm); transition: transform 0.2s;
}
.switch input:checked + span { background: var(--plum); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }

input[type='range'].range {
  width: 100%; accent-color: var(--plum); height: 28px;
}

/* ---------- Speech bubble ---------- */

.bubble {
  position: relative;
  background: #fff;
  border-radius: 20px;
  padding: 14px 18px;
  box-shadow: var(--shadow-md), inset 0 0 0 1px var(--line);
  font-weight: 650;
  color: var(--ink);
}
.bubble::before {
  content: ''; position: absolute; left: -9px; bottom: 18px;
  width: 18px; height: 18px; background: #fff;
  transform: rotate(45deg);
  box-shadow: -1px 1px 0 var(--line);
  border-radius: 3px;
}
.bubble-top::before { left: 28px; top: -8px; bottom: auto; box-shadow: -1px -1px 0 var(--line); }
.guide { display: flex; align-items: flex-end; gap: 12px; }
.guide .bubble { flex: 1; }

/* ---------- Mascot animation ---------- */

@keyframes bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes hatwiggle { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(-3deg); } }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.1); } }
@keyframes quill { 0%, 100% { transform: rotate(0deg) translateX(0); } 50% { transform: rotate(-8deg) translateX(-2px); } }
@keyframes tailflick { 0%, 70%, 100% { transform: rotate(0deg); } 78% { transform: rotate(-7deg); } 86% { transform: rotate(3deg); } }
@keyframes twinkle { 0%, 100% { opacity: 0.2; transform: scale(0.7); } 50% { opacity: 1; transform: scale(1.1); } }
@keyframes floaty { 0% { transform: translateY(0) rotate(0); opacity: 0; } 15% { opacity: 1; } 100% { transform: translateY(-60px) rotate(25deg); opacity: 0; } }

.tuft .tuft-body { animation: bob 3.2s ease-in-out infinite; transform-origin: 100px 150px; }
.tuft .tuft-hat { animation: hatwiggle 4s ease-in-out infinite; transform-origin: 100px 90px; transform-box: view-box; }
.tuft .tuft-tail { animation: tailflick 4.4s ease-in-out infinite; transform-origin: 132px 170px; transform-box: view-box; }
.tuft .tuft-eye { animation: blink 5s infinite; transform-box: fill-box; transform-origin: center; }
.tuft .tuft-quill { animation: quill 0.6s ease-in-out infinite; transform-box: fill-box; transform-origin: bottom right; }
.tuft .tuft-spark { animation: twinkle 1.8s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.tuft .tuft-spark:nth-of-type(2) { animation-delay: 0.6s; }
.tuft .tuft-spark:nth-of-type(3) { animation-delay: 1.2s; }
.tuft.still * { animation: none !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- Book covers ---------- */

.cover {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 4px 10px 10px 4px;
  overflow: hidden;
  box-shadow:
    inset 6px 0 0 rgba(0, 0, 0, 0.18),
    inset 8px 0 0 rgba(255, 255, 255, 0.12),
    0 2px 2px rgba(0, 0, 0, 0.12),
    0 10px 18px rgba(46, 27, 85, 0.22);
  color: #fff;
  text-align: center;
  isolation: isolate;
  min-width: 0;
  min-height: 0;
}
.cover::after {
  content: ''; position: absolute; inset: 0; z-index: -1;
  background: linear-gradient(115deg, rgba(255, 255, 255, 0.18), transparent 30%, transparent 70%, rgba(0, 0, 0, 0.12));
  pointer-events: none;
}
.cover-photo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; z-index: -1; }
.cover-photo::after { z-index: 0; }
.cover-inner { position: absolute; inset: 8% 9% 7% 15%; display: flex; flex-direction: column; }
.cover-title {
  font-family: var(--font-display);
  font-variation-settings: 'SOFT' 100;
  font-weight: 700;
  line-height: 1.05;
  font-size: var(--cover-title-size, 17px);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
.cover-author {
  margin-top: auto;
  font-size: var(--cover-author-size, 9.5px);
  font-weight: 800;
  letter-spacing: 0.12em; text-transform: uppercase;
  opacity: 0.85;
}
.cover-emblem { flex: 1; display: grid; place-items: center; padding: 6% 0; }
.cover-emblem svg { width: 58%; height: auto; opacity: 0.95; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.2)); }
.cover-frame {
  position: absolute; inset: 7% 6% 6% 12%; z-index: -1;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
}
.cover-ribbon {
  position: absolute; top: 0; right: 12%; z-index: 2;
  width: 18%; min-width: 18px; height: 24%;
  background: var(--gold);
  clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 80%, 0 100%);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  display: grid; place-items: start center; padding-top: 10%;
  color: var(--plum-deep); font-weight: 900; font-size: 11px;
}

/* ---------- Shelf ---------- */

.shelf-section { margin-top: 30px; }
.shelf-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.shelf-head h2 { font-size: 22px; }
.shelf {
  position: relative;
  display: flex; align-items: flex-end; gap: clamp(14px, 2.5vw, 28px);
  padding: 22px clamp(12px, 2vw, 22px) 0;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}
.shelf::after { content: ''; flex: 0 0 4px; }
.shelf-board {
  height: 18px; margin-top: -2px;
  border-radius: 4px 4px 10px 10px;
  background: linear-gradient(180deg, var(--wood-light) 0, var(--wood) 35%, var(--wood-dark) 100%);
  box-shadow: 0 10px 16px rgba(95, 60, 39, 0.28), inset 0 2px 0 rgba(255, 255, 255, 0.2);
  position: relative;
}
.shelf-board::before {
  content: ''; position: absolute; left: 0; right: 0; top: -6px; height: 8px;
  background: linear-gradient(180deg, transparent, rgba(95, 60, 39, 0.18));
}
.shelf-item {
  flex: 0 0 auto;
  width: clamp(112px, 15vw, 150px);
  scroll-snap-align: start;
  text-decoration: none; color: inherit;
  display: flex; flex-direction: column; gap: 8px;
  padding-bottom: 10px;
  position: relative;
  transition: transform 0.18s ease;
  background: none; border: none; cursor: pointer; text-align: left; padding-left: 0; padding-right: 0;
}
.shelf-item:hover { transform: translateY(-6px) rotate(-0.6deg); }
.shelf-item .cover { width: 100%; }
.shelf-meta { padding: 0 2px; min-height: 0; }
.shelf-meta .t { font-weight: 800; font-size: 13.5px; line-height: 1.2; color: var(--ink); }
.shelf-meta .s { font-size: 12px; color: var(--ink-soft); }

/* Series box set: stacked covers */
.boxset { position: relative; isolation: isolate; }
.boxset .cover:not(:first-of-type) { position: absolute; inset: 0; }
.boxset .cover:nth-of-type(2) { transform: translate(10px, -8px) rotate(3deg); z-index: -1; filter: brightness(0.9); }
.boxset .cover:nth-of-type(3) { transform: translate(18px, -14px) rotate(6deg); z-index: -2; filter: brightness(0.8); }
.boxset-count {
  position: absolute; left: -8px; top: -10px; z-index: 3;
  background: var(--gold); color: var(--plum-deep);
  font-size: 11.5px; font-weight: 900; border-radius: 999px; padding: 4px 9px;
  box-shadow: var(--shadow-sm);
}
.edition-count {
  position: absolute; right: -8px; bottom: 54px; z-index: 3;
  background: var(--plum); color: #fff;
  font-size: 11.5px; font-weight: 900; border-radius: 999px; padding: 4px 9px;
  box-shadow: var(--shadow-sm);
  display: inline-flex; align-items: center; gap: 4px;
}
.status-pill {
  position: absolute; left: 6px; right: 6px; top: 6px; z-index: 3;
  background: rgba(255, 255, 255, 0.92); color: var(--plum);
  font-size: 11px; font-weight: 900; border-radius: 999px; padding: 4px 8px;
  display: flex; align-items: center; gap: 6px; justify-content: center;
  box-shadow: var(--shadow-sm);
}
.progress-bar { height: 6px; border-radius: 999px; background: rgba(43, 33, 64, 0.1); overflow: hidden; }
.progress-bar > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--lavender), var(--plum)); }
.progress-bar.gold > i { background: linear-gradient(90deg, var(--gold-soft), var(--gold)); }
.progress-bar.ruby > i { background: linear-gradient(90deg, var(--rose), var(--ruby)); }

/* ---------- Library toolbar ---------- */

.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  padding: 10px; border-radius: var(--r-lg);
  background: rgba(255, 253, 247, 0.75);
  box-shadow: inset 0 0 0 1px var(--line);
}
.search {
  flex: 1 1 220px; display: flex; align-items: center; gap: 8px;
  background: #fff; border-radius: 999px; padding: 0 14px;
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
  min-height: 44px;
}
.search input { border: none; outline: none; font: inherit; flex: 1; background: transparent; min-width: 0; }
.search:focus-within { box-shadow: inset 0 0 0 2px var(--plum); }

.popover {
  position: absolute; z-index: 60; top: calc(100% + 8px); right: 0;
  width: min(340px, calc(100vw - 32px));
  background: var(--paper); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--line);
  padding: 18px;
}
.popover h4 { font-family: var(--font-ui); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-faint); margin-bottom: 8px; }

/* ---------- List view ---------- */

.list-table { width: 100%; border-collapse: separate; border-spacing: 0 8px; }
.list-row { background: var(--paper); box-shadow: var(--shadow-sm); border-radius: var(--r-md); }
.list-row td { padding: 10px 14px; vertical-align: middle; }
.list-row td:first-child { border-radius: var(--r-md) 0 0 var(--r-md); }
.list-row td:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; }

/* ---------- Modal ---------- */

.scrim {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(30, 20, 50, 0.45);
  backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 16px;
  animation: fadein 0.15s ease;
}
@keyframes fadein { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(12px) scale(0.98); } }
.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 32px); overflow: auto;
  background: var(--paper); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: 26px;
  animation: rise 0.2s ease;
}
.modal-wide { width: min(820px, 100%); }

/* ---------- Toast ---------- */

.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%);
  z-index: 120;
  display: flex; align-items: center; gap: 12px;
  background: var(--plum-deep); color: #fff;
  padding: 10px 18px 10px 10px; border-radius: 999px;
  box-shadow: var(--shadow-lg);
  font-weight: 700;
  animation: rise 0.25s ease;
  max-width: calc(100vw - 32px);
}

/* ---------- Tabs ---------- */

.tabs { display: flex; gap: 4px; border-bottom: 1.5px solid var(--line); overflow-x: auto; }
.tabs button, .tabs a {
  border: none; background: none; cursor: pointer; text-decoration: none;
  padding: 12px 14px; font-weight: 800; color: var(--ink-soft);
  border-bottom: 3px solid transparent; margin-bottom: -1.5px;
  white-space: nowrap;
}
.tabs button.on, .tabs a.on { color: var(--plum); border-bottom-color: var(--plum); }

/* ---------- Grids ---------- */

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------- Sparkle decoration ---------- */

.sparkles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.sparkles i {
  position: absolute; width: 10px; height: 10px;
  background: radial-gradient(circle, var(--gold) 0 30%, transparent 32%);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: twinkle 2.4s ease-in-out infinite;
}

.feather-float { position: absolute; animation: floaty 4s ease-in infinite; opacity: 0; }

/* ---------- Prototype ribbon ---------- */

.proto-note {
  display: flex; gap: 10px; align-items: flex-start;
  background: repeating-linear-gradient(-45deg, #fff7df, #fff7df 10px, #fdf0cc 10px, #fdf0cc 20px);
  border: 1.5px dashed var(--gold);
  border-radius: var(--r-md);
  padding: 10px 14px; font-size: 13.5px; color: var(--gold-deep); font-weight: 700;
}

/* ---------- Select (themed dropdown; the app never uses a native <select>) ---------- */

.fb-select { position: relative; min-width: 0; }
.fb-select-button {
  width: 100%; min-height: 44px; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: var(--r-md); cursor: pointer; text-align: left;
  background: #fff; border: 1.5px solid var(--line-strong); color: var(--ink); font: inherit; font-weight: 700;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.fb-select-button:hover { border-color: var(--lavender); }
.fb-select-button:focus-visible, .fb-select.open .fb-select-button { outline: none; border-color: var(--plum); box-shadow: 0 0 0 4px rgba(75, 46, 131, 0.14); }
.fb-select-value { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.fb-select-chevron { flex: none; color: var(--plum); transition: transform 0.2s; }
.fb-select.open .fb-select-chevron { transform: rotate(180deg); }
.fb-select-list {
  position: absolute; z-index: 70; left: 0; top: calc(100% + 6px);
  width: max(100%, min(340px, calc(100vw - 32px)));
  max-height: 300px; overflow: auto; margin: 0; padding: 6px; list-style: none;
  background: var(--paper); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--line);
  animation: rise 0.14s ease;
}
.fb-select-list.above { top: auto; bottom: calc(100% + 6px); }
.fb-select-option { display: flex; align-items: flex-start; gap: 8px; padding: 9px 10px; border-radius: 12px; cursor: pointer; font-weight: 700; }
.fb-select-option.active { background: var(--plum-soft); }
.fb-select-option.selected { color: var(--plum); }
.fb-select-option[aria-disabled='true'] { opacity: 0.45; cursor: not-allowed; }
.fb-select-check { width: 18px; flex: none; padding-top: 2px; color: var(--plum); }
.fb-select-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.fb-select-text > .row > span:first-child { white-space: nowrap; }

/* ==========================================================================
   Screen styles
   ========================================================================== */

.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link-btn { background: none; border: none; padding: 0; color: var(--plum); font-weight: 800; text-decoration: underline; cursor: pointer; }
.btn.pressed { box-shadow: inset 0 0 0 2px var(--plum); }
.inline-icon { display: inline-block; vertical-align: -2px; color: var(--ruby); }
@media (max-width: 640px) { .hide-sm { display: none !important; } }

/* ---------- Library ---------- */

.lib-hero { display: flex; gap: 24px; align-items: flex-end; flex-wrap: wrap; padding-top: 8px; }
.lib-hero-guide { flex: 0 1 460px; }
.attention { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-top: 22px; }
.attention-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--paper); border-radius: var(--r-lg); padding: 12px 14px;
  box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line);
  text-decoration: none; color: inherit;
  transition: transform 0.15s, box-shadow 0.15s;
}
.attention-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md), inset 0 0 0 1px var(--line); }
.attention-card .t { font-weight: 800; line-height: 1.2; }
.attention-card .s { font-size: 13px; color: var(--ink-soft); }
.mini-cover, .list-cover { width: 44px; flex: none; }
.mini-cover .cover-title, .mini-cover .cover-author, .list-cover .cover-title, .list-cover .cover-author { display: none; }

/* Keep reading: a "now reading" hero beside a queue of other books and running adaptations. */
.now-reading { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; margin-top: 26px; align-items: stretch; }
.now-reading.solo { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 820px) { .now-reading { grid-template-columns: minmax(0, 1fr); } }
.now-reading .eyebrow { font-size: 12px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.now-hero {
  position: relative; overflow: hidden; display: flex; gap: 24px; align-items: center;
  padding: 24px 26px; border-radius: var(--r-lg); color: var(--parchment); text-decoration: none;
  background: radial-gradient(420px 240px at 88% 0%, rgba(185, 165, 227, 0.35), transparent 70%), linear-gradient(140deg, var(--plum), var(--plum-deep));
  box-shadow: var(--shadow-md); transition: transform 0.15s, box-shadow 0.15s;
}
.now-hero:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.now-hero:hover .now-cta { filter: brightness(1.05); }
.now-cover { width: 112px; flex: none; transform: rotate(-3deg); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); }
.now-reading.solo .now-cover { width: 120px; }
.now-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.now-body .eyebrow { color: var(--gold-soft); }
.now-body h2 { color: var(--parchment); font-size: clamp(22px, 2.6vw, 28px); line-height: 1.15; }
.now-sub { font-size: 14px; color: rgba(251, 244, 228, 0.78); }
.now-body .progress-bar { background: rgba(255, 255, 255, 0.16); margin-top: 4px; }
.now-reading.solo .now-body .progress-bar { max-width: 420px; }
.now-line { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; color: rgba(251, 244, 228, 0.8); font-variant-numeric: tabular-nums; }
.now-reading.solo .now-line { max-width: 420px; }
.now-cta { align-self: flex-start; margin-top: 6px; }
.now-spark { position: absolute; color: var(--gold-soft); opacity: 0.5; }
@media (max-width: 520px) {
  .now-hero { gap: 16px; padding: 18px; align-items: flex-start; }
  .now-cover, .now-reading.solo .now-cover { width: 76px; margin-top: 4px; }
  .now-body h2 { font-size: 20px; }
  .now-sub { font-size: 13px; }
  .now-spark { display: none; }
  .now-cover .cover-title, .now-cover .cover-author { display: none; }
}
.now-queue {
  display: flex; flex-direction: column; padding: 14px 8px 8px; border-radius: var(--r-lg);
  background: #fff; box-shadow: var(--shadow-md), inset 0 0 0 1px var(--line);
}
.now-queue .eyebrow { color: var(--plum); padding: 0 12px 6px; }
.now-row { display: flex; gap: 14px; align-items: center; padding: 10px 12px; border-radius: var(--r-md); text-decoration: none; color: inherit; transition: background 0.15s; }
.now-row + .now-row { box-shadow: 0 -1px 0 var(--line); }
.now-row:hover { background: var(--plum-soft); box-shadow: none; }
.now-row:hover + .now-row { box-shadow: none; }
.now-row-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.now-row .t { font-weight: 800; line-height: 1.2; }
.now-row .s { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.progress-bar.working > i { position: relative; overflow: hidden; }
.progress-bar.working > i::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent); animation: shimmer 1.8s ease-in-out infinite; }
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .progress-bar.working > i::after { animation: none; } }

/* ---------- Series ---------- */

.series-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin: 10px 0 24px; }
.series-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.series-book { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.series-cover { width: 92px; flex: none; }
.series-actions { flex: none; }
@media (max-width: 640px) { .series-book { align-items: flex-start; } .series-cover { width: 72px; } }

/* ---------- Book page ---------- */

.book-hero { display: grid; grid-template-columns: 220px 1fr; gap: 36px; align-items: start; margin-top: 14px; }
.book-hero-cover { position: relative; }
.book-hero-cover::after { content: ''; position: absolute; left: 10%; right: 10%; bottom: -14px; height: 20px; background: radial-gradient(closest-side, rgba(46, 27, 85, 0.25), transparent); }
@media (max-width: 700px) {
  .book-hero { grid-template-columns: 1fr; gap: 20px; }
  .book-hero-cover { width: 160px; margin: 0 auto; }
}

.edition-card { display: flex; flex-direction: column; gap: 18px; }
.edition-head { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.edition-cover { width: 64px; flex: none; }
.edition-cover .cover-title, .edition-cover .cover-author { display: none; }
.edition-cover .cover-emblem svg { width: 70%; }
.edition-primary { display: flex; gap: 8px; flex-wrap: wrap; }
.settings-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 860px) { .settings-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.setting { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: var(--r-md); background: rgba(75, 46, 131, 0.045); }
.note-box { background: #fffaf0; border-left: 4px solid var(--gold); border-radius: 6px var(--r-md) var(--r-md) 6px; padding: 12px 16px; display: flex; flex-direction: column; gap: 6px; }
.note-box p, .note-box ul { font-size: 14.5px; margin: 0; }
.note-box ul { padding-left: 18px; }
.edition-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 14px; border-top: 1px solid var(--line); }
.details { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px 24px; margin: 0; }
.details dt { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); }
.details dd { margin: 2px 0 0; font-weight: 700; }
.edit-book-grid { display: grid; grid-template-columns: 160px 1fr; gap: 24px; }
@media (max-width: 640px) { .edit-book-grid { grid-template-columns: 1fr; } }

/* ---------- Content heatmap ---------- */

.heatmap { display: flex; flex-direction: column; gap: 6px; }
.heatmap-legend { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin-bottom: 6px; }
.heat-swatch { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.heat-row { display: grid; grid-template-columns: 190px 1fr 170px; gap: 14px; align-items: center; }
.heat-label { display: flex; gap: 8px; align-items: center; font-weight: 700; font-size: 14px; }
.heat-cells { display: flex; gap: 2px; height: 22px; }
.heat-cells i { flex: 1; border-radius: 4px; min-width: 3px; }
.heat-sum { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 760px) {
  .heat-row { grid-template-columns: 1fr auto; gap: 4px 10px; }
  .heat-cells { grid-column: 1 / -1; grid-row: 2; height: 16px; }
}

/* ---------- Add a book ---------- */

.dropzone {
  border: 3px dashed var(--lavender); border-radius: var(--r-xl);
  background: linear-gradient(180deg, rgba(255, 253, 247, 0.9), rgba(236, 228, 248, 0.5));
  padding: 48px 24px; text-align: center; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}
.dropzone:hover, .dropzone.over { border-color: var(--plum); background: linear-gradient(180deg, #fff, #ece4f8); }
.dropzone.over { transform: scale(1.01); }
.steps-list { list-style: none; padding: 0; margin: 10px 0 0; text-align: left; display: flex; flex-direction: column; gap: 10px; }
.steps-list li { display: flex; align-items: center; gap: 10px; color: var(--ink-faint); font-weight: 700; }
.steps-list li.done { color: var(--emerald); }
.steps-list li.now { color: var(--plum); }
.step-dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid currentColor; display: grid; place-items: center; flex: none; }
.steps-list li.done .step-dot { background: var(--emerald); border-color: var(--emerald); color: #fff; }
.steps-list li.now .step-dot { border-top-color: transparent; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tips { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-size: 14.5px; }
.review-grid { display: grid; grid-template-columns: 170px 1fr; gap: 28px; }
@media (max-width: 640px) { .review-grid { grid-template-columns: 1fr; } }
.series-choices, .look-list { display: flex; flex-direction: column; gap: 10px; }
.choice {
  display: flex; align-items: center; gap: 14px; cursor: pointer;
  padding: 14px 16px; border-radius: var(--r-md); background: #fff;
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
  transition: box-shadow 0.15s, background 0.15s;
}
.choice:hover { box-shadow: inset 0 0 0 1.5px var(--plum); }
.choice.on { box-shadow: inset 0 0 0 2.5px var(--plum); background: #faf7ff; }
.choice input[type='radio'] { accent-color: var(--plum); width: 18px; height: 18px; flex: none; }
.input-xs { width: 56px; min-height: 32px; padding: 4px 8px; text-align: center; }
.chapter-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.chapter-list li { display: flex; align-items: center; gap: 12px; padding: 6px 8px; border-radius: 10px; }
.chapter-list li:hover { background: rgba(75, 46, 131, 0.04); }
.chapter-list li.excluded .input-plain { color: var(--ink-faint); text-decoration: line-through; }
.input-plain { flex: 1; border: none; background: transparent; font: inherit; font-weight: 700; padding: 6px 8px; border-radius: 8px; min-width: 0; color: var(--ink); }
.input-plain:focus { outline: none; background: #fff; box-shadow: inset 0 0 0 1.5px var(--plum); }
.sticky-actions {
  position: sticky; bottom: 16px; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 253, 247, 0.94); backdrop-filter: blur(10px);
  padding: 12px; border-radius: 999px; box-shadow: var(--shadow-lg);
}
@media (max-width: 760px) { .sticky-actions { bottom: 84px; } }

/* ---------- Wizard ---------- */

.wizard-top { display: flex; align-items: center; gap: 16px; justify-content: space-between; margin-bottom: 14px; }
.wizard-grid { display: grid; grid-template-columns: 230px 1fr; gap: 28px; align-items: start; }
.stepper { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 4px; }
.step {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: none; border: none; cursor: pointer; padding: 10px 12px; border-radius: 14px;
  font-weight: 800; color: var(--ink-faint);
}
.step:hover { background: rgba(75, 46, 131, 0.06); }
.step.now { background: var(--paper); color: var(--plum); box-shadow: var(--shadow-sm); }
.step.done { color: var(--ink-soft); }
.step-num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; flex: none; background: rgba(43, 33, 64, 0.08); font-size: 13px; }
.step.now .step-num { background: var(--plum); color: #fff; }
.step.done .step-num { background: var(--emerald); color: #fff; }
.wizard-main { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.wizard-guide { max-width: 640px; }
.wizard-nav {
  position: sticky; bottom: 16px; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 253, 247, 0.94); backdrop-filter: blur(10px);
  padding: 10px; border-radius: 999px; box-shadow: var(--shadow-lg);
}
@media (max-width: 900px) {
  .wizard-grid { grid-template-columns: 1fr; gap: 14px; }
  .stepper { position: static; flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .step { flex: none; padding: 6px 10px; }
  .step:not(.now) .step-title { display: none; }
  .stepper .card { display: none; }
}
@media (max-width: 760px) { .wizard-nav { bottom: 84px; } .wizard-card.card-lg { padding: 20px; } }

.age-picker { display: flex; align-items: center; gap: 24px; }
.age-big {
  width: 104px; height: 104px; border-radius: 50%; flex: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: radial-gradient(circle at 35% 30%, #8b63d1, var(--plum-deep));
  color: #fff; box-shadow: var(--shadow-md), inset 0 -4px 0 rgba(0, 0, 0, 0.2);
}
.age-big span { font-family: var(--font-display); font-size: 46px; font-weight: 800; line-height: 1; font-variation-settings: 'SOFT' 100; }
.age-big small { font-size: 11px; font-weight: 800; opacity: 0.8; }
.band-strip { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 8px; }
.band { font-size: 12px; font-weight: 800; padding: 5px 10px; border-radius: 999px; background: rgba(43, 33, 64, 0.05); color: var(--ink-faint); }
.band.on { background: var(--gold-soft); color: var(--gold-deep); box-shadow: inset 0 0 0 1.5px var(--gold); }
.mode-card {
  position: relative; text-align: left; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px;
  padding: 18px; border-radius: var(--r-lg); border: none; background: #fff;
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
  transition: box-shadow 0.15s, transform 0.15s;
}
.mode-card:hover { transform: translateY(-2px); }
.mode-card.on { box-shadow: inset 0 0 0 3px var(--plum), var(--shadow-md); background: #faf7ff; }
.mode-icon { font-size: 30px; }
.mode-check { position: absolute; top: 12px; right: 12px; width: 26px; height: 26px; border-radius: 50%; background: var(--plum); color: #fff; display: grid; place-items: center; }

.inside-summary { background: #fff8ea; border-radius: var(--r-md); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }

.filter-rows { display: flex; flex-direction: column; gap: 8px; }
.filter-row { display: flex; align-items: center; gap: 16px; padding: 12px 14px; border-radius: var(--r-md); background: #fff; box-shadow: inset 0 0 0 1px var(--line); flex-wrap: wrap; }
.filter-row.quiet { background: rgba(255, 255, 255, 0.5); }
.filter-row.quiet .filter-info { opacity: 0.7; }
.filter-info { display: flex; gap: 12px; align-items: flex-start; flex: 1 1 260px; min-width: 0; }
.filter-icon { font-size: 22px; width: 32px; text-align: center; flex: none; }
.filter-control { flex: none; }
.default-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--lavender); margin-left: 4px; vertical-align: middle; }
.faith-example { margin-top: 6px; padding: 12px 16px; border-radius: var(--r-md); background: #fffaf0; border-left: 4px solid var(--lavender); }
.faith-example p { font-family: var(--font-read); font-size: 16px; margin-top: 4px; }
.toggle-row { display: flex; align-items: center; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.toggle-row:last-child { border-bottom: none; }
.picture-toggle { display: flex; align-items: center; gap: 16px; padding: 18px; border-radius: var(--r-lg); background: linear-gradient(135deg, #fff8e6, #f3ecfb); box-shadow: inset 0 0 0 1px var(--line); }
.style-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 640px) { .style-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.style-card {
  display: flex; flex-direction: column; gap: 4px; text-align: left; cursor: pointer;
  padding: 10px; border-radius: var(--r-md); border: none; background: #fff;
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
}
.style-card.on { box-shadow: inset 0 0 0 3px var(--plum); background: #faf7ff; }
.style-swatch { height: 44px; border-radius: 10px; margin-bottom: 4px; }
.review-summary { display: flex; flex-direction: column; border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.sum-item { display: grid; grid-template-columns: 130px 1fr auto; gap: 12px; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.sum-item:last-child { border-bottom: none; }
@media (max-width: 640px) { .sum-item { grid-template-columns: 1fr auto; } .sum-item > span:nth-child(2) { grid-column: 1; } }
.estimate { display: flex; flex-direction: column; gap: 14px; padding: 20px; border-radius: var(--r-lg); background: linear-gradient(135deg, #fffaf0, #f5efe0); box-shadow: inset 0 0 0 1.5px var(--gold-soft); }
.est-total { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.est-total strong { font-family: var(--font-display); font-size: 34px; color: var(--plum-deep); line-height: 1.1; }
.est-lines { display: flex; flex-direction: column; gap: 6px; font-size: 14.5px; }
.est-lines div { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 6px; border-bottom: 1px dashed var(--line-strong); }
.money-input { display: inline-flex; align-items: center; background: #fff; border: 1.5px solid var(--line-strong); border-radius: var(--r-md); padding: 0 12px; min-height: 44px; }
.money-input span { font-weight: 800; color: var(--ink-soft); }
.money-input input { border: none; outline: none; font: inherit; font-weight: 800; width: 80px; padding: 8px 4px; background: transparent; }
.money-input:focus-within { border-color: var(--plum); box-shadow: 0 0 0 4px rgba(75, 46, 131, 0.14); }

/* ---------- Sample review ---------- */

.sample-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin: 22px 0 14px; }
.sample-tabs { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sample-tabs [role='tab'] {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  border: none; cursor: pointer; padding: 10px 16px; border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.6); box-shadow: inset 0 0 0 1.5px var(--line-strong); font-weight: 800; color: var(--ink-soft);
}
.sample-tabs [role='tab'].on { background: var(--plum); color: #fff; box-shadow: var(--shadow-md); }
.sample-grid { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }
@media (max-width: 1080px) { .sample-grid { grid-template-columns: 1fr; } }
.sample-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 84px; }
@media (max-width: 1080px) { .sample-side { position: static; } }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 0; background: var(--paper); border-radius: var(--r-lg); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line); overflow: hidden; }
.compare.original, .compare.softened { grid-template-columns: 1fr; }
@media (max-width: 760px) { .compare.side { grid-template-columns: 1fr; } }
.compare-col { padding: 22px 26px; min-width: 0; }
.compare-col.original { background: #faf6ee; }
.compare.side .compare-col.original { border-right: 1px solid var(--line); }
.compare-col.softened { background: #fffdf9; }
.compare-head { margin-bottom: 10px; }
.prose { font-family: var(--font-read); font-size: 16.5px; line-height: 1.65; color: #2f2638; }
.prose p { margin: 0 0 0.9em; }
.compare-col.original .prose, .compare-col.original.prose { color: #5b5166; }
.prose mark { background: #fde9a6; border-radius: 3px; padding: 0 2px; box-shadow: 0 2px 0 var(--gold); }
.change-notes, .comment-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.change-notes li { display: flex; gap: 10px; align-items: flex-start; }
.change-notes .chip { flex: none; margin-top: 2px; }
.comment-list li { padding: 10px 12px; border-radius: var(--r-md); background: #fffaf0; display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
blockquote { margin: 0; font-family: var(--font-read); font-style: italic; color: var(--ink-soft); font-size: 14px; }
.comment-pop {
  position: absolute; z-index: 90; width: 320px;
  background: var(--paper); border-radius: var(--r-lg); padding: 14px;
  box-shadow: var(--shadow-lg), inset 0 0 0 1px var(--line);
  display: flex; flex-direction: column; gap: 10px; animation: rise 0.15s ease;
}
.progress-bar .indeterminate { width: 40% !important; animation: slide 1.2s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(260%); } }

/* ---------- Run progress ---------- */

.celebrate { position: relative; overflow: hidden; }
.version-hero { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 20px; border-radius: var(--r-lg); background: #faf7ff; max-width: 480px; }
.chapter-dots { display: flex; flex-wrap: wrap; gap: 4px; }
.chapter-dots i { width: 16px; height: 16px; border-radius: 5px; background: rgba(43, 33, 64, 0.08); }
.chapter-dots i.done { background: linear-gradient(180deg, #8b63d1, var(--plum)); }
.chapter-dots i.now { background: var(--gold); animation: twinkle 1.2s ease-in-out infinite; }
.cost-meter { display: flex; flex-direction: column; gap: 6px; }
.meter { position: relative; height: 14px; border-radius: 999px; background: rgba(43, 33, 64, 0.08); }
.meter i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: inherit; background: linear-gradient(90deg, var(--emerald-soft), var(--emerald)); transition: width 0.4s; }
.meter i.over { background: linear-gradient(90deg, var(--rose), var(--ruby)); }
.meter b { position: absolute; top: -4px; bottom: -4px; width: 3px; border-radius: 2px; background: var(--plum-deep); }

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

.reader {
  --r-bg: #fffdf9; --r-ink: #231d2e; --r-soft: #6d6479; --r-bar: rgba(255, 253, 249, 0.92); --r-line: rgba(35, 29, 46, 0.1);
  position: fixed; inset: 0; z-index: 30;
  display: flex; flex-direction: column;
  background: var(--r-bg); color: var(--r-ink);
}
.reader.theme-parchment {
  --r-bg: #f5ead2; --r-ink: #3a2c1e; --r-soft: #7c6a54; --r-bar: rgba(245, 234, 210, 0.94); --r-line: rgba(58, 44, 30, 0.12);
  background-image: radial-gradient(ellipse at 50% 0%, rgba(255, 255, 255, 0.5), transparent 70%), radial-gradient(ellipse at 50% 120%, rgba(160, 120, 70, 0.18), transparent 60%);
}
.reader.theme-night { --r-bg: #16121e; --r-ink: #e8e0d2; --r-soft: #a39bb3; --r-bar: rgba(22, 18, 30, 0.92); --r-line: rgba(232, 224, 210, 0.12); color-scheme: dark; }
.reader .btn-ghost { color: var(--r-ink); }
.reader .btn-ghost:hover, .reader .btn-ghost.on { background: color-mix(in srgb, var(--r-ink) 10%, transparent); }
.reader-bar, .reader-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 8px max(12px, env(safe-area-inset-left)) 8px max(12px, env(safe-area-inset-right));
  background: var(--r-bar); border-bottom: 1px solid var(--r-line);
  transition: opacity 0.25s, transform 0.25s; z-index: 2;
}
.reader-bar { padding-top: max(8px, env(safe-area-inset-top)); }
.reader-foot { border-bottom: none; border-top: 1px solid var(--r-line); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.reader.immersive .reader-bar { opacity: 0; transform: translateY(-100%); pointer-events: none; }
.reader.immersive .reader-foot { opacity: 0; transform: translateY(100%); pointer-events: none; }
.reader-title { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; }
.reader-title strong { font-family: var(--font-display); font-size: 16px; max-width: 100%; }
.reader-title span { color: var(--r-soft); max-width: 100%; }
.lock-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 800; padding: 6px 12px; border-radius: 999px; background: var(--gold-soft); color: var(--gold-deep); }
.reader-note { text-align: center; font-size: 13px; padding: 6px 12px; background: color-mix(in srgb, var(--gold) 18%, transparent); color: var(--r-ink); }
.reader-note a { color: inherit; font-weight: 800; }

.pager { position: relative; flex: 1; min-height: 0; overflow: hidden; margin: clamp(18px, 4vh, 44px) clamp(20px, 7vw, 120px); touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: default; }
.flow { height: 100%; column-fill: auto; transition: transform 0.38s cubic-bezier(0.2, 0.7, 0.2, 1); will-change: transform; }
.flow p { margin: 0 0 0.85em; text-align: justify; hyphens: auto; -webkit-hyphens: auto; orphans: 2; widows: 2; }
.para-wrap { display: contents; }
.dropcap::first-letter { float: left; font-family: var(--font-display); font-size: 3.4em; line-height: 0.85; padding: 0.06em 0.08em 0 0; color: var(--plum); font-weight: 700; }
.theme-night .dropcap::first-letter { color: var(--lavender); }
.chapter-head { text-align: center; padding: 0.6em 0 1.2em; break-inside: avoid; }
.chapter-num { font-family: var(--font-ui); font-size: 0.6em; font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase; color: var(--r-soft); }
.chapter-head h1 { font-family: var(--font-display); font-size: 1.7em; color: inherit; margin: 0.2em 0 0.1em; font-variation-settings: 'SOFT' 100, 'WONK' 1; }
.chapter-orig { font-style: italic; font-size: 0.75em; color: var(--r-soft); }
.chapter-flourish { color: var(--gold); letter-spacing: 0.4em; margin-top: 0.4em; font-size: 0.8em; }
.recap { display: flex; gap: 10px; align-items: flex-start; padding: 0.8em 1em; margin-bottom: 1.2em; border-radius: 14px; background: color-mix(in srgb, var(--lavender) 22%, transparent); break-inside: avoid; font-size: 0.82em; font-family: var(--font-ui); line-height: 1.5; }
.recap p { margin: 0 !important; text-align: left !important; }
.recap .tuft { flex: none; }
@media (max-width: 600px) { .flow p { text-align: left; } }
.illus { margin: 0.4em 0 1.2em; break-inside: avoid; cursor: zoom-in; text-align: center; }
.illus .illus-img { display: block; max-width: 100%; max-height: 48vh; margin: 0 auto; border-radius: 6px; mix-blend-mode: multiply; }
.theme-night .illus .illus-img { mix-blend-mode: normal; border-radius: 10px; }
.illus-todo { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 1.2em 1em; border-radius: 14px; border: 2px dashed var(--lavender); background: color-mix(in srgb, var(--lavender) 14%, transparent); font-family: var(--font-ui); font-size: 0.72em; line-height: 1.45; text-align: center; max-height: 48vh; }
.illus-todo strong { color: var(--plum); }
.illus figcaption { font-size: 0.72em; font-style: italic; color: var(--r-soft); margin-top: 0.5em; line-height: 1.4; }
.end-note { break-inside: avoid; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 1.4em 0; color: var(--r-soft); font-family: var(--font-ui); font-size: 0.8em; }
.reader-progress { flex: 1; display: flex; flex-direction: column; gap: 6px; align-items: center; min-width: 0; color: var(--r-soft); }
.chapter-track { position: relative; width: 100%; max-width: 560px; height: 6px; border-radius: 999px; background: var(--r-line); }
.chapter-track i { position: absolute; top: -2px; width: 2px; height: 10px; border-radius: 1px; background: color-mix(in srgb, var(--r-ink) 22%, transparent); }
.chapter-track b { position: absolute; left: 0; top: 0; bottom: 0; border-radius: inherit; background: linear-gradient(90deg, var(--gold-soft), var(--gold)); }
.compare-reader { flex: 1; min-height: 0; overflow: auto; display: grid; grid-template-columns: 1fr 1fr; }
.compare-reader .compare-col { padding: 28px clamp(20px, 4vw, 56px); }
.theme-night .compare-reader .compare-col.original { background: #1d1828; }
.theme-night .compare-reader .compare-col.softened { background: #16121e; }
.theme-night .prose, .theme-night .compare-col.original .prose { color: var(--r-ink); }
.chapter-cheer {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 50;
  background: var(--paper); color: var(--plum-deep); padding: 22px 30px; border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column; align-items: center; gap: 6px;
  animation: rise 0.25s ease; font-family: var(--font-display); font-size: 20px;
}
.illus-zoom { margin: 0; max-width: min(900px, 100%); display: flex; flex-direction: column; gap: 10px; align-items: center; color: #fff; }
.illus-zoom .illus-img { max-width: 100%; max-height: 78vh; border-radius: 10px; background: #fff; }
.illus-zoom .illus-todo { background: var(--paper); color: var(--ink); font-size: 16px; }
.illus-zoom figcaption { font-family: var(--font-read); font-style: italic; font-size: 18px; text-align: center; }
.toc { list-style: none; padding: 0; margin: 0; max-height: 60vh; overflow: auto; }
.toc-item { width: 100%; display: flex; gap: 12px; align-items: center; text-align: left; padding: 10px 12px; border: none; background: none; border-radius: 10px; cursor: pointer; font-weight: 700; color: var(--ink); }
.toc-item:hover:not(:disabled) { background: var(--plum-soft); }
.toc-item.on { background: var(--plum); color: #fff; }
.toc-item.on .faint { color: rgba(255, 255, 255, 0.7); }
.toc-item:disabled { color: var(--ink-faint); cursor: default; }
.font-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.font-card { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; border-radius: var(--r-md); border: none; background: #fff; box-shadow: inset 0 0 0 1.5px var(--line-strong); cursor: pointer; }
.font-card.on { box-shadow: inset 0 0 0 3px var(--plum); background: #faf7ff; }
.theme-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-swatch { padding: 18px 8px; border-radius: var(--r-md); border: none; cursor: pointer; font-weight: 800; box-shadow: inset 0 0 0 1.5px var(--line-strong); }
.theme-swatch.day { background: #fffdf9; color: #231d2e; }
.theme-swatch.parchment { background: #f5ead2; color: #3a2c1e; }
.theme-swatch.night { background: #16121e; color: #e8e0d2; }
.theme-swatch.on { box-shadow: inset 0 0 0 3px var(--plum), 0 0 0 3px var(--gold-soft); }
.hold-unlock { position: relative; width: 48px; height: 48px; border: none; background: none; padding: 0; cursor: pointer; display: grid; place-items: center; touch-action: none; -webkit-touch-callout: none; user-select: none; }
.hold-unlock .tuft { position: relative; z-index: 1; }
.hold-ring { position: absolute; inset: 0; width: 48px; height: 48px; transform: rotate(-90deg); }
.hold-ring circle { fill: none; stroke: color-mix(in srgb, var(--r-ink) 12%, transparent); stroke-width: 3; }
.hold-ring circle.fill { stroke: var(--gold); stroke-dasharray: 132; stroke-linecap: round; }
.pin-dots { display: flex; gap: 14px; margin: 6px 0; }
.pin-dots i { width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--plum); }
.pin-dots i.on { background: var(--plum); }
.pin-dots.shake { animation: shake 0.4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.pin-pad { display: grid; grid-template-columns: repeat(3, 72px); gap: 10px; }
.pin-pad button { height: 60px; border-radius: 18px; border: none; background: var(--plum-soft); font-size: 22px; font-weight: 800; color: var(--plum-deep); cursor: pointer; display: grid; place-items: center; }
.pin-pad button:active { background: var(--lavender); }
.pin-pad .pin-cancel { font-size: 14px; background: transparent; }

/* ---------- Refine ---------- */

.chapter-pick { display: flex; flex-wrap: wrap; gap: 6px; max-height: 220px; overflow: auto; padding: 4px; }
.passage-pick { max-height: 340px; overflow: auto; padding: 10px; border-radius: var(--r-md); background: #fffdf9; box-shadow: inset 0 0 0 1px var(--line); }
.passage-pick p { padding: 8px 10px; border-radius: 10px; cursor: pointer; margin: 0 0 4px; }
.passage-pick p:hover { background: var(--plum-soft); }
.passage-pick p.picked { background: #fde9a6; box-shadow: inset 4px 0 0 var(--gold); }
.pic-pick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 640px) { .pic-pick { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pic-card { display: flex; flex-direction: column; gap: 6px; padding: 8px; border-radius: var(--r-md); background: #fff; box-shadow: inset 0 0 0 1.5px var(--line); }
.pic-card > button:first-child { border: none; padding: 0; background: none; cursor: pointer; border-radius: 10px; overflow: hidden; }
.pic-card .illus-img { width: 100%; height: 150px; object-fit: contain; background: #fff; }
.pic-card .illus-todo { height: 150px; font-size: 11px; justify-content: center; }
.pic-card.on { box-shadow: inset 0 0 0 3px var(--plum); }

/* ---------- History ---------- */

.timeline { list-style: none; padding: 0 0 0 28px; margin: 0; position: relative; display: flex; flex-direction: column; gap: 18px; }
.timeline::before { content: ''; position: absolute; left: 9px; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: linear-gradient(180deg, var(--lavender), var(--parchment-3)); }
.timeline li { position: relative; }
.tl-dot { position: absolute; left: -26px; top: 22px; width: 17px; height: 17px; border-radius: 50%; background: var(--paper); box-shadow: inset 0 0 0 3px var(--lavender); }
.timeline li.current .tl-dot { background: var(--plum); box-shadow: 0 0 0 4px var(--plum-soft); }
.timeline li.current .card { box-shadow: var(--shadow-md), inset 0 0 0 2px var(--plum); }
.guidance-quote { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; border-radius: var(--r-md); background: #fffaf0; border-left: 4px solid var(--gold); }
.diff-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 640px) { .diff-pair { grid-template-columns: 1fr; } }
.diff-old, .diff-new { font-family: var(--font-read); font-size: 15px; padding: 12px 14px; border-radius: var(--r-md); margin: 0; display: flex; flex-direction: column; gap: 4px; }
.diff-old { background: var(--ruby-soft); color: #5b2433; }
.diff-new { background: var(--emerald-soft); color: #1d4a3a; }
.diff-old .tiny, .diff-new .tiny { font-family: var(--font-ui); font-weight: 800; letter-spacing: 0.08em; opacity: 0.9; }

/* ---------- Settings ---------- */

.settings-layout { display: grid; grid-template-columns: 220px 1fr; gap: 28px; align-items: start; }
.settings-nav { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 84px; }
.settings-nav button { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 14px; border: none; background: none; text-align: left; font-weight: 800; color: var(--ink-soft); cursor: pointer; }
.settings-nav button:hover { background: rgba(75, 46, 131, 0.06); }
.settings-nav button.on { background: var(--paper); color: var(--plum); box-shadow: var(--shadow-sm); }
@media (max-width: 860px) {
  .settings-layout { grid-template-columns: 1fr; gap: 14px; }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; }
  .settings-nav button { flex: none; }
}
.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1000px) { .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { display: flex; flex-direction: column; gap: 4px; padding: 18px; }
.kpi.warn { box-shadow: var(--shadow-sm), inset 0 0 0 2px var(--rose); }
.kpi-value { font-family: var(--font-display); font-size: 32px; color: var(--plum-deep); line-height: 1.1; font-variation-settings: 'SOFT' 100; }
.legend { display: flex; gap: 14px; font-size: 13px; font-weight: 700; color: var(--ink-soft); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.bar-chart { position: relative; height: 240px; padding: 8px 0 26px 54px; }
.bar-grid { position: absolute; left: 54px; right: 0; top: 8px; bottom: 26px; }
.bar-grid div { position: absolute; left: 0; right: 0; border-top: 1px dashed var(--line); }
.bar-grid span { position: absolute; left: -54px; top: -9px; width: 46px; text-align: right; font-size: 11.5px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.bars { position: relative; height: 100%; display: flex; align-items: flex-end; gap: clamp(12px, 4vw, 48px); padding: 0 8px; }
.bar-col { position: relative; flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; outline: none; }
.bar-stack { width: min(56px, 100%); display: flex; flex-direction: column; gap: 2px; }
.bar-stack .seg { min-height: 2px; }
.bar-stack > :first-child { border-radius: 4px 4px 0 0; }
.bar-proj { border: 2px dashed var(--lavender); border-bottom: none; border-radius: 4px 4px 0 0; background: repeating-linear-gradient(135deg, transparent 0 5px, rgba(185, 165, 227, 0.25) 5px 8px); }
.bar-label { position: absolute; bottom: -24px; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }
.bar-col:hover .bar-stack, .bar-col:focus .bar-stack { filter: brightness(1.08); }
.chart-tip { position: absolute; bottom: calc(100% - 10px); left: 50%; transform: translateX(-50%); z-index: 5; min-width: 170px; background: var(--plum-deep); color: #fff; padding: 10px 12px; border-radius: 12px; font-size: 13px; box-shadow: var(--shadow-lg); pointer-events: none; display: flex; flex-direction: column; gap: 3px; }
.chart-tip i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; }
.tip-total { border-top: 1px solid rgba(255, 255, 255, 0.2); padding-top: 4px; margin-top: 2px; font-weight: 800; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-faint); padding: 8px 10px; border-bottom: 1.5px solid var(--line); }
.data-table td { padding: 10px; border-bottom: 1px solid var(--line); }
.data-table tr:last-child td { border-bottom: none; }
.data-table a { font-weight: 700; text-decoration: none; }
.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: 120px 1fr 64px; gap: 10px; align-items: center; }
.hbar-track { height: 14px; border-radius: 4px; background: rgba(43, 33, 64, 0.06); }
.hbar-track i { display: block; height: 100%; border-radius: 0 4px 4px 0; background: #6a46b0; }
.people { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.people li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-md); background: rgba(75, 46, 131, 0.04); }
.pin-input { font-size: 24px; letter-spacing: 0.5em; font-weight: 800; text-align: center; max-width: 180px; }

/* ---------- Sign-in gate ---------- */

.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.gate-card { position: relative; overflow: hidden; width: min(440px, 100%); background: var(--paper); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); padding: 40px 28px; display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; }
.gate-title { font-size: 42px; font-variation-settings: 'SOFT' 100, 'WONK' 1; }
.google-btn { display: inline-flex; align-items: center; gap: 12px; padding: 12px 22px; border-radius: 999px; background: #fff; color: #1f1f1f; font-weight: 800; text-decoration: none; box-shadow: inset 0 0 0 1.5px #dadce0, var(--shadow-sm); margin-top: 8px; min-height: 48px; }
.google-btn:hover { box-shadow: inset 0 0 0 1.5px #b0b4ba, var(--shadow-md); }

/* ---------- Meet Tuft ---------- */

.meet-hero { display: flex; align-items: center; gap: 32px; flex-wrap: wrap; padding: 20px 0; }
.pose-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-top: 12px; }
.pose-card { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.app-icon { background: linear-gradient(160deg, #6a46b0, var(--plum-deep)); display: grid; place-items: center; box-shadow: var(--shadow-md); overflow: hidden; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; }
.swatch { display: flex; gap: 10px; align-items: center; }
.swatch i { width: 40px; height: 40px; border-radius: 12px; box-shadow: inset 0 0 0 1px var(--line); flex: none; }

/* Image density picker (wizard → Pictures) */
.density-readout { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 8px; margin-top: 8px; }
.density-readout > div { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: var(--r-md, 12px); background: linear-gradient(135deg, #fffaf0, #f5efe0); box-shadow: inset 0 0 0 1.5px var(--gold-soft); }
.density-readout strong { font-family: var(--font-display); font-size: 22px; color: var(--plum-deep); line-height: 1.15; }
.density-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
.density-table th { text-align: left; font-size: 12px; color: var(--ink-faint); font-weight: 800; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.density-table td { padding: 6px 8px; border-bottom: 1px dashed var(--line); cursor: pointer; white-space: nowrap; }
.density-table tr.on td { background: rgba(106, 70, 176, 0.08); font-weight: 800; }
.density-table tr.on td:first-child { box-shadow: inset 3px 0 0 var(--plum); }
.density-table .linkish { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.density-table .cost-bar { display: inline-block; height: 8px; border-radius: 4px; background: var(--gold); margin-right: 8px; vertical-align: middle; }
@media (max-width: 560px) { .density-table .cost-bar { display: none; } }

/* Settings → AI models & keys */
.model-slot { display: grid; grid-template-columns: 120px 1fr; gap: 6px 14px; align-items: start; padding: 12px 0; border-top: 1px dashed var(--line); }
.model-slot:first-of-type { border-top: 0; }
.model-slot .slot-name { font-weight: 800; padding-top: 10px; }
.model-slot .slot-name small { display: block; font-weight: 600; color: var(--ink-faint); font-size: 12px; }
.model-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
/* One row per provider: name and hint on the left, the key (or a field to paste one) on the right. */
.key-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 14px 0; border-top: 1px dashed var(--line); }
.key-row:first-of-type { border-top: 0; }
.key-row .key-info { flex: 1 1 240px; min-width: 0; }
.key-row .key-info .chip { margin-left: 4px; vertical-align: 2px; }
.key-saved { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.key-saved .mono { color: var(--ink-soft); margin-right: 2px; }
.key-row form.key-form { display: flex; align-items: center; gap: 8px; flex: 1 1 320px; max-width: 460px; }
.key-row form.key-form .input { flex: 1; min-width: 0; height: 40px; padding: 0 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; letter-spacing: 0; }
.key-row .key-note { flex-basis: 100%; margin: 0; }
@media (max-width: 560px) {
  .key-saved { justify-content: flex-start; gap: 2px; }
  .key-saved .btn-sm { padding-inline: 7px; }
}
@media (max-width: 560px) { .model-slot { grid-template-columns: 1fr; } .model-slot .slot-name { padding-top: 0; } }

/* ---------- First visit ---------- */

/* ---------- Onboarding: tour (replayable) and key setup (once) ---------- */
.onboarding { display: flex; flex-direction: column; gap: 18px; }
.onboarding-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.onboarding-phases { list-style: none; display: flex; gap: 6px; padding: 0; margin: 0; }
.onboarding-phases li { padding: 6px 12px; border-radius: 999px; font-weight: 800; font-size: 13px; color: var(--ink-faint); background: rgba(43, 33, 64, 0.06); }
.onboarding-phases li.now { background: var(--plum); color: #fff; }
.onboarding-phases li.done { background: var(--emerald-soft); color: var(--emerald); }

.tour { display: flex; flex-direction: column; gap: 20px; }
.tour-top { display: flex; align-items: center; gap: 14px; min-height: 36px; }
.tour-count { font-weight: 800; white-space: nowrap; }
.tour-dots { display: flex; gap: 6px; flex: 1; }
.tour-dots button { height: 8px; flex: 1; max-width: 56px; border: none; padding: 0; border-radius: 999px; background: rgba(43, 33, 64, 0.12); cursor: pointer; transition: background 0.2s; }
.tour-dots button.done { background: var(--lavender); }
.tour-dots button.on { background: var(--plum); }
.tour-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: center; min-height: 340px; animation: tour-in 0.3s ease-out; }
@keyframes tour-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .tour-body { animation: none; } }
.tour-copy { display: flex; flex-direction: column; gap: 12px; }
.tour-points { list-style: none; padding: 0; margin: 4px 0 0; display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: 14.5px; }
.tour-points li { display: flex; gap: 8px; align-items: center; }
.tour-points svg { color: var(--emerald); flex: none; }
.tour-nav, .keysetup-nav { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-top: 16px; border-top: 1px solid var(--line); }

.scene { background: linear-gradient(180deg, #fffaf0, #fbf1dc); border-radius: var(--r-lg); padding: 22px; min-height: 260px; display: flex; flex-direction: column; justify-content: center; gap: 12px; box-shadow: inset 0 0 0 1px var(--line); }
.scene-books { display: flex; align-items: flex-end; gap: 6px; padding: 0 18px; height: 104px; }
.scene-books span { width: 26px; border-radius: 4px 4px 2px 2px; box-shadow: inset -4px 0 0 rgba(0, 0, 0, 0.12); }
.scene-books .scene-new { animation: book-drop 0.6s 0.2s ease-out both; }
@keyframes book-drop { from { transform: translateY(-40px); opacity: 0; } to { transform: none; opacity: 1; } }
.scene-plank { height: 10px; border-radius: 4px; background: linear-gradient(180deg, var(--wood-light), var(--wood)); margin-top: -12px; }
.scene-file { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--paper); border-radius: var(--r-md); padding: 10px 12px; box-shadow: var(--shadow-sm); color: var(--plum); }
.scene-file > div { flex: 1; min-width: 150px; color: var(--ink); }
.scene-heat-row { display: grid; grid-template-columns: 104px 1fr; gap: 10px; align-items: center; }
.scene-heat-cells { display: flex; gap: 3px; height: 20px; }
.scene-heat-cells i { flex: 1; border-radius: 4px; }
.scene-callout { display: flex; align-items: center; gap: 6px; font-weight: 700; color: var(--ruby); margin-top: 4px; }
.scene-text { font-family: var(--font-read); font-size: 16px; line-height: 1.6; background: var(--paper); border-radius: var(--r-md); padding: 14px 16px; margin: 0; box-shadow: var(--shadow-sm); }
.scene-text del { background: var(--ruby-soft); color: var(--ruby); }
.scene-text ins { background: var(--emerald-soft); color: var(--emerald); text-decoration: none; }
.scene-text mark { background: var(--gold-soft); border-radius: 3px; }
.scene-comment { display: flex; align-items: center; gap: 10px; background: var(--paper); border-radius: var(--r-md); padding: 8px 12px; box-shadow: var(--shadow-sm); margin-left: 24px; }
.scene-read { align-items: center; }
.scene-picture { width: 100%; max-width: 260px; aspect-ratio: 4 / 3; border-radius: var(--r-md); display: grid; place-items: center; background: radial-gradient(circle at 30% 30%, var(--sky), var(--plum-soft) 60%, var(--gold-soft)); box-shadow: inset 0 0 0 6px var(--paper), var(--shadow-md); }
.scene-lock { display: flex; align-items: center; gap: 8px; background: var(--plum); color: #fff; padding: 8px 14px; border-radius: 999px; }

.keysetup { display: flex; flex-direction: column; gap: 18px; }
.keysetup-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chip-plum { background: var(--plum-soft); color: var(--plum); }
.keysetup-head { display: flex; align-items: flex-start; gap: 16px; }
.keypath-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.keypath { text-align: left; align-items: flex-start; }
.keypath strong { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding-right: 30px; }
.keypath-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--plum-soft); color: var(--plum); }
.keypath-pair { display: flex; gap: 2px; }
.keypath-pair svg { width: 16px; height: 16px; }
.howto { margin: 0; padding-left: 0; list-style: none; counter-reset: howto; display: flex; flex-direction: column; gap: 12px; }
.howto li { counter-increment: howto; position: relative; padding-left: 42px; line-height: 1.5; }
.howto li::before { content: counter(howto); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--plum); color: #fff; font-weight: 800; font-size: 13px; }
.howto li .tiny { margin-top: 4px; }
.keysetup code { font-family: ui-monospace, 'SF Mono', Menlo, monospace; font-size: 0.9em; background: rgba(43, 33, 64, 0.07); padding: 1px 6px; border-radius: 6px; }
.keysetup .link { color: var(--plum); font-weight: 800; text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }
.keysetup .link svg { display: inline-block; vertical-align: -1px; margin-left: 2px; transform: rotate(-45deg); }
.keypaste { display: flex; flex-direction: column; gap: 8px; background: #faf7ff; border-radius: var(--r-md); padding: 16px; box-shadow: inset 0 0 0 1.5px var(--plum-soft); }
.keypaste p { margin: 0; }
.keypaste-ok { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 10px; background: var(--emerald-soft); box-shadow: none; color: var(--emerald); }
.keypaste-ok strong { color: var(--emerald); }
.keysetup-summary { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.keysetup-summary li { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--emerald-soft); padding: 12px 14px; border-radius: var(--r-md); }
.keysetup-summary li > svg { color: var(--emerald); }
.keysetup-warn { display: flex; gap: 12px; padding: 16px; border-radius: var(--r-md); background: var(--ruby-soft); color: var(--ruby); }
.keysetup-warn > svg { flex: none; margin-top: 2px; }
.keysetup-warn ul { margin: 6px 0 8px; padding-left: 18px; color: var(--ink); }
.keysetup-warn .small { color: var(--ink-soft); }

@media (max-width: 760px) {
  .tour-body { grid-template-columns: 1fr; gap: 20px; }
  .tour-body { min-height: 0; }
  .tour-scene { order: 2; }
  .tour.card-lg, .keysetup.card-lg { padding: 20px; }
  .scene { min-height: 0; }
  .keypath-grid { grid-template-columns: 1fr; }
  .keysetup-head .tuft { width: 52px; height: 52px; }
}
.empty-shelf { min-height: 140px; align-items: center; justify-content: center; }

/* ---------- Account menu ---------- */

.account-menu { position: relative; }
.account-menu summary { list-style: none; cursor: pointer; overflow: hidden; }
.account-menu summary::-webkit-details-marker { display: none; }
.account-menu summary img { width: 100%; height: 100%; object-fit: cover; }
.account-menu .popover { width: 240px; display: flex; flex-direction: column; gap: 10px; }

/* ---------- Settings (web app) ---------- */

.settings-nav a { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 14px; text-align: left; font-weight: 800; color: var(--ink-soft); text-decoration: none; }
.settings-nav a:hover { background: rgba(75, 46, 131, 0.06); }
.settings-nav a.on { background: var(--paper); color: var(--plum); box-shadow: var(--shadow-sm); }
@media (max-width: 860px) { .settings-nav a { flex: none; } }
.status-ok { color: var(--emerald); font-weight: 700; }
.status-bad { color: var(--ruby); font-weight: 700; }
.gate-tagline { max-width: 30ch; text-wrap: balance; }
.gate-note { background: var(--parchment); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 16px; color: var(--ink-soft); text-wrap: pretty; }

/* ---------- Book import & book page (web app) ---------- */

.clamp-6 { display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.cover-picks { display: flex; gap: 12px; overflow-x: auto; padding: 4px; }
.cover-pick { flex: none; width: 104px; display: flex; flex-direction: column; gap: 6px; align-items: stretch; padding: 6px; border-radius: var(--r-md); border: none; background: #fff; box-shadow: inset 0 0 0 1.5px var(--line-strong); cursor: pointer; text-align: center; }
.cover-pick img { width: 100%; aspect-ratio: 2 / 3; object-fit: cover; border-radius: 4px 8px 8px 4px; }
.cover-pick.on { box-shadow: inset 0 0 0 3px var(--plum); background: #faf7ff; }
.chapter-list li.merged { opacity: 0.7; padding-left: 28px; }
.toc-list { list-style: none; padding: 0; margin: 0; columns: 2 260px; column-gap: 24px; }
.toc-list li { break-inside: avoid; }
.toc-list a { display: flex; gap: 10px; padding: 6px 8px; border-radius: 8px; text-decoration: none; color: var(--ink); font-weight: 700; }
.toc-list a:hover { background: var(--plum-soft); }

/* ---------- Reader extras (web app) ---------- */

.scene-break { text-align: center; color: var(--gold); letter-spacing: 0.6em; margin: 0.6em 0 1em; break-inside: avoid; }
.book-h { font-family: var(--font-display); color: inherit; margin: 0.8em 0 0.5em; break-after: avoid; }
.book-h1 { font-size: 1.4em; }
.book-h2 { font-size: 1.2em; }
.book-h3 { font-size: 1.05em; }
.book-quote { margin: 0 0 0.85em 1em; padding-left: 0.8em; border-left: 3px solid color-mix(in srgb, var(--r-ink) 20%, transparent); font-style: normal; color: inherit; font-size: 0.95em; }

/* ---------- Analysis ---------- */

.estimate-strip { display: flex; flex-wrap: wrap; gap: 10px; }
.estimate-strip > div { flex: 1 1 120px; display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border-radius: var(--r-md); background: rgba(75, 46, 131, 0.045); }
.estimate-strip strong { font-size: 18px; }
.chapter-notes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.chapter-notes > li { border-top: 1px solid var(--line); }
.chapter-notes summary { display: flex; gap: 10px; align-items: baseline; padding: 10px 0; cursor: pointer; list-style: none; }
.chapter-notes summary::-webkit-details-marker { display: none; }
.chapter-notes summary .mono { width: 18px; text-align: right; flex: none; }
.chapter-notes-flags { margin-left: auto; display: flex; gap: 4px; flex: none; }
.bible-place-list { display: flex; flex-direction: column; gap: 6px; margin: 0; padding-left: 18px; }
.sample-extras { display: flex; flex-direction: column; gap: 4px; padding: 10px 12px; margin-bottom: 14px; border-radius: var(--r-md); background: #f8f2ff; }
.compare-col .book-h { font-family: var(--font-display); font-size: 1.1em; margin: 0 0 0.8em; }
.compare-col .book-quote { margin: 0 0 0.9em 1em; font-style: italic; }
.compare-col .scene-break { text-align: center; margin: 0.6em 0 1em; color: var(--ink-faint); }
.chapter-subtitle { margin: -4px 0 6px; font-size: 0.8em; opacity: 0.65; font-style: italic; }
.book-quote.recap { font-style: normal; border-left: 3px solid var(--gold); padding-left: 0.9em; opacity: 0.9; }
.notices { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.notice-row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; flex-wrap: wrap; }
.notice-row p { margin: 0; font-weight: 700; }
.sparkles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.sparkles i {
  position: absolute; width: 10px; height: 10px;
  background: radial-gradient(circle, var(--gold) 0 30%, transparent 32%);
  clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
  animation: twinkle 2.4s ease-in-out infinite;
}

/* ---------- Character sheets ---------- */

.sheet-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.sheet-card { border-radius: var(--r-lg); background: var(--paper); box-shadow: var(--shadow-sm), inset 0 0 0 1px var(--line); overflow: hidden; display: flex; flex-direction: column; }
.sheet-card.approved { box-shadow: var(--shadow-sm), inset 0 0 0 2px var(--emerald); }
.sheet-art { aspect-ratio: 3 / 2; background: #fffdf9; display: grid; place-items: center; border-bottom: 1px solid var(--line); }
.sheet-art img { width: 100%; height: 100%; object-fit: contain; }
.clamp-3 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.pic-card > img { width: 100%; aspect-ratio: 4 / 3; object-fit: contain; background: #fffdf9; border-radius: 10px; }

/* ---------- Changes highlighted in side-by-side text ---------- */

.diff-del { background: rgba(200, 71, 94, 0.13); color: #8c2f43; border-radius: 3px; text-decoration: line-through; text-decoration-color: rgba(140, 47, 67, 0.45); text-decoration-thickness: 1px; }
.diff-ins { background: rgba(47, 125, 98, 0.15); color: #1f5a46; border-radius: 3px; box-shadow: 0 1px 0 rgba(47, 125, 98, 0.45); }
.diff-legend { display: inline-flex; gap: 6px; align-items: center; }
.diff-legend .diff-del, .diff-legend .diff-ins { padding: 0 4px; }
.theme-night .diff-del { color: #f3a6b6; background: rgba(200, 71, 94, 0.22); }
.theme-night .diff-ins { color: #9be0c4; background: rgba(47, 125, 98, 0.28); }
.compare.aligned { display: block; }
.compare.aligned .compare-row { display: grid; grid-template-columns: 1fr 1fr; }
.compare.aligned .compare-col { padding: 0 26px; }
.compare.aligned .compare-row:first-child .compare-col { padding-top: 22px; }
.compare.aligned .compare-row:last-child .compare-col { padding-bottom: 22px; }
.compare.aligned .compare-col.original { border-right: 1px solid var(--line); }
.compare.aligned .prose > p, .compare.aligned .prose > h3, .compare.aligned .prose > blockquote { margin: 0; padding: 0 0 0.9em; }
@media (max-width: 760px) {
  .compare.aligned .compare-row { grid-template-columns: 1fr; }
  .compare.aligned .compare-col.original { border-right: 0; padding-top: 10px; }
  .compare.aligned .compare-row:first-child .compare-col.original { display: none; }
}
.chapter-end { padding: 1.6em 0 0.6em; }
.compare-reader-scroll { flex: 1; min-height: 0; overflow: auto; padding: 0 clamp(12px, 3vw, 40px) 40px; }
.compare-reader-scroll .compare { max-width: 1200px; margin: 0 auto; }
.theme-night .compare-reader-scroll .compare-col.original { background: #1d1828; }
.theme-night .compare-reader-scroll .compare-col.softened { background: #16121e; }
.budget-note { display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; padding: 8px 12px; border-radius: var(--r-md); background: var(--gold-soft); color: var(--gold-deep); margin: 0; }
.budget-note.over { background: rgba(200, 71, 94, 0.1); color: var(--ruby); }
