/* The course's own styles. /hai-client/hai.css styles the shell, transcript
   and model context drawer; this sheet sets the course's palette through the
   --hai-* tokens and styles everything inside the course's surfaces, built
   from those same tokens so they follow light and dark.

   The palette follows the dual channel: the accent (cobalt) is what the model
   receives, good (teal) is what stays in the browser, warn (amber) is a turn
   parked on a person. */

/* Plain dark values first: a browser without light-dark() keeps these, as
   hai.css's own tokens do. */
:root {
  --hai-bg: #0f141a;
  --hai-panel: #161d26;
  --hai-panel-2: #121921;
  --hai-line: #2a3442;
  --hai-fg: #e3e8ee;
  --hai-dim: #93a0b0;
  --hai-accent: #8ea6ff;
  --hai-on-accent: #0b1220;
  --hai-good: #4fd1bd;
  --hai-warn: #e7b04f;
  --hai-bad: #f08a8f;
  --hai-user-bg: #1b2442;
  --hai-code-bg: #10161e;
  --hai-selected: var(--hai-accent-soft);

  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --hai-sans: var(--display);
  --hai-mono: var(--mono);
}

/* One value per scheme. These follow the system, or a data-hai-theme pin. */
@supports (color: light-dark(#000, #fff)) {
  :root {
    --hai-bg: light-dark(#edf1f5, #0f141a);
    --hai-panel: light-dark(#ffffff, #161d26);
    --hai-panel-2: light-dark(#f6f8fb, #121921);
    --hai-line: light-dark(#cad3de, #2a3442);
    --hai-fg: light-dark(#17202b, #e3e8ee);
    --hai-dim: light-dark(#536173, #93a0b0);
    --hai-accent: light-dark(#2b4fd6, #8ea6ff);
    --hai-on-accent: light-dark(#ffffff, #0b1220);
    --hai-good: light-dark(#0c7a6e, #4fd1bd);
    --hai-warn: light-dark(#9a5d08, #e7b04f);
    --hai-bad: light-dark(#b4232a, #f08a8f);
    --hai-user-bg: light-dark(#e6ecfc, #1b2442);
    --hai-code-bg: light-dark(#f3f5f9, #10161e);
  }
}

:where(button, summary, [tabindex]):focus-visible { outline: 2px solid var(--hai-accent); outline-offset: 2px; }

/* ── the menu bar under the header: Home, Tutorial, Lesson ──────────── */
/* Its own row in the shell, above the chat and the drawer beside it. */
.menu {
  flex: none; position: relative; z-index: 20;
  display: flex; align-items: center; gap: 2px;
  height: 42px; padding: 0 10px 0 6px;
  border-bottom: 1px solid var(--hai-line); background: var(--hai-panel);
}
.menu-item { position: relative; }
.menu-trigger {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px 6px 10px;
  border: 0; border-radius: 8px; background: none; color: var(--hai-fg);
  font: 600 13.5px var(--display); cursor: pointer;
}
.menu-trigger:hover, .menu-trigger[aria-expanded="true"] { background: var(--hai-hover); }
.menu-icon, .menu-chevron {
  flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.menu-icon { width: 16px; height: 16px; color: var(--hai-dim); transition: color 0.15s; }
.menu-trigger:hover .menu-icon, .menu-trigger[aria-expanded="true"] .menu-icon { color: var(--hai-accent); }
.menu-chevron { width: 13px; height: 13px; margin-left: -2px; opacity: 0.55; transition: transform 0.15s; }
.menu-trigger[aria-expanded="true"] .menu-chevron { transform: rotate(180deg); }
.menu-panel {
  position: absolute; top: calc(100% + 6px); left: 0;
  min-width: 280px; max-width: min(380px, calc(100vw - 24px)); max-height: calc(100vh - 110px); overflow: auto;
  padding: 6px; border: 1px solid var(--hai-line); border-radius: 12px;
  background: var(--hai-panel); box-shadow: 0 16px 40px -12px rgb(0 0 0 / 0.28);
}
.menu-panel[hidden] { display: none; }
.menu-group-heading { margin: 8px 8px 3px; font: 600 12px var(--display); color: var(--hai-dim); }
.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-link {
  display: grid; grid-template-columns: 2.6em minmax(0, 1fr); align-items: baseline; gap: 4px;
  width: 100%; padding: 7px 8px; border: 0; border-radius: 7px; background: none;
  color: var(--hai-fg); text-align: left; font: 14px/1.35 var(--display); cursor: pointer;
}
.menu-link.plain { grid-template-columns: minmax(0, 1fr); }
.menu-link:hover { background: var(--hai-hover); }
.menu-n { font: 600 12px var(--mono); color: var(--hai-accent); font-variant-numeric: tabular-nums; }
/* narrow: a list hangs from the whole bar, across the screen */
@media (max-width: 640px) {
  .menu-item { position: static; }
  .menu-panel { left: 12px; right: 12px; top: calc(100% + 4px); min-width: 0; max-width: none; }
}

/* ── inline text ─────────────────────────────────────────────────────── */
.ic {
  font: 0.86em var(--mono);
  background: var(--hai-code-bg);
  border: 1px solid var(--hai-line-soft);
  border-radius: 4px;
  padding: 0.05em 0.3em;
  white-space: nowrap;
}

/* ── welcome: the HaiKIT logo and a short introduction ─────────────── */
/* The logo's colours come from hai.css's logo tokens, so it reverses in the
   dark scheme with the header's mark; the fallbacks cover a client without them. */
.brand-ink { fill: var(--hai-logo-ink, var(--hai-fg)); }
.brand-paper { fill: var(--hai-logo-paper, var(--hai-panel)); }
.brand-paper-dim { fill: var(--hai-logo-paper, var(--hai-panel)); opacity: 0.5; }
.brand-hot { fill: var(--hai-logo-hot, #ff5a1f); }

.welcome { padding: 40px 40px 34px; container-type: inline-size; }
.welcome-top {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 14px 20px; margin-bottom: 26px;
}
.welcome-title { margin: 0; line-height: 0; }
.welcome-links { display: flex; flex-wrap: wrap; gap: 8px; }
.welcome-link {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px 7px 12px;
  border: 1px solid var(--hai-line); border-radius: 999px; background: var(--hai-panel);
  color: var(--hai-fg); font: 600 13.5px var(--display); text-decoration: none;
}
.welcome-link:hover { background: var(--hai-hover); }
.welcome-link:focus-visible { outline: 2px solid var(--hai-accent); outline-offset: 2px; }
.welcome-link-icon { width: 16px; height: 16px; fill: currentColor; flex: none; }
.welcome-logo { display: block; height: 46px; width: auto; max-width: 100%; }
.welcome-lede {
  margin: 0 0 14px; max-width: 26ch;
  font: 600 28px/1.2 var(--display); letter-spacing: -0.02em; text-wrap: balance;
}
.welcome-p { margin: 0 0 12px; max-width: 58ch; font: 17px/1.6 var(--serif); color: var(--hai-dim); }
.welcome-p strong { color: var(--hai-fg); font-weight: 600; }
.welcome-meta { margin: 18px 0 0; font-size: 13.5px; color: var(--hai-dim); }
.welcome-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.choice-btn {
  padding: 10px 18px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--hai-line); background: var(--hai-panel); color: var(--hai-fg);
  font: 600 14.5px var(--display);
}
.choice-btn:not(:disabled):hover { background: var(--hai-hover); }
.choice-btn.primary { background: var(--hai-accent); border-color: var(--hai-accent); color: var(--hai-on-accent); }
.choice-btn.primary:not(:disabled):hover { background: color-mix(in srgb, var(--hai-accent) 88%, var(--hai-fg)); }
.choice-btn:disabled { cursor: default; opacity: 0.45; }
.choice-btn.picked:disabled { opacity: 1; }
.welcome-closed { margin: 14px 0 0; font-size: 13px; color: var(--hai-dim); }

/* the sections: why HaiKIT, what the LLM brings, what HaiKIT gives you */
.welcome-section {
  margin-top: 34px; padding-top: 30px; border-top: 1px solid var(--hai-line-soft);
  container-type: inline-size;
}
.welcome-section-head { display: grid; gap: 16px; margin-bottom: 22px; }
@container (min-width: 600px) {
  .welcome-section-head { grid-template-columns: minmax(0, 0.8fr) minmax(0, 1fr); gap: 28px; align-items: center; }
}
.welcome-section-title { margin: 0; font: 600 21px/1.25 var(--display); letter-spacing: -0.015em; text-wrap: balance; }
.welcome-section-lead { margin: 6px 0 0; max-width: 34ch; font: 16px/1.5 var(--serif); color: var(--hai-dim); }
/* Each point spans two rows of the section's grid, title and text, as a
   subgrid: side by side, the texts line up even when a title wraps. */
.welcome-points { display: grid; grid-template-columns: minmax(0, 1fr); column-gap: 22px; row-gap: 0; }
.welcome-point { display: grid; grid-row: span 2; grid-template-rows: subgrid; margin-bottom: 14px; }
@container (min-width: 540px) {
  .welcome-points { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .welcome-point { margin-bottom: 0; }
}
.welcome-point h4 { margin: 0 0 5px; font: 600 14.5px/1.35 var(--display); text-wrap: balance; }
.welcome-point p { margin: 0; font: 14px/1.55 var(--display); color: var(--hai-dim); }

/* the close: what this app is, and where to begin */
.welcome-close { display: grid; gap: 16px; margin-top: 36px; }
@container (min-width: 620px) {
  .welcome-close { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
.welcome-start, .welcome-tutorial {
  display: flex; flex-direction: column; padding: 24px 26px 22px;
  border-radius: 14px; background: var(--hai-panel-2); border: 1px solid var(--hai-line-soft);
}
.welcome-start .welcome-p { color: var(--hai-fg); }
/* each panel's buttons sit at its foot, so side by side they line up */
.welcome-start .welcome-actions, .welcome-tutorial-read { margin-top: auto; }
.welcome-start .welcome-meta { margin-bottom: 20px; }

/* the tutorial: its steps, each a link into it */
.welcome-tutorial-label { margin: 0; font: 600 13px var(--display); color: var(--hai-accent); }
.welcome-tutorial-title { margin: 4px 0 0; font: 600 19px/1.25 var(--display); letter-spacing: -0.01em; }
.welcome-tutorial-lead { margin: 6px 0 14px; font: 15px/1.5 var(--serif); color: var(--hai-dim); }
.welcome-tutorial-steps { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 1px; }
.welcome-tutorial-steps button {
  display: grid; grid-template-columns: 2.3em minmax(0, 1fr); align-items: baseline; width: calc(100% + 16px);
  padding: 4px 8px; margin: 0 -8px; border: 0; border-radius: 6px; background: none; cursor: pointer;
  color: var(--hai-fg); text-align: left; font: 14.5px/1.4 var(--display);
}
.welcome-tutorial-steps button:not(:disabled):hover { background: var(--hai-hover); }
.welcome-tutorial-steps button:not(:disabled):hover span:last-child { text-decoration: underline; text-underline-offset: 2px; }
.welcome-tutorial-steps button:disabled { cursor: default; color: var(--hai-dim); }
.welcome-tutorial-steps button.picked { background: var(--hai-selected); color: var(--hai-fg); }
.welcome-tutorial-n { font: 600 12.5px var(--mono); color: var(--hai-accent); font-variant-numeric: tabular-nums; }
a.choice-btn { display: inline-flex; align-items: center; align-self: flex-start; text-decoration: none; }

/* the section illustrations: the same channels, the same colours */
.welcome-ill { margin: 0; }
.ill { display: block; width: 100%; max-width: 420px; height: auto; color: var(--hai-fg); }
.ill text { fill: currentColor; font-family: var(--display); }
.ill-label { font-size: 15px; font-weight: 600; }
.ill .ill-sub { font-size: 13px; fill: var(--hai-dim); }
.ill-sub-strong { font-size: 13px; font-weight: 600; }
.ill .ill-code { font: 12px var(--mono); fill: var(--hai-dim); }
.ill-card { fill: var(--hai-panel-2); stroke: var(--hai-line); }
.ill-card-strong { fill: var(--hai-panel); stroke: var(--hai-fg); stroke-width: 1.5; }
.ill-card-model { fill: var(--hai-accent-soft); stroke: var(--hai-accent); }
.ill-card-ui { fill: var(--hai-good-soft); stroke: var(--hai-good); }
.ill-model { color: var(--hai-accent); }
.ill-ui { color: var(--hai-good); }
.ill-wait { color: var(--hai-warn); }
.ill-dim { color: var(--hai-dim); }
.ill-ink { color: var(--hai-fg); }
.ill-ok { color: var(--hai-good); }
.ill-wire { fill: none; stroke: currentColor; stroke-width: 1.75; }
.ill-wire-faint { stroke-dasharray: 4 4; opacity: 0.6; }
.ill line { stroke: currentColor; stroke-width: 1.75; }
.ill polygon { fill: currentColor; }
.ill .ill-row { stroke-width: 3.5; stroke-linecap: round; opacity: 0.45; }
.ill-bar-ui { fill: var(--hai-good); }
.ill-bar-model { fill: var(--hai-accent); }
.ill-option { fill: var(--hai-panel-2); stroke: var(--hai-line); }
.ill-option-picked { fill: var(--hai-good-soft); stroke: var(--hai-good); stroke-width: 1.5; }
.ill-cursor { fill: var(--hai-fg); stroke: var(--hai-panel); stroke-width: 1; }
.ill-dot { fill: currentColor; }
.ill-check-dot { fill: currentColor; }
.ill-check { fill: none; stroke: var(--hai-panel); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* the architecture diagram: the model channel in the accent, the browser's in
   good, as everywhere else in the course; boxes and names in the text colour */
.arch { margin: 22px 0 20px; container-type: inline-size; }
.arch svg { width: 100%; height: auto; }
/* one drawing at a time, chosen by the card's width; same specificity as each
   other, so the container query below is what decides. The wide drawing is
   600 units across, so below 580px its 11.5px labels would shrink past 11px:
   the column drawing takes over there, at full size. */
.arch .arch-wide { display: none; }
.arch .arch-narrow { display: block; max-width: 340px; }
@container (min-width: 580px) {
  .arch .arch-wide { display: block; }
  .arch .arch-narrow { display: none; }
}
.arch text { fill: currentColor; font-family: var(--display); }
.arch-box { fill: var(--hai-panel-2); stroke: var(--hai-line); stroke-width: 1; }
.arch-node.brand .arch-box { fill: var(--hai-panel); stroke: var(--hai-fg); stroke-width: 1.5; }
.arch-name { font-size: 14px; font-weight: 600; }
.arch .arch-role { fill: var(--hai-dim); font-size: 11.5px; }
.arch-arrow line { stroke: currentColor; stroke-width: 1.75; }
.arch-arrow polygon { fill: currentColor; }
.arch-label { font-size: 11.5px; font-weight: 600; }
.arch-model { color: var(--hai-accent); }
.arch-ui { color: var(--hai-good); }
.arch figcaption { margin-top: 8px; font-size: 13px; color: var(--hai-dim); }

/* ── course map ──────────────────────────────────────────────────────── */
.map { padding: 18px 20px 16px; max-width: 760px; }
.map-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 14px; margin-bottom: 6px; }
.map-title { margin: 0; font: 700 24px/1.2 var(--display); letter-spacing: -0.015em; }
.map-meta { margin: 0; color: var(--hai-dim); font-size: 13px; }
.map-part { margin-top: 18px; }
.map-part-title { margin: 0; font: 600 17px/1.3 var(--display); display: flex; gap: 10px; align-items: baseline; }
.map-part-n { color: var(--hai-accent); font-weight: 700; white-space: nowrap; }
.map-blurb { margin: 4px 0 8px; color: var(--hai-dim); font: 15px/1.5 var(--serif); max-width: 64ch; }
.map-lessons { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--hai-line-soft); }
.map-lesson {
  display: grid;
  grid-template-columns: 2.6em minmax(0, 1fr) auto;
  gap: 2px 12px;
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-bottom: 1px solid var(--hai-line-soft);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
}
button.map-lesson { cursor: pointer; }
button.map-lesson:hover { background: var(--hai-hover); }
.map-lesson.picked { background: var(--hai-selected); box-shadow: inset 3px 0 0 var(--hai-accent); }
.map-id { font: 600 13px/1.6 var(--mono); color: var(--hai-accent); font-variant-numeric: tabular-nums; }
.map-ltitle { font-weight: 600; font-size: 15px; }
.map-min { color: var(--hai-dim); font-size: 12.5px; white-space: nowrap; }
.map-sum { grid-column: 2 / -1; color: var(--hai-dim); font-size: 13.5px; line-height: 1.45; }
.map-glossary { margin-top: 18px; border: 1px solid var(--hai-line-soft); border-radius: 8px; padding: 0 14px; }
.map-glossary summary { cursor: pointer; padding: 10px 0; font-weight: 600; font-size: 14px; }
.map-glossary dl { margin: 0 0 14px; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; }
.map-glossary dt { font: 600 13px/1.5 var(--mono); color: var(--hai-good); }
.map-glossary dd { margin: 0; font-size: 14px; line-height: 1.5; }
.map-closed { margin: 14px 0 0; color: var(--hai-dim); font-size: 13px; }

/* ── lesson ──────────────────────────────────────────────────────────── */
.lesson { padding: 26px 28px 22px; max-width: 780px; }
.lesson-where {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px;
  margin: 0 0 10px; color: var(--hai-dim); font-size: 13px;
}
.lesson-title {
  margin: 0; font: 700 clamp(24px, 3.4vw, 32px)/1.12 var(--display); letter-spacing: -0.02em;
  display: flex; gap: 0.45em; align-items: baseline; text-wrap: balance;
}
.lesson-id { color: var(--hai-accent); font-variant-numeric: tabular-nums; }
.lesson-summary { margin: 10px 0 0; font: italic 18px/1.5 var(--serif); color: var(--hai-dim); max-width: 60ch; }
.lesson-body { margin-top: 20px; font: 17px/1.65 var(--serif); }
.l-p, .l-list { max-width: 66ch; }
.l-p { margin: 0 0 14px; }
.l-h { margin: 28px 0 8px; font: 600 20px/1.3 var(--display); letter-spacing: -0.01em; }
.l-list { margin: 0 0 16px; padding-left: 1.2em; }
.l-list li { margin-bottom: 8px; }
.l-list li::marker { color: var(--hai-dim); }

.l-note {
  margin: 18px 0; padding: 12px 16px; max-width: 66ch;
  border-left: 3px solid var(--hai-accent); background: var(--hai-accent-soft); border-radius: 0 8px 8px 0;
  font: 15px/1.55 var(--display);
}
.l-note p { margin: 2px 0 0; }
.l-note-label { font-weight: 700; color: var(--hai-accent); font-size: 13.5px; }
.l-note-tip { border-color: var(--hai-good); background: var(--hai-good-soft); }
.l-note-tip .l-note-label { color: var(--hai-good); }
.l-note-warn { border-color: var(--hai-warn); background: var(--hai-warn-soft); }
.l-note-warn .l-note-label { color: var(--hai-warn); }

.l-code, .l-diagram { margin: 18px 0; }
.l-code pre, .l-diagram pre {
  margin: 0; padding: 14px 16px; overflow: auto; max-height: 32em;
  background: var(--hai-code-bg); border: 1px solid var(--hai-line-soft); border-radius: 8px;
  font: 13px/1.55 var(--mono); tab-size: 2;
}
.l-source {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  padding: 7px 12px; border: 1px solid var(--hai-line-soft); border-bottom: 0; border-radius: 8px 8px 0 0;
  background: var(--hai-panel-2); font: 12px var(--mono); color: var(--hai-dim);
}
.l-source + pre { border-radius: 0 0 8px 8px; }
.l-live { color: var(--hai-good); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.l-live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.l-path { overflow-wrap: anywhere; }
.l-caption { margin-top: 7px; font: 14px/1.5 var(--display); color: var(--hai-dim); }
.t-com { color: var(--hai-dim); font-style: italic; }
.t-str { color: var(--hai-good); }
.t-kw { color: var(--hai-accent); }
.t-num { color: var(--hai-warn); }

.l-table { margin: 16px 0 20px; overflow-x: auto; }
.l-table table { border-collapse: collapse; width: 100%; font: 14.5px/1.5 var(--display); }
.l-table th { text-align: left; font-weight: 600; padding: 8px 12px 8px 0; border-bottom: 2px solid var(--hai-line); }
.l-table td { padding: 9px 12px 9px 0; border-bottom: 1px solid var(--hai-line-soft); vertical-align: top; }
.l-table td:first-child { white-space: nowrap; }

.l-compare { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 18px 0 22px; }
.l-side { border: 1px solid var(--hai-line-soft); border-top: 3px solid var(--hai-bad); border-radius: 8px; padding: 12px 14px; background: var(--hai-panel-2); }
.l-side-good { border-top-color: var(--hai-good); }
.l-side h4 { margin: 0 0 8px; font: 600 15px var(--display); }
.l-side-bad h4 { color: var(--hai-bad); }
.l-side-good h4 { color: var(--hai-good); }
.l-side p { margin: 10px 0 0; font: 14.5px/1.55 var(--display); }
.l-sample { margin: 0; white-space: pre-wrap; font: 12px/1.5 var(--mono); color: var(--hai-fg); }
/* code from the tutorial: the file it goes in, numbered lines, their notes */
.l-file {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px;
  padding: 7px 12px; border: 1px solid var(--hai-line-soft); border-bottom: 0; border-radius: 8px 8px 0 0;
  background: var(--hai-panel-2); font-size: 12.5px;
}
.l-file + pre { border-radius: 0 0 8px 8px; }
.l-file-name { font: 600 12.5px var(--mono); color: var(--hai-fg); overflow-wrap: anywhere; }
.l-file-action {
  padding: 1px 8px; border-radius: 999px; background: var(--hai-accent-soft); color: var(--hai-accent);
  font: 600 11.5px var(--display);
}
.l-line { display: inline; border-radius: 3px; }
.l-mark {
  display: inline-flex; align-items: center; justify-content: center; min-width: 1.55em; height: 1.55em;
  padding: 0 0.3em; border-radius: 999px; vertical-align: 0.05em;
  background: var(--hai-accent); color: var(--hai-on-accent);
  font: 700 10.5px/1 var(--display); text-decoration: none;
}
.l-mark:focus-visible { outline: 2px solid var(--hai-accent); outline-offset: 2px; }
.l-notes { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.l-note-item { display: grid; grid-template-columns: 2.2em minmax(0, 1fr); gap: 4px 10px; align-items: start; border-radius: 6px; }
.l-note-item .l-mark { margin-top: 0.25em; }
.l-note-body { font: 15px/1.55 var(--display); }
.l-note-body p { margin: 0 0 6px; }
.l-note-body ul { margin: 4px 0 8px; padding-left: 1.1em; }
.l-note-body li { margin-bottom: 4px; }
.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0%, 40% { background: var(--hai-warn-soft); } 100% { background: transparent; } }

/* callouts from the tutorial reuse the asides above */
.l-callout-title { margin: 2px 0 6px; font-weight: 700; }
.l-callout p { margin: 0 0 8px; }
.l-callout p:last-child { margin-bottom: 0; }
.l-callout ul { margin: 0 0 8px; padding-left: 1.1em; }

/* a fold: the tutorial's optional parts */
.l-fold { margin: 18px 0; border: 1px solid var(--hai-line); border-radius: 10px; padding: 0 16px; background: var(--hai-panel-2); }
.l-fold > summary { cursor: pointer; padding: 12px 0; font: 600 15px var(--display); }
.l-fold[open] > summary { border-bottom: 1px solid var(--hai-line-soft); margin-bottom: 12px; }
.l-fold > :last-child { margin-bottom: 16px; }

/* a tutorial page: its buttons at its foot */
.tutorial-nav { margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--hai-line-soft); }
.tutorial-nav-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.tutorial-nav-closed { margin: 12px 0 0; font-size: 13px; color: var(--hai-dim); }

/* a working select list in a comparison: local to the lesson */
.l-picker { margin: 0; padding: 0; border: 0; min-width: 0; }
.l-picker-caption { padding: 0; margin-bottom: 6px; font: 600 12.5px var(--display); color: var(--hai-dim); }
.l-picker-row {
  display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: center; gap: 10px;
  padding: 7px 10px; margin-bottom: 4px; border: 1px solid var(--hai-line); border-radius: 7px;
  background: var(--hai-panel); cursor: pointer; font: 13.5px var(--display);
}
.l-picker-row:hover { background: var(--hai-hover); }
.l-picker-row:has(input:checked) { background: var(--hai-selected); border-color: var(--hai-good); }
.l-picker-row:has(input:focus-visible) { outline: 2px solid var(--hai-accent); outline-offset: 1px; }
.l-picker-row input { margin: 0; accent-color: var(--hai-good); }
.l-picker-label { font: 600 13px var(--mono); }
.l-picker-detail { color: var(--hai-dim); text-align: right; }
.l-side .l-picker-more { margin: 2px 0 0; font-size: 12.5px; color: var(--hai-dim); }
.l-side .l-picker-sends { margin: 8px 0 0; font-size: 13px; color: var(--hai-good); }

/* ── the sequence diagram: Browser | Server | Model ─────────────────── */
.seq {
  margin: 22px 0; padding: 16px 18px 14px;
  border: 1px solid var(--hai-line); border-radius: 12px; background: var(--hai-panel);
  font-family: var(--display);
}
.seq-top { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.seq-title { font-weight: 700; }
.seq-count { color: var(--hai-dim); font-variant-numeric: tabular-nums; }
.seq-lanes {
  display: grid; grid-template-columns: repeat(3, 1fr);
  margin: 14px 0 2px 2.2em; text-align: center; font-size: 13px; font-weight: 600;
}
.seq-lane-browser { color: var(--hai-good); }
.seq-lane-model { color: var(--hai-accent); }
.seq-steps { list-style: none; margin: 0; padding: 0; }
.seq-step { display: grid; grid-template-columns: 2.2em 1fr; height: 38px; transition: opacity 0.16s; }
.seq-step[data-state="todo"] { opacity: 0.2; }
.seq-step[data-state="done"] { opacity: 0.42; }
.seq-step[data-state="current"] { background: var(--hai-panel-2); border-radius: 6px; }
.seq-step[data-state="current"] .seq-n { color: inherit; font-weight: 600; }
.seq-n { align-self: center; padding-left: 6px; font: 11.5px var(--mono); color: var(--hai-dim); }
.seq-track {
  position: relative;
  background-image: linear-gradient(var(--hai-line), var(--hai-line)), linear-gradient(var(--hai-line), var(--hai-line)),
    linear-gradient(var(--hai-line), var(--hai-line));
  background-size: 1px 100%;
  background-repeat: no-repeat;
  background-position: 16.667% 0, 50% 0, 83.333% 0;
}
.tone-plain { color: var(--hai-fg); }
.tone-model { color: var(--hai-accent); }
.tone-ui { color: var(--hai-good); }
.tone-park { color: var(--hai-warn); }
.seq-arrow, .seq-self {
  position: absolute; top: 3px; height: 32px; padding: 0; border: 0; background: none;
  color: inherit; font: inherit; cursor: pointer;
}
.seq-arrow {
  left: calc((var(--a) * 2 + 1) / 6 * 100%);
  width: calc((var(--b) - var(--a)) / 3 * 100%);
}
.seq-arrow::before {
  content: ""; position: absolute; left: 0; right: 0; bottom: 8px; height: 2px; background: currentColor;
}
.seq-arrow::after {
  content: ""; position: absolute; bottom: 4px; border: 5px solid transparent;
}
.seq-arrow.to-right::after { right: -2px; border-left: 8px solid currentColor; border-right: 0; }
.seq-arrow.to-left::after { left: -2px; border-right: 8px solid currentColor; border-left: 0; }
.seq-arrow .seq-label {
  position: absolute; left: 50%; bottom: 13px; transform: translateX(-50%); white-space: nowrap;
}
.seq-self { left: calc((var(--a) * 2 + 1) / 6 * 100% - 6px); display: flex; align-items: center; gap: 10px; }
.seq-self::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--hai-panel);
  border: 2px solid currentColor; box-sizing: border-box; flex: none;
}
.seq-label { font: 12px var(--mono); }
.seq-step[data-state="current"] .seq-label { font-weight: 600; font-size: 12.5px; }
.seq-step[data-state="current"] .seq-arrow::before { height: 3px; }
.seq-note {
  min-height: 3.2em; margin: 12px 0 10px; padding: 10px 12px;
  background: var(--hai-panel-2); border-radius: 8px; font: 15px/1.55 var(--display);
}
.seq-controls { display: flex; gap: 8px; justify-content: flex-end; }
.seq-btn {
  border: 1px solid var(--hai-line); background: var(--hai-panel); color: var(--hai-fg);
  border-radius: 999px; padding: 5px 14px; font: 600 13px var(--display); cursor: pointer;
}
.seq-btn-next { background: var(--hai-accent); color: var(--hai-on-accent); border-color: var(--hai-accent); }
.seq-btn:disabled { opacity: 0.35; cursor: default; }

/* ── recap: the lesson's digest, in the model channel's colour ─────── */
.lesson-recap {
  margin-top: 30px; padding: 14px 18px 12px;
  border-left: 3px solid var(--hai-accent); background: var(--hai-accent-soft); border-radius: 0 10px 10px 0;
  font-family: var(--display);
}
.recap-title { margin: 0 0 6px; font-size: 14px; font-weight: 700; color: var(--hai-accent); }
.lesson-recap ul { margin: 0; padding-left: 1.1em; font-size: 15px; line-height: 1.5; }
.lesson-recap li { margin-bottom: 4px; }
.recap-foot { margin: 10px 0 0; font-size: 13px; color: var(--hai-good); }

/* ── checkpoint ──────────────────────────────────────────────────────── */
.cp-head, .cp-question, .cp-options { margin-left: 20px; margin-right: 20px; max-width: 720px; }
.cp-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; font-size: 13px; }
.cp-kind { font-weight: 700; }
.cp-status { color: var(--hai-dim); display: inline-flex; align-items: center; gap: 7px; }
.cp-status.live { color: var(--hai-warn); font-weight: 600; }
.cp-status.live::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor;
  animation: waiting 1.8s ease-in-out infinite;
}
@keyframes waiting { 50% { opacity: 0.25; } }
.cp-question { margin-top: 8px; margin-bottom: 14px; font: 19px/1.45 var(--serif); }
.cp-options { display: grid; gap: 8px; margin-bottom: 18px; }
.cp-option {
  display: grid; grid-template-columns: 2em minmax(0, 1fr); gap: 10px; align-items: baseline;
  width: 100%; padding: 10px 14px; text-align: left;
  border: 1px solid var(--hai-line); border-radius: 8px; background: var(--hai-panel); color: var(--hai-fg);
  font: 15px/1.45 var(--display); cursor: pointer;
}
.cp-option:not(:disabled):hover { border-color: var(--hai-accent); background: var(--hai-hover); }
.cp-option:disabled { cursor: default; color: var(--hai-dim); }
.cp-option.picked { border-color: var(--hai-accent); background: var(--hai-selected); color: var(--hai-fg); }
.cp-letter { font: 600 13px var(--mono); color: var(--hai-accent); }

/* ── up next: the button that moves on to the next lesson ────────────── */
.next-lesson { padding: 18px 22px 18px; max-width: 640px; }
.next-lesson-label { margin: 0; font-size: 12.5px; color: var(--hai-dim); }
.next-lesson-title {
  margin: 4px 0 0; display: flex; gap: 0.45em; align-items: baseline;
  font: 600 18px/1.3 var(--display); letter-spacing: -0.01em;
}
.next-lesson-id { color: var(--hai-accent); font-variant-numeric: tabular-nums; }
.next-lesson-summary { margin: 6px 0 0; max-width: 60ch; font: 15px/1.5 var(--serif); color: var(--hai-dim); }
.next-lesson-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.next-lesson-closed { margin: 12px 0 0; font-size: 13px; color: var(--hai-dim); }

/* ── small screens and motion ────────────────────────────────────────── */
@media (max-width: 640px) {
  .welcome { padding: 26px 18px 22px; }
  .welcome-logo { height: 36px; }
  .welcome-lede { font-size: 22px; }
  .welcome-p { font-size: 16px; }
  .welcome-start, .welcome-tutorial { padding: 18px 16px; }
  .map { padding: 14px 14px 12px; }
  .lesson { padding: 20px 16px 18px; }
  .lesson-body { font-size: 16.5px; }
  .l-compare { grid-template-columns: minmax(0, 1fr); }
  .seq { padding: 14px 12px 12px; }
  .seq-label { font-size: 10.5px; }
  .cp-head, .cp-question, .cp-options { margin-left: 14px; margin-right: 14px; }
  .map-glossary dl { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .map-glossary dd { margin-bottom: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .menu-icon, .menu-chevron { transition: none; }
  .flash { animation: none; }
  .seq-step { transition: none; }
  .cp-status.live::before { animation: none; }
}
