/* gobyphp app styles. Tokens and rules are documented in DESIGN.md. */
@import url("https://fonts.googleapis.com/css2?family=Overpass:ital,wght@0,400;0,600;0,800;0,900;1,400&family=Overpass+Mono:wght@400;600&display=swap");

:root {
  --ink: #16193A;          /* diagram navy: text, casings, enamel */
  --ink-2: #474B66;        /* secondary text, 8.4:1 on white */
  --ink-3: #5F6380;        /* tertiary, 5.9:1 on white */
  --paper: #FFFFFF;
  --paper-2: #F3F4F8;      /* panel ground */
  --paper-3: #E8EAF1;
  --rule: #D3D6E2;
  --php: #777BB4;          /* PHP platform */
  --php-ink: #4F5394;      /* PHP text-safe, 7.0:1 */
  --go: #00ADD8;           /* Go platform */
  --go-ink: #00728F;       /* Go text-safe, 5.5:1 */
  --pass: #00703A;
  --fail: #B42318;
  --gap: #FFD329;          /* mind-the-gap yellow, never text */
  --gap-ground: #FFF8D9;
  --focus: #0019A8;

  --font: "Overpass", "Segoe UI", system-ui, sans-serif;
  --mono: "Overpass Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --r: 4px;                /* enamel-plate corners: small, never pill except station capsules */
  --line-w: 8px;
  --ease: cubic-bezier(.16, 1, .3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.6 var(--font);
  font-feature-settings: "tnum" 0;
}
::selection { background: var(--go-ink); color: #fff; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
a { color: var(--ink); text-decoration-thickness: 2px; text-underline-offset: 3px; text-decoration-color: var(--go); }
a:hover { text-decoration-color: var(--ink); }
img, svg { display: block; max-width: 100%; }
code, kbd, pre { font-family: var(--mono); font-size: .92em; }
:not(pre) > code { background: var(--paper-2); border: 1px solid var(--rule); border-radius: 3px; padding: .05em .35em; }
h1, h2, h3 { line-height: 1.08; letter-spacing: -0.02em; text-wrap: balance; margin: 0; }
p { text-wrap: pretty; }
html { scrollbar-color: var(--ink-3) var(--paper-2); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 16px; top: -60px; background: var(--ink); color: #fff; padding: 10px 14px; z-index: 50; border-radius: var(--r); }
.skip:focus { top: 12px; }

/* ---------- Wordmark ---------- */
.wordmark { display: inline-flex; align-items: center; gap: 10px; font-weight: 900; font-size: 1.3rem; letter-spacing: -0.03em; text-decoration: none; color: var(--ink); }
.wordmark svg { width: 46px; height: 22px; }
.wordmark b { font-weight: 900; }
.wordmark .wm-go { color: var(--go-ink); }
.wordmark .wm-php { color: var(--php-ink); }

/* ---------- Buttons: enamel plates ---------- */
.btn {
  --bg: var(--ink); --fg: #fff;
  display: inline-flex; align-items: center; gap: .55em;
  min-height: 46px; padding: .65em 1.15em .55em;
  background: var(--bg); color: var(--fg);
  border: 2px solid var(--bg); border-radius: var(--r);
  font: 800 1rem/1 var(--font); letter-spacing: 0; text-decoration: none; cursor: pointer;
  transition: transform .2s var(--ease), box-shadow .2s var(--ease), background .2s;
  box-shadow: 0 1px 0 rgba(22,25,58,.25), 0 6px 14px -8px rgba(22,25,58,.55);
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 2px 0 rgba(22,25,58,.25), 0 10px 18px -8px rgba(22,25,58,.5); }
.btn:active { transform: translateY(0); }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn-quiet { --bg: transparent; --fg: var(--ink); border-color: var(--ink); box-shadow: none; }
.btn-quiet:hover { background: var(--paper-2); box-shadow: none; }
.btn-go { --bg: var(--go-ink); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-sm { min-height: 36px; padding: .45em .8em .35em; font-size: .9rem; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: rgba(255,255,255,.94); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--rule); }
.topbar-in { max-width: 1240px; margin: 0 auto; padding: 12px 24px; display: flex; align-items: center; gap: 24px; }
.topbar nav { display: flex; gap: 22px; margin-left: auto; align-items: center; }
.topbar nav a:not(.btn) { text-decoration: none; font-weight: 600; color: var(--ink-2); }
.topbar nav a:not(.btn):hover { color: var(--ink); }
@media (max-width: 720px) {
  .topbar-in { padding: 10px 16px; gap: 12px; }
  .topbar nav { gap: 14px; }
  .topbar nav .hide-sm { display: none; }
}

/* ---------- Station markers (shared) ---------- */
.tick { stroke-linecap: butt; }
.ichg { fill: #fff; stroke: var(--ink); stroke-width: 3.5; }

/* ---------- Mind the gap / asides ---------- */
.gap {
  margin: 1.6em 0; padding: 1rem 1.15rem 1.05rem;
  background: var(--gap-ground); border: 1px solid #E7C200; border-radius: var(--r);
  position: relative; overflow: hidden;
}
.gap::before { /* platform edge */
  content: ""; position: absolute; inset: 0 0 auto 0; height: 6px;
  background: var(--gap); border-bottom: 1px solid #E7C200;
}
.gap h4, .aside h4 { margin: .35rem 0 .3rem; font-size: .95rem; font-weight: 900; letter-spacing: .01em; display: flex; align-items: center; gap: .45em; }
.gap p, .aside p { margin: .35em 0 0; }
.aside { margin: 1.6em 0; padding: .95rem 1.15rem; border: 1px solid var(--rule); border-radius: var(--r); background: var(--paper-2); }
.aside h4 svg, .gap h4 svg { width: 20px; height: 20px; }

/* ---------- Code panes ---------- */
.platform { border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; background: #FAFAFC; display: flex; flex-direction: column; min-width: 0; }
.platform-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px 6px; background: #fff; border-bottom: 1px solid var(--rule); font-size: .85rem; }
.platform-head .plate { display: inline-flex; align-items: center; gap: 6px; font-weight: 900; color: #fff; padding: 3px 8px 1px; border-radius: 3px; font-size: .78rem; letter-spacing: .04em; }
.platform.php .plate { background: var(--php-ink); }
.platform.go .plate { background: var(--go-ink); }
.platform-head .file { font-family: var(--mono); color: var(--ink-2); }
.platform pre { margin: 0; padding: 14px 16px 16px; overflow: auto; font-size: .86rem; line-height: 1.65; tab-size: 4; flex: 1; }

/* ---------- Generic layout ---------- */
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
@media (max-width: 720px) { .wrap { padding: 0 16px; } }

/* ---------- Footer ---------- */
.foot { margin-top: 96px; border-top: 1px solid var(--rule); background: var(--paper-2); }
.foot-in { max-width: 1240px; margin: 0 auto; padding: 40px 24px 48px; display: flex; flex-wrap: wrap; gap: 24px 48px; align-items: flex-start; justify-content: space-between; color: var(--ink-2); font-size: .95rem; }
.foot-in nav { display: flex; gap: 20px; flex-wrap: wrap; }
.foot-in a { color: var(--ink-2); }
.proto-note { font-size: .82rem; color: var(--ink-3); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
/* Departure-board chips: small mono tags for meta lines, in place of separators. */
.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip { display: inline-block; padding: .4em .65em .3em; border: 1px solid color-mix(in srgb, currentColor 30%, transparent); border-radius: 4px; font: 600 .74rem/1.2 var(--mono); letter-spacing: .06em; text-transform: uppercase; font-variant-numeric: tabular-nums; max-width: 100%; white-space: nowrap; }
.chip svg { display: inline-block; width: 1.15em; height: 1.15em; vertical-align: -.25em; margin-right: .4em; }
.chip-long { white-space: normal; }
.chip code { background: none; border: 0; padding: 0; font: inherit; letter-spacing: 0; text-transform: none; }

/* ======== Shared app chrome ======== */
.app-course { font-weight: 800; color: var(--ink-2); font-size: .95rem; padding-left: 18px; border-left: 1px solid var(--rule); }
@media (max-width: 720px) { .app-course { display: none; } }

/* ---------- Signed-in chrome: ticket stub + account roundel ---------- */
/* The stub is a mini fare ticket: 2px navy edge, a dashed perforation and two punched notches. */
.stub {
  display: inline-flex; align-items: stretch; height: 36px; flex: none;
  border: 2px solid var(--ink); border-radius: 6px; overflow: hidden;
  background: var(--paper); color: var(--ink); text-decoration: none;
  font-weight: 800; font-size: .9rem; line-height: 1; white-space: nowrap;
}
.stub > span { display: inline-flex; align-items: center; gap: 7px; padding: 2px 11px 0; }
.stub svg { width: 18px; height: 18px; flex: none; margin-top: -2px; }
.stub-fare { color: var(--ink-2); }
.stub > .stub-act { gap: 0; position: relative; border-left: 2px dashed var(--ink); transition: background .2s var(--ease), color .2s var(--ease); }
.stub-act::before, .stub-act::after {
  content: ""; position: absolute; left: -7px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--paper); border: 2px solid var(--ink);
}
.stub-act::before { top: -8px; }
.stub-act::after { bottom: -8px; }
.stub-price { font-feature-settings: "tnum" 1; margin-left: .6em; padding-left: .6em; border-left: 1px solid color-mix(in srgb, currentColor 35%, transparent); }
.stub:hover .stub-act { background: var(--ink); color: #fff; }
.stub-paid { background: var(--ink); transition: background .2s var(--ease); }
.stub-paid .stub-fare { color: #fff; }
.stub-paid:hover { background: var(--ink-2); border-color: var(--ink-2); }

/* Initials sit on a PHP Ink roundel; open, it gains the "you are here" ring. */
.avatar {
  display: inline-grid; place-items: center; width: 36px; height: 36px; flex: none;
  padding: 2px 0 0; border: 0; border-radius: 50%;
  background: var(--php-ink); color: #fff;
  font: 800 .85rem/1 var(--font); letter-spacing: .02em; cursor: pointer;
  transition: background .2s var(--ease), box-shadow .2s var(--ease);
}
button.avatar:hover { background: var(--ink); }
button.avatar:has(+ .acct-menu:popover-open) { background: var(--ink); box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }
.topbar .avatar { margin-left: -6px; }

/* Account menu: an outlined panel, not a floating card (only plates cast shadows). */
.acct-menu {
  position: fixed; inset: auto; margin: 0;
  top: 62px; right: max(16px, calc((100vw - 1240px) / 2 + 24px));
  width: min(300px, calc(100vw - 32px)); padding: 0;
  background: var(--paper); color: var(--ink);
  border: 2px solid var(--ink); border-radius: 6px;
  opacity: 1; translate: 0 0;
  transition: opacity .18s var(--ease), translate .18s var(--ease), overlay .18s allow-discrete, display .18s allow-discrete;
}
.acct-menu:not(:popover-open) { opacity: 0; translate: 0 -4px; }
@starting-style { .acct-menu:popover-open { opacity: 0; translate: 0 -4px; } }
.acct-menu::backdrop { background: transparent; }
@supports (position-anchor: --a) {
  .topbar button.avatar { anchor-name: --acct; }
  .acct-menu { position-anchor: --acct; top: anchor(bottom); right: anchor(right); margin-top: 10px; }
}
.acct-who { display: flex; align-items: center; gap: 12px; padding: 14px 16px 12px; border-bottom: 1px solid var(--rule); }
.acct-who .avatar { width: 40px; height: 40px; cursor: default; }
.acct-who p { margin: 0; display: grid; gap: 2px; min-width: 0; line-height: 1.3; }
.acct-who strong { font-weight: 900; }
.acct-who p span { color: var(--ink-3); font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acct-links { list-style: none; margin: 0; padding: 6px 0; }
.acct-links a, .acct-out button {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; min-height: 40px; padding: 2px 16px 0;
  background: none; border: 0; text-align: left; cursor: pointer;
  font: 600 .98rem/1.2 var(--font); color: var(--ink); text-decoration: none;
}
.acct-links a:hover, .acct-out button:hover { background: var(--paper-2); }
.acct-links a:focus-visible, .acct-out button:focus-visible { outline-offset: -3px; }
.acct-note { display: inline-flex; align-items: center; gap: 5px; font-size: .82rem; color: var(--ink-3); }
.acct-note svg { width: 14px; height: 14px; margin-top: -2px; }
.acct-out { border-top: 1px solid var(--rule); padding: 6px 0; }

@media (max-width: 720px) {
  .stub-zone, .stub-price { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .stub > span { padding: 2px 9px 0; }
  .acct-menu { top: 56px; }
}

/* ======== Dashboard (/learn) ======== */


.dash { padding-top: 40px; }
.greet { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 24px; }
.greet h1 { font-size: clamp(2rem, 4.6vw, 3rem); font-weight: 900; letter-spacing: -0.035em; }
.greet p { margin: 0; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* Next-train indicator: the one dot-matrix board in the product */
.board { margin-top: 24px; background: #0E0F1A; border-radius: 8px; padding: 22px 26px; display: grid; grid-template-columns: 1fr auto; gap: 18px 28px; align-items: center; color: #FFB000;
  box-shadow: inset 0 0 0 2px #2A2C40, 0 14px 30px -18px rgba(14,15,26,.8); }
.board .rows { font-family: var(--mono); text-transform: uppercase; letter-spacing: .06em; min-width: 0; }
.board .r1 { display: grid; grid-template-columns: 3ch 1fr auto; gap: 16px; font-size: clamp(1.05rem, 2.4vw, 1.5rem); font-weight: 600; }
.board .r1 span:nth-child(2) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .r2 { margin-top: 6px; color: #C79A3A; font-size: .85rem; }
.board .btn { --bg: #FFB000; --fg: #0E0F1A; box-shadow: none; }
@media (max-width: 640px) { .board { grid-template-columns: 1fr; padding: 18px; } .board .btn { justify-self: start; } .board .r1 { grid-template-columns: 3ch 1fr; } .board .r1 span:nth-child(2) { white-space: normal; } .board .r1 span:nth-child(3) { grid-column: 2; font-size: .9rem; } }

/* Ticket banner */
.ticketbar { margin-top: 18px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding: 14px 18px; border: 2px dashed var(--ink); border-radius: var(--r); }
.ticketbar svg { width: 26px; height: 26px; flex: none; }
.ticketbar p { margin: 0; flex: 1 1 320px; }
.ticketbar strong { font-weight: 900; }

/* Lines */
.lines { margin-top: 48px; display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 48px 40px; align-items: start; }
.unit { --line: #000; }
.unit header { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 2px solid var(--ink); margin-bottom: 8px; }
.unit .roundel { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font: 900 .95rem var(--font); background: var(--line); color: #fff; flex: none; padding-top: 2px; }
.unit.light .roundel { color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.unit.ink-text .roundel { color: var(--ink); }
.unit h2 { font-size: 1.2rem; font-weight: 900; letter-spacing: -0.02em; flex: 1; }
.unit .count { font-size: .85rem; color: var(--ink-3); font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 6px; }
.unit .count svg { width: 16px; height: 16px; }
.unit ol { list-style: none; margin: 0; padding: 0; }
.unit li { position: relative; padding: 7px 0 7px 44px; min-height: 40px; display: flex; align-items: center; gap: 10px; }
/* the rail segment for this station */
.unit li::before { content: ""; position: absolute; left: 12px; top: 0; bottom: 0; width: 8px; background: var(--line); }
.unit.light li::before { box-shadow: 1.25px 0 0 var(--ink), -1.25px 0 0 var(--ink); }
.unit li:first-child::before { top: 50%; }
.unit li:last-child::before { bottom: 50%; }
/* station tick */
.unit li::after { content: ""; position: absolute; left: 20px; top: calc(50% - 2px); width: 9px; height: 4px; background: var(--line); }
.unit.light li::after { background: var(--ink); }
/* untravelled: hollow rail */
.unit li.todo::before { background: #fff; box-shadow: inset 2.5px 0 0 var(--line), inset -2.5px 0 0 var(--line); }
.unit.light li.todo::before { box-shadow: inset 2px 0 0 var(--ink), inset -2px 0 0 var(--ink); }
.unit li a, .unit li span.t { text-decoration: none; font-weight: 600; line-height: 1.3; }
.unit li a:hover { text-decoration: underline; }
.unit li.done a { color: var(--ink-2); font-weight: 400; }
.unit li.done .ok { width: 16px; height: 16px; color: var(--pass); flex: none; }
.unit li .n { font: 600 .78rem var(--mono); color: var(--ink-3); min-width: 2.6em; font-variant-numeric: tabular-nums; }
/* you are here */
.unit li.here::after { width: 22px; height: 22px; left: 5px; top: calc(50% - 11px); border-radius: 50%; background: #fff; border: 4px solid var(--ink); }
.unit li.here a { font-weight: 900; }
.unit li .yah { margin-left: auto; font: 900 .7rem var(--font); letter-spacing: .06em; background: var(--ink); color: #fff; padding: 4px 7px 2px; border-radius: 3px; white-space: nowrap; }
/* locked line */
.unit.locked h2 { color: var(--ink-2); }
.unit.locked li span.t { color: var(--ink-3); font-weight: 400; }
.unit.locked li::before { background: #fff; box-shadow: inset 2.5px 0 0 var(--line), inset -2.5px 0 0 var(--line); opacity: .7; }
.unit.locked.light li::before { box-shadow: inset 2px 0 0 var(--ink), inset -2px 0 0 var(--ink); }
.unit.locked li::after { opacity: .7; }
.unit li.cap .t, .unit li.cap a { font-style: italic; }

/* ======== Lesson ======== */

.lesson-page { height: 100%; }
.app { display: grid; grid-template-rows: auto auto 1fr auto; height: 100dvh; }
.lesson-page .topbar { position: static; }

/* ---- Line diagram (in-carriage strip) ---- */
.linebar { border-bottom: 1px solid var(--rule); background: #fff; }
.linebar-in { display: flex; align-items: center; gap: 18px; padding: 10px 24px 8px; }
.linebar .roundel { width: 30px; height: 30px; border-radius: 50%; background: var(--line); color: #fff; display: grid; place-items: center; font-weight: 900; flex: none; padding-top: 2px; }
.linebar .ln { font-weight: 900; white-space: nowrap; }
.app.ink-text .linebar .roundel { color: var(--ink); }
.app.light .linebar .roundel { color: var(--ink); box-shadow: inset 0 0 0 2px var(--ink); }
.app.light .strip-ol::before { box-shadow: inset 0 0 0 2px var(--ink); }
.app.light .strip-ol::after { box-shadow: inset 0 0 0 1.25px var(--ink); }
.app.light .strip-ol li:not(.here) a::before { background: var(--ink); }
.strip-ol { flex: 1; display: flex; list-style: none; margin: 0; padding: 0 6px; position: relative; min-width: 0; }
.strip-ol::before { content: ""; position: absolute; left: 0; right: 0; top: 11px; height: 6px; border-radius: 3px; background: #fff; box-shadow: inset 0 0 0 2px var(--line); }
.strip-ol::after { content: ""; position: absolute; left: 0; width: var(--travelled, 10%); top: 11px; height: 6px; border-radius: 3px; background: var(--line); }
.strip-ol li { flex: 1; position: relative; z-index: 1; display: flex; justify-content: center; }
.strip-ol a { display: block; width: 100%; height: 28px; position: relative; }
.strip-ol a::before { content: ""; position: absolute; left: 50%; top: 17px; width: 3px; height: 7px; margin-left: -1.5px; background: var(--line); }
.strip-ol li.here a::before { width: 18px; height: 18px; top: 5px; margin-left: -9px; border-radius: 50%; background: #fff; border: 4px solid var(--ink); }
.strip-ol li.done a::before { background: var(--line); }
.strip-ol a .tip { position: absolute; top: 30px; left: 50%; transform: translateX(-50%); white-space: nowrap; background: var(--ink); color: #fff; font-size: .78rem; font-weight: 800; padding: 3px 7px 1px; border-radius: 3px; opacity: 0; pointer-events: none; transition: opacity .15s; z-index: 5; }
.strip-ol a:hover .tip, .strip-ol a:focus-visible .tip { opacity: 1; }
.linebar .pos { font: 600 .82rem var(--mono); color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
@media (max-width: 720px) { .linebar-in { padding: 8px 16px 6px; gap: 10px; } .linebar .ln { display: none; } }

/* ---- Two panes ---- */
.panes { display: grid; grid-template-columns: minmax(340px, var(--split, 44%)) 10px minmax(380px, 1fr); min-height: 0; }
.pane { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.pane-tabs { display: flex; gap: 2px; padding: 0 20px; border-bottom: 1px solid var(--rule); background: #fff; flex: none; }
.pane-tabs button { font: 800 .95rem var(--font); color: var(--ink-2); background: none; border: 0; padding: 14px 14px 10px; cursor: pointer; position: relative; display: inline-flex; align-items: center; gap: 8px; }
.pane-tabs button[aria-selected="true"] { color: var(--ink); }
.pane-tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 4px; background: var(--ink); border-radius: 2px 2px 0 0; }
.pane-tabs .st { width: 16px; height: 16px; color: var(--pass); }
.pane-body { overflow: auto; flex: 1; min-height: 0; scrollbar-width: thin; }
.panes:focus { outline: none; }
.panes.solo { grid-template-columns: 1fr; }
.panes.solo .read article { margin: 0 auto; }
.splitter { background: var(--paper-2); border-left: 1px solid var(--rule); border-right: 1px solid var(--rule); cursor: col-resize; position: relative; }
.splitter::after { content: ""; position: absolute; left: 3px; right: 3px; top: 50%; height: 36px; margin-top: -18px; border-radius: 2px; background: repeating-linear-gradient(var(--ink-3) 0 2px, transparent 2px 6px); opacity: .6; }
.splitter:focus-visible { outline-offset: -3px; }
.right { background: var(--paper-2); }
.right .pane-tabs { background: var(--paper-2); }

/* ---- Explainer ---- */
.read { padding: 32px clamp(20px, 3vw, 44px) 56px; }
.read article { max-width: 68ch; }
.read h1 { font-size: clamp(2rem, 3.2vw, 2.6rem); font-weight: 900; letter-spacing: -0.035em; margin-bottom: 8px; }
.read .meta { color: var(--ink-3); font-size: .9rem; margin: 0 0 28px; }
.read h2 { font-size: 1.35rem; font-weight: 900; margin: 2.2em 0 .5em; letter-spacing: -0.02em; }
.read p, .read li { color: #23264A; }
.read strong, .quiz strong { font-weight: 800; }
.read table { border-collapse: collapse; width: 100%; margin: 1.2em 0; font-size: .95rem; display: block; overflow-x: auto; }
.read th, .read td { text-align: left; padding: 8px 12px 6px; border-bottom: 1px solid var(--rule); }
.read th { font-size: .88rem; font-weight: 800; color: var(--ink-2); border-bottom: 2px solid var(--ink); }
.read td code { font-size: .9rem; white-space: nowrap; }
.read hr { border: 0; border-top: 1px solid var(--rule); margin: 2.2em 0; }
.read hr + h2 { margin-top: 0; }
.recap { margin-top: 2.4em; padding: 18px 20px 14px; background: var(--paper-2); border-radius: var(--r); }
.recap h2 { margin-top: 0; font-size: 1.05rem; }
.recap ul { margin: 0; padding-left: 1.2em; }
.read .next { margin-top: 32px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

/* ---- Quiz ---- */
.quiz { padding: 32px clamp(20px, 3vw, 44px) 56px; max-width: 72ch; }
.quiz h1 { font-size: 1.8rem; font-weight: 900; letter-spacing: -0.03em; }
.quiz fieldset { border: 0; padding: 0; margin: 28px 0 0; }
.quiz legend { font-weight: 800; font-size: 1.05rem; margin-bottom: 10px; padding: 0; }
.quiz legend code { font-size: .92rem; }
.opt { display: flex; gap: 12px; align-items: center; padding: 10px 14px 8px; border: 1px solid var(--rule); border-radius: var(--r); margin-top: 8px; cursor: pointer; background: #fff; }
.opt:hover { border-color: var(--ink-3); }
.opt input { accent-color: var(--ink); width: 18px; height: 18px; margin: 0; flex: none; }
.opt:has(input:checked) { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.opt.right { border-color: var(--pass); box-shadow: inset 0 0 0 1px var(--pass); background: #EEF8F2; }
.opt.wrong { border-color: var(--fail); box-shadow: inset 0 0 0 1px var(--fail); background: #FDF1F0; }
.fb { margin: 8px 0 0; font-size: .95rem; display: flex; gap: 8px; align-items: flex-start; }
.fb svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.fb.ok { color: var(--pass); } .fb.no { color: var(--fail); }
.quiz fieldset:focus-visible, .quiz .score:focus-visible { outline-offset: 6px; }
.quiz .actions { margin-top: 28px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.quiz .score { font-weight: 800; }

/* ---- Interchange ---- */
.ichg-body { padding: 22px 22px 40px; container-type: inline-size; }
.ichg-body h2 { font-size: 1rem; font-weight: 900; margin: 0 0 10px; display: flex; gap: 10px; align-items: center; }
.ichg-body h2 .no { width: 24px; height: 24px; border-radius: 50%; background: #fff; border: 3px solid var(--ink); display: inline-grid; place-items: center; font-size: .72rem; padding-top: 1px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
@container (max-width: 760px) { .pair { grid-template-columns: 1fr; } }
.ichg-body pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.ichg-body .gap { margin: 0 0 34px; }

/* ---- Exercise ---- */
.ex { display: grid; grid-template-rows: auto auto minmax(200px, 1fr) auto auto; height: 100%; min-height: 0; }
.task { padding: 16px 22px 12px; font-size: .97rem; }
.task p { margin: 0; max-width: 70ch; }
.task strong { font-weight: 800; }
.files { display: flex; align-items: center; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--rule); }
.files span { font: 600 .82rem var(--mono); padding: 8px 12px 6px; background: #fff; border: 1px solid var(--rule); border-bottom: 0; border-radius: 4px 4px 0 0; margin-bottom: -1px; }
.files .sp { flex: 1; background: none; border: 0; padding: 0; }
.files button { font: 800 .85rem var(--font); background: none; border: 0; color: var(--ink-2); display: inline-flex; gap: 6px; align-items: center; padding: 6px 8px; cursor: pointer; border-radius: 3px; }
.files button:hover { color: var(--ink); background: #fff; }
.files button svg { width: 15px; height: 15px; }
.editor { background: #fff; min-height: 0; overflow: hidden; }
.editor .cm-editor { height: 100%; }
.editor textarea { width: 100%; height: 100%; min-height: 240px; border: 0; padding: 12px 16px; font: .9rem/1.65 var(--mono); tab-size: 4; resize: none; }
.runbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); background: var(--paper-2); }
.runbar .sp { flex: 1; }
.runbar kbd { font-size: .78rem; color: var(--ink-3); }
.runbar .hintbtn { font: 800 .9rem var(--font); background: none; border: 0; color: var(--ink-2); display: inline-flex; gap: 6px; align-items: center; cursor: pointer; padding: 6px; }
.runbar .hintbtn svg { width: 18px; height: 18px; }
.out { overflow: auto; padding: 12px 18px 18px; background: #fff; font-size: .92rem; min-height: 96px; max-height: 32vh; }
.out .empty { color: var(--ink-3); margin: 4px 0; }
.out .busy { display: flex; gap: 10px; align-items: center; color: var(--ink-2); }
.out .busy i { width: 46px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--line) 0 30%, var(--paper-3) 30%); background-size: 200% 100%; animation: travel 1s linear infinite; }
@keyframes travel { from { background-position: 100% 0; } to { background-position: -100% 0; } }
.out ul { list-style: none; margin: 0; padding: 0; }
.out li { display: grid; grid-template-columns: 20px 1fr; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--paper-3); }
.out li svg { width: 18px; height: 18px; margin-top: 2px; }
.out li.pass svg { color: var(--pass); }
.out li.fail svg { color: var(--fail); }
.out li code { background: none; border: 0; padding: 0; font-weight: 600; }
.out li .why { grid-column: 2; font: .84rem var(--mono); color: var(--fail); white-space: pre-wrap; }
.out .sum { margin-top: 10px; font-weight: 800; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.out .sum.ok { color: var(--pass); }
.out .sum.no { color: var(--fail); }
.out pre.stdout { margin: 0; font: .88rem/1.6 var(--mono); white-space: pre-wrap; }
.out .meta { color: var(--ink-3); font-size: .8rem; margin-top: 8px; }
.hints { padding: 0 22px; }
.hints ol { margin: 0 0 12px; padding: 12px 16px 12px 36px; background: var(--gap-ground); border: 1px solid #E7C200; border-radius: var(--r); }
.hints li { margin: 4px 0; }
.hints:empty { display: none; }

/* ---- Bottom nav ---- */
.stationbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px; border-top: 1px solid var(--rule); background: #fff; }
.stationbar a { display: inline-flex; gap: 8px; align-items: center; text-decoration: none; font-weight: 800; color: var(--ink-2); }
.stationbar a:hover { color: var(--ink); }
.stationbar a svg { width: 18px; height: 18px; }
.stationbar .mid { font-size: .85rem; color: var(--ink-3); }
.mswitch { display: none; }

/* ---- Narrow: one pane at a time ---- */
@media (max-width: 1023px) {
  .panes { grid-template-columns: 1fr; }
  .splitter { display: none; }
  .panes[data-view="read"] .right, .panes[data-view="interchange"] .left, .panes[data-view="code"] .left { display: none; }
  .mswitch { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; border-top: 1px solid var(--rule); background: #fff; }
  .mswitch button { font: 800 .9rem var(--font); background: none; border: 0; padding: 12px 6px 10px; color: var(--ink-2); cursor: pointer; }
  .mswitch button[aria-pressed="true"] { color: var(--ink); box-shadow: inset 0 4px 0 var(--ink); }
  .stationbar .mid { display: none; }
  .app-course { display: none; }
}

/* ---------- Chroma token classes (server-side highlighting) ---------- */
.hl .k, .hl .kd, .hl .kn, .hl .kr, .hl .kc, .hl .cp { color: #0019A8; font-weight: 600; }
.hl .kt, .hl .nc { color: #00728F; }
.hl .s, .hl .s1, .hl .s2, .hl .sb, .hl .sr, .hl .se, .hl .sd, .hl .sc { color: #00703A; }
.hl .c, .hl .c1, .hl .cm, .hl .cs, .hl .ch { color: #5F6380; font-style: italic; }
.hl .m, .hl .mi, .hl .mf, .hl .mh, .hl .il { color: #9B0058; }
.hl .nv, .hl .vc, .hl .vg { color: #8A4A12; }
.hl .nf, .hl .fm { color: #16193A; font-weight: 600; }

/* ---------- Live runner states ---------- */
.runbar .busy { display: inline-flex; gap: 8px; align-items: center; color: var(--ink-2); font-size: .88rem; }
.runbar .busy i { width: 40px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--line) 0 30%, var(--paper-3) 30%); background-size: 200% 100%; animation: travel 1s linear infinite; }
.out pre.stdout.fail { color: var(--fail); }
.out .sol { margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.out .sol span { color: var(--ink-3); font-size: .88rem; }
.out li.skip svg { color: var(--ink-3); }
.task p { margin: 0 0 .4em; }
.task p:last-child { margin-bottom: 0; }
.quiz .meta { color: var(--ink-3); }
.opt span p { margin: 0; }

/* ---------- :::meme, the in-world departure-board joke ---------- */
.meme { margin: 1.8em 0; background: #0E0F1A; border-radius: 8px; padding: 18px 22px 16px; box-shadow: inset 0 0 0 2px #2A2C40; color: #FFB000; }
.meme table { width: 100%; border-collapse: collapse; font: 600 .95rem/1.45 var(--mono); }
.read .meme table { display: table; margin: 0; font-size: .95rem; }
.read .meme th, .read .meme td { border-bottom: 1px dashed #3A3D55; padding: 9px 12px 7px 0; vertical-align: top; color: #FFB000; text-align: left; font-weight: 600; }
.read .meme th { white-space: nowrap; width: 1%; padding-right: 22px; color: #C79A3A; font-size: .85rem; letter-spacing: .04em; text-transform: uppercase; border-bottom-color: #3A3D55; }
.read .meme tr:last-child th, .read .meme tr:last-child td { border-bottom: 0; }
.meme code { background: none; border: 0; padding: 0; color: inherit; }
.meme figcaption { margin-top: 12px; font: 400 .9rem var(--font); color: #C9CCE0; }
@media (max-width: 560px) { .read .meme th { white-space: normal; width: auto; } }

/* ---------- ```mermaid diagrams ---------- */
.diagram { margin: 1.8em 0; padding: 18px 16px 12px; border: 1px solid var(--rule); border-radius: 6px; background: #fff; overflow-x: auto; }
.diagram pre.mermaid { margin: 0; background: none; font: .85rem/1.5 var(--mono); color: var(--ink-3); white-space: pre-wrap; }
.diagram pre.mermaid[data-processed] { font: inherit; color: inherit; white-space: normal; text-align: center; }
.diagram svg { height: auto; margin: 0 auto; }

/* ---------- Highlighted code in lesson prose ---------- */
pre.code { margin: 1.4em 0; padding: 14px 16px; background: #FAFAFC; border: 1px solid var(--rule); border-radius: 6px; overflow-x: auto; font-size: .86rem; line-height: 1.65; tab-size: 4; }
.task pre { margin: .6em 0; padding: 10px 14px; background: #FAFAFC; border: 1px solid var(--rule); border-radius: 4px; font-size: .86rem; }

/* ---------- Exercise reference (collapsed docs excerpt) ---------- */
.task { max-height: 40vh; overflow-y: auto; }
.task .ref { margin-top: 8px; }
.task .ref summary { cursor: pointer; font-weight: 800; font-size: .9rem; color: var(--ink-2); display: inline-flex; gap: 6px; align-items: center; }
.task .ref summary:hover { color: var(--ink); }
.task .ref[open] summary { margin-bottom: 4px; }
.task .ref p { font-size: .9rem; color: var(--ink-2); }

/* ---------- File tabs + read-only test view ---------- */
.files .file-tab { font: 600 .82rem var(--mono); padding: 8px 12px 6px; background: var(--paper-2); border: 1px solid var(--rule); border-bottom: 0; border-radius: 4px 4px 0 0; margin-bottom: -1px; color: var(--ink-2); cursor: pointer; }
.files .file-tab[aria-pressed="true"] { background: #fff; color: var(--ink); }
.files .file-tab small { font: 400 .72rem var(--font); color: var(--ink-3); margin-left: 4px; }
.testview { margin: 0; padding: 12px 16px; background: #FAFAFC; overflow: auto; min-height: 0; font-size: .86rem; line-height: 1.65; tab-size: 4; }
.editor[hidden], .testview[hidden], .files button[hidden] { display: none; }
