/* ===========================================================================
   TinySkiff ESP32-S3 Lab · course design system (light / minimal)
   Shared, tokenised styling for every guided day and the course map.
   Reskinned to the landing's language (issue #21): cool-neutral paper, one calm
   blue accent, all-Inter type. Genuine terminals (code panel, serial monitor)
   stay dark; the old skeuomorphic sonar instrument is retired. Legacy token
   names (--sounder, --depth, --abyss…) are kept but remapped. Per-day values
   (voyage fill, glossary) are injected by the build, never hard-coded here.
   =========================================================================== */

:root {
  /* Palette — light, minimal; the shared language with the landing.
     Legacy token names are kept (many rules reference them) but remapped to a
     cool-neutral paper + one calm blue accent. Dark ink is reserved for genuine
     terminals (code panel, serial monitor) and small intentional highlights. */
  --abyss: #171a20;          /* dark ink: code panels, serial monitor, highlights */
  --abyss-2: #20242c;        /* raised dark surface */
  --abyss-line: #2b303a;     /* hairlines on dark */
  --chart: #fcfcfd;          /* page background (cool paper, not cream) */
  --paper: #ffffff;          /* reading card surface */
  --ink: #171a20;            /* primary text */
  --ink-soft: #4c525d;       /* secondary text */
  --ink-faint: #6b7280;      /* captions, meta — AA on white at small sizes */
  --line: #e5e7ee;           /* hairlines */
  --line-strong: #d7dbe4;
  --sounder: #3557f0;        /* primary accent (blue) */
  --sounder-deep: #2743c9;
  --depth: #3557f0;          /* links, structure — same accent, for restraint */
  --depth-deep: #223bb8;
  --depth-wash: #eef1fe;     /* accent tint surface */
  --phosphor: #8fc9ff;       /* soft readout blue on dark terminals */
  --hazard: #c77d2e;         /* safety callouts — semantic caution, used sparingly */
  --hazard-wash: #fbf3e6;

  --shadow-sm: 0 1px 2px rgba(18, 22, 33, 0.04), 0 1px 3px rgba(18, 22, 33, 0.05);
  --shadow-md: 0 6px 22px rgba(18, 22, 33, 0.07);
  --shadow-lg: 0 24px 60px rgba(18, 22, 33, 0.14);
  --shadow-inset: inset 0 0 0 1px rgba(255, 255, 255, 0.04);

  --r-xl: 20px;
  --r-lg: 16px;
  --r-md: 12px;
  --r-sm: 8px;

  /* Type — all Inter; no high-contrast display serif. */
  --display: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --body: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "Spline Sans Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background-color: var(--chart);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--depth-deep); text-underline-offset: 0.18em; text-decoration-thickness: 1.5px; }
a:hover { color: var(--depth); }
button, input, textarea { font: inherit; }

h1, h2, h3, h4 {
  font-family: var(--display);
  font-weight: 640;
  line-height: 1.1;
  margin: 0;
  letter-spacing: -0.02em;
  font-optical-sizing: auto;
}

.mono { font-family: var(--mono); }

/* --- eyebrows / kickers: instrument tick labels --------------------------- */
.eyebrow, .section-kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--depth-deep);
}
.eyebrow::before {
  content: "";
  width: 22px;
  height: 2px;
  background: var(--sounder);
}

/* ===========================================================================
   Shell
   =========================================================================== */
.lesson-shell {
  width: min(1200px, calc(100% - 40px));
  margin: 0 auto;
  padding: 26px 0 90px;
}

/* ===========================================================================
   Hero — the sounder
   =========================================================================== */
.hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(300px, 0.72fr);
  gap: 34px;
  padding: 40px clamp(24px, 4vw, 46px) 42px;
  border-radius: var(--r-xl);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
/* faint breadboard-dot motif — a subject nod, kept barely-there */
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(23, 26, 32, 0.05) 1px, transparent 1.4px);
  background-size: 22px 22px;
  background-position: -11px -11px;
  mask-image: radial-gradient(130% 100% at 78% 0%, #000 35%, transparent 78%);
  pointer-events: none;
}
.hero > * { position: relative; z-index: 1; }

