/* JavaScript Professional Engineering Academy: shared styles.
   Light and dark themes, level colours, code editor, panels, reduced motion and focus styles. */
:root {
  --bg: #f6f7f9; --surface: #ffffff; --surface-2: #eef1f5; --surface-3: #e4e8ef; --ink: #141923; --ink-2: #4b5466; --ink-3: #6b7385; --line: #dce1e9;
  --accent: #2f5bd3; --accent-2: #1d3f9e; --accent-ink: #ffffff; --accent-bg: #e8eefc;
  --ok: #137333; --ok-bg: #e6f4ea; --no: #b3261e; --no-bg: #fce8e6; --warn: #7a4b00; --warn-bg: #fdf1dc; --info-bg: #e8f0fe;
  --l1: #2f7d4f; --l2: #2563a6; --l3: #7a4cc2; --l4: #b4532a; --l5: #0f766e; --l6: #a3245e;
  --l1-bg: #e5f3ea; --l2-bg: #e4eef9; --l3-bg: #efe8fa; --l4-bg: #fbece4; --l5-bg: #e0f3f1; --l6-bg: #f9e6ef;
  --code-bg: #0f1420; --code-ink: #e6e9f2; --code-line: #273049; --code-gutter: #6b7591;
  --tk-kw: #c792ea; --tk-str: #a5d6a7; --tk-num: #f7a96b; --tk-com: #7f8aa6; --tk-fn: #82aaff; --tk-pun: #b8c0d6; --tk-lit: #ff8f8f;
  --radius: 12px; --radius-sm: 8px; --shadow: 0 1px 2px rgba(16,24,40,.06), 0 4px 18px rgba(16,24,40,.06);
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1117; --surface: #151b24; --surface-2: #1c2430; --surface-3: #252f3d; --ink: #e8ecf3; --ink-2: #aab3c4; --ink-3: #8a94a8; --line: #2b3545;
    --accent: #84a6ff; --accent-2: #a9c1ff; --accent-ink: #0d1117; --accent-bg: #1b2a4a;
    --ok: #7fd49b; --ok-bg: #12301f; --no: #ff9a92; --no-bg: #3b1715; --warn: #f5c869; --warn-bg: #362812; --info-bg: #172640;
    --l1: #6fcf97; --l2: #79b0f0; --l3: #b99af0; --l4: #f0a07a; --l5: #5fd0c2; --l6: #f08bbb;
    --l1-bg: #14301f; --l2-bg: #132842; --l3-bg: #261c3d; --l4-bg: #3a2216; --l5-bg: #0f2e2b; --l6-bg: #3a1528;
    --code-bg: #0a0e16; --code-line: #222b3d;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1117; --surface: #151b24; --surface-2: #1c2430; --surface-3: #252f3d; --ink: #e8ecf3; --ink-2: #aab3c4; --ink-3: #8a94a8; --line: #2b3545;
  --accent: #84a6ff; --accent-2: #a9c1ff; --accent-ink: #0d1117; --accent-bg: #1b2a4a;
  --ok: #7fd49b; --ok-bg: #12301f; --no: #ff9a92; --no-bg: #3b1715; --warn: #f5c869; --warn-bg: #362812; --info-bg: #172640;
  --l1: #6fcf97; --l2: #79b0f0; --l3: #b99af0; --l4: #f0a07a; --l5: #5fd0c2; --l6: #f08bbb;
  --l1-bg: #14301f; --l2-bg: #132842; --l3-bg: #261c3d; --l4-bg: #3a2216; --l5-bg: #0f2e2b; --l6-bg: #3a1528;
  --code-bg: #0a0e16; --code-line: #222b3d;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 72px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.6 var(--sans); }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
img, svg { max-width: 100%; }
code, pre, kbd, samp { font-family: var(--mono); font-size: .9em; }
:not(pre) > code { background: var(--surface-2); padding: .1em .35em; border-radius: 5px; border: 1px solid var(--line); }
pre { margin: 0; }
h1, h2, h3, h4 { line-height: 1.25; margin: 1.3em 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); letter-spacing: -.025em; margin-top: .3em; }
h2 { font-size: clamp(1.3rem, 2.4vw, 1.65rem); }
h3 { font-size: 1.15rem; }
p, li { max-width: 76ch; }
.skip { position: absolute; left: -9999px; } .skip:focus { left: 16px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 99; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--ink-2); } .small { font-size: .88rem; } .tiny { font-size: .78rem; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* header */
.top { position: sticky; top: 0; z-index: 40; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; gap: 14px; min-height: 58px; flex-wrap: wrap; padding-top: 6px; padding-bottom: 6px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; color: var(--ink); text-decoration: none; letter-spacing: -.02em; }
.brand .mark { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: #f0db4f; color: #1d1d1d; font: 800 13px/1 var(--mono); }
.brand small { display: block; font-weight: 500; color: var(--ink-3); font-size: .72rem; letter-spacing: 0; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.nav a { padding: 6px 10px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-weight: 550; font-size: .93rem; }
.nav a:hover, .nav a[aria-current="page"] { background: var(--surface-2); color: var(--ink); }
.tools { display: flex; gap: 6px; align-items: center; }
.crumbs { font-size: .85rem; color: var(--ink-3); padding: 14px 0 0; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.crumbs li + li::before { content: "/"; margin-right: 6px; color: var(--line); }
.crumbs a { color: var(--ink-2); }

/* buttons and inputs */
button, .btn { font: inherit; font-weight: 600; font-size: .93rem; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 8px 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; line-height: 1.3; }
button:hover, .btn:hover { background: var(--surface-2); }
button:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary, button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover, button.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: .84rem; border-radius: 7px; }
input[type="text"], input[type="number"], input[type="search"], input[type="url"], select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; max-width: 100%; }
label { font-weight: 600; }
.field { display: grid; gap: 4px; margin: 0 0 12px; }
.field small { color: var(--ink-3); font-weight: 400; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; border-radius: 0; padding: 6px 12px; font-size: .86rem; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }

/* layout pieces */
main { padding-bottom: 64px; }
.hero { padding: 48px 0 28px; }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); max-width: 20ch; }
.lede { font-size: 1.15rem; color: var(--ink-2); max-width: 64ch; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card h3 { margin-top: 0; }
.card > :last-child { margin-bottom: 0; }
a.card { color: inherit; text-decoration: none; display: block; }
a.card:hover { border-color: var(--accent); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin: 18px 0; }
.panel > h2:first-child, .panel > h3:first-child { margin-top: 0; }
.actions4 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); margin: 24px 0; }
.action { display: flex; gap: 12px; align-items: flex-start; padding: 16px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); text-decoration: none; color: var(--ink); box-shadow: var(--shadow); }
.action:hover { border-color: var(--accent); }
.action .n { flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-bg); color: var(--accent); font-weight: 800; }
.action strong { display: block; }
.action span { color: var(--ink-2); font-size: .9rem; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .74rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); text-transform: none; white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.badge.info { background: var(--info-bg); color: var(--accent); border-color: transparent; }
.badge.planned { background: transparent; border-style: dashed; color: var(--ink-3); }
.lv { --c: var(--l1); --cb: var(--l1-bg); }
.lv-1 { --c: var(--l1); --cb: var(--l1-bg); } .lv-2 { --c: var(--l2); --cb: var(--l2-bg); } .lv-3 { --c: var(--l3); --cb: var(--l3-bg); }
.lv-4 { --c: var(--l4); --cb: var(--l4-bg); } .lv-5 { --c: var(--l5); --cb: var(--l5-bg); } .lv-6 { --c: var(--l6); --cb: var(--l6-bg); }
.lvtag { display: inline-block; font-size: .74rem; font-weight: 750; padding: 2px 9px; border-radius: 999px; color: var(--c); background: var(--cb); letter-spacing: .01em; }
.lvbar { border-left: 4px solid var(--c); }
.note { border-radius: var(--radius-sm); padding: 12px 14px; background: var(--info-bg); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); margin: 12px 0; }
.note.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.note.ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.note > :first-child { margin-top: 0; } .note > :last-child { margin-bottom: 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; }
.kv dt { font-weight: 650; color: var(--ink-2); } .kv dd { margin: 0; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink-2); font-weight: 650; background: var(--surface-2); }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.table-wrap table { min-width: 560px; }
details { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); margin: 10px 0; }
details > summary { cursor: pointer; padding: 10px 14px; font-weight: 650; list-style-position: inside; }
details[open] > summary { border-bottom: 1px solid var(--line); }
details > .body { padding: 12px 16px; }
.foot { border-top: 1px solid var(--line); padding: 28px 0 40px; color: var(--ink-2); font-size: .9rem; background: var(--surface); }
.foot a { color: var(--ink-2); }
.foot .cols { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.foot h2 { font-size: .95rem; margin: 0 0 8px; color: var(--ink); }
.foot ul { list-style: none; margin: 0; padding: 0; } .foot li { margin: 4px 0; }

/* code editor */
.editor { position: relative; border-radius: var(--radius-sm); background: var(--code-bg); color: var(--code-ink); border: 1px solid var(--code-line); overflow: hidden; }
.editor-head { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: color-mix(in srgb, var(--code-bg) 85%, #fff 15%); color: #b9c2d8; font-size: .8rem; border-bottom: 1px solid var(--code-line); flex-wrap: wrap; }
.editor-head .fname { font-family: var(--mono); color: #dfe5f3; }
.editor-head .spacer { flex: 1; }
.editor-head button { background: transparent; color: #cfd6e6; border-color: #39445e; padding: 3px 9px; font-size: .78rem; }
.editor-head button:hover { background: #222b3f; }
.editor-body { position: relative; display: grid; grid-template-columns: auto 1fr; max-height: 520px; overflow: auto; }
.gutter { padding: 12px 8px 12px 12px; text-align: right; color: var(--code-gutter); font: 14px/1.55 var(--mono); user-select: none; white-space: pre; }
.code-area { position: relative; }
.code-area pre, .code-area textarea { font: 14px/1.55 var(--mono); padding: 12px 14px 12px 6px; margin: 0; white-space: pre; tab-size: 2; letter-spacing: normal; word-spacing: normal; }
.code-area pre { pointer-events: none; color: var(--code-ink); min-height: 100%; }
.code-area textarea { position: absolute; inset: 0; width: 100%; height: 100%; resize: none; border: 0; border-radius: 0; outline: 0; background: transparent; color: transparent; caret-color: #fff; overflow: hidden; }
.code-area textarea::selection { background: rgba(130,170,255,.35); color: transparent; }
.editor:focus-within { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 55%, transparent); }
.editor .hl-line { background: rgba(255,214,102,.16); display: inline-block; width: 100%; }
.editor .err-line { background: rgba(255,107,107,.18); display: inline-block; width: 100%; }
.tk-kw { color: var(--tk-kw); } .tk-str { color: var(--tk-str); } .tk-num { color: var(--tk-num); } .tk-com { color: var(--tk-com); font-style: italic; } .tk-fn { color: var(--tk-fn); } .tk-pun { color: var(--tk-pun); } .tk-lit { color: var(--tk-lit); }
.static-code { background: var(--code-bg); color: var(--code-ink); padding: 12px 14px; border-radius: var(--radius-sm); overflow-x: auto; font: 14px/1.55 var(--mono); white-space: pre; border: 1px solid var(--code-line); }
.editor-help { font-size: .78rem; color: var(--ink-3); margin: 4px 2px 0; }

/* run panel */
.runbox { margin: 14px 0; }
.runbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.runbar .spacer { flex: 1; }
.console { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); font: 13.5px/1.5 var(--mono); min-height: 44px; max-height: 320px; overflow: auto; }
.console-head { display: flex; justify-content: space-between; gap: 8px; padding: 6px 10px; font: 600 .78rem/1.4 var(--sans); color: var(--ink-3); border-bottom: 1px solid var(--line); background: var(--surface-2); }
.console ol { list-style: none; margin: 0; padding: 4px 0; }
.console li { padding: 2px 12px; white-space: pre-wrap; word-break: break-word; border-bottom: 1px dashed transparent; max-width: none; }
.console li.warn { background: var(--warn-bg); color: var(--warn); }
.console li.error { background: var(--no-bg); color: var(--no); }
.console li.info { color: var(--accent); }
.console li.system { color: var(--ink-3); font-style: italic; }
.console .empty { padding: 8px 12px; color: var(--ink-3); font-family: var(--sans); font-size: .88rem; }
.errbox { border: 1px solid color-mix(in srgb, var(--no) 40%, transparent); background: var(--no-bg); border-radius: var(--radius-sm); padding: 12px 14px; margin: 10px 0; }
.errbox h4 { margin: 0 0 6px; color: var(--no); font-size: 1rem; }
.errbox p { margin: 6px 0; }
.tests { margin: 10px 0; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; }
.tests-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 12px; background: var(--surface-2); font-weight: 650; flex-wrap: wrap; }
.tests ul { list-style: none; margin: 0; padding: 0; }
.tests li { padding: 9px 12px; border-top: 1px solid var(--line); max-width: none; display: grid; grid-template-columns: 24px 1fr; gap: 2px 8px; }
.tests li .ic { font-weight: 800; }
.tests li.pass .ic { color: var(--ok); } .tests li.fail .ic { color: var(--no); }
.tests .detail { grid-column: 2; font-size: .86rem; color: var(--ink-2); }
.tests .detail code { white-space: pre-wrap; word-break: break-word; }
.preview-frame { width: 100%; min-height: 220px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; }
.split { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); align-items: start; }

/* lesson */
.lesson-head { padding: 18px 0 8px; }
.lesson-head .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.opening { font-size: 1.2rem; font-weight: 600; color: var(--ink); border-left: 4px solid var(--c, var(--accent)); padding: 4px 0 4px 14px; margin: 14px 0; max-width: 70ch; }
.lesson-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 28px; align-items: start; }
.toc { position: sticky; top: 76px; font-size: .9rem; max-height: calc(100vh - 96px); overflow: auto; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc a { display: block; padding: 5px 10px; border-radius: 7px; color: var(--ink-2); text-decoration: none; border-left: 2px solid transparent; }
.toc a:hover { background: var(--surface-2); }
.toc a.done::after { content: " ✓"; color: var(--ok); font-weight: 800; }
@media (max-width: 900px) { .lesson-layout { grid-template-columns: 1fr; } .toc { position: static; max-height: none; } .toc ol { display: flex; flex-wrap: wrap; gap: 4px; } }
.section { scroll-margin-top: 76px; padding: 2px 0 8px; border-bottom: 1px solid var(--line); }
.section:last-child { border-bottom: 0; }
.section > h2 { display: flex; align-items: baseline; gap: 10px; }
.section > h2 .num { font: 700 .8rem var(--mono); color: var(--ink-3); }
.explain-tabs { margin: 8px 0; }
.defs { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.defs div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; }
.defs dt { font-weight: 700; } .defs dd { margin: 4px 0 0; color: var(--ink-2); font-size: .93rem; }
.example { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 16px; margin: 16px 0; }
.example h3 { margin-top: 0; display: flex; gap: 8px; flex-wrap: wrap; align-items: baseline; }
.example .id { font: 600 .75rem var(--mono); color: var(--ink-3); }
.env { font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); }
.env.dom { background: var(--l3-bg); color: var(--l3); border-color: transparent; }
.env.worker { background: var(--l2-bg); color: var(--l2); border-color: transparent; }
.env.node { background: var(--l5-bg); color: var(--l5); border-color: transparent; }
.env.sim { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.expected { font: 13.5px/1.5 var(--mono); background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 12px; white-space: pre-wrap; border: 1px solid var(--line); }
.choices { display: grid; gap: 8px; margin: 10px 0; padding: 0; border: 0; }
.choices legend { font-weight: 650; margin-bottom: 6px; padding: 0; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; font-weight: 500; }
.choice:hover { border-color: var(--accent); }
.choice input { margin-top: 4px; }
.choice.correct { border-color: var(--ok); background: var(--ok-bg); }
.choice.wrong { border-color: var(--no); background: var(--no-bg); }
.feedback { margin: 8px 0; padding: 10px 12px; border-radius: var(--radius-sm); }
.feedback.ok { background: var(--ok-bg); color: var(--ink); border-left: 4px solid var(--ok); }
.feedback.no { background: var(--no-bg); color: var(--ink); border-left: 4px solid var(--no); }
.exercise { border: 1px solid var(--line); border-left: 4px solid var(--c, var(--accent)); border-radius: var(--radius); background: var(--surface); padding: 16px 18px; margin: 18px 0; }
.exercise h3 { margin-top: 0; }
.exercise .xtype { font-size: .75rem; font-weight: 750; letter-spacing: .02em; color: var(--ink-3); text-transform: uppercase; }
.exercise.passed { border-left-color: var(--ok); }
.hints { margin: 8px 0; }
.hint { background: var(--warn-bg); border-radius: var(--radius-sm); padding: 10px 12px; margin: 6px 0; }
.hint strong { color: var(--warn); }
.steps { counter-reset: s; list-style: none; padding: 0; }
.steps > li { counter-increment: s; position: relative; padding: 0 0 0 38px; margin: 0 0 14px; }
.steps > li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-bg); color: var(--accent); display: grid; place-items: center; font-weight: 800; font-size: .85rem; }
.steps > li.done::before { content: "✓"; background: var(--ok-bg); color: var(--ok); }
.steps > li.current::before { background: var(--accent); color: var(--accent-ink); }
.mission { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 18px 20px; box-shadow: var(--shadow); }
.mission-progress { height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 8px 0 14px; }
.mission-progress span { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s; }
.callout-ai { border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 10px 14px; background: var(--surface); }
.prompt { position: relative; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); padding: 12px 14px; margin: 10px 0; }
.prompt pre { white-space: pre-wrap; font-size: .86rem; }
.prompt .row { margin-top: 8px; }

