/* Layout: an indigo dojo banner over a pale, indigo-tinted paper floor; one centred column
   (max 1080px) of cards; the writer splits into notebook + Sensei panel on wide screens.
   Belt colours are the only bright accents; vermilion is kept for seal stamps. */
:root {
  --paper: #f3f4f9;
  --sheet: #ffffff;
  --sheet-2: #f8f9fc;
  --ink: #1b2143;
  --ink-soft: #5b6188;
  --rule: #dde0ee;
  --rule-strong: #c4c9de;
  --indigo: #252d5c;
  --indigo-2: #323b74;
  --on-indigo: #eef0fb;
  --btn: #2d3a8c;
  --btn-ink: #ffffff;
  --accent: #3446b0;
  --seal: #c5352b;
  --gold: #c98a12;
  --good: #1f7a4a;
  --good-bg: #e3f3ea;
  --warn: #9a5b06;
  --warn-bg: #fcf0d9;
  --bad: #b3261e;
  --bad-bg: #fbe6e4;
  --mark-fix: rgba(214, 58, 44, 0.16);
  --mark-fix-line: #d23a2c;
  --mark-tip: rgba(226, 158, 18, 0.2);
  --mark-tip-line: #d99a10;
  --notebook-margin: rgba(197, 53, 43, 0.35);
  --shadow: 0 1px 2px rgba(27, 33, 67, 0.06), 0 6px 18px rgba(27, 33, 67, 0.06);
  --font-display: "Dela Gothic One", "Arial Black", "Helvetica Neue", system-ui, sans-serif;
  --font-body: "Andika", "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;
  --radius: 12px;
  --radius-sm: 8px;
  color-scheme: light;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #10132a;
    --sheet: #181c39;
    --sheet-2: #1d2244;
    --ink: #e8eaf8;
    --ink-soft: #a2a8cf;
    --rule: #2b3160;
    --rule-strong: #3b4276;
    --indigo: #0b0e22;
    --indigo-2: #161a3a;
    --on-indigo: #e8eaf8;
    --btn: #5466d6;
    --btn-ink: #ffffff;
    --accent: #95a4ff;
    --seal: #ec5b4f;
    --gold: #f1b745;
    --good: #66d39a;
    --good-bg: #16352a;
    --warn: #f3b555;
    --warn-bg: #3a2c12;
    --bad: #ff8278;
    --bad-bg: #3e1c1c;
    --mark-fix: rgba(255, 112, 100, 0.26);
    --mark-fix-line: #ff7b70;
    --mark-tip: rgba(255, 196, 76, 0.22);
    --mark-tip-line: #f3b555;
    --notebook-margin: rgba(236, 91, 79, 0.4);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #10132a;
  --sheet: #181c39;
  --sheet-2: #1d2244;
  --ink: #e8eaf8;
  --ink-soft: #a2a8cf;
  --rule: #2b3160;
  --rule-strong: #3b4276;
  --indigo: #0b0e22;
  --indigo-2: #161a3a;
  --on-indigo: #e8eaf8;
  --btn: #5466d6;
  --btn-ink: #ffffff;
  --accent: #95a4ff;
  --seal: #ec5b4f;
  --gold: #f1b745;
  --good: #66d39a;
  --good-bg: #16352a;
  --warn: #f3b555;
  --warn-bg: #3a2c12;
  --bad: #ff8278;
  --bad-bg: #3e1c1c;
  --mark-fix: rgba(255, 112, 100, 0.26);
  --mark-fix-line: #ff7b70;
  --mark-tip: rgba(255, 196, 76, 0.22);
  --mark-tip-line: #f3b555;
  --notebook-margin: rgba(236, 91, 79, 0.4);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 18px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.55;
}
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  height: env(safe-area-inset-top, 0px);
  z-index: 10;
  background: var(--indigo);
}
img, svg { max-width: 100%; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; text-wrap: balance; }
h1, h2 { font-family: var(--font-display); font-weight: 400; letter-spacing: 0.01em; }
h1 { font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.15rem); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.08rem; font-weight: 700; }
h4 { font-size: 0.95rem; font-weight: 700; }
p { margin: 0; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--ink-soft); }
.small { font-size: 0.85rem; }
.block { display: block; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.zh { color: var(--ink-soft); font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif; }
.icon { width: 1.15em; height: 1.15em; flex: none; vertical-align: -0.2em; }
.eyebrow {
  display: flex; align-items: center; gap: 0.45rem; flex-wrap: wrap;
  font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft);
}
.lede { color: var(--ink-soft); max-width: 62ch; }
.section-title { font-size: 1.1rem; }