.hero .eyebrow { color: var(--ink-soft); }
.hero .eyebrow::before { background: var(--sounder); }

.hero h1 {
  margin: 16px 0 0;
  font-size: clamp(2.4rem, 5.4vw, 4rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  color: var(--ink);
}
.hero h1 em {
  font-style: normal;
  color: var(--sounder);
}
.lede {
  max-width: 42ch;
  margin: 18px 0 0;
  color: var(--ink-soft);
  font-size: clamp(1.02rem, 1.6vw, 1.16rem);
}

.meta-row { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 26px; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--chart);
  color: var(--ink-soft);
  font-size: 0.85rem;
  font-weight: 500;
}
.pill.is-key {
  border-color: color-mix(in srgb, var(--sounder) 35%, var(--line));
  background: var(--depth-wash);
  color: var(--depth-deep);
}

/* --- the "at a glance" readout card --------------------------------------
   The old skeuomorphic sonar animation (sounder-stage: sensor, target, pings,
   sweep) is retired for the simpler design — only the informative readout
   remains, as a clean light stat. */
.sounder {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.sounder-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.sounder-head .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--sounder);
  animation: pulse-dot 2.4s ease-in-out infinite;
}
@keyframes pulse-dot { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

/* the animated sonar stage is retired in the minimal design */
.sounder-stage { display: none; }
.sounder-stage-legacy {
  position: relative;
  height: 176px;
  overflow: hidden;
}
/* the sensor at left */
.sounder-sensor {
  position: absolute;
  left: 16px; top: 50%;
  transform: translateY(-50%);
  width: 10px; height: 46px;
  border-radius: 4px;
  background: linear-gradient(180deg, #2f5763, #12303a);
  border: 1px solid #3c6673;
  z-index: 2;
}
/* the target line at right */
.sounder-target {
  position: absolute;
  right: 46px; top: 18%;
  width: 3px; height: 64%;
  border-radius: 3px;
  background: repeating-linear-gradient(180deg, var(--sounder) 0 7px, transparent 7px 13px);
  opacity: 0.85;
  transition: right 1.6s cubic-bezier(0.5, 0, 0.2, 1);
  z-index: 2;
}
/* concentric ping rings */
.ping {
  position: absolute;
  left: 21px; top: 50%;
  width: 22px; height: 22px;
  margin: -11px 0 0 -11px;
  border-radius: 50%;
  border: 2px solid var(--phosphor);
  opacity: 0;
  animation: ping-out 2.6s cubic-bezier(0.2, 0.6, 0.3, 1) infinite;
}
.ping:nth-child(2) { animation-delay: 0.5s; }
.ping:nth-child(3) { animation-delay: 1.0s; }
@keyframes ping-out {
  0%   { transform: scale(0.3); opacity: 0.9; }
  70%  { opacity: 0.28; }
  100% { transform: scale(9); opacity: 0; }
}
/* sweep line */
.sounder-stage::after {
  content: "";
  position: absolute;
  left: 21px; top: 50%;
  width: 200%; height: 1px;
  background: linear-gradient(90deg, rgba(111,230,176,0.5), transparent);
  transform-origin: left center;
  pointer-events: none;
}

.sounder-readout {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 16px;
  border-top: 1px solid var(--line);
  background: var(--chart);
}
.sounder-readout .label {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.sounder-readout .value {
  font-family: var(--mono);
  font-size: 1.7rem;
  font-weight: 600;
  color: var(--sounder);
  font-variant-numeric: tabular-nums;
}
.sounder-readout .value small { font-size: 0.85rem; color: var(--ink-faint); }

/* agent-assist tucked under the readout */
.agent-strip {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 16px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}
.agent-strip .lesson-code {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.agent-strip .lesson-code .label {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.agent-strip .lesson-code code {
  font-family: var(--mono);
  font-size: 0.92rem;
  color: var(--depth-deep);
}
.copy-prompt {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 0;
  border-radius: var(--r-md);
  padding: 0.72rem 1rem;
  color: #fff;
  background: var(--sounder);
  font-weight: 600;
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, box-shadow 140ms ease;
  box-shadow: 0 1px 2px rgba(53, 87, 240, 0.35), 0 6px 18px rgba(53, 87, 240, 0.22);
}
.copy-prompt:hover { transform: translateY(-1px); background: var(--sounder-deep); }
.copy-prompt:active { transform: translateY(0); }
.agent-strip .agent-note { margin: 0; color: var(--ink-soft); font-size: 0.86rem; }
.agent-strip .agent-note a { color: var(--depth-deep); }

/* ===========================================================================
   Layout: voyage rail + main
   =========================================================================== */
.layout {
  display: grid;
  grid-template-columns: 244px minmax(0, 1fr);
  gap: 30px;
  margin-top: 30px;
  align-items: start;
}

.rail {
  position: sticky;
  top: 18px;
  padding: 20px 18px;
  border-radius: var(--r-xl);
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
}
.rail-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 4px;
}
.rail-head strong {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.rail-head .day-of {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--depth-deep);
  font-weight: 600;
}
/* voyage progress meter */
.voyage {
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  margin: 10px 0 16px;
}
.voyage span {
  display: block;
  height: 100%;
  /* --voyage-fill is set inline per day (day N of 30); defaults to empty */
  width: var(--voyage-fill, 0%);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--depth), var(--sounder));
}

.rail-nav { display: grid; gap: 1px; }
.rail-nav a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0.5rem 0.55rem 0.5rem 0.4rem;
  border-radius: 10px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.92rem;
  transition: background 130ms ease, color 130ms ease;
}
.rail-nav a .tick {
  flex: 0 0 auto;
  width: 9px; height: 9px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  background: var(--paper);
  transition: all 130ms ease;
}
.rail-nav a:hover { background: var(--depth-wash); color: var(--depth-deep); }
.rail-nav a.active {
  background: var(--depth-wash);
  color: var(--depth-deep);
  font-weight: 600;
}
.rail-nav a.active .tick {
  border-color: var(--sounder);
  background: var(--sounder);
  box-shadow: 0 0 0 3px rgba(240, 160, 33, 0.18);
}

.lesson-main { display: grid; gap: 22px; min-width: 0; }

/* ===========================================================================
   Sections / cards
   =========================================================================== */
.card {
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  scroll-margin-top: 20px;
}
.card-inner { padding: clamp(22px, 3.6vw, 36px); }

.section-head { margin-bottom: 22px; }
.section-head h2 {
  margin: 9px 0 0;
  font-size: clamp(1.7rem, 3.1vw, 2.3rem);
}
.section-head .muted { margin: 10px 0 0; max-width: 62ch; }
.muted { color: var(--ink-soft); }

/* section index number, chart-mark style */
.section-index {
  font-family: var(--mono);
  color: var(--sounder-deep);
  font-weight: 600;
}

/* ===========================================================================
   Parts grid
   =========================================================================== */
.part-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.part-card {
  display: flex;
  flex-direction: column;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: #fff;
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}
.part-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.part-photo {
  position: relative;
  display: grid;
  place-items: center;
  height: 132px;
  margin: 0 0 12px;
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  background: var(--chart);
  overflow: hidden;
}
.part-photo img { width: 84%; height: 100%; object-fit: contain; }
.part-photo figcaption {
  position: absolute;
  left: 8px; bottom: 8px;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  background: rgba(23, 26, 32, 0.72);
  color: #eef0f4;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.part-card h3 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 1.02rem;
  font-family: var(--body);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.part-card p { margin: 6px 0 0; color: var(--ink-soft); font-size: 0.9rem; }
.part-card code, .pin-row code, p code, li code, span code {
  font-family: var(--mono);
  font-size: 0.86em;
  padding: 0.05em 0.35em;
  border-radius: 5px;
  background: var(--depth-wash);
  color: var(--depth-deep);
}

/* ===========================================================================
   Define chip (opens lightbox)
   =========================================================================== */
.define {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.1rem 0.5rem 0.1rem 0.42rem;
  border: 1px solid rgba(14, 124, 139, 0.32);
  border-radius: 999px;
  background: var(--depth-wash);
  color: var(--depth-deep);
  font-family: var(--body);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  vertical-align: middle;
  transition: background 130ms ease, color 130ms ease, border-color 130ms ease;
}
.define::before {
  content: "";
  width: 13px; height: 13px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  background:
    radial-gradient(circle, currentColor 1.5px, transparent 2px) center 3.5px / 100% no-repeat;
  position: relative;
}
.define:hover, .define:focus-visible {
  background: var(--depth);
  border-color: var(--depth);
  color: #fff;
  outline: none;
}
/* code-note define chips read on dark */
.code-note .define {
  border-color: rgba(111, 230, 176, 0.35);
  background: rgba(111, 230, 176, 0.1);
  color: #a7ecca;
}
.code-note .define:hover, .code-note .define:focus-visible {
  background: var(--phosphor);
  color: #06151c;
  border-color: var(--phosphor);
}

/* ===========================================================================
   Wiring: chart the circuit
   =========================================================================== */
.wire-layout { display: grid; grid-template-columns: 1.15fr 1fr; gap: 18px; align-items: start; }

.image-frame {
  position: relative;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: #fff;
}
.image-frame button.zoom {
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: var(--r-md);
  background: none;
  cursor: zoom-in;
}
.image-frame img { display: block; width: 100%; height: auto; border-radius: var(--r-md); }
.image-frame .zoom-hint {
  position: absolute;
  right: 20px; top: 20px;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  background: rgba(23, 26, 32, 0.78);
  color: #eef0f4;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
}
.caption {
  margin: 11px 4px 0;
  color: var(--ink-faint);
  font-size: 0.82rem;
}

.pin-table {
  display: grid;
  gap: 8px;
  padding: 4px;
  border-radius: var(--r-lg);
}
.pin-row {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  transition: border-color 130ms ease, box-shadow 130ms ease, background 130ms ease;
}
.pin-row:hover, .pin-row.lit {
  border-color: var(--sounder);
  box-shadow: 0 0 0 3px rgba(240, 160, 33, 0.14);
}
.pin-name {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
}
.pin-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--depth); }
.pin-arrow { font-family: var(--mono); color: var(--ink-faint); }
.pin-dest {
  font-family: var(--mono);
  font-weight: 600;
  color: var(--depth-deep);
  padding: 0.15rem 0.5rem;
  background: var(--depth-wash);
  border-radius: 7px;
  white-space: nowrap;
}
.pin-why { color: var(--ink-soft); font-size: 0.9rem; }

