/* TOMPA: a calm, professional learning interface. One accent color, real borders, no decoration for its own sake.
   Two complete themes (dark, light). Every text color meets WCAG AA contrast (4.5:1); tests/theme.test.js checks it. */
*, *::before, *::after { box-sizing: border-box; }

:root {
    color-scheme: dark;
    --top-h: 60px;
    --font: Inter, Heebo, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Consolas, monospace;
    --radius: 10px;
    --radius-sm: 8px;

    --bg: #0d1117;
    --surface: #161b22;
    --surface-2: #1c2128;
    --border: #30363d;
    --border-strong: #444c56;
    --text: #e6edf3;
    --text-2: #b1bac4;
    --muted: #8b949e;
    --accent: #58a6ff;
    --accent-strong: #1f6feb;
    --accent-hover: #1a5fd0;
    --accent-text: #58a6ff;
    --on-accent: #ffffff;
    --success: #3fb950;
    --on-success: #04260f;
    --warning: #d29922;
    --danger: #f85149;
    --shadow: 0 8px 24px rgba(1, 4, 9, .45);

    --code-bg: #0d1117;
    --code-text: #e6edf3;
    --gutter-bg: #0d1117;
    --gutter: #8b949e;
    --inline-code-bg: rgba(110, 118, 129, .25);
    --tk-tag: #7ee787; --tk-attr: #79c0ff; --tk-string: #a5d6ff; --tk-comment: #8b949e;
    --tk-punct: #9ea7b3; --tk-number: #79c0ff; --tk-keyword: #ff7b72; --tk-fn: #d2a8ff;
    --tk-builtin: #79c0ff; --tk-prop: #79c0ff; --tk-selector: #7ee787;
}

:root[data-theme="light"] {
    color-scheme: light;
    --bg: #f6f8fa;
    --surface: #ffffff;
    --surface-2: #f6f8fa;
    --border: #d0d7de;
    --border-strong: #afb8c1;
    --text: #1f2328;
    --text-2: #424a53;
    --muted: #59636e;
    --accent: #0969da;
    --accent-strong: #0969da;
    --accent-hover: #0550ae;
    --accent-text: #0550ae;
    --on-accent: #ffffff;
    --success: #1a7f37;
    --on-success: #ffffff;
    --warning: #9a6700;
    --danger: #cf222e;
    --shadow: 0 8px 24px rgba(31, 35, 40, .12);

    --code-bg: #ffffff;
    --code-text: #1f2328;
    --gutter-bg: #f6f8fa;
    --gutter: #59636e;
    --inline-code-bg: rgba(175, 184, 193, .3);
    --tk-tag: #116329; --tk-attr: #0550ae; --tk-string: #0a3069; --tk-comment: #59636e;
    --tk-punct: #59636e; --tk-number: #0550ae; --tk-keyword: #cf222e; --tk-fn: #6639ba;
    --tk-builtin: #0550ae; --tk-prop: #0550ae; --tk-selector: #116329;
}