/* ---------- banner ---------- */
.bar {
  background-color: var(--indigo);
  background-image:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 14px),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, 0.035) 0 1px, transparent 1px 14px);
  color: var(--on-indigo);
}
.bar-inner, .tabs-inner, main, .foot {
  max-width: 1080px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.bar-inner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding-block: 0.85rem; }
.brand { display: flex; align-items: center; gap: 0.75rem; color: inherit; text-decoration: none; min-width: 0; }
.brand-seal {
  display: grid; place-items: center; width: 2.6rem; height: 2.6rem; flex: none;
  background: var(--seal); color: #fff; border-radius: 6px;
  font-family: var(--font-display); font-size: 1.45rem; line-height: 1;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.25);
  transform: rotate(-4deg);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; min-width: 0; }
.brand-text small { font-size: 0.8rem; opacity: 0.8; letter-spacing: 0.04em; }
.brand-text strong { font-family: var(--font-display); font-weight: 400; font-size: 1.3rem; }
.bar-stats { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.pill {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.3rem 0.7rem; border-radius: 999px;
  background: rgba(255, 255, 255, 0.09); font-weight: 700; font-size: 0.92rem;
  font-variant-numeric: tabular-nums;
}
.pill .icon { color: var(--gold); }
.pill.streak .icon { color: #ff8a4c; }
.belt-chip .belt-svg { width: 34px; height: auto; }
.belt-chip .belt-svg [stroke-dasharray] { stroke: var(--on-indigo); opacity: 0.7; }
.belt-chip { padding-left: 0.45rem; }

.tabs { background: var(--indigo-2); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; }
.tabs-inner { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 0.25rem; padding-block: 0.3rem; }
.tabs a {
  display: flex; align-items: center; justify-content: center; gap: 0.45rem;
  padding: 0.55rem 0.4rem; border-radius: 8px;
  color: var(--on-indigo); opacity: 0.78; text-decoration: none; font-weight: 700; font-size: 0.95rem;
}
.tabs a:hover { opacity: 1; background: rgba(255, 255, 255, 0.06); }
.tabs a.active { opacity: 1; background: rgba(255, 255, 255, 0.13); box-shadow: inset 0 -3px 0 var(--seal); }
@media (max-width: 560px) {
  .tabs a { flex-direction: column; gap: 0.1rem; font-size: 0.72rem; padding: 0.45rem 0.1rem; }
  .tabs .icon { width: 1.35em; height: 1.35em; }
  .brand-text strong { font-size: 1.1rem; }
  .bar-stats { gap: 0.35rem; }
  .pill { font-size: 0.82rem; padding: 0.25rem 0.55rem; }
  .belt-chip span { display: none; }
}

main { padding-block: 1.6rem 3rem; display: flex; flex-direction: column; gap: 1.4rem; }
.foot { padding-block: 0 2.2rem; display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; color: var(--ink-soft); font-size: 0.85rem; }
.foot a { color: inherit; }

/* ---------- surfaces ---------- */
.card {
  background: var(--sheet);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem;
  box-shadow: var(--shadow);
  min-width: 0;
}
.page-head { display: flex; flex-direction: column; gap: 0.4rem; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr)); gap: 1.2rem; align-items: start; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font: inherit; font-weight: 700; font-size: 0.98rem;
  padding: 0.6rem 1.1rem; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--rule-strong); background: var(--sheet); color: var(--ink);
  text-decoration: none; line-height: 1.2;
  transition: transform 0.08s ease, background 0.15s ease;
}
.btn:hover { background: var(--sheet-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--btn); border-color: var(--btn); color: var(--btn-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn.ghost:hover { background: var(--sheet-2); }
.btn.small { font-size: 0.86rem; padding: 0.4rem 0.8rem; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.danger-text { color: var(--bad) !important; }
.btn.seal-btn { background: var(--seal); border-color: var(--seal); color: #fff; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center; }
.actions.center { justify-content: center; }

.chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.chip {
  font: inherit; font-size: 0.9rem; font-weight: 700; cursor: pointer;
  padding: 0.35rem 0.85rem; border-radius: 999px;
  border: 1.5px solid var(--rule-strong); background: var(--sheet); color: var(--ink-soft); text-decoration: none;
}
.chip.small { font-size: 0.8rem; padding: 0.25rem 0.65rem; }
.chip.on { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ---------- seal stamp ---------- */
.seal {
  display: inline-block; flex: none;
  font-family: var(--font-display); color: var(--seal);
  border: 2.5px solid var(--seal); border-radius: 6px;
  padding: 0.12rem 0.45rem; font-size: 0.72rem; letter-spacing: 0.1em;
  transform: rotate(-7deg);
  box-shadow: inset 0 0 0 1.5px var(--sheet), inset 0 0 0 3px var(--seal);
  opacity: 0.92;
}
.seal.big { font-size: 1.5rem; padding: 0.3rem 0.9rem; border-width: 4px; }
.seal.corner { position: absolute; top: 1rem; right: 1rem; }
.stamp { animation: stamp 0.45s cubic-bezier(0.2, 1.6, 0.4, 1) both; }
@keyframes stamp {
  from { transform: rotate(-7deg) scale(2.2); opacity: 0; }
  to { transform: rotate(-7deg) scale(1); opacity: 0.92; }
}

/* ---------- belts ---------- */
.belt-svg { display: block; overflow: visible; }
.belt-dot { display: inline-block; width: 0.8rem; height: 0.8rem; border-radius: 3px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25); }

/* ---------- dojo home ---------- */
.hero {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 1.6rem; align-items: center;
  background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1.5rem 1.6rem;
}
.hero-text { display: flex; flex-direction: column; gap: 0.55rem; min-width: 0; }
.hero-belt { padding: 0.6rem 0.4rem; }
@media (max-width: 620px) {
  .hero { grid-template-columns: 1fr; gap: 0.6rem; padding: 1.2rem; }
  .hero-belt .belt-svg { width: 110px; height: auto; }
}
.belt-progress { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.3rem; }
.pip { width: 2.1rem; height: 0.6rem; border-radius: 999px; background: var(--rule); }
.pip.done { background: var(--good); }
.pip.test { width: 1rem; background: transparent; border: 2px solid var(--rule-strong); height: 1rem; border-radius: 4px; transform: rotate(45deg); margin: 0 0.25rem; }
.pip.test.ready { border-color: var(--seal); background: var(--seal); }
.pip.test.done { border-color: var(--good); background: var(--good); }
.pip-label { font-size: 0.85rem; color: var(--ink-soft); margin-left: 0.3rem; }

.today { display: flex; flex-direction: column; gap: 0.75rem; }
.today-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: 1rem; }
.today-card { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; }
.today-card .btn { margin-top: auto; }
.today-card.continue { border-color: var(--btn); box-shadow: inset 0 0 0 1px var(--btn), var(--shadow); }

.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.stat-row.compact { gap: 0.6rem; margin: 0.8rem 0 1rem; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 620px) { .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { display: flex; flex-direction: column; padding: 0.85rem 1rem; border-radius: var(--radius-sm); background: var(--sheet); border: 1px solid var(--rule); min-width: 0; }
.stat-value { font-family: var(--font-display); font-size: 1.45rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.2; }
.stat-row.compact .stat-value { font-size: 1.1rem; }
.stat-label { font-size: 0.82rem; color: var(--ink-soft); }

.week-head { display: flex; justify-content: space-between; align-items: baseline; gap: 0.5rem; margin-bottom: 0.8rem; }
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.4rem; }
.day { display: flex; flex-direction: column; align-items: center; gap: 0.3rem; }
.day-cell {
  width: 100%; aspect-ratio: 1; max-width: 3.2rem; border-radius: 8px;
  display: grid; place-items: center; font-size: 0.78rem; font-weight: 700; font-variant-numeric: tabular-nums;
  background: var(--sheet-2); border: 1px solid var(--rule); color: var(--ink);
}
.day-cell.lvl1 { background: color-mix(in srgb, var(--good) 22%, var(--sheet)); }
.day-cell.lvl2 { background: color-mix(in srgb, var(--good) 45%, var(--sheet)); }
.day-cell.lvl3 { background: var(--good); color: var(--sheet); }
.day-cell.is-today { outline: 2px solid var(--accent); outline-offset: 1px; }
.day-name { font-size: 0.75rem; color: var(--ink-soft); }

.path-list { list-style: none; margin: 0.8rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 0.6rem 0.4rem; }
.path-step { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; text-align: center; padding: 0.4rem 0.2rem; border-radius: var(--radius-sm); }
.path-step.locked { opacity: 0.45; }
.path-step.current { background: var(--sheet-2); box-shadow: inset 0 0 0 1.5px var(--accent); }
.path-name { font-weight: 700; font-size: 0.85rem; }
.path-sub { font-size: 0.74rem; color: var(--ink-soft); }

/* ---------- katas ---------- */
.belt-group { display: flex; flex-direction: column; gap: 0.8rem; }
.belt-group-head { display: flex; align-items: center; gap: 1rem; }
.belt-group-head > div { flex: 1; min-width: 0; }
.belt-group-head .rank { font-family: var(--font-body); font-size: 0.85rem; font-weight: 700; }
.belt-group.locked .kata-grid { opacity: 0.55; }
.lock-note { display: flex; align-items: center; gap: 0.5rem; color: var(--ink-soft); font-size: 0.92rem; }
.kata-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 0.9rem; }
.kata-card { display: flex; flex-direction: column; gap: 0.4rem; color: inherit; text-decoration: none; transition: transform 0.12s ease, border-color 0.12s ease; }
a.kata-card:not(.disabled):hover { transform: translateY(-2px); border-color: var(--accent); }
.kata-card.disabled { cursor: default; }
.kata-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding-top: 0.4rem; min-height: 2rem; }
.best { font-weight: 700; font-size: 0.88rem; font-variant-numeric: tabular-nums; }
.test-card { background: var(--sheet-2); border-style: dashed; border-color: var(--rule-strong); }

.runner-head { display: flex; flex-direction: column; gap: 0.4rem; }
.back-link { display: inline-flex; align-items: center; gap: 0.25rem; font-weight: 700; text-decoration: none; font-size: 0.92rem; width: fit-content; }
.round-dots { display: flex; gap: 0.4rem; }
.rdot { width: 2.4rem; height: 0.45rem; border-radius: 999px; background: var(--rule); }
.rdot.now { background: var(--accent); }
.rdot.good { background: var(--good); }
.rdot.half { background: var(--gold); }
.rdot.miss { background: var(--bad); }
.stage { max-width: 760px; }
.round { display: flex; flex-direction: column; gap: 0.9rem; padding: 1.4rem 1.5rem; }
.round-count { font-size: 0.82rem; color: var(--ink-soft); font-weight: 700; }
.q-label { font-weight: 700; }
.q-text { font-size: 1.2rem; font-weight: 700; line-height: 1.45; }
.q-original {
  font-size: 1.15rem; padding: 0.7rem 1rem; border-radius: var(--radius-sm);
  background: var(--sheet-2); border-left: 4px solid var(--rule-strong);
}
.kata-input {
  width: 100%; font: inherit; font-size: 1.15rem; line-height: 1.5;
  padding: 0.75rem 0.9rem; border-radius: var(--radius-sm);
  border: 2px solid var(--rule-strong); background: var(--sheet); color: var(--ink); resize: vertical;
}
.kata-input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.kata-input[readonly] { background: var(--sheet-2); }
.options { display: grid; gap: 0.6rem; }
.options.grid-2 { grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.option {
  font: inherit; font-size: 1.05rem; text-align: left; cursor: pointer;
  padding: 0.8rem 1rem; border-radius: var(--radius-sm);
  border: 2px solid var(--rule-strong); background: var(--sheet); color: var(--ink);
}
.option:hover:not(:disabled) { border-color: var(--accent); }
.option:disabled { cursor: default; }
.option.right { border-color: var(--good); background: var(--good-bg); }
.option.wrong { border-color: var(--bad); background: var(--bad-bg); }
.tile-line, .tile-bank { display: flex; flex-wrap: wrap; gap: 0.5rem; min-height: 3.3rem; padding: 0.6rem; border-radius: var(--radius-sm); }
.tile-line { border: 2px dashed var(--rule-strong); background: var(--sheet-2); align-items: center; }
.tile-hint { color: var(--ink-soft); font-size: 0.92rem; }
.tile {
  font: inherit; font-size: 1.1rem; cursor: pointer;
  padding: 0.4rem 0.8rem; border-radius: 8px;
  border: 1.5px solid var(--rule-strong); border-bottom-width: 3px; background: var(--sheet); color: var(--ink);
}
.tile.placed { border-color: var(--accent); }
.feedback:empty { display: none; }
.feedback { display: flex; flex-direction: column; gap: 0.8rem; }
.note { display: flex; gap: 0.55rem; align-items: flex-start; padding: 0.7rem 0.9rem; border-radius: var(--radius-sm); background: var(--sheet-2); border: 1px solid var(--rule); }
.note .icon { margin-top: 0.2em; }
.note.good { background: var(--good-bg); border-color: transparent; color: var(--ink); }
.note.good .icon { color: var(--good); }
.note.bad { background: var(--bad-bg); border-color: transparent; }
.note.bad .icon { color: var(--bad); }
.note.warn { background: var(--warn-bg); border-color: transparent; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.checklist li { display: flex; gap: 0.5rem; align-items: flex-start; color: var(--ink-soft); font-size: 0.95rem; }
.checklist li .icon { margin-top: 0.15em; color: var(--rule-strong); }
.checklist li.ok { color: var(--ink); }
.checklist li.ok .icon { color: var(--good); }
.model { padding: 0.8rem 1rem; border-radius: var(--radius-sm); background: var(--sheet-2); border: 1px dashed var(--rule-strong); display: flex; flex-direction: column; gap: 0.35rem; }
.model-text { font-size: 1.05rem; }
.result { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 0.8rem; padding: 2rem 1.5rem; }
.result h2 { font-size: 3rem; font-variant-numeric: tabular-nums; }
.xp-lines { list-style: none; margin: 0; padding: 0; width: min(100%, 320px); display: flex; flex-direction: column; gap: 0.3rem; }
.xp-lines li { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px dashed var(--rule); padding: 0.2rem 0; }
.xp-lines strong { color: var(--gold); font-variant-numeric: tabular-nums; }

/* ---------- write ---------- */
.pick-top { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: 1rem; }
.feature { display: flex; flex-direction: column; gap: 0.55rem; align-items: flex-start; padding: 1.4rem; }
.feature .btn { margin-top: 0.4rem; }
.feature.alt { background: var(--sheet-2); }
.prompt-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 0.8rem; margin-top: 0.8rem; }
.prompt-card { display: flex; flex-direction: column; gap: 0.35rem; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.prompt-card:hover { border-color: var(--accent); }
.prompt-title { font-weight: 700; font-size: 1.05rem; }
.stretch { background: var(--warn-bg); color: var(--warn); border-radius: 999px; padding: 0 0.45rem; letter-spacing: 0.04em; }
section > .chips { margin-top: 0.7rem; }

.writer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.writer-head > div { display: flex; flex-direction: column; gap: 0.35rem; min-width: 0; flex: 1 1 320px; }
.task { font-size: 1.05rem; max-width: 70ch; }
.title-input {
  font-family: var(--font-display); font-size: 1.5rem; color: var(--ink);
  border: none; border-bottom: 2px dashed var(--rule-strong); background: transparent; padding: 0.2rem 0; width: 100%;
}
.title-input:focus { outline: none; border-bottom-color: var(--accent); }
.writer-grid { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 1.3rem; align-items: start; }
@media (max-width: 899px) { .writer-grid { grid-template-columns: minmax(0, 1fr); } }
.editor-col { display: flex; flex-direction: column; gap: 0.75rem; min-width: 0; }
.timer { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; color: var(--ink-soft); }
.timer-display { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--ink); min-width: 3.4rem; text-align: center; }
.timer-display.low { color: var(--seal); }
.paper {
  border-radius: var(--radius); border: 1px solid var(--rule); box-shadow: var(--shadow); background: var(--sheet);
  overflow: hidden;
}
.editor {
  --line: 2rem;
  --pad: 0.9rem;
  display: block; width: 100%; min-height: 22rem; resize: vertical;
  font-family: var(--font-body); font-size: 1.15rem; line-height: var(--line); color: var(--ink);
  border: none; outline: none; background-color: var(--sheet);
  padding: var(--pad) 1rem var(--pad) 3.2rem;
  background-image:
    linear-gradient(90deg, transparent 2.4rem, var(--notebook-margin) 2.4rem, var(--notebook-margin) calc(2.4rem + 1.5px), transparent calc(2.4rem + 1.5px)),
    linear-gradient(transparent calc(var(--line) - 1px), var(--rule) calc(var(--line) - 1px));
  background-size: 100% 100%, 100% var(--line);
  background-position: 0 0, 0 var(--pad);
  background-attachment: local;
}
.editor:focus { box-shadow: inset 0 0 0 2px var(--accent); }
.live { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; align-items: center; color: var(--ink-soft); font-size: 0.92rem; }
.live-num { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.live-words { display: flex; align-items: center; gap: 0.6rem; flex: 1 1 220px; }
.meter { flex: 1; height: 0.5rem; border-radius: 999px; background: var(--rule); overflow: hidden; min-width: 80px; }
.meter-fill { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width 0.25s ease; }
.meter-fill.full { background: var(--good); }
.criteria { display: flex; flex-direction: column; gap: 0.5rem; background: var(--sheet-2); }
.writer-actions { padding-top: 0.2rem; }

.coach-panel { background: var(--sheet); border: 1px solid var(--rule); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; overflow: hidden; scroll-margin-top: 4.5rem; }
@media (min-width: 900px) { .coach-panel:not(.static) { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 4rem); max-height: calc(100vh - 5.5rem); overflow-y: auto; } }
.coach-panel.stale .feedback-view { opacity: 0.6; }
.coach-panel.stale .panel-body::before {
  content: "You changed your writing. Press “Check my writing” to update the marks.";
  display: block; margin-bottom: 0.8rem; padding: 0.55rem 0.8rem; border-radius: var(--radius-sm);
  background: var(--warn-bg); color: var(--ink); font-size: 0.88rem;
}
.panel-tabs { display: flex; border-bottom: 1px solid var(--rule); background: var(--sheet-2); position: sticky; top: 0; z-index: 1; }
.panel-tabs button {
  flex: 1; font: inherit; font-weight: 700; font-size: 0.95rem; padding: 0.7rem; cursor: pointer;
  border: none; background: transparent; color: var(--ink-soft); border-bottom: 3px solid transparent;
}
.panel-tabs button.on { color: var(--ink); border-bottom-color: var(--seal); }
.panel-body { padding: 1.1rem 1.2rem 1.3rem; display: flex; flex-direction: column; gap: 1.1rem; }
.empty { display: flex; flex-direction: column; gap: 0.55rem; }
.empty.big { align-items: flex-start; padding: 1.6rem; }
.empty-title { font-family: var(--font-display); font-size: 1.15rem; }

.feedback-view { display: flex; flex-direction: column; gap: 1.1rem; }
.says { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 0.8rem; }
.says-col { padding: 0.8rem 0.9rem; border-radius: var(--radius-sm); display: flex; flex-direction: column; gap: 0.45rem; min-width: 0; }
.says-col.good { background: var(--good-bg); }
.says-col.work { background: var(--warn-bg); }
.says-col ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.93rem; }
.says-col li { display: flex; gap: 0.45rem; align-items: flex-start; overflow-wrap: anywhere; }
.says-col li .icon { margin-top: 0.2em; }
.says-col.good .icon { color: var(--good); }
.says-col.work .icon { color: var(--warn); }
.marked-wrap { display: flex; flex-direction: column; gap: 0.55rem; }
.marked-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.legend { display: flex; gap: 0.4rem; font-size: 0.8rem; }
.marked {
  white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1.02rem; line-height: 1.85;
  padding: 0.8rem 0.9rem; border-radius: var(--radius-sm); background: var(--sheet-2); border: 1px solid var(--rule);
  max-height: 22rem; overflow-y: auto;
}
mark.mk, .mk { color: inherit; border-radius: 3px; padding: 0 1px; cursor: pointer; }
.mk.fix { background: var(--mark-fix); box-shadow: inset 0 -2px 0 var(--mark-fix-line); }
.mk.tip { background: var(--mark-tip); box-shadow: inset 0 -2px 0 var(--mark-tip-line); }
.legend .mk { cursor: default; padding: 0 0.35rem; }
.mark-detail { padding: 0.75rem 0.9rem; border-radius: var(--radius-sm); border: 1.5px dashed var(--rule-strong); display: flex; flex-direction: column; gap: 0.35rem; align-items: flex-start; }
.detail-cat { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; }
.detail-cat.fix { color: var(--mark-fix-line); }
.detail-cat.tip { color: var(--warn); }
.all-notes summary { cursor: pointer; font-weight: 700; }
.note-group { margin-top: 0.8rem; }
.note-group ul { margin: 0.35rem 0 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.92rem; }
.note-group li.fix::marker { color: var(--mark-fix-line); }
.note-group li.tip::marker { color: var(--mark-tip-line); }
.quote { font: inherit; font-weight: 700; color: var(--accent); background: none; border: none; padding: 0; cursor: pointer; text-align: left; overflow-wrap: anywhere; }

.ai-box { border-top: 1px solid var(--rule); padding-top: 1rem; display: flex; flex-direction: column; gap: 0.6rem; }
.ai-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }
.ai-head h3 { display: flex; align-items: center; gap: 0.4rem; }
.ai-text { display: flex; flex-direction: column; gap: 0.45rem; font-size: 0.97rem; }
.ai-text h4 { margin-top: 0.4rem; font-family: var(--font-display); font-weight: 400; font-size: 0.98rem; color: var(--accent); }
.ai-text ul { margin: 0; padding-left: 1.15rem; display: flex; flex-direction: column; gap: 0.3rem; }
.thinking { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.45; } }