.callout {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 13px;
  margin-top: 18px;
  padding: 16px 18px;
  border-radius: var(--r-lg);
  border: 1px solid #eccf9c;
  background: var(--hazard-wash);
}
.callout .icon {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: #f6e2c0;
  font-size: 1.15rem;
}
.callout p { margin: 0; }
.callout strong { color: #a9611f; }

/* ===========================================================================
   Build steps (checkable)
   =========================================================================== */
.steps-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px 15px;
  border-radius: var(--r-md);
  border: 1px dashed var(--line-strong);
  background: #fff;
}
.steps-progress .bar {
  flex: 1;
  height: 8px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.steps-progress .bar span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--depth), var(--sounder));
  transition: width 320ms cubic-bezier(0.3, 0.7, 0.2, 1);
}
.steps-progress .count {
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
}

.step-list { display: grid; gap: 10px; padding: 0; margin: 0; list-style: none; counter-reset: step; }
.step {
  counter-increment: step;
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 14px;
  align-items: start;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: #fff;
  transition: border-color 140ms ease, background 140ms ease;
}
.step:hover { border-color: var(--line-strong); }
.step .box {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  padding: 0;
  border-radius: 9px;
  border: 2px solid var(--line-strong);
  background: #fff;
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 140ms ease;
}
.step .box::before { content: counter(step); }
.step .box:hover { border-color: var(--depth); color: var(--depth-deep); }
.step .text { margin: 0; padding-top: 2px; cursor: pointer; }
.step.done { background: var(--depth-wash); border-color: rgba(14, 124, 139, 0.3); }
.step.done .box {
  border-color: var(--depth);
  background: var(--depth);
  color: #fff;
}
.step.done .box::before { content: "✓"; }
.step.done .text { color: var(--ink-soft); }

