/* PyForge design system. Dark "forge" by default, with a light theme. */
:root {
  --bg: #15111f; --bg-2: #1b1628; --panel: #221c33; --panel-2: #2b2441; --line: #3a3256; --line-2: #4a4170;
  --text: #f4effc; --muted: #a99fc6; --faint: #7a7198;
  --ember: #ff7a3d; --ember-2: #ff9a5c; --ember-d: #c9531d; --gold: #ffc94d; --ice: #6fd3ff; --leaf: #4be38f; --berry: #ff5c8a; --violet: #c58bff;
  --ok: #4be38f; --ok-bg: #173c2b; --bad: #ff6b6b; --bad-bg: #44202a; --warn: #ffc94d;
  --code-bg: #100d19; --code-text: #ece6fb; --sel: #3b3260;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --r-s: 8px; --r-m: 12px; --r-l: 18px; --r-xl: 26px;
  --f-display: "Bricolage Grotesque", "Avenir Next", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, sans-serif;
  --f-code: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  --ad-h: 0px; --tab-h: 62px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f2fa; --bg-2: #ece8f6; --panel: #ffffff; --panel-2: #f3f0fa; --line: #ddd6ee; --line-2: #c9c0e2;
  --text: #1c1630; --muted: #625a7e; --faint: #8e86a8;
  --ember: #e8622a; --ember-2: #f07a3f; --ember-d: #b8481a; --gold: #c98f00; --ice: #1592c9; --leaf: #0f9d58; --berry: #d63b6a; --violet: #7d4fd0;
  --ok: #0f9d58; --ok-bg: #dcf5e7; --bad: #d63b3b; --bad-bg: #fde4e4; --warn: #b98000;
  --code-bg: #1b1628; --code-text: #ece6fb; --sel: #3b3260;
  --shadow: 0 10px 30px rgba(40, 20, 80, .12);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 400 16px/1.5 var(--f-body); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-user-select: none; user-select: none; touch-action: manipulation; }
a { color: var(--ice); }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
h1, h2, h3, h4 { font-family: var(--f-display); margin: 0; line-height: 1.1; letter-spacing: -.01em; }
h1 { font-size: 31px; font-weight: 800; }
h2 { font-size: 24px; font-weight: 700; }
h3 { font-size: 19px; font-weight: 700; }
p { margin: 0 0 .75em; }
code, kbd, pre { font-family: var(--f-code); }
code, kbd, pre, .cm-editor, .mono, .opt.code, .pline, .keys button { font-variant-ligatures: none; font-feature-settings: "liga" 0, "calt" 0; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 13.5px; }
.mono { font-family: var(--f-code); }
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.hide { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* boot */
.boot { height: 100vh; display: grid; place-items: center; }
.boot-spark { width: 18px; height: 18px; border-radius: 50%; background: var(--ember); box-shadow: 0 0 40px 10px rgba(255, 122, 61, .5); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(.6); opacity: .6; } }

