/* ============ Design tokens ============ */
:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --surface-2: #f3f0eb;
  --surface-3: #ebe6de;
  --border: #e4ded4;
  --text: #1f1d1a;
  --text-2: #5c574f;
  --text-3: #8a8378;
  --accent: #c2410c;
  --accent-2: #ea580c;
  --accent-soft: #fdebdd;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --warn: #a16207;
  --warn-soft: #fef3c7;
  --info: #1d4ed8;
  --info-soft: #dbeafe;
  --code-bg: #1e1b18;
  --code-text: #f1ece4;
  --shadow: 0 1px 2px rgba(30, 25, 15, .06), 0 4px 16px rgba(30, 25, 15, .05);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Inter", "Noto Sans Thai", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Code", Consolas, monospace;
  --sidebar-w: 290px;
  --topbar-h: 56px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151412; --surface: #1d1b19; --surface-2: #252320; --surface-3: #2f2c28; --border: #36322d;
    --text: #f2eee8; --text-2: #bdb5aa; --text-3: #8d857a;
    --accent: #f97316; --accent-2: #fb923c; --accent-soft: #3a2415;
    --ok: #4ade80; --ok-soft: #14301f; --bad: #f87171; --bad-soft: #3a1717;
    --warn: #facc15; --warn-soft: #3a3012; --info: #60a5fa; --info-soft: #172640;
    --code-bg: #0f0e0d; --code-text: #ece6dc;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #151412; --surface: #1d1b19; --surface-2: #252320; --surface-3: #2f2c28; --border: #36322d;
  --text: #f2eee8; --text-2: #bdb5aa; --text-3: #8d857a;
  --accent: #f97316; --accent-2: #fb923c; --accent-soft: #3a2415;
  --ok: #4ade80; --ok-soft: #14301f; --bad: #f87171; --bad-soft: #3a1717;
  --warn: #facc15; --warn-soft: #3a3012; --info: #60a5fa; --info-soft: #172640;
  --code-bg: #0f0e0d; --code-text: #ece6dc;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  color-scheme: dark;
}

