/* Layout: a field-journal app — a quest map dashboard, then a two-column week view (section rail + work surface). */
:root {
  --bg: #f3f6f3;
  --surface: #ffffff;
  --surface-2: #e9eeea;
  --ink: #17262a;
  --ink-2: #4a5c5f;
  --line: #cfd9d4;
  --brand: #1d3a3f;
  --accent: #b86e12;
  --accent-soft: #f6e6cc;
  --good: #2c6e57;
  --good-soft: #dcefe6;
  --bad: #a83a2a;
  --bad-soft: #f7e0db;
  --code-bg: #f7f4ec;
  --code-ink: #2a2a24;
  --focus: #2b6cb0;
  --f-display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --f-body: "Atkinson Hyperlegible", "Segoe UI", system-ui, sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --r: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1a1c; --surface: #152427; --surface-2: #1c3034; --ink: #e5ece9; --ink-2: #a7b8b4; --line: #2d4448;
    --brand: #0b1416; --accent: #e4a53a; --accent-soft: #3a2e17; --good: #6cc3a1; --good-soft: #173a2f;
    --bad: #f08a76; --bad-soft: #3d1f1a; --code-bg: #101c1e; --code-ink: #e9e4d6; --focus: #7fb2f0; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1a1c; --surface: #152427; --surface-2: #1c3034; --ink: #e5ece9; --ink-2: #a7b8b4; --line: #2d4448;
  --brand: #0b1416; --accent: #e4a53a; --accent-soft: #3a2e17; --good: #6cc3a1; --good-soft: #173a2f;
  --bad: #f08a76; --bad-soft: #3d1f1a; --code-bg: #101c1e; --code-ink: #e9e4d6; --focus: #7fb2f0; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.6 var(--f-body); -webkit-font-smoothing: antialiased; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
a { color: inherit; }
h1, h2, h3, h4 { font-family: var(--f-display); line-height: 1.15; text-wrap: balance; margin: 0 0 .5em; }
h1 { font-size: clamp(1.8rem, 3vw + 1rem, 2.6rem); font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 1.5rem; font-weight: 700; }
h3 { font-size: 1.15rem; font-weight: 700; }
code, pre, kbd { font-family: var(--f-mono); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 50; }
.skip:focus { left: 8px; }
button { font: inherit; }
.wrap { max-width: 1200px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.muted { color: var(--ink-2); }
.eyebrow { font: 700 .75rem/1 var(--f-body); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }

/* ---------- top bar */
.topbar { background: var(--brand); color: #eef3f0; position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 21; background: var(--brand); }
.topbar-inner { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding-block: 10px; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand svg { width: 30px; height: 30px; color: #e4a53a; }
.brand span { display: flex; flex-direction: column; line-height: 1.1; }
.brand strong { font-family: var(--f-display); font-size: 1.1rem; }
.brand small { font-size: .75rem; opacity: .75; letter-spacing: .04em; }
.mainnav { display: flex; gap: 4px; flex-wrap: wrap; }
.mainnav a { text-decoration: none; padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: .92rem; opacity: .85; }
.mainnav a:hover { opacity: 1; background: rgba(255,255,255,.08); }
.mainnav a[aria-current="page"] { background: #e4a53a; color: #1b1405; opacity: 1; }
.account { margin-left: auto; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: .85rem; }
.py-status, .save-status { opacity: .8; }
.py-status.ready::before { content: "● "; color: #6cc3a1; }
.py-status.loading::before { content: "◌ "; color: #e4a53a; }
.menu { position: relative; }
.menu summary { cursor: pointer; list-style: none; padding: 6px 12px; border: 1px solid rgba(255,255,255,.25); border-radius: 999px; font-weight: 700; }
.menu summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 10px 30px rgba(0,0,0,.18); min-width: 200px; padding: 6px; display: grid; }
.menu-pop button { text-align: left; background: none; border: 0; padding: 10px 12px; border-radius: 6px; color: inherit; cursor: pointer; }
.menu-pop button:hover { background: var(--surface-2); }

/* ---------- buttons & forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 9px 16px; border-radius: 999px; font-weight: 700; cursor: pointer; text-decoration: none; min-height: 40px; }
.btn:hover { border-color: var(--ink-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #1b1405; }
.btn.go { background: var(--good); border-color: var(--good); color: #fff; }
:root[data-theme="dark"] .btn.go, :root:not([data-theme="light"]) .btn.go { color: #06140f; }
@media (prefers-color-scheme: light) { :root:not([data-theme="dark"]) .btn.go { color: #fff; } }
.btn.small { padding: 5px 12px; min-height: 32px; font-size: .88rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
label { font-weight: 700; display: block; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; }
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.field { margin-bottom: 14px; }
.hint { font-size: .85rem; color: var(--ink-2); margin-top: 4px; }
.error-msg { color: var(--bad); font-weight: 700; min-height: 1.5em; }

/* ---------- auth */
.auth { min-height: 100%; display: grid; place-items: center; padding-block: 40px; }
.auth-card { width: min(920px, 100%); display: grid; grid-template-columns: 1.1fr 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.auth-hero { background: var(--brand); color: #eef3f0; padding: 36px; position: relative; overflow: hidden; }
.auth-hero h1 { color: #fff; }
.auth-hero p { opacity: .85; max-width: 38ch; }
.auth-hero .contours { position: absolute; inset: auto -40px -40px auto; width: 360px; opacity: .25; color: #e4a53a; }
.auth-hero ul { padding-left: 1.1em; opacity: .9; }
.auth-form { padding: 32px; }
.tabs { display: flex; gap: 6px; margin-bottom: 20px; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; padding: 10px 6px; margin-right: 12px; font-weight: 700; color: var(--ink-2); border-bottom: 3px solid transparent; cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
@media (max-width: 760px) { .auth-card { grid-template-columns: 1fr; } .auth-hero { padding: 24px; } }

/* ---------- dashboard */
.page { padding-block: 28px 64px; }
.dash-head { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-end; justify-content: space-between; margin-bottom: 24px; }
.meter { width: min(360px, 100%); }
.meter-bar { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.meter-bar span { display: block; height: 100%; background: var(--good); border-radius: 999px; }
.meter-label { display: flex; justify-content: space-between; font-size: .85rem; color: var(--ink-2); margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: .85rem; color: var(--ink-2); margin-bottom: 14px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.map { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.tile { position: relative; display: grid; gap: 8px; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px; min-width: 0; }
.tile:hover { border-color: var(--accent); }
.tile .num { font: 800 2rem/1 var(--f-display); color: var(--accent); font-variant-numeric: tabular-nums; }
.tile .ttl { font-weight: 700; line-height: 1.3; }
.tile .sub { font-size: .85rem; color: var(--ink-2); }
.tile.exam { background: var(--accent-soft); border-color: transparent; }
.tile.current { outline: 2px solid var(--accent); outline-offset: -2px; }
.pips { display: flex; gap: 4px; }
.pip { width: 100%; height: 6px; border-radius: 3px; background: var(--surface-2); }
.pip.done { background: var(--good); }
.pip.part { background: var(--accent); }
.tile .pct { position: absolute; top: 16px; right: 16px; font-size: .8rem; font-weight: 700; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.continue { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; margin-bottom: 24px; }

/* ---------- week view */
.week { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 28px; padding-block: 24px 64px; }
.rail { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 76px); align-self: start; display: grid; gap: 6px; }
.rail .back { font-size: .9rem; color: var(--ink-2); text-decoration: none; margin-bottom: 8px; }
.rail .wk { font: 800 1.2rem/1.2 var(--f-display); margin-bottom: 8px; }
.rail a.sec { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); }
.rail a.sec:hover { background: var(--surface-2); }
.rail a.sec[aria-current="page"] { background: var(--surface); border: 1px solid var(--line); font-weight: 700; }
.state { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line); flex: none; display: grid; place-items: center; font-size: 11px; }
.state.done { background: var(--good); border-color: var(--good); color: #fff; }
.state.part { border-color: var(--accent); background: conic-gradient(var(--accent) 0 50%, transparent 50% 100%); }
.weeknav { display: flex; justify-content: space-between; gap: 12px; margin-top: 32px; flex-wrap: wrap; }
@media (max-width: 900px) {
  .week { grid-template-columns: 1fr; }
  .rail { position: static; grid-auto-flow: column; grid-auto-columns: max-content; overflow-x: auto; padding-bottom: 6px; }
  .rail .back, .rail .wk { display: none; }
}
.content { min-width: 0; }
.prose { max-width: 75ch; }
.prose h3 { margin-top: 1.6em; }
.prose p, .prose li { max-width: 75ch; }
.prose table { border-collapse: collapse; width: 100%; font-size: .93rem; margin: 1em 0; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.prose th { background: var(--surface-2); }
.prose code { background: var(--code-bg); color: var(--code-ink); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.prose pre { background: var(--code-bg); color: var(--code-ink); padding: 14px 16px; border-radius: var(--r); overflow-x: auto; font-size: .86rem; line-height: 1.5; border: 1px solid var(--line); }
.prose pre code { background: none; color: inherit; padding: 0; font-size: inherit; }
.prose pre.console { background: #0e1416; color: #d7e4d9; border-color: #0e1416; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; margin: 18px 0; }
.card > h3:first-child { margin-top: 0; }
.donebar { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 24px; padding: 14px 16px; border-radius: 10px; background: var(--surface-2); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; background: var(--surface-2); color: var(--ink-2); }
.chip.good { background: var(--good-soft); color: var(--good); }
.chip.bad { background: var(--bad-soft); color: var(--bad); }
.chip.warn { background: var(--accent-soft); color: var(--accent); }

/* ---------- knowledge check */
.q { border-top: 1px solid var(--line); padding: 18px 0; min-width: 0; }
.q pre { max-width: 100%; overflow-x: auto; }
.q legend { max-width: 100%; }
.q:first-of-type { border-top: 0; }
.q .stem { font-weight: 700; }
.opts { display: grid; gap: 8px; margin-top: 10px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; font-weight: 400; margin: 0; background: var(--surface); }
.opt:hover { border-color: var(--ink-2); }
.opt input { margin-top: 5px; }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }
.q.right .stem::after { content: "  ✓ correct"; color: var(--good); font-size: .85rem; }
.q.wrong .stem::after { content: "  ✗ try again"; color: var(--bad); font-size: .85rem; }

/* ---------- workbench */
.task { border-top: 2px solid var(--line); padding-top: 18px; margin-top: 26px; }
.bench { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); overflow: hidden; margin-top: 14px; }
.bench-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.ftab { border: 1px solid transparent; background: none; padding: 5px 10px; border-radius: 6px; font: 600 .85rem var(--f-mono); color: var(--ink-2); cursor: pointer; }
.ftab[aria-selected="true"] { background: var(--surface); border-color: var(--line); color: var(--ink); }
.bench-head .spacer { flex: 1; }
.bench .CodeMirror { height: auto; min-height: 220px; max-height: 520px; font: .9rem/1.55 var(--f-mono); background: var(--code-bg); color: var(--code-ink); }
.bench .CodeMirror-scroll { min-height: 220px; max-height: 520px; }
.bench .CodeMirror-gutters { background: var(--surface-2); border-right: 1px solid var(--line); }
.bench .CodeMirror-linenumber { color: var(--ink-2); }
.bench .CodeMirror-cursor { border-left-color: var(--ink); }
.cm-s-default .cm-keyword { color: #8f3f71; font-weight: 600; }
.cm-s-default .cm-string { color: #2c6e57; }
.cm-s-default .cm-comment { color: #7a7a6a; font-style: italic; }
.cm-s-default .cm-number { color: #b86e12; }
.cm-s-default .cm-def, .cm-s-default .cm-builtin { color: #1f5f9e; }
:root[data-theme="dark"] .cm-s-default .cm-keyword { color: #e39bc6; }
:root[data-theme="dark"] .cm-s-default .cm-string { color: #8fd4b4; }
:root[data-theme="dark"] .cm-s-default .cm-def, :root[data-theme="dark"] .cm-s-default .cm-builtin { color: #8ec2f5; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .cm-s-default .cm-keyword { color: #e39bc6; }
  :root:not([data-theme="light"]) .cm-s-default .cm-string { color: #8fd4b4; }
  :root:not([data-theme="light"]) .cm-s-default .cm-def, :root:not([data-theme="light"]) .cm-s-default .cm-builtin { color: #8ec2f5; }
  :root:not([data-theme="light"]) .cm-s-default .cm-variable, :root:not([data-theme="light"]) .cm-s-default .cm-variable-2 { color: var(--code-ink); }
}
.bench-io { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); border-top: 1px solid var(--line); }
.bench-io > div { padding: 10px 12px; min-width: 0; }
.bench-io > div + div { border-left: 1px solid var(--line); }
.bench-io textarea { font: .85rem/1.5 var(--f-mono); min-height: 110px; }
.bench-io .out { font: .82rem/1.5 var(--f-mono); background: #0e1416; color: #d7e4d9; border-radius: 8px; padding: 10px 12px; min-height: 110px; max-height: 380px; overflow: auto; white-space: pre; margin: 0; }
.bench-io .lbl { font: 700 .72rem/1 var(--f-body); letter-spacing: .1em; text-transform: uppercase; color: var(--ink-2); margin-bottom: 6px; display: block; }
@media (max-width: 700px) { .bench-io { grid-template-columns: 1fr; } .bench-io > div + div { border-left: 0; border-top: 1px solid var(--line); } }
.bench-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; padding: 10px 12px; border-top: 1px solid var(--line); }
.results { border-top: 1px solid var(--line); padding: 10px 12px; display: grid; gap: 8px; }
.result { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
.result.pass { border-color: transparent; background: var(--good-soft); }
.result.fail { border-color: transparent; background: var(--bad-soft); }
.result summary { cursor: pointer; font-weight: 700; display: flex; gap: 8px; align-items: center; }
.result .mark { font-family: var(--f-mono); }
.diff { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; margin-top: 10px; }
.diff pre { margin: 4px 0 0; background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 8px; font-size: .78rem; max-height: 300px; overflow: auto; white-space: pre; }
.diff .first { margin-top: 8px; font-size: .88rem; }
.diff .first code { background: var(--surface); padding: 1px 4px; border-radius: 4px; white-space: pre; }
@media (max-width: 700px) { .diff { grid-template-columns: 1fr; } }
.hl-bad { background: var(--bad-soft); outline: 1px solid var(--bad); }

/* ---------- analysis */
.step { display: grid; gap: 6px; margin-bottom: 18px; }
.step .count { font-size: .8rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------- instructor */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table.grid { border-collapse: collapse; width: 100%; font-size: .9rem; font-variant-numeric: tabular-nums; }
table.grid th, table.grid td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: center; white-space: nowrap; }
table.grid th:first-child, table.grid td:first-child { text-align: left; position: sticky; left: 0; background: var(--surface); }
table.grid thead th { background: var(--surface-2); }
table.grid td.c0 { color: var(--ink-2); }
table.grid td.c1 { background: var(--accent-soft); }
table.grid td.c2 { background: var(--good-soft); color: var(--good); font-weight: 700; }
table.grid a { font-weight: 700; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input { max-width: 280px; }

dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); padding: 24px; width: min(440px, 92vw); }
dialog::backdrop { background: rgba(10, 20, 22, .55); }
.toast { position: fixed; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-weight: 700; z-index: 40; box-shadow: 0 8px 24px rgba(0,0,0,.25); }
@media (prefers-reduced-motion: no-preference) { .tile, .btn { transition: border-color .15s, background-color .15s; } }

/* ---------- catalog, course landing, free preview and unlocking */
[hidden] { display: none !important; }
.linkish { background: none; border: 0; padding: 0; color: var(--ink-2); text-decoration: underline; cursor: pointer; font-size: .9rem; }
.linkish:hover { color: var(--ink); }
.catalog-hero { padding: 12px 0 28px; max-width: 760px; }
.catalog-hero p { font-size: 1.1rem; color: var(--ink-2); max-width: 60ch; }
.catalog { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 16px; }
.course-card { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; }
.course-card h2 { margin: 4px 0 0; }
.course-card p { margin: 0; }
.course-card.soon { background: transparent; border-style: dashed; }
.course-card.soon h2, .course-card.soon .muted { opacity: .75; }
.course-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.price { font: 800 1.1rem/1 var(--f-display); }
.course-actions { margin-top: auto; padding-top: 12px; }
.landing { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 28px; align-items: start; margin: 12px 0 20px; }
.landing .lead { font-size: 1.1rem; max-width: 60ch; }
.ticks { padding-left: 1.2em; }
.ticks li { margin: 4px 0; }
.outline { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 6px; font-size: .93rem; }
.outline li { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.unlock { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; background: var(--accent-soft); border-radius: 12px; padding: 16px 20px; margin-bottom: 16px; }
.unlock strong { display: block; font-size: 1.05rem; }
.unlock-actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.tile.locked { background: transparent; border-style: dashed; }
.tile.locked .num, .tile.locked .ttl { opacity: .6; }
.locked-card { max-width: 720px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 24px; margin-top: 12px; }
@media (max-width: 800px) { .landing { grid-template-columns: 1fr; } }

/* ---------- math workbench */
.prose .katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.mtask-prompt .prose { margin-bottom: 10px; }
.mbench { margin-top: 6px; }
.mwork { padding: 14px; display: grid; gap: 10px; }
.mrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.mlabel { font-weight: 700; white-space: nowrap; }
.mf { min-width: min(320px, 100%); flex: 1; max-width: 520px; font-size: 1.15rem; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
math-field.mf { display: block; --caret-color: var(--accent); --selection-background-color: var(--accent-soft); --contains-highlight-background-color: transparent; }
math-field.mf:focus-within { outline: 3px solid var(--focus); outline-offset: 1px; }
input.mf { font-family: var(--f-mono); font-size: 1rem; }
.msteps { margin: 0; padding-left: 1.6em; display: grid; gap: 8px; }
.msteps li { padding-left: 4px; }
.msteps li > * { vertical-align: middle; }
.msteps li .mf { display: inline-block; width: calc(100% - 56px); max-width: 520px; }
.msteps li .btn { margin-left: 6px; }
.msteps li.good .mf { border-color: var(--good); box-shadow: inset 4px 0 0 var(--good); }
.msteps li.bad .mf { border-color: var(--bad); box-shadow: inset 4px 0 0 var(--bad); }
.mfeedback:empty { display: none; }
.mfeedback { margin: 0 12px 12px; padding: 10px 12px; border-radius: 8px; }
.mfeedback.ok { background: var(--good-soft); color: var(--ink); }
.mfeedback.no { background: var(--bad-soft); color: var(--ink); }
.mfeedback.ok strong { color: var(--good); }
.mfeedback.no strong { color: var(--bad); }
.mgraph-wrap { display: grid; gap: 8px; }
.mgraph { width: 100%; max-width: 620px; height: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; touch-action: none; }
.mgraph .g-minor { stroke: var(--line); stroke-width: .6; opacity: .6; }
.mgraph .g-major { stroke: var(--line); stroke-width: 1.2; }
.mgraph .g-tick { font: 11px var(--f-body); fill: var(--ink-2); }
.mgraph .g-label { font: 700 12px var(--f-body); fill: var(--ink-2); }
.mgraph .g-line { stroke: var(--accent); stroke-width: 3; }
.mgraph .g-pt { fill: var(--brand); stroke: #fff; stroke-width: 3; cursor: grab; }
:root[data-theme="dark"] .mgraph .g-pt { fill: var(--accent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .mgraph .g-pt { fill: var(--accent); } }
.mgraph .g-pt:focus { outline: none; stroke: var(--focus); stroke-width: 4; }
.mpoints { display: flex; gap: 16px; flex-wrap: wrap; font-size: .9rem; }
.mpoints input { width: 7em; padding: 4px 6px; }
.mwork > .btn { justify-self: start; }
math-field.mf::part(menu-toggle) { display: none; }
/* phones: the header scrolls away instead of pinning, and fits in fewer rows */
@media (max-width: 640px) {
  .topbar { position: static; }
  .topbar-inner { gap: 8px 12px; padding-block: 8px; }
  .mainnav { flex-wrap: nowrap; overflow-x: auto; width: 100%; order: 3; scrollbar-width: none; }
  .mainnav a { white-space: nowrap; padding: 5px 10px; }
  .account { gap: 8px; }
  .rail { top: 0; }
  .msteps li .mf { min-width: 0; width: calc(100% - 52px); }
  .mf { min-width: 0; width: 100%; }
}
.msteps li .mf { min-width: 0; }
.mrow .hint { flex-basis: 100%; margin: 0; }
.mrow.good .mf { border-color: var(--good); box-shadow: inset 4px 0 0 var(--good); }
.mrow.bad .mf, .mrow.bad .mchoice { border-color: var(--bad); box-shadow: inset 4px 0 0 var(--bad); }
.mrow-choice { align-items: flex-start; }
.mchoice { display: flex; flex-wrap: wrap; gap: 8px; border: 1px solid transparent; border-radius: 8px; padding: 2px; }
.mopt { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; }
.mopt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }

/* touch devices: plain text answer box with symbol buttons and a live preview */
.mtext { flex: 1; min-width: 0; max-width: 520px; display: grid; gap: 6px; }
.mtext-input { width: 100%; min-width: 0; font: 1.1rem/1.4 var(--f-mono); padding: 10px 12px; }
.mkeys { display: flex; flex-wrap: wrap; gap: 6px; }
.mkey { min-width: 44px; min-height: 40px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); color: var(--ink); font: 600 1rem var(--f-body); }
.mkey:active { background: var(--accent-soft); }
.mpreview { min-height: 1.6em; font-size: 1.1rem; color: var(--ink-2); overflow-x: auto; }
.mpreview:empty { display: none; }
.msteps li .mtext { display: inline-grid; width: calc(100% - 52px); vertical-align: middle; }
.mrow.good .mtext-input { border-color: var(--good); box-shadow: inset 4px 0 0 var(--good); }
.mrow.bad .mtext-input { border-color: var(--bad); box-shadow: inset 4px 0 0 var(--bad); }
.msteps li.good .mtext-input { border-color: var(--good); box-shadow: inset 4px 0 0 var(--good); }
.msteps li.bad .mtext-input { border-color: var(--bad); box-shadow: inset 4px 0 0 var(--bad); }
/* symbol buttons only under the box being typed in; step lines use the full width */
.mtext:not(:focus-within) .mkeys { display: none; }
.mpreview { overflow-y: hidden; }
.msteps { counter-reset: step; list-style: none; padding-left: 0; }
.msteps li { counter-increment: step; display: grid; grid-template-columns: 1.8em minmax(0, 1fr) auto; gap: 6px; align-items: start; padding-left: 0; }
.msteps li::before { content: counter(step) "."; padding-top: 10px; color: var(--ink-2); text-align: right; }
.msteps li .mf, .msteps li .mtext { width: 100%; max-width: 520px; display: block; }
.msteps li .btn { margin-left: 0; margin-top: 4px; }
@media (max-width: 640px) { .mrow { align-items: stretch; } .mrow .mlabel { flex-basis: 100%; } }
.course-project { font-weight: 700; color: var(--accent); font-size: .95rem; margin: 2px 0 4px; }

/* Paths */
.section-title { margin: 28px 0 6px; }
.paths { margin-bottom: 8px; }
.path-card { border-width: 2px; }
.path-steps { margin: 6px 0 0; padding-left: 1.3em; display: grid; gap: 4px; }
.path-steps li { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.path-steps li.soon { opacity: .7; }
.path-link { font-size: .9rem; font-weight: 600; }
.path-courses { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 14px; }
.path-courses > li { display: grid; grid-template-columns: 40px 1fr; gap: 12px; align-items: start; }
.path-num { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; background: var(--accent); color: var(--surface); margin-top: 18px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 14px; }
.chip-btn { border: 1px solid var(--line); background: var(--surface); color: inherit; border-radius: 999px; padding: 5px 12px; font: inherit; font-size: .9rem; cursor: pointer; }
.chip-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--surface); }
.admin-note { display: inline-block; margin-top: 10px; white-space: normal; line-height: 1.4; }
.cert-card { border-style: solid; border-color: var(--accent); }
.course-top .chip { white-space: nowrap; }

/* Site layout: side menu on home, paths, courses, certifications */
.site-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 32px; align-items: start; }
.site-side { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 18px; }
.site-side nav { display: flex; flex-direction: column; gap: 4px; }
.side-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: inherit; text-decoration: none; font-weight: 600; }
.side-link:hover { background: var(--surface); }
.side-link[aria-current="page"] { background: var(--surface); box-shadow: inset 3px 0 0 var(--accent); }
.side-icon { width: 20px; text-align: center; color: var(--accent); }
.side-count { margin-left: auto; font-size: .8rem; font-weight: 700; color: var(--ink-2); background: var(--line); border-radius: 999px; padding: 1px 8px; }
.side-mine { display: flex; flex-direction: column; gap: 4px; padding: 0 12px; }
.side-sub { font-size: .92rem; }
.side-note { font-size: .85rem; color: var(--ink-2); padding: 0 12px; margin: 0; }
.site-content { min-width: 0; }
.catalog-hero.compact { padding-bottom: 18px; }
.section-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }

/* Home */
.home-hero { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 32px; align-items: center; padding: 8px 0 24px; }
.home-hero h1 { font-size: clamp(2.4rem, 5vw, 3.6rem); margin: 6px 0 10px; }
.home-hero .lead { font-size: 1.12rem; color: var(--ink-2); max-width: 58ch; }
.hero-cycle { display: grid; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; }
.cycle-step { display: flex; align-items: center; gap: 12px; font-weight: 700; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); }
.cycle-step span { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: var(--surface); flex: none; }
.how-grid { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); gap: 14px; }
.how-step { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 18px; }
.how-step h3 { margin: 10px 0 6px; }
.how-step p { margin: 0; color: var(--ink-2); }
.how-num { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; border: 2px solid var(--accent); color: var(--accent); }
.why-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 22px; }
.why-grid h3 { margin: 0 0 6px; }
.why-grid p { margin: 0; color: var(--ink-2); }
.way-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 14px; }
.way-card { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; color: inherit; text-decoration: none; }
.way-card:hover { border-color: var(--accent); }
.way-card h3, .way-card p { margin: 0; }
.way-card p { color: var(--ink-2); }
.way-count { font-size: 2rem; font-weight: 800; color: var(--accent); line-height: 1; }
.way-count small { font-size: .95rem; font-weight: 700; color: var(--ink-2); }
.way-go { margin-top: auto; font-weight: 700; }
.cta-band { margin-top: 36px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; background: var(--surface); border: 2px solid var(--accent); border-radius: 16px; padding: 24px; }
.cta-band h2 { margin: 0 0 4px; }
.cta-band p { margin: 0; color: var(--ink-2); }

@media (max-width: 860px) {
  .site-layout { grid-template-columns: 1fr; gap: 12px; }
  .site-side { position: static; }
  .site-side nav { flex-direction: row; overflow-x: auto; gap: 6px; padding-bottom: 4px; }
  .side-link { white-space: nowrap; border: 1px solid var(--line); }
  .side-link[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--accent); }
  .side-mine, .side-note { display: none; }
  .home-hero { grid-template-columns: 1fr; }
}

/* ===== App shell: fixed left navigation rail ===== */
:root { --rail-w: 248px; }
.appnav { position: fixed; top: 0; bottom: 0; left: 0; width: var(--rail-w); z-index: 30; background: var(--brand); color: #eef3f0;
  display: flex; flex-direction: column; gap: 18px; overflow-y: auto; padding: calc(env(safe-area-inset-top, 0px) + 16px) 12px 16px max(12px, env(safe-area-inset-left, 0px)); }
.appnav .brand { padding: 4px 8px 10px; border-bottom: 1px solid rgba(255,255,255,.12); }
.appnav .mainnav { flex-direction: column; flex-wrap: nowrap; gap: 2px; }
.appnav .mainnav a { display: flex; align-items: center; gap: 10px; border-radius: 10px; padding: 9px 10px; color: inherit; opacity: .88; font-size: .95rem; }
.appnav .mainnav a:hover { background: rgba(255,255,255,.08); opacity: 1; }
.appnav .mainnav a[aria-current="page"] { background: #e4a53a; color: #1b1405; opacity: 1; }
.nav-ico { width: 20px; text-align: center; flex: none; opacity: .9; }
.nav-count { margin-left: auto; font-size: .75rem; font-weight: 700; background: rgba(255,255,255,.14); border-radius: 999px; padding: 0 8px; }
.nav-count:empty { display: none; }
.appnav .mainnav a[aria-current="page"] .nav-count { background: rgba(0,0,0,.15); }
.nav-label { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; opacity: .65; padding: 0 10px 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-foot { margin-top: auto; display: grid; gap: 10px; padding: 12px 6px 0; border-top: 1px solid rgba(255,255,255,.12); }
.nav-note { margin: 0; font-size: .8rem; opacity: .75; }
.appnav .menu summary { text-align: left; border-color: rgba(255,255,255,.25); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appnav .menu-pop { left: 0; right: auto; top: auto; bottom: calc(100% + 6px); }
.app-main { margin-left: var(--rail-w); min-height: 100vh; }
.app-main .topbar { display: flex; align-items: center; gap: 12px; padding: 8px max(16px, env(safe-area-inset-right, 0px)) 8px 16px; min-height: 44px; background: var(--bg); color: var(--ink); border-bottom: 1px solid var(--line); }
.app-main .topbar .account { margin-left: auto; }
.nav-toggle, .brand-mini { display: none; }
.nav-toggle { background: none; border: 1px solid var(--line); color: inherit; border-radius: 8px; font-size: 1.2rem; padding: 2px 10px; cursor: pointer; }
.brand-mini { text-decoration: none; color: inherit; font-family: var(--f-display); }
.nav-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 25; }
.rail { top: calc(env(safe-area-inset-top, 0px) + 64px); }
body::before { display: none; }

@media (max-width: 900px) {
  .appnav { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  body.rail-open .appnav { transform: none; }
  .app-main { margin-left: 0; }
  .app-main .topbar { position: sticky; top: 0; z-index: 20; background: var(--brand); color: #eef3f0; border-bottom: 0; }
  .nav-toggle { display: inline-block; border-color: rgba(255,255,255,.3); }
  .brand-mini { display: inline-block; }
}
@media (prefers-reduced-motion: reduce) { .appnav { transition: none; } }
.planned-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--ink-2); margin: 0 0 14px; cursor: pointer; }
.planned-toggle input { width: auto; }
.cert-link { display: block; }

/* ---------- certificates */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--f-mono); font-size: .9em; overflow-wrap: anywhere; }
.cert-panel { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: var(--r); padding: 16px 20px; margin: 0 0 18px; }
.cert-panel h3 { margin: 4px 0; }
.cert-panel .meter { margin: 10px 0 6px; max-width: 420px; }
.req-details summary { cursor: pointer; font-weight: 700; margin: 8px 0; }
.req-list { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 4px; }
.req-list li { display: grid; grid-template-columns: 22px 1fr; gap: 6px; font-size: .92rem; }
.req-mark { font-weight: 700; color: var(--ink-2); text-align: center; }
.req-list li.ok .req-mark { color: var(--good); }
.req-list li.warn .req-mark { color: var(--bad); }
.field.check { display: grid; grid-template-columns: 22px 1fr; gap: 8px; align-items: start; }
.field.check input { width: 18px; height: 18px; margin-top: 3px; }
.field.check label { font-weight: 400; }
.review-card { border-left: 4px solid var(--accent); }
.review-card textarea { margin: 8px 0; }
.verify-bar { border-radius: var(--r); padding: 12px 16px; margin-bottom: 16px; }
.verify-bar.good { background: var(--good-soft); color: var(--ink); border: 1px solid var(--good); }
.verify-bar.bad { background: var(--bad-soft); color: var(--ink); border: 1px solid var(--bad); }
.certificate { position: relative; overflow: hidden; background: #fffdf7; color: #1d2b2e; border-radius: 4px; padding: 18px; margin: 8px 0 20px;
  box-shadow: 0 8px 28px rgba(0,0,0,.14); text-align: center; font-family: var(--f-body); }
.cert-inner { border: 3px double #b86e12; outline: 1px solid #e3d3ad; outline-offset: -10px; padding: 34px 48px 18px; display: flex; flex-direction: column; justify-content: space-between; gap: 14px; height: 100%; box-sizing: border-box;
  background: radial-gradient(ellipse at center, rgba(184,110,18,.05), transparent 70%); }
@media (min-width: 900px) { .certificate { aspect-ratio: 11 / 8.5; } }
.cert-brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--f-display); font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-size: .82rem; color: #1d3a3f; }
.cert-logo { width: 26px; height: 26px; color: #b86e12; display: inline-flex; }
.cert-logo svg { width: 100%; height: 100%; }
.cert-kind { font-family: var(--f-display); font-size: clamp(1.8rem, 4.2vw, 2.9rem); font-weight: 800; color: #b86e12; letter-spacing: .01em; margin-top: 10px; }
.cert-small { font-size: .85rem; color: #4a5c5f; margin: 2px 0; }
.cert-name { font-family: var(--f-display); font-size: clamp(2rem, 5.4vw, 3.4rem); font-weight: 700; line-height: 1.15; border-bottom: 1.5px solid #c9b98f; display: inline-block; min-width: 55%; padding: 0 24px 8px; margin: 6px 0 8px; overflow-wrap: anywhere; }
.cert-course { font-family: var(--f-display); font-size: clamp(1.3rem, 3vw, 1.9rem); font-weight: 700; color: #1d3a3f; margin: 4px 0 2px; }
.cert-desc { font-size: .92rem; color: #4a5c5f; margin: 2px 0 0; }
.cert-outcomes { text-align: left; max-width: 760px; margin: 16px auto 0; }
.cert-label { font-family: var(--f-display); font-size: .74rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #8a5a17; text-align: center; margin-bottom: 6px; }
.cert-outcomes ul { margin: 0; padding-left: 18px; font-size: .88rem; columns: 2; column-gap: 34px; }
.cert-outcomes li { break-inside: avoid; margin-bottom: 3px; }
.cert-foot { display: grid; grid-template-columns: 1fr auto 1fr; align-items: end; gap: 28px; margin-top: 6px; }
.cert-sign { text-align: center; }
.cert-sigline { font-family: var(--f-display); font-size: 1.05rem; font-weight: 600; border-bottom: 1px solid #1d2b2e; padding: 0 8px 4px; margin: 0 12px 4px; }
.cert-seal svg { width: 104px; height: 104px; display: block; }
.cert-id { font-size: .76rem; color: #6b7a7c; margin-top: 4px; }
.cert-id .mono { font-size: .95em; color: #1d2b2e; }
.cert-void { position: absolute; inset: 0; display: grid; place-items: center; font: 800 6rem/1 var(--f-display); color: rgba(168,58,42,.22); transform: rotate(-18deg); pointer-events: none; }
.certificate.revoked { filter: grayscale(.6); }
@media (max-width: 700px) {
  .certificate { padding: 10px; }
  .cert-inner { padding: 26px 16px 14px; }
  .cert-outcomes ul { columns: 1; }
  .cert-foot { grid-template-columns: 1fr; justify-items: center; gap: 14px; }
  .cert-seal { order: -1; }
}
@media print {
  @page { size: letter portrait; margin: 0.6in; }
  @page cert { size: letter landscape; margin: 0.3in; }
  html, body { background: #fff !important; }
  .appnav, .app-main > header, .topbar, #nav-scrim, .verify-bar, .no-print, .toast { display: none !important; }
  .app-main { margin: 0 !important; padding: 0 !important; }
  .wrap.page, .verify-page { padding: 0 !important; margin: 0 !important; max-width: none !important; }
  .certificate { page: cert; width: 100%; height: 7.88in; aspect-ratio: auto; margin: 0; padding: 0.16in; box-shadow: none; border-radius: 0; break-inside: avoid; page-break-inside: avoid; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .cert-inner { padding: 0.36in 0.6in 0.14in; gap: 8px; }
  .cert-kind { font-size: 2.7rem; }
  .cert-name { font-size: 3rem; }
  .cert-course { font-size: 1.75rem; }
  .cert-outcomes ul { columns: 2; font-size: .85rem; }
  .cert-foot { grid-template-columns: 1fr auto 1fr; }
  .cert-seal { order: 0; }
}

/* ---------- course documentation packet */
.packet { max-width: 900px; }
.pk-head { border-bottom: 3px solid var(--accent); padding-bottom: 12px; margin: 10px 0 18px; }
.pk-head h1 { margin: 4px 0 0; }
.pk-sub { font-family: var(--f-display); font-size: 1.15rem; font-weight: 700; color: var(--ink-2); margin: 2px 0; }
.pk-for { font-weight: 700; margin: 6px 0 0; }
.pk-sec { margin: 0 0 22px; }
.pk-sec h2 { font-size: 1.2rem; border-bottom: 1px solid var(--line); padding-bottom: 4px; margin: 0 0 10px; }
.pk-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.pk-table th { text-align: left; vertical-align: top; width: 28%; padding: 6px 12px 6px 0; color: var(--ink-2); font-weight: 700; }
.pk-table td { padding: 6px 0; vertical-align: top; overflow-wrap: anywhere; }
.pk-table tr + tr th, .pk-table tr + tr td { border-top: 1px solid var(--line); }
.pk-table ul { margin: 0; padding-left: 18px; }
.pk-record { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--good); border-radius: var(--r); padding: 12px 16px; }
.pk-week { padding: 8px 0 10px; border-bottom: 1px solid var(--line); font-size: .93rem; }
.pk-week h3 { font-size: 1rem; margin: 0 0 4px; }
.pk-week > div { margin: 2px 0; }
.pk-q { font-style: italic; margin: 0 0 4px; color: var(--ink-2); }
@media (max-width: 640px) { .pk-table th { width: 38%; } }
@media print {
  .packet { max-width: none; color: #111; }
  .packet .pk-record { border-color: #999; background: #fff; }
  .packet .pk-week { break-inside: avoid; }
  .packet .pk-sec h2 { break-after: avoid; }
}
