/* Tutor Potato — design tokens first. Practice/review sheets are deliberately plain black-on-white. */
/* Andika (SIL International, SIL OFL 1.1; licence in fonts/OFL.txt): designed for early readers: plain unslashed 0, distinct 1/l/I, single-storey a and g like children are taught to write. */
@font-face { font-family: 'Andika'; src: url(fonts/andika-400.woff2) format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Andika'; src: url(fonts/andika-700.woff2) format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
:root {
  --bg: #faf7f0; --surface: #fff; --surface-2: #f4efe3; --line: #e8e1d1; --line-2: #d8cfba;
  --ink: #1f2a24; --muted: #66726a; --faint: #8d978f;
  --green: #2f6b4f; --green-2: #245640; --green-soft: #e3efe6; --green-line: #b5d2bf;
  --potato: #c99a52; --potato-soft: #f5e8cf; --amber: #a9631a; --amber-soft: #fbecd2;
  --red: #b3372f; --blue: #1d5fd1; --blue-soft: #e5eefc;
  --radius: 14px; --shadow: 0 1px 2px #3a2f1a0d, 0 8px 24px -12px #3a2f1a26;
  --serif: Georgia, 'Iowan Old Style', 'Palatino Linotype', serif;
  --worksheet: 'Andika', Verdana, 'DejaVu Sans', system-ui, sans-serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .4; cursor: not-allowed; }
h1, h2 { font-family: var(--serif); font-weight: 400; letter-spacing: -.015em; margin: 0; line-height: 1.15; }
h1 { font-size: clamp(30px, 4vw, 40px); } h2 { font-size: 22px; }
p { margin: 0; }
:focus-visible { outline: 3px solid #5f9c7b; outline-offset: 2px; border-radius: 6px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .pad { padding: 22px 26px; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); margin-bottom: 8px; }
.lead { color: var(--muted); font-size: 16px; margin-top: 10px; max-width: 60ch; }
svg { width: 1.15em; height: 1.15em; flex: none; }

/* ----- header ----- */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 24px; height: 68px; padding: 0 max(20px, calc((100vw - 1180px) / 2)); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 4px 6px 4px 0; font: 400 22px var(--serif); letter-spacing: -.02em; }
.brand .potato { width: 34px; height: 29px; }
.tabs { display: flex; gap: 4px; margin-right: auto; }
.tab { white-space: nowrap; border: 0; background: none; padding: 9px 14px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 14px; }
.tab:hover { background: var(--surface-2); color: var(--ink); }
.tab[aria-current] { background: var(--green-soft); color: var(--green-2); }
.profile-chip { margin-left: auto; display: flex; align-items: center; gap: 10px; border: 1px solid var(--line-2); background: var(--surface); border-radius: 999px; padding: 5px 12px 5px 6px; }
.tabs + .profile-chip { margin-left: 0; }
.profile-chip:hover { border-color: var(--green); }
.profile-chip .who { display: flex; flex-direction: column; text-align: left; line-height: 1.15; } .profile-chip small { color: var(--faint); font-size: 11px; }
.avatar { display: inline-grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: var(--potato-soft); font-size: 23px; flex: none; }
.avatar.sm { width: 32px; height: 32px; font-size: 18px; } .avatar.empty { background: var(--green-soft); color: var(--green); }
.toast { position: fixed; z-index: 40; left: 50%; top: 80px; transform: translateX(-50%); max-width: min(92vw, 560px); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow); animation: pop .25s ease-out; }
.paper-mode .toast { top: auto; bottom: 16px; pointer-events: none; }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -8px); } }
.foot { text-align: center; color: var(--faint); font-size: 12px; padding: 30px 20px 40px; }