/* ---------- scroll ---------- */
.scroll-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 1rem; }
.piece-card { display: flex; flex-direction: column; gap: 0.35rem; color: inherit; text-decoration: none; }
.piece-card:hover { border-color: var(--accent); }
.piece-date { font-size: 0.8rem; color: var(--ink-soft); font-weight: 700; }
.piece-title { font-family: var(--font-display); font-size: 1.1rem; line-height: 1.25; overflow-wrap: anywhere; }
.piece-meta { display: flex; flex-wrap: wrap; gap: 0.4rem 0.7rem; align-items: center; }
.piece-snip { color: var(--ink-soft); font-size: 0.92rem; overflow-wrap: anywhere; }
.tag { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.75rem; font-weight: 700; padding: 0.05rem 0.5rem; border-radius: 999px; background: var(--sheet-2); border: 1px solid var(--rule); }
.piece-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 1.3rem; align-items: start; }
@media (max-width: 899px) { .piece-grid { grid-template-columns: minmax(0, 1fr); } }
.piece-read { position: relative; display: flex; flex-direction: column; gap: 1rem; padding: 1.5rem 1.6rem; }
.piece-text { display: flex; flex-direction: column; gap: 0.85rem; font-size: 1.1rem; line-height: 1.75; overflow-wrap: anywhere; }
.drafts summary { cursor: pointer; font-weight: 700; }
.draft { margin-top: 0.8rem; padding-top: 0.8rem; border-top: 1px dashed var(--rule); }
.draft-text { white-space: pre-wrap; color: var(--ink-soft); font-size: 0.95rem; margin-top: 0.3rem; overflow-wrap: anywhere; }

