:root {
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --surface-2: #f0e9db;
  --ink: #1d1b16;
  --muted: #6b655a;
  --line: #e2d9c6;
  --accent: #1f3a34;
  --accent-ink: #fffdf8;
  --gold: #d98e1f;
  --good: #2f8f5b;
  --good-bg: #e3f3e8;
  --bad: #c4493c;
  --bad-bg: #fbe7e3;
  --shadow: 0 1px 2px rgb(40 30 10 / .06), 0 8px 24px rgb(40 30 10 / .08);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, sans-serif;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15130f;
    --surface: #201d17;
    --surface-2: #2a261e;
    --ink: #f1ece0;
    --muted: #a69f90;
    --line: #38332a;
    --accent: #8fd0b5;
    --accent-ink: #10201b;
    --gold: #f0b45a;
    --good: #5cc58a;
    --good-bg: #1b3326;
    --bad: #ee7a6c;
    --bad-bg: #3a1f1b;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 8px 24px rgb(0 0 0 / .35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
a { color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.pad { padding: 16px; }
.row { display: flex; gap: 10px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }

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

#app { height: 100dvh; }
.screen {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
}
.main { flex: 1; overflow-y: auto; min-height: 0; }
.center-msg { align-items: center; justify-content: center; gap: 12px; padding: 24px; text-align: center; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
}
.topbar-title { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.topbar-title strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; flex: 1; }
.brand-icon { width: 30px; height: 30px; }
.stat-chips { display: flex; gap: 6px; }
.chip-stat {
  font-size: .82rem; font-weight: 600;
  background: var(--surface); border: 1px solid var(--line);
  padding: 3px 9px; border-radius: 99px; white-space: nowrap;
}

.icon-btn {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px; flex: none;
  border: none; background: transparent; border-radius: 50%;
  font-size: 1.4rem; text-decoration: none; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

.tabbar {
  display: flex;
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding-bottom: var(--safe-bottom);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px;
  padding: 8px 0 7px; text-decoration: none; font-size: .78rem; font-weight: 600; color: var(--muted);
}
.tab-icon { font-size: 1.2rem; line-height: 1.2; }
.tab.active { color: var(--accent); }

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

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 20px; border-radius: 14px; border: none; cursor: pointer;
  background: var(--accent); color: var(--accent-ink);
  font-weight: 700; text-decoration: none; text-align: center;
  box-shadow: 0 3px 0 rgb(0 0 0 / .18);
  transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgb(0 0 0 / .18); }
.btn:disabled { opacity: .4; cursor: default; transform: none; }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); box-shadow: 0 2px 0 var(--line); }
.btn.good { background: var(--good); color: #fff; }
.btn.bad { background: var(--bad); color: #fff; }
.btn.danger { background: var(--bad); color: #fff; }
.btn.wide { width: 100%; }
.btn.small { padding: 7px 12px; font-size: .85rem; border-radius: 10px; }

.linkish {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--accent); font-weight: 600; font-size: .88rem; text-align: left;
}
.tag {
  display: inline-block; font-size: .72rem; font-weight: 600;
  padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted);
}
.tag.warn { background: #f7e2b8; color: #7a4b05; }
@media (prefers-color-scheme: dark) { .tag.warn { background: #4a3714; color: #f5cf86; } }

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

.lib-title { font-family: var(--serif); font-size: 1.9rem; margin: 6px 0 16px; }
.library-list { display: flex; flex-direction: column; gap: 14px; }
.book-tile {
  position: relative; display: flex;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
}
.book-tile .icon-btn { position: absolute; top: 6px; right: 6px; font-size: 1rem; color: var(--muted); }
.book-link { display: flex; gap: 14px; padding: 14px; text-decoration: none; flex: 1; min-width: 0; }
.cover {
  flex: none; width: 76px; height: 108px; border-radius: 6px 10px 10px 6px;
  background: linear-gradient(160deg, hsl(var(--h) 45% 38%), hsl(calc(var(--h) + 40) 50% 24%));
  color: #fff; padding: 8px; display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: inset 4px 0 0 rgb(0 0 0 / .18), 0 4px 10px rgb(0 0 0 / .18);
}
.cover { position: relative; overflow: hidden; }
.cover-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cover.has-img .cover-title, .cover.has-img .cover-author { visibility: hidden; }
.cover-edit {
  position: absolute; left: 70px; top: 102px; width: 28px; height: 28px;
  display: grid; place-items: center; padding: 0; cursor: pointer;
  border-radius: 50%; border: 2px solid var(--surface); background: var(--ink); color: var(--bg);
  font-size: .8rem; box-shadow: 0 2px 6px rgb(0 0 0 / .25);
}
.cover-title { font-family: var(--serif); font-weight: 700; font-size: .82rem; line-height: 1.15; }
.cover-author { font-size: .6rem; opacity: .85; }
.book-meta { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding-top: 4px; }
.book-meta strong { font-size: 1.1rem; font-family: var(--serif); }
.book-meta .tag { align-self: flex-start; margin-top: 4px; }
.import-box { margin-top: 26px; text-align: center; }

/* ---------- Feed ---------- */

.feed-chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 16px 10px;
  scrollbar-width: none; flex: none;
}
.feed-chips::-webkit-scrollbar { display: none; }
.feed-chip {
  flex: none; padding: 6px 13px; border-radius: 99px; text-decoration: none;
  font-size: .85rem; font-weight: 600; white-space: nowrap;
  max-width: 72vw; overflow: hidden; text-overflow: ellipsis;
  background: var(--surface); border: 1px solid var(--line);
}
.feed-chip.theme { color: var(--muted); }
.feed-chip.active { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.feed-wrap { position: relative; overflow: hidden; }
.feed {
  height: 100%; overflow-y: auto; scroll-snap-type: y mandatory;
  overscroll-behavior: contain; scrollbar-width: none;
}
.feed::-webkit-scrollbar { display: none; }
.slot {
  height: 100%; scroll-snap-align: start; scroll-snap-stop: always;
  display: flex; align-items: center; padding: 10px 16px 18px;
}
.feed-counter {
  position: absolute; top: 14px; right: 26px; z-index: 2;
  font-size: .72rem; font-weight: 700; color: var(--muted);
  background: var(--bg); padding: 1px 8px; border-radius: 99px; pointer-events: none;
}

.end-card { width: 100%; text-align: center; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.end-mark { font-size: 2.4rem; margin: 0; color: var(--good); }

/* ---------- Cards ---------- */

.card {
  --tc: #7c6f58;
  width: 100%; max-height: 100%; overflow-y: auto;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px 20px 16px; display: flex; flex-direction: column; gap: 12px;
  border-top: 5px solid var(--tc);
}
.card.compact { box-shadow: none; border: 1px solid var(--line); border-top: 5px solid var(--tc); max-height: none; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  font-size: .74rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--tc);
}
.glyph {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 4px;
  border-radius: 7px; background: color-mix(in srgb, var(--tc) 16%, transparent); font-size: .8rem;
}
.where { font-size: .74rem; color: var(--muted); text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-title { font-family: var(--serif); font-size: 1.45rem; }
.card-body { margin: 0; font-size: 1.08rem; line-height: 1.6; }
.steps { margin: 0; padding-left: 0; list-style: none; counter-reset: s; display: flex; flex-direction: column; gap: 8px; }
.steps li {
  counter-increment: s; display: flex; gap: 10px; align-items: baseline;
  background: var(--surface-2); border-radius: 10px; padding: 8px 12px;
}
.steps li::before { content: counter(s); font-weight: 800; color: var(--tc); }

.quote-text {
  margin: 8px 0 0; font-family: var(--serif); font-size: 1.45rem; line-height: 1.45;
  padding-left: 16px; border-left: 3px solid var(--tc);
}
.quote-context { margin: 0; color: var(--muted); font-size: .92rem; }
.quote-cite { margin: 0; font-size: .85rem; font-weight: 600; }

.sibling { font-size: .82rem; }
.card-foot { display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; margin-top: auto; padding-top: 6px; }
.theme-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.theme-tag { font-size: .76rem; color: var(--muted); text-decoration: none; font-weight: 600; }
.theme-tag:hover { color: var(--accent); }

.inline-links { display: flex; flex-direction: column; gap: 8px; }
.mini-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; cursor: pointer;
  background: var(--surface-2); border: none; border-radius: 12px; padding: 10px 12px; font-weight: 600; font-size: .92rem;
}
.mini-card.wide { width: 100%; margin-bottom: 8px; }
.mini-type { font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 800; }

.feed-quiz { display: flex; flex-direction: column; gap: 12px; }
.feed-quiz-answer {
  background: var(--good-bg); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px;
}
.feed-quiz-answer p { margin: 0; font-weight: 600; }

/* type colors */
.t-chapter_summary, .t-book_thesis, .t-idea_map, .t-closing, .t-theme_intro { --tc: #1f3a34; }
.t-quote { --tc: #9b5d2e; }
.t-fact { --tc: #2f6fa3; }
.t-idea { --tc: #6b4fa3; }
.t-example { --tc: #2f8f7a; }
.t-term { --tc: #a3477a; }
.t-framework { --tc: #4c6b1f; }
.t-try_this { --tc: #d17a12; }
.t-counterpoint, .t-tension { --tc: #b8433a; }
.t-quiz { --tc: #c28a00; }
.t-feynman { --tc: #3b8fb8; }
.t-synthesis, .t-callback { --tc: #5a5fbf; }
.t-character, .t-scene, .t-motif, .t-turning_point { --tc: #8a5a9e; }
@media (prefers-color-scheme: dark) {
  .t-chapter_summary, .t-book_thesis, .t-idea_map, .t-closing, .t-theme_intro { --tc: #8fd0b5; }
  .t-quote { --tc: #e0a274; }
  .t-fact { --tc: #7db4e6; }
  .t-idea { --tc: #b49ae6; }
  .t-example { --tc: #6cd0b8; }
  .t-term { --tc: #e88cbd; }
  .t-framework { --tc: #a8cf6a; }
  .t-try_this { --tc: #f2a64a; }
  .t-counterpoint, .t-tension { --tc: #f08b80; }
  .t-quiz { --tc: #f0c340; }
  .t-feynman { --tc: #7cc6ea; }
  .t-synthesis, .t-callback { --tc: #9da2f0; }
  .t-character, .t-scene, .t-motif, .t-turning_point { --tc: #d1a1e6; }
}
.t-book_thesis .card-title, .t-closing .card-title { font-size: 1.7rem; }
.t-theme_intro .card-title { font-size: 2rem; }
.t-theme_intro .card-title::before { content: "# "; color: var(--muted); }

/* ---------- Choices (shared) ---------- */

.choices { display: flex; flex-direction: column; gap: 8px; }
.choice {
  display: flex; gap: 12px; align-items: center; text-align: left; cursor: pointer;
  padding: 11px 14px; border-radius: 14px; background: var(--surface);
  border: 2px solid var(--line); box-shadow: 0 2px 0 var(--line); font-size: .98rem;
}
.choices.big .choice { padding: 14px; }
.choice .key {
  flex: none; width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center;
  border: 1.5px solid var(--line); font-size: .75rem; font-weight: 700; color: var(--muted);
}
.choice.picked { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); box-shadow: 0 2px 0 var(--accent); }
.choice.right { border-color: var(--good); background: var(--good-bg); box-shadow: 0 2px 0 var(--good); }
.choice.wrong { border-color: var(--bad); background: var(--bad-bg); box-shadow: 0 2px 0 var(--bad); }

/* ---------- Path ---------- */

.path { padding-bottom: 40px; }
.path-stats {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px;
}
.path-stats > div {
  background: var(--surface); border-radius: 14px; padding: 10px; text-align: center;
  display: flex; flex-direction: column; border: 1px solid var(--line);
}
.path-stats strong { font-size: 1.3rem; }
.review-banner {
  display: flex; gap: 14px; align-items: center; text-decoration: none;
  background: var(--surface); border: 2px solid var(--line); border-radius: 16px; padding: 12px 16px; margin-bottom: 8px;
}
.review-banner > span:last-child { display: flex; flex-direction: column; }
.review-banner.hot { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 12%, var(--surface)); }
.review-icon {
  font-size: 1.5rem; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--gold); color: #fff; flex: none;
}

.unit {
  margin: 26px 0 18px; padding: 14px 16px; border-radius: 16px;
  background: hsl(var(--h) 38% 34%); color: #fff;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.unit > div { display: flex; flex-direction: column; }
.unit-kicker { opacity: .8; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.unit-link {
  flex: none; font-size: .82rem; font-weight: 700; text-decoration: none;
  border: 1.5px solid rgb(255 255 255 / .6); border-radius: 10px; padding: 6px 10px;
}
.node-row {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px;
  margin: 0 auto 18px; transform: translateX(var(--x));
  width: max-content; max-width: 70%;
}
.node-row.is-current { margin-top: 44px; }
.node {
  width: 72px; height: 66px; border-radius: 50%; border: none; cursor: pointer;
  font-size: 1.6rem; color: #fff; background: var(--accent);
  box-shadow: 0 6px 0 color-mix(in srgb, var(--accent) 60%, #000);
  transition: transform .08s;
}
@media (prefers-color-scheme: dark) { .node { color: var(--accent-ink); } }
.node:active { transform: translateY(4px); box-shadow: 0 2px 0 color-mix(in srgb, var(--accent) 60%, #000); }
.node.done { background: var(--gold); box-shadow: 0 6px 0 color-mix(in srgb, var(--gold) 60%, #000); color: #fff; }
.node.locked { background: var(--surface-2); color: var(--muted); box-shadow: 0 6px 0 var(--line); font-size: 1.2rem; }
.node.checkpoint { width: 88px; height: 80px; border-radius: 26px; font-size: 2rem; }
.node.current { animation: pulse 1.8s infinite; }
@keyframes pulse {
  0%, 100% { outline: 0 solid color-mix(in srgb, var(--accent) 35%, transparent); }
  50% { outline: 10px solid color-mix(in srgb, var(--accent) 0%, transparent); }
}
.node-label { font-size: .85rem; font-weight: 600; text-align: center; }
.start-bubble {
  position: absolute; top: -30px; background: var(--surface); border: 2px solid var(--line);
  padding: 2px 10px; border-radius: 10px; font-weight: 800; font-size: .78rem; color: var(--accent);
  animation: bob 1.4s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(-4px); } }
.path-done { text-align: center; font-weight: 600; margin-top: 20px; }

/* ---------- Lesson ---------- */

.lesson { background: var(--bg); }
.lesson-top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + var(--safe-top)) 14px 4px;
}
.progress { flex: 1; height: 14px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress-fill { height: 100%; width: 0; border-radius: 99px; background: var(--good); transition: width .35s ease; }
.progress.small-bar { height: 8px; margin: 12px 0 4px; }
.lesson-title { text-align: center; margin: 2px 16px 0; }
.stage { flex: 1; overflow-y: auto; padding: 16px 18px 24px; min-height: 0; }
.q-enter { animation: slidein .25s ease; }
@keyframes slidein { from { opacity: 0; transform: translateX(24px); } }

.question { display: flex; flex-direction: column; gap: 16px; }
.q-head { display: flex; gap: 8px; align-items: center; }
.q-format { font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); }
.bloom { font-size: .7rem; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.q-prompt { font-family: var(--serif); font-size: 1.4rem; }
.situation {
  background: var(--surface); border-left: 4px solid var(--gold); border-radius: 12px;
  padding: 12px 14px; font-size: 1rem;
}

.fill-text { font-family: var(--serif); font-size: 1.35rem; line-height: 2; margin: 0; }
.blank {
  font: inherit; font-family: var(--sans); font-size: 1.05rem; width: 9em; max-width: 100%;
  padding: 2px 8px; margin: 0 4px; border: none; border-bottom: 3px solid var(--accent);
  background: var(--surface); border-radius: 8px 8px 0 0; color: var(--ink); text-align: center;
}
.blank:focus { outline: none; background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.blank.right { border-color: var(--good); background: var(--good-bg); }
.blank.wrong { border-color: var(--bad); background: var(--bad-bg); }

.order { display: flex; flex-direction: column; gap: 18px; }
.order-slots { margin: 0; padding: 0; list-style: none; counter-reset: o; display: flex; flex-direction: column; gap: 8px; }
.order-slots li {
  counter-increment: o; display: flex; gap: 10px; align-items: center; min-height: 48px;
  border-radius: 12px;
}
.order-slots li::before { content: counter(o); width: 22px; flex: none; text-align: center; font-weight: 800; color: var(--muted); }
.order-slots li.empty .order-ghost {
  flex: 1; border: 2px dashed var(--line); border-radius: 12px; padding: 10px; color: var(--muted); font-size: .85rem;
}
.order-slots li.right .order-item { border-color: var(--good); background: var(--good-bg); }
.order-slots li.wrong .order-item { border-color: var(--bad); background: var(--bad-bg); }
.order-bank { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 14px; border-top: 2px solid var(--line); }
.order-item {
  cursor: pointer; text-align: left; padding: 10px 14px; border-radius: 12px; font-size: .95rem;
  background: var(--surface); border: 2px solid var(--line); box-shadow: 0 2px 0 var(--line);
}
.order-item.placed { flex: 1; }

.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match-col { display: flex; flex-direction: column; gap: 8px; }
.match-item {
  cursor: pointer; text-align: left; padding: 12px; border-radius: 12px; font-size: .9rem; min-height: 56px;
  background: var(--surface); border: 2px solid var(--line); box-shadow: 0 2px 0 var(--line);
}
.match-item.sel { border-color: var(--accent); box-shadow: 0 2px 0 var(--accent); }
.match-item.matched {
  border-color: hsl(var(--mh) 45% 45%); background: hsl(var(--mh) 50% 50% / .14); box-shadow: none; opacity: .8; cursor: default;
}
.match-item.shake { animation: shake .35s; border-color: var(--bad); }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.recall {
  width: 100%; font: inherit; padding: 12px 14px; border-radius: 14px; resize: vertical;
  border: 2px solid var(--line); background: var(--surface); color: var(--ink);
}
.recall:focus { outline: none; border-color: var(--accent); }
.recall-result { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.recall-result p { margin: 0; }
.model-answer { background: var(--surface); border-radius: 12px; padding: 12px 14px; border: 1px solid var(--line); }
.kw-row { display: flex; gap: 6px; flex-wrap: wrap; }
.kw { font-size: .78rem; padding: 2px 9px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.kw.hit { background: var(--good-bg); color: var(--good); font-weight: 700; }
.recall-result .row { justify-content: stretch; }
.recall-result .row .btn { flex: 1; }

.lesson-foot {
  padding: 14px 18px calc(16px + var(--safe-bottom));
  border-top: 2px solid var(--line); display: flex; flex-direction: column; gap: 8px;
}
.lesson-foot:empty { display: none; }
.lesson-foot.feedback { animation: up .2s ease; }
@keyframes up { from { transform: translateY(20px); opacity: 0; } }
.lesson-foot.is-good { background: var(--good-bg); border-color: transparent; }
.lesson-foot.is-bad { background: var(--bad-bg); border-color: transparent; }
.fb-head { font-weight: 800; font-size: 1.15rem; }
.is-good .fb-head { color: var(--good); }
.is-bad .fb-head { color: var(--bad); }
.fb-note { margin: 0; font-weight: 600; }
.fb-expl { margin: 0; font-size: .95rem; }
.fb-links { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }

.finish { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; padding-top: 8vh; }
.finish-badge { font-size: 4rem; animation: pop .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { from { transform: scale(.3); } }
.finish-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.finish-stats > div {
  display: flex; flex-direction: column; padding: 12px 6px; border-radius: 14px; background: var(--surface); border: 2px solid var(--line);
}
.finish-stats strong { font-size: 1.3rem; }

/* ---------- Primers ---------- */

.primer-intro { margin-bottom: 18px; }
.primer-intro h1 { font-family: var(--serif); font-size: 1.7rem; margin-bottom: 6px; }
.primer-intro p { margin: 0 0 4px; }
.primer-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.primer {
  background: var(--surface); border-radius: 16px; padding: 14px 16px; border: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 8px; transition: opacity .2s;
}
.primer.found { opacity: .62; }
.primer.found .primer-q { text-decoration: line-through; text-decoration-color: var(--good); }
.primer-head { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.primer-q { margin: 0; font-family: var(--serif); font-size: 1.15rem; line-height: 1.4; }
.primer .row { justify-content: space-between; }
.ptype { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; padding: 2px 9px; border-radius: 99px; }
.p-curiosity { background: #e6ddfa; color: #5b3fa0; }
.p-predict { background: #dcecf9; color: #1f5c8f; }
.p-prior { background: #fbe8d0; color: #8a4f0c; }
.p-term { background: #f8dcea; color: #8f2f63; }
@media (prefers-color-scheme: dark) {
  .p-curiosity { background: #352b52; color: #c6b3f5; }
  .p-predict { background: #1e3449; color: #9cc9f0; }
  .p-prior { background: #46311a; color: #f3c58c; }
  .p-term { background: #4a2338; color: #f3a9cf; }
}
.primer-note {
  width: 100%; font: inherit; font-size: .92rem; padding: 8px 10px; border-radius: 10px;
  border: 1.5px solid var(--line); background: var(--bg); color: var(--ink); resize: vertical;
}

/* ---------- Sheet + toast ---------- */

.sheet-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / .4); z-index: 20; animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-width: 560px; margin: 0 auto; max-height: 86dvh; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 22px 22px 0 0; animation: up .25s ease;
  padding-bottom: var(--safe-bottom);
}
.sheet-bar { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 0; }
.sheet-grip { width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto; }
.sheet-body { overflow-y: auto; padding: 8px 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.sheet-h { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 8px; }
.confirm p { font-size: 1.05rem; font-weight: 600; margin: 4px 0 18px; }

#toast {
  position: fixed; left: 50%; bottom: calc(80px + var(--safe-bottom)); transform: translateX(-50%);
  z-index: 30; background: var(--ink); color: var(--bg);
  padding: 10px 18px; border-radius: 12px; font-weight: 600; font-size: .9rem;
  max-width: calc(100% - 32px); box-shadow: var(--shadow); animation: up .2s;
}

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