/* TQuest styles. Same chassis as TypeQuest: a sticky station rail (desktop) or a top bar (narrow), one reading column.
   Signature: story recaps and the student's rule cards render on ruled notebook paper ("sheet") in both themes, because the
   chapter is about what gets written down and retold. Accent is sunlight (O'Brien: "it's about sunlight"); the rule line is a notebook blue. */

:root {
  --bg: #F4F3EE;
  --surface: #FFFFFF;
  --surface-2: #EAE8E0;
  --ink: #1B1A17;
  --ink-2: #514E46;
  --ink-3: #7D796E;
  --line: #D8D5CB;
  --accent: #B8741F;        /* late-afternoon sunlight */
  --accent-soft: #F7E9D2;
  --accent-ink: #FFFFFF;
  --guide: #5A86B8;         /* notebook rule blue */
  --guide-soft: #E1EAF5;
  --link: #2A5D9C;
  --ok: #2E7A4B;
  --ok-soft: #DDF1E3;
  --warn: #9A6418;
  --warn-soft: #FBEED8;
  --bad: #B23A2E;
  --bad-soft: #F9E3E0;
  --focus: #2A5D9C;
  --shadow: 0 1px 2px rgba(30, 26, 16, .06), 0 8px 24px rgba(30, 26, 16, .08);
  --sheet: #FDFBF4;
  --sheet-ink: #1B1A17;
  --sheet-muted: #5E5A50;
  --sheet-rule: #CFDCEB;
  --sheet-margin: #D98A7A;
  --font-display: 'Newsreader', Georgia, 'Times New Roman', serif;
  --font-ui: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --font-hand: 'Caveat', 'Comic Sans MS', cursive;
  --radius: 10px;
  --rail-w: 264px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16150F; --surface: #1F1E18; --surface-2: #2A2820; --ink: #EEEBE2; --ink-2: #B3AE9F; --ink-3: #85806F;
    --line: #3A3729; --accent: #E0A04A; --accent-soft: #3A2C14; --accent-ink: #16150F; --guide: #7FA6D6; --guide-soft: #1E2A3A;
    --link: #8FB6EA; --ok: #5BC283; --ok-soft: #173024; --warn: #E0A23A; --warn-soft: #3A2C13; --bad: #EE6A5C; --bad-soft: #3A1F1E; --focus: #8FB6EA;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
    --sheet: #F3EFE2; --sheet-ink: #1B1A17; --sheet-muted: #5E5A50; --sheet-rule: #C3D3E6; --sheet-margin: #D98A7A;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16150F; --surface: #1F1E18; --surface-2: #2A2820; --ink: #EEEBE2; --ink-2: #B3AE9F; --ink-3: #85806F;
  --line: #3A3729; --accent: #E0A04A; --accent-soft: #3A2C14; --accent-ink: #16150F; --guide: #7FA6D6; --guide-soft: #1E2A3A;
  --link: #8FB6EA; --ok: #5BC283; --ok-soft: #173024; --warn: #E0A23A; --warn-soft: #3A2C13; --bad: #EE6A5C; --bad-soft: #3A1F1E; --focus: #8FB6EA;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  --sheet: #F3EFE2; --sheet-ink: #1B1A17; --sheet-muted: #5E5A50; --sheet-rule: #C3D3E6; --sheet-margin: #D98A7A;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--ink);
  font-family: var(--font-ui); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.1; margin: 0; text-wrap: balance; letter-spacing: -0.005em; }