/* roadmap */
.road-level { margin: 22px 0; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); overflow: hidden; }
.road-level > header { padding: 14px 18px; border-left: 6px solid var(--c); background: var(--cb); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.road-level > header h2 { margin: 0; font-size: 1.2rem; }
.road-mods { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0; }
.road-mod { padding: 14px 18px; border-top: 1px solid var(--line); border-right: 1px solid var(--line); }
.road-mod h3 { font-size: .98rem; margin: 0 0 6px; }
.road-mod ol { margin: 0; padding-left: 0; list-style: none; font-size: .9rem; }
.road-mod li { display: flex; gap: 6px; align-items: baseline; padding: 2px 0; }
.road-mod li .ln { font: 600 .74rem var(--mono); color: var(--ink-3); min-width: 26px; }
.state-dot { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: inline-block; transform: translateY(1px); }
.state-dot[data-s="explored"] { border-color: var(--accent); }
.state-dot[data-s="practiced"] { background: color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
.state-dot[data-s="demonstrated"] { background: var(--accent); border-color: var(--accent); }
.state-dot[data-s="mastered"] { background: var(--ok); border-color: var(--ok); }
.road-projects { padding: 12px 18px; border-top: 1px solid var(--line); font-size: .9rem; display: flex; flex-wrap: wrap; gap: 6px 10px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .85rem; color: var(--ink-2); align-items: center; }
.legend span { display: inline-flex; gap: 6px; align-items: center; }

/* project cards */
.pcard { position: relative; display: flex; flex-direction: column; gap: 6px; }
.pcard .pn { font: 700 .78rem var(--mono); color: var(--ink-3); }
.pcard h3 { margin: 0; font-size: 1.02rem; }
.pcard.planned { background: transparent; box-shadow: none; border-style: dashed; }
.pcard.planned h3 { color: var(--ink-2); }
.stagebar { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.stagebar button { font-size: .82rem; padding: 5px 10px; }
.stagebar button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.filetabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.filetabs button { font: 600 .8rem var(--mono); padding: 4px 10px; }
.filetabs button[aria-selected="true"] { background: var(--code-bg); color: var(--code-ink); border-color: var(--code-bg); }
.state-view { font: 13px/1.5 var(--mono); background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; white-space: pre-wrap; max-height: 300px; overflow: auto; }

/* visualizer */
.viz { display: grid; gap: 14px; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
@media (max-width: 860px) { .viz { grid-template-columns: 1fr; } }
.viz-code { font: 14px/1.6 var(--mono); background: var(--code-bg); color: var(--code-ink); border-radius: var(--radius-sm); padding: 10px 0; overflow-x: auto; }
.viz-code div { padding: 0 14px; white-space: pre; }
.viz-code div.cur { background: rgba(255,214,102,.2); box-shadow: inset 4px 0 0 #ffd666; }
.viz-code .ln { display: inline-block; width: 2.4em; color: var(--code-gutter); text-align: right; margin-right: 12px; user-select: none; }
.scope-box { border: 1px solid var(--line); border-radius: var(--radius-sm); margin: 0 0 8px; background: var(--surface); }
.scope-box h4 { margin: 0; padding: 6px 10px; font-size: .82rem; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.scope-box table { font-size: .86rem; } .scope-box td { font-family: var(--mono); padding: 4px 10px; }
.stack-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column-reverse; gap: 4px; }
.stack-list li { font: 13px var(--mono); background: var(--l3-bg); color: var(--l3); border-radius: 6px; padding: 4px 10px; }
.changed td { background: var(--warn-bg); }

/* object widgets */
.obj-stage { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 16px; }
.boxes { display: flex; flex-wrap: wrap; gap: 12px; margin: 10px 0; }
.vbox { min-width: 120px; border: 2px solid var(--c, var(--accent)); border-radius: 10px; padding: 8px 12px; background: var(--surface); }
.vbox .nm { font: 700 .8rem var(--mono); color: var(--ink-2); }
.vbox .vl { font: 700 1.05rem var(--mono); }
.vbox .tp { font-size: .72rem; color: var(--ink-3); }
.vbox.const { border-style: double; border-width: 4px; }
.vbox.flash { animation: flash .6s; }
@keyframes flash { from { background: var(--warn-bg); } to { background: var(--surface); } }
.tree { font: 14px/1.4 var(--mono); }
.tree ul { list-style: none; padding-left: 22px; margin: 0; border-left: 1px dashed var(--line); }
.tree li { margin: 4px 0; max-width: none; }
.tree .node { display: inline-flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 3px 8px; background: var(--surface); }
.tree .node .val { color: var(--ok); font-weight: 700; }
.tree .node .op { color: var(--l3); font-weight: 800; }
.order-n { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent-bg); color: var(--accent); font-size: .7rem; font-weight: 800; }

/* toast and dialog */
.live { position: fixed; bottom: 16px; right: 16px; z-index: 90; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); font-size: .92rem; }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink); padding: 0; max-width: min(640px, calc(100vw - 32px)); width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(10,14,22,.5); }
dialog .dlg-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
dialog .dlg-head h2 { margin: 0; font-size: 1.15rem; }
dialog .dlg-body { padding: 16px 18px; max-height: 70vh; overflow: auto; }
.next-fab { position: fixed; right: 16px; bottom: 16px; z-index: 30; box-shadow: var(--shadow); }
@media print { .top, .next-fab, .foot, .runbar, .toc { display: none !important; } }

/* mode visibility */
body[data-mode="professional"] .guided-only, body[data-mode="explore"] .guided-only { display: none; }
body[data-mode="guided"] .pro-only, body[data-mode="explore"] .pro-only { display: none; }

/* presenter */
.presenter { display: grid; grid-template-columns: minmax(300px, 420px) minmax(0, 1fr); gap: 16px; align-items: start; }
@media (max-width: 960px) { .presenter { grid-template-columns: 1fr; } }
.narration { position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow: auto; }
.scene { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin: 8px 0; background: var(--surface); }
.scene.current { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.scene h4 { margin: 0 0 4px; font-size: .9rem; }
.app-frame { width: 100%; height: 78vh; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
@media (max-width: 640px) { .nav { width: 100%; margin-left: 0; overflow-x: auto; flex-wrap: nowrap; } .hero { padding-top: 28px; } }

/* ---------- workspaces and learning objects */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
.chip { padding: 4px 10px; font-size: .84rem; border-radius: 999px; font-weight: 500; }
.mono { font-family: var(--mono); }
input.wide { width: 100%; }
.row > input[type="text"], .row > input:not([type]) { flex: 1 1 220px; min-width: 0; }
.toolbar { align-items: end; margin: 0 0 12px; } .toolbar .field { margin: 0; }
.ok-text { color: var(--ok); } .no-text { color: var(--no); }
button.danger { border-color: var(--no); color: var(--no); }
.kv-table th { text-align: left; width: 38%; font-weight: 600; color: var(--ink-2); }
.kv-table td, .kv-table th { padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: pre-wrap; }
code.outline { background: var(--surface-2); border: 1px solid var(--line); border-radius: 6px; padding: 2px 8px; white-space: pre-wrap; }
.fields-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.tlb-out { padding-left: 1.2em; } .tlb-out li { margin: 4px 0; }
/* stepper */
.scopes { display: flex; flex-direction: column; gap: 8px; }
.scope { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.scope-name { font-size: .8rem; font-weight: 700; padding: 5px 10px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.var { display: grid; grid-template-columns: minmax(70px, auto) 1fr auto; gap: 10px; padding: 5px 10px; border-bottom: 1px solid var(--line); align-items: baseline; }
.var:last-child { border-bottom: 0; }
.var .vname { font: 600 13px var(--mono); } .var .vval { font-size: 13px; overflow-wrap: anywhere; }
.var.changed { background: var(--warn-bg); } .var.tdz .vval { color: var(--ink-3); font-style: italic; }
ol.stack { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
ol.stack li { font: 13px var(--mono); background: var(--l3-bg); color: var(--l3); border-radius: 6px; padding: 4px 10px; }
ol.stack li.muted { background: var(--surface-2); color: var(--ink-3); }
.stepper input[type="range"] { flex: 1 1 160px; }
.editor .code-area .hl-line { background: color-mix(in srgb, #f0db4f 22%, transparent); display: inline-block; width: 100%; }
/* expression tree */
.etree { overflow-x: auto; padding: 4px 0; }
.enode { display: inline-flex; flex-direction: column; align-items: center; gap: 6px; padding: 0 4px; }
.enode.leaf { padding: 4px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); }
.eop { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border-radius: 8px; background: var(--accent-bg); border: 1px solid var(--accent); }
.estep { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: .72rem; font-weight: 700; }
.eval { color: var(--ink-2); }
.ekids { display: flex; gap: 10px; align-items: flex-start; border-top: 2px solid var(--line); padding-top: 6px; }
.esteps li { margin: 4px 0; }
/* sorter */
.sorter { display: grid; gap: 8px; }
.sort-row { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; margin: 0; }
.sort-row legend { font-weight: 600; padding: 0 4px; }
.choice.inline { display: inline-flex; margin-right: 14px; }
/* mission */
.mission-grid { display: grid; gap: 16px; grid-template-columns: minmax(240px, 340px) minmax(0, 1fr); align-items: start; }
@media (max-width: 860px) { .mission-grid { grid-template-columns: 1fr; } }
.mission-steps { padding-left: 1.3em; margin: 0 0 10px; } .mission-steps li { margin: 6px 0; color: var(--ink-3); }
.mission-steps li.current { color: var(--ink); } .mission-steps li.done { color: var(--ok); }
/* portfolio */
.stats .stat { display: grid; gap: 4px; } .big { font-size: 1.7rem; }
.skill-list { list-style: none; padding: 0; columns: 2 220px; } .skill-list li { margin: 4px 0; display: flex; gap: 8px; align-items: center; }
/* presenter */
.presenter-frame { width: 100%; height: 78vh; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.say { font-size: 1.15rem; line-height: 1.5; }
.demo-list li { margin: 8px 0; }
.stage-info { border-left: 4px solid var(--c, var(--accent)); padding-left: 14px; margin: 0 0 12px; }
/* small-screen overflow guards */
@media (max-width: 900px) { .lesson-layout { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) { .mission-grid { grid-template-columns: minmax(0, 1fr); } }
.mission-grid > *, .grid-2 > *, .lesson-layout > * { min-width: 0; }
.toolbar .field { min-width: 0; max-width: 100%; } select { max-width: 100%; }
.editor, .runbox { max-width: 100%; min-width: 0; }
.field { grid-template-columns: minmax(0, 1fr); } .toolbar > .field { flex: 1 1 200px; }
/* learning objects 003–015 */
.str-ruler { display: flex; flex-wrap: wrap; gap: 3px; margin: 6px 0 12px; }
.str-cell { display: inline-flex; flex-direction: column; align-items: center; min-width: 26px; border: 1px solid var(--line); border-radius: 6px; padding: 2px 4px; background: var(--surface-2, var(--surface)); }
.str-cell small { font-size: 11px; color: var(--ink-3, var(--ink-2)); }
.fle-steps { max-height: 260px; overflow: auto; padding-left: 1.6em; }
.fle-steps li { margin: 2px 0; }
.pattern-out { font-family: var(--mono, ui-monospace, monospace); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; overflow-x: auto; min-height: 2em; line-height: 1.35; }
.chip[aria-pressed="true"] { outline: 2px solid var(--accent, currentColor); }
/* Level 2 learning objects */
.grid-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.grid-table th, .grid-table td { padding: 5px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: pre-wrap; }
.grid-table thead th { color: var(--ink-2); font-weight: 600; }
.grid-table caption { text-align: left; padding: 4px 0; }
.arr-cells { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0 12px; }
.arr-cell { display: inline-flex; flex-direction: column; align-items: center; min-width: 44px; border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; background: var(--surface-2, var(--surface)); }
.arr-cell small { font-size: 11px; color: var(--ink-2); }
.arr-cell.hit { border-color: var(--ok); box-shadow: 0 0 0 2px var(--ok-bg); }
.path-steps { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0 12px; }
.path-step { border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; }
.path-step.missing { border-color: var(--no); background: var(--no-bg); }
.path-code { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 100%; }
.table-wrap table.grid-table { min-width: 0; }
