/* 穗子学习站 · 手绘童书。规则见 .stitch/DESIGN.md、MOTION.md、ANTI-PATTERNS.md */
:root {
  --desk: #F6E9B8; --paper: #FFFDF6; --warm: #FFEF9F; --warm-2: #FFF6CC;
  --ink: #1D1836; --ink-soft: #4C426C; --muted: #6E6487; --line: #E6D9B0; --line-strong: #CDBB86;
  --accent: #FF8A1F; --accent-press: #F07A0C;
  --ok: #23824A; --ok-bg: #E6F4EA; --think: #9A4A0B; --think-bg: #FDF0DC;
  --c: #2F7FC4;
  --font: "PingFang SC", "HarmonyOS Sans SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --sk-a: 255px 15px 225px 15px / 15px 225px 15px 255px;
  --sk-b: 15px 225px 15px 255px / 255px 15px 225px 15px;
  --sk-c: 225px 18px 255px 12px / 12px 255px 18px 225px;
  --press: transform 120ms cubic-bezier(.2, 0, 0, 1), background-color 120ms cubic-bezier(.2, 0, 0, 1);
}
.s-math { --c: #2F7FC4; }
.s-chinese { --c: #D9532A; }
.s-science { --c: #2F8F55; }
.s-morality { --c: #8A5CC2; }
.s-english { --c: #0E7F86; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font-family: var(--font); font-size: 17px; line-height: 1.65;
  background: var(--desk); -webkit-font-smoothing: antialiased; min-height: 100vh; min-height: 100dvh;
}
a { color: inherit; }
h1, h2, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 10px; }
.keep { white-space: nowrap; }
.loading { padding: 64px 20px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.ok { color: var(--ok); }
.err { color: var(--think); min-height: 1.4em; }

/* 手绘圆角 */
.sk-a { border-radius: var(--sk-a); }
.sk-b { border-radius: var(--sk-b); }
.sk-c { border-radius: var(--sk-c); }

/* 按钮：蜡笔橙主按钮 + 白色次按钮，墨线描边 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 18px; border: 2.5px solid var(--ink); border-radius: var(--sk-b);
  background: #fff; font-weight: 700; text-decoration: none; white-space: nowrap;
  transition: var(--press); touch-action: manipulation;
}
.btn:active { transform: scale(.96); background: var(--warm-2); }
.btn.primary { background: var(--accent); }
.btn.primary:active { background: var(--accent-press); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.wide { width: 100%; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }

/* ---------------- 孩子页：一张绘本纸 ---------------- */
.kid { font-size: 19px; }
.page {
  max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; background: var(--paper);
  padding: max(22px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(36px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  display: flex; flex-direction: column;
}
@media (min-width: 640px) {
  .page { min-height: 0; margin: 32px auto 48px; border: 3px solid var(--ink); padding: 30px 32px 36px; }
}
@media (max-width: 639px) { .page { border-radius: 0 !important; } }
.kid-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.kid-head .cat { flex: none; transform: rotate(4deg); margin-top: 2px; }
.date { font-size: 14px; font-weight: 600; color: var(--muted); letter-spacing: .04em; }
.kid-head h1 { font-size: 28px; line-height: 1.35; font-weight: 800; margin-top: 4px; display: inline; }
.wave {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="7"><path d="M0 3.5 Q5 0.5 10 3.5 T20 3.5 T30 3.5 T40 3.5" fill="none" stroke="%23FF8A1F" stroke-width="2.6" stroke-linecap="round"/></svg>');
  background-repeat: repeat-x; background-position: 0 100%; padding-bottom: 9px;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.status {
  align-self: flex-start; display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px 14px;
  margin-top: 18px; padding: 9px 16px; background: var(--warm); border: 2.5px solid var(--ink);
  font-size: 16px; font-weight: 700; transform: rotate(-1deg);
}
.status-stars { display: inline-flex; align-items: center; gap: 6px; }
.status-run::before { content: "·"; margin-right: 14px; color: var(--ink-soft); }

.tasks { list-style: none; margin: 22px 0 0; padding: 0; display: grid; gap: 16px; }
.task {
  position: relative; padding: 16px 16px 16px 24px; background: #fff; border: 2.5px solid var(--ink); overflow: hidden;
}
.task::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 9px; background: var(--c); }
.task.is-next { transform: rotate(.8deg); box-shadow: 0 5px 0 rgba(29, 24, 54, .12); }
.task-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.task-kind { font-size: 14px; font-weight: 700; color: var(--ink-soft); letter-spacing: .04em; }
.task-kind b { color: var(--c); }
.task-title { font-size: 21px; line-height: 1.4; font-weight: 800; margin-top: 4px; }
.task-meta { font-size: 15px; color: var(--muted); margin-top: 2px; }
.task .btn { margin-top: 14px; min-height: 56px; font-size: 19px; }
.done-mark { display: inline-flex; align-items: center; gap: 6px; font-size: 15px; font-weight: 700; color: var(--ok); white-space: nowrap; }
.task.is-done { background: #FFFEF9; }
.task.is-done .task-title { color: var(--ink-soft); }
.task-foot.got { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 15px; font-weight: 700; color: var(--ink-soft); }
.stars { display: inline-flex; gap: 3px; align-items: center; }
.star { display: block; }
.empty { margin-top: 22px; padding: 18px; background: #fff; border: 2.5px dashed var(--line-strong); font-size: 17px; }

.done-card {
  margin-top: 22px; padding: 20px; background: var(--warm-2); border: 2.5px solid var(--ink);
  display: grid; gap: 8px; justify-items: center; text-align: center;
}
.done-art { position: relative; }
.done-art .paw { position: absolute; right: -26px; bottom: 2px; transform: rotate(-14deg); }
.done-card .big { font-size: 23px; font-weight: 800; }
.done-card p { font-size: 17px; color: var(--ink-soft); }
.done-card .btn { margin-top: 6px; min-height: 52px; }
.kid-foot { margin-top: auto; padding-top: 30px; text-align: center; }
.kid-foot a { display: inline-block; padding: 10px 6px 4px; color: var(--muted); font-size: 15px; text-decoration: none; border-bottom: 2px dashed var(--line-strong); }

/* ---------------- 做题 ---------------- */
.p-head { display: flex; align-items: center; gap: 12px; }
.back {
  display: inline-flex; align-items: center; min-height: 48px; padding: 0 14px; background: #fff;
  border: 2.5px solid var(--ink); font-size: 16px; font-weight: 700; text-decoration: none; white-space: nowrap; transition: var(--press);
}
.back:active { transform: scale(.96); background: var(--warm-2); }
.crumb { font-size: 15px; font-weight: 700; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb b { color: var(--c); }
.dots { margin-left: auto; display: flex; gap: 9px; align-items: center; flex: none; }
.d { width: 14px; height: 14px; border-radius: 50%; border: 2.5px solid var(--ink); background: #fff; }
.d.now { background: var(--accent); border-color: var(--ink); transform: scale(1.2); }
.d.ok { background: var(--ok); border-color: var(--ok); }
.d.retry { background: var(--think); border-color: var(--think); }
.q-card { display: grid; gap: 16px; margin-top: 20px; }
.know {
  justify-self: start; padding: 6px 14px; background: var(--warm); border: 2.5px solid var(--ink);
  font-size: 15px; font-weight: 700; transform: rotate(-1.2deg); max-width: 100%;
}
.prompt { font-size: 24px; line-height: 1.5; font-weight: 800; }
.fig { color: var(--ink); background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 8px; }
.fig svg { display: block; width: 100%; height: auto; max-height: 240px; }
.choices { display: grid; gap: 12px; }
.choices.fig-row { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
.choice {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 62px; padding: 10px 16px; text-align: left;
  background: #fff; border: 2.5px solid var(--ink); font-size: 20px; font-weight: 600; transition: var(--press); touch-action: manipulation;
}
.choice:active:not(:disabled) { transform: scale(.98); background: var(--warm-2); }
.choice:disabled { cursor: default; color: var(--ink-soft); border-color: var(--line-strong); }
.choice.right { background: var(--ok-bg); border-color: var(--ok); color: var(--ink); }
.choice.wrong { background: var(--think-bg); border-color: var(--think); color: var(--ink); }
.key-badge {
  flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  background: var(--warm); border: 2.5px solid var(--ink); font-size: 17px; font-weight: 800;
}
.choice:disabled .key-badge { border-color: var(--line-strong); }
.choice.right .key-badge { background: var(--ok); border-color: var(--ok); color: #fff; }
.choice.wrong .key-badge { background: var(--think); border-color: var(--think); color: #fff; }
.c-text { flex: 1; }
.c-flag { flex: none; font-size: 15px; font-weight: 700; color: var(--ok); }
.fig-row .choice { flex-direction: column; text-align: center; }
.fig-row .fig { border: 0; padding: 0; }
.fig-row .fig svg { max-height: 110px; }

.answer-box {
  min-height: 70px; display: grid; place-items: center; padding: 8px 16px; background: #fff; border: 2.5px solid var(--ink);
  font-size: 34px; font-weight: 800; letter-spacing: 2px; font-variant-numeric: tabular-nums;
}
.answer-box.placeholder { border-style: dashed; border-color: var(--line-strong); font-size: 17px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.key {
  min-height: 62px; background: #fff; border: 2.5px solid var(--ink); font-size: 28px; font-weight: 800;
  font-variant-numeric: tabular-nums; transition: var(--press); touch-action: manipulation;
}
.key:active { transform: scale(.94); background: var(--warm-2); }
.key.util { background: var(--warm); font-size: 20px; }
.keypad .submit { grid-column: 1 / -1; min-height: 60px; font-size: 21px; }
.quiet {
  justify-self: center; min-height: 44px; padding: 8px 4px 2px; background: none; border: 0; border-bottom: 2px dashed var(--line-strong);
  color: var(--muted); font-size: 16px;
}
.feedback { margin-top: 18px; padding: 16px 18px 18px; background: #fff; border: 2.5px solid var(--ink); display: grid; gap: 8px; }
.feedback.ok { background: var(--ok-bg); }
.feedback.retry { background: var(--think-bg); }
.verdict { display: flex; align-items: center; gap: 8px; font-size: 24px; font-weight: 800; }
.feedback.ok .verdict { color: var(--ok); }
.feedback.retry .verdict { color: var(--think); }
.answer-line { font-size: 18px; }
.explain { font-size: 17px; line-height: 1.7; color: var(--ink-soft); }
.feedback .btn { margin-top: 8px; min-height: 58px; font-size: 20px; }
.two { display: flex; gap: 12px; flex-wrap: wrap; }
.pop { display: inline-flex; animation: pop 420ms cubic-bezier(.2, 0, 0, 1) both; }
@keyframes pop { 0% { transform: scale(.2) rotate(-40deg); opacity: 0; } 60% { transform: scale(1.3) rotate(8deg); opacity: 1; } 100% { transform: scale(1) rotate(0); } }

.finish { margin-top: 26px; display: grid; gap: 12px; justify-items: center; text-align: center; }
.finish-art { position: relative; margin-bottom: 4px; }
.finish-art .paw { position: absolute; right: -30px; bottom: 0; transform: rotate(-14deg); }
.finish h2 { font-size: 24px; line-height: 1.4; font-weight: 800; }
.finish p { font-size: 18px; color: var(--ink-soft); max-width: 22em; }
.finish .stars { gap: 8px; }
.finish .btn { margin-top: 10px; min-height: 58px; font-size: 20px; }

/* ---------------- 家长页：同一套纸与墨，更安静 ---------------- */
.mode-parent { font-size: 15px; }
.parent { max-width: 980px; margin: 0 auto; padding: max(20px, env(safe-area-inset-top)) 16px 48px; }
.parent.narrow { max-width: 440px; padding-top: 48px; }
.parent h1 { font-size: 26px; line-height: 1.3; font-weight: 800; }
.p-top { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.flash { margin-bottom: 14px; padding: 10px 14px; border-radius: 12px; background: var(--ok-bg); border: 2px solid var(--ok); }
.callout {
  margin-bottom: 14px; padding: 12px 14px; border-radius: var(--sk-c); background: var(--warm); border: 2.5px solid var(--ink);
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: space-between; font-weight: 600;
}
.grid { display: grid; gap: 16px; }
@media (min-width: 860px) { .grid { grid-template-columns: 1fr 1fr; align-items: start; } .grid > .card:first-child { grid-column: 1 / -1; } }
.card { background: var(--paper); border: 2px solid var(--ink); border-radius: 18px; padding: 16px 18px 18px; display: grid; gap: 12px; min-width: 0; }
.card h2 { font-size: 18px; font-weight: 800; }
.card.error { max-width: 520px; margin: 48px auto; }
.gate { margin-top: 16px; border-radius: var(--sk-a); }
.gate label { font-size: 19px; font-weight: 700; }
.gate input { min-height: 52px; padding: 8px 14px; border: 2.5px solid var(--ink); border-radius: 12px; font-size: 24px; width: 100%; background: #fff; }
.chip {
  display: inline-block; padding: 0 9px; border-radius: 999px; background: #fff; border: 2px solid var(--c); color: var(--ink);
  font-size: 12.5px; font-weight: 700; line-height: 1.7; white-space: nowrap;
}
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 520px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kpi { display: grid; padding: 10px 12px; border-radius: 12px; background: #fff; border: 1.5px solid var(--line); }
.kpi strong { font-size: 24px; line-height: 1.25; font-weight: 800; font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: 13px; }
.strip { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 4px; }
@media (max-width: 520px) { .strip { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
.strip li { display: grid; justify-items: center; gap: 2px; padding: 6px 0; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; font-size: 12px; font-variant-numeric: tabular-nums; min-height: 66px; }
.strip .dn { color: var(--muted); }
.strip .mk { font-weight: 800; font-size: 14px; }
.strip .mn { color: var(--muted); font-size: 11px; }
.strip .full { background: var(--ok-bg); border-color: var(--ok); }
.strip .full .mk { color: var(--ok); }
.strip .part { background: var(--warm-2); border-color: var(--accent); }
.strip .miss { border-style: dashed; border-color: var(--line-strong); }
.strip .none { opacity: .55; }
.plain { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.plain li { line-height: 1.75; }
.prog { display: grid; gap: 6px; }
.prog-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.prog-head strong { color: var(--c); }
.prog-head .muted { font-size: 13px; }
.bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; border: 2px solid var(--ink); background: #fff; }
.seg.mastered { background: var(--ok); }
.seg.learning { background: var(--accent); }
.seg.weak { background: var(--think); }
.seg.untouched { background: transparent; }
.legend { font-size: 13px; color: var(--muted); }
.links { display: inline-flex; gap: 12px; margin-left: 6px; flex-wrap: wrap; font-size: 14px; }
.links a, .linkish { color: #2B5E99; text-underline-offset: 3px; }
.linkish { background: none; border: 0; padding: 0; text-decoration: underline; font-size: 14px; }
.mistake { padding: 10px 12px; border-left: 5px solid var(--c); background: #fff; border-radius: 8px; display: grid; gap: 4px; }
.mk-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-weight: 700; }
.mk-head .muted { font-weight: 400; font-size: 13px; margin-left: auto; }
.mk-q { font-size: 16px; }
.field { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.field.inline { display: flex; align-items: center; gap: 8px; }
.field select { min-height: 44px; padding: 6px 10px; border: 2px solid var(--ink); border-radius: 10px; background: #fff; font-size: 15px; color: var(--ink); max-width: 100%; }
.subj-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 6px 0; border-top: 1.5px dashed var(--line); }
.subj-row .field.inline { flex: 1; min-width: 0; }
.subj-row select { flex: 1; min-width: 0; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; min-width: 120px; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--ink); }
@media (max-width: 560px) { .subj-row .field.inline { flex-basis: 100%; } .check { min-width: 0; } }
#import-file { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

@media (max-width: 380px) {
  .kid { font-size: 18px; }
  .kid-head h1 { font-size: 25px; }
  .kid-head .cat { width: 60px; height: 48px; }
  .prompt { font-size: 22px; }
  .key { min-height: 56px; }
  .p-head { gap: 8px; }
  .crumb { font-size: 14px; }
}
@media (max-height: 700px) and (max-width: 639px) {
  .page { padding-top: max(14px, env(safe-area-inset-top)); }
  .q-card { gap: 12px; margin-top: 14px; }
  .prompt { font-size: 22px; }
  .answer-box { min-height: 58px; }
  .keypad { gap: 9px; }
  .key { min-height: 54px; }
  .keypad .submit { min-height: 54px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .btn:active, .choice:active, .key:active, .back:active { transform: none !important; }
}