/* ---------- shell ---------- */
.shell { min-height: 100vh; display: flex; }
.sidebar { display: none; }
.main { flex: 1; min-width: 0; padding: calc(var(--safe-t) + 14px) 16px calc(var(--tab-h) + var(--safe-b) + var(--ad-h) + 24px); max-width: 1100px; margin: 0 auto; width: 100%; }
.tabs { position: fixed; left: 0; right: 0; bottom: var(--ad-h); z-index: 30; display: flex; background: color-mix(in srgb, var(--bg-2) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabs button { flex: 1; background: none; border: 0; padding: 8px 0 7px; display: flex; flex-direction: column; align-items: center; gap: 3px; color: var(--faint); font-size: 11.5px; font-weight: 500; }
.tabs button svg { width: 24px; height: 24px; }
.tabs button.on { color: var(--text); }
.tabs button.on svg { color: var(--ember); }
.web-ad { position: fixed; left: 0; right: 0; bottom: 0; height: var(--ad-h); }
@media (min-width: 900px) {
  .sidebar { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; width: 232px; flex: none; padding: 22px 14px; border-right: 1px solid var(--line); background: var(--bg-2); }
  .sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 22px; font: 800 22px var(--f-display); }
  .sidebar button { display: flex; align-items: center; gap: 12px; background: none; border: 0; text-align: left; padding: 11px 12px; border-radius: var(--r-m); color: var(--muted); font-weight: 500; }
  .sidebar button svg { width: 22px; height: 22px; }
  .sidebar button:hover { background: var(--panel); color: var(--text); }
  .sidebar button.on { background: var(--panel-2); color: var(--text); }
  .sidebar button.on svg { color: var(--ember); }
  .sidebar .side-foot { margin-top: auto; }
  .tabs { display: none; }
  .main { padding: 30px 36px calc(40px + var(--ad-h)); }
}

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: var(--r-m); padding: 13px 18px; font: 600 16px var(--f-body); background: var(--ember); color: #1a0d05; box-shadow: 0 3px 0 var(--ember-d); transition: transform .06s, filter .15s; white-space: nowrap; }
.btn:hover { filter: brightness(1.06); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 var(--ember-d); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--panel-2); color: var(--text); box-shadow: 0 3px 0 var(--line); }
.btn.ghost:active:not(:disabled) { box-shadow: 0 1px 0 var(--line); }
.btn.ok { background: var(--leaf); color: #062614; box-shadow: 0 3px 0 #1f9c58; }
.btn.bad { background: var(--bad); color: #2a0606; box-shadow: 0 3px 0 #b33d3d; }
.btn.ice { background: var(--ice); color: #04263a; box-shadow: 0 3px 0 #2c93c0; }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn.tiny { padding: 5px 9px; font-size: 13px; border-radius: 8px; box-shadow: none; }
.link { background: none; border: 0; padding: 0; color: var(--ice); font-weight: 500; }
.icon-btn { width: 38px; height: 38px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); display: grid; place-items: center; flex: none; padding: 0; }
.icon-btn svg { width: 20px; height: 20px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); font-size: 13px; font-weight: 500; white-space: nowrap; }
.chip.ember { color: var(--ember); } .chip.gold { color: var(--gold); } .chip.ice { color: var(--ice); } .chip.leaf { color: var(--leaf); }
.chip.pro { background: linear-gradient(90deg, var(--ember), var(--gold)); color: #1a0d05; border: 0; font-weight: 700; font-size: 11.5px; padding: 2px 8px; }

/* ---------- cards ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l); padding: 18px; }
.card.tight { padding: 14px; }
.section { margin: 28px 0 12px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }

/* ---------- home ---------- */
.top { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.top h1 { font-size: 27px; }
.stat-pills { display: flex; gap: 8px; }
.hero { position: relative; overflow: hidden; border-radius: var(--r-xl); padding: 20px; background: radial-gradient(120% 140% at 100% 0%, color-mix(in srgb, var(--accent, var(--ember)) 38%, transparent), transparent 60%), var(--panel); border: 1px solid var(--line); display: flex; gap: 16px; align-items: center; }
.hero .nova { width: 92px; flex: none; }
@media (max-width: 560px) { .hero { display: block; padding-right: 20px; } .hero .nova { position: absolute; right: 12px; top: 10px; width: 64px; } .hero .kicker { padding-right: 70px; } .hero h2 { padding-right: 60px; } }
.hero .kicker { font-size: 13px; color: var(--muted); font-weight: 500; }
.hero h2 { margin: 2px 0 6px; }
.goal-ring { position: relative; width: 58px; height: 58px; flex: none; }
.goal-ring svg { transform: rotate(-90deg); }
.goal-ring span { position: absolute; inset: 0; display: grid; place-items: center; font: 700 13px var(--f-display); text-align: center; line-height: 1; }
.stage { margin-top: 34px; }
.stage-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.stage-num { font: 800 58px/0.82 var(--f-display); color: var(--stage); letter-spacing: -.04em; min-width: 34px; }
.stage-head p { margin: 4px 0 0; color: var(--muted); font-size: 14.5px; max-width: 60ch; }
.units { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 700px) { .units { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.unit { position: relative; text-align: left; border: 1px solid var(--line); border-radius: var(--r-l); padding: 14px 14px 12px; background: var(--panel); min-height: 132px; display: flex; flex-direction: column; overflow: hidden; }
.unit::before { content: ""; position: absolute; inset: 0; background: radial-gradient(90% 80% at 0% 100%, color-mix(in srgb, var(--stage) calc(var(--heat) * 55%), transparent), transparent 70%); pointer-events: none; }
.unit > * { position: relative; }
.unit .n { font: 800 30px/1 var(--f-display); color: var(--stage); }
.unit h4 { font: 700 16px/1.2 var(--f-display); margin: 6px 0 auto; }
.unit .meta { display: flex; align-items: center; justify-content: space-between; margin-top: 12px; font-size: 12.5px; color: var(--muted); }
.unit .bar { height: 5px; border-radius: 3px; background: var(--line); margin-top: 6px; overflow: hidden; }
.unit .bar i { display: block; height: 100%; background: var(--stage); border-radius: 3px; }
.unit.locked { opacity: .55; }
.unit.locked .n { color: var(--faint); }
.unit .badge { position: absolute; top: 12px; right: 12px; }
.unit.current { border-color: var(--stage); box-shadow: 0 0 0 1px var(--stage), 0 10px 30px color-mix(in srgb, var(--stage) 25%, transparent); }

/* ---------- unit page ---------- */
.back-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.unit-hero { border-radius: var(--r-xl); padding: 22px; background: radial-gradient(100% 120% at 100% 0%, color-mix(in srgb, var(--stage) 35%, transparent), transparent 65%), var(--panel); border: 1px solid var(--line); }
.unit-hero .n { font: 800 64px/0.85 var(--f-display); color: var(--stage); }
.skills { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding-left: 52px; }
.timeline li::before { content: ""; position: absolute; left: 19px; top: 44px; bottom: -6px; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.tl-node { position: absolute; left: 0; top: 10px; width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font: 700 15px var(--f-display); background: var(--panel-2); border: 2px solid var(--line); }
.tl-node.done { background: var(--stage); border-color: var(--stage); color: #160f05; }
.tl-node.open { border-color: var(--stage); color: var(--stage); }
.tl-item { width: 100%; text-align: left; display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l); padding: 14px 16px; margin-bottom: 10px; }
.tl-item:disabled { opacity: .5; cursor: not-allowed; }
.tl-item .title { font-weight: 600; }
.extra-card { display: flex; gap: 14px; align-items: center; width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l); padding: 16px; margin-bottom: 10px; }
.extra-card .ico { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; flex: none; background: var(--panel-2); }
.extra-card .ico svg { width: 26px; height: 26px; }

/* ---------- full-screen player (lessons & projects) ---------- */
.player { position: fixed; inset: 0; z-index: 40; background: var(--bg); display: flex; flex-direction: column; padding-top: var(--safe-t); }
.player-top { display: flex; align-items: center; gap: 12px; padding: 10px 16px; max-width: 1100px; width: 100%; margin: 0 auto; }
.progress { flex: 1; height: 10px; border-radius: 6px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--ember), var(--gold)); transition: width .35s ease; }
.player-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.player-inner { max-width: 760px; margin: 0 auto; padding: 8px 16px 40px; }
.player-inner.wide { max-width: 1240px; }
.ex-kind { display: inline-flex; align-items: center; gap: 6px; font: 600 13px var(--f-body); color: var(--ember); margin-bottom: 8px; }
.ex-q { font: 600 20px/1.35 var(--f-display); margin: 0 0 14px; }
.player-foot { border-top: 1px solid var(--line); padding: 14px 16px calc(14px + var(--safe-b)); background: var(--bg-2); }
.player-foot .inner { max-width: 760px; margin: 0 auto; display: flex; gap: 10px; align-items: center; }
.player:has(.player-inner.wide) .player-foot .inner, .player:has(.player-inner.wide) .player-top { max-width: 1240px; }
.player-foot.ok { background: var(--ok-bg); border-color: transparent; }
.player-foot.bad { background: var(--bad-bg); border-color: transparent; }
.verdict { font: 700 19px var(--f-display); }
.player-foot.ok .verdict { color: var(--ok); }
.player-foot.bad .verdict { color: var(--bad); }
.why { font-size: 14.5px; margin-top: 3px; }
@media (min-width: 980px) {
  .split { display: grid; grid-template-columns: minmax(300px, 0.85fr) 1.15fr; gap: 26px; align-items: start; }
  .split > .sticky { position: sticky; top: 0; }
}

/* text from lessons */
.md p { margin: 0 0 .7em; }
.md ul, .md ol { margin: 0 0 .7em; padding-left: 1.3em; }
.md-table { overflow-x: auto; margin: 0 0 .8em; border: 1px solid var(--line); border-radius: var(--r-m); }
.md table { border-collapse: collapse; width: 100%; font-size: 14px; }
.md th, .md td { text-align: left; padding: 7px 11px; border-bottom: 1px solid var(--line); vertical-align: top; }
.md th { background: var(--panel-2, var(--panel)); font-weight: 600; }
.md tr:last-child td { border-bottom: 0; }
.md li { margin: .2em 0; }
.md code { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 0 5px; font-size: .9em; }
.md pre { background: var(--code-bg); color: var(--code-text); border-radius: var(--r-m); padding: 12px 14px; overflow-x: auto; font-size: 13.5px; }
.md pre code { background: none; border: 0; padding: 0; }
.md strong { color: var(--text); }
.learn-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l); padding: 18px; }
.learn-card h2 { margin-bottom: 10px; }

/* options */
.opts { display: grid; gap: 10px; }
.opt { text-align: left; background: var(--panel); border: 1.5px solid var(--line); border-radius: var(--r-m); padding: 13px 15px; font-size: 15.5px; box-shadow: 0 2px 0 var(--line); }
.opt.code { font-family: var(--f-code); font-size: 14.5px; white-space: pre-wrap; }
.opt:hover:not(:disabled) { border-color: var(--line-2); }
.opt.sel { border-color: var(--ice); box-shadow: 0 2px 0 var(--ice); background: color-mix(in srgb, var(--ice) 10%, var(--panel)); }
.opt.right { border-color: var(--ok); box-shadow: 0 2px 0 var(--ok); background: var(--ok-bg); }
.opt.wrong { border-color: var(--bad); box-shadow: 0 2px 0 var(--bad); background: var(--bad-bg); }
pre.code-view { margin: 0 0 14px; background: var(--code-bg); color: var(--code-text); border-radius: var(--r-m); padding: 14px 16px; overflow-x: auto; font-size: 14px; line-height: 1.6; }

/* parsons */
.parsons { display: grid; gap: 8px; }
.pline { display: flex; align-items: center; gap: 8px; text-align: left; width: 100%; font: 14px/1.4 var(--f-code); background: var(--code-bg); color: var(--code-text); border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; white-space: pre; overflow-x: auto; }
.pline .ln { color: var(--faint); width: 1.5em; flex: none; }
.pline.pick { border-color: var(--ice); }
.pline.right { border-color: var(--ok); } .pline.wrong { border-color: var(--bad); }
.pool { display: grid; gap: 8px; margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); }

