/* =====================================================================
   DENAI Learning Hub — design system
   Palette comes from the DENAI game UI (Kenney pixel pack, see /denai/denai.css).
   Two surfaces:
     .surface-play  — home, hub, game launch: sky, wood frames, chunky buttons
     .surface-read  — notes, exercises: plain paper, calm, maths first
   Breakpoints (used in media queries below, CSS vars cannot be):
     --bp-tablet 600px, --bp-desktop 960px
   ===================================================================== */
:root {
  /* brand (from the game) */
  --sky: #aee3f5; --sky-pale: #e4f6fc; --sky-ink: #1d6f8c;
  --grass: #2eb082; --grass-dark: #1a6c4e; --grass-pale: #e3f6ee;
  --gold: #f4b41b; --gold-light: #fee481; --gold-shade: #c98a0e; --gold-pale: #fff4d1;
  --ribbon: #e2665b; --ribbon-dark: #a8453b; --ribbon-pale: #fdecea;
  --wood: #a3703a; --wood-dark: #6d4b27; --wood-pale: #f3e6d2;
  --parchment: #fff1d2;

  /* neutrals */
  --ink: #232a3b;          /* body text, from the game outline slate */
  --ink-soft: #545d73;
  --ink-faint: #5f6679;    /* ≥4.6:1 on every hub surface (WCAG AA); was #7b8296 */
  --line: #e3dccd;
  --line-strong: #c9bea8;
  --paper: #fffdf8;        /* reading surface */
  --page: #f8f3e8;         /* app background */
  --card: #ffffff;

  /* semantic */
  --primary: var(--gold); --primary-ink: #3a2814;
  --ok: #17704a; --ok-bg: #e3f6ee; --ok-line: #9fdcc0;
  --bad: #b8433a; --bad-bg: #fdecea; --bad-line: #f1b3ac;
  --info: #1d6f8c; --info-bg: #e4f6fc;
  --focus: #2b62d9;
  --warning: #8a5a00; --warning-bg: #fff4d1; --warning-line: #f1d58a;
  --error: var(--bad); --error-bg: var(--bad-bg); --error-line: var(--bad-line);
  --success: var(--ok); --success-bg: var(--ok-bg); --success-line: var(--ok-line);
  --information: var(--info); --information-bg: var(--info-bg);

  /* type */
  --font-display: 'Lilita One', 'Trebuchet MS', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --fs-xs: 13px; --fs-sm: 15px; --fs-md: 17px; --fs-lg: 20px; --fs-xl: 26px;
  --fs-2xl: clamp(28px, 4.2vw, 38px); --fs-hero: clamp(40px, 7vw, 68px);

  /* space (4-pt) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px;
  --gutter: 16px;
  --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(35, 42, 59, .06), 0 2px 8px rgba(35, 42, 59, .05);
  --shadow-2: 0 4px 18px rgba(35, 42, 59, .10);
  --shadow-wood: 0 4px 0 var(--wood-dark);
  --w-page: 1160px; --w-read: 720px;
  --nav-h: 64px; --tab-h: 64px;
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}
@media (min-width: 600px) { :root { --gutter: 24px; } }
@media (min-width: 960px) { :root { --gutter: 32px; } }

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(var(--nav-h) + 16px); scroll-padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 16px); }
@media (min-width: 960px) { html { scroll-padding-bottom: 16px; } }
body { margin: 0; font-family: var(--font-body); font-size: var(--fs-md); line-height: 1.65; color: var(--ink); background: var(--page); overflow-x: hidden; }
img, svg { max-width: 100%; display: block; }
img { height: auto; }
a { color: var(--sky-ink); text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
a:hover { color: var(--ink); }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 4px; }
h1[tabindex="-1"]:focus, .view:focus { outline: none; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 100; background: #fff; padding: 10px 14px; border-radius: var(--r-sm); font-weight: 800; }
.skip:focus { left: 8px; }
.wrap { width: 100%; max-width: var(--w-page); margin: 0 auto; padding: 0 var(--gutter); }
.wrap-read { max-width: calc(var(--w-read) + 2 * var(--gutter)); }
.stack > * + * { margin-top: var(--s4); }
.muted { color: var(--ink-soft); }
.small { font-size: var(--fs-sm); }
.nowrap { white-space: nowrap; }

/* ---------------------------------------------------------------- type */
.display { font-family: var(--font-display); font-weight: 400; letter-spacing: .01em; }
.h1 { font-size: var(--fs-2xl); font-weight: 800; letter-spacing: -.01em; }
.h1.display { font-weight: 400; letter-spacing: .01em; }
.h2 { font-size: var(--fs-xl); font-weight: 800; letter-spacing: -.005em; }
.h3 { font-size: var(--fs-lg); font-weight: 800; }
.eyebrow { font-size: var(--fs-xs); font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: var(--ink-soft); }
.lead { font-size: var(--fs-lg); line-height: 1.55; color: var(--ink-soft); max-width: 38em; }
.section-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: var(--s2) var(--s4); margin-bottom: var(--s4); }
.section-head p { color: var(--ink-soft); }

/* ---------------------------------------------------------------- buttons */
.btn { --b-bg: var(--card); --b-ink: var(--ink); --b-line: var(--line-strong); --b-shadow: transparent;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 48px; padding: 10px 20px;
  border: 2px solid var(--b-line); border-radius: var(--r-md); background: var(--b-bg); color: var(--b-ink);
  font-weight: 800; font-size: var(--fs-md); line-height: 1.2; text-decoration: none; cursor: pointer; box-shadow: 0 3px 0 var(--b-shadow);
  transition: background-color .15s, border-color .15s, transform .08s, box-shadow .08s; text-align: center; }
.btn:hover { color: var(--b-ink); }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn-primary { --b-bg: var(--gold); --b-ink: var(--primary-ink); --b-line: var(--wood-dark); --b-shadow: var(--wood-dark); }
.btn-primary:hover { --b-bg: var(--gold-light); }
.btn-secondary { --b-bg: var(--card); --b-ink: var(--ink); --b-line: var(--ink); --b-shadow: var(--ink); }
.btn-secondary:hover { --b-bg: var(--sky-pale); }
.btn-quiet { --b-bg: transparent; --b-line: transparent; padding-inline: 12px; color: var(--sky-ink); }
.btn-quiet:hover { --b-bg: var(--sky-pale); }
.btn-ok { --b-bg: #1b7a55; --b-ink: #fff; --b-line: #135c40; --b-shadow: #135c40; } /* white text 5.3:1 (was 2.75:1 on --grass) */
.btn-ok:hover { --b-bg: #176a49; }
.btn-lg { min-height: 56px; padding: 12px 26px; font-size: var(--fs-lg); border-radius: 14px; }
.btn-block { width: 100%; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; box-shadow: none; }
@media (prefers-reduced-motion: no-preference) {
  .btn:not([disabled]):active { transform: translateY(3px); box-shadow: 0 0 0 var(--b-shadow); }
}
.btn-row { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; }
.textlink { font-weight: 800; display: inline-flex; align-items: center; gap: 6px; }
.textlink svg { width: 18px; height: 18px; }

/* ---------------------------------------------------------------- shell: top nav */
.topnav { position: sticky; top: 0; z-index: 40; background: rgba(255, 253, 248, .92); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.topnav-in { display: flex; align-items: center; gap: var(--s4); height: var(--nav-h); }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); margin-right: auto; }
.brand-mark { font-family: var(--font-display); font-size: 26px; line-height: 1; color: var(--gold); -webkit-text-stroke: 1.5px var(--ribbon-dark); paint-order: stroke fill; text-shadow: 0 2px 0 var(--ribbon-dark); letter-spacing: .02em; }
.brand-sub { font-size: var(--fs-xs); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); padding-left: 10px; border-left: 2px solid var(--line); }
.navlinks { display: none; gap: var(--s1); list-style: none; }
.navlinks a { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: var(--r-pill); text-decoration: none; color: var(--ink-soft); font-weight: 800; font-size: var(--fs-sm); }
.navlinks a svg { width: 18px; height: 18px; }
.navlinks a:hover { background: var(--wood-pale); color: var(--ink); }
.navlinks a[aria-current="page"] { background: var(--ink); color: #fff; }
.nav-cta { display: none; }
@media (min-width: 960px) { .navlinks { display: flex; } .nav-cta { display: inline-flex; min-height: 44px; padding: 8px 16px; font-size: var(--fs-sm); } }
@media (max-width: 420px) { .brand-sub { display: none; } }

/* landscape phones: keep more room for content */
@media (max-height: 480px) and (max-width: 959px) { :root { --tab-h: 52px; } .tabbar a { flex-direction: row; gap: 6px; } .tabbar a svg { width: 20px; height: 20px; } }

/* ---------------------------------------------------------------- shell: mobile tab bar */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: var(--paper); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); box-shadow: 0 -4px 16px rgba(35, 42, 59, .06); }
.tabbar ul { display: grid; grid-template-columns: repeat(4, 1fr); list-style: none; max-width: 560px; margin: 0 auto; }
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--tab-h); text-decoration: none; color: var(--ink-faint); font-size: 13px; font-weight: 800; position: relative; }
.tabbar a svg { width: 24px; height: 24px; }
.tabbar a[aria-current="page"] { color: var(--ink); }
.tabbar a[aria-current="page"]::before { content: ''; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--gold); }
.tabbar a[aria-current="page"] svg { color: var(--wood-dark); }
@media (min-width: 960px) { .tabbar { display: none; } }
.app { min-height: 100vh; padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + var(--s5)); }
@media (min-width: 960px) { .app { padding-bottom: var(--s8); } }