p { margin: 0; }
a { color: var(--link); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.eyebrow { font-family: var(--font-mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); }
.muted { color: var(--ink-2); }
.small { font-size: 14px; }
.num { font-variant-numeric: tabular-nums; }

/* ---------- App frame ---------- */
.app { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: env(safe-area-inset-top, 0px); align-self: start; height: calc(100vh - env(safe-area-inset-top, 0px));
  display: flex; flex-direction: column; gap: 10px;
  padding-block: 20px 16px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: 12px;
  border-right: 1px solid var(--line); background: var(--surface); overflow-y: auto;
}
.brand { display: flex; align-items: baseline; gap: 8px; padding: 0 6px; }
.brand .mark { font-family: var(--font-display); font-weight: 700; font-size: 26px; letter-spacing: -0.02em; }
.brand .mark em { font-style: italic; color: var(--accent); font-weight: 500; }
.brand .ver { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
.rail .rail-close { display: none; margin-left: auto; }
.student-tag { padding: 0 6px; font-size: 14px; color: var(--ink-2); min-height: 1.4em; }

.stations { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.stations .day { padding: 8px 6px 2px; }
.st-btn {
  display: grid; grid-template-columns: 26px 1fr auto; align-items: center; gap: 10px;
  width: 100%; text-align: left; padding: 5px 8px; border: 0; border-radius: 8px; background: transparent; cursor: pointer;
  color: var(--ink); font-size: 14.5px; min-height: 36px;
}
.st-btn:hover { background: var(--surface-2); }
.st-btn[aria-current="step"] { background: var(--accent-soft); color: var(--ink); font-weight: 700; }
.st-btn .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-family: var(--font-mono); font-size: 11px; color: var(--ink-2); }
.st-btn.is-done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.st-btn.is-started .dot { border-color: var(--accent); color: var(--accent); }
.st-btn .min { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); }
.st-btn:disabled { opacity: .45; cursor: not-allowed; }
.rail-rules { padding: 6px 6px 0; display: grid; gap: 6px; }
.rule-dots { display: flex; flex-wrap: wrap; gap: 5px; }
.rule-dots span { width: 14px; height: 18px; border-radius: 2px; border: 1.5px solid var(--line); background: var(--surface); }
.rule-dots span.is-on { background: var(--accent); border-color: var(--accent); }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; padding: 0 6px; }
.timer { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); display: flex; justify-content: space-between; }
.rail-foot .btn { width: 100%; }

.topbar { display: none; }

.main { padding-block: 28px 80px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.col { max-width: 1020px; margin: 0 auto; }

/* ---------- Station ---------- */
.station { display: flex; flex-direction: column; gap: 28px; animation: rise .35s ease-out both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.station-head { display: grid; gap: 10px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.station-head h1 { font-size: clamp(34px, 5vw, 52px); font-weight: 700; }
.station-head .lede { font-size: 18px; color: var(--ink-2); max-width: 62ch; text-wrap: pretty; }
.station-head .meta { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }

.block { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 18px; }
.block > .tag { font-family: var(--font-mono); font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); padding-top: 6px; }
.block > .tag::before { content: ""; display: block; width: 28px; height: 3px; margin-bottom: 8px; background: var(--guide); }
.block.try > .tag::before { background: var(--accent); }
.block.check > .tag::before { background: var(--ok); }
.block > .body { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.block .prose { max-width: 66ch; display: flex; flex-direction: column; gap: 10px; }
.block .prose p { text-wrap: pretty; }
.block .prose strong { font-weight: 700; }
.directions { background: var(--surface-2); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 0 8px 8px 0; max-width: 72ch; }
.directions b { font-weight: 700; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; min-height: 44px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 700; font-size: 15px; line-height: 1.2; text-decoration: none; color: var(--ink); }
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-ghost { background: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn.sm { padding: 6px 10px; font-size: 13px; min-height: 36px; }
.next-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-top: 8px; border-top: 1px solid var(--line); }
.next-row .status { font-size: 14px; color: var(--ink-2); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 9px 12px; min-height: 40px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 14px; line-height: 1.2; }
.chip:hover { border-color: var(--ink-3); }
.chip.is-on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip.is-ok, .chip.is-on.is-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.chip.is-bad, .chip.is-on.is-bad { background: var(--bad); border-color: var(--bad); color: #fff; }
.chip.is-miss { border-color: var(--warn); border-style: dashed; }
.chip:disabled { cursor: default; }

.fb { padding: 10px 14px; border-radius: 8px; font-size: 15px; border: 1px solid var(--line); background: var(--surface-2); }
.fb.ok { background: var(--ok-soft); border-color: var(--ok); }
.fb.bad { background: var(--bad-soft); border-color: var(--bad); }
.fb.warn { background: var(--warn-soft); border-color: var(--warn); }
.fb.note { background: var(--guide-soft); border-color: var(--guide); }
.fb b { font-weight: 700; }

/* ---------- Form bits ---------- */
.field { display: grid; gap: 6px; }
.field label { font-weight: 700; font-size: 14px; }
.field .hint { font-size: 13px; color: var(--ink-2); font-weight: 400; }
.field input[type="text"], .field select, .field textarea {
  font: inherit; padding: 10px 12px; min-height: 44px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); width: 100%;
}
.field input:focus, .field textarea:focus, .field select:focus { outline: 3px solid var(--focus); outline-offset: 1px; border-color: var(--focus); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr 120px; gap: 14px; }
.writing { display: grid; gap: 8px; }
.writing textarea { font: inherit; font-size: 15.5px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); min-height: 130px; resize: vertical; line-height: 1.55; }
.writing .starters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.writing .starters .chip { font-size: 13px; padding: 6px 10px; min-height: 34px; }
.writing .count { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); }
.writing .count .met { color: var(--ok); font-weight: 700; }
.writing .prompt { font-weight: 700; max-width: 66ch; }

/* multiple choice */
.mc-group { display: grid; gap: 30px; }
.mc-group .mc-note { margin-bottom: -14px; }
.mc { display: grid; gap: 10px; }
.mc + .mc { padding-top: 24px; border-top: 1px solid var(--line); }
.mc .q { font-weight: 700; max-width: 66ch; }
.mc .opts { display: grid; gap: 8px; }
.mc .opt { text-align: left; padding: 10px 14px; min-height: 44px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: grid; grid-template-columns: 26px 1fr; gap: 10px; align-items: start; }
.mc .opt:hover { border-color: var(--ink-3); }
.mc .opt .k { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); padding-top: 3px; }
.mc .opt.is-right { background: var(--ok-soft); border-color: var(--ok); }
.mc .opt.is-wrong { background: var(--bad-soft); border-color: var(--bad); }
.mc .opt:disabled { cursor: default; }
.mc.locked .opt:not(.is-right):not(.is-wrong) { opacity: .6; }

