/* Machine Learning, Explained — shared styles (phone first). */

:root {
  --bg: #faf8f4;
  --surface: #ffffff;
  --surface-2: #f2efe8;
  --ink: #1c1b19;
  --ink-2: #57534c;
  --line: #e4dfd5;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --accent-soft: #e0f2ef;
  --cold: #2563eb;
  --cold-soft: #e3ecfd;
  --warm: #d9650b;
  --warm-soft: #fdeede;
  --fixed: #78716c;
  --good: #15803d;
  --good-soft: #e3f4e8;
  --bad: #b91c1c;
  --bad-soft: #fbe6e6;
  --radius: 16px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 4px 16px rgb(0 0 0 / 0.05);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151412;
    --surface: #1f1e1b;
    --surface-2: #29271f;
    --ink: #f3f0ea;
    --ink-2: #b5aea2;
    --line: #37342d;
    --accent: #2dd4bf;
    --accent-ink: #0b2622;
    --accent-soft: #123330;
    --cold: #6b9bff;
    --cold-soft: #1a2640;
    --warm: #f59a45;
    --warm-soft: #3a2615;
    --fixed: #a8a29e;
    --good: #4ade80;
    --good-soft: #13301d;
    --bad: #f87171;
    --bad-soft: #3a1717;
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 18px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
}

img, svg { max-width: 100%; display: block; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.6em; letter-spacing: -0.01em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.55rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
ul, ol { margin: 0 0 1em; padding-left: 1.2em; }
strong { font-weight: 650; }
a { color: var(--accent); }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 6px; }
h2:focus { outline: none; }

/* Elements hidden with the hidden attribute stay hidden, even ones styled with display (like .btn). */
[hidden] { display: none !important; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.wrap { max-width: 34rem; margin: 0 auto; padding: 0 16px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding-top: env(safe-area-inset-top);
}
.topbar-row {
  display: flex; align-items: center; gap: 12px;
  min-height: 56px;
}
.topbar-title { flex: 1; font-size: 0.95rem; font-weight: 600; color: var(--ink-2); margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 44px; height: 44px; margin-left: -10px;
  border-radius: 999px; color: var(--ink); text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); }

.lang-switch {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2); border-radius: 999px;
}
.lang-switch button {
  font: 600 0.85rem/1 var(--font);
  min-width: 44px; min-height: 36px; padding: 0 10px;
  border: 0; border-radius: 999px; background: transparent; color: var(--ink-2);
  cursor: pointer;
}
.lang-switch button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.progress { height: 4px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: inherit; transition: width 0.3s ease; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 22px;
  font: 600 1rem/1.2 var(--font);
  border-radius: 999px; border: 1.5px solid transparent;
  cursor: pointer; text-decoration: none; text-align: center;
  touch-action: manipulation;
}
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-small { min-height: 44px; padding: 0 16px; font-size: 0.95rem; }
.btn[disabled] { opacity: 0.45; cursor: default; }
.btn-block { width: 100%; }

/* ---------- Cards and blocks ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px; margin: 0 0 16px;
  box-shadow: var(--shadow);
}
.card > :last-child { margin-bottom: 0; }

.chip {
  display: inline-block; padding: 4px 12px; margin-bottom: 12px;
  font-size: 0.8rem; font-weight: 650; letter-spacing: 0.02em;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}
.chip[data-part="play"] { background: var(--warm-soft); color: var(--warm); }
.chip[data-part="check"] { background: var(--cold-soft); color: var(--cold); }
.chip[data-part="video"] { background: var(--surface-2); color: var(--ink); }

.lead { font-size: 1.1rem; color: var(--ink-2); }
.muted { color: var(--ink-2); }
.small { font-size: 0.9rem; }

.callout {
  border-left: 4px solid var(--accent); background: var(--accent-soft);
  padding: 14px 16px; border-radius: 0 12px 12px 0; margin: 0 0 1em;
}
.callout > :last-child { margin-bottom: 0; }

.note {
  background: var(--surface-2); border-radius: 12px; padding: 14px 16px; margin: 0 0 1em;
  font-size: 0.95rem;
}
.note > :last-child { margin-bottom: 0; }

details.curious {
  border: 1px dashed var(--line); border-radius: 12px; padding: 0 16px; margin: 0 0 1em;
  font-size: 0.95rem;
}
details.curious summary {
  cursor: pointer; font-weight: 600; min-height: 48px; display: flex; align-items: center;
  list-style: none; color: var(--ink-2);
}
details.curious summary::-webkit-details-marker { display: none; }
details.curious summary::before { content: "+"; width: 1.2em; font-weight: 700; color: var(--accent); }
details.curious[open] summary::before { content: "–"; }
details.curious[open] { padding-bottom: 14px; }

.icon-list { list-style: none; padding: 0; }
.icon-list li { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; }
.icon-list .ic {
  flex: none; width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center; background: var(--surface-2); font-size: 1.1rem; line-height: 1;
}

/* ---------- Home ---------- */
.hero { padding: 20px 0 8px; }
.eyebrow { font-size: 0.85rem; font-weight: 650; color: var(--accent); letter-spacing: 0.03em; text-transform: uppercase; margin-bottom: 8px; }