/* ---------- toolkit ---------- */
.toc { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 3.6rem); z-index: 2; background: var(--paper); padding-block: 0.4rem; }
.tool-section { display: flex; flex-direction: column; gap: 0.6rem; scroll-margin-top: 7.5rem; }
.toolkit-compact { display: flex; flex-direction: column; gap: 0.8rem; }
.word-table { display: flex; flex-direction: column; }
.word-row { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: 0.7rem; padding: 0.5rem 0; border-bottom: 1px dashed var(--rule); align-items: baseline; }
.word-row:last-child { border-bottom: none; }
.tired { font-weight: 700; text-decoration: line-through; text-decoration-color: var(--seal); text-decoration-thickness: 2px; }
.alts { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.alt { padding: 0.1rem 0.55rem; border-radius: 6px; background: var(--sheet-2); border: 1px solid var(--rule); font-size: 0.93rem; }
.groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 1rem; }
.group { display: flex; flex-direction: column; gap: 0.4rem; }
.traps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 0.7rem; }
.traps li { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.7rem 0.85rem; border-radius: var(--radius-sm); border: 1px solid var(--rule); background: var(--sheet-2); }
.traps .bad, .traps .good { display: flex; gap: 0.4rem; align-items: flex-start; }
.traps .bad { color: var(--ink-soft); text-decoration: line-through; text-decoration-color: var(--bad); }
.traps .bad .icon { color: var(--bad); margin-top: 0.2em; }
.traps .good { font-weight: 700; }
.traps .good .icon { color: var(--good); margin-top: 0.2em; }
.coach-panel .traps { grid-template-columns: 1fr; }
.punct-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 0.8rem; }
.punct { display: grid; grid-template-columns: 3rem minmax(0, 1fr); gap: 0.7rem; align-items: start; }
.punct-mark { font-family: var(--font-display); font-size: 1.5rem; text-align: center; color: var(--seal); line-height: 1.3; }
.spell-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 0.35rem 1rem; font-size: 0.95rem; }
.spell s { color: var(--ink-soft); text-decoration-color: var(--bad); }