/* page transition */
.view { outline: none; }
@media (prefers-reduced-motion: no-preference) {
  .view.is-entering { animation: view-in .28s var(--ease) both; }
  @keyframes view-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
}

/* ---------------------------------------------------------------- breadcrumbs + back */
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; list-style: none; font-size: var(--fs-sm); color: var(--ink-faint); padding: var(--s4) 0 0; }
.crumbs li { display: inline-flex; align-items: center; gap: 6px; }
.crumbs li + li::before { content: '/'; color: var(--line-strong); }
.crumbs a { color: var(--ink-soft); font-weight: 700; text-decoration: none; }
.crumbs a:hover { text-decoration: underline; color: var(--ink); }
.crumbs [aria-current] { color: var(--ink); font-weight: 800; }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; font-weight: 800; text-decoration: none; color: var(--ink-soft); }
.back svg { width: 18px; height: 18px; }
.back:hover { color: var(--ink); }

/* ---------------------------------------------------------------- cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); padding: var(--s5); box-shadow: var(--shadow-1); }
.card-tight { padding: var(--s4); }
.card-game { background: var(--paper); border: 3px solid var(--wood); border-radius: var(--r-lg); box-shadow: var(--shadow-wood); padding: var(--s5); }
.card-sky { background: linear-gradient(180deg, var(--sky) 0%, var(--sky-pale) 100%); border: 3px solid var(--ink); border-radius: var(--r-lg); box-shadow: 0 4px 0 var(--ink); padding: var(--s5); }
.card-link { position: relative; display: block; color: inherit; text-decoration: none; }
.card-link:hover { color: inherit; }
@media (prefers-reduced-motion: no-preference) {
  .card-link { transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s; }
  .card-link:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); border-color: var(--line-strong); }
}
.card h3 + p, .card-game h3 + p { margin-top: var(--s2); }
.grid { display: grid; gap: var(--s4); }
@media (min-width: 600px) { .grid-2 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } .grid-gap-lg { gap: var(--s5); } }

/* ---------------------------------------------------------------- tags, states */
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 800; letter-spacing: .02em; line-height: 1.4; background: var(--wood-pale); color: var(--wood-dark); white-space: nowrap; }
.tag svg { width: 14px; height: 14px; }
.tag-ready { background: var(--sky-pale); color: var(--sky-ink); }
.tag-soon { background: #efedea; color: var(--ink-faint); }
.tag-progress { background: var(--gold-pale); color: #8a5a00; }
.tag-done { background: var(--ok-bg); color: var(--ok); }
.tag-elective { background: #f0eafb; color: #5b3e99; }
.tag-demo { background: var(--ink); color: #fff; letter-spacing: .08em; text-transform: uppercase; }
.tag-game { background: var(--grass-pale); color: var(--grass-dark); }

/* demo-data flag */
.demo-note { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 10px 14px; border: 2px dashed var(--line-strong); border-radius: var(--r-md); background: var(--paper); font-size: var(--fs-sm); color: var(--ink-soft); }
.demo-note strong { color: var(--ink); }

/* segmented control (demo switch, tingkatan tabs) */
.seg { display: inline-flex; padding: 4px; gap: 4px; background: var(--wood-pale); border-radius: var(--r-pill); border: 1px solid var(--line); max-width: 100%; }
.seg button, .seg a { min-height: 44px; padding: 0 18px; border: 0; border-radius: var(--r-pill); background: transparent; font-weight: 800; font-size: var(--fs-sm); color: var(--ink-soft); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; white-space: nowrap; }
.seg [aria-pressed="true"], .seg [aria-selected="true"], .seg [aria-current="page"] { background: var(--card); color: var(--ink); box-shadow: var(--shadow-1); }
@media (max-width: 420px) { .seg button, .seg a { padding: 0 12px; } }

/* ---------------------------------------------------------------- progress */
.bar { --v: 0; height: 10px; border-radius: var(--r-pill); background: #ece6d8; overflow: hidden; }
.bar > i { display: block; height: 100%; width: calc(var(--v) * 1%); border-radius: inherit; background: var(--grass); }
.bar.is-gold > i { background: var(--gold); }
.bar-sm { height: 6px; }
@media (prefers-reduced-motion: no-preference) { .bar > i { transition: width .7s var(--ease); } .bar.is-pre > i { width: 0; } }
.meter { display: grid; gap: 6px; }
.meter-row { display: flex; justify-content: space-between; gap: var(--s3); font-size: var(--fs-sm); font-weight: 700; color: var(--ink-soft); }
.meter-row b { color: var(--ink); }

/* step dots (exercise position) */
.dots { display: flex; gap: 6px; list-style: none; }
.dots li { width: 28px; height: 8px; border-radius: var(--r-pill); background: #e6dfcf; }
.dots li.is-current { background: var(--ink); }
.dots li.is-right { background: var(--grass); }
.dots li.is-wrong { background: var(--ribbon); }

/* ---------------------------------------------------------------- lists */
.rows { list-style: none; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--card); overflow: hidden; }
.rows > li + li { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: var(--s4); padding: var(--s4); color: inherit; text-decoration: none; min-height: 64px; }
a.row:hover { background: #fdf9f0; color: inherit; }
.row-main { flex: 1; min-width: 0; }
.row-main > b { display: block; }
.row-main > span { display: block; font-size: var(--fs-sm); color: var(--ink-soft); }
.row-end { flex: none; display: flex; align-items: center; gap: var(--s2); color: var(--ink-faint); }
.row-end svg { width: 20px; height: 20px; }
.num { flex: none; display: grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-md); background: var(--wood-pale); color: var(--wood-dark); font-weight: 800; font-size: var(--fs-md); }
.num.is-done { background: var(--ok-bg); color: var(--ok); }
.num.is-progress { background: var(--gold-pale); color: #8a5a00; }
.num.is-soon { background: #efedea; color: var(--ink-faint); }
.num svg { width: 22px; height: 22px; }

/* empty state */
.empty { text-align: center; padding: var(--s6) var(--s5); border: 2px dashed var(--line-strong); border-radius: var(--r-lg); background: var(--paper); }
.empty svg { width: 40px; height: 40px; margin: 0 auto var(--s3); color: var(--ink-faint); }
.empty h3 { font-size: var(--fs-lg); }
.empty p { margin: var(--s2) auto 0; max-width: 34em; color: var(--ink-soft); }
.empty .btn-row { justify-content: center; margin-top: var(--s4); }

/* ---------------------------------------------------------------- page header */
.pagehead { padding: var(--s4) 0 var(--s5); }
.pagehead .h1 { margin-top: var(--s2); }
.pagehead .lead { margin-top: var(--s3); }
.section { margin-top: var(--s7); }
.sky-band + .wrap > .section:first-child { margin-top: var(--s7); }

/* =====================================================================
   SURFACE: play (home, hub, game)
   ===================================================================== */
.sky-band { background: linear-gradient(180deg, var(--sky) 0%, var(--sky-pale) 70%, var(--page) 100%); position: relative; overflow: hidden; }
.sky-band .wrap { position: relative; z-index: 1; }
.ground { height: 18px; background: linear-gradient(180deg, var(--grass) 0 9px, var(--grass-dark) 9px 12px, #c9734a 12px); }

/* home hero */
.hero { display: grid; gap: var(--s6); padding: var(--s6) 0 var(--s7); align-items: center; }
@media (min-width: 960px) { .hero { grid-template-columns: 1fr 1.05fr; gap: var(--s7); padding: var(--s8) 0; } }
.hero-logo { font-family: var(--font-display); font-size: clamp(64px, 14vw, 112px); line-height: .9; color: var(--gold); -webkit-text-stroke: 3px var(--ribbon-dark); paint-order: stroke fill; text-shadow: 0 6px 0 var(--ribbon-dark); letter-spacing: .02em; }
.hero h1 { font-size: var(--fs-hero); font-family: var(--font-display); font-weight: 400; line-height: 1.02; letter-spacing: .005em; margin-top: var(--s4); }
.hero h1 em { font-style: normal; color: var(--ribbon-dark); }
.hero .lead { margin-top: var(--s4); color: var(--ink); opacity: .82; }
.hero .btn-row { margin-top: var(--s5); }
.hero-note { margin-top: var(--s3); font-size: var(--fs-sm); color: var(--ink-soft); font-weight: 700; }
.stage { position: relative; padding-bottom: 28px; }
.stage-shot { border: 4px solid var(--ink); border-radius: var(--r-lg); overflow: hidden; box-shadow: 0 8px 0 rgba(35, 42, 59, .25); image-rendering: pixelated; background: var(--sky); }
@media (min-width: 960px) { .stage-shot { transform: rotate(-1.2deg); } }
.chillboy { position: absolute; right: 3%; bottom: 0; width: 77px; height: 120px; background: url('../img/chillboy-idle.webp') 0 0 / 928px 120px no-repeat; filter: drop-shadow(0 4px 0 rgba(0, 0, 0, .15)); }
@media (min-width: 600px) { .chillboy { width: 116px; height: 180px; background-size: 1392px 180px; } }
@media (prefers-reduced-motion: no-preference) {
  .chillboy { animation: cb-sm 1.3s steps(12) infinite; }
  @media (min-width: 600px) { .chillboy { animation-name: cb-lg; } }
  @keyframes cb-sm { to { background-position: -928px 0; } }
  @keyframes cb-lg { to { background-position: -1392px 0; } }
}

/* journey: understand → review → practise → play → track */
.journey { list-style: none; display: grid; gap: var(--s3); counter-reset: j; }
@media (min-width: 600px) { .journey { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .journey { grid-template-columns: repeat(5, 1fr); } }
.journey li { position: relative; padding: var(--s4); background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); }
.journey .j-ico { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--jc, var(--wood-pale)); color: var(--ink); margin-bottom: var(--s3); }
.journey .j-ico svg { width: 24px; height: 24px; }
.journey b { display: block; font-size: var(--fs-md); }
.journey b::before { counter-increment: j; content: counter(j) '. '; color: var(--ink-faint); }
.journey p { font-size: var(--fs-sm); color: var(--ink-soft); margin-top: 4px; }
.journey-compact { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; align-items: center; font-size: var(--fs-xs); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); }
.journey-compact li { display: inline-flex; align-items: center; gap: 6px; }
.journey-compact li + li::before { content: '→'; color: var(--line-strong); }
.journey-compact .is-here { color: var(--ink); background: var(--gold-pale); border-radius: var(--r-pill); padding: 2px 8px; }

/* chapter preview chips on home */
.chip-list { display: flex; flex-wrap: wrap; gap: var(--s2); list-style: none; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 6px 14px 6px 6px; border-radius: var(--r-pill); background: var(--card); border: 1px solid var(--line); font-weight: 700; font-size: var(--fs-sm); color: var(--ink); text-decoration: none; }
.chip b { display: grid; place-items: center; min-width: 28px; height: 28px; border-radius: var(--r-pill); background: var(--wood-pale); color: var(--wood-dark); font-size: var(--fs-xs); }
a.chip:hover { border-color: var(--line-strong); background: #fdf9f0; color: var(--ink); }
.chip.is-soon { color: var(--ink-faint); background: transparent; border-style: dashed; }
.chip.is-soon b { background: #efedea; color: var(--ink-faint); }

/* screenshot figures */
.shot { margin: 0; }
.shot img { border-radius: var(--r-md); border: 3px solid var(--ink); image-rendering: pixelated; aspect-ratio: 16 / 9; object-fit: cover; width: 100%; background: var(--sky); }
.shot figcaption { margin-top: var(--s2); font-size: var(--fs-sm); color: var(--ink-soft); }
.shot figcaption b { color: var(--ink); }

/* hub: welcome + continue */
.welcome { display: grid; gap: var(--s5); padding: var(--s5) 0 var(--s6); align-items: center; }
@media (min-width: 960px) { .welcome { grid-template-columns: 1.3fr 1fr; } }
.welcome h1 { font-family: var(--font-display); font-weight: 400; font-size: var(--fs-2xl); letter-spacing: .01em; }
.continue { display: grid; gap: var(--s4); }
.continue .bar { margin-top: var(--s2); }
.continue-head { display: flex; gap: var(--s3); align-items: center; }
.big-num { flex: none; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 14px; background: var(--gold); color: var(--primary-ink); font-family: var(--font-display); font-size: 26px; border: 3px solid var(--wood-dark); }
.steps-start { list-style: none; display: grid; gap: var(--s3); counter-reset: s; }
.steps-start li { display: flex; gap: var(--s3); align-items: flex-start; }
.steps-start li::before { counter-increment: s; content: counter(s); flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--ink); color: #fff; font-weight: 800; font-size: var(--fs-sm); }
.steps-start div > b { display: block; }
.steps-start div > span { color: var(--ink-soft); font-size: var(--fs-sm); }
.activity { list-style: none; display: grid; gap: 0; }
.activity li { display: grid; grid-template-columns: 36px 1fr; gap: var(--s3); padding: var(--s3) 0; border-top: 1px solid var(--line); }
.activity li:first-child { border-top: 0; padding-top: 0; }
.activity .a-ico { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: var(--wood-pale); color: var(--wood-dark); }
.activity .a-ico svg { width: 20px; height: 20px; }
.activity .a-ico.is-game { background: var(--grass-pale); color: var(--grass-dark); }
.activity .a-ico.is-ex { background: var(--sky-pale); color: var(--sky-ink); }
.activity div > b { display: block; font-size: var(--fs-sm); }
.activity div > span { display: block; font-size: var(--fs-xs); color: var(--ink-faint); font-weight: 700; }
.recommend { display: flex; flex-wrap: wrap; gap: var(--s4); align-items: center; justify-content: space-between; }
.recommend > div { flex: 1 1 260px; }

/* chapter cards */
.ch-grid { display: grid; gap: var(--s3); }
@media (min-width: 600px) { .ch-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 960px) { .ch-grid { grid-template-columns: repeat(3, 1fr); gap: var(--s4); } }
.ch-card { display: grid; grid-template-columns: auto 1fr; gap: var(--s3) var(--s4); align-content: start; padding: var(--s4); min-height: 148px; }
.ch-card .num { width: 52px; height: 52px; font-size: var(--fs-lg); border-radius: 14px; }
.ch-card h3 { font-size: var(--fs-md); line-height: 1.3; }
.ch-card .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ch-card .ch-foot { grid-column: 1 / -1; align-self: end; }
.ch-card.is-soon { background: var(--paper); box-shadow: none; }
.ch-card.is-soon h3 { color: var(--ink-soft); }
.ch-card.is-current { border: 2px solid var(--gold); box-shadow: 0 0 0 4px var(--gold-pale); }

/* overview */
.ov-head { display: grid; gap: var(--s5); padding: var(--s4) 0 var(--s5); }
@media (min-width: 960px) { .ov-head { grid-template-columns: 1fr 340px; align-items: start; } }
.ov-intro { color: var(--ink-soft); font-size: var(--fs-md); max-width: 40em; margin-top: var(--s3); }
.ov-intro p + p { margin-top: var(--s2); }
.next-card { border: 3px solid var(--ink); box-shadow: 0 4px 0 var(--ink); background: var(--gold-pale); }
.next-card .eyebrow { color: #8a5a00; }
.concepts { list-style: none; display: grid; gap: var(--s3); }
.concept { display: grid; grid-template-columns: auto 1fr; gap: var(--s3) var(--s4); padding: var(--s4); background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); }
.concept h3 { font-size: var(--fs-md); }
.concept .meta { font-size: var(--fs-sm); color: var(--ink-soft); }
.concept .btn-row { grid-column: 1 / -1; gap: var(--s2); }
@media (min-width: 600px) { .concept { grid-template-columns: auto 1fr auto; align-items: center; } .concept .btn-row { grid-column: auto; } }
.concept .btn { min-height: 44px; padding: 8px 14px; font-size: var(--fs-sm); }
.std-list { list-style: none; display: grid; gap: var(--s2); }
.std-list li { display: flex; gap: var(--s3); padding: var(--s3) var(--s4); background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-md); }
.std-list code { font-family: inherit; font-weight: 800; color: var(--ink-faint); flex: none; }

/* game launch */
.game-hero { display: grid; gap: var(--s5); padding: var(--s5) 0 var(--s6); align-items: center; }
@media (min-width: 960px) { .game-hero { grid-template-columns: 1fr 1.1fr; gap: var(--s7); } }
.levels { list-style: none; display: grid; gap: var(--s3); counter-reset: none; }
.level { display: grid; grid-template-columns: auto 1fr; gap: var(--s3) var(--s4); padding: var(--s4); background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); align-items: start; }
.level-no { display: grid; place-items: center; min-width: 56px; height: 44px; padding: 0 8px; border-radius: 10px; background: var(--grass-dark); color: #fff; font-family: var(--font-display); font-size: 20px; border: 2px solid #12513a; }
.level h3 { font-size: var(--fs-md); }
.level p { font-size: var(--fs-sm); color: var(--ink-soft); margin-top: 2px; }
.level .textlink { margin-top: 6px; font-size: var(--fs-sm); }
.keys { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); list-style: none; font-size: var(--fs-sm); color: var(--ink-soft); }
.keys li { display: inline-flex; align-items: center; gap: 6px; }
kbd { display: inline-grid; place-items: center; min-width: 30px; height: 28px; padding: 0 6px; border: 2px solid var(--ink); border-bottom-width: 4px; border-radius: 6px; background: #fff; font: 800 12px/1 var(--font-body); color: var(--ink); }
.notice { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s4); border-radius: var(--r-md); background: var(--info-bg); color: var(--ink); border: 1px solid #b9e2f0; }
.notice svg { width: 22px; height: 22px; flex: none; color: var(--info); margin-top: 2px; }

/* progress page */
.stat-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s3); }
@media (min-width: 960px) { .stat-row { grid-template-columns: repeat(4, 1fr); } }
.stat { padding: var(--s4); background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); }
.stat dt { font-size: var(--fs-sm); color: var(--ink-soft); font-weight: 700; }
.stat dd { margin: 4px 0 0; font-size: var(--fs-xl); font-weight: 800; line-height: 1.1; }
.stat dd small { font-size: var(--fs-sm); color: var(--ink-faint); font-weight: 700; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--card); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th, .table td { text-align: left; padding: 12px var(--s4); border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); background: var(--paper); font-weight: 800; }
.table tr:last-child td { border-bottom: 0; }
.table td b { display: block; }
@media (max-width: 599px) {
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
  .table tr:last-child { border-bottom: 0; }
  .table td { border: 0; padding: 2px 0; }
  .table td[data-label]::before { content: attr(data-label) ': '; color: var(--ink-faint); font-weight: 700; }
}

/* =====================================================================
   SURFACE: read (notes, exercises)
   ===================================================================== */
.surface-read { background: var(--paper); }
.read { max-width: var(--w-read); margin: 0 auto; }
.read-head { padding: var(--s2) 0 var(--s5); border-bottom: 1px solid var(--line); }
.read-head .h1 { margin-top: var(--s2); }
.read-head .lead { margin-top: var(--s3); font-size: var(--fs-md); }
.jump { position: sticky; top: var(--nav-h); z-index: 20; display: flex; gap: 6px; overflow-x: auto; padding: var(--s3) 0; background: var(--paper); border-bottom: 1px solid var(--line); scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; margin: 0 calc(-1 * var(--gutter)); padding-inline: var(--gutter); scroll-snap-type: x proximity; }
@media (min-width: 760px) { .jump { margin: 0; padding-inline: 0; } }
.jump a { flex: none; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 14px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--card); font-size: var(--fs-xs); font-weight: 800; letter-spacing: .07em; text-decoration: none; color: var(--ink-soft); scroll-snap-align: start; }
.jump a:hover { border-color: var(--line-strong); color: var(--ink); }
.jump a.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.jump a i { width: 8px; height: 8px; border-radius: 50%; background: var(--k); }
.jump a.is-active i { background: #fff; }

/* note sections — one accent per learning step */
.nsec { --k: var(--sky-ink); padding: var(--s6) 0 var(--s2); scroll-margin-top: calc(var(--nav-h) + 72px); }
.nsec + .nsec { border-top: 1px solid var(--line); }
.nsec-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s4); }
.nsec-label { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 8px; border-radius: var(--r-pill); background: color-mix(in srgb, var(--k) 12%, #fff); color: var(--k); font-size: var(--fs-xs); font-weight: 800; letter-spacing: .1em; }
.nsec-label i { width: 10px; height: 10px; border-radius: 3px; background: var(--k); }
.nsec-head h2 { font-size: var(--fs-lg); font-weight: 800; }
.nsec.k-fahami { --k: #1d6f8c; }
.nsec.k-contoh { --k: #8a5a00; }
.nsec.k-ulang { --k: #5b3e99; }
.nsec.k-latihan { --k: #1a6c4e; }
.jump a.k-fahami { --k: #1d6f8c; } .jump a.k-contoh { --k: #c98a0e; } .jump a.k-ulang { --k: #5b3e99; } .jump a.k-latihan { --k: #1f8a5a; }

.prose { font-size: var(--fs-md); line-height: 1.75; }
.prose > * + * { margin-top: var(--s3); }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: 6px; }
.prose strong { font-weight: 800; }
.prose .callout { padding: var(--s3) var(--s4); border-left: 4px solid var(--sky-ink); background: var(--sky-pale); border-radius: 0 var(--r-md) var(--r-md) 0; }
.math-display { display: block; overflow-x: auto; overflow-y: hidden; padding: 6px 0; margin: var(--s3) 0; }
.katex { font-size: 1.08em; }
.katex-display { margin: 0; }
.when { margin-top: var(--s4); padding: var(--s3) var(--s4); border-radius: var(--r-md); background: var(--card); border: 1px solid var(--line); font-size: var(--fs-sm); }

/* worked example */
.example { border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--card); overflow: hidden; }
.example-q { padding: var(--s4) var(--s5); background: #fffaf0; border-bottom: 1px solid var(--line); }
.example-plan { display: grid; gap: 4px; padding: var(--s3) var(--s5); font-size: var(--fs-sm); color: var(--ink-soft); border-bottom: 1px solid var(--line); }
.example-plan b { color: var(--ink); }
.wsteps { list-style: none; counter-reset: w; padding: var(--s3) var(--s5) var(--s4); }
.wsteps li { position: relative; padding: var(--s3) 0 var(--s3) 44px; border-top: 1px dashed var(--line); }
.wsteps li:first-child { border-top: 0; }
.wsteps li::before { counter-increment: w; content: counter(w); position: absolute; left: 0; top: var(--s3); width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--gold-pale); color: #8a5a00; font-weight: 800; font-size: var(--fs-sm); }
.wsteps .why { margin-top: 4px; font-size: var(--fs-sm); color: var(--ink-soft); }
.example-end { padding: var(--s3) var(--s5); background: var(--ok-bg); border-top: 1px solid var(--ok-line); font-size: var(--fs-sm); }
.example-end + .example-end { border-top: 0; padding-top: 0; }

/* revision */
.formulas { display: grid; gap: var(--s3); }
.formula { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--card); padding: var(--s3) var(--s4); }
.formula .math-display, .formula dt { margin: 0; overflow-x: auto; overflow-y: hidden; }
.formula dd { margin: 6px 0 0; font-size: var(--fs-sm); color: var(--ink-soft); }
.howto { padding-left: 1.3em; }
.mistake { display: grid; gap: 6px; border-radius: var(--r-md); padding: var(--s4); background: var(--bad-bg); border: 1px solid var(--bad-line); font-size: var(--fs-sm); }
.mistake .fix { padding-top: 6px; border-top: 1px dashed var(--bad-line); color: var(--ok); }
.mistake .fix b { color: var(--ok); }
.mistake b { color: var(--bad); }
.subhead { font-size: var(--fs-sm); font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); margin: var(--s5) 0 var(--s3); }

.practice-cta { display: flex; flex-wrap: wrap; gap: var(--s4); align-items: center; justify-content: space-between; padding: var(--s5); border-radius: var(--r-lg); background: var(--grass-pale); border: 2px solid var(--ok-line); }
.practice-cta > div { flex: 1 1 240px; }
.pager { display: grid; gap: var(--s3); margin-top: var(--s6); }
@media (min-width: 600px) { .pager { grid-template-columns: 1fr 1fr; } }
.pager a { display: grid; gap: 2px; padding: var(--s4); border: 1px solid var(--line); border-radius: var(--r-md); text-decoration: none; color: var(--ink); background: var(--card); }
.pager a span { font-size: var(--fs-xs); font-weight: 800; letter-spacing: .07em; text-transform: uppercase; color: var(--ink-faint); }
.pager a:hover { border-color: var(--line-strong); color: var(--ink); }
.pager .next { text-align: right; }
.source-line { margin-top: var(--s5); font-size: var(--fs-xs); color: var(--ink-faint); }

/* visuals (ported from /app/addmath/styles/addmath.css so mountVisual() renders the same) */
.visual-fig { margin: var(--s4) 0 0; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md); padding: var(--s3); }
.visual-fig figcaption { margin-top: var(--s2); font-size: var(--fs-sm); }
.visual-fig summary { cursor: pointer; font-weight: 800; color: var(--sky-ink); min-height: 32px; display: flex; align-items: center; }
.plot-svg, .mapping-svg { display: block; width: 100%; max-width: 460px; margin: 0 auto; height: auto; }
.plot-grid { stroke: #ECE8DA; stroke-width: 1; }
.plot-axis { stroke: var(--ink); stroke-width: 1.4; }
.plot-tick { font-size: 10px; fill: var(--ink); opacity: .75; text-anchor: middle; }
.plot-tick-y { text-anchor: end; }
.plot-axis-label { font-size: 12px; font-style: italic; fill: var(--ink); }
.plot-curve { fill: none; stroke-width: 2.6; stroke-linejoin: round; }
.plot-curve.is-dashed { stroke-dasharray: 6 5; stroke-width: 1.8; }
.plot-open { fill: #fff; stroke-width: 2; stroke: var(--ink); }
.plot-point { fill: #D9534F; }
.plot-point-label { font-size: 12px; font-weight: 700; fill: var(--ink); }
.plot-testline { stroke: #D9822B; stroke-width: 2; stroke-dasharray: 4 4; }
.plot-shade { fill: #3467D433; }
.plot-axisline { stroke: #7B4FC9; stroke-width: 1.6; stroke-dasharray: 3 4; }
.plot-polygon { fill: #3467D422; stroke-width: 2.2; stroke-linejoin: round; }
.plot-segment { fill: none; stroke-width: 2.6; }
.plot-arrow { stroke-width: 2.8; }
.plot-arrow.is-dashed { stroke-dasharray: 6 4; stroke-width: 2; }
.plot-controls { display: grid; gap: 10px; margin: 10px auto 0; max-width: 460px; }
.plot-param label { display: block; font-size: 15px; font-weight: 700; margin-bottom: 2px; }
.plot-param input[type=range] { width: 100%; accent-color: var(--sky-ink); min-height: 32px; }
.plot-readout { max-width: 460px; margin: 10px auto 0; font-size: 15px; line-height: 1.6; background: var(--sky-pale); border-radius: 12px; padding: 10px 14px; }
.plot-readout:empty { display: none; }
.mapping-oval { fill: #F4F7FD; stroke: var(--line); }
.mapping-label { font-size: 15px; font-weight: 700; fill: var(--ink); text-anchor: middle; }
.mapping-arrow-line { stroke: var(--sky-ink); stroke-width: 1.8; }
.mapping-head { fill: var(--sky-ink); }
.mapping-note { max-width: 460px; margin: 8px auto 0; font-size: 15px; }
.mapping-stage + .mapping-note:empty { display: none; }
.diagram-toggle { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-bottom: 8px; }
.toggle-btn { min-height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--r-pill); background: #fff; font-weight: 800; font-size: 14px; cursor: pointer; }
.toggle-btn.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.value-table-wrap { overflow-x: auto; }
.value-table { border-collapse: collapse; margin: 0 auto; font-size: 15px; }
.value-table th, .value-table td { border: 1px solid var(--line); padding: 6px 14px; text-align: center; }
.value-table th { background: #F4F7FD; }
.value-table-add { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; justify-content: center; margin-top: 10px; font-size: 14px; }
.value-table-add input { width: 110px; min-height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; font-size: 16px; }
.btn-ghost { min-height: 40px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; font-weight: 800; cursor: pointer; }

/* ---------------------------------------------------------------- exercise */
.ex-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s4) 0; }
.ex-count { font-size: var(--fs-sm); font-weight: 800; color: var(--ink-soft); }
.qcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); overflow: hidden; }
.qcard-body { padding: var(--s5); }
@media (max-width: 599px) { .qcard-body { padding: var(--s4); } }
.ex-bank-note { margin: var(--s3) 0 0; }
.qmeta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: var(--s3); }
.qprompt { font-size: var(--fs-lg); line-height: 1.6; font-weight: 600; }
.qprompt .math-display { font-size: var(--fs-md); }
.options { list-style: none; display: grid; gap: var(--s2); margin-top: var(--s5); }
.option { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 56px; padding: var(--s3) var(--s4); text-align: left; background: #fff; border: 2px solid var(--line); border-radius: var(--r-md); cursor: pointer; font-size: var(--fs-md); line-height: 1.5; transition: border-color .15s, background-color .15s; }
.option:hover:not([disabled]) { border-color: var(--line-strong); background: #fdf9f0; }
.option .opt-key { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 2px solid var(--line-strong); font-weight: 800; font-size: var(--fs-sm); color: var(--ink-soft); background: #fff; }
.option .opt-text { flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden; }
.option .opt-mark { flex: none; width: 24px; height: 24px; }
.option[aria-checked="true"] { border-color: var(--ink); background: var(--sky-pale); box-shadow: inset 0 0 0 1px var(--ink); }
.option[aria-checked="true"] .opt-key { background: var(--ink); border-color: var(--ink); color: #fff; }
.option[disabled] { cursor: default; }
.option.is-right { border-color: var(--ok); background: var(--ok-bg); box-shadow: none; }
.option.is-right .opt-key { background: var(--ok); border-color: var(--ok); color: #fff; }
.option.is-right .opt-mark { color: var(--ok); }
.option.is-wrong { border-color: var(--bad); background: var(--bad-bg); box-shadow: none; }
.option.is-wrong .opt-key { background: var(--bad); border-color: var(--bad); color: #fff; }
.option.is-wrong .opt-mark { color: var(--bad); }
.option.is-dim { opacity: .55; }
.answer-field { margin-top: var(--s5); display: grid; gap: var(--s2); }
.answer-field label { font-weight: 800; font-size: var(--fs-sm); }
.answer-field input { min-height: 56px; width: 100%; max-width: 360px; padding: 0 var(--s4); border: 2px solid var(--line-strong); border-radius: var(--r-md); font-size: var(--fs-lg); background: #fff; }
.answer-field input:focus { border-color: var(--ink); outline: none; box-shadow: 0 0 0 3px #2b62d933; }
.answer-field input.is-right { border-color: var(--ok); background: var(--ok-bg); }
.answer-field input.is-wrong { border-color: var(--bad); background: var(--bad-bg); }
.answer-field .hint { font-size: var(--fs-sm); color: var(--ink-faint); }
.inline-msg { font-size: var(--fs-sm); color: var(--bad); font-weight: 700; min-height: 1.4em; }
.qactions { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; justify-content: space-between; padding: var(--s4) var(--s5); border-top: 1px solid var(--line); background: var(--paper); }
@media (max-width: 599px) { .qactions { padding: var(--s4); } .qactions .btn { flex: 1 1 auto; } }
.qstatus { font-size: var(--fs-sm); color: var(--ink-faint); font-weight: 700; }
.feedback { display: grid; gap: var(--s2); padding: var(--s4) var(--s5); border-top: 1px solid; }
.feedback[tabindex="-1"], .hint-box[tabindex="-1"] { scroll-margin-block: var(--s4); }
@media (max-width: 959px) { .feedback[tabindex="-1"], .hint-box[tabindex="-1"] { scroll-margin-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + var(--s4)); } }
.feedback-title { display: flex; align-items: center; gap: var(--s2); font-weight: 800; font-size: var(--fs-lg); }
.feedback-title svg { width: 26px; height: 26px; flex: none; }
.feedback.is-right { background: var(--ok-bg); border-color: var(--ok-line); }
.feedback.is-right .feedback-title { color: var(--ok); }
.feedback.is-wrong { background: var(--bad-bg); border-color: var(--bad-line); }
.feedback.is-wrong .feedback-title { color: var(--bad); }
.feedback .correct-line { font-size: var(--fs-sm); }
@media (max-width: 599px) { .feedback { padding: var(--s4); } }
@media (prefers-reduced-motion: no-preference) {
  .feedback { animation: fb-in .28s var(--ease) both; }
  @keyframes fb-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
  .option.is-wrong { animation: nudge .32s ease both; }
  @keyframes nudge { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
}
.explain { border-top: 1px solid var(--line); }
.explain summary { display: flex; align-items: center; gap: var(--s2); min-height: 52px; padding: 0 var(--s5); cursor: pointer; font-weight: 800; color: var(--sky-ink); list-style: none; }
.explain summary::-webkit-details-marker { display: none; }
.explain summary::after { content: '+'; margin-left: auto; font-size: 22px; line-height: 1; color: var(--ink-faint); }
.explain[open] summary::after { content: '−'; }
.explain ol { padding: 0 var(--s5) var(--s4) calc(var(--s5) + 1.2em); display: grid; gap: var(--s2); }
@media (max-width: 599px) { .explain summary { padding: 0 var(--s4); } .explain ol { padding: 0 var(--s4) var(--s4) calc(var(--s4) + 1.2em); } }

/* completion */
.done { text-align: center; padding: var(--s6) var(--s5); }
.score-ring { --v: 0; width: 148px; height: 148px; margin: 0 auto var(--s4); border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--grass) calc(var(--v) * 1%), #ece6d8 0); }
.score-ring > div { width: 116px; height: 116px; border-radius: 50%; background: var(--card); display: grid; place-items: center; align-content: center; }
.score-ring b { font-size: 36px; line-height: 1; font-weight: 800; }
.score-ring span { font-size: var(--fs-xs); font-weight: 800; color: var(--ink-faint); letter-spacing: .06em; text-transform: uppercase; margin-top: 4px; }
.done h2 { font-size: var(--fs-xl); }
.done > p { color: var(--ink-soft); margin: var(--s2) auto 0; max-width: 32em; }
.done .btn-row { justify-content: center; margin-top: var(--s5); }
.review-list { list-style: none; display: grid; gap: var(--s2); text-align: left; margin-top: var(--s5); }
.review-list li { display: flex; align-items: flex-start; gap: var(--s3); padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: var(--r-md); font-size: var(--fs-sm); background: #fff; }
.review-list svg { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.review-list .is-right svg { color: var(--ok); }
.review-list .is-wrong svg { color: var(--bad); }
.review-list .rl-text { flex: 1; min-width: 0; overflow-x: auto; overflow-y: hidden; }

/* ---------------------------------------------------------------- footer */
.foot { margin-top: var(--s8); padding: var(--s6) 0; border-top: 1px solid var(--line); font-size: var(--fs-sm); color: var(--ink-soft); }
.foot-in { display: flex; flex-wrap: wrap; gap: var(--s3) var(--s5); justify-content: space-between; }
.foot a { color: var(--ink-soft); font-weight: 700; }

/* ---------------------------------------------------------------- loading + reveal */
.loading { display: flex; align-items: center; gap: var(--s3); padding: var(--s7) 0; justify-content: center; color: var(--ink-soft); font-weight: 700; }
.loading::before { content: ''; width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--ink); }
@media (prefers-reduced-motion: no-preference) { .loading::before { animation: spin .8s linear infinite; } @keyframes spin { to { transform: rotate(1turn); } } }
@media (prefers-reduced-motion: no-preference) {
  [data-reveal] { opacity: 0; transform: translateY(16px); transition: opacity .5s var(--ease), transform .5s var(--ease); }
  [data-reveal].is-in { opacity: 1; transform: none; }
}
@media (max-width: 599px) { .sr-only-m { display: none; } }
.explain summary svg { width: 20px; height: 20px; flex: none; }
.opt-mark svg { width: 24px; height: 24px; }
/* long maths never widens the page: grid items may shrink, display maths scrolls inside its box */
.formulas { grid-template-columns: minmax(0, 1fr); }
.formula, .example, .wsteps li, .qprompt, .prose { min-width: 0; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }
.wsteps li > div, .example-plan > span, .example-end { overflow-x: auto; overflow-y: hidden; }

/* ---------------------------------------------------------------- mode banner (demo / no storage) */
.modebar { background: var(--ink); color: #fff; font-size: var(--fs-sm); }
.modebar[hidden] { display: none; }
.modebar-in { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding-top: 10px; padding-bottom: 10px; }
.modebar .tag-demo { background: var(--gold); color: var(--primary-ink); }
.modebar-text { flex: 1 1 260px; }
.modebar-exit { color: #fff; font-weight: 800; }
.modebar-exit:hover { color: var(--gold-light); }
.seg-sm { background: rgba(255, 255, 255, .12); border-color: transparent; }
.seg-sm button { min-height: 36px; color: #fff; padding: 0 12px; }
.seg-sm [aria-pressed="true"] { color: var(--ink); }

/* ---------------------------------------------------------------- mastery */
.mastery { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 800; white-space: nowrap; }
.mastery i { width: 10px; height: 10px; border-radius: 50%; border: 2px solid currentColor; }
.mastery-belum { background: #efedea; color: var(--ink-faint); }
.mastery-mencuba { background: var(--gold-pale); color: #8a5a00; }
.mastery-mencuba i { background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
.mastery-faham { background: var(--sky-pale); color: var(--sky-ink); }
.mastery-faham i { background: currentColor; }
.mastery-mahir { background: var(--ok-bg); color: var(--ok); }
.mastery-mahir i { background: currentColor; box-shadow: 0 0 0 2px var(--ok-bg), 0 0 0 3px currentColor; width: 8px; height: 8px; }
.mastery-key { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: var(--fs-xs); color: var(--ink-soft); }
.note-done-row { display: flex; flex-wrap: wrap; gap: var(--s3); align-items: center; justify-content: space-between; margin-top: var(--s4); padding: var(--s4); border-radius: var(--r-md); background: var(--card); border: 1px solid var(--line); }
.note-done-row.is-done { background: var(--ok-bg); border-color: var(--ok-line); }
.attempt-note { font-size: var(--fs-sm); font-weight: 700; color: var(--ink-soft); }
.option.is-tried { border-color: var(--bad-line); background: var(--bad-bg); opacity: .8; }
.option.is-tried .opt-key { background: var(--bad); border-color: var(--bad); color: #fff; }
.feedback.is-retry { background: var(--gold-pale); border-color: #f1d58a; }
.feedback.is-retry .feedback-title { color: #8a5a00; }

/* =====================================================================
   Learning Hub v2 — four tabs, one primary action, learning paths
   ===================================================================== */
.btn-sm { min-height: 40px; padding: 6px 14px; font-size: var(--fs-sm); }
.btn-quiet.btn-sm { padding-inline: 10px; }
@media (max-width: 599px) { .btn-block-m { width: 100%; } }
.section-sm { margin-top: var(--s6); }
.section-sm > h2 { margin-bottom: var(--s3); }
.tag-review { background: #f0eafb; color: #5b3e99; }

/* preview of content under review (owner only, ?semak=1) */
.preview-flag { background: #f0eafb; color: #3f2a6e; border-bottom: 1px solid #d9cdf2; font-size: var(--fs-sm); padding: 10px 0; }

/* ---------------------------------------------------------------- Utama */
.home-wrap { max-width: calc(640px + 2 * var(--gutter)); }
.home-main { padding: var(--s6) 0 var(--s5); }
.home-title { font-family: var(--font-display); font-weight: 400; font-size: var(--fs-2xl); letter-spacing: .01em; margin-top: var(--s2); }
.next-up { margin-top: var(--s5); padding: var(--s5); background: var(--card); border: 2px solid var(--line); border-radius: 24px; box-shadow: 0 4px 0 var(--line); }
.next-label { font-size: var(--fs-xs); font-weight: 800; letter-spacing: .09em; text-transform: uppercase; color: #8a5a00; }
.next-title { font-size: var(--fs-xl); font-weight: 800; margin-top: var(--s1); line-height: 1.25; }
.next-why { color: var(--ink-soft); margin: var(--s2) 0 var(--s5); }
.next-where { margin-top: var(--s4); font-size: var(--fs-sm); color: var(--ink-soft); }
.next-where a { font-weight: 800; }
.home-review { margin-top: var(--s4); }
.home-review h2 { margin-bottom: var(--s3); }
.home-review > p { margin-top: var(--s3); }
.home-foot { margin-top: var(--s5); }
.review-rows { list-style: none; display: grid; gap: var(--s2); }
.review-rows a { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); min-height: 64px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; text-decoration: none; color: var(--ink); }
.review-rows a:hover { border-color: var(--line-strong); color: var(--ink); background: #fdf9f0; }
.review-rows a > span:first-child { flex: 1; min-width: 0; }
.review-rows b { display: block; font-size: var(--fs-md); }
.review-rows small { display: block; font-size: var(--fs-sm); color: var(--ink-soft); }
.review-rows svg { width: 20px; height: 20px; flex: none; color: var(--ink-faint); }
.review-act { display: inline-flex; align-items: center; gap: 4px; font-size: var(--fs-sm); font-weight: 800; color: var(--sky-ink); white-space: nowrap; }

/* ---------------------------------------------------------------- learning path */
.wrap-path { max-width: calc(760px + 2 * var(--gutter)); }
.path-toolbar { display: flex; flex-wrap: wrap; gap: var(--s3) var(--s5); align-items: center; justify-content: space-between; margin-bottom: var(--s5); }
.chapter-search { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s2) var(--s4); margin: 0 0 var(--s4) calc(56px + var(--s4)); }
.chapter-search label { grid-column: 1 / -1; font-size: var(--fs-sm); font-weight: 800; }
.chapter-search input { width: 100%; min-width: 0; min-height: 48px; padding: 0 var(--s4); border: 1px solid var(--line-strong); border-radius: var(--r-md); background: var(--card); }
.chapter-search input:focus-visible { outline-offset: 2px; }
.chapter-search .small { margin: 0; white-space: nowrap; }
.empty-search { margin: 0 0 0 calc(56px + var(--s4)); padding: var(--s4); border: 1px dashed var(--line-strong); border-radius: var(--r-md); color: var(--ink-soft); }
.empty-search[hidden] { display: none; }
.path { list-style: none; position: relative; display: grid; gap: var(--s3); }
.path-node { position: relative; display: grid; grid-template-columns: 56px 1fr; gap: var(--s4); align-items: start; }
.path-node:not(:last-child)::before { content: ''; position: absolute; left: 27px; top: 56px; bottom: calc(-1 * var(--s3)); width: 4px; margin-left: -1px; border-radius: 2px; background: var(--line); }
.path-node.is-done:not(:last-child)::before { background: var(--ok-line); }
.path-dot { position: relative; z-index: 1; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--card); border: 3px solid var(--line-strong); font-weight: 800; font-size: var(--fs-md); color: var(--ink-soft); box-shadow: 0 3px 0 var(--line); }
.path-dot svg { width: 26px; height: 26px; }
.path-node.is-done .path-dot { background: var(--ok); border-color: #135c40; color: #fff; box-shadow: 0 3px 0 #135c40; }
.path-node.is-progress .path-dot { border-color: var(--gold-shade); color: #8a5a00; background: var(--gold-pale); }
.path-node.is-current .path-dot { background: var(--gold); border-color: var(--wood-dark); color: var(--primary-ink); box-shadow: 0 3px 0 var(--wood-dark), 0 0 0 6px var(--gold-pale); }
.path-node.is-soon .path-dot { background: #f3f1ed; border-style: dashed; color: var(--ink-faint); box-shadow: none; }
.path-body { min-width: 0; padding: var(--s3) var(--s4) var(--s4); background: var(--card); border: 1px solid var(--line); border-radius: 18px; }
.path-node.is-current .path-body { border: 2px solid var(--gold); background: #fffcf2; }
.path-node.is-soon .path-body { background: transparent; border-style: dashed; }
.path-link { display: grid; gap: 2px; text-decoration: none; color: var(--ink); }
.path-link:hover { color: var(--ink); }
.path-link:hover .path-title { text-decoration: underline; }
.path-kicker { font-size: var(--fs-xs); font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.path-title { font-size: var(--fs-lg); font-weight: 800; line-height: 1.3; }
.path-node.is-soon .path-title { color: var(--ink-soft); }
.path-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: var(--s2); font-size: var(--fs-sm); color: var(--ink-soft); }
.path-body > .btn { margin-top: var(--s3); }
.path-next { margin-top: var(--s3); padding-top: var(--s3); border-top: 1px dashed var(--line-strong); display: grid; gap: var(--s3); justify-items: start; }
.path-next p { font-size: var(--fs-sm); }
@media (max-width: 599px) { .path-next .btn { width: 100%; } }
.path-actions { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: var(--s3); }
.path-actions a { display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px; border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--paper); font-size: var(--fs-sm); font-weight: 800; color: var(--sky-ink); text-decoration: none; }
.path-actions a:hover { border-color: var(--line-strong); color: var(--ink); }
.path-actions svg { width: 16px; height: 16px; }
@media (max-width: 420px) { .path-node { grid-template-columns: 44px 1fr; gap: var(--s3); } .path-dot { width: 44px; height: 44px; font-size: var(--fs-sm); } .path-node:not(:last-child)::before { left: 21px; top: 44px; } }
@media (max-width: 420px) { .chapter-search, .empty-search { margin-left: calc(44px + var(--s3)); } }
.path-extra { display: grid; gap: var(--s2); margin-top: var(--s6); }
.row-link { display: flex; align-items: center; gap: var(--s3); padding: var(--s4); min-height: 64px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); text-decoration: none; color: var(--ink); }
.row-link:hover { border-color: var(--line-strong); color: var(--ink); background: #fdf9f0; }
.row-link > span { flex: 1; min-width: 0; }
.row-link b { display: block; }
.row-link small { display: block; font-size: var(--fs-sm); color: var(--ink-soft); }
.row-link svg { width: 22px; height: 22px; flex: none; color: var(--ink-faint); }
.std-list em { margin-left: auto; font-style: normal; font-size: var(--fs-xs); font-weight: 800; color: var(--ink-faint); white-space: nowrap; }
.evidence-note { display: flex; gap: 6px; align-items: flex-start; margin-top: var(--s2); font-size: var(--fs-sm); color: var(--sky-ink); font-weight: 700; }
.evidence-note svg { width: 16px; height: 16px; flex: none; margin-top: 3px; }

/* ---------------------------------------------------------------- notes */
.read-meta { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; margin-top: var(--s3); font-size: var(--fs-sm); color: var(--ink-soft); }
.more { margin-top: var(--s4); border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.more > summary { display: flex; align-items: center; gap: var(--s2); min-height: 52px; padding: 0 var(--s4); cursor: pointer; font-weight: 800; color: var(--sky-ink); list-style: none; }
.more > summary::-webkit-details-marker { display: none; }
.more > summary::after { content: '+'; margin-left: auto; font-size: 22px; line-height: 1; color: var(--ink-faint); }
.more[open] > summary::after { content: '−'; }
.more-body { padding: 0 var(--s4) var(--s4); min-width: 0; }
.more .example { border: 0; border-radius: 0; }
.concept-block + .concept-block { margin-top: var(--s5); }
.subhead-plain { font-size: var(--fs-md); font-weight: 800; margin-bottom: var(--s2); }
.callout-box { margin: var(--s4) 0; padding: var(--s3) var(--s4); border-left: 4px solid var(--sky-ink); background: var(--sky-pale); border-radius: 0 var(--r-md) var(--r-md) 0; }
.example-mode { padding: var(--s2) var(--s4) 0; }
.step-ctrl { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; padding: 0 var(--s5) var(--s4); }
.step-ctrl[hidden], .example-tail[hidden], .example-mode[hidden] { display: none; }
@media (max-width: 599px) { .example-q, .example-plan, .wsteps, .example-end, .step-ctrl { padding-left: var(--s4); padding-right: var(--s4); } }

/* ---------------------------------------------------------------- exercise */
.seg-mode { display: flex; flex-wrap: wrap; width: fit-content; max-width: 100%; border-radius: var(--r-md); }
.seg-mode a { white-space: normal; text-align: center; }
@media (max-width: 420px) {
  .jump { gap: var(--s2); }
  .jump a { min-height: 44px; padding-inline: 12px; }
  .seg-mode { width: 100%; }
  .seg-mode a { flex: 1 1 145px; }
}
.hint-box { margin-top: var(--s2); padding: var(--s3) var(--s4); border-radius: var(--r-md); background: #fff; border: 1px solid #f1d58a; }
.hint-title { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: var(--fs-sm); color: #8a5a00; }
.hint-title svg { width: 18px; height: 18px; }
.hint-box ol { padding-left: 1.3em; margin-top: 6px; }
.wparts { display: grid; gap: var(--s5); margin-top: var(--s4); }
.wpart { display: grid; gap: var(--s2); min-width: 0; }
.wpart + .wpart { padding-top: var(--s4); border-top: 1px dashed var(--line); }
.wpart-prompt { font-weight: 600; overflow-x: auto; overflow-y: hidden; }
.wpart .answer-field { margin-top: 0; }
.wpart-row { display: flex; flex-wrap: wrap; gap: var(--s2); }
.wpart-row input { flex: 1 1 200px; }
.wpart .feedback { border: 1px solid; border-radius: var(--r-md); }
.wpart .explain { border: 1px solid var(--line); border-radius: var(--r-md); margin-top: var(--s2); }
.feedback.is-self { background: var(--sky-pale); border-color: #b9e2f0; }
.feedback.is-self .feedback-title { color: var(--sky-ink); }
.feedback ol { padding-left: 1.3em; }

/* ---------------------------------------------------------------- game */
.worlds { list-style: none; display: grid; gap: var(--s4); }
.world { padding: var(--s4); border: 1px solid var(--line); border-radius: 18px; background: var(--card); }
.world.is-playable { border: 3px solid var(--wood); box-shadow: var(--shadow-wood); background: var(--paper); }
.world-head { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s3); margin-bottom: var(--s3); }
.world-head > div { flex: 1 1 200px; }
.world-head h3 { font-size: var(--fs-lg); }
.world-no { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: var(--grass); color: #fff; font-family: var(--font-display); font-size: 22px; border: 2px solid var(--grass-dark); }
.world:not(.is-playable) .world-no { background: #efedea; color: var(--ink-faint); border-color: var(--line-strong); }
.world-note { margin: 0; }
.level-mastery { display: flex; flex-wrap: wrap; gap: 6px 8px; align-items: center; margin-top: var(--s2) !important; }

/* ---------------------------------------------------------------- progress */
.prog-summary { margin-top: var(--s3); font-weight: 700; color: var(--ink); }
.prog-list { list-style: none; display: grid; gap: var(--s2); }
.prog-ch { padding: var(--s3) var(--s4); border: 1px solid var(--line); border-radius: 16px; background: var(--card); }
.prog-ch.is-soon { background: transparent; border-style: dashed; }
.prog-ch-head { display: flex; align-items: center; gap: var(--s3); }
.prog-ch-head > div { flex: 1; min-width: 0; display: grid; }
.prog-ch-head a { color: var(--ink); text-decoration: none; }
.prog-ch-head a:hover { text-decoration: underline; }
.prog-subs { list-style: none; display: grid; gap: var(--s2); margin-top: var(--s3); padding-top: var(--s3); border-top: 1px solid var(--line); }
.prog-subs li { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.prog-subs li > a { color: var(--ink); }
.prog-subs li > .small { flex-basis: 100%; }
.prog-subs .evidence-note { flex-basis: 100%; margin-top: 0; }
.rules { display: grid; gap: var(--s3); margin-bottom: var(--s3); }
.rules > div { display: grid; gap: 4px; }
.rules dd { margin: 0; font-size: var(--fs-sm); }
.confirm { padding: var(--s3) var(--s4); border: 2px solid var(--bad-line); border-radius: var(--r-md); background: var(--bad-bg); }

/* Kemajuan: folded chapters, game records, record export/import */
.prog-fold { margin-top: var(--s2); }
.prog-fold .prog-list { margin-top: var(--s2); }
.game-recs { list-style: none; display: grid; gap: var(--s2); margin-top: var(--s2); }
.game-recs li { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s2) var(--s3); border: 1px solid var(--line); border-radius: var(--r-md); }
.game-recs li span { display: grid; gap: 2px; }
.game-recs small { color: var(--ink-soft); }
.level-rec { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.data-io label.btn { cursor: pointer; }
.data-io input[type=file]:focus-visible + label.btn { outline: 2px solid currentColor; outline-offset: 2px; }