/* ---------- Sheet (notebook paper) ---------- */
.sheet {
  background: var(--sheet); color: var(--sheet-ink); border: 1px solid var(--sheet-rule); box-shadow: var(--shadow); color-scheme: light; border-radius: 4px;
  background-image: linear-gradient(to right, transparent 0, transparent 44px, var(--sheet-margin) 44px, var(--sheet-margin) 45px, transparent 45px), repeating-linear-gradient(to bottom, transparent 0, transparent 27px, var(--sheet-rule) 27px, var(--sheet-rule) 28px);
  background-position: 0 0, 0 14px;
}
.sheet .sheet-in { padding: 14px 20px 18px 60px; }

/* ---------- Signposts ---------- */
.sp-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.sp-card { display: grid; gap: 8px; align-content: start; }
.sp-card h3 { font-size: 22px; }
.sp-card .anchor { font-family: var(--font-display); font-style: italic; font-size: 19px; color: var(--accent); }
.sp-card .when { font-size: 14.5px; color: var(--ink-2); }
.ladder-demo { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; max-width: 72ch; counter-reset: rung; }
.ladder-demo li { display: grid; grid-template-columns: 120px 1fr; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.ladder-demo li:last-child { border-bottom: 1px solid var(--line); }
.rung-k { font-family: var(--font-mono); font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); padding-top: 3px; }
.example { display: grid; gap: 6px; max-width: 72ch; }
.example p { font-size: 15px; }

/* ---------- Story station pieces ---------- */
.story-recap { display: grid; gap: 10px; }
.story-recap .sheet-in { display: grid; gap: 10px; }
.story-recap h3 { font-family: var(--font-display); font-size: 24px; font-weight: 600; color: var(--sheet-ink); }
.story-recap p { font-size: 16px; line-height: 28px; color: var(--sheet-ink); text-wrap: pretty; max-width: 68ch; }
.story-recap .reminder { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--sheet-muted); }
.signpost-call { display: grid; grid-template-columns: auto 1fr; gap: 14px; align-items: start; }
.signpost-call .badge { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; padding: 6px 10px; border-radius: 6px; background: var(--guide-soft); color: var(--ink); border: 1px solid var(--guide); white-space: nowrap; }
.signpost-call .anchor { font-family: var(--font-display); font-style: italic; font-size: clamp(20px, 2.6vw, 26px); line-height: 1.25; color: var(--ink); }

