/* Python Companion: a learning platform in the Codecademy mould.
   Navy top bar, white content, yellow primary actions, a split lesson (instructions | dark code environment).
   Progress is shown with plain bars on courses, lessons and the home page. */
:root {
  --font-head: "Figtree", "Atkinson Hyperlegible Next", ui-sans-serif, system-ui, sans-serif;
  --font-ui: "Atkinson Hyperlegible Next", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-code: "Atkinson Hyperlegible Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --navy: oklch(0.2 0.06 275);
  --navy-2: oklch(0.27 0.065 275);
  --navy-3: oklch(0.34 0.07 275);
  --yellow: oklch(0.88 0.17 95);
  --yellow-hover: oklch(0.83 0.17 92);
  --on-yellow: oklch(0.2 0.06 275);

  --bg: oklch(0.985 0.004 275);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.962 0.01 275);
  --border: oklch(0.9 0.012 275);
  --border-strong: oklch(0.72 0.03 275);
  --fg: oklch(0.2 0.06 275);
  --fg-2: oklch(0.44 0.04 275);
  --accent: oklch(0.45 0.22 285);
  --accent-fg: oklch(1 0 0);
  --accent-soft: oklch(0.94 0.04 285);
  --ok: oklch(0.45 0.13 152);
  --ok-soft: oklch(0.93 0.06 152);
  --bad: oklch(0.5 0.19 25);
  --bad-soft: oklch(0.95 0.035 25);
  --warn-soft: oklch(0.95 0.07 92);
  --warn: oklch(0.42 0.09 75);

  --code-bg: oklch(0.17 0.055 275);
  --code-gutter: oklch(0.21 0.058 275);
  --code-fg: oklch(0.95 0.01 275);
  --code-dim: oklch(0.66 0.04 275);

  --line-l: 0.5;
  --zone-a: oklch(0.99 0.003 275);
  --zone-b: oklch(0.962 0.01 275);
  --focus: oklch(0.5 0.22 285);
  --shadow: 0 1px 2px oklch(0.2 0.06 275 / 0.08), 0 6px 18px oklch(0.2 0.06 275 / 0.06);

  --r: 6px;
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --t-xs: 0.75rem; --t-sm: 0.8125rem; --t-base: 0.9375rem; --t-md: 1rem; --t-lg: 1.1875rem; --t-xl: 1.5rem; --t-2xl: 2rem; --t-3xl: 2.75rem;
  --top-h: 60px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: oklch(0.17 0.05 275); --surface: oklch(0.22 0.058 275); --surface-2: oklch(0.27 0.062 275);
    --border: oklch(0.33 0.065 275); --border-strong: oklch(0.5 0.06 275);
    --fg: oklch(0.96 0.008 275); --fg-2: oklch(0.78 0.035 275);
    --accent: oklch(0.76 0.14 285); --accent-fg: oklch(0.2 0.06 275); --accent-soft: oklch(0.32 0.09 285);
    --ok: oklch(0.78 0.15 152); --ok-soft: oklch(0.3 0.06 152);
    --bad: oklch(0.78 0.14 25); --bad-soft: oklch(0.31 0.07 25);
    --warn-soft: oklch(0.33 0.06 90); --warn: oklch(0.86 0.1 92);
    --line-l: 0.76; --zone-a: oklch(0.2 0.055 275); --zone-b: oklch(0.245 0.06 275); --focus: oklch(0.8 0.14 285);
    --shadow: 0 1px 2px oklch(0 0 0 / 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: oklch(0.17 0.05 275); --surface: oklch(0.22 0.058 275); --surface-2: oklch(0.27 0.062 275);
  --border: oklch(0.33 0.065 275); --border-strong: oklch(0.5 0.06 275);
  --fg: oklch(0.96 0.008 275); --fg-2: oklch(0.78 0.035 275);
  --accent: oklch(0.76 0.14 285); --accent-fg: oklch(0.2 0.06 275); --accent-soft: oklch(0.32 0.09 285);
  --ok: oklch(0.78 0.15 152); --ok-soft: oklch(0.3 0.06 152);
  --bad: oklch(0.78 0.14 25); --bad-soft: oklch(0.31 0.07 25);
  --warn-soft: oklch(0.33 0.06 90); --warn: oklch(0.86 0.1 92);
  --line-l: 0.76; --zone-a: oklch(0.2 0.055 275); --zone-b: oklch(0.245 0.06 275); --focus: oklch(0.8 0.14 285);
  --shadow: 0 1px 2px oklch(0 0 0 / 0.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { height: 100%; scroll-padding-top: calc(var(--top-h) + 16px); }
body {
  margin: 0; min-height: 100%;
  background: var(--bg); color: var(--fg);
  font: 400 var(--t-base)/1.55 var(--font-ui);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-soft); color: var(--fg); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
a { color: var(--accent); }
code, pre, kbd, samp { font-family: var(--font-code); }
h1, h2, h3 { font-family: var(--font-head); font-weight: 800; text-wrap: balance; line-height: 1.15; margin: 0; letter-spacing: -0.01em; }
p { margin: 0 0 var(--s3); }
button { font: inherit; color: inherit; }
table { border-collapse: collapse; }
.lc { --lc: oklch(var(--line-l) var(--c, 0.15) var(--h, 260)); }

/* ---------- top bar ---------- */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); background: var(--navy); z-index: 31; }
.topbar { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 30; background: var(--navy); color: oklch(0.97 0.01 275); }
.topbar-in {
  min-height: var(--top-h); display: flex; align-items: center; gap: var(--s5); flex-wrap: wrap;
  padding: 0 max(var(--s5), env(safe-area-inset-right, 0px)) 0 max(var(--s5), env(safe-area-inset-left, 0px));
}
.brand { display: flex; align-items: center; gap: var(--s3); text-decoration: none; color: inherit; padding: 8px 0; }
.brand b { font-family: var(--font-head); font-size: var(--t-lg); font-weight: 800; letter-spacing: -0.01em; }
.topnav { display: flex; gap: var(--s1); align-self: stretch; overflow-x: auto; }
.topnav a {
  display: flex; align-items: center; padding: 0 var(--s3); color: oklch(0.82 0.03 275); text-decoration: none; font-weight: 700;
  border-bottom: 4px solid transparent; border-top: 4px solid transparent; white-space: nowrap;
}
.topnav a:hover { color: white; }
.topnav a[aria-current="page"] { color: white; border-bottom-color: var(--yellow); }
.topnav a:focus-visible { outline-color: var(--yellow); outline-offset: -4px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: var(--s3); }
.pill { padding: 5px 12px; border-radius: 99px; background: var(--navy-2); font-size: var(--t-sm); font-variant-numeric: tabular-nums; color: oklch(0.85 0.03 275); }
.pill b { color: var(--yellow); font-size: var(--t-md); }
.py-status { display: inline-flex; align-items: center; gap: 8px; font-size: var(--t-xs); color: oklch(0.8 0.03 275); }
.py-status i { width: 8px; height: 8px; border-radius: 50%; background: oklch(0.82 0.15 90); }
.py-status[data-s="ready"] i { background: oklch(0.78 0.16 152); }
.py-status[data-s="error"] i { background: oklch(0.7 0.19 25); }

