/* Chalkbox design system: tokens and components shared by the app (index.html) and the public pages (learn/app/pages).
   Roles, scales and the one way to draw each component: learn/app/design/DESIGN.md. "Chalk on cream." */

/* ---------- tokens ---------- */
:root {
  --bg:#fbf5f8; --surface:#ffffff; --surface-2:#fff7fa; --soft:#ffe3ee; --line:#f0dce6; --line-2:#e4c3d2;
  --ink:#26101f; --ink-2:#5b4152; --muted:#7c5f73;
  --pink:#ff2e88; --pink-deep:#cc0e66; --accent:#d92774; --accent-2:#c21f67; --on:#ffffff;
  --good:#0f9d58; --good-ink:#0b7a43; --good-soft:#e1f6ea;
  --bad:#e5484d; --bad-ink:#c42b30; --bad-soft:#ffecee;
  --warn:#ffd23f; --warn-ink:#7a5a00; --warn-soft:#fff4c2;
  --violet:#5b21b6; --violet-ink:#5b21b6; --violet-soft:#ede5fb;
  --board:#2b1a26; --board-2:#3a2634; --chalk:#fbf5f8; --chalk-2:#d9c4d0; --chalk-key:#ffd23f; --chalk-pro:#7be3a9; --chalk-con:#ff8a8a; --chalk-blue:#9dbcff;
  --bio:#0f9d58; --chem:#f26b1d; --phys:#2563eb; --maths:#5b21b6;
  /* kept for older scripts (quiz.js, options.js, live.js inline styles) */
  --inv:#26101f; --on-inv:#ffffff; --yellow:#ffd23f; --yellow-deep:#d9a400; --k-pro:#0b7a43; --k-con:#c42b30;
  --f-display:"Bricolage Grotesque", "Arial Rounded MT Bold", system-ui, sans-serif;
  --f-body:"DM Sans", system-ui, sans-serif;
  --f-notes:"Fredoka", "Arial Rounded MT Bold", system-ui, sans-serif;
  --s1:4px; --s2:8px; --s3:12px; --s4:16px; --s5:24px; --s6:32px; --s7:48px;
  --r-sm:10px; --r:16px; --r-lg:20px; --r-xl:24px; --r-pill:999px;
  --shadow-1:0 1px 2px rgba(38,16,31,.06), 0 1px 0 rgba(38,16,31,.02);
  --shadow-2:0 16px 40px -16px rgba(38,16,31,.3), 0 2px 6px rgba(38,16,31,.06);
  --ease:cubic-bezier(.2,.7,.2,1); --fast:160ms; --slow:240ms;
  --gutter:16px;
  color-scheme:light;
}
@media (min-width: 768px) { :root { --gutter:24px; } }
:root[data-mode="dark"] {
  --bg:#120b10; --surface:#1c1218; --surface-2:#241820; --soft:#3a1f2d; --line:#2f2029; --line-2:#46303c;
  --ink:#f6edf2; --ink-2:#cbb3c1; --muted:#a68c9b;
  --pink:#ff4f9b; --pink-deep:#ff7ab5;
  --good:#34d399; --good-ink:#6ee7b7; --good-soft:#10291f;
  --bad:#f87171; --bad-ink:#fca5a5; --bad-soft:#331616;
  --warn-ink:#ffe08a; --warn-soft:#3a2f0b;
  --violet:#a78bfa; --violet-ink:#c4b5fd; --violet-soft:#2a2440;
  --board:#0f0a0d; --board-2:#1c1218;
  --inv:#f6edf2; --on-inv:#120b10; --k-pro:#6ee7b7; --k-con:#fca5a5;
  --shadow-1:0 1px 2px rgba(0,0,0,.4); --shadow-2:0 16px 40px -16px rgba(0,0,0,.7), 0 2px 6px rgba(0,0,0,.3);
  color-scheme:dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing:border-box; }