.ladder { display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.rung { display: grid; gap: 8px; padding: 16px 18px; border-top: 1px solid var(--line); }
.rung:first-child { border-top: 0; }
.rung .rung-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.rung .rung-q { font-weight: 700; max-width: 66ch; }
.rung textarea { font: inherit; font-size: 15.5px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); min-height: 76px; resize: vertical; line-height: 1.55; }
.rung .count { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); display: flex; justify-content: space-between; }
.rung .count .met { color: var(--ok); font-weight: 700; }
.rung.is-locked { opacity: .55; }
.rung.is-locked textarea, .rung.is-locked input { pointer-events: none; }
.both { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.both .field input { min-height: 44px; }
.both .and { display: grid; place-items: center; font-family: var(--font-display); font-style: italic; font-size: 20px; color: var(--accent); }
.rung .nudge { font-size: 14.5px; }

.rule-card { display: grid; gap: 10px; }
.rule-card .sheet-in { display: grid; gap: 8px; }
.rule-card .rule-k { font-family: var(--font-mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.rule-card blockquote { margin: 0; font-family: var(--font-display); font-size: 20px; line-height: 28px; color: var(--sheet-ink); font-weight: 500; }
.rule-card .also { font-size: 14.5px; line-height: 28px; color: var(--sheet-muted); }
.rule-card .own { display: grid; gap: 6px; }
.rule-card .own label { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--sheet-muted); }
.rule-card .own textarea { font-family: var(--font-hand); font-size: 24px; line-height: 28px; padding: 0 4px; border: 0; border-bottom: 2px solid var(--guide); background: transparent; color: var(--sheet-ink); min-height: 56px; resize: vertical; width: 100%; }
.rule-card .own textarea:focus { outline: none; border-bottom-color: var(--accent); }
.rule-card .own .count { font-family: var(--font-mono); font-size: 12px; color: var(--sheet-muted); }
.rule-card .own .count .met { color: var(--ok); font-weight: 700; }

/* happened / seemed sorter */
.sort-list { display: grid; gap: 10px; }
.sort-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 14px; }
.sort-row .ans { display: flex; gap: 6px; }
.sort-row .why { grid-column: 1 / -1; font-size: 14px; color: var(--ink-2); }
.sort-row.is-right { border-color: var(--ok); }
.sort-row.is-wrong { border-color: var(--bad); }

/* pairs */
.pairs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 760px; }
.pairs .col-l, .pairs .col-r { display: grid; gap: 8px; }
.pair-btn { text-align: left; padding: 12px 14px; min-height: 48px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-family: var(--font-display); font-size: 18px; }
.pair-btn:hover { border-color: var(--ink-3); }
.pair-btn.is-on { border-color: var(--accent); background: var(--accent-soft); }
.pair-btn.is-done { border-color: var(--ok); background: var(--ok-soft); cursor: default; }
.pair-btn.is-bad { border-color: var(--bad); background: var(--bad-soft); }

/* tellings */
.tellings { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.telling { display: grid; gap: 8px; align-content: start; }
.telling .k { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.telling .where { font-size: 14px; color: var(--ink-2); }
.telling textarea { font: inherit; font-size: 15px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); min-height: 72px; resize: vertical; }

/* rulebook */
.rule-rank { display: grid; gap: 8px; }
.rank-row { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 12px; }
.rank-row .n { font-family: var(--font-display); font-size: 24px; font-weight: 700; color: var(--ink-3); text-align: center; }
.rank-row.is-top .n { color: var(--accent); }
.rank-row .txt { display: grid; gap: 2px; min-width: 0; }
.rank-row .txt b { font-size: 15.5px; }
.rank-row .txt .own { font-family: var(--font-hand); font-size: 19px; color: var(--ink-2); line-height: 1.2; }
.rank-row .txt .own.empty { font-family: var(--font-ui); font-size: 13px; color: var(--warn); }
.rank-row .ctl { display: flex; gap: 6px; }
.rank-row .ctl .btn { padding: 6px 10px; min-width: 44px; }
.rank-row.is-doubt { border-color: var(--warn); }
.doubt-box { grid-column: 1 / -1; display: grid; gap: 6px; }
.doubt-box textarea { font: inherit; font-size: 15px; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); min-height: 64px; resize: vertical; }