/* ---------- grown-ups ---------- */
.settings { display: flex; flex-direction: column; gap: 0.45rem; margin: 0.8rem 0; }
.settings label { font-weight: 700; font-size: 0.92rem; }
.settings input:not([type="checkbox"]) {
  font: inherit; padding: 0.55rem 0.75rem; border-radius: var(--radius-sm);
  border: 1.5px solid var(--rule-strong); background: var(--sheet); color: var(--ink); margin-bottom: 0.4rem; max-width: 22rem;
}
.toggle { display: flex !important; gap: 0.6rem; align-items: flex-start; font-weight: 400 !important; cursor: pointer; margin-top: 0.3rem; }
.toggle input { width: 1.15rem; height: 1.15rem; margin-top: 0.2rem; accent-color: var(--btn); flex: none; }
.slips { margin: 0.5rem 0 0; padding-left: 1.3rem; display: flex; flex-direction: column; gap: 0.35rem; }
.slips li span { margin-right: 0.4rem; }
.slips strong { color: var(--seal); font-variant-numeric: tabular-nums; }
.prose { display: flex; flex-direction: column; gap: 0.7rem; }
.prose ul { margin: 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.45rem; max-width: 75ch; }
.prose h2 { margin-top: 0.4rem; }

/* ---------- toast & modal ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(1.2rem + env(safe-area-inset-bottom, 0px)); z-index: 30;
  transform: translate(-50%, 1rem); opacity: 0;
  max-width: calc(100% - 32px); padding: 0.7rem 1.1rem; border-radius: 999px;
  background: var(--ink); color: var(--paper); font-weight: 700; box-shadow: var(--shadow);
  transition: transform 0.25s ease, opacity 0.25s ease;
}
#toast.show { transform: translate(-50%, 0); opacity: 1; }
#modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; }
.modal-back { position: absolute; inset: 0; background: rgba(10, 12, 30, 0.55); }
.modal-box {
  position: relative; width: min(100%, 520px); max-height: calc(100% - 32px); overflow-y: auto;
  background: var(--sheet); color: var(--ink); border-radius: var(--radius); padding: 1.5rem; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.modal-box > div { display: flex; flex-direction: column; gap: 0.8rem; }
.celebrate { align-items: center; text-align: center; }
.celebrate-belt { position: relative; display: grid; place-items: center; padding: 0.6rem 0 0.4rem; }
.celebrate-belt .seal { position: absolute; right: -0.5rem; bottom: 0; }
.copy-fallback { position: fixed; left: -9999px; top: 0; }

/* ---------- placement ---------- */
.invite { display: flex; justify-content: space-between; align-items: center; gap: 1rem 1.5rem; flex-wrap: wrap; border-color: var(--btn); box-shadow: inset 0 0 0 1px var(--btn), var(--shadow); }
.invite > div:first-child { display: flex; flex-direction: column; gap: 0.35rem; flex: 1 1 340px; min-width: 0; }
.round-dots { max-width: 760px; }
.round-dots.many .rdot { width: auto; flex: 1 1 0; max-width: 2.4rem; }
.rdot.done { background: var(--ink-soft); }
.option.picked { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--sheet)); }
.steps { margin: 0; padding-left: 1.3rem; display: flex; flex-direction: column; gap: 0.5rem; }
.round .editor { min-height: 14rem; }
.placement-result .result-title { font-size: 1.6rem; }
.placement-detail { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 1.2rem; text-align: left; width: 100%; margin-top: 0.4rem; }
.placement-detail > div { display: flex; flex-direction: column; gap: 0.5rem; min-width: 0; }