.done-banner {
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: var(--r-lg);
  border: 1px solid rgba(14, 124, 139, 0.3);
  background: linear-gradient(135deg, var(--depth-wash), #fff);
  display: none;
  align-items: center;
  gap: 12px;
}
.done-banner.show { display: flex; animation: rise 360ms cubic-bezier(0.2, 0.7, 0.2, 1); }
.done-banner .icon { font-size: 1.5rem; }
.done-banner strong { font-family: var(--display); font-size: 1.15rem; }
.done-banner p { margin: 2px 0 0; color: var(--ink-soft); font-size: 0.92rem; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===========================================================================
   Code focus + language tabs
   =========================================================================== */
.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
}
.tab {
  border: 0;
  border-radius: 999px;
  padding: 0.44rem 0.95rem;
  background: none;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 140ms ease, color 140ms ease;
}
.tab .badge {
  margin-left: 0.4rem;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.tab[aria-selected="true"] { background: var(--sounder); color: #fff; }
.tab[aria-selected="true"] .badge { color: #fff; }

.code-panel {
  border-radius: var(--r-lg);
  background: var(--abyss);
  border: 1px solid var(--abyss);
  overflow: hidden;
}
.code-titlebar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--abyss-line);
  font-family: var(--mono);
  font-size: 0.72rem;
  color: #7fa6ab;
}
.code-titlebar .lights { display: flex; gap: 5px; }
.code-titlebar .lights i { width: 9px; height: 9px; border-radius: 50%; display: block; }
.code-titlebar .lights i:nth-child(1) { background: #e0674f; }
.code-titlebar .lights i:nth-child(2) { background: #e5b13b; }
.code-titlebar .lights i:nth-child(3) { background: var(--phosphor); }
.code-titlebar .file { margin-left: auto; }

.tabpanel[hidden] { display: none; }
.code-panel pre {
  margin: 0;
  padding: 20px 22px;
  overflow-x: auto;
  color: #dcecec;
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.72;
}
.code-panel pre .tok-key { color: #f2b45a; }
.code-panel pre .tok-fn { color: #7fc6e6; }
.code-panel pre .tok-num { color: var(--phosphor); }
.code-panel pre .tok-com { color: #6b8a90; font-style: italic; }

.code-notes { display: grid; gap: 9px; padding: 14px; }
.code-note {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.4fr);
  gap: 14px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--abyss-line);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.03);
}
.code-note > code {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: #f6d79c;
  background: none;
  padding: 0;
  word-break: break-word;
}
.code-note .note-text { color: #cfe2e2; font-size: 0.9rem; }
.code-note .note-text .define { margin-left: 0.2rem; }

.optional-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 12px;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  background: var(--depth-wash);
  color: var(--depth-deep);
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
}
.micropython-note {
  margin: 12px 2px 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* ===========================================================================
   Theory: physics of a ping
   =========================================================================== */
.theory-flow {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin: 6px 0 18px;
  counter-reset: flow;
}
.flow-step {
  position: relative;
  padding: 18px 16px 16px;
  border: 1px solid var(--line);
  background: #fff;
  counter-increment: flow;
}
.flow-step:first-child { border-radius: var(--r-lg) 0 0 var(--r-lg); }
.flow-step:last-child { border-radius: 0 var(--r-lg) var(--r-lg) 0; }
.flow-step:not(:first-child) { border-left: 0; }
.flow-step::after {
  content: "›";
  position: absolute;
  right: -9px; top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: 18px; height: 18px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--sounder);
  color: #10202a;
  font-weight: 800;
  font-size: 0.8rem;
}
.flow-step:last-child::after { display: none; }
.flow-step .n {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--depth-deep);
  font-weight: 600;
}
.flow-step .n::before { content: "0" counter(flow) " · "; }
.flow-step h3 { margin: 6px 0 5px; font-size: 1.02rem; font-family: var(--body); font-weight: 700; }
.flow-step p { margin: 0; color: var(--ink-soft); font-size: 0.86rem; }

.formula-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-radius: var(--r-lg);
  background: var(--abyss);
  color: #eaf4f4;
}
.formula-card .label {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--phosphor);
}
.formula-card code {
  font-family: var(--mono);
  font-size: clamp(1rem, 2vw, 1.25rem);
  color: #fff;
  background: none;
  padding: 0;
}
/* light accent for emphasis on the dark formula card (blue accent fails AA here) */
.formula-card code b { color: var(--phosphor); font-weight: 600; }

.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.mini-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: #fff;
}
.mini-card h3 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  font-size: 1.02rem;
  font-family: var(--body);
  font-weight: 700;
}
.mini-card p { margin: 7px 0 0; color: var(--ink-soft); font-size: 0.92rem; }