/* the test */
.test-nav { display: flex; flex-wrap: wrap; gap: 8px; }
.test-nav .chip.is-done::after { content: " ✓"; }
.test-item { display: grid; gap: 16px; }
.test-item .sheet-in h3 { font-family: var(--font-display); font-size: 26px; font-weight: 600; margin-bottom: 8px; color: var(--sheet-ink); }
.test-item .sheet-in p { font-size: 17px; line-height: 28px; color: var(--sheet-ink); max-width: 66ch; text-wrap: pretty; }
.test-item .wc { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--sheet-muted); margin-top: 8px; }
.verdict { display: grid; gap: 10px; }
.verdict .v-row { display: flex; gap: 8px; flex-wrap: wrap; }
.verdict .v-btn { padding: 10px 16px; min-height: 44px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 700; }
.verdict .v-btn.is-on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.tagger { display: grid; gap: 8px; }
.tagger .eyebrow { margin-top: 4px; }
.tag-rule { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); }
.tag-rule:first-of-type { border-top: 0; }
.tag-rule .tr-name { font-size: 14.5px; }
.tag-rule .tr-ctl { display: flex; gap: 4px; }
.tag-rule .tr-ctl .chip { font-size: 12px; padding: 6px 10px; min-height: 36px; }
.tag-rule .tr-ctl .chip.is-on.follows { background: var(--ok); border-color: var(--ok); color: #fff; }
.tag-rule .tr-ctl .chip.is-on.breaks { background: var(--bad); border-color: var(--bad); color: #fff; }
.key-box { display: grid; gap: 8px; }
.key-box .key-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.key-box .key-tags span { font-family: var(--font-mono); font-size: 11px; padding: 3px 8px; border-radius: 4px; border: 1px solid var(--line); }
.key-box .key-tags span.f { border-color: var(--ok); color: var(--ok); }
.key-box .key-tags span.b { border-color: var(--bad); color: var(--bad); }

/* your story */
.story-rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.story-rules li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: start; padding: 10px 12px; border-radius: 8px; background: var(--surface-2); }
.story-rules input[type="checkbox"] { width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--accent); }
.story-rules .own { font-family: var(--font-hand); font-size: 20px; line-height: 1.2; color: var(--ink-2); }
.story-rules .own.empty { font-family: var(--font-ui); font-size: 13px; color: var(--warn); }
.plan-grid { display: grid; gap: 14px; }
.plan-grid .field textarea { min-height: 64px; resize: vertical; line-height: 1.5; }
.plan-grid .field .count { font-family: var(--font-mono); font-size: 12px; color: var(--ink-2); }
.plan-grid .field .count .met { color: var(--ok); font-weight: 700; }

/* ---------- Turn in ---------- */
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.checklist li { display: grid; grid-template-columns: 24px 1fr; gap: 10px; align-items: start; padding: 8px 10px; border-radius: 6px; background: var(--surface-2); font-size: 15px; }
.checklist li .ck { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); margin-top: 1px; }
.checklist li.done .ck { background: var(--ok); border-color: var(--ok); }
.checklist li.done { color: var(--ink-2); }
.checklist li button { background: none; border: 0; color: var(--link); cursor: pointer; padding: 0; font-weight: 700; text-decoration: underline; }
.summary-preview { max-height: 360px; overflow: auto; font-size: 14px; }
.summary-preview h3 { font-size: 16px; margin-top: 12px; font-family: var(--font-ui); }
.summary-preview p { white-space: pre-wrap; }