/* ----- buttons & chips ----- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); padding: 10px 18px; border-radius: 10px; font-weight: 600; font-size: 14px; text-decoration: none; transition: background .12s, border-color .12s, transform .05s; }
.btn:hover:not(:disabled) { border-color: var(--green); } .btn:active:not(:disabled) { transform: translateY(1px); }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; } .btn.primary:hover:not(:disabled) { background: var(--green-2); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.quiet { border-color: transparent; background: none; color: var(--muted); padding-inline: 12px; } .btn.quiet:hover:not(:disabled) { background: var(--surface-2); color: var(--ink); }
.btn.lg { padding: 14px 24px; font-size: 15px; border-radius: 12px; } .btn.small { padding: 7px 14px; font-size: 13px; } .btn.block { width: 100%; }
.link { border: 0; background: none; color: var(--green); font-weight: 600; font-size: 13px; padding: 0; } .link:hover { text-decoration: underline; }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 10px; background: none; color: var(--muted); } .icon-btn:hover { background: var(--surface-2); color: var(--red); }
.chip { display: inline-flex; align-items: center; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.chip.good { background: var(--green-soft); color: var(--green-2); } .chip.warn { background: var(--amber-soft); color: var(--amber); }

/* ----- pages & cards ----- */
.page { max-width: 1180px; margin: 0 auto; padding: 40px 20px 20px; } .page.narrow { max-width: 820px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: 26px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px 26px; box-shadow: var(--shadow); } .card.flush { padding: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 18px; }
.cols { display: grid; grid-template-columns: 1.25fr 1fr; gap: 18px; align-items: start; }
.next-step { display: flex; justify-content: space-between; align-items: center; gap: 28px; padding: 28px 32px; background: linear-gradient(135deg, var(--potato-soft), #f7efdc 60%, #eef3e4); border: 1px solid #e6d6b2; border-radius: 18px; margin-bottom: 18px; }
.next-step.attention { background: linear-gradient(135deg, var(--blue-soft), #eef3fd); border-color: #c5d7f4; }
.next-step p:not(.eyebrow) { color: #5c5a4d; margin-top: 8px; max-width: 56ch; } .next-step .eyebrow { color: #92784a; } .next-step.attention .eyebrow { color: #4a74b8; }
.stack { display: flex; flex-direction: column; gap: 6px; align-items: stretch; text-align: center; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 18px; }
.stats > div { background: var(--surface); padding: 20px 24px; } .stats strong { display: block; font: 600 30px/1.15 var(--sans); letter-spacing: -.02em; } .stats strong small { font-size: 16px; color: var(--faint); } .stats span { font-size: 13px; color: var(--muted); }
.plain { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); } .row:first-child { border-top: 0; padding-top: 0; }
.row > div { flex: 1; display: flex; flex-direction: column; min-width: 0; } .row span.muted { font-size: 13px; }
.row.big { padding: 16px 26px; } .row.big:first-child { padding-top: 16px; }
.empty-hero { text-align: center; padding: 70px 10px; } .empty-hero .potato { width: 84px; height: 71px; margin-bottom: 18px; } .empty-hero .lead { margin: 14px auto 28px; }

/* heatmap */
.heat-wrap { display: flex; gap: 10px; justify-content: center; } .heat-days { margin-top: 0; display: grid; grid-template-rows: repeat(7, 26px); row-gap: 5px; font-size: 10px; color: var(--faint); padding: 0; width: 24px; }
.heat-days span:nth-child(1) { grid-row: 1; } .heat-days span:nth-child(2) { grid-row: 3; } .heat-days span:nth-child(3) { grid-row: 5; } .heat-days span { line-height: 26px; }
.heatmap { display: grid; grid-template-rows: repeat(7, 26px); grid-auto-flow: column; grid-auto-columns: 26px; gap: 5px; }
.heat { width: 26px; height: 26px; border-radius: 5px; background: #efeadb; display: block; } .heat.future { background: transparent; }
.heat.l1 { background: #d3e6d4; } .heat.l2 { background: #a5cca9; } .heat.l3 { background: #6faa79; } .heat.l4 { background: #3b7e55; }
.heat-key { display: flex; gap: 4px; align-items: center; justify-content: flex-end; font-size: 11px; color: var(--faint); margin-top: 12px; } .heat-key .heat { width: 11px; height: 11px; }

/* learning path */
.legend { display: flex; gap: 18px; font-size: 12px; color: var(--muted); } .legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--line-2); background: var(--surface); display: inline-block; } .dot.done { background: var(--green); border-color: var(--green); } .dot.sug { border-color: var(--potato); background: var(--potato-soft); }
.path-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; align-items: start; }
.tree-wrap { position: relative; min-width: 0; }
.tree { background: var(--surface-2); border: 1px solid var(--line); border-radius: 18px; overflow: auto; max-height: min(78vh, 860px); overscroll-behavior: contain; cursor: grab; background-image: radial-gradient(var(--line-2) 1px, transparent 1px); background-size: 22px 22px; scrollbar-width: thin; scroll-behavior: smooth; }
.tree.dragging { cursor: grabbing; scroll-behavior: auto; user-select: none; } .tree.dragging .node { pointer-events: none; }
.tree-canvas { position: relative; } .tree-canvas > svg { position: absolute; inset: 0; width: auto; height: auto; z-index: 1; pointer-events: none; }
.lane { position: absolute; left: 0; right: 0; z-index: 0; background: #ffffff70; border-block: 1px solid var(--line); } .lane:nth-of-type(even) { background: #ffffff38; }
.tier-bar { position: sticky; top: 0; z-index: 4; height: 34px; margin-bottom: -34px; background: var(--surface-2); border-bottom: 1px solid var(--line); } .tier { position: absolute; top: 9px; z-index: 1; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--faint); text-align: center; }
.tree-arrow { position: absolute; z-index: 5; top: 50%; translate: 0 -50%; width: 40px; height: 64px; border-radius: 12px; border: 1px solid var(--line-2); background: #fffffff0; box-shadow: var(--shadow); font-size: 28px; line-height: 1; color: var(--ink); cursor: pointer; } .tree-arrow:hover { background: var(--surface); border-color: var(--ink); } .tree-arrow:disabled { display: none; }
.tree-arrow.left { left: -10px; } .tree-arrow.right { right: -10px; }
.edge { fill: none; stroke: var(--line-2); stroke-width: 2; stroke-dasharray: 5 5; } .edge.done { stroke: var(--green); stroke-dasharray: none; } .edge.suggested { stroke: var(--potato); stroke-dasharray: none; stroke-width: 2.5; }
.lane-label { position: sticky; left: 14px; display: inline-block; margin: 5px 0 0 14px; padding: 1px 8px; border-radius: 99px; background: #fffffff0; font-size: 11px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; color: var(--faint); }
.node { position: absolute; z-index: 2; text-align: left; display: flex; flex-direction: column; justify-content: space-between; padding: 14px 16px; background: var(--surface); border: 1.5px solid var(--line-2); border-radius: 14px; box-shadow: var(--shadow); transition: transform .12s, border-color .12s; }
.node:hover { transform: translateY(-2px); } .node.selected { border-color: var(--ink); box-shadow: 0 0 0 3px #1f2a2414, var(--shadow); }
.node strong { font: 400 18px/1.2 var(--serif); } .node small { color: var(--faint); font-size: 12px; }
.node-state { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--muted); }
.node.mastered { background: var(--green-soft); border-color: var(--green-line); } .node.mastered .node-state { color: var(--green-2); }
.node.suggested { border-color: var(--potato); background: #fffaf0; } .node.suggested .node-state { color: var(--amber); }
.node.later { background: #f8f5ec; } .node.later strong { color: var(--muted); }
.detail { position: sticky; top: 88px; display: flex; flex-direction: column; gap: 14px; }
.detail dl { margin: 0; display: grid; gap: 8px; } .detail dl div { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; border-top: 1px solid var(--line); padding-top: 8px; } .detail dt { color: var(--muted); } .detail dd { margin: 0; font-weight: 600; text-align: right; }
.note { background: var(--amber-soft); color: #6d4210; border-radius: 10px; padding: 10px 14px; font-size: 13px; }

/* summary */
.summary { padding: 36px 40px; } .summary h1 { margin-bottom: 24px; }
.result { display: flex; align-items: center; gap: 24px; padding: 22px; border-radius: 16px; background: var(--surface-2); margin-bottom: 24px; } .result.good { background: var(--green-soft); } .result p { color: var(--muted); margin-top: 6px; }
.ring { --p: 0; width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center; flex: none; background: radial-gradient(closest-side, var(--surface) 78%, transparent 80%), conic-gradient(var(--green) calc(var(--p) * 1%), var(--line-2) 0); } .ring strong { font: 600 22px var(--sans); }
.answers { list-style: none; margin: 0 0 28px; padding: 0; } .answers li { display: flex; gap: 14px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); } .comment { color: var(--blue); font-style: italic; margin-top: 4px; font-size: 14px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.mark { font-size: 26px; line-height: 1; font-weight: 700; } .mark.correct { color: #2a8a4f; } .mark.incorrect { color: var(--red); } .mark.unmarked { color: var(--blue); }

/* ----- dialogs ----- */
.backdrop { position: fixed; inset: 0; z-index: 30; background: #1b241e66; backdrop-filter: blur(2px); display: grid; place-items: center; padding: 20px; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
.dialog { width: min(100%, 440px); max-height: calc(100dvh - 40px); overflow: auto; background: var(--surface); border-radius: 18px; padding: 26px 28px; box-shadow: 0 24px 60px -12px #0004; animation: rise .2s ease-out; } .dialog.wide { width: min(100%, 520px); }
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
.dialog > p { color: var(--muted); margin-top: 10px; } .dialog h2 { font-size: 24px; }
.dlg-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
.dlg-foot { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-top: 20px; flex-wrap: wrap; }
.learners { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 8px; } .learners li { display: flex; gap: 4px; align-items: center; }
.learner { flex: 1; display: flex; align-items: center; gap: 14px; text-align: left; padding: 10px 14px 10px 10px; border: 1.5px solid var(--line); background: var(--surface); border-radius: 14px; min-width: 0; } .learner:hover { border-color: var(--green-line); background: #fbfdfb; }
.learners .current .learner { border-color: var(--green); background: var(--green-soft); }
.learner .info { display: flex; flex-direction: column; flex: 1; min-width: 0; } .learner small { color: var(--muted); font-size: 12px; }
.empty-note { text-align: center; color: var(--muted); padding: 28px 0 8px; }

/* ----- paper (practice & review): a booklet page with one slim control bar ----- */
body.paper-mode { height: 100dvh; overflow: hidden; background: #efefea; }
body.paper-mode #app { height: 100dvh; display: flex; flex-direction: column; }
body.paper-mode .view { flex: 1; min-height: 0; display: flex; }
.sheet-layout { flex: 1; min-width: 0; width: min(100%, 1320px); margin: 0 auto; padding: 6px 8px 8px; display: flex; flex-direction: column; gap: 6px; min-height: 0; }
.sheet-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; flex: none; min-height: 44px; }
.sheet-bar .btn { min-height: 40px; padding: 7px 14px; font-size: 14px; white-space: nowrap; }
.sheet-bar .btn.quiet { padding-inline: 10px; }
.spacer { flex: 1; }
.bar-hint { flex: 1 1 160px; min-width: 0; margin: 0; text-align: center; font: 600 14px/1.25 var(--worksheet); color: #2f3a33; text-wrap: balance; }
.review-hint { font-weight: 400; color: #555; font-size: 13px; }
.bar-title { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; } .bar-title strong { font: 700 15px var(--worksheet); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .bar-title span { font-size: 12px; color: #666; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-title b { font-size: 13px; } .bar-title .g { color: #2a8a4f; } .bar-title .r { color: var(--red); } .bar-title .b { color: var(--blue); }
.pager { display: flex; gap: 5px; align-items: center; flex: none; white-space: nowrap; } .pager i { width: 22px; height: 5px; border-radius: 3px; background: #c9c9c0; } .pager i.on { background: #111; } .pager i.done { background: #2a8a4f; } .pageno { font-size: 12px; color: #555; margin-left: 4px; font-variant-numeric: tabular-nums; }
.status { font-size: 13px; color: #555; white-space: nowrap; }
/* Undo is the one tool a child reaches for constantly: warm colour, big target, always in the same place. */
.btn.undo { background: var(--amber-soft); border: 1.5px solid #d99a3e; color: #6b3d05; font-weight: 700; font-size: 15px; padding-inline: 18px; min-width: 96px; }
.btn.undo svg { width: 1.35em; height: 1.35em; } .btn.undo:hover:not(:disabled) { background: #f8dca8; border-color: #b87a1c; }
.btn.undo:disabled { opacity: .45; }
.sheet-area { flex: 1; min-width: 0; min-height: 0; display: flex; justify-content: center; align-items: flex-start; }
.sheet { position: relative; flex: 1; min-height: 0; background: #fff; color: #000; border: 1px solid #d9d9d1; border-radius: 3px; box-shadow: 0 2px 10px -6px #0003; overflow: hidden; }
.sheet-content { position: absolute; inset: 0; z-index: 2; pointer-events: none; display: flex; flex-direction: column; padding: clamp(4px, 1vh, 10px) clamp(14px, 2.4vw, 34px) clamp(4px, 1vh, 10px); }
.sheet #writing { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; }
.question { flex: 1; min-height: 0; padding-top: clamp(6px, 1.4vh, 14px); border-bottom: 1px solid #e3e3dc; position: relative; font-family: var(--worksheet); }
.question:last-child { border-bottom: 0; }
.q-title { display: flex; gap: .55em; align-items: baseline; font-size: clamp(17px, 2.7vh, 24px); line-height: 1.3; letter-spacing: .005em; font-weight: 400; text-rendering: optimizeLegibility; -webkit-font-smoothing: antialiased; font-variant-numeric: lining-nums; }
.q-num { font-weight: 700; min-width: 1.9em; color: #333; text-align: right; }
.q-text { color: #000; }
.blank { display: inline-block; width: 2.4em; border-bottom: 2px solid #222; margin: 0 .15em; vertical-align: baseline; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* typed answer: a long, visible line at the right of the question band */
.q-type { position: absolute; right: 0; bottom: clamp(5px, 1.2vh, 10px); width: clamp(220px, 27%, 380px); display: flex; gap: 8px; align-items: baseline; font: 400 13px var(--worksheet); color: #777; pointer-events: auto; }
.q-type input { flex: 1; min-width: 0; border: 0; border-bottom: 2px solid #b9b9af; background: #fafaf7; padding: 3px 6px; font: 400 clamp(17px, 2.4vh, 21px) var(--worksheet); border-radius: 3px 3px 0 0; color: #000; } .q-type input:focus { border-bottom-color: var(--green); background: #f3f9f5; outline: none; }
.q-type input:placeholder-shown { background: #fafaf7; }
.switch { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; white-space: nowrap; } .switch input { accent-color: var(--green); }
.reason { color: var(--amber); font-size: 12px; }
#app.busy::after { content: 'Reading handwriting…'; position: fixed; inset: 0; display: grid; place-items: center; background: #fffc; font: 400 22px var(--serif); z-index: 50; }

/* The page is one fixed-proportion sheet and everything on it is sized from the sheet itself, so a page looks the same
   (just scaled) in practice, in review beside the rail, and after rotating the device. Ink is stored relative to the sheet. */
@supports (width: 1cqw) {
  .sheet::before { content: ''; position: absolute; z-index: 2; left: 68%; top: 1.2cqh; bottom: 1.2cqh; border-left: 2px dotted #cfcfc5; pointer-events: none; }
  @container (max-width: 760px) { .rail-row.two { grid-template-columns: 1fr; } }
  .sheet-area { container-type: size; }
  .sheet { flex: none; container-type: size; width: min(100cqw, calc(100cqh * var(--aspect, 1.5))); aspect-ratio: var(--aspect, 1.5); min-height: 0; }
  .sheet-content { padding: 1cqh 3cqw 1cqh; }
  .question { padding-top: 1.6cqh; }
  .q-title { font-size: min(3.5cqh, 2.4cqw); }
  .q-type { width: 27cqw; bottom: 1.4cqh; font-size: min(1.8cqh, 1.2cqw); }
  .q-type input { font-size: min(3.1cqh, 2.1cqw); }
}

/* ----- responsive ----- */
@media (max-width: 900px) {
  .cols, .path-layout { grid-template-columns: 1fr; } .detail { position: static; }
  .stats { grid-template-columns: repeat(2, 1fr); } .next-step { flex-direction: column; align-items: stretch; padding: 22px; }
  .top { gap: 10px; padding: 0 14px; } .tabs { overflow-x: auto; } .profile-chip .who small { display: none; }
}
@media (max-width: 1100px) { .bar-title span, .sheet-bar .lbl { display: none; } }
@media (max-width: 900px) { .bar-title { display: none; } .q-type { width: min(60%, 300px); } }
@media (max-width: 560px) { .heatmap { grid-template-rows: repeat(7, 18px); grid-auto-columns: 18px; gap: 4px; } .heat-days { grid-template-rows: repeat(7, 18px); row-gap: 4px; } .heat { width: 18px; height: 18px; } .heat-days span { line-height: 18px; } .brand span { display: none; } .tab { padding: 8px 10px; } .profile-chip .who { display: none; } .summary { padding: 24px 20px; } .result { flex-direction: column; text-align: center; } }
@media (max-height: 560px) { .bar-title span { display: none; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* review controls: the right-hand answer column of each question band, same place as the type-in box while practising */
.rail-card { position: absolute; right: 0; top: 4px; bottom: 4px; width: 27cqw; min-width: 230px; overflow: auto; pointer-events: auto; background: #fff; border: 1px solid var(--line-2); border-radius: 10px; padding: 4px 8px; display: flex; flex-direction: column; justify-content: center; gap: 3px; font-family: var(--sans); }
.rail-row { display: flex; align-items: center; gap: 8px; min-width: 0; } .rail-row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rail-row .mark { display: grid; place-items: center; width: 3.1rem; height: 3.1rem; font-size: 2rem; cursor: pointer; border-radius: 12px; border: 2px solid currentColor; background: #fff; user-select: none; flex: none; transition: transform .08s; } .rail-row .mark:hover { transform: scale(1.06); } .rail-row .mark:active { transform: scale(.95); }
.rail-row .mark.correct { background: #e6f5ec; } .rail-row .mark.incorrect { background: #fdeaea; } .rail-row .mark.unmarked { border-color: var(--line-2); color: var(--muted); }
/* the whole question band glows with its mark: green = correct, red = incorrect, none while undecided */
.question.m-correct { background: linear-gradient(#2fa85e14, #2fa85e14); box-shadow: inset 0 0 0 2px #2fa85e, inset 0 0 26px 4px #2fa85e55; }
.question.m-incorrect { background: linear-gradient(#e0434314, #e0434314); box-shadow: inset 0 0 0 2px #e04343, inset 0 0 26px 4px #e0434355; }
.rail-facts { font-size: 13px; color: var(--muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .rail-facts b { color: var(--ink); }
.rail-field { display: flex; flex-direction: column; gap: 1px; font-size: 10.5px; font-weight: 600; color: var(--muted); min-width: 0; }
.rail-field input { border: 1px solid var(--line-2); border-radius: 7px; padding: 3px 7px; font-size: 14px; background: #fff; color: var(--ink); min-width: 0; width: 100%; }
.rail-field input[data-comment] { color: var(--blue); }
.rail-card .reason { font-size: 11.5px; color: var(--amber); margin: 0; line-height: 1.2; } .rail-card .reason:empty { display: none; }
@media (max-width: 1180px) { .review-hint { display: none; } }
@media (max-width: 900px) { .bar-hint { order: 9; flex: 1 0 100%; } }

.bar-hint { font-size: 13.5px; }

/* ----- sign-in, hand-back and prompts ----- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.auth-card { width: min(100%, 420px); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 30px 30px 26px; box-shadow: var(--shadow); text-align: left; }
.auth-stack { width: min(100%, 420px); display: grid; gap: 16px; }
.auth-stack .auth-card { width: 100%; }
.auth-intro { font-size: 14px; line-height: 1.5; color: var(--muted); padding: 0 6px; } .auth-intro h2 { font-size: 18px; color: var(--ink); margin: 0 0 6px; } .auth-intro p { margin: 0 0 10px; }
.auth-intro .testing { background: #fff7e0; border: 1px solid #ecd9a0; border-radius: 12px; padding: 10px 12px; color: #5a4a14; } .auth-intro a { color: inherit; font-weight: 600; }
.auth-card .potato { width: 54px; margin-bottom: 8px; } .auth-card h1 { font-size: 30px; margin: 0 0 6px; } .auth-card .lead { margin: 0 0 18px; font-size: 15px; }
.auth-card form { display: grid; gap: 12px; } .auth-card .btn.block { width: 100%; margin-top: 4px; }
.auth-links { margin: 16px 0 0; font-size: 14px; color: var(--muted); text-align: center; }
.auth-field { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--muted); margin-top: 10px; } .auth-card .auth-field { margin-top: 0; }
.auth-field input { border: 1.5px solid var(--line-2); border-radius: 10px; padding: 11px 12px; font-size: 16px; background: #fff; color: var(--ink); width: 100%; } .auth-field input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.auth-check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; color: var(--muted); } .auth-check input { margin-top: 3px; accent-color: var(--green); }
.form-error { color: var(--red); font-size: 14px; margin: 4px 0 0; } .form-note { background: var(--green-soft); border-radius: 10px; padding: 9px 12px; font-size: 14px; margin: 0 0 14px; color: var(--ink); } .form-note.dev { background: #fff4d6; }
.dialog form, form.dialog { display: block; } .dialog .auth-field { margin-top: 14px; }
.account-block { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); } .account-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

/* ----- subject tabs and block codes ----- */
.subject-tabs { display: flex; gap: 6px; margin: 0 0 12px; flex-wrap: wrap; }
.subject-tab { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 9px 18px 8px; border: 1.5px solid var(--line-2); border-bottom-width: 3px; border-radius: 12px 12px 6px 6px; background: var(--surface); text-align: left; min-width: 120px; }
.subject-tab b { font: 400 18px var(--serif); } .subject-tab small { font-size: 11.5px; color: var(--muted); }
.subject-tab:hover { border-color: var(--ink); } .subject-tab[aria-selected="true"] { background: var(--green-soft); border-color: var(--green); }
.tier b { font-size: 15px; color: var(--ink); letter-spacing: 0; }
.node-code { position: absolute; top: 9px; right: 12px; font: 700 11px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .02em; color: var(--muted); background: #0000000a; border-radius: 6px; padding: 3px 6px; }
.block-id { margin: 2px 0 0; font-size: 13px; color: var(--muted); } .block-id .code { font: 700 12px ui-monospace, "SF Mono", Menlo, monospace; background: #0000000a; border-radius: 6px; padding: 3px 7px; margin-right: 6px; color: var(--ink); }

.node { padding: 8px 12px 8px; } .node strong { font-size: 14.5px; line-height: 1.18; padding-right: 44px; } .node small { font-size: 11px; } .node-code { top: 7px; }
.node.planned { background: transparent; border-style: dashed; box-shadow: none; } .node.planned strong, .node.planned small { color: var(--faint); }
.edge.provisional { stroke-width: 1.5; } .edge.provisional:not(.done):not(.suggested) { opacity: .7; }
.example { font-size: 13.5px; color: var(--muted); margin: 10px 0 0; } .example q { color: var(--ink); quotes: "“" "”"; }

/* ----- Write / Type switch ----- */
.mode-switch { display: inline-flex; border: 2px solid var(--ink); border-radius: 12px; overflow: hidden; flex: none; }
.mode-switch button { display: inline-flex; align-items: center; gap: 7px; min-height: 40px; padding: 6px 16px; border: 0; background: #fff; font-weight: 700; font-size: 15px; cursor: pointer; color: var(--ink); }
.mode-switch button svg { width: 1.25em; height: 1.25em; } .mode-switch button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.mode-switch button:not([aria-pressed="true"]):hover { background: var(--surface-2); }
/* Typing mode: the page is read-only paper (existing ink stays visible) so a resting pen or hand cannot draw; writing mode shows no answer boxes to tap. */
.sheet.typing #writing { pointer-events: none; cursor: default; }
@media (max-width: 760px) { .mode-switch button span { display: none; } .mode-switch button { padding-inline: 12px; } }

/* ----- the answer column scales with the question's band, so marking controls never overflow on a small pad ----- */
.rail-text { min-width: 0; display: flex; flex-direction: column; gap: 1px; flex: 1; }
@supports (width: 1cqw) {
  /* --u: one unit of type for this card = a fixed share of the band height (page height / questions on the page), capped for big screens. */
  .rail-card { --u: min(calc(100cqh / var(--n, 6) * .125), 16px); font-size: var(--u); width: 27cqw; min-width: 0; padding: calc(var(--u) * .3) calc(var(--u) * .6); gap: calc(var(--u) * .3); border-radius: calc(var(--u) * .8); overflow: hidden; }
  .rail-row { gap: calc(var(--u) * .6); } .rail-row.two { gap: calc(var(--u) * .6); }
  .rail-row .mark { width: calc(var(--u) * 3.1); height: calc(var(--u) * 3.1); font-size: calc(var(--u) * 2); border-radius: calc(var(--u) * .8); border-width: max(1.5px, calc(var(--u) * .14)); }
  .rail-facts { font-size: calc(var(--u) * .95); } .rail-card .reason { font-size: calc(var(--u) * .8); line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .rail-field { font-size: calc(var(--u) * .72); gap: 0; } .rail-field input { font-size: var(--u); padding: calc(var(--u) * .2) calc(var(--u) * .5); border-radius: calc(var(--u) * .5); }
  @container (max-width: 760px) { .rail-row.two { grid-template-columns: 1fr 1fr; } }
}

/* ----- typing mode: a plain scrolling list (never squashed by the on-screen keyboard) ----- */
.type-area { flex: 1; min-height: 0; display: flex; }
.type-list { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; display: grid; gap: 12px; align-content: start; width: 100%; max-width: 700px; margin: 0 auto; padding: 4px 4px calc(var(--kb, 0px) + 55vh); }
.type-q { background: #fff; border: 1.5px solid #d9d9d1; border-radius: 16px; padding: 14px 16px 16px; display: grid; gap: 10px; font-family: var(--worksheet); }
.tq-text { font-size: clamp(18px, 4.6vw, 24px); line-height: 1.3; color: #000; } .tq-text b { color: #333; margin-right: .2em; }
.type-q input { font: 400 clamp(22px, 6vw, 28px) var(--worksheet); padding: 10px 14px; border: 2px solid #b9b9af; border-radius: 12px; background: #fafaf7; color: #000; width: 100%; min-width: 0; }
.type-q input:focus { border-color: var(--green); background: #f3f9f5; outline: none; box-shadow: 0 0 0 3px var(--green-soft); }

/* ----- phone-shaped pages (narrower than 3:4): answer controls under each question instead of beside it ----- */
.rail-edit { display: none; }
.mark.inline { display: inline-grid; font-size: 1.3em; vertical-align: -.1em; }
@supports (width: 1cqw) {
  .sheet.tall::before { display: none; }
  .sheet.tall .q-title { font-size: 4.7cqw; line-height: 1.25; }
  /* Phone review: a small pill in the bottom-right corner of each band (mark + Edit). Expected answer, what was read and feedback live in the Edit panel, so nearly all the handwriting stays visible. */
  .sheet.tall .rail-card { --u: min(calc(100cqw * .04), 14px); top: auto; bottom: 4px; left: auto; right: 4px; width: auto; height: auto; padding: calc(var(--u) * .4); }
  .sheet.tall .rail-text { display: none; }
  .sheet.tall .rail-row.two { display: none; }
  .sheet.tall .rail-edit { display: inline-flex; align-items: center; margin-left: auto; flex: none; height: calc(var(--u) * 2.6); padding: 0 calc(var(--u) * 1.1); border: 1.5px solid var(--line-2); border-radius: calc(var(--u) * .7); background: #fff; font: 600 calc(var(--u) * 1) var(--sans); color: var(--ink); cursor: pointer; }
}

/* ----- compact toolbar on phones ----- */
@media (max-width: 600px) {
  .sheet-layout { padding: 4px 6px 6px; gap: 4px; }
  .sheet-bar { gap: 4px 6px; } .sheet-bar .btn { min-height: 42px; padding: 6px 10px; }
  .bar-hint, .bar-title, .review-hint { display: none; }
  .sheet-bar .switch { font-size: 12.5px; } .sheet-bar .status { font-size: 12.5px; }
  .btn.undo { min-width: 0; padding-inline: 12px; }
  /* Review toolbar on a phone is always two rows, whatever the status says: row 1 = leave, pages, "show what was read"; row 2 = status, undo, back, next. */
  .review-bar { flex-wrap: wrap; }
  .review-bar > * { order: 4; }
  .review-bar > .btn.quiet, .review-bar > .pager { order: 1; } .review-bar > .switch { order: 2; margin-left: auto; }
  .review-bar::after { content: ''; order: 3; flex: 0 0 100%; height: 0; }
  .review-bar > .pager { flex: 1 1 0; min-width: 0; overflow: hidden; gap: 3px; } .review-bar .pager i { width: 14px; flex: none; } .review-bar .pageno { display: none; }
  .review-bar > .status { flex: 1 1 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
  .review-bar > .btn { flex: none; }
}

/* ----- cookie consent banner (never over a practice or review page) ----- */
.consent { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 60; max-width: 560px; margin: 0 auto; background: #fff; border: 1px solid var(--line-2); border-radius: 16px; box-shadow: 0 10px 40px -12px #0005; padding: 14px 16px; font: 14px/1.45 var(--sans); color: var(--ink); }
.consent p { margin: 0 0 10px; } .consent-actions { display: flex; gap: 8px; justify-content: flex-end; }
body:has(.sheet-layout) .consent { display: none; }
.foot .link, .auth-intro .link { font: inherit; text-decoration: underline; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.auth-privacy { font-size: 13px; color: var(--muted); line-height: 1.45; } .auth-privacy summary { cursor: pointer; font-weight: 600; } .auth-privacy p { margin: 6px 0 0; } .auth-privacy a { color: inherit; }