/* ===========================================================================
   Test + debug
   =========================================================================== */
.test-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.readout-title, .checks-title {
  display: block;
  margin-bottom: 10px;
  font-family: var(--body);
  font-weight: 700;
  font-size: 1.02rem;
}
.serial {
  border-radius: var(--r-lg);
  border: 1px solid var(--abyss);
  background: var(--abyss);
  overflow: hidden;
}
.serial .bar {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--abyss-line);
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #7fa6ab;
}
.serial .bar .baud { margin-left: auto; color: var(--phosphor); }
.serial .lines { display: grid; gap: 3px; padding: 14px 16px; }
.serial .lines span {
  font-family: var(--mono);
  font-size: 0.92rem;
  color: var(--phosphor);
}
.serial .lines span::before { content: "› "; color: #4d7076; }
.serial .lines span:last-child { position: relative; }
.serial .lines span:last-child::after {
  content: "";
  display: inline-block;
  width: 8px; height: 1.05em;
  margin-left: 3px;
  vertical-align: -2px;
  background: var(--phosphor);
  animation: blink 1.1s steps(1) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Visual-result panel — for days whose proof is a blink, colour, sound, or
   movement rather than Serial Monitor text. Same instrument frame, warm face. */
.observe {
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--chart);
  overflow: hidden;
}
.observe .bar {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.observe .bar::before {
  content: "";
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--sounder);
  box-shadow: 0 0 8px rgba(240, 160, 33, 0.5);
}
.observe-lines { display: grid; gap: 9px; margin: 0; padding: 14px 16px; list-style: none; }
.observe-lines li {
  position: relative;
  padding-left: 22px;
  color: var(--ink);
  font-size: 0.95rem;
}
.observe-lines li::before {
  content: "";
  position: absolute;
  left: 2px; top: 0.55em;
  width: 10px; height: 10px;
  border: 2px solid var(--sounder);
  border-radius: 50%;
}

.checklist { display: grid; gap: 9px; padding: 0; margin: 0; list-style: none; }
.checklist li {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--sounder);
  border-radius: var(--r-md);
  background: #fff;
  font-size: 0.92rem;
}
.checklist li strong { color: var(--ink); }