/* ============ Base ============ */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.6 var(--font); -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.08rem; }
p { margin: 0 0 .9em; }
ul, ol { margin: 0 0 1em; padding-left: 1.3em; }
li { margin: .25em 0; }
code { font-family: var(--mono); font-size: .88em; background: var(--surface-2); border: 1px solid var(--border); padding: .08em .35em; border-radius: 5px; }
pre { margin: 0; }
button { font: inherit; color: inherit; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.muted { color: var(--text-2); }
.small { font-size: .85rem; }
.tiny { font-size: .76rem; }
.nowrap { white-space: nowrap; }

/* ============ Top bar & layout ============ */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px; padding: 0 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); font-size: 1.02rem; }
.brand:hover { text-decoration: none; }
.brand-mark { display: flex; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.top-progress { font-size: .8rem; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.top-progress .bar { width: 120px; }
.icon-btn { background: none; border: 1px solid transparent; border-radius: 8px; padding: 6px; cursor: pointer; color: var(--text-2); display: inline-flex; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.menu-btn { display: none; }
.lang-btn { font: inherit; font-size: .8rem; font-weight: 700; min-width: 46px; padding: 5px 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.account-btn { display: inline-flex; align-items: center; gap: 8px; font-size: .82rem; font-weight: 600; padding: 5px 12px; border-radius: 8px; background: var(--accent); color: #fff; border: 1px solid var(--accent); white-space: nowrap; }
.account-btn:hover { background: var(--accent-2); text-decoration: none; }
.account-btn.signed-in { background: var(--surface); color: var(--text); border-color: var(--border); padding: 3px 10px 3px 4px; }
.account-btn.signed-in:hover { border-color: var(--accent); }
.avatar { border-radius: 50%; display: inline-grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; object-fit: cover; flex: none; }
.auth-wrap { min-height: calc(100vh - 180px); display: grid; place-items: center; padding: 20px 0; }
.auth-card { width: 100%; max-width: 440px; padding: 28px; }
.auth-card h1 { font-size: 1.6rem; }
.field { display: block; margin: 12px 0; }
.field span { display: block; font-size: .82rem; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.field input { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.field input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.auth-links { margin-top: 16px; text-align: center; color: var(--text-2); }
.auth-skip { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); text-align: center; font-size: .9rem; }
@media (max-width: 620px) { .acct-name { display: none; } .account-btn.signed-in { padding: 3px; } }
.lang-btn:hover { border-color: var(--accent); color: var(--accent); }

.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto;
  scrollbar-gutter: stable; /* same width whether or not the menu needs a scrollbar */
  overscroll-behavior: contain; /* scrolling the menu never scrolls the page */
  border-right: 1px solid var(--border); background: var(--surface); padding: 14px 10px 40px;
}
main { padding: 28px 32px 80px; width: 100%; min-width: 0; outline: none; } /* fills the window */
.scrim { display: none; }

/* Track switcher & cards */
.track-switch { display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 4px; margin: 0 4px 12px; }
.track-switch a { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: 7px; font-size: .86rem; font-weight: 600; color: var(--text-2); white-space: nowrap; }
.track-switch a > span { width: 18px; flex: none; text-align: center; color: var(--tc); }
.track-switch a:hover { text-decoration: none; color: var(--text); }
.track-switch a.on { background: var(--surface); color: var(--tc); box-shadow: var(--shadow); }
.track-card { border-top: 4px solid var(--tc); display: flex; flex-direction: column; }
.track-card .row:last-child { margin-top: auto; }
.track-icon { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 1.4rem; color: #fff; background: var(--tc); flex: none; }

/* Sidebar */
.nav-section { margin-bottom: 14px; }
.nav-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 600; padding: 6px 10px; }
.nav-link {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; color: var(--text-2);
  font-size: .9rem; line-height: 1.35;
}
.nav-link:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-link.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-link .ico { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav-phase > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px;
  font-size: .86rem; font-weight: 600; color: var(--text);
}
.nav-phase > summary::-webkit-details-marker { display: none; }
.nav-phase > summary:hover { background: var(--surface-2); }
.nav-phase > summary .chev { margin-left: auto; transition: transform .15s; color: var(--text-3); }
.nav-phase[open] > summary .chev { transform: rotate(90deg); }
.phase-num { font-size: .7rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); border-radius: 6px; padding: 1px 6px; flex: none; }
.nav-mod { display: flex; align-items: center; gap: 8px; padding: 5px 10px 5px 30px; font-size: .84rem; color: var(--text-2); border-radius: 8px; line-height: 1.35; }
.nav-mod:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-mod.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--border); flex: none; }
.dot.part { border-color: var(--accent); background: linear-gradient(90deg, var(--accent) 50%, transparent 50%); }
.dot.done { border-color: var(--ok); background: var(--ok); }

/* ============ Components ============ */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid > .card, .career-steps > .card { margin-top: 0; } /* grids space their own items; keep every box aligned */
.card-title { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack > * + * { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.section-head { display: flex; align-items: baseline; gap: 12px; margin: 30px 0 12px; }
.section-head h2 { margin: 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
  border-radius: 9px; padding: 9px 16px; font-weight: 600; font-size: .9rem;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.sm { padding: 5px 11px; font-size: .82rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.danger { color: var(--bad); }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); white-space: nowrap; }
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }

.bar { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; min-width: 60px; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s ease; }
.bar.ok > span { background: var(--ok); }
.bar.lg { height: 12px; }

.ring { --p: 0; --size: 120px; width: var(--size); height: var(--size); border-radius: 50%; display: grid; place-items: center; flex: none;
  background: conic-gradient(var(--accent) calc(var(--p) * 1%), var(--surface-3) 0); }
.ring > div { width: calc(var(--size) - 22px); height: calc(var(--size) - 22px); border-radius: 50%; background: var(--surface); display: grid; place-items: center; text-align: center; }
.ring strong { font-size: 1.6rem; display: block; line-height: 1; }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .num { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.stat .lbl { font-size: .8rem; color: var(--text-2); }

.callout { border-radius: var(--radius-sm); padding: 12px 14px; background: var(--info-soft); border-left: 4px solid var(--info); margin: 0 0 1em; font-size: .92rem; }
.callout.why { background: var(--accent-soft); border-left-color: var(--accent); }
.callout.warn { background: var(--warn-soft); border-left-color: var(--warn); }
.callout.ok { background: var(--ok-soft); border-left-color: var(--ok); }
.callout > :last-child { margin-bottom: 0; }
.callout strong:first-child { display: block; margin-bottom: 2px; }

.hero { display: flex; gap: 24px; align-items: center; }
.hero h1 { font-size: 1.9rem; }
.eyebrow { font-size: .75rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-bottom: 6px; }
.breadcrumb { font-size: .82rem; color: var(--text-3); margin-bottom: 8px; }
.breadcrumb a { color: var(--text-2); }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 18px 0 20px; overflow-x: auto; scrollbar-width: none; }
.tab { background: none; border: none; border-bottom: 2px solid transparent; padding: 10px 14px; cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--text-2); white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* Lessons */
.lesson { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 14px; overflow: hidden; }
.lesson > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 12px; padding: 14px 18px; font-weight: 600; }
.lesson > summary::-webkit-details-marker { display: none; }
.lesson > summary:hover { background: var(--surface-2); }
.lesson-idx { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; background: var(--surface-2); color: var(--text-2); flex: none; border: 1px solid var(--border); }
.lesson.read .lesson-idx { background: var(--ok); color: #fff; border-color: var(--ok); }
.lesson-body { padding: 4px 22px 18px 56px; border-top: 1px solid var(--border); }
/* keep long reading text at a comfortable line length on wide screens */
.lesson-body > p, .lesson-body > ul, .lesson-body > ol { max-width: 95ch; }
.lesson-body h4 { margin-top: 1.1em; font-size: .98rem; }
.lesson-body table { border-collapse: collapse; width: 100%; margin: 0 0 1em; font-size: .88rem; display: block; overflow-x: auto; }
.lesson-body th, .lesson-body td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; vertical-align: top; }
.lesson-body th { background: var(--surface-2); }
.lesson-foot { display: flex; justify-content: flex-end; margin-top: 12px; }
.analogy { background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 14px; margin: 0 0 1em; font-size: .92rem; }
.analogy::before { content: "Think of it like this — "; font-weight: 700; color: var(--accent); }

/* Code */
.code { position: relative; background: var(--code-bg); color: var(--code-text); border-radius: var(--radius-sm); margin: 0 0 1em; }
.code code { background: none; border: 0; padding: 0; color: inherit; font-size: inherit; border-radius: 0; }
.code pre { padding: 14px 16px; overflow-x: auto; font: 13px/1.55 var(--mono); tab-size: 4; }
.code .lang { position: absolute; top: 6px; right: 70px; font-size: .68rem; color: #9b9387; text-transform: uppercase; letter-spacing: .06em; font-family: var(--mono); }
.code .copy { position: absolute; top: 5px; right: 6px; background: #2d2925; color: #d9d2c7; border: 1px solid #45403a; font-size: .72rem; padding: 2px 9px; border-radius: 6px; cursor: pointer; }
.code .copy:hover { background: #3b3631; }
.tok-c { color: #8f877b; font-style: italic; }
.tok-s { color: #a8d59b; }
.tok-k { color: #f0a36b; }
.tok-n { color: #d7b3ff; }

/* Video lessons */
.videos { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.video { min-width: 0; }
.yt, .yt-frame { display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; border-radius: 10px; overflow: hidden; background: #000; }
.yt { position: relative; padding: 0; cursor: pointer; }
.yt img { width: 100%; height: 100%; object-fit: cover; display: block; transition: opacity .15s; }
.yt:hover img { opacity: .85; }
.yt .play { position: absolute; inset: 0; margin: auto; width: 58px; height: 40px; border-radius: 11px; background: rgba(220, 38, 38, .9); color: #fff; display: grid; place-items: center; font-size: 17px; box-shadow: 0 2px 10px rgba(0,0,0,.35); }
.yt:hover .play { background: #dc2626; }
.video-meta { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; font-size: .86rem; line-height: 1.35; }

/* Key terms */
.terms { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.term { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-size: .86rem; }
.term b { display: block; margin-bottom: 2px; color: var(--text); }
.term span { color: var(--text-2); }

/* Quiz */
.q { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; background: var(--surface); margin-bottom: 14px; }
.q-head { display: flex; gap: 10px; font-weight: 600; margin-bottom: 10px; }
.q-num { color: var(--accent); flex: none; }
.opt { display: flex; align-items: flex-start; gap: 10px; width: 100%; text-align: left; padding: 10px 12px; margin: 6px 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; font-size: .92rem; line-height: 1.45; }
.opt:hover { border-color: var(--accent); }
.opt .key { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; font-size: .75rem; font-weight: 700; background: var(--surface-2); flex: none; border: 1px solid var(--border); }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.opt.sel .key { background: var(--accent); color: #fff; border-color: var(--accent); }
.opt.right { border-color: var(--ok); background: var(--ok-soft); }
.opt.right .key { background: var(--ok); color: #fff; border-color: var(--ok); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt.wrong .key { background: var(--bad); color: #fff; border-color: var(--bad); }
.opt:disabled { cursor: default; }
.opt:disabled:hover { border-color: inherit; }
.explain-row, .why-head { display: flex; align-items: flex-start; gap: 10px; }
.explain-row > div:first-child { flex: 1; min-width: 0; }
.why-head { justify-content: space-between; }
.why-head strong { margin-bottom: 2px; }
.swap { flex: none; font-size: .74rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; white-space: nowrap; }
.swap:hover { border-color: var(--accent); color: var(--accent); }
[lang="th"] { line-height: 1.75; }
.explain { margin-top: 10px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: .88rem; }
.score-banner { display: flex; align-items: center; gap: 16px; padding: 16px 18px; border-radius: var(--radius); margin-bottom: 16px; }
.score-banner.pass { background: var(--ok-soft); }
.score-banner.fail { background: var(--warn-soft); }
.score-banner .big { font-size: 2rem; font-weight: 800; }

/* Lab */
.steps { counter-reset: step; list-style: none; padding: 0; }
.steps > li { counter-increment: step; position: relative; padding: 2px 0 12px 40px; }
.steps > li::before { content: counter(step); position: absolute; left: 0; top: 1px; width: 26px; height: 26px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: .8rem; display: grid; place-items: center; }
.check { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.check:hover { background: var(--surface-2); }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--ok); flex: none; }
.check.done span { color: var(--text-3); text-decoration: line-through; }
textarea, input[type="text"], select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 11px;
}
textarea { min-height: 110px; resize: vertical; font-size: .9rem; }
select { width: auto; }

/* Roadmap */
.roadmap { position: relative; padding-left: 36px; }
.roadmap::before { content: ""; position: absolute; left: 15px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.rm-phase { position: relative; margin-bottom: 18px; }
.rm-node { position: absolute; left: -36px; top: 18px; width: 32px; height: 32px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border); display: grid; place-items: center; font-weight: 700; font-size: .82rem; color: var(--text-2); }
.rm-node.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.rm-node.part { border-color: var(--accent); color: var(--accent); }
.rm-mods { display: grid; gap: 8px; margin-top: 12px; }
.rm-mod { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--text); font-size: .9rem; }
.rm-mod:hover { text-decoration: none; background: var(--surface-3); }
.rm-mod .meta { margin-left: auto; display: flex; gap: 8px; align-items: center; color: var(--text-3); font-size: .78rem; }

/* Cert cards */
.cert { display: flex; flex-direction: column; gap: 10px; }
.cert-top { display: flex; align-items: flex-start; gap: 12px; }
.cert-logo { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; font-weight: 800; font-size: .72rem; color: #fff; flex: none; letter-spacing: .02em; }
.cert h3 { margin: 0 0 2px; }
.star { background: none; border: none; cursor: pointer; color: var(--text-3); padding: 4px; margin-left: auto; }
.star.on { color: var(--accent); }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.fact { background: var(--surface-2); border-radius: 8px; padding: 8px 10px; }
.fact b { display: block; font-size: .95rem; }
.fact span { font-size: .72rem; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.domain { display: grid; grid-template-columns: minmax(0, 1fr) 60px; gap: 10px; align-items: center; font-size: .9rem; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.domain:last-child { border-bottom: none; }

/* Exam */
.exam-nav { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0; }
.exam-nav button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: .8rem; font-weight: 600; }
.exam-nav button.ans { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.exam-nav button.cur { outline: 2px solid var(--accent); outline-offset: 1px; }
.exam-nav button.right { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.exam-nav button.wrong { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.timer { font-family: var(--mono); font-weight: 600; font-size: 1.05rem; }
.timer.low { color: var(--bad); }
.flag { color: var(--warn); }

/* Labs */
.lab-canvas { width: 100%; height: auto; background: var(--surface-2); border-radius: var(--radius-sm); border: 1px solid var(--border); touch-action: none; display: block; }
.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin: 12px 0; }
.control label { display: flex; justify-content: space-between; font-size: .82rem; color: var(--text-2); margin-bottom: 4px; }
.control input[type="range"] { width: 100%; accent-color: var(--accent); }
.readout { font-family: var(--mono); font-size: .85rem; background: var(--surface-2); padding: 8px 12px; border-radius: 8px; }
.prob-row { display: grid; grid-template-columns: 90px minmax(0, 1fr) 56px; gap: 10px; align-items: center; font-size: .88rem; margin: 5px 0; }
.prob-row .bar { height: 14px; }
.prob-row .bar > span { transition: width .25s; }
.sample-out { font-family: var(--mono); font-size: .9rem; background: var(--surface-2); padding: 10px 12px; border-radius: 8px; min-height: 44px; word-break: break-word; }

.empty { text-align: center; padding: 40px 20px; color: var(--text-2); }
.footer-note { margin-top: 40px; font-size: .8rem; color: var(--text-3); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-size: .88rem; opacity: 0; pointer-events: none; transition: all .25s; z-index: 50; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============ Responsive ============ */
@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .menu-btn { display: inline-flex; }
  .sidebar { position: fixed; left: 0; top: var(--topbar-h); z-index: 40; width: min(86vw, 320px); transform: translateX(-102%); transition: transform .2s ease; box-shadow: var(--shadow); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .scrim { display: block; position: fixed; inset: var(--topbar-h) 0 0 0; background: rgba(0,0,0,.35); z-index: 35; }
  main { padding: 20px 16px 70px; }
  .top-progress .bar { width: 70px; }
}
@media (max-width: 620px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .hero { flex-direction: column; align-items: flex-start; }
  .lesson-body { padding: 4px 16px 16px 16px; }
  .top-progress .txt { display: none; }
  h1, .hero h1 { font-size: 1.45rem; }
  .rm-mod .meta .badge { display: none; }
  .stats-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stats-row .card { padding: 12px 10px; }
  .stats-row .num { font-size: 1.15rem; }
  .stats-row .lbl { font-size: .72rem; }
}

.track-card h2 { font-size: 1.2rem; overflow-wrap: anywhere; }

/* career guide */
.career-cta { display: flex; align-items: center; gap: 14px; margin-top: 16px; color: inherit; border-left: 4px solid var(--accent); }
.career-cta:hover, .career-card:hover { text-decoration: none; box-shadow: var(--shadow); }
.career-cta .track-icon .ico { width: 22px; height: 22px; }
.career-card { color: inherit; }
.chain { align-items: center; margin-bottom: 14px; }
.chain-arrow { color: var(--text-3); font-size: .85rem; }
.chain-card .chain { margin: 0; }
.career-steps { display: grid; gap: 14px; margin-top: 14px; }
.career-step { display: flex; gap: 14px; align-items: flex-start; }
.career-step h3 { margin: 10px 0 6px; }
.step-num { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; color: #fff; background: var(--text-3); }
.step-body { flex: 1; min-width: 0; }
.howto { margin: 0 0 10px; }
.howto > li { padding-bottom: 8px; }
@media (max-width: 620px) {
  .career-cta { flex-wrap: wrap; }
  .career-step { gap: 10px; }
  .step-num { width: 28px; height: 28px; font-size: .85rem; }
}

/* sidebar before a track is chosen */
.nav-link.disabled { opacity: .45; cursor: default; }
.nav-link.disabled:hover { background: none; color: var(--text-2); }
.nav-hint { font-size: .75rem; color: var(--text-3); padding: 4px 10px 0; }

/* admin panel */
.admin-search { height: 36px; min-width: min(280px, 100%); padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: .88rem; }
.admin-table-wrap { padding: 0; overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.admin-table th, .admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.admin-table th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-3); background: var(--surface-2); white-space: nowrap; }
.admin-table tbody tr:last-child td { border-bottom: 0; }
.admin-table tr[data-uid] { cursor: pointer; }
.admin-table tr[data-uid]:hover, .admin-table tr[data-uid]:focus { background: var(--surface-2); outline: none; }
.admin-table .bar { margin-top: 4px; }
.admin-table .dot { display: inline-block; vertical-align: middle; margin-right: 6px; }