.lesson-card { display: block; text-decoration: none; color: inherit; }
.lesson-card .num { font-size: 0.85rem; font-weight: 700; color: var(--accent); }
.lesson-card h3 { font-size: 1.25rem; margin: 4px 0 6px; }
.lesson-card .meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 0.9rem; color: var(--ink-2); margin-bottom: 14px; }
.badge-done { color: var(--good); font-weight: 650; }

.stage { margin: 28px 0 8px; }
.stage h3 { margin-bottom: 4px; }
.stage-num { font-size: 0.8rem; font-weight: 700; color: var(--ink-2); letter-spacing: 0.04em; text-transform: uppercase; }
.lesson-list { list-style: none; padding: 0; margin: 10px 0 0; }
.lesson-list li {
  display: flex; gap: 12px; align-items: baseline; padding: 10px 0;
  border-top: 1px solid var(--line); font-size: 0.98rem;
}
.lesson-list .n { flex: none; width: 1.8em; font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 0.85rem; }
.lesson-list .soon { color: var(--ink-2); }
.lesson-list a { color: var(--ink); font-weight: 600; }

.site-footer { padding: 32px 0 48px; font-size: 0.85rem; color: var(--ink-2); }

/* ---------- Lesson stepper ---------- */
.lesson main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.step { padding: 20px 0 8px; }
.step[hidden] { display: none; }
.js .step:not(.is-active) { display: none; }

.stepnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  padding: 10px 0 calc(10px + env(safe-area-inset-bottom));
}
.stepnav .wrap { display: flex; gap: 12px; }
.stepnav .btn-ghost { flex: 0 0 auto; }
.stepnav .btn-primary { flex: 1; }

/* ---------- Illustrations ---------- */
.figure { margin: 0 0 1.2em; }
.figure figcaption { font-size: 0.9rem; color: var(--ink-2); margin-top: 8px; text-align: center; }

.tomatoes { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; text-align: center; }
.tomatoes svg { width: 100%; max-width: 64px; margin: 0 auto 6px; }
.tomatoes span { font-size: 0.78rem; color: var(--ink-2); line-height: 1.25; display: block; }
.tomatoes .q span { color: var(--accent); font-weight: 700; }