/* ===========================================================================
   Challenge + logbook
   =========================================================================== */
.logbook {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding: 20px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background:
    repeating-linear-gradient(180deg, transparent 0 37px, rgba(53, 87, 240, 0.06) 37px 38px),
    #fff;
}
.logbook .logbook-head {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--display);
  font-size: 1.15rem;
}
.logbook label { display: grid; gap: 6px; color: var(--ink-soft); font-weight: 600; font-size: 0.92rem; }
.logbook textarea {
  min-height: 62px;
  resize: vertical;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  padding: 11px 12px;
  background: #fffdfa;
  color: var(--ink);
  font-family: var(--body);
}
.logbook textarea:focus-visible { outline: 2px solid var(--depth); outline-offset: 1px; }

/* ===========================================================================
   Agent section
   =========================================================================== */
.agent-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 4px; }

/* ===========================================================================
   Footer / attribution
   =========================================================================== */
.colophon {
  margin-top: 26px;
  padding: 22px clamp(20px, 4vw, 34px);
  border-radius: var(--r-xl);
  border: 1px solid var(--line);
  background: var(--paper);
  color: var(--ink-faint);
  font-size: 0.82rem;
}
.colophon strong { color: var(--ink-soft); }
.colophon .rule { height: 1px; background: var(--line); margin: 14px 0; }
.colophon code { font-family: var(--mono); font-size: 0.78rem; color: var(--depth-deep); }