[hidden] { display:none !important; }
html { background:var(--bg); -webkit-text-size-adjust:100%; }
body { margin:0; background:var(--bg); color:var(--ink); font-family:var(--f-body); font-size:16px; line-height:1.5; -webkit-font-smoothing:antialiased; }
h1, h2, h3, h4 { font-family:var(--f-display); font-weight:800; letter-spacing:-.025em; line-height:1.12; margin:0; text-wrap:balance; color:var(--ink); }
h1 { font-size:clamp(1.75rem, 5vw, 2.25rem); line-height:1.08; letter-spacing:-.03em; }
h2 { font-size:1.375rem; }
h3 { font-size:1.125rem; font-weight:700; letter-spacing:-.015em; line-height:1.25; }
h4 { font-size:1rem; font-weight:700; letter-spacing:-.01em; }
p { margin:0; }
button, input, textarea, select { font:inherit; color:inherit; }
button { cursor:pointer; -webkit-tap-highlight-color:transparent; border:0; background:none; padding:0; }
a { color:inherit; -webkit-tap-highlight-color:transparent; }
img, svg, video { max-width:100%; }
:focus-visible { outline:3px solid var(--accent); outline-offset:2px; border-radius:var(--r-sm); }
.muted { color:var(--muted); }
.ink2 { color:var(--ink-2); }
.small { font-size:.875rem; line-height:1.45; }
.micro { font-size:.75rem; line-height:1.4; font-weight:700; }
.eyebrow { font-size:.75rem; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--muted); }
.num { font-variant-numeric:tabular-nums; }
.sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; }
.ms { display:inline-block; flex:none; vertical-align:middle; }
.stack { display:grid; gap:var(--s3); }
.hstack { display:flex; align-items:center; gap:var(--s2); }
.grow { flex:1; min-width:0; }

/* ---------- motion ---------- */
@keyframes rise { from { opacity:0; transform:translateY(8px); } }
@keyframes fadein { from { opacity:0; } }
@keyframes sheetup { from { opacity:0; transform:translateY(24px); } }
@keyframes pop { from { transform:scale(.6); opacity:0; } }
@keyframes shake { 20%,60% { transform:translateX(-5px); } 40%,80% { transform:translateX(5px); } }
.screen, .flow .col { animation:rise var(--slow) var(--ease) both; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation:none !important; transition:none !important; scroll-behavior:auto !important; } }

/* ---------- buttons ---------- */
.btn { display:inline-flex; align-items:center; justify-content:center; gap:8px; min-height:48px; padding:0 20px; border-radius:var(--r); border:1px solid var(--line-2);
  background:var(--surface); color:var(--ink); font-weight:700; font-size:1rem; line-height:1.2; text-decoration:none; text-align:center; cursor:pointer;
  transition:transform var(--fast) var(--ease), background var(--fast), border-color var(--fast), color var(--fast); }
.btn:hover { border-color:var(--muted); }
.btn:active { transform:scale(.985); }
.btn.main { background:var(--accent); border-color:transparent; color:var(--on); }
.btn.main:hover { background:var(--accent-2); }
.btn.ghost { background:var(--soft); border-color:transparent; color:var(--pink-deep); }
.btn.ghost:hover { background:color-mix(in srgb, var(--soft) 80%, var(--pink)); }
.btn.dark { background:var(--inv); border-color:transparent; color:var(--on-inv); }
.btn.danger { background:var(--bad); border-color:transparent; color:#fff; }
.btn.full { width:100%; }
.btn.slim { min-height:40px; padding:0 14px; font-size:.9rem; border-radius:12px; }
.btn.icon { width:44px; min-width:44px; min-height:44px; padding:0; border-radius:var(--r-pill); }
.btn:disabled { opacity:.5; cursor:not-allowed; }
.btn.main:disabled { background:color-mix(in srgb, var(--accent) 45%, var(--surface)); opacity:1; }
.btn .ms, .btn svg { flex:none; }
.textbtn { display:inline-flex; align-items:center; justify-content:center; gap:6px; min-height:44px; padding:0 12px; background:none; border:0; color:var(--muted); font-weight:700; text-decoration:none; cursor:pointer; border-radius:var(--r-sm); }
.textbtn:hover { color:var(--ink); text-decoration:underline; text-underline-offset:3px; }
.linkbtn { background:none; border:0; padding:2px 4px; color:var(--pink-deep); font:inherit; font-weight:700; text-decoration:underline; text-underline-offset:3px; cursor:pointer; }
.prolink { font-size:.85rem; font-weight:700; color:var(--muted); text-decoration:underline; text-underline-offset:3px; }
.backbtn { width:40px; height:40px; min-width:40px; border-radius:50%; border:0; background:var(--soft); color:var(--pink-deep); display:inline-grid; place-items:center; text-decoration:none; flex:none; cursor:pointer; transition:background var(--fast); }
.backbtn:hover { background:color-mix(in srgb, var(--soft) 80%, var(--pink)); }

/* ---------- surfaces ---------- */
.card { background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg); }
.card.pad { padding:var(--s4); }
@media (min-width: 768px) { .card.pad { padding:var(--s5) 20px; } }
.card.raised { box-shadow:var(--shadow-1); }
a.card, button.card { text-decoration:none; color:inherit; text-align:left; cursor:pointer; transition:border-color var(--fast), transform var(--fast) var(--ease); }
a.card:hover, button.card:hover { border-color:var(--line-2); }
a.card:active, button.card:active { transform:scale(.99); }
.inset { background:var(--surface-2); border-radius:var(--r-sm); padding:12px 14px; }