/* ---------- plan & revise ---------- */
.q-note { font-size: 0.95rem; color: var(--ink-soft); font-style: italic; margin-top: -0.4rem; }
.curriculum { color: var(--ink-soft); font-weight: 700; letter-spacing: 0.02em; margin-top: 0.15rem; }
.plan { display: flex; flex-direction: column; gap: 0.75rem; }
.plan-head { display: flex; flex-direction: column; gap: 0.15rem; }
.plan-step { display: flex; flex-direction: column; gap: 0.2rem; }
.plan-step label { display: flex; align-items: center; gap: 0.45rem; font-weight: 700; font-size: 0.95rem; }
.plan-num { display: inline-grid; place-items: center; width: 1.4rem; height: 1.4rem; border-radius: 50%; background: var(--sheet-2); border: 1.5px solid var(--rule-strong); font-size: 0.75rem; flex: none; }
.plan-step textarea { width: 100%; font: inherit; font-size: 0.95rem; padding: 0.45rem 0.6rem; border-radius: var(--radius-sm); border: 1.5px solid var(--rule); background: var(--sheet-2); color: var(--ink); resize: vertical; }
.plan-step textarea:focus { outline: none; border-color: var(--accent); background: var(--sheet); }
.revise-box { border: 1px dashed var(--rule-strong); border-radius: var(--radius-sm); padding: 0.6rem 0.8rem; }
.revise-box summary { cursor: pointer; font-weight: 700; font-size: 0.95rem; }
.revise-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 0.8rem; margin-top: 0.6rem; }
.revise-cols ul, ul.plain { margin: 0.3rem 0 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.92rem; }