/* ===========================================================================
   Lightbox dialog (explainers + image zoom)
   =========================================================================== */
dialog.lightbox {
  width: min(560px, calc(100vw - 32px));
  max-height: min(84vh, 720px);
  padding: 0;
  border: 0;
  border-radius: var(--r-xl);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
dialog.lightbox::backdrop {
  background: rgba(8, 22, 30, 0.55);
  backdrop-filter: blur(3px);
}
dialog.lightbox[open] { animation: dialog-in 200ms cubic-bezier(0.2, 0.7, 0.2, 1); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(10px) scale(0.98); } to { opacity: 1; transform: none; } }

.lb-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 22px 0;
}
.lb-kicker {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--depth-deep);
}
.lb-head h3 { margin: 6px 0 0; font-size: 1.4rem; }
.lb-close {
  flex: 0 0 auto;
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #fff;
  color: var(--ink-soft);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  transition: background 130ms ease, color 130ms ease;
}
.lb-close:hover { background: var(--abyss); color: #fff; border-color: var(--abyss); }
.lb-body { padding: 14px 22px 0; color: var(--ink-soft); }
.lb-body p { margin: 0; }
.lb-shortcut {
  display: flex;
  gap: 10px;
  margin: 16px 22px 22px;
  padding: 13px 15px;
  border-radius: var(--r-md);
  background: var(--depth-wash);
  border: 1px solid rgba(14, 124, 139, 0.18);
  font-size: 0.92rem;
}
.lb-shortcut .tag {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--depth-deep);
  padding-top: 2px;
}

/* image-zoom variant */
dialog.lightbox.image { width: min(1000px, calc(100vw - 32px)); }
dialog.lightbox.image .lb-body { padding: 0; }
dialog.lightbox.image img { display: block; width: 100%; height: auto; }
dialog.lightbox.image .lb-cap {
  padding: 14px 22px 20px;
  color: var(--ink-faint);
  font-size: 0.82rem;
}
dialog.lightbox.image .lb-close {
  position: absolute; top: 14px; right: 14px; z-index: 2;
  background: rgba(11, 31, 42, 0.82); color: #fff; border-color: transparent;
}

/* ===========================================================================
   Toast
   =========================================================================== */
.toast {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translate(-50%, 20px);
  opacity: 0;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  color: #eaf4f4;
  background: var(--abyss);
  box-shadow: var(--shadow-md);
  font-size: 0.9rem;
  font-weight: 600;
  transition: opacity 180ms ease, transform 180ms ease;
  z-index: 80;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===========================================================================
   Focus visibility (accessibility floor)
   =========================================================================== */
:focus-visible { outline: 2px solid var(--depth); outline-offset: 2px; border-radius: 4px; }
.hero :focus-visible { outline-color: var(--sounder); }

/* ===========================================================================
   Responsive
   =========================================================================== */
@media (max-width: 1040px) {
  .layout { grid-template-columns: 1fr; }
  .rail { position: static; }
  .rail-nav { grid-template-columns: repeat(2, 1fr); display: grid; gap: 2px; }
}
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 26px; }
  .part-grid { grid-template-columns: repeat(2, 1fr); }
  .wire-layout, .test-grid, .two-col, .agent-grid { grid-template-columns: 1fr; }
  .theory-flow { grid-template-columns: 1fr 1fr; }
  .flow-step { border-radius: var(--r-md) !important; border-left: 1px solid var(--line) !important; }
  .flow-step::after { display: none; }
  .code-note { grid-template-columns: 1fr; gap: 6px; }
  .rail-nav { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .part-grid { grid-template-columns: 1fr; }
  .theory-flow { grid-template-columns: 1fr; }
  .pin-row { grid-template-columns: auto 1fr; }
  .pin-why { grid-column: 1 / -1; }
  .sounder-readout .value { font-size: 1.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .ping { display: none; }
  .serial .lines span:last-child::after { animation: none; opacity: 1; }
}

/* ===========================================================================
   Course map (the voyage) + cross-page nav — added when the prototype was
   productised. Reuses the same tokens as the lesson pages.
   =========================================================================== */
.map-hero { grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.7fr); }
.map-hero h1 { font-size: clamp(2.5rem, 5.8vw, 4.2rem); }
.map-hero h1 em { font-style: normal; color: var(--sounder); }