/* ---------- editor & console ---------- */
.editor-wrap { border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; background: var(--code-bg); }
.editor-bar { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 12px; background: color-mix(in srgb, var(--code-bg) 80%, #000); border-bottom: 1px solid #2a2340; color: #a99fc6; font: 500 12.5px var(--f-code); }
.cm-editor { font-size: var(--code-size, 14.5px); background: var(--code-bg); color: var(--code-text); }
.cm-editor.cm-focused { outline: none; }
.cm-scroller { font-family: var(--f-code) !important; line-height: 1.6; }
.cm-gutters { background: var(--code-bg) !important; border-right: 1px solid #2a2340 !important; color: #5f5880 !important; }
.cm-activeLine { background: rgba(255, 255, 255, .035) !important; }
.cm-activeLineGutter { background: transparent !important; color: #a99fc6 !important; }
.cm-cursor { border-left-color: var(--gold) !important; border-left-width: 2px !important; }
.cm-selectionBackground, .cm-focused .cm-selectionBackground { background: var(--sel) !important; }
.cm-errline { background: rgba(255, 92, 92, .16) !important; }
.keys { display: flex; gap: 6px; overflow-x: auto; padding: 7px 8px; background: #0c0a14; border-top: 1px solid #2a2340; scrollbar-width: none; }
.keys::-webkit-scrollbar { display: none; }
.keys button { flex: none; min-width: 36px; padding: 7px 10px; border-radius: 8px; border: 1px solid #2f2847; background: #1b1628; color: #ece6fb; font: 500 14px var(--f-code); }
.run-row { display: flex; gap: 8px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
.stdin { width: 100%; min-height: 44px; resize: vertical; font: 14px var(--f-code); background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: var(--r-s); padding: 8px 10px; }
.console { border: 1px solid var(--line); border-radius: var(--r-m); background: var(--panel); overflow: hidden; }
.console-head { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-bottom: 1px solid var(--line); font-size: 12.5px; color: var(--muted); font-weight: 600; }
.console pre { margin: 0; padding: 12px 14px; font: 13.5px/1.55 var(--f-code); white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow: auto; }
.console .empty { padding: 14px; color: var(--faint); font-size: 14px; }
.err { margin: 10px 12px 12px; border-radius: var(--r-m); background: var(--bad-bg); border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); padding: 12px 14px; }
.err b { color: var(--bad); font-family: var(--f-code); font-size: 14px; }
.err .msg { font-family: var(--f-code); font-size: 13.5px; margin-top: 2px; }
.err .hint { margin-top: 8px; font-size: 14px; }
.tests { list-style: none; margin: 0; padding: 6px 12px 10px; }
.tests li { display: flex; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.tests li:last-child { border-bottom: 0; }
.tests .tick { width: 20px; height: 20px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 12px; font-weight: 800; margin-top: 1px; }
.tests .tick.y { background: var(--ok); color: #062614; }
.tests .tick.n { background: var(--bad); color: #2a0606; }
.tests .label { font-family: var(--f-code); font-size: 13px; }
.tests .msg { white-space: pre-wrap; font-family: var(--f-code); font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.files { padding: 8px 12px 12px; display: grid; gap: 6px; }
.file { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.file summary { padding: 7px 10px; font: 13px var(--f-code); cursor: pointer; display: flex; justify-content: space-between; gap: 10px; }
.file pre { max-height: 180px; border-top: 1px solid var(--line); }
.chart { padding: 12px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font: 11px var(--f-body); }
.chart .title { fill: var(--text); font: 600 13px var(--f-body); }

/* ---------- missions ---------- */
.mission { display: flex; flex-direction: column; height: 100%; }
.m-tabs { display: flex; gap: 6px; padding: 0 16px 10px; }
.m-tabs button { flex: 1; padding: 9px 0; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); font-weight: 600; font-size: 14px; color: var(--muted); }
.m-tabs button.on { background: var(--panel-2); color: var(--text); border-color: var(--line-2); }
.m-grid { flex: 1; min-height: 0; display: block; overflow-y: auto; }
.m-pane { padding: 4px 16px 24px; }
@media (min-width: 1000px) {
  .m-tabs { display: none; }
  .m-grid { display: grid; grid-template-columns: 330px minmax(0, 1fr) minmax(0, 1fr); gap: 0; overflow: hidden; }
  .m-pane { overflow-y: auto; padding: 8px 18px 30px; border-right: 1px solid var(--line); }
  .m-pane:last-child { border-right: 0; }
  .m-pane.hide { display: block !important; }
  .mobile-only { display: none !important; }
}
.steps { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 6px; }
.steps button { width: 100%; text-align: left; display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); font-size: 14px; }
.steps button.on { border-color: var(--ember); background: color-mix(in srgb, var(--ember) 10%, var(--panel)); }
.steps .dot { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; flex: none; font: 700 12px var(--f-display); background: var(--panel-2); border: 1.5px solid var(--line); }
.steps .dot.done { background: var(--leaf); border-color: var(--leaf); color: #062614; }
.steps button:disabled { opacity: .45; cursor: not-allowed; }
.stage-view { border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; background: #07060c; position: relative; }

/* game */
.game-box { position: relative; width: 100%; background: #07060c; border-radius: var(--r-m); overflow: hidden; touch-action: none; }
.game-box canvas { display: block; width: 100%; height: auto; image-rendering: auto; }
.game-hud { position: absolute; top: 8px; right: 8px; display: flex; gap: 6px; z-index: 2; }
.game-hud button { width: 34px; height: 34px; border-radius: 10px; border: 0; background: rgba(0, 0, 0, .45); color: #fff; display: grid; place-items: center; }
.game-hud svg { width: 18px; height: 18px; }
.pad { display: flex; justify-content: space-between; gap: 10px; padding: 10px; background: #0c0a14; touch-action: none; }
.pad .grp { display: flex; gap: 8px; }
.pad button { width: 58px; height: 52px; border-radius: 14px; border: 1px solid #2f2847; background: #1d1830; color: #ece6fb; font: 700 16px var(--f-display); touch-action: none; }
.pad button.wide { width: 96px; }
.pad button.down { background: var(--ember); color: #1a0d05; }
.game-over-tip { position: absolute; inset: auto 0 0 0; padding: 10px; text-align: center; font-size: 13px; color: #a99fc6; }
.game-full { position: fixed; inset: 0; z-index: 60; background: #050409; display: flex; flex-direction: column; padding: var(--safe-t) 0 var(--safe-b); }
.game-full .game-area { flex: 1; display: grid; place-items: center; min-height: 0; padding: 8px; }
.game-full .game-box { max-height: 100%; max-width: 100%; }

/* world */
.world-box { position: relative; background: radial-gradient(120% 100% at 50% 0%, #2a2350, #0d0b17 70%); border-radius: var(--r-m); overflow: hidden; touch-action: none; }
.world-box canvas { display: block; width: 100%; height: 100%; }
.lab-out { position: sticky; top: 16px; }
.world-tools { position: absolute; left: 8px; bottom: 8px; right: 8px; display: flex; gap: 6px; align-items: center; }
.world-tools button { height: 34px; min-width: 34px; padding: 0 10px; border-radius: 10px; border: 0; background: rgba(0, 0, 0, .5); color: #fff; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.world-tools svg { width: 17px; height: 17px; }
.world-count { margin-left: auto; color: #cfc6ee; font: 12px var(--f-code); background: rgba(0, 0, 0, .45); padding: 6px 9px; border-radius: 8px; }

/* app preview */
.phone { max-width: 340px; margin: 0 auto; border-radius: 34px; padding: 12px; background: #050409; border: 1px solid var(--line); }
.phone-screen { border-radius: 24px; min-height: 420px; padding: 16px; background: #171327; color: #f3eefe; display: flex; flex-direction: column; gap: 10px; }
.phone-screen.light { background: #fbfaff; color: #1c1630; }
.phone-screen .t { font: 700 18px var(--f-display); text-align: center; margin-bottom: 4px; }
.uw-row { display: flex; gap: 8px; }
.uw-row > * { flex: 1; }
.uw-btn { border: 0; border-radius: 14px; padding: 14px 8px; font: 600 18px var(--f-body); background: #2b2441; color: inherit; }
.phone-screen.light .uw-btn { background: #ece8f6; }
.uw-input { font: 16px var(--f-body); padding: 11px 12px; border-radius: 12px; border: 1px solid #3a3256; background: transparent; color: inherit; }
.uw-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.uw-list li button { width: 100%; text-align: left; background: rgba(255, 255, 255, .05); border: 0; border-radius: 10px; padding: 10px 12px; color: inherit; }

/* ---------- arcade ---------- */
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.game-card { position: relative; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-l); overflow: hidden; padding: 0; display: flex; flex-direction: column; }
.game-card .art { aspect-ratio: 16 / 9; background: #0b0914; display: grid; place-items: center; }
.game-card .art canvas, .game-card .art svg { width: 100%; height: 100%; }
.game-card .body { padding: 12px 14px 14px; }
.game-card h3 { font-size: 17px; }
.game-card.locked .art { filter: grayscale(1) brightness(.6); }

/* ---------- dojo ---------- */
.puzzles { display: grid; gap: 8px; }
.puzzle { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-m); padding: 12px 14px; }
.diff { display: inline-flex; gap: 3px; }
.diff i { width: 6px; height: 14px; border-radius: 2px; background: var(--line); }
.diff i.on { background: var(--ember); }
.filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 10px; scrollbar-width: none; }
.filters button { flex: none; }
.filters .chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }

/* ---------- profile ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-m); padding: 12px 14px; }
.stat b { display: block; font: 800 26px var(--f-display); }
.stat span { font-size: 13px; color: var(--muted); }
.heat { display: grid; grid-template-rows: repeat(7, 12px); grid-auto-flow: column; grid-auto-columns: 12px; gap: 3px; overflow-x: auto; padding: 4px 0; }
.heat i { border-radius: 3px; background: var(--line); }
.heat i.l1 { background: color-mix(in srgb, var(--ember) 35%, var(--line)); }
.heat i.l2 { background: color-mix(in srgb, var(--ember) 65%, var(--line)); }
.heat i.l3 { background: var(--ember); }
.achs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.ach { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-m); padding: 12px; display: flex; gap: 10px; align-items: center; }
.ach .medal { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; background: linear-gradient(140deg, var(--gold), var(--ember)); color: #1a0d05; }
.ach .medal svg { width: 22px; height: 22px; }
.ach.off { opacity: .45; }
.ach.off .medal { background: var(--line); color: var(--faint); }
.ach b { font-size: 14px; display: block; line-height: 1.2; }
.ach span { font-size: 12px; color: var(--muted); }
.settings { display: grid; }
.setting { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.setting:last-child { border-bottom: 0; }
.setting .grow b { display: block; font-weight: 600; }
.setting .grow span { font-size: 13px; color: var(--muted); }
.toggle { width: 50px; height: 30px; border-radius: 999px; background: var(--line); border: 0; position: relative; flex: none; padding: 0; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: left .15s; }
.toggle.on { background: var(--leaf); }
.toggle.on::after { left: 23px; }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: none; padding: 6px 11px; border-radius: 7px; font-size: 13.5px; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
input.field, select.field { width: 100%; font: 16px var(--f-body); color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-m); padding: 12px 14px; }

/* ---------- onboarding ---------- */
.onb { min-height: 100vh; display: flex; flex-direction: column; padding: calc(var(--safe-t) + 18px) 20px calc(var(--safe-b) + 20px); max-width: 560px; margin: 0 auto; }
.onb .body { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.onb h1 { font-size: 36px; }
.onb .big-nova { width: 170px; margin: 0 auto; }
.choices { display: grid; gap: 10px; }
.choice { display: flex; gap: 14px; align-items: center; text-align: left; padding: 14px 16px; border-radius: var(--r-l); background: var(--panel); border: 1.5px solid var(--line); }
.choice.on { border-color: var(--ember); background: color-mix(in srgb, var(--ember) 9%, var(--panel)); }
.choice .ci { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--panel-2); flex: none; }
.choice .ci svg { width: 22px; height: 22px; color: var(--ember); }
.choice b { display: block; }
.choice span { font-size: 13.5px; color: var(--muted); }
.dots { display: flex; gap: 6px; justify-content: center; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.dots i.on { background: var(--ember); width: 20px; border-radius: 4px; }

/* ---------- Nova ---------- */
.nova svg { width: 100%; height: auto; display: block; overflow: visible; }
.nova .float { animation: hover 3.2s ease-in-out infinite; }
@keyframes hover { 50% { transform: translateY(-4px); } }
.say { display: flex; gap: 12px; align-items: flex-start; }
.say .nova { width: 56px; flex: none; }
.bubble { position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 11px 14px; font-size: 15px; }
.bubble::before { content: ""; position: absolute; left: -7px; top: 18px; width: 12px; height: 12px; background: var(--panel); border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); transform: rotate(45deg); }

/* ---------- sheets, toasts ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 80; background: rgba(5, 3, 12, .65); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s; }
@media (min-width: 700px) { .sheet-bg { align-items: center; } }
.sheet { width: 100%; max-width: 520px; max-height: 94vh; overflow-y: auto; background: var(--bg-2); border: 1px solid var(--line); border-radius: 26px 26px 0 0; padding: 22px 20px calc(20px + var(--safe-b)); animation: up .22s ease-out; }
@media (min-width: 700px) { .sheet { border-radius: 26px; } }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(30px); opacity: .5; } }
.toast { position: fixed; left: 50%; top: calc(var(--safe-t) + 14px); transform: translateX(-50%); z-index: 100; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14.5px; box-shadow: var(--shadow); max-width: 92vw; animation: up .2s; }
.plans { display: grid; gap: 10px; margin: 16px 0; }
.plan { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: var(--r-l); border: 1.5px solid var(--line); background: var(--panel); text-align: left; width: 100%; }
.plan.on { border-color: var(--ember); box-shadow: 0 0 0 1px var(--ember); }
.plan .radio { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line-2); flex: none; }
.plan.on .radio { border: 7px solid var(--ember); }
.plan b { display: block; font-size: 16px; }
.plan .price { font: 700 17px var(--f-display); }
.perks { list-style: none; margin: 14px 0; padding: 0; display: grid; gap: 8px; }
.perks li { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; }
.perks svg { width: 20px; height: 20px; color: var(--leaf); flex: none; margin-top: 2px; }
.legal { font-size: 11.5px; color: var(--faint); line-height: 1.45; }

/* done screen */
.done-screen { text-align: center; padding: 30px 16px; display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 520px; margin: 0 auto; }
.done-screen .nova { width: 150px; }
.done-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; width: 100%; }
.cert { aspect-ratio: 1.414; width: 100%; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
canvas.confetti { position: fixed; inset: 0; z-index: 90; pointer-events: none; width: 100%; height: 100%; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ---------- step-through debugger ---------- */
.stepper .step-controls { display: flex; align-items: center; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.stepper .step-controls .icon-btn { width: 34px; height: 34px; font-size: 13px; }
.stepper .step-controls .icon-btn.play { width: 44px; color: var(--ice); }
.stepper .step-controls input[type=range] { flex: 1; min-width: 120px; accent-color: var(--ice); }
.stepper .step-now { padding: 8px 14px; font-weight: 600; font-size: 14px; color: var(--ice); background: color-mix(in srgb, var(--ice) 8%, transparent); border-bottom: 1px solid var(--line); }
.stepper .step-now.return { color: var(--leaf); background: color-mix(in srgb, var(--leaf) 8%, transparent); }
.stepper .step-now.exception { color: var(--bad); background: var(--bad-bg); }
.stepper .step-body { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); }
.stepper .step-code { background: var(--code-bg); color: var(--code-text); font: 13px/1.6 var(--f-code); padding: 8px 0; max-height: 380px; overflow: auto; }
.stepper .sl { display: flex; white-space: pre; padding: 0 10px 0 0; border-left: 3px solid transparent; }
.stepper .sl .sn { width: 40px; flex: none; text-align: right; padding-right: 10px; color: #6f6890; user-select: none; }
.stepper .sl.cur { background: color-mix(in srgb, var(--ice) 22%, transparent); border-left-color: var(--ice); }
.stepper .sl.cur .sn { color: var(--ice); }
.stepper .sl.cur.return { background: color-mix(in srgb, var(--leaf) 20%, transparent); border-left-color: var(--leaf); }
.stepper .sl.cur.exception { background: color-mix(in srgb, var(--bad) 25%, transparent); border-left-color: var(--bad); }
.stepper .sl.was { background: rgba(255, 255, 255, .04); }
.stepper .step-side { padding: 10px 12px; border-left: 1px solid var(--line); min-width: 0; max-height: 380px; overflow: auto; }
.stepper .step-stack { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 4px; }
.stepper .step-stack .chip.on { border-color: var(--ice); color: var(--ice); }
.stepper .step-h { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 10px 0 4px; }
.stepper .step-vars { width: 100%; border-collapse: collapse; font: 12.5px/1.45 var(--f-code); }
.stepper .step-vars td { padding: 3px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.stepper .step-vars .vn { font-weight: 600; white-space: nowrap; }
.stepper .step-vars .vv { word-break: break-all; }
.stepper .step-vars .vt { color: var(--muted); font-size: 11px; white-space: nowrap; text-align: right; }
.stepper .step-vars tr.chg td { background: color-mix(in srgb, var(--gold) 18%, transparent); }
.stepper .step-vars.dim { opacity: .75; }
.stepper .step-out { margin: 0; padding: 8px 10px; background: var(--code-bg); color: var(--code-text); border-radius: 8px; font: 12.5px/1.5 var(--f-code); white-space: pre-wrap; max-height: 140px; overflow: auto; }
@media (max-width: 720px) {
  .stepper .step-body { grid-template-columns: 1fr; }
  .stepper .step-side { border-left: 0; border-top: 1px solid var(--line); }
  .stepper .step-code { max-height: 260px; }
}

.md.inline { display: inline; } .md.inline p { display: inline; margin: 0; }

.chip.tiny { font-size: 10.5px; padding: 1px 7px; font-weight: 700; letter-spacing: .04em; vertical-align: 2px; }
.chip.solo { color: var(--violet); border-color: color-mix(in srgb, var(--violet) 50%, transparent); }
.chip.legacy { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 50%, transparent); }

/* grid children must be allowed to shrink (the touch key row is wide) */
.split > * { min-width: 0; }