.flow { display: flex; flex-direction: column; align-items: stretch; gap: 0; }
.flow-box {
  border-radius: 12px; padding: 10px 14px; background: var(--surface-2);
  font-size: 0.95rem; text-align: center;
}
.flow-box.rule { background: var(--accent-soft); color: var(--ink); font-weight: 650; }
.flow-arrow { text-align: center; color: var(--ink-2); line-height: 1; padding: 4px 0; font-size: 1.1rem; }
.ex-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.ex { font-size: 0.85rem; font-weight: 600; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.ex.cold { background: var(--cold-soft); color: var(--cold); }
.ex.warm { background: var(--warm-soft); color: var(--warm); }

.roadmap { list-style: none; padding: 0; margin: 0 0 1em; position: relative; }
.roadmap li { position: relative; padding: 0 0 18px 34px; }
.roadmap li::before {
  content: ""; position: absolute; left: 7px; top: 22px; bottom: -4px; width: 2px; background: var(--line);
}
.roadmap li:last-child::before { display: none; }
.roadmap .dot {
  position: absolute; left: 0; top: 5px; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--line); background: var(--surface);
}
.roadmap li.here .dot { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.roadmap strong { display: block; }
.roadmap p { margin: 2px 0 0; font-size: 0.92rem; color: var(--ink-2); }
.here-tag { display: inline-block; margin-left: 6px; font-size: 0.75rem; font-weight: 700; color: var(--accent); vertical-align: 1px; }

.recap { list-style: none; padding: 0; }
.recap li { position: relative; padding: 10px 0 10px 34px; border-top: 1px solid var(--line); }
.recap li:first-child { border-top: 0; }
.recap li::before {
  content: "✓"; position: absolute; left: 0; top: 11px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-size: 0.8rem; font-weight: 800;
  display: grid; place-items: center;
}

/* ---------- Choice questions (predict + check) ---------- */
.choices { display: grid; gap: 10px; margin: 12px 0 0; }
.choice {
  width: 100%; min-height: 52px; padding: 12px 16px;
  font: 500 1rem/1.35 var(--font); text-align: left; color: var(--ink);
  background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px;
  cursor: pointer; touch-action: manipulation;
}
.choice:hover { border-color: var(--ink-2); }
.choice[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.choice.is-right { border-color: var(--good); background: var(--good-soft); }
.choice.is-wrong { border-color: var(--bad); background: var(--bad-soft); }
.feedback { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface-2); font-size: 0.95rem; }
.feedback:empty { display: none; }
.feedback.good { background: var(--good-soft); }
.feedback.bad { background: var(--bad-soft); }
.q-title { font-weight: 650; margin-bottom: 4px; }
.q-num { font-size: 0.8rem; font-weight: 700; color: var(--ink-2); }

/* ---------- Recap video ---------- */
.video { display: block; width: 100%; aspect-ratio: 4 / 5; margin: 0 0 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); box-shadow: var(--shadow); }
#transcript p { margin: 0 0 0.6em; }