/* ---------- Drawer / toast / modal ---------- */
.drawer { position: fixed; top: env(safe-area-inset-top, 0px); right: 0; bottom: 0; width: min(440px, 92vw); background: var(--surface); border-left: 1px solid var(--line); box-shadow: var(--shadow); z-index: 40; transform: translateX(100%); transition: transform .3s ease; display: flex; flex-direction: column; padding-right: env(safe-area-inset-right, 0px); }
.drawer.open { transform: none; }
.drawer header { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.drawer header h2 { font-size: 22px; }
.drawer .body { overflow-y: auto; padding: 14px 18px 30px; }
.drawer dl { margin: 0; display: grid; gap: 10px; }
.drawer dt { font-weight: 700; }
.drawer dd { margin: 0 0 6px; color: var(--ink-2); font-size: 14.5px; }
.drawer input { width: 100%; font: inherit; padding: 9px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); margin-bottom: 12px; }
.rule-cards { display: grid; gap: 10px; }
.rule-mini { padding: 10px 12px 12px 48px; display: grid; gap: 4px; }
.rule-mini .k { font-family: var(--font-mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.rule-mini .own { font-family: var(--font-hand); font-size: 22px; line-height: 28px; color: var(--sheet-ink); }
.rule-mini .own.empty { font-family: var(--font-ui); font-size: 13px; color: var(--sheet-muted); }
.rule-mini .q { font-size: 13px; color: var(--sheet-muted); line-height: 1.4; }
.rule-mini .sheet-in { padding: 0; }
.scrim { position: fixed; inset: 0; background: rgba(20, 16, 8, .35); z-index: 30; }
.toast { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); top: calc(16px + env(safe-area-inset-top, 0px)); transform: translateY(-10px); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 14px; opacity: 0; transition: opacity .25s, transform .25s; z-index: 50; max-width: calc(100vw - 32px); pointer-events: none; }
.toast.show { opacity: 1; transform: none; }
.modal { position: fixed; inset: 0; display: grid; place-items: center; z-index: 45; padding: 16px; }
.modal .box { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 22px; max-width: 520px; width: 100%; display: grid; gap: 14px; box-shadow: var(--shadow); }
.modal h2 { font-size: 24px; }

.day-break { border: 2px dashed var(--guide); border-radius: var(--radius); padding: 18px 20px; display: grid; gap: 10px; background: var(--guide-soft); }
.day-break h3 { font-size: 22px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { position: fixed; left: 0; top: env(safe-area-inset-top, 0px); bottom: 0; height: auto; width: min(320px, 88vw); z-index: 40; transform: translateX(-100%); transition: transform .3s ease; box-shadow: var(--shadow); }
  .rail.open { transform: none; }
  .rail .rail-close { display: inline-flex; }
  .topbar { display: flex; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); align-items: center; gap: 10px; padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
  .topbar .brand .mark { font-size: 20px; }
  .topbar select { font: inherit; font-size: 14px; padding: 6px 8px; min-height: 40px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); min-width: 0; flex: 1; }
  .topbar .btn.sm { white-space: nowrap; }
  .block { grid-template-columns: 1fr; gap: 8px; }
  .block > .tag::before { display: inline-block; margin: 0 8px 0 0; vertical-align: middle; }
  .form-grid { grid-template-columns: 1fr; }
  .main { padding-block: 18px 60px; }
  .ladder-demo li { grid-template-columns: 1fr; gap: 4px; }
}
@media (max-width: 560px) {
  .station-head h1 { font-size: 32px; }
  .both { grid-template-columns: 1fr; }
  .both .and { padding: 2px 0; }
  .pairs { grid-template-columns: 1fr; }
  .pair-btn { font-size: 16px; }
  .sort-row { grid-template-columns: 1fr; }
  .signpost-call { grid-template-columns: 1fr; }
  .rank-row { grid-template-columns: 30px minmax(0, 1fr); }
  .rank-row .ctl { grid-column: 1 / -1; justify-content: flex-end; }
  .sheet .sheet-in { padding-left: 52px; padding-right: 14px; }
  .tag-rule { grid-template-columns: 1fr; }
}
@media (hover: none) and (pointer: coarse) {
  .kbd-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-delay: 0s !important; transition-duration: .001s !important; }
}