main { min-width: 0; padding-block: var(--s6) var(--s7); padding-left: max(var(--s5), env(safe-area-inset-left, 0px)); padding-right: max(var(--s5), env(safe-area-inset-right, 0px)); max-width: 1240px; margin: 0 auto; }
main.is-lesson { max-width: none; padding: 0; }
main:focus, h1[tabindex="-1"]:focus { outline: none; }
.boot { color: var(--fg-2); }

/* ---------- shared ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: 9px var(--s4); min-height: 42px; border-radius: var(--r); border: 2px solid var(--fg);
  background: transparent; color: var(--fg); font-family: var(--font-head); font-weight: 700; cursor: pointer; text-decoration: none;
  transition: background-color 0.15s, color 0.15s, transform 0.15s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary, .btn.yellow { background: var(--yellow); border-color: var(--yellow); color: var(--on-yellow); }
.btn.primary:hover, .btn.yellow:hover { background: var(--yellow-hover); border-color: var(--yellow-hover); }
.btn.small { min-height: 34px; padding: 4px var(--s3); font-size: var(--t-sm); }
.btn.big { min-height: 52px; padding: 12px var(--s5); font-size: var(--t-md); }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px;
  font-size: var(--t-xs); font-weight: 700; background: var(--surface-2); color: var(--fg-2); white-space: nowrap;
}
.chip.line { background: var(--surface); color: var(--fg); border: 1px solid var(--border); }
.chip.line i { width: 10px; height: 10px; border-radius: 50%; background: var(--lc); }
.chip.ok { background: var(--ok-soft); color: var(--ok); }
.chip.seen { background: var(--warn-soft); color: var(--warn); }
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.bar { display: block; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 4px; background: var(--lc, var(--yellow)); }
.page-head { display: flex; flex-wrap: wrap; gap: var(--s4) var(--s5); align-items: flex-end; justify-content: space-between; margin-bottom: var(--s5); }
.page-head h1 { font-size: var(--t-2xl); }
.page-head p { color: var(--fg-2); margin: var(--s2) 0 0; max-width: 62ch; }
.sec { font-size: var(--t-xl); margin: var(--s6) 0 var(--s4); }
.crumbs { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; font-size: var(--t-sm); color: var(--fg-2); margin-bottom: var(--s3); }
.crumbs a { color: var(--fg-2); }

/* ---------- home ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: var(--s6); align-items: center;
  background: var(--navy); color: oklch(0.97 0.01 275); border-radius: 12px; padding: var(--s6) var(--s6);
}
.hero h1 { font-size: var(--t-3xl); margin-bottom: var(--s3); color: white; }
.hero p { color: oklch(0.84 0.03 275); font-size: var(--t-lg); max-width: 46ch; margin-bottom: var(--s5); }
.hero .chip.ok { background: var(--ok-soft); }
.hero-stats { background: var(--navy-2); border-radius: 10px; padding: var(--s5); }
.stat { display: flex; align-items: baseline; gap: var(--s3); margin-bottom: var(--s3); }
.stat b { font-family: var(--font-head); font-size: var(--t-3xl); line-height: 1; color: var(--yellow); font-variant-numeric: tabular-nums; }
.stat span { color: oklch(0.84 0.03 275); }
.hero .bar { background: var(--navy-3); }
.hero .bar i { background: var(--yellow); }
.bar.big { height: 12px; border-radius: 6px; }
.hero dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s3); margin: var(--s4) 0 0; }
.hero dt { font-size: var(--t-xs); color: oklch(0.78 0.04 275); }
.hero dd { margin: 0; font-family: var(--font-head); font-size: var(--t-xl); font-weight: 800; font-variant-numeric: tabular-nums; }
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--s4); }
.course {
  display: flex; flex-direction: column; gap: var(--s3); padding: var(--s4) var(--s5) var(--s5); text-decoration: none; color: var(--fg);
  background: var(--surface); border: 2px solid var(--border); border-radius: 10px; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.course:hover { border-color: var(--lc); box-shadow: var(--shadow); transform: translateY(-2px); }
.course-top { background: var(--surface-2); border-radius: 8px; padding: 10px 14px; }
.course h3 { font-size: var(--t-lg); }
.course p { color: var(--fg-2); margin: 0; flex: 1; }
.course-foot { display: grid; grid-template-columns: 1fr auto; gap: var(--s2) var(--s3); align-items: center; font-size: var(--t-sm); color: var(--fg-2); }
.course-foot .bar { grid-column: 1 / -1; }
.course-foot b { color: var(--fg); }
.course-foot .go { font-family: var(--font-head); font-weight: 800; color: var(--accent); }
.mini { display: block; max-width: 100%; }

.course-head { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: var(--s6); align-items: center; background: var(--surface); border: 2px solid var(--border); border-radius: 12px; padding: var(--s5) var(--s6); }
.course-head .mini { max-width: 320px; margin-bottom: var(--s4); }
.course-head h1 { font-size: var(--t-2xl); margin-bottom: var(--s2); }
.course-head p { color: var(--fg-2); margin: 0; }
.course-side p { margin: var(--s2) 0 var(--s4); color: var(--fg-2); }
.syllabus { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.syllabus a { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: var(--s4); align-items: center; padding: var(--s3) var(--s4); text-decoration: none; color: var(--fg); background: var(--surface); border: 2px solid var(--border); border-radius: 10px; transition: border-color 0.15s; }
.syllabus a:hover { border-color: var(--lc); }
.num { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; border: 3px solid var(--lc); font-family: var(--font-head); font-weight: 800; color: var(--fg); }
.num.seen { background: color-mix(in oklch, var(--lc) 30%, var(--surface)); }
.num.done { background: var(--lc); color: var(--surface); }
.syl-body b { font-family: var(--font-head); font-size: var(--t-md); display: block; }
.syl-body small { color: var(--fg-2); font-size: var(--t-sm); }
.syl-meta { display: flex; gap: var(--s2); flex-wrap: wrap; justify-content: flex-end; }

/* ---------- spec table ---------- */
.filters { display: flex; flex-wrap: wrap; gap: var(--s3); margin-bottom: var(--s4); align-items: end; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: var(--t-xs); font-weight: 700; color: var(--fg-2); }
.filters select, .filters input {
  min-height: 40px; padding: 6px var(--s3); border-radius: var(--r); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--fg); font: inherit; font-weight: 400;
}
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.spec-table { width: 100%; min-width: 720px; font-size: var(--t-base); }
.spec-table th { text-align: left; font-size: var(--t-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-2); background: var(--surface-2); padding: 0; border-bottom: 1px solid var(--border); }
.spec-table th button { all: unset; box-sizing: border-box; width: 100%; padding: 10px var(--s4); cursor: pointer; font-weight: 700; }
.spec-table th button:hover { color: var(--fg); }
.spec-table th button:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.spec-table td { padding: 10px var(--s4); border-top: 1px solid var(--border); vertical-align: middle; }
.spec-table tbody tr:first-child td { border-top: 0; }
.spec-table tbody tr:hover { background: var(--surface-2); }
.spec-table td a { font-weight: 600; text-decoration: none; }
.spec-table td a:hover { text-decoration: underline; }
.spec-table td:nth-child(4) { white-space: nowrap; }
.spec-table .ref { font-family: var(--font-code); font-size: var(--t-sm); white-space: nowrap; }
.empty { padding: var(--s6); text-align: center; color: var(--fg-2); }