/* ---------- Activity ---------- */
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px;
  padding: 4px; background: var(--surface-2); border-radius: 14px; margin-bottom: 14px;
}
.seg button {
  min-height: 48px; padding: 6px 8px; border: 0; border-radius: 10px;
  font: 600 0.95rem/1.2 var(--font); color: var(--ink-2); background: transparent; cursor: pointer;
}
.seg button small { display: block; font-weight: 500; font-size: 0.78rem; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.chart { width: 100%; height: auto; touch-action: pan-y; cursor: pointer; user-select: none; -webkit-user-select: none; }
.chart text { font-family: var(--font); fill: var(--ink-2); }
.chart .axis { stroke: var(--line); stroke-width: 2; }
.chart .tick { stroke: var(--line); }
.chart .row-label { font-size: 12px; font-weight: 650; }
.chart .dot-cold { fill: var(--cold); }
.chart .dot-warm { fill: var(--warm); }
.chart .dot-new { stroke: var(--ink); stroke-width: 2; }
.chart .fixed-line { stroke: var(--fixed); stroke-width: 2.5; stroke-dasharray: 5 4; }
.chart .learned-line { stroke: var(--accent); stroke-width: 3; }
.chart .fixed-label { fill: var(--fixed); font-size: 12px; font-weight: 700; }
.chart .learned-label { fill: var(--accent); font-size: 12px; font-weight: 700; }
.chart .test-line { stroke: var(--ink); stroke-width: 1.5; opacity: 0.35; }
.chart .test-mark { fill: var(--ink); }
.chart .test-label { fill: var(--ink); font-size: 12px; font-weight: 700; }
.chart .lines { transition: transform 0.35s ease; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.85rem; color: var(--ink-2); margin: 4px 0 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.sw.cold { background: var(--cold); }
.sw.warm { background: var(--warm); }
.sw.fixed { width: 16px; height: 0; border-radius: 0; border-top: 2.5px dashed var(--fixed); }
.sw.learned { width: 16px; height: 3px; border-radius: 0; background: var(--accent); }
.sw.newday { background: var(--ink); }

.score { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 14px; }
.score div { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.score .lbl { font-size: 0.8rem; color: var(--ink-2); display: block; line-height: 1.3; }
.score .val { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.score .fixed-c .val { color: var(--fixed); }
.score .learned-c .val { color: var(--accent); }

.slider-row { margin: 6px 0 12px; }
.slider-row label { display: flex; justify-content: space-between; font-weight: 600; font-size: 0.95rem; margin-bottom: 4px; }
.slider-row output { font-variant-numeric: tabular-nums; }
input[type="range"] {
  width: 100%; height: 44px; margin: 0; background: transparent; accent-color: var(--accent);
  touch-action: pan-y;
}

.verdicts { list-style: none; padding: 0; margin: 0 0 14px; }
.verdicts li {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 10px 0; border-top: 1px solid var(--line); font-size: 0.95rem;
}
.verdicts li:first-child { border-top: 0; }
.verdicts .who { color: var(--ink-2); }
.verdicts .say { font-weight: 650; text-align: right; }
.verdicts .mark { display: inline-block; width: 1.4em; text-align: center; font-weight: 800; }
.verdicts .mark.ok { color: var(--good); }
.verdicts .mark.no { color: var(--bad); }
.verdicts li.truth { background: var(--surface-2); margin: 4px -12px 0; padding: 10px 12px; border-radius: 10px; border-top: 0; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.actions .btn { flex: 1 1 auto; }

.live-msg { font-size: 0.92rem; color: var(--accent); font-weight: 600; min-height: 1.4em; margin: 8px 0 0; }

.done-hero { text-align: center; padding-top: 20px; }
.done-badge {
  width: 84px; height: 84px; margin: 0 auto 16px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 2.4rem; font-weight: 800;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* ---------- Examples, features and labels (Lesson 02) ---------- */
.melon-slot svg { width: 100%; height: auto; }
.melon-hero .melon-slot { max-width: 200px; margin: 0 auto; }

.ex-card { padding: 16px; }
.ex-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.ex-card-head .melon-slot { width: 56px; flex: none; }
.ex-group { border-radius: 12px; padding: 10px 12px 8px; margin-top: 10px; position: relative; }
.ex-group.features { background: var(--surface-2); }
.ex-group.label { background: var(--accent-soft); }
.ex-tag { display: block; font-size: 0.78rem; font-weight: 750; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-2); margin-bottom: 4px; }
.ex-group.label .ex-tag { color: var(--accent); }
.ex-card dl, .mess-card dl { margin: 0; }
.ex-card dl div, .mess-card dl div { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; font-size: 0.95rem; }
.ex-card dt, .mess-card dt { color: var(--ink-2); }
.ex-card dd, .mess-card dd { margin: 0; font-weight: 650; text-align: right; }

.clue-list { list-style: none; padding: 6px 16px; }
.clue-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 0.95rem; }
.clue-list li:first-child { border-top: 0; }
.verdict { flex: none; font-size: 0.8rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.verdict.good { background: var(--good-soft); color: var(--good); }
.verdict.none { background: var(--surface-2); color: var(--ink-2); }

.stalls { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 1em; }
.stall { margin: 0; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.stall.empty { border-style: dashed; box-shadow: none; }
.stall-melons { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; min-height: 48px; }
.stall-melons .melon-slot { width: 30px; }
.stall-melons .more { font-size: 0.8rem; font-weight: 700; color: var(--ink-2); margin-left: 4px; }
.stall-melons.q { position: relative; }
.stall-melons.q .melon-slot { width: 48px; opacity: 0.8; }
.stall-melons .qmark { font-size: 1.6rem; font-weight: 800; color: var(--accent); margin-left: 6px; }

.messy { display: grid; gap: 10px; margin-bottom: 1em; }
.mess-card { margin: 0; padding: 12px 16px; }
.mess-card .bad-cell { background: var(--bad-soft); margin: 0 -8px; padding: 5px 8px; border-radius: 8px; }
.mess-card .bad-cell dd { color: var(--bad); }
.mess-note { font-size: 0.88rem; color: var(--bad); margin: 6px 0 0; font-weight: 600; }

/* Activity: clue toggles, melon grid, goals */
.toggles { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.toggle {
  min-height: 44px; padding: 0 16px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--ink);
  font: 600 0.95rem/1.2 var(--font); touch-action: manipulation;
}
.toggle::before { content: "+ "; color: var(--ink-2); }
.toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.toggle[aria-pressed="true"]::before { content: "✓ "; color: inherit; }
.card h3 { font-size: 1rem; margin-bottom: 10px; }
.seg + .seg { margin-top: -6px; }
/* Lesson 05: four flexibility choices; Greek labels need two columns on phones. */
#flex { grid-auto-flow: row; grid-template-columns: 1fr 1fr; }

.score3 { grid-template-columns: repeat(3, 1fr); }
.score3 .ok-c .val { color: var(--good); }
.score3 .no-c .val { color: var(--bad); }
.score3 .q-c .val { color: var(--ink-2); }

.melon-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 10px; }
.melon-tile {
  min-width: 0;
  position: relative; aspect-ratio: 1; padding: 6px 4px 10px; cursor: pointer;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink-2);
  touch-action: manipulation;
}
.melon-tile.is-selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.melon-tile svg { width: 100%; height: auto; }
.melon-tile .stall-tag { position: absolute; left: 6px; top: 4px; font-size: 0.72rem; font-weight: 800; }
.melon-tile .res {
  position: absolute; right: 4px; top: 4px; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center; font-size: 0.75rem; font-weight: 800; color: #fff;
}
.melon-tile .res.ok { background: var(--good); }
.melon-tile .res.no { background: var(--bad); }
.melon-tile .res.q { background: var(--ink-2); }
.melon-tile .sound { position: absolute; left: 6px; bottom: 4px; width: 20px; color: var(--accent); }
.melon-tile .waves { width: 100%; height: auto; display: block; }
.melon-detail { min-height: 1.6em; font-weight: 600; }

.tries { list-style: none; padding: 0; margin: 0 0 12px; }
.tries li { display: flex; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 0.95rem; }
.tries li:first-child { border-top: 0; }
.tries .tick {
  flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
  font-size: 0.8rem; font-weight: 800; background: var(--surface-2); color: var(--ink-2);
}
.tries li.is-done .tick { background: var(--good); color: #fff; }
.tries small { display: block; color: var(--good); font-weight: 600; margin-top: 4px; font-size: 0.88rem; }

/* ---------- Similarity maps (Lesson 03) ---------- */
.knn-map { width: 100%; height: auto; display: block; }
.knn-map .plot-bg { fill: var(--surface-2); }
.knn-map .z-warm { fill: var(--warm-soft); }
.knn-map .z-cold { fill: var(--cold-soft); }
.knn-map .axis-l { stroke: var(--ink-2); stroke-width: 1.2; opacity: 0.5; }
.knn-map .tick-t { font: 10px var(--font); fill: var(--ink-2); }
.knn-map .axis-t { font: 600 11px var(--font); fill: var(--ink-2); }
.knn-map .d-warm { fill: var(--warm); stroke: var(--surface); stroke-width: 1.5; }
.knn-map .d-cold { fill: var(--cold); stroke: var(--surface); stroke-width: 1.5; }
.knn-map .d-nb { stroke: var(--ink); stroke-width: 2.2; }
.knn-map .nb-line { stroke: var(--ink); stroke-width: 1.4; stroke-dasharray: 3 3; opacity: 0.7; }
.knn-map .new-pin circle { fill: var(--surface); stroke-width: 3.5; }
.knn-map .new-pin.v-warm circle { stroke: var(--warm); }
.knn-map .new-pin.v-cold circle { stroke: var(--cold); }
.knn-map .new-pin .pin-core { fill: var(--ink); stroke: none; }
.map-live { touch-action: none; cursor: crosshair; user-select: none; -webkit-user-select: none; margin: 0 -6px; }
.map-pair { display: grid; grid-template-columns: 1fr; gap: 0; }
.map-pair .figure { margin-bottom: 12px; }
.sw.newm { background: var(--surface); border: 3px solid var(--ink-2); width: 14px; height: 14px; }
.verdict-box { border-radius: 12px; padding: 10px 14px; margin: 0 0 12px; font-size: 0.95rem; }
.verdict-box.v-warm { background: var(--warm-soft); }
.verdict-box.v-cold { background: var(--cold-soft); }

/* ---------- Trend lines (Lesson 04) ---------- */
.fit-chart .grid { stroke: var(--line); stroke-width: 1; }
.fit-chart .ride { fill: var(--warm); stroke: var(--surface); stroke-width: 1.5; }
.fit-chart .fit-line { stroke: var(--accent); stroke-width: 3; stroke-linecap: round; }
.fit-chart .gap { stroke: var(--bad); stroke-width: 2.4; }
.fit-chart .handle { fill: var(--surface); stroke: var(--accent); stroke-width: 3; }
.fit-chart .cand-a { stroke: var(--warm); stroke-width: 2.5; }
.fit-chart .cand-b { stroke: var(--accent); stroke-width: 3; }
.fit-chart .cand-c { stroke: var(--fixed); stroke-width: 2.5; stroke-dasharray: 5 4; }
.fit-chart .cand-t { font: 800 14px var(--font); paint-order: stroke; stroke: var(--surface-2); stroke-width: 4px; stroke-linejoin: round; }
.fit-chart .cand-t.a { fill: var(--warm); }
.fit-chart .cand-t.b { fill: var(--accent); }
.fit-chart .cand-t.c { fill: var(--fixed); }
.fit-chart .ring { fill: none; stroke: var(--warm); stroke-width: 2; }
.fit-chart .guide { stroke: var(--ink-2); stroke-width: 1.2; stroke-dasharray: 3 3; }
.fit-chart .anno { font: 650 11px var(--font); fill: var(--ink); paint-order: stroke; stroke: var(--surface-2); stroke-width: 3px; stroke-linejoin: round; }
.fit-chart .anno-teal { fill: var(--accent); }
.fit-chart .anno-dot { fill: var(--accent); }
#fig-predict { margin: 10px -6px 0; }
.sw.gap { width: 3px; height: 14px; border-radius: 0; background: var(--bad); }
.loop-list { padding-left: 1.4em; }
.loop-list li { margin: 4px 0; padding-left: 4px; }
.err-trail {
  display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; justify-content: center;
  margin: 10px 0 0; font-size: 0.85rem; font-variant-numeric: tabular-nums;
}
.err-trail:empty { display: none; }
.err-trail .e { padding: 2px 8px; border-radius: 999px; background: var(--bad-soft); color: var(--bad); font-weight: 650; white-space: nowrap; }
.err-trail .e.last { background: var(--good-soft); color: var(--good); }
.err-trail .arr { color: var(--ink-2); }
#trail { margin: -4px 0 12px; }
.score .miss-c .val { color: var(--bad); }
.score .miss-c.is-good .val { color: var(--good); }

/* ---------- Training and test sets (Lesson 05) ---------- */
.fit-chart polyline { fill: none; stroke-linejoin: round; }
.fit-chart .test-ring { fill: var(--surface); stroke: var(--cold); stroke-width: 2.5; }
.fit-chart .bar-train { fill: var(--warm); }
.fit-chart .bar-test { fill: var(--cold); }
.fit-chart .bar-v { font: 650 9px var(--font); fill: var(--ink-2); }
.sw.ring-cold { background: var(--surface); border: 2.5px solid var(--cold); width: 13px; height: 13px; }
.sw.sq { border-radius: 3px; }
.legend-center { justify-content: center; margin-top: 8px; }
.score .train-c .val { color: var(--warm); }
.score .test-c .val { color: var(--cold); }

/* ---------- Scores and thresholds (Lesson 06) ---------- */
.kind-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 1em; }
.kind-card { margin: 0; padding: 14px; text-align: center; display: flex; flex-direction: column; gap: 6px; }
.kind-card p { margin: 0; }
.kind-q { font-size: 0.9rem; color: var(--ink-2); line-height: 1.35; flex: 1; }
.kind-a { font-size: 1.4rem; font-weight: 800; border-radius: 10px; padding: 4px 0; }
.kind-a.num { background: var(--accent-soft); color: var(--accent); }
.kind-a.cat { background: var(--warm-soft); color: var(--warm); }
.kind-t { font-size: 0.8rem; font-weight: 700; color: var(--ink-2); }
.score-line .folder { fill: var(--warm-soft); }
.score-line .row-l { stroke: var(--line); stroke-width: 1.5; }
.score-line .row-t { font: 650 11px var(--font); fill: var(--ink-2); }
.score-line .miss-ring { fill: none; stroke: var(--bad); stroke-width: 2.5; }
.score-line .th-line { stroke: var(--ink); stroke-width: 2; stroke-dasharray: 4 3; }
.score-line .th-knob { fill: var(--surface); stroke: var(--ink); stroke-width: 2.5; }
.fit-chart .anno-bad { fill: var(--bad); }
.sw.folder { border-radius: 3px; background: var(--warm-soft); border: 1px solid var(--warm); }
.sw.ring { background: none; border: 2.5px solid var(--bad); width: 14px; height: 14px; }
.score4 .ok-c .val { color: var(--good); }
.score4 .no-c .val { color: var(--bad); }
.ic.mk-fa, .ic.mk-miss { position: relative; }
.ic.mk-fa::after, .ic.mk-miss::after {
  content: ""; width: 12px; height: 12px; border-radius: 50%; background: var(--cold);
  box-shadow: 0 0 0 3px var(--surface-2), 0 0 0 5.5px var(--bad);
}
.ic.mk-miss::after { background: var(--warm); }
.mistake-list { list-style: none; padding: 0; margin: 0; }
.mistake-list li { display: flex; gap: 10px; align-items: baseline; padding: 8px 0; border-top: 1px solid var(--line); font-size: 0.92rem; }
.mistake-list li:first-child { border-top: 0; }
.mistake-list .verdict { white-space: nowrap; }
.verdict.bad-tag { background: var(--bad-soft); color: var(--bad); }

/* ---------- Decision trees (Lesson 07) ---------- */
.knn-map .cut { stroke: var(--ink); stroke-width: 2; }
.knn-map .new-ring { fill: var(--surface); stroke-width: 2.5; }
.knn-map .new-ring.cold { stroke: var(--cold); }
.knn-map .new-ring.warm { stroke: var(--warm); }
.sw.ring-ink { background: var(--surface); border: 2.5px solid var(--ink-2); width: 13px; height: 13px; }
.map-live.tap-only { touch-action: manipulation; cursor: pointer; }
.tree-box { margin: 4px 0 12px; overflow-x: auto; }
.tree-box:empty { display: none; }
.t-node { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.t-q {
  background: var(--accent-soft); color: var(--ink); font-weight: 700; font-size: 0.85rem; line-height: 1.25;
  border-radius: 10px; padding: 6px 10px; text-align: center;
}
.t-kids { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: 100%; position: relative; }
.t-kids::before { content: ""; position: absolute; top: -6px; left: 25%; right: 25%; border-top: 2px solid var(--line); }
.t-kid { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 0; }
.t-edge { font-size: 0.75rem; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.03em; }
.t-leaf { border-radius: 10px; padding: 6px 6px; text-align: center; width: 100%; font-size: 0.82rem; line-height: 1.25; }
.t-leaf strong { display: block; }
.t-leaf.sail { background: var(--cold-soft); }
.t-leaf.cancel { background: var(--warm-soft); }
.t-count { font-variant-numeric: tabular-nums; color: var(--ink-2); }
.t-count .c { color: var(--cold); }
.t-count .w { color: var(--warm); }
.tree-key { margin: 8px 0 0; font-size: 0.82rem; color: var(--ink-2); text-align: center; }
.tree-key .c { color: var(--cold); }
.tree-key .w { color: var(--warm); }
.seg-days { margin-top: 10px; }
.t-kid .t-node .t-q { font-size: 0.78rem; padding: 5px 6px; }