/* ---------- rows ---------- */
.rows { display:grid; gap:8px; }
.row { display:flex; gap:12px; align-items:center; width:100%; padding:12px 14px; border:1px solid var(--line); border-radius:var(--r); background:var(--surface); color:inherit; text-align:left; text-decoration:none; cursor:pointer; transition:border-color var(--fast), background var(--fast); }
.row:hover { border-color:var(--line-2); background:var(--surface-2); }
.row[style*="cursor:default"], .row.static { cursor:default; }
.row .ic { width:40px; height:40px; border-radius:12px; display:grid; place-items:center; flex:none; background:var(--soft); color:var(--pink-deep); font-family:var(--f-display); font-weight:800; }
.row .t { flex:1; min-width:0; display:grid; gap:1px; line-height:1.3; }
.row .t b { display:block; }
.row > .ms:last-child { color:var(--muted); }
.row.danger b { color:var(--bad-ink); }

/* ---------- chips ---------- */
.chip { display:inline-flex; align-items:center; gap:5px; font-size:.75rem; line-height:1; font-weight:700; padding:5px 10px; border-radius:var(--r-pill); background:var(--soft); color:var(--pink-deep); white-space:nowrap; vertical-align:middle; }
.chip.grey { background:var(--surface-2); color:var(--ink-2); border:1px solid var(--line); }
.chip.ok { background:var(--good-soft); color:var(--good-ink); }
.chip.bad { background:var(--bad-soft); color:var(--bad-ink); }
.chip.pro { background:var(--warn); color:#3b2a00; }
.chip.ink { background:var(--inv); color:var(--on-inv); }
.chip.violet { background:var(--violet-soft); color:var(--violet-ink); }
mark { background:var(--warn-soft); color:inherit; border-radius:4px; padding:0 2px; }

/* ---------- tabs and segments ---------- */
.tabs { display:flex; gap:6px; overflow-x:auto; padding:2px; margin:-2px; scrollbar-width:none; }
.tabs::-webkit-scrollbar { display:none; }
.tabs.more { -webkit-mask-image:linear-gradient(to right, #000 calc(100% - 40px), transparent); mask-image:linear-gradient(to right, #000 calc(100% - 40px), transparent); }
.tabs > button, .tabs > a { flex:none; display:inline-flex; align-items:center; gap:6px; min-height:40px; padding:0 14px; border-radius:var(--r-pill); border:1px solid transparent; background:transparent; color:var(--ink-2); font-weight:700; font-size:.95rem; text-decoration:none; transition:background var(--fast), color var(--fast); }
.tabs > button:hover, .tabs > a:hover { background:var(--surface); border-color:var(--line); }
.tabs > button[aria-pressed="true"], .tabs > a[aria-current="page"] { background:var(--inv); color:var(--on-inv); border-color:transparent; }
.seg { display:grid; grid-auto-flow:column; grid-auto-columns:1fr; gap:4px; padding:4px; border-radius:14px; background:var(--soft); }
.seg button { border:0; border-radius:10px; min-height:40px; padding:0 10px; font-weight:700; background:transparent; color:var(--pink-deep); transition:background var(--fast), color var(--fast); }
.seg button[aria-pressed="true"] { background:var(--surface); color:var(--ink); box-shadow:var(--shadow-1); }
.seg button:disabled { opacity:.45; }

/* ---------- forms ---------- */
.field { display:grid; gap:6px; }
.field label, .lbl { font-weight:700; font-size:.875rem; color:var(--ink-2); }
.field input, .field select, .field textarea, textarea.input, input.input { width:100%; min-height:48px; padding:0 14px; border-radius:12px; border:1px solid var(--line-2); background:var(--surface); color:var(--ink); font-size:1rem; }
.field textarea, textarea.input { padding:12px 14px; min-height:120px; resize:vertical; line-height:1.5; }
.field input:focus, .field textarea:focus, textarea.input:focus, input.input:focus { outline:none; border-color:var(--accent); box-shadow:0 0 0 3px var(--soft); }
.field input::placeholder, textarea::placeholder { color:var(--muted); opacity:.8; }
.code { letter-spacing:.4em; text-align:center; font-weight:700; font-size:1.4rem !important; }
.note-s { font-size:.8rem; color:var(--muted); text-align:center; line-height:1.45; }
.sw { flex:none; width:48px; height:28px; border-radius:var(--r-pill); border:0; padding:3px; background:var(--line-2); cursor:pointer; transition:background var(--fast); }
.sw i { display:block; width:22px; height:22px; border-radius:50%; background:#fff; box-shadow:0 1px 3px rgba(0,0,0,.25); transition:transform var(--fast) var(--ease); }
.sw[aria-checked="true"] { background:var(--good); } .sw[aria-checked="true"] i { transform:translateX(20px); }
.search { position:relative; display:block; }
.search .ms, .search > svg { position:absolute; left:14px; top:50%; translate:0 -50%; color:var(--muted); pointer-events:none; }
.search input { width:100%; min-height:44px; padding:0 14px 0 42px; border:1px solid var(--line-2); border-radius:var(--r-pill); background:var(--surface); font-size:.95rem; }
.search input:focus { outline:none; border-color:var(--accent); box-shadow:0 0 0 3px var(--soft); }

/* ---------- progress ---------- */
.pbar { height:6px; border-radius:var(--r-pill); background:var(--soft); overflow:hidden; }
.pbar i { display:block; height:100%; width:0; border-radius:var(--r-pill); background:var(--pink); transition:width .6s var(--ease); }
.pbar i.full { background:var(--good); }
.pbar.sm { height:4px; }
.ring { position:relative; width:88px; height:88px; flex:none; }
.ring svg { transform:rotate(-90deg); width:100%; height:100%; }
.ring circle { fill:none; stroke-width:10; }
.ring .bg { stroke:var(--soft); }
.ring .fg { stroke:var(--pink); stroke-linecap:round; transition:stroke-dashoffset .8s var(--ease); }
.ring b { position:absolute; inset:0; display:grid; place-items:center; font-family:var(--f-display); font-size:1.25rem; font-weight:800; }

/* ---------- stats, empty state, phead ---------- */
.stat { display:grid; gap:2px; }
.stat b { font-family:var(--f-display); font-size:1.5rem; font-weight:800; line-height:1.1; letter-spacing:-.02em; font-variant-numeric:tabular-nums; }
.stat span { font-size:.8rem; color:var(--muted); font-weight:700; }
.empty { display:grid; gap:10px; justify-items:center; text-align:center; padding:24px 16px; }
.empty .ic { width:56px; height:56px; border-radius:50%; display:grid; place-items:center; background:var(--soft); color:var(--pink-deep); }
.empty p { color:var(--muted); max-width:36ch; }
.phead { display:grid; grid-template-columns:auto minmax(0, 1fr); gap:4px 12px; align-items:center; }
.phead .backbtn { grid-row:1 / 3; }
.phead .eyebrow { grid-column:2; }
.phead h1 { grid-column:2; font-size:clamp(1.5rem, 4.5vw, 2rem); }
.phead.noback .eyebrow, .phead.noback h1 { grid-column:1 / -1; }
.sechead { display:flex; align-items:baseline; justify-content:space-between; gap:12px; }
.sechead h2 { font-size:1.125rem; }
.sechead a, .sechead button.link { font-size:.875rem; font-weight:700; color:var(--pink-deep); text-decoration:none; background:none; border:0; cursor:pointer; }

/* ---------- sheets and toasts ---------- */
.sheet-back { position:fixed; inset:0; z-index:80; background:rgba(38,16,31,.45); display:grid; place-items:end center; animation:fadein var(--fast) both; }
:root[data-mode="dark"] .sheet-back { background:rgba(0,0,0,.65); }
.sheet { width:min(560px, 100%); max-height:92%; overflow-y:auto; background:var(--surface); color:var(--ink); border-radius:var(--r-xl) var(--r-xl) 0 0; box-shadow:var(--shadow-2);
  padding:12px max(20px, env(safe-area-inset-right, 0px)) calc(20px + env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px)); display:grid; gap:14px; align-content:start; animation:sheetup var(--slow) var(--ease) both; }
.sheet .grab { width:40px; height:4px; border-radius:var(--r-pill); background:var(--line-2); justify-self:center; margin-bottom:2px; }
@media (min-width: 980px) { .sheet-back { place-items:center; } .sheet { border-radius:var(--r-xl); padding:20px 24px 24px; max-height:88vh; } }
.toast { position:fixed; left:50%; translate:-50% 0; bottom:calc(84px + env(safe-area-inset-bottom, 0px)); z-index:95; background:var(--inv); color:var(--on-inv); padding:11px 18px; border-radius:var(--r-pill); font-weight:700; font-size:.9rem; max-width:calc(100% - 32px); text-align:center; box-shadow:var(--shadow-2); animation:sheetup var(--fast) var(--ease) both; }
@media (min-width: 980px) { .toast { bottom:28px; } }

/* ---------- answers (quiz, duels, level check) ---------- */
.answers { display:grid; gap:10px; }
.ans { display:flex; align-items:center; gap:12px; width:100%; min-height:52px; padding:10px 14px; border-radius:14px; border:1px solid var(--line-2); background:var(--surface); color:var(--ink); font-weight:600; text-align:left; cursor:pointer; transition:border-color var(--fast), background var(--fast); }
.ans:hover:not(:disabled) { border-color:var(--muted); }
.ans .k { width:28px; height:28px; border-radius:8px; background:var(--soft); color:var(--pink-deep); display:grid; place-items:center; flex:none; font-size:.8rem; font-weight:800; }
.ans.right { background:var(--good-soft); border-color:var(--good); } .ans.right .k { background:var(--good); color:#fff; }
.ans.wrong { background:var(--bad-soft); border-color:var(--bad); animation:shake .4s; } .ans.wrong .k { background:var(--bad); color:#fff; }
.ans:disabled { cursor:default; }
.ans:disabled:not(.right):not(.wrong) { opacity:.55; }
.feedback { border-radius:14px; padding:12px 14px; display:grid; gap:4px; animation:rise var(--fast) var(--ease) both; }
.feedback.good { background:var(--good-soft); color:var(--ink); } .feedback.bad { background:var(--bad-soft); color:var(--ink); }
.feedback b { font-family:var(--f-display); font-size:1.1rem; }
.feedback.good b { color:var(--good-ink); } .feedback.bad b { color:var(--bad-ink); }
.qtext { font-family:var(--f-display); font-weight:800; font-size:1.3rem; letter-spacing:-.02em; line-height:1.2; }

/* ---------- note cards (the "board"): light card, framed pictures, coloured key words (the original picture style, Imk 2026-11-07) ---------- */
.board { background:var(--surface); color:var(--ink); border:1px solid var(--line); border-radius:var(--r-lg); padding:20px; display:grid; gap:14px; font-family:var(--f-notes); font-size:1.0625rem; line-height:1.5; font-weight:400; }
@media (min-width: 768px) { .board { padding:24px 28px; } }
.board h3 { font-family:var(--f-notes); font-weight:600; font-size:1.35rem; letter-spacing:0; color:var(--ink); }
.board .ntag { justify-self:start; font-family:var(--f-body); font-size:.72rem; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--muted); background:var(--soft); padding:4px 10px; border-radius:var(--r-pill); }
.board ul { list-style:none; margin:0; padding:0; display:grid; gap:9px; }
.board li { position:relative; padding-left:22px; }
.board li::before { content:""; position:absolute; left:4px; top:.66em; width:7px; height:7px; border-radius:50%; background:var(--ink); }
.board li.pro::before { background:var(--good); } .board li.con::before { background:var(--bad); }
.board li.picli, .board li.phli { padding-left:0; } .board li.picli::before, .board li.phli::before { display:none; }
.board img { width:100%; display:block; border-radius:14px; background:var(--bg); border:1px solid var(--line); }
:root[data-mode="dark"] .board img { background:#f3f7fc; }
.board .lpic { margin:4px 0; }
.board .kw { color:#2563eb; font-weight:600; }
:root[data-mode="dark"] .board .kw { color:#7aa7ff; }
.board .kp { color:var(--good-ink); font-weight:600; } .board .kc { color:var(--bad-ink); font-weight:600; }
.board .key { background:var(--good-soft); color:var(--good-ink); border:1.5px solid var(--good); border-radius:12px; padding:12px 14px; }
.board .key b { color:var(--good-ink); margin-right:4px; }
.board .key .kw { color:var(--good-ink); }
.board .hchip { display:inline-block; font-family:var(--f-body); font-size:.66rem; font-weight:800; padding:2px 7px; border-radius:var(--r-pill); background:var(--violet-soft); color:var(--violet-ink); vertical-align:2px; margin-right:4px; }
.board .ph { display:flex; gap:12px; align-items:center; padding:14px; min-height:96px; border-radius:14px; border:1.5px dashed var(--line-2); color:var(--muted); font-family:var(--f-body); font-size:.85rem; }
.board .ph b { color:var(--ink); }

/* ---------- ad slot (ads.js) ---------- */
.adslot { display:grid; gap:8px; padding:12px 14px; border-radius:var(--r-lg); background:var(--surface); border:1px solid var(--line); }
.adslot .adhead { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.adslot .adlabel { font-size:.7rem; font-weight:700; letter-spacing:.06em; text-transform:uppercase; color:var(--muted); }
.adslot .adx { width:32px; height:32px; border:0; border-radius:50%; background:var(--surface-2); color:var(--muted); font-size:1.1rem; line-height:1; cursor:pointer; }
.adslot .adcard { display:flex; align-items:center; gap:12px; padding:12px; border-radius:14px; background:var(--surface-2); color:var(--ink); text-decoration:none; }
.adslot .adic { width:40px; height:40px; flex:none; border-radius:12px; display:grid; place-items:center; background:var(--soft); color:var(--pink-deep); }
.adslot .adtx { flex:1; min-width:0; display:grid; gap:2px; }
.adslot .adtx b { font-family:var(--f-display); font-size:1rem; line-height:1.2; }
.adslot .adtx span { font-size:.84rem; color:var(--muted); line-height:1.35; }
.adslot .adtx .prolink { display:block; margin-top:4px; }
.adslot.real ins.adsbygoogle { min-height:90px; }
.adslot:has(ins[data-ad-status="unfilled"]) { display:none; }

/* ---------- subject stickers ---------- */
.cicon { width:48px; height:48px; border-radius:14px; display:grid; place-items:center; color:#fff; flex:none; border:1px solid rgba(38,16,31,.06); }
.cicon svg.ill { width:80%; height:80%; }
.avatar { width:36px; height:36px; border-radius:50%; background:var(--inv); color:var(--on-inv); display:grid; place-items:center; font-family:var(--f-display); font-weight:800; border:0; flex:none; cursor:pointer; }
.avatar.sm { width:30px; height:30px; font-size:.85rem; }
.avatar.lg { width:56px; height:56px; font-size:1.4rem; }