/* ---------- lesson: instructions left, code environment right ---------- */
.lesson-bar {
  display: flex; align-items: center; gap: var(--s5); padding: 0 max(var(--s5), env(safe-area-inset-right, 0px)) 0 max(var(--s5), env(safe-area-inset-left, 0px));
  min-height: 52px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: calc(var(--top-h) + env(safe-area-inset-top, 0px)); z-index: 20;
}
.lesson-bar .back { color: var(--fg); font-weight: 700; text-decoration: none; white-space: nowrap; }
.lesson-bar .back:hover { text-decoration: underline; }
.lb-title { font-family: var(--font-head); font-weight: 800; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-prog { display: flex; align-items: center; gap: var(--s3); font-size: var(--t-sm); color: var(--fg-2); white-space: nowrap; }
.lb-prog .bar { width: 120px; }
.lesson { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); height: calc(100vh - var(--top-h) - 52px - env(safe-area-inset-top, 0px)); }
.reading { min-width: 0; overflow: auto; padding: var(--s6) var(--s6) var(--s7); background: var(--bg); }
.reading > * { max-width: 68ch; }
.lesson-head h1 { font-size: var(--t-2xl); margin-bottom: var(--s3); }
.outcome { border: 2px solid var(--border); background: var(--surface); border-radius: 10px; padding: var(--s3) var(--s4); margin-bottom: var(--s5); }
.outcome b { display: block; font-family: var(--font-head); font-size: var(--t-sm); margin-bottom: 2px; color: var(--accent); }
.prose { font-size: var(--t-md); line-height: 1.7; }
.prose ul, .prose ol { padding-left: 1.25em; margin: 0 0 var(--s3); }
.prose li { margin-bottom: var(--s1); }
.prose code, .note code, .outcome code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-size: 0.9em; }
.prose pre { background: var(--code-bg); color: var(--code-fg); padding: var(--s3) var(--s4); border-radius: var(--r); overflow-x: auto; font-size: var(--t-sm); }
.prose pre code { background: none; padding: 0; }
.prose table { width: 100%; margin: var(--s3) 0; font-size: var(--t-sm); display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.prose th { background: var(--surface-2); }
.note { border-radius: 10px; padding: var(--s3) var(--s4); margin: var(--s4) 0; background: var(--surface); border: 2px solid var(--border); }
.note h3 { font-size: var(--t-sm); margin-bottom: 4px; }
.note.watch { background: var(--warn-soft); border-color: transparent; }
.note.watch h3 { color: var(--warn); }
.note.top { background: var(--accent-soft); border-color: transparent; }
.note.top h3 { color: var(--accent); }
.note p:last-child { margin-bottom: 0; }
details.reveal { border: 2px solid var(--border); border-radius: 10px; background: var(--surface); margin: var(--s3) 0; }
details.reveal > summary { cursor: pointer; padding: var(--s3) var(--s4); font-family: var(--font-head); font-weight: 800; }
details.reveal > div { padding: 0 var(--s4) var(--s3); }
details.reveal pre { margin: var(--s2) 0 0; background: var(--code-bg); color: var(--code-fg); padding: var(--s3); border-radius: var(--r); overflow-x: auto; font-size: var(--t-sm); }
.pager { display: flex; flex-wrap: wrap; gap: var(--s3); justify-content: space-between; margin-top: var(--s6); padding-top: var(--s4); border-top: 1px solid var(--border); }

/* the code environment is always dark, like an IDE */
.bench {
  --surface: oklch(0.22 0.065 275); --surface-2: oklch(0.28 0.07 275); --border: oklch(0.36 0.07 275); --border-strong: oklch(0.55 0.06 275);
  --fg: oklch(0.96 0.008 275); --fg-2: oklch(0.8 0.035 275); --accent: oklch(0.8 0.13 285);
  --ok: oklch(0.8 0.16 152); --ok-soft: oklch(0.3 0.07 152); --bad: oklch(0.8 0.14 25); --bad-soft: oklch(0.32 0.08 25);
  --warn-soft: oklch(0.34 0.07 90); --warn: oklch(0.88 0.1 92); --focus: oklch(0.88 0.15 95);
  background: var(--navy); color: var(--fg); min-width: 0; display: flex; flex-direction: column; min-height: 0;
}
.tabs { display: flex; background: var(--code-bg); border-bottom: 1px solid var(--border); flex: none; }
.tabs button {
  padding: 13px var(--s5); border: 0; background: none; cursor: pointer; font-family: var(--font-head); font-weight: 700; color: var(--fg-2);
  border-bottom: 4px solid transparent; margin-bottom: -1px;
}
.tabs button:hover { color: white; }
.tabs button[aria-selected="true"] { color: white; background: var(--navy); border-bottom-color: var(--yellow); }
.tabs button:focus-visible { outline-offset: -3px; }
.panel { padding: var(--s4) var(--s5) var(--s5); overflow: auto; display: flex; flex-direction: column; gap: var(--s3); min-height: 0; flex: 1; }
.panel[hidden] { display: none; }
.task-prompt { font-size: var(--t-base); line-height: 1.6; }
.task-prompt code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-size: 0.9em; }
.task-prompt pre { background: var(--code-bg); color: var(--code-fg); padding: var(--s3); border-radius: var(--r); font-size: var(--t-sm); overflow-x: auto; margin: var(--s2) 0 0; }
.editor { display: grid; grid-template-columns: auto minmax(0, 1fr); background: var(--code-bg); border-radius: var(--r); overflow: hidden; border: 1px solid var(--border); flex: 1 1 240px; min-height: 200px; }
.editor:focus-within { outline: 3px solid var(--focus); outline-offset: 1px; }
.gutter { background: var(--code-gutter); color: var(--code-dim); text-align: right; padding: 12px 10px 12px 12px; overflow: hidden; font: 400 14px/22px var(--font-code); user-select: none; white-space: pre; font-variant-numeric: tabular-nums; }
.gutter .bad { color: oklch(0.8 0.15 25); font-weight: 700; }
.code {
  background: transparent; color: var(--code-fg); border: 0; resize: none; padding: 12px; margin: 0; min-width: 0; height: 100%;
  font: 400 14px/22px var(--font-code); tab-size: 4; white-space: pre; overflow: auto; outline: none; caret-color: var(--yellow);
}
.code::selection { background: oklch(0.45 0.14 285); color: white; }
.hint { font-size: var(--t-xs); color: var(--fg-2); margin: 0; }
.hint kbd { background: var(--surface-2); border-radius: 4px; padding: 0 5px; font-size: 0.95em; }
.toolbar { display: flex; flex-wrap: wrap; gap: var(--s2); align-items: center; }
.toolbar .spacer { flex: 1; }
.bench .btn { border-color: oklch(0.96 0.008 275); color: oklch(0.96 0.008 275); }
.bench .btn:hover { background: var(--surface-2); }
.bench .btn.primary, .bench .btn.yellow { background: var(--yellow); border-color: var(--yellow); color: var(--on-yellow); }
.bench .btn.primary:hover, .bench .btn.yellow:hover { background: var(--yellow-hover); }
.bench .btn.small { border-color: var(--border-strong); color: var(--fg-2); }
.inputs-box label { display: block; font-size: var(--t-xs); font-weight: 700; color: var(--fg-2); margin-bottom: 4px; }
.inputs-box textarea { width: 100%; min-height: 52px; resize: vertical; padding: 8px var(--s3); border-radius: var(--r); border: 1px solid var(--border); background: var(--code-bg); color: var(--code-fg); font: 400 14px/1.5 var(--font-code); }
.out-wrap h3, .checks-wrap h3 { font-size: var(--t-sm); color: var(--fg-2); margin-bottom: 4px; font-family: var(--font-head); }
.out { margin: 0; padding: var(--s3); min-height: 56px; max-height: 190px; overflow: auto; white-space: pre-wrap; word-break: break-word; background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--r); font-size: 14px; line-height: 1.5; color: var(--code-fg); }
.out.empty { color: var(--fg-2); font-family: var(--font-ui); }
.err { margin-top: var(--s2); padding: var(--s3); border-radius: var(--r); background: var(--bad-soft); color: var(--bad); font-weight: 600; font-size: var(--t-sm); }
.banner { padding: var(--s3) var(--s4); border-radius: var(--r); font-family: var(--font-head); font-weight: 800; display: flex; gap: var(--s3); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.banner.ok { background: var(--ok-soft); color: var(--ok); }
.banner.partial { background: var(--warn-soft); color: var(--warn); }
.checks { list-style: none; margin: var(--s2) 0 0; padding: 0; display: grid; gap: 4px; }
.checks li { display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: var(--s2); font-size: var(--t-sm); align-items: start; }
.checks svg { margin-top: 2px; }
.checks .pass svg { color: var(--ok); }
.checks .fail svg { color: var(--bad); }
.checks .note-line { color: var(--fg-2); font-family: var(--font-code); font-size: var(--t-xs); display: block; overflow-wrap: anywhere; }

/* guide */
.guide { max-width: 72ch; }
.guide h2 { font-size: var(--t-lg); margin: var(--s5) 0 var(--s2); }
.guide li { margin-bottom: var(--s1); }
.guide kbd { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 6px; }
.callout { border: 1px solid var(--border); background: var(--surface); border-radius: var(--r); padding: var(--s3) var(--s4); }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--s5) + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 16px);
  background: var(--rail); color: var(--rail-fg); padding: 10px var(--s4); border-radius: var(--r); font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 20; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .hero { grid-template-columns: minmax(0, 1fr); padding: var(--s5); }
  .hero h1 { font-size: var(--t-2xl); }
  .course-head { grid-template-columns: minmax(0, 1fr); padding: var(--s5); }
  .lesson { display: flex; flex-direction: column; height: auto; }
  .reading { overflow: visible; padding: var(--s5) max(var(--s4), env(safe-area-inset-left, 0px)) var(--s6); }
  .bench { min-height: 0; }
  .panel { overflow: visible; }
  .editor { flex: none; height: 260px; }
  .lesson-bar { position: static; gap: var(--s3); padding-left: max(var(--s4), env(safe-area-inset-left, 0px)); padding-right: max(var(--s4), env(safe-area-inset-right, 0px)); flex-wrap: wrap; padding-block: var(--s2); }
  .lb-title { flex-basis: 100%; order: 3; white-space: normal; }
  .lb-prog .bar { width: 70px; }
}
@media (max-width: 760px) {
  .topbar-in { gap: var(--s2) var(--s3); padding-left: max(var(--s4), env(safe-area-inset-left, 0px)); padding-right: max(var(--s4), env(safe-area-inset-right, 0px)); }
  .topnav { order: 3; flex-basis: 100%; margin: 0 calc(-1 * var(--s4)); padding: 0 var(--s4); min-height: 44px; }
  .py-status span { display: none; }
  main { padding-left: max(var(--s4), env(safe-area-inset-left, 0px)); padding-right: max(var(--s4), env(safe-area-inset-right, 0px)); padding-top: var(--s5); }
  .page-head h1, .lesson-head h1, .course-head h1 { font-size: var(--t-xl); }
  .syllabus a { grid-template-columns: 36px minmax(0, 1fr); }
  .syl-meta { grid-column: 2; justify-content: flex-start; }
  .map-scroll { display: none; }
  .map-list { display: block; }
  .map-block > p.zoom-note { display: none; }
  .tabs button { flex: 1; }
  .panel { padding-left: max(var(--s4), env(safe-area-inset-left, 0px)); padding-right: max(var(--s4), env(safe-area-inset-right, 0px)); }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
.lesson-head .chips { margin-bottom: var(--s4); }
.reading .lesson-head { margin-bottom: 0; }

/* ---------- course cards ---------- */
.course h3 { display: flex; align-items: center; gap: var(--s2); }
.course h3 .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--lc); flex: none; border: 0; }
.course-foot .bar { height: 10px; }