/* ---------- named checks, review, transfer ---------- */
.checks { display: flex; flex-direction: column; gap: 0.5rem; }
.check-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.4rem; }
.check { display: grid; grid-template-columns: 7.2rem minmax(0, 1fr); gap: 0.6rem; align-items: start; }
.check-status { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; padding: 0.15rem 0.45rem; border-radius: 6px; text-align: center; }
.check.flag .check-status { background: var(--bad-bg); color: var(--bad); }
.check.clear .check-status { background: var(--good-bg); color: var(--good); }
.check.person .check-status { background: var(--sheet-2); color: var(--ink-soft); border: 1px dashed var(--rule-strong); }
.check-text { display: flex; flex-direction: column; gap: 0.05rem; min-width: 0; }
.round-count.transfer { color: var(--accent); }
.grown-up-check { width: 100%; text-align: left; display: flex; flex-direction: column; gap: 0.5rem; padding: 1rem; border-radius: var(--radius-sm); border: 1.5px dashed var(--rule-strong); background: var(--sheet-2); }
.grown-up-check .sample { margin: 0; padding: 0.6rem 0.8rem; border-left: 3px solid var(--rule-strong); background: var(--sheet); white-space: pre-wrap; overflow-wrap: anywhere; max-height: 12rem; overflow-y: auto; }
.select { font: inherit; padding: 0.45rem 0.6rem; border-radius: var(--radius-sm); border: 1.5px solid var(--rule-strong); background: var(--sheet); color: var(--ink); max-width: 22rem; }
.belt-state { display: flex; flex-direction: column; align-items: flex-end; gap: 0.3rem; text-align: right; }
.review-list { list-style: none; margin: 0.6rem 0 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.review-list li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.8rem; }

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