.pill.pill-link {
  text-decoration: none;
  cursor: pointer;
}
.pill.pill-link:hover { background: var(--depth-wash); color: var(--depth-deep); border-color: color-mix(in srgb, var(--sounder) 35%, var(--line)); }

/* voyage progress card on the map hero */
.map-progress {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.map-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 15px;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.map-progress-head .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--sounder);
  animation: pulse-dot 2.4s ease-in-out infinite;
}
.map-progress-body { display: grid; gap: 12px; padding: 18px 16px; }
.map-progress-count { font-family: var(--mono); font-size: 0.95rem; color: var(--ink-soft); }
.map-progress-count b { color: var(--sounder); font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.map-progress .voyage { margin: 0; background: var(--surface-2, var(--line)); }
.map-progress .voyage span { width: 0%; transition: width 400ms ease; }
.map-resume {
  justify-self: start;
  padding: 0.5rem 0.9rem;
  border-radius: var(--r-md);
  background: var(--sounder);
  color: #fff;
  font-weight: 600;
  text-decoration: none;
}
.map-resume:hover { background: var(--sounder-deep); color: #fff; }

.course-body { margin-top: 30px; display: grid; gap: 30px; }
.map-note { margin: 0; }

.arc { display: grid; gap: 16px; }
.arc-head h2 { font-size: clamp(1.5rem, 3vw, 2rem); }
.arc-head p { margin: 6px 0 0; color: var(--ink-soft); max-width: 60ch; }

.day-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 14px;
}
.day-tile {
  position: relative;
  display: grid;
  gap: 6px;
  padding: 16px 16px 15px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: #fff;
  text-decoration: none;
  color: var(--ink);
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}
.day-tile.is-ready:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.day-tile-num {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--depth-deep);
}
.day-tile-title { font-family: var(--display); font-size: 1.08rem; line-height: 1.18; }
.day-tile-meta {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.04em;
  color: var(--ink-faint);
}
.day-tile.is-upcoming { background: var(--chart); border-style: dashed; color: var(--ink-soft); }
.day-tile.is-upcoming .day-tile-title { color: var(--ink-soft); }
/* completion tick (added by course.js when a day is finished) */
.day-tile-tick {
  position: absolute;
  top: 14px; right: 14px;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--line-strong);
  background: #fff;
  transition: all 150ms ease;
}
.day-tile.is-done { border-color: rgba(14, 124, 139, 0.35); background: var(--depth-wash); }
.day-tile.is-done .day-tile-tick {
  border-color: var(--depth);
  background: var(--depth);
}
.day-tile.is-done .day-tile-tick::after {
  content: "✓";
  display: grid; place-items: center;
  color: #fff; font-size: 0.7rem; font-weight: 700;
  width: 100%; height: 100%;
}

/* prev / next day navigation at the foot of a lesson */
.day-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 2px;
}
.day-nav-link {
  display: grid;
  gap: 4px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--paper);
  text-decoration: none;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease;
}
.day-nav-link.next { text-align: right; }
.day-nav-link.is-empty { border: 0; background: none; box-shadow: none; }
.day-nav-link:not(.is-empty):hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.day-nav-dir {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  color: var(--depth-deep);
  font-weight: 600;
}
.day-nav-title { font-family: var(--display); font-size: 1.05rem; }

@media (max-width: 860px) {
  .map-hero { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .day-nav { grid-template-columns: 1fr; }
  .day-nav-link.next { text-align: left; }
}