html { scroll-behavior: smooth; }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font: 15px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, h3, p, ul, ol, dl, dd { margin: 0; }
ul, ol { padding: 0; list-style: none; }
code { direction: ltr; unicode-bidi: isolate; font: 500 .88em var(--mono); background: var(--inline-code-bg); padding: 1px 6px; border-radius: 5px; white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.i { flex: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; inset-inline-start: 12px; top: -60px; z-index: 100; padding: 8px 14px; border-radius: var(--radius-sm); background: var(--accent-strong); color: var(--on-accent); font-weight: 600; }
.skip:focus { top: 10px; }
main#view:focus { outline: none; }
.muted { color: var(--text-2); }
.kicker { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: 14px; font-weight: 500; white-space: nowrap; transition: background .15s, border-color .15s; }
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn.primary { background: var(--accent-strong); border-color: transparent; color: var(--on-accent); font-weight: 600; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.large { height: 44px; padding: 0 20px; font-size: 15px; }
.btn:disabled { opacity: .5; cursor: default; }
.link-btn { display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; padding: 4px 6px; font-size: 13px; font-weight: 500; color: var(--text-2); border-radius: 6px; }
.link-btn:hover { color: var(--text); background: var(--surface-2); }
.bar { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .4s ease; }
.mark { display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0 8px; border-radius: var(--radius-sm); font: 600 14px var(--mono); color: var(--text); background: color-mix(in srgb, var(--c, var(--accent)) 22%, var(--surface)); border: 1px solid color-mix(in srgb, var(--c, var(--accent)) 55%, var(--border)); }
.mark.large { min-width: 56px; height: 56px; font-size: 18px; border-radius: var(--radius); }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; height: var(--top-h); display: flex; align-items: center; gap: 20px; padding: 0 24px; background: var(--bg); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; white-space: nowrap; }
.brand-logo { display: none; height: 46px; width: auto; }
/* Two color variants of the same file (logo.svg: white letters, logo-dark.svg: the same paths
   in the light theme's --text color), swapped by theme -- so the mark sits directly on the bar
   in both themes, no backdrop chip needed. */
:root[data-theme="dark"] .brand-logo-dark { display: block; }
:root[data-theme="light"] .brand-logo-light { display: block; }
.course-nav { display: flex; gap: 2px; margin-inline-start: 4px; max-width: 46vw; overflow-x: auto; scrollbar-width: none; }
.course-nav::-webkit-scrollbar { display: none; }
.course-nav a { padding: 6px 12px; border-radius: 6px; font-size: 14px; font-weight: 500; color: var(--text-2); white-space: nowrap; }
.course-nav a:hover { color: var(--text); background: var(--surface-2); }
.course-nav a.active { color: var(--text); background: var(--surface-2); box-shadow: inset 0 -2px var(--accent); }
.top-right { margin-inline-start: auto; display: flex; align-items: center; gap: 14px; }
.streak { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 500; color: var(--text-2); }
.streak[hidden] { display: none; }
.level { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.level b { color: var(--text); font-weight: 600; }
.xpbar { display: block; width: 72px; height: 4px; border-radius: 999px; background: var(--border); overflow: hidden; }
.xpbar i { display: block; width: 0; height: 100%; background: var(--accent); transition: width .5s ease; }
.theme { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.theme button { display: grid; place-items: center; width: 34px; height: 30px; border: 0; background: transparent; color: var(--text-2); }
.theme button + button { border-inline-start: 1px solid var(--border); }
.theme button:hover { color: var(--text); background: var(--surface-2); }
.theme button[aria-pressed="true"] { color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, var(--surface)); }

/* ---------- home ---------- */
main#view { padding-bottom: 56px; }
main#view:has(.lesson) { padding-bottom: 0; }
/* The footer supplies its own bottom spacing (.foot-bottom); adding the default 56px on top of
   it left an empty gap below the footer on every page that renders one (landing, legal pages). */
main#view:has(> .site-foot:last-child) { padding-bottom: 0; }
#view.enter { animation: enter .2s ease-out; }
@keyframes enter { from { opacity: 0; transform: translateY(4px); } }
.hero { max-width: 1120px; margin: 0 auto; padding: 64px 24px 32px; display: grid; grid-template-columns: 1fr 1.05fr; gap: 56px; align-items: center; }
.hero h1 { margin: 10px 0 16px; font-size: clamp(34px, 4.6vw, 52px); line-height: 1.1; letter-spacing: -.03em; font-weight: 700; }
.lead { max-width: 30em; font-size: 17px; color: var(--text-2); }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }

.demo { display: grid; gap: 0; min-width: 0; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface); box-shadow: var(--shadow); }
.demo-tabs { display: flex; gap: 2px; padding: 8px 8px 0; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.demo-tab { padding: 7px 14px; border-radius: 6px 6px 0 0; font: 400 12px var(--mono); color: var(--muted); }
.demo-tab.on { color: var(--text); background: var(--code-bg); box-shadow: inset 0 2px var(--accent); }
.demo-code { margin: 0; height: 176px; overflow: hidden; padding: 14px 16px; background: var(--code-bg); font: 400 13px/1.7 var(--mono); color: var(--code-text); white-space: pre; }
.caret { display: inline-block; width: 7px; height: 1.1em; margin-inline-start: 1px; vertical-align: -3px; background: var(--accent); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.demo-browser { background: #fff; border-top: 1px solid var(--border); transition: opacity .4s; }
.demo-browser.fade { opacity: 0; }
.mock-bar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: #eef1f4; border-bottom: 1px solid #d8dee4; }
.mock-bar i { width: 9px; height: 9px; border-radius: 50%; background: #c6cdd5; }
.mock-bar span { margin-inline-start: 10px; font: 400 11px var(--mono); color: #57606a; }
.demo-page { display: block; min-height: 140px; }

.section { max-width: 1120px; margin: 0 auto; padding: 32px 24px 0; }
.section-title { margin-bottom: 16px; font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.section-title small { margin-inline-start: 8px; font-size: 13px; font-weight: 400; color: var(--muted); }
.summary { display: flex; align-items: center; gap: 32px; padding: 18px 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.summary-main { flex: 1; min-width: 200px; }
.label { margin-bottom: 8px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.summary-stats { display: flex; flex-wrap: wrap; gap: 8px 28px; font-size: 14px; color: var(--text-2); }
.summary-stats b { color: var(--text); font-weight: 600; }

.course-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; }
.course-card { display: flex; flex-direction: column; gap: 8px; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: inset 0 3px color-mix(in srgb, var(--c) 80%, transparent); transition: border-color .15s, box-shadow .15s; }
.course-card:hover { border-color: var(--border-strong); box-shadow: inset 0 3px color-mix(in srgb, var(--c) 80%, transparent), var(--shadow); }
.cc-top { display: flex; align-items: center; justify-content: space-between; }
.cc-lang { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.course-card h3 { margin-top: 6px; font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.course-card p { color: var(--text-2); }
.cc-meta { font-size: 13px; color: var(--muted); margin: 4px 0 4px; }
.cc-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; font-size: 13px; color: var(--muted); }
.cc-cta { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--accent); }

.how-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.how-item { padding: 16px 0 0; border-top: 1px solid var(--border); }
.how-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; margin-bottom: 10px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); color: var(--accent); }
.how-item h3 { font-size: 15px; font-weight: 600; }
.how-item p { margin-top: 4px; font-size: 14px; color: var(--text-2); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat-tile { padding: 16px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); text-align: center; }
.stat-tile b { display: block; font-size: 28px; font-weight: 700; letter-spacing: -.02em; color: var(--accent-text); }
.stat-tile span { display: block; margin-top: 4px; font-size: 13px; color: var(--text-2); }

.section-lead { margin: -8px 0 16px; font-size: 14px; }
.mix-grid { display: grid; gap: 10px; }
.mix-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.mix-icon { display: grid; place-items: center; flex: none; color: var(--accent); }
.mix-label { flex: none; min-width: 90px; font-size: 14px; font-weight: 600; }
.mix-bar { flex: 1 1 140px; height: 10px; }
.mix-count { flex: none; min-width: 30px; text-align: end; font-size: 13px; font-weight: 600; color: var(--text-2); font-variant-numeric: tabular-nums; }

.badge-grid, .ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; }
.badge, .ach-tile { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.badge-icon, .ach-icon { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.badge b, .ach-tile b { display: block; font-size: 14px; font-weight: 600; color: var(--text-2); }
.badge small, .ach-tile small { display: block; font-size: 13px; color: var(--muted); line-height: 1.35; }
.badge.earned { border-color: color-mix(in srgb, var(--success) 50%, var(--border)); }
.badge.earned .badge-icon { background: var(--success); border-color: var(--success); color: var(--on-success); }
.badge.earned b { color: var(--text); }
/* ---------- site footer ---------- */
.site-foot { margin-top: 64px; border-top: 1px solid var(--border); background: var(--surface); }
.foot-top { max-width: 1120px; margin: 0 auto; padding: 44px 24px 32px; display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 32px; }
.foot-brand-col p { margin: 12px 0 0; font-size: 13px; color: var(--muted); max-width: 30ch; }
.foot-col h3 { margin: 0 0 14px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.foot-col { display: flex; flex-direction: column; gap: 10px; }
.foot-col a { color: var(--text-2); font-size: 14px; text-decoration: none; width: fit-content; }
.foot-col a:hover { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }
.foot-bottom { max-width: 1120px; margin: 0 auto; padding: 18px 24px; border-top: 1px solid var(--border); display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; font-size: 12px; color: var(--muted); }
@media (max-width: 720px) {
    .foot-top { grid-template-columns: 1fr 1fr; }
    .foot-brand-col { grid-column: 1 / -1; }
}

/* ---------- course outline ---------- */
.page-head { max-width: 920px; margin: 0 auto; padding: 36px 24px 8px; }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.breadcrumb a { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); }
.breadcrumb a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.ph-row { display: flex; align-items: center; gap: 18px; margin: 18px 0 20px; }
.ph-text { flex: 1; min-width: 0; }
.ph-text h1 { font-size: 30px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.ph-text p { margin-top: 4px; color: var(--text-2); }
.ph-side { display: flex; align-items: center; gap: 20px; }
.ph-progress { text-align: end; line-height: 1.3; }
.ph-progress b { display: block; font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.ph-progress span { font-size: 13px; color: var(--muted); }
.outline { max-width: 920px; margin: 0 auto; padding: 16px 24px 0; display: grid; gap: 12px; }
.chapter { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.chapter.soon { background: transparent; border-style: dashed; }
.chapter-head { display: flex; align-items: center; gap: 16px; padding: 16px 18px; }
.ch-num { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border-strong); font-size: 14px; font-weight: 600; color: var(--text-2); }
.chapter.complete .ch-num { background: var(--success); border-color: var(--success); color: var(--on-success); }
.ch-text { flex: 1; min-width: 0; }
.ch-text h2 { font-size: 17px; font-weight: 600; }
.ch-text p { margin-top: 2px; font-size: 14px; color: var(--text-2); }
.ch-side { display: flex; align-items: center; gap: 14px; flex: none; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.status.complete { color: var(--success); font-weight: 500; }
.steps { border-top: 1px solid var(--border); }
.step-row { display: flex; align-items: center; gap: 12px; padding: 11px 18px; padding-inline-start: 66px; border-bottom: 1px solid var(--border); transition: background .12s; }
.steps li:last-child .step-row { border-bottom: 0; border-radius: 0 0 var(--radius) var(--radius); }
.step-row:hover { background: var(--surface-2); }
.s-state { display: grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%; border: 1px solid var(--border-strong); color: var(--muted); }
.step-row.done .s-state { background: var(--success); border-color: var(--success); color: var(--on-success); }
.s-title { flex: 1; font-size: 14px; font-weight: 500; }
.s-type { font-size: 12px; color: var(--muted); }
.topics { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px 16px; padding-inline-start: 66px; }
.topics li { padding: 3px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: 13px; color: var(--text-2); }
.empty { max-width: 480px; margin: 120px auto; padding: 0 24px; text-align: center; display: grid; gap: 12px; justify-items: center; }
.empty h1 { font-size: 26px; }

/* ---------- lesson ---------- */
.lesson { display: flex; flex-direction: column; height: calc(100vh - var(--top-h)); min-height: 560px; }
.lesson-bar { flex: none; display: flex; align-items: center; gap: 20px; padding: 10px 20px; border-bottom: 1px solid var(--border); background: var(--surface); }
.crumb-current { color: var(--text); font-weight: 500; }
.segments { display: flex; gap: 6px; margin-inline-start: auto; }
.seg { position: relative; width: 28px; height: 6px; border-radius: 3px; background: var(--border-strong); }
.seg::before { content: ''; position: absolute; inset: -10px -2px; }
.seg.done { background: var(--success); }
.seg.now { background: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 30%, transparent); }
.step-count { font-size: 13px; color: var(--muted); white-space: nowrap; }

.lesson-grid { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(290px, 340px) minmax(0, 1.1fr) minmax(0, 1fr); }
.mission { min-height: 0; overflow-y: auto; padding: 22px; border-inline-end: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; gap: 14px; }
.type-label { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-2); }
.t-try .i { color: var(--accent); }
.t-challenge .i { color: var(--success); }
.t-break .i { color: var(--warning); }
.t-quiz .i { color: var(--accent); }
.mission h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; line-height: 1.2; }
.mission-text { display: grid; gap: 10px; color: var(--text-2); }
.mission-text strong { color: var(--text); font-weight: 600; }

/* A small worked example: the code types itself, then the rendered result fades in below it. */
.step-demo { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.step-demo-head { display: flex; align-items: center; gap: 6px; padding: 8px 12px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); background: var(--surface-2); border-bottom: 1px solid var(--border); }
.step-demo-code { margin: 0; min-height: 60px; padding: 12px 14px; background: var(--code-bg); font: 400 13px/1.6 var(--mono); color: var(--code-text); white-space: pre-wrap; word-break: break-word; }
.step-demo-stage { max-height: 0; opacity: 0; overflow: hidden; background: #fff; transition: max-height .4s ease, opacity .35s ease; }
.step-demo-stage.show { max-height: 160px; opacity: 1; }
.step-demo-frame { display: block; width: 100%; height: 140px; border: 0; }

.req { border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
.req-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.req-head h2 { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.req-head span { font-size: 13px; color: var(--text-2); }
.checks li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; font-size: 14px; color: var(--text-2); transition: color .15s; }
.checks li + li { border-top: 1px solid var(--border); }
.checks .box { display: grid; place-items: center; flex: none; width: 18px; height: 18px; margin-top: 2px; border-radius: 5px; border: 1.5px solid var(--border-strong); color: transparent; transition: background .15s, border-color .15s; }
.checks li.ok { color: var(--text); }
.checks li.ok .box { background: var(--success); border-color: var(--success); color: var(--on-success); }
.checks li.ok .box::after { content: ''; width: 9px; height: 5px; margin-top: -2px; border-left: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); }
.help-row { display: flex; flex-wrap: wrap; gap: 8px; }

.done-card { display: grid; gap: 10px; padding: 14px 16px; border: 1px solid color-mix(in srgb, var(--success) 55%, var(--border)); border-radius: var(--radius); background: color-mix(in srgb, var(--success) 9%, var(--surface)); }
.done-card[hidden] { display: none; }
.done-title { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--success); }
.done-card p { font-size: 14px; color: var(--text-2); }
.done-block h2 { margin-bottom: 2px; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.done-block p + p { margin-top: 6px; }
.done-xp { font-size: 13px; font-weight: 500; color: var(--text-2); }
/* Back / Next stay on screen at all times (a bar under the lesson), so nothing has to be scrolled to. */
.lesson-foot { position: sticky; bottom: 0; z-index: 10; flex: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px; border-top: 1px solid var(--border); background: var(--surface); }
.foot-status { display: inline-flex; align-items: center; gap: 6px; margin-inline-start: auto; font-size: 14px; font-weight: 500; color: var(--success); }
.foot-status:empty { display: none; }
.next.ready { background: var(--accent-strong); border-color: transparent; color: var(--on-accent); font-weight: 600; }
.next.ready:hover { background: var(--accent-hover); }

.work, .stage { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.work { border-inline-end: 1px solid var(--border); background: var(--code-bg); }
.pane-head { flex: none; height: 38px; display: flex; align-items: center; justify-content: space-between; padding: 0 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.file-chip { padding: 2px 8px; border-radius: 6px; border: 1px solid var(--border-strong); background: var(--surface); font: 400 12px var(--mono); letter-spacing: 0; text-transform: none; color: var(--text); }
.pane-head .link-btn { text-transform: none; letter-spacing: 0; }
#editor { flex: 1; min-height: 0; }

.feedback { flex: none; display: flex; gap: 12px; align-items: flex-start; min-height: 84px; max-height: 210px; overflow-y: auto; padding: 14px 16px; border-top: 1px solid var(--border); border-inline-start: 3px solid var(--accent); background: var(--surface); }
.fb-icon { flex: none; margin-top: 1px; color: var(--accent); }
.fb-title { margin-bottom: 2px; font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
#fb-text { font-size: 14px; line-height: 1.55; color: var(--text); }
#fb-text p + p { margin-top: 8px; }
.more { display: block; margin-top: 4px; color: var(--muted); }
.feedback[data-state="error"] { border-inline-start-color: var(--danger); }
.feedback[data-state="error"] .fb-icon { color: var(--danger); }
.feedback[data-state="success"] { border-inline-start-color: var(--success); }
.feedback[data-state="success"] .fb-icon { color: var(--success); }
.feedback[data-state="hint"] { border-inline-start-color: var(--warning); }
.feedback[data-state="hint"] .fb-icon { color: var(--warning); }

.stage { background: var(--bg); }
#preview { flex: 1; min-height: 0; width: 100%; border: 0; background: #fff; }
.console { flex: none; height: 170px; display: flex; flex-direction: column; border-top: 1px solid var(--border); background: var(--code-bg); }
.stage.console-only .console { flex: 1; height: auto; border-top: 0; }
.console-body { flex: 1; overflow: auto; padding: 8px 14px; font: 13px/1.7 var(--mono); }
.log { display: flex; gap: 10px; color: var(--code-text); }
.log span { flex: none; width: 14px; color: var(--muted); }
.log.error, .log.error span { color: var(--danger); }
.log.warn, .log.warn span, .log.alert, .log.alert span { color: var(--warning); }
.log.empty { color: var(--muted); }
.log em { color: var(--muted); font-style: normal; }

/* ---------- quiz ---------- */
.is-quiz .quiz { grid-column: 2 / -1; min-height: 0; overflow-y: auto; padding: 28px; display: grid; gap: 16px; align-content: start; max-width: 760px; }
.qcard { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.qcard h2 { margin-bottom: 14px; font-size: 17px; font-weight: 600; line-height: 1.5; }
.qcard h2 span { display: block; margin-bottom: 4px; font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt { min-height: 48px; padding: 10px 14px; text-align: start; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); font-size: 14px; font-weight: 500; transition: background .12s, border-color .12s; }
.opt:hover:not(:disabled) { background: var(--surface-2); border-color: var(--muted); }
.opt.right { border-color: var(--success); background: color-mix(in srgb, var(--success) 12%, var(--surface)); }
.opt.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.opt:disabled:not(.right):not(.wrong) { opacity: .55; }
.opt:disabled { cursor: default; }
.qwhy { margin-top: 12px; font-size: 14px; color: var(--text-2); }
.qwhy b { color: var(--success); }
.qwhy.bad { color: var(--danger); }

/* ---------- editor ---------- */
.ed { direction: ltr; text-align: left; display: flex; height: 100%; min-height: 0; font: 400 13.5px/22px var(--mono); background: var(--code-bg); }
.ed:focus-within { box-shadow: inset 0 0 0 1px var(--accent); }
.ed-gutter { flex: none; min-width: 46px; padding: 14px 10px 14px 12px; text-align: right; overflow: hidden; user-select: none; color: var(--gutter); background: var(--gutter-bg); border-right: 1px solid var(--border); }
.ed-gutter .err { color: var(--danger); font-weight: 600; }
.ed-surface { position: relative; flex: 1; min-width: 0; }
.ed-hl, .ed-input { position: absolute; inset: 0; margin: 0; padding: 14px 16px; border: 0; font: inherit; letter-spacing: 0; tab-size: 2; white-space: pre; overflow: auto; }
.ed-hl { pointer-events: none; color: var(--code-text); scrollbar-width: none; }
.ed-hl::-webkit-scrollbar { display: none; }
.ed-input { resize: none; outline: 0; background: transparent; color: transparent; -webkit-text-fill-color: transparent; caret-color: var(--text); }
.ed-input::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); -webkit-text-fill-color: transparent; }
.ed-err { text-decoration: underline wavy var(--danger) 1px; text-underline-offset: 4px; background: color-mix(in srgb, var(--danger) 10%, transparent); }
.tok-tag { color: var(--tk-tag); }
.tok-attr { color: var(--tk-attr); }
.tok-string { color: var(--tk-string); }
.tok-comment { color: var(--tk-comment); font-style: italic; }
.tok-punct { color: var(--tk-punct); }
.tok-number { color: var(--tk-number); }
.tok-keyword { color: var(--tk-keyword); }
.tok-fn { color: var(--tk-fn); }
.tok-builtin { color: var(--tk-builtin); }
.tok-prop { color: var(--tk-prop); }
.tok-selector { color: var(--tk-selector); }

/* ---------- toasts, chapter summary ---------- */
#toasts { position: fixed; z-index: 90; inset-inline-end: 20px; bottom: 76px; display: grid; gap: 8px; justify-items: end; pointer-events: none; }
.toast { display: inline-flex; align-items: center; gap: 8px; padding: 9px 16px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow); font-size: 14px; font-weight: 500; animation: enter .2s ease-out; transition: opacity .3s; }
.toast .i { color: var(--success); }
.toast.out { opacity: 0; }
.modal-backdrop { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 20px; background: rgba(1, 4, 9, .6); opacity: 0; transition: opacity .18s; }
.modal-backdrop.in { opacity: 1; }
.modal { width: min(420px, 100%); padding: 28px; text-align: center; border: 1px solid var(--border-strong); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
.modal-icon { display: inline-grid; place-items: center; width: 48px; height: 48px; margin-bottom: 12px; border-radius: 50%; background: var(--success); color: var(--on-success); }
.modal h2 { margin-top: 4px; font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
.modal-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 22px 0 4px; }
.modal-stats div { padding: 12px 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); }
.modal-stats dt { font-size: 12px; color: var(--muted); }
.modal-stats dd { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 22px; }

/* ---------- self-test ---------- */
.selftest { max-width: 960px; margin: 0 auto; padding: 40px 24px 0; }
.selftest h1 { margin: 6px 0 8px; font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
.st-summary { margin: 20px 0 14px; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); font-weight: 600; }
.st-summary.good { border-color: var(--success); color: var(--success); }
.st-summary.bad { border-color: var(--danger); color: var(--danger); }
.st-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.st-table th { padding: 8px 10px; text-align: start; font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); }
.st-table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.st-table tr.bad td { background: color-mix(in srgb, var(--danger) 8%, transparent); }
.st-table a { text-decoration: underline; text-underline-offset: 3px; }
.st-ok { color: var(--success); font-weight: 600; }
.st-bad { color: var(--danger); font-weight: 600; }
.st-frame { position: fixed; left: -9999px; top: 0; width: 900px; height: 700px; border: 0; }

/* ---------- accounts, forms, legal ---------- */
.lang-select { height: 32px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }
.account-link { display: inline-flex; align-items: center; gap: 6px; max-width: 160px; height: 32px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-size: 13px; font-weight: 500; }
.account-link span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-link:hover { background: var(--surface-2); }
.hero-note { margin-top: 14px; max-width: 34em; font-size: 13px; color: var(--muted); }
.path-note p { display: flex; gap: 10px; align-items: center; padding: 14px 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text-2); }
.loading { margin: 120px auto; text-align: center; color: var(--muted); }
.auth { max-width: 440px; margin: 0 auto; padding: 48px 24px 0; }
.auth.wide { max-width: 640px; }
.auth h1 { margin-bottom: 6px; font-size: 28px; font-weight: 700; letter-spacing: -.02em; }
.auth form { margin-top: 22px; }
.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 500; }
.input-wrap { position: relative; display: flex; }
.field input:not([type="checkbox"]), .field select { width: 100%; height: 44px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; font-size: 16px; }
.field input[type="email"] { direction: ltr; text-align: start; }
.field input:focus, .field select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.pw-toggle { position: absolute; inset-block: 4px; inset-inline-end: 4px; padding: 0 10px; border: 0; border-radius: 6px; background: transparent; color: var(--text-2); font-size: 13px; font-weight: 500; }
.pw-toggle:hover { background: var(--surface-2); color: var(--text); }
.hint-text { margin-top: 6px; font-size: 13px; color: var(--muted); }
.field-msg, .form-error { min-height: 0; margin-top: 6px; font-size: 13px; color: var(--danger); }
.field-msg:empty, .form-error:empty, .form-ok:empty { display: none; }
.form-ok { margin-bottom: 12px; font-size: 14px; color: var(--success); }
.form-error { margin: 0 0 12px; font-size: 14px; }
.btn.block { width: 100%; }
.checkbox { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; font-weight: 400; color: var(--text-2); }
.checkbox input { width: 20px; height: 20px; margin: 1px 0 0; flex: none; accent-color: var(--accent-strong); }
.checkbox a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.auth-switch { margin-top: 20px; font-size: 14px; color: var(--text-2); }
.auth-switch a { color: var(--accent); font-weight: 600; }
.card-form { margin: 24px 0 0; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.card-form h2 { margin-bottom: 14px; font-size: 17px; font-weight: 600; }
.card-form.danger { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.site-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.danger-btn { background: var(--danger); border-color: transparent; color: #fff; font-weight: 600; }
.danger-btn:hover { background: var(--danger); filter: brightness(.92); }
:root[data-theme="dark"] .danger-btn { color: #1c0507; }
.legal { max-width: 720px; margin: 0 auto; padding: 48px 24px 0; }
.legal h1 { margin-bottom: 10px; font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
.legal h2 { margin: 26px 0 6px; font-size: 18px; font-weight: 600; }
.legal p { color: var(--text-2); }
.legal p a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.foot-logo { display: none; height: 38px; width: auto; }
:root[data-theme="dark"] .foot-logo-dark { display: block; }
:root[data-theme="light"] .foot-logo-light { display: block; }

/* ---------- locked steps (nothing can be skipped) ---------- */
.course-card.is-locked { opacity: .92; }
.course-card.is-locked .cc-cta { color: var(--muted); }
.lock-banner { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 14px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); font-size: 14px; color: var(--text-2); }
.lock-banner a { color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
.chapter.locked { background: transparent; }
.chapter.locked .ch-num { color: var(--muted); }
.step-row.locked { color: var(--muted); cursor: not-allowed; }
.step-row.locked .s-title { font-weight: 400; }
.step-row.current { background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.step-row.current .s-state { border-color: var(--accent); color: var(--accent); }
.s-next { padding: 1px 8px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 16%, var(--surface)); color: var(--accent-text); font-size: 12px; font-weight: 600; }
.seg.locked { background: var(--border); opacity: .7; }
.btn.next.disabled { opacity: .5; cursor: not-allowed; pointer-events: auto; }
.btn.next.disabled:hover { background: var(--surface); border-color: var(--border-strong); }
.save-failed { color: var(--danger); }

/* ---------- phone: lesson tabs and the code symbol bar ---------- */
.lesson-tabs { display: none; }
.symbols { display: none; }
.lang-select option { color: var(--text); background: var(--surface); }
:root { --foot-h: 58px; }

/* ---------- responsive ---------- */
.symbols { gap: 6px; padding: 8px 10px; overflow-x: auto; border-top: 1px solid var(--border); background: var(--surface-2); position: sticky; bottom: var(--foot-h); z-index: 5; scrollbar-width: none; }
.symbols::-webkit-scrollbar { display: none; }
.symbols button { flex: none; min-width: 40px; height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); font: 500 16px var(--mono); }
.symbols button:active { background: var(--surface-2); }
@media (pointer: coarse), (max-width: 900px) { .symbols { display: flex; } }
@media (pointer: coarse) {
    :root { --foot-h: 66px; }
    .btn { min-height: 44px; }
    .btn.small { height: auto; min-height: 44px; }
    .link-btn { min-height: 44px; }
    .brand { min-height: 44px; min-width: 44px; }
    .theme button { width: 42px; height: 40px; }
    .lang-select { height: 44px; font-size: 16px; }
    .account-link { height: 44px; }
    .opt { min-height: 56px; }
    .course-nav a { padding: 12px 14px; }
    .seg::before { inset: -20px -3px; }
    .chip-btn, .pw-toggle { min-height: 40px; }
}
@media (max-width: 1100px) {
    /* Not enough height to fit everything on one screen: let the lesson grow and the page scroll. */
    .lesson { height: auto; min-height: calc(100vh - var(--top-h)); }
    .lesson-grid { grid-template-columns: minmax(260px, 310px) minmax(0, 1fr); grid-template-rows: minmax(420px, auto) minmax(420px, auto); }
    .mission { grid-row: 1 / 3; }
    .work { border-inline-end: 0; border-bottom: 1px solid var(--border); }
    .is-quiz .quiz { grid-row: 1 / 3; }
    .how-grid { grid-template-columns: repeat(2, 1fr); }
    .xpbar { display: none; }
}
@media (max-width: 900px) {
    .topbar { padding: 0 14px; gap: 10px; }
    .course-nav, .hide-narrow { display: none; }
    .hero { grid-template-columns: 1fr; padding-top: 36px; gap: 32px; }
    .summary { flex-direction: column; align-items: stretch; gap: 14px; }
    .ph-row { flex-wrap: wrap; }
    .ph-side { width: 100%; justify-content: space-between; }
    .chapter-head { flex-wrap: wrap; }
    .ch-side { width: 100%; justify-content: space-between; padding-inline-start: 48px; }
    .step-row, .topics { padding-inline-start: 18px; }
    .topics { padding-inline-end: 18px; }
    /* Short content still fills the screen, so Back/Next sit at the bottom edge and not in the middle of the page. */
    .lesson { height: auto; min-height: calc(100vh - var(--top-h)); }
    @supports (height: 100dvh) { .lesson { min-height: calc(100dvh - var(--top-h)); } }
    .lesson-bar { flex-wrap: wrap; gap: 10px 16px; padding: 10px 16px; }
    .segments { margin-inline-start: 0; }
    .lesson-grid, .is-quiz { display: flex; flex-direction: column; }
    .mission { border-inline-end: 0; border-bottom: 0; overflow: visible; }
    .work { border-inline-end: 0; border-bottom: 0; }
    .ed { font-size: 16px; line-height: 24px; }
    #editor { min-height: 340px; }
    .stage { min-height: 460px; }
    .console { height: 140px; }
    .is-quiz .quiz { padding: 20px 16px; }
    .opts { grid-template-columns: 1fr; }
    /* One pane at a time: Lesson, Code or Result. */
    .lesson-tabs { display: flex; position: sticky; top: var(--top-h); z-index: 9; background: var(--surface); border-bottom: 1px solid var(--border); }
    .lesson-tabs .tab { position: relative; flex: 1; height: 48px; border: 0; border-bottom: 2px solid transparent; background: none; font-size: 14px; font-weight: 600; color: var(--text-2); }
    .lesson-tabs .tab.on { color: var(--text); border-bottom-color: var(--accent); }
    .lesson-tabs .dot { position: absolute; top: 13px; inset-inline-end: calc(50% - 40px); width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
    .lesson[data-tab="lesson"] .work, .lesson[data-tab="lesson"] .stage,
    .lesson[data-tab="code"] .mission, .lesson[data-tab="code"] .stage,
    .lesson[data-tab="result"] .mission, .lesson[data-tab="result"] .work { display: none; }
    .lesson[data-tab="result"] .stage { min-height: calc(100vh - var(--top-h) - 48px - var(--foot-h)); }
    .lesson-foot { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
    #toasts { bottom: calc(var(--foot-h) + 14px); inset-inline: 14px; justify-items: stretch; }
}
@media (max-width: 560px) {
    .streak, .xp-num, .account-link span { display: none; }
    .topbar { padding: 0 10px; gap: 8px; }
    .lang-select { max-width: 108px; padding: 0 2px 0 8px; padding-inline: 8px 2px; }
    .theme button { width: 32px; }
    .top-right { gap: 6px; }
    .how-grid { grid-template-columns: 1fr; }
    .actions .btn { width: 100%; }
    .modal-stats dd { font-size: 18px; }
    .auth { padding-top: 32px; }
    .step-count { display: none; }
}
@media (max-width: 420px) {
    /* The level is also on the dashboard; the top bar needs the room for the language, theme and account buttons. */
    .level { display: none; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
    html { scroll-behavior: auto; }
}

/* ---------- admin panel ---------- */
.adm { max-width: 1120px; margin: 0 auto; padding: 32px 24px 72px; }
.adm-head h1 { margin: 6px 0 14px; font-size: 30px; font-weight: 700; letter-spacing: -.02em; }
.adm-tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.adm-tabs a { padding: 10px 14px; margin-bottom: -1px; border-bottom: 2px solid transparent; font-size: 14px; font-weight: 600; color: var(--text-2); }
.adm-tabs a:hover { color: var(--text); }
.adm-tabs a[aria-current="page"] { color: var(--text); border-bottom-color: var(--accent); }
.adm h2 { font-size: 18px; font-weight: 600; }
.adm-h2 { margin: 32px 0 12px; }
.adm-h3 { margin: 22px 0 4px; font-size: 15px; font-weight: 600; }
.adm a:not(.btn):not(.adm-tabs a) { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }

.adm input:not([type="checkbox"]):not([type="radio"]), .adm select, .adm textarea { width: 100%; height: 40px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; }
.adm textarea { height: auto; min-height: 44px; padding: 10px; font-family: var(--mono); font-size: 13.5px; line-height: 1.55; resize: vertical; }
.adm input:focus, .adm select:focus, .adm textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.adm input[readonly] { background: var(--surface-2); color: var(--text-2); }
.adm .field { margin-bottom: 14px; }
.adm .field label, .adm legend { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 500; }
.adm-hint { margin: 6px 0 0; font-size: 13px; }
.adm textarea[dir="rtl"], .adm input[dir="rtl"] { font-family: var(--font); font-size: 15px; }
#test-btn { margin-top: 12px; }
.adm-tools { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.adm-tools input { max-width: 340px; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }

.adm-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.adm-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.adm-table th { padding: 10px 12px; text-align: start; font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap; }
.adm-table td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.adm-table tr:last-child td { border-bottom: 0; }
.adm-email { color: var(--text-2); word-break: break-all; }
.adm-when { white-space: nowrap; }
.adm-table time { white-space: nowrap; }
.adm-badge { display: inline-block; padding: 1px 7px; border: 1px solid var(--border-strong); border-radius: 999px; font-size: 11px; font-weight: 600; color: var(--accent-text); vertical-align: middle; }
.adm-badge.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 55%, var(--border-strong)); }
.adm-progress { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.adm-bar { display: block; width: 64px; height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; flex: none; }
.adm-bar i { display: block; height: 100%; background: var(--accent-strong); }
.adm-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 16px 0 0; }
.adm-facts > div { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.adm-facts dt { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.adm-facts dd { margin: 4px 0 0; font-size: 15px; word-break: break-word; }
.adm-reset-row { display: flex; gap: 10px; flex-wrap: wrap; }
.adm-reset-row input { flex: 1 1 240px; width: auto; font-family: var(--mono); }
.adm-reset .form-ok { margin: 12px 0 0; }
.adm-reset > p.muted { margin-bottom: 14px; }
.adm-enable + .adm-hint { margin-bottom: 16px; }
.adm-step.todo td { color: var(--text-2); }
.adm-state { display: inline-flex; align-items: center; gap: 5px; font-weight: 500; }
.adm-state.ok { color: var(--success); }
.adm-state.next { color: var(--accent-text); }

/* lessons list */
.adm-saved { display: flex; align-items: center; gap: 8px; margin: 0 0 16px; padding: 10px 14px; border: 1px solid color-mix(in srgb, var(--success) 50%, var(--border)); border-radius: var(--radius-sm); background: var(--surface); color: var(--success); font-weight: 500; }
.adm-course { margin: 28px 0 0; }
.adm-course-head, .adm-chapter-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.adm-course-head h2 small { font-size: 14px; font-weight: 400; margin-inline-start: 8px; }
.adm-chapter { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.adm-chapter-head { padding: 12px 14px; border-bottom: 1px solid var(--border); }
.adm-chapter-head h3 { font-size: 15px; font-weight: 600; }
.adm-actions { display: inline-flex; gap: 8px; align-items: center; }
.adm-steps { list-style: none; margin: 0; padding: 0; }
.adm-steps li { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.adm-steps li:last-child { border-bottom: 0; }
.adm-type { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.adm-loc { display: inline-block; margin-inline-end: 4px; padding: 1px 6px; border: 1px solid var(--border-strong); border-radius: 4px; font-size: 11px; font-weight: 600; color: var(--text-2); }
.adm-loc.off { border-style: dashed; color: var(--muted); text-decoration: line-through; }
.adm-builtin { font-size: 13px; }
.adm-empty { margin: 0; padding: 12px 14px; font-size: 14px; }
.adm-errors { margin: 8px 0 0; padding-inline-start: 20px; font-size: 13px; font-family: var(--mono); }
.adm-errors li { margin-bottom: 4px; }

/* forms */
.adm-form { display: grid; gap: 20px; }
.adm-card { padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.adm-card > h2 { margin-bottom: 14px; }
.adm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0 18px; }
.adm-locale { margin: 0 0 16px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); }
.adm-types { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }
.adm-type-card { position: relative; display: grid; gap: 4px; align-content: start; padding: 14px; border: 1px solid var(--border-strong); border-radius: var(--radius); cursor: pointer; font-size: 13px; line-height: 1.4; }
.adm-type-card input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.adm-type-card:hover { border-color: var(--muted); }
.adm-type-card.on { border-color: var(--accent); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--accent); }
.adm-type-card:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.adm-type-name { display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--text); }
.adm-tabs-lang { display: flex; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--border); }
.adm-lang-tab { padding: 9px 14px; margin-bottom: -1px; border: 0; border-bottom: 2px solid transparent; background: none; font-size: 14px; font-weight: 600; color: var(--text-2); }
.adm-lang-tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.adm-enable { margin-bottom: 4px; }
.adm-reqs, .adm-questions { list-style: none; margin: 12px 0; padding: 0; display: grid; gap: 12px; }
.adm-req, .adm-question { padding: 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.adm-req-main { display: grid; grid-template-columns: 220px minmax(0, 1fr) auto; gap: 10px; align-items: start; }
.adm-req-params { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.adm-req-params > input, .adm-req-params > select { flex: 1 1 150px; width: auto; }
.adm-req-params > textarea { flex: 1 1 100%; }
.adm-not { flex: none; white-space: nowrap; }
.adm-req-labels { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px 12px; margin-top: 10px; }
.adm-req-labels label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.adm-req-labels input { text-transform: none; letter-spacing: 0; font-weight: 400; }
.adm-q-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.adm-options { margin: 0 0 14px; padding: 0; border: 0; }
.adm-option { display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 10px; align-items: center; margin-bottom: 8px; }
.adm-option input[type="radio"] { width: 20px; height: 20px; margin: 0; accent-color: var(--accent-strong); }
.adm-preview { display: block; width: 100%; height: 220px; margin-top: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.adm-test { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.adm-test li { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.adm-test li.ok { color: var(--success); }
.adm-test li.bad { color: var(--danger); }
.adm-test .i { flex: none; margin-top: 2px; }
#test-result .form-ok, #test-result .form-error { margin: 12px 0 0; }
.adm-warning { display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--warning) 60%, var(--border)); border-radius: var(--radius-sm); background: var(--surface); font-size: 14px; }
.adm-warning .i { flex: none; margin-top: 2px; color: var(--warning); }
.adm-savebar { pointer-events: none; display: flex; justify-content: flex-end; gap: 10px; position: sticky; bottom: 0; padding: 12px 0; background: linear-gradient(to top, var(--bg) 70%, transparent); z-index: 5; }
.adm-savebar > * { pointer-events: auto; }
#form-errors:empty, #impact-note:empty { display: none; }
#form-errors ul { margin: 0; padding-inline-start: 20px; }

@media (pointer: coarse) {
    .adm input:not([type="checkbox"]):not([type="radio"]), .adm select, .adm textarea { font-size: 16px; }
    .adm input:not([type="checkbox"]):not([type="radio"]), .adm select { height: 44px; }
}
@media (max-width: 900px) {
    .adm { padding: 22px 16px 60px; }
    .adm-req-main { grid-template-columns: minmax(0, 1fr) auto; }
    .adm-req-main > select { grid-column: 1 / 2; }
    .adm-req-params { grid-column: 1 / 3; grid-row: 2; }
    .adm-steps li { grid-template-columns: minmax(0, 1fr) auto; }
    .adm-type { grid-column: 1 / 3; }
    .adm-locs { grid-column: 1 / 2; grid-row: 3; }
    .adm-actions { grid-column: 2 / 3; grid-row: 3; }
}