/* ---------- code symbol bar (touch) ---------- */
.symbols { display: none; gap: 6px; overflow-x: auto; padding-bottom: 2px; }
.symbols button { flex: none; min-width: 44px; min-height: 44px; border-radius: var(--r); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--fg); font: 600 16px var(--font-code); cursor: pointer; }
.symbols button:active { background: var(--navy-3); }
.m-tabs { display: none; }
.nav-ico { display: none; }
.topnav svg { display: none; }

/* ---------- mobile ---------- */
@media (pointer: coarse), (max-width: 1000px) {
  .symbols { display: flex; }
  .code, .gutter { font-size: 16px; line-height: 24px; }
  .inputs-box textarea, .filters select, .filters input { font-size: 16px; }
  .btn { min-height: 46px; }
  .btn.small { min-height: 40px; }
}
@media (max-width: 1000px) {
  .m-tabs { display: grid; grid-template-columns: repeat(3, 1fr); position: sticky; top: calc(var(--top-h) + env(safe-area-inset-top, 0px)); z-index: 19; background: var(--surface); border-bottom: 1px solid var(--border); }
  .m-tabs button { min-height: 48px; border: 0; background: none; font-family: var(--font-head); font-weight: 800; color: var(--fg-2); border-bottom: 4px solid transparent; cursor: pointer; }
  .m-tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--yellow); }
  .lesson[data-pane="learn"] .bench { display: none; }
  .lesson[data-pane="ex"] .reading, .lesson[data-pane="task"] .reading { display: none; }
  .bench .tabs { display: none; }
  .lesson { min-height: calc(100vh - var(--top-h) - 100px); }
  .bench { flex: 1; }
  .panel { padding-bottom: var(--s4); }
  .editor { height: 300px; }
  .toolbar { position: sticky; bottom: 0; background: var(--navy); padding: var(--s3) 0; margin: 0; z-index: 5; box-shadow: 0 -8px 12px -8px oklch(0.1 0.04 275 / 0.7); }
  .toolbar .spacer { display: none; }
  .toolbar .btn.small { margin-left: auto; }
  .hint { display: none; }
}
@media (max-width: 760px) {
  html { scroll-padding-top: 16px; }
  body:not(.in-lesson) { padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px)); }
  .topbar-in { min-height: 56px; flex-wrap: nowrap; }
  .topnav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; order: 0; flex-basis: auto; margin: 0; padding: 0 0 env(safe-area-inset-bottom, 0px);
    background: var(--navy); border-top: 1px solid var(--navy-3); min-height: 0; display: grid; grid-template-columns: repeat(3, 1fr); overflow: visible; align-self: auto;
  }
  body.in-lesson .topnav { display: none; }
  .topnav a { flex-direction: column; justify-content: center; gap: 2px; min-height: 58px; padding: 6px 4px; font-size: var(--t-xs); border: 0; border-top: 3px solid transparent; }
  .topnav a[aria-current="page"] { border-top-color: var(--yellow); }
  .topnav svg { display: block; }
  .py-status span { display: none; }
  .toast { bottom: calc(76px + env(safe-area-inset-bottom, 0px)); }
  body.in-lesson .toast { bottom: calc(88px + env(safe-area-inset-bottom, 0px)); }
  .hero { padding: var(--s5) var(--s4); border-radius: 10px; }
  .hero .btn.big { width: 100%; }
  .hero p { font-size: var(--t-md); }
  .course-grid { grid-template-columns: minmax(0, 1fr); gap: var(--s3); }
  .page-head { margin-bottom: var(--s4); }
  .filters { display: grid; grid-template-columns: 1fr 1fr; }
  .filters label:first-child { grid-column: 1 / -1; }
  .filters select, .filters input { width: 100%; }
  .table-wrap { border: 0; background: none; overflow: visible; }
  .spec-table { min-width: 0; }
  .spec-table thead { display: none; }
  .spec-table, .spec-table tbody { display: block; }
  .spec-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); padding: var(--s3) var(--s4); margin-bottom: var(--s2); background: var(--surface); border: 2px solid var(--border); border-radius: 10px; }
  .spec-table td { padding: 0; border: 0; }
  .spec-table td:nth-child(2) { flex-basis: 100%; order: -1; }
  .lesson-bar { padding-top: max(var(--s2), 0px); }
  .lb-title { display: none; }
  .reading { padding-top: var(--s4); }
  .reading > * { max-width: none; }
  .prose { font-size: 1.0625rem; }
  .pager .btn { flex: 1; }
  .guide { max-width: none; }
}

/* ---------- teaching supports ---------- */
.editor { position: relative; }
.hl-layer { position: absolute; right: 0; background: oklch(0.88 0.17 95 / 0.18); border-top: 1px solid oklch(0.88 0.17 95 / 0.5); border-bottom: 1px solid oklch(0.88 0.17 95 / 0.5); pointer-events: none; z-index: 1; }
.steps h3 { font-size: var(--t-sm); color: var(--fg-2); margin-bottom: var(--s2); }
.steps ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.steps button { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: var(--s3); align-items: start; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 8px var(--s3); cursor: pointer; font-size: var(--t-sm); line-height: 1.45; min-height: 40px; }
.steps button:hover { border-color: var(--border-strong); }
.steps button[aria-pressed="true"] { border-color: var(--yellow); background: oklch(0.88 0.17 95 / 0.14); }
.steps .ln { font-family: var(--font-code); font-size: var(--t-xs); color: var(--yellow); font-weight: 600; padding-top: 2px; }
.hints { display: grid; gap: var(--s2); justify-items: start; }
.hint-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: var(--s3); font-size: var(--t-sm); width: 100%; margin-top: var(--s2); }
.hint-card b { font-family: var(--font-head); color: var(--yellow); }
.hint-card p { margin: 4px 0 0; }
.hint-card pre { margin: 6px 0 0; padding: var(--s3); background: var(--code-bg); border-radius: var(--r); overflow-x: auto; font-size: var(--t-sm); color: var(--code-fg); }
.hint-card.answer { border-color: var(--yellow); }
.symptom { background: var(--warn-soft); color: var(--warn); border-radius: var(--r); padding: var(--s2) var(--s3); }
details.mini-d { margin-top: var(--s2); font-size: var(--t-sm); }
details.mini-d summary { cursor: pointer; font-weight: 700; color: var(--fg-2); min-height: 32px; }
@media (max-width: 1000px) {
  .m-tabs { grid-template-columns: repeat(4, 1fr); }
  .lesson[data-pane="bug"] .reading { display: none; }
  .steps button { min-height: 44px; }
}
