@font-face {
  font-family: Nunito;
  font-style: normal;
  font-display: swap;
  font-weight: 200 1000;
  src: url("fonts/nunito-latin-ext-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: Nunito;
  font-style: normal;
  font-display: swap;
  font-weight: 200 1000;
  src: url("fonts/nunito-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --page: #E9EDF1;      /* behind everything, on every page */
  --bg: #EFF2F5;
  --panel: #F8FAFC;
  --panel-2: #EEF1F5;
  --border: #D3DAE2;
  --text: #1C2530;
  --body: #364250;
  --muted: #586474;
  --faint: #586474;
  --brand: #3A9A94;      /* logo, icons, details: never behind or as body text */
  --accent: #0F6B6B;     /* links, hovers, filled buttons */
  --accent-hover: #0B5555;
  --pos: #2762BC;
  --num: #9A4416;
  --pass: #256843;
  --fail: #AB3227;
  --warn: #7D5800;
  --shadow: #1C2530;
  --band: #1C2530;       /* the landing page's dark band */
  --r-card: 20px;
  --r-inner: 14px;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, ui-monospace, monospace;
  --sans: Nunito, "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --page: #0F1419;
  --bg: #151B22;
  --panel: #1C232C;
  --panel-2: #242C36;
  --border: #36404C;
  --text: #E6EBF0;
  --body: #C7CFD8;
  --muted: #9AA5B1;
  --faint: #9AA5B1;
  --brand: #4FB0A9;
  --accent: #5CC8C0;
  --accent-hover: #84DAD3;
  --pos: #7AA9F0;
  --num: #EFAA80;
  --pass: #79CB9C;
  --fail: #F0948A;
  --warn: #E0B95E;
  --shadow: #000000;
  --band: #0A0E12;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--page);
  color: var(--text);
  font: 15px/1.5 var(--sans);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
button, select, input { font: inherit; color: inherit; }
a { color: var(--accent); }

/* ---------- scrollbars: a slim rounded thumb on no track, in both themes ---------- */
@supports selector(::-webkit-scrollbar) {
  ::-webkit-scrollbar { width: 12px; height: 12px; }
  ::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
  ::-webkit-scrollbar-thumb {
    border: 3px solid transparent;
    border-radius: 999px;
    background: color-mix(in srgb, var(--muted) 45%, transparent) padding-box;
  }
  ::-webkit-scrollbar-thumb:hover { background-color: color-mix(in srgb, var(--muted) 70%, transparent); }
  ::-webkit-scrollbar-thumb:active { background-color: var(--accent); }
}
@supports not selector(::-webkit-scrollbar) {
  * { scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--muted) 45%, transparent) transparent; }
}
.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler { background: transparent; }
/* Icons from src/icons.svg (src/icons.js): the size and colour of the text around them. */
.icon {
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
svg.icon { width: 1em; height: 1em; vertical-align: -0.14em; flex-shrink: 0; overflow: visible; }
kbd .icon { vertical-align: -0.2em; }
.icon-btn, .fb-vote, .fb-offer-x, .notice-close { display: inline-flex; align-items: center; justify-content: center; }
.btn.play .icon { vertical-align: -0.12em; }

kbd {
  font: 11px var(--mono);
  padding: 1px 4px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--text) 8%, transparent);
  margin-left: 6px;
}
.btn.primary:not(:disabled) kbd { background: var(--accent-hover); } /* a lighter tint drops "Ctrl" below 4.5:1 */

/* ---------- text selection ----------
 * Interface chrome and visualizations aren't text to copy, so a click-drag
 * over them shouldn't select anything. The description, the code, test
 * messages, output and error messages stay selectable. */
.topbar, .panel-head, .viz-root, .drawer, .modal {
  -webkit-user-select: none;
  user-select: none;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  height: 52px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  flex: none;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: 0.2px; color: var(--text); text-decoration: none; }
a.brand:hover { color: var(--accent); }
/* Tracks in the Challenge list (landing page and drawer) */
.track + .track { margin-top: 22px; }
.track-head { margin: 0 0 2px; font-size: 15px; font-weight: 650; display: flex; align-items: center; gap: 8px; }
.track-summary { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.track.empty .track-head { color: var(--muted); }
.track-planned { margin: 0; color: var(--muted); opacity: 0.7; font-size: 13px; }
/* Learn more, under a Description */
.learn-more { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--border); }
.learn-more h3 { margin: 0 0 8px; font-size: 14px; }
.learn-more ul { margin: 0; padding-left: 18px; }
.learn-more li { margin: 4px 0; }
.learn-more .note { display: block; color: var(--muted); font-size: 13px; }
/* the Beta label next to the name, until the public launch (X); it opens the feedback dialog */
.beta-tag {
  margin-left: -6px;
  padding: 1px 7px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  color: var(--text);
  font: inherit; font-size: 11px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase;
  cursor: pointer;
}
.beta-tag:hover { background: color-mix(in srgb, var(--accent) 20%, transparent); }
.logo {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--brand), var(--accent) 70%);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent);
}
.challenge-nav { display: flex; align-items: center; gap: 6px; margin-left: 12px; }
.drawer-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 14px;
  min-width: 240px;
  height: 32px;
  cursor: pointer;
  text-align: left;
}
.drawer-btn:hover { border-color: var(--accent); }
.drawer-btn .burger { color: var(--muted); }
.drawer-btn #current-title { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 32px; height: 32px;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
}
.icon-btn:hover { border-color: var(--accent); color: var(--text); }
.status { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.status[data-state="ready"] .dot { background: var(--pass); }
.status[data-state="running"] .dot { background: var(--accent); animation: pulse 0.8s ease-in-out infinite alternate; }
.status[data-state="loading"] .dot { animation: pulse 0.8s ease-in-out infinite alternate; }
.status[data-state="fatal"] .dot { background: var(--fail); }
@keyframes pulse { from { opacity: 0.35; } to { opacity: 1; } }

/* ---------- workspace: panels and gutters ---------- */
[hidden] { display: none !important; }
.workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  padding: 8px;
  background: var(--page);
}
.col { min-width: 320px; min-height: 0; }
.col-viz { order: 0; }
.gutter-col { order: 1; }
.col-work { order: 2; display: flex; flex-direction: column; }
.workspace.swapped .col-viz { order: 2; }
.workspace.swapped .col-work { order: 0; }

.panel {
  display: flex;
  flex-direction: column;
  min-height: var(--head-h);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  overflow: hidden;
}
:root { --head-h: 38px; }
.panel-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--head-h);
  padding: 0 10px;
  background: var(--panel-2);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  white-space: nowrap;
}
.panel-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.panel-head .pill:last-child { margin-left: auto; }
.panel-body { flex: 1; min-height: 0; overflow-y: auto; }
/* the challenge window: one tab bar, one visible tab */
.work-head { padding: 0 8px 0 0; gap: 6px; }
.work-head .tabs { align-self: stretch; display: flex; }
.work-head .tabs [role=tab] {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 14px;
  border-bottom: 2px solid transparent;
  border-right: 1px solid var(--border);
}
.work-head .tabs [role=tab]:hover { color: var(--text); background: color-mix(in srgb, var(--text) 3%, transparent); }
.work-head .tabs [role=tab].active { background: var(--panel); color: var(--text); border-bottom-color: var(--accent); }
.work-head .btn { padding: 4px 12px; }
.tab-dot { font-size: 12px; color: var(--accent); }
.tab-dot.bad { color: var(--fail); }
.count.good { color: var(--pass); }
.tab-pane { flex: 1; min-height: 0; }
.code-pane { display: flex; flex-direction: column; }
.task-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px 0; }
.task-head h2 { margin: 0; font-size: 17px; }
.swap-btn { margin-left: auto; }
.swap-btn + .status { margin-left: 4px; }

.gutter { flex: none; position: relative; }
.gutter-col { width: 8px; cursor: col-resize; }
.gutter::after {
  content: "";
  position: absolute;
  border-radius: 2px;
  background: transparent;
  transition: background 0.15s;
}
.gutter-col::after { top: 50%; left: 3px; width: 2px; height: 36px; margin-top: -18px; }
.gutter:hover::after { background: var(--faint); }
.gutter.active::after { background: var(--accent); }
.gutter-col.active::after { top: 0; height: 100%; margin-top: 0; }
body.resizing { user-select: none; cursor: col-resize; }
body.resizing iframe, body.resizing .CodeMirror { pointer-events: none; }

.viz-body { padding: 14px 16px 20px; background: var(--bg); container-type: inline-size; }
.viz-root { display: flex; flex-direction: column; gap: 14px; transition: opacity 0.2s, filter 0.2s; }
.viz-root.stale { opacity: 0.45; filter: grayscale(0.6); }
@container (min-width: 900px) {
  .viz-root { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}

.pill {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--muted);
  white-space: nowrap;
}
.pill:empty { display: none; }
.pill.good { color: var(--pass); border-color: color-mix(in srgb, var(--pass) 40%, transparent); }
.pill.bad { color: var(--fail); border-color: color-mix(in srgb, var(--fail) 40%, transparent); }
.pill.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
/* Difficulty labels: the word always stays, the colour only helps (nothing is shown by colour alone) */
.pill.diff-easy { color: var(--pass); border-color: color-mix(in srgb, var(--pass) 45%, transparent); background: color-mix(in srgb, var(--pass) 8%, transparent); }
.pill.diff-medium { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 8%, transparent); }
.pill.diff-hard { color: var(--fail); border-color: color-mix(in srgb, var(--fail) 45%, transparent); background: color-mix(in srgb, var(--fail) 8%, transparent); }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: 14px 16px 16px;
}
.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  color: var(--muted);
}
.card-head strong { color: var(--text); font-weight: 600; }
.card-head .pill { margin-left: auto; }
.card svg:not(.icon), .card canvas { display: block; width: 100%; height: auto; }
.plot { position: relative; width: 100%; max-width: 420px; margin: 0 auto; }
.plot canvas, .plot svg:not(.icon) { position: absolute; inset: 0; width: 100%; height: 100%; }
.plot::before { content: ""; display: block; padding-top: 100%; }
.plot.clickable { cursor: crosshair; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; font-size: 12px; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.readout {
  font: 12px/1.7 var(--mono);
  color: var(--muted);
  margin-top: 8px;
  white-space: pre-wrap;
  overflow-x: auto;
}
.readout b { color: var(--text); font-weight: 500; }

.error-box {
  border: 1px solid color-mix(in srgb, var(--fail) 45%, transparent);
  background: color-mix(in srgb, var(--fail) 8%, transparent);
  color: var(--fail);
  border-radius: var(--r-inner);
  padding: 10px 12px;
  margin-bottom: 12px;
  font: 12.5px/1.55 var(--mono);
  white-space: pre-wrap;
}
.error-box .where { color: var(--muted); }

/* timeline */
.timeline { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.timeline input[type="range"] { flex: 1; accent-color: var(--accent); }
.attn-sentence { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 10px 0 4px; font-size: 17px; }
.attn-word { font: inherit; padding: 4px 9px; border-radius: 6px; border: 0; outline: 2px solid transparent; cursor: pointer; }
.attn-word:hover { outline-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.attn-word.chosen { outline-color: var(--warn); }
.attn-word:focus-visible { outline-color: var(--accent); }
.timeline .step { padding: 4px 6px; font-size: 14px; line-height: 1; }
.timeline select,
.axis-pick select {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
}
.axis-pick { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.timeline .label { font: 12px var(--mono); color: var(--muted); min-width: 150px; text-align: right; }

/* ---------- code pane ---------- */
.task-body {
  padding: 12px 18px 14px;
  color: var(--body);
}
.task-body p { margin: 0 0 10px; }
.task-body ul, .task-body ol { margin: 0 0 10px; padding-left: 20px; }
.task-body li { margin-bottom: 4px; }
.task-body code {
  font: 12.5px var(--mono);
  background: var(--panel-2);
  padding: 1px 5px;
  border-radius: 6px;
  color: var(--accent);
}
.task-body .math {
  font: 13px var(--mono);
  background: var(--panel-2);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: var(--r-inner);
  margin: 0 0 10px;
}
.task-body .try {
  border: 1px dashed var(--border);
  border-radius: var(--r-inner);
  padding: 8px 10px;
  color: var(--muted);
}
.task-body .try strong { color: var(--warn); }

.spacer { flex: 1; }
.toggle { display: flex; align-items: center; gap: 6px; color: var(--muted); cursor: pointer; font-size: 13px; }
.toggle input { accent-color: var(--accent); }
.btn {
  border-radius: 999px;
  padding: 5px 14px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  cursor: pointer;
  font-size: 13px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--panel); font-weight: 700; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; color: var(--muted); }
/* Own colors, not opacity: people read "Run" while Python loads, so it keeps AA contrast. */
.btn:disabled, .btn.primary:disabled { background: var(--panel-2); border-color: var(--border); color: var(--muted); cursor: not-allowed; pointer-events: none; } /* events reach the wrapper's tooltip */
.run-wrap { display: inline-flex; cursor: not-allowed; }
.run-wrap:has(.btn:not(:disabled)) { cursor: auto; }

.editor { flex: 1; min-height: 0; position: relative; }
.editor .CodeMirror {
  position: absolute;
  inset: 0;
  height: auto;
  font: 13.5px/1.6 var(--mono);
  background: var(--panel);
}
/* the editor's own theme, set in src/app.js */
.cm-s-vml.CodeMirror { color: var(--text); }
.cm-s-vml .CodeMirror-gutters { background: var(--panel); border-right: 1px solid var(--border); }
.cm-s-vml .CodeMirror-linenumber { color: var(--muted); }
.cm-s-vml .CodeMirror-cursor { border-left-color: var(--text); }
.cm-s-vml .CodeMirror-activeline-background { background: color-mix(in srgb, var(--text) 3.5%, transparent); }
.cm-s-vml div.CodeMirror-selected, .cm-s-vml.CodeMirror-focused div.CodeMirror-selected { background: color-mix(in srgb, var(--brand) 24%, transparent); }
.cm-s-vml .CodeMirror-matchingbracket { color: var(--text) !important; background: color-mix(in srgb, var(--brand) 24%, transparent); }
.cm-s-vml .cm-comment { color: var(--muted); font-style: italic; }
.cm-s-vml .cm-keyword { color: var(--accent); font-weight: 700; }
.cm-s-vml .cm-def { color: var(--text); font-weight: 700; }
.cm-s-vml .cm-builtin { color: var(--pos); }
.cm-s-vml .cm-string { color: var(--pass); }
.cm-s-vml .cm-number { color: var(--num); }
.cm-s-vml .cm-operator, .cm-s-vml .cm-punctuation, .cm-s-vml .cm-bracket { color: var(--body); }
.cm-s-vml .cm-variable, .cm-s-vml .cm-variable-2, .cm-s-vml .cm-property { color: var(--text); }
.cm-s-vml .cm-error { color: var(--fail); }
.CodeMirror .error-line { background: color-mix(in srgb, var(--fail) 16%, transparent); }

.tabs { gap: 2px; }
.tabs [role=tab] {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 8px 10px;
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
}
.tabs [role=tab].active { color: var(--text); border-bottom-color: var(--accent); }
.count { font-size: 11px; color: var(--muted); }
.tab-body { padding: 8px 12px; margin: 0; }
.tab-body.output { font: 12.5px/1.5 var(--mono); white-space: pre-wrap; color: var(--body); }

.test {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 2px 8px;
  padding: 6px 4px;
  border-bottom: 1px solid color-mix(in srgb, var(--text) 4%, transparent);
  font-size: 13px;
}
.test .mark { font-weight: 700; }
.test.pass .mark { color: var(--pass); }
.test.fail .mark { color: var(--fail); }
.test .msg { grid-column: 2; font: 12px/1.5 var(--mono); color: var(--fail); white-space: pre-wrap; }
.banner {
  border-radius: var(--r-inner);
  padding: 8px 12px;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 13px;
}
.banner.solved { background: color-mix(in srgb, var(--pass) 12%, transparent); color: var(--pass); border: 1px solid color-mix(in srgb, var(--pass) 35%, transparent); }
.banner.muted { color: var(--muted); background: var(--panel-2); font-weight: 400; }

@media (max-width: 899px) {
  body { overflow: auto; height: auto; }
  .workspace { flex-direction: column; gap: 8px; }
  .gutter, .swap-btn { display: none !important; }
  .col { min-width: 0; }
  .col-viz, .workspace.swapped .col-viz { order: 0; }
  .col-work, .workspace.swapped .col-work { order: 2; height: 85vh; flex: none; }
  .viz-body { overflow: visible; }
  .work-head { overflow-x: auto; }
  .drawer-btn { min-width: 0; max-width: 46vw; }
  .status .label { display: none; }
}

/* ---------- challenge list (landing page + drawer) ---------- */
.muted { color: var(--muted); }
.ch-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ch-card {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  background: var(--panel);
  color: var(--text);
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s;
}
.ch-card:hover { border-color: var(--accent); }
.ch-card.current { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.ch-top { display: flex; align-items: center; gap: 8px; }
.ch-title { font-weight: 600; }
.ch-implement { font-size: 13px; color: var(--body); }
.ch-implement code { font: 12px var(--mono); background: var(--panel-2); padding: 1px 5px; border-radius: 6px; color: var(--accent); }
.ch-blurb { font-size: 13px; color: var(--muted); }
.ch-status { margin-left: auto; font-size: 12px; white-space: nowrap; color: var(--faint); }
.ch-status.solved { color: var(--pass); }
.ch-status.in-progress { color: var(--warn); }
.ch-status.in-progress::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--warn); margin-right: 6px; vertical-align: 1px;
}
.drawer-btn .ch-status { margin-left: 0; font-weight: 700; }
.drawer-btn .ch-status.in-progress::before { margin-right: 0; }

/* ---------- drawer ---------- */
.drawer {
  margin: 0;
  height: 100%;
  max-height: none;
  width: min(420px, 92vw);
  padding: 16px;
  border: 0;
  border-right: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  overflow-y: auto;
}
.drawer[open] { animation: slide-in 0.18s ease-out; }
.drawer::backdrop { background: color-mix(in srgb, var(--shadow) 45%, transparent); }
@keyframes slide-in { from { transform: translateX(-24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.drawer-head h2 { margin: 0; font-size: 16px; }
.drawer-head .muted { font-size: 13px; }
.drawer-head .icon-btn { margin-left: auto; }
.drawer-foot { margin: 18px 0 0; font-size: 13px; color: var(--faint); }
.drawer-foot a { color: var(--muted); }

/* ---------- modal ---------- */
.modal {
  width: min(420px, calc(100vw - 32px));
  padding: 24px 22px 20px;
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  background: var(--panel);
  color: var(--text);
  text-align: center;
  box-shadow: 0 20px 60px color-mix(in srgb, var(--shadow) 18%, transparent);
}
.modal::backdrop { background: color-mix(in srgb, var(--shadow) 45%, transparent); }
.modal-icon { font-size: 36px; margin-bottom: 6px; color: var(--accent); }
.modal-icon .icon { stroke-width: 1.5; }
.modal h2 { margin: 0 0 8px; font-size: 18px; }
.modal p { margin: 0 0 18px; color: var(--body); }
.modal-actions { display: flex; gap: 10px; justify-content: center; }
.modal-actions .btn { padding: 8px 16px; }
.tree-modal { max-width: 95vw; width: max-content; max-height: 90vh; padding: 14px 16px; text-align: left; }
.tree-modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; color: var(--muted); font-size: 13px; }
.tree-modal-head strong { color: var(--text); font-size: 15px; }
.tree-modal-head .icon-btn { margin-left: auto; }
.tree-modal-body { overflow: auto; max-height: calc(90vh - 70px); }
.tree-modal-body svg { display: block; max-width: none; height: auto; }
.tree-host { cursor: zoom-in; border-radius: var(--r-inner); }
.tree-host:hover { background: color-mix(in srgb, var(--text) 2%, transparent); }
.tree-host:focus-visible { outline: 2px solid var(--accent); }

/* ---------- loading Python ---------- */
.py-loading .card-head span { color: var(--muted); }
.py-steps { list-style: none; margin: 6px 0 12px; padding: 0; display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--faint); }
.py-steps li::before {
  content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 6px; vertical-align: -1px;
  border: 1.5px solid currentColor; border-radius: 50%;
}
.py-steps li.active { color: var(--text); }
.py-steps li.active::before { color: var(--accent); background: linear-gradient(90deg, currentColor 50%, transparent 50%); }
.py-steps li.done { color: var(--muted); }
.py-steps li.done::before { color: var(--pass); background: currentColor; }
.py-bar { height: 6px; border-radius: 3px; background: var(--panel-2); overflow: hidden; }
.py-bar i {
  display: block; height: 100%; width: 0;
  background: repeating-linear-gradient(-45deg, var(--accent) 0 10px, var(--brand) 10px 20px);
  background-size: 28px 28px;
  animation: py-stripes 0.8s linear infinite;
  transition: width 0.6s ease;
}
@keyframes py-stripes { to { background-position: 28px 0; } }
.py-slow { margin: 10px 0 0; font-size: 13px; color: var(--warn); }
.py-failed p { margin: 10px 0 0; color: var(--body); }
.py-failed .py-why { font: 12px var(--mono); color: var(--muted); }
.py-failed .py-retry { margin-top: 12px; }
.py-loading.failed .py-steps, .py-loading.failed .py-bar { display: none; }

/* ---------- tooltips (src/tooltip.js) ---------- */
.tooltip {
  position: fixed;
  z-index: 100;
  max-width: 280px;
  padding: 7px 10px;
  border-radius: var(--r-inner);
  border: 1px solid var(--text);
  background: var(--text);
  color: var(--panel);
  font-size: 12.5px;
  line-height: 1.45;
  box-shadow: 0 8px 24px color-mix(in srgb, var(--shadow) 16%, transparent);
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
  animation: tooltip-in 0.12s ease-out;
}
.tooltip[data-side="above"] { animation-name: tooltip-in-above; }
@keyframes tooltip-in { from { opacity: 0; transform: translateY(-3px); } }
@keyframes tooltip-in-above { from { opacity: 0; transform: translateY(3px); } }
@media (prefers-reduced-motion: reduce) { .tooltip { animation: none; } }

/* ---------- feedback (src/feedback.js) ---------- */
.feedback-btn { margin-left: auto; }
.feedback-btn + .swap-btn { margin-left: 8px; }
.fb-dialog { width: min(520px, calc(100vw - 32px)); text-align: left; padding: 18px 20px 14px; }
.fb-head { display: flex; align-items: center; margin-bottom: 10px; }
.fb-head h2 { margin: 0; }
.fb-head .icon-btn { margin-left: auto; }
.fb-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.fb-tabs [role=tab] {
  border: 0; background: none; color: var(--muted); cursor: pointer;
  padding: 8px 10px; border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 13px;
}
.fb-tabs [role=tab]:hover { color: var(--text); }
.fb-tabs [role=tab][aria-selected=true] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.fb-tabs [role=tab][hidden] { display: none; }
.fb-form { display: flex; flex-direction: column; gap: 12px; }
.fb-form[hidden] { display: none; }
.fb-field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.fb-field textarea, .fb-field input {
  padding: 8px 12px; border-radius: var(--r-inner); border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); outline: none; resize: vertical; font: inherit; font-size: 14px;
}
.fb-field textarea:focus, .fb-field input:focus { border-color: var(--accent); }
.fb-count { align-self: flex-end; color: var(--warn); font-size: 12px; }
.fb-votes { display: flex; gap: 8px; }
.fb-vote {
  color: var(--muted);
  font-size: 20px; line-height: 1; padding: 6px 12px; cursor: pointer;
  border-radius: 999px; border: 1px solid var(--border); background: var(--panel-2);
}
.fb-vote:hover { border-color: var(--accent); color: var(--text); }
.fb-vote[aria-pressed=true] { color: var(--accent); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.fb-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.fb-chips button {
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border);
  background: none; color: var(--muted); cursor: pointer; font-size: 12px;
}
.fb-chips button:hover { color: var(--text); }
.fb-chips button[aria-pressed=true] { color: var(--text); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.fb-name[hidden] { display: none; }
.fb-tick { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }
.fb-sent-with { margin: 0; font-size: 12px; color: var(--faint); background: var(--panel-2); border-radius: var(--r-inner); padding: 8px 12px; }
.fb-details { font-size: 12px; color: var(--faint); background: var(--panel-2); border-radius: var(--r-inner); padding: 8px 12px; }
.fb-details strong { color: var(--muted); font-weight: 600; }
.fb-details ul { margin: 6px 0 0; padding-left: 18px; }
.fb-details li { overflow-wrap: anywhere; }
.fb-actions { display: flex; align-items: center; gap: 12px; }
.fb-actions .btn { margin-left: auto; padding: 7px 18px; }
.fb-msg { font-size: 13px; color: var(--muted); }
.fb-msg.error { color: var(--fail); }
.fb-check:empty { display: none; }
.fb-thanks { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--pass); font-size: 14px; padding: 6px 0; }
.fb-thanks .btn { margin-left: auto; }
.fb-foot { margin: 14px 0 0; font-size: 12px; color: var(--faint); text-align: left; }
.fb-foot a { color: var(--muted); }

/* the offer under the Solved banner */
.fb-offer { margin: 0 0 10px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-inner); background: var(--panel-2); }
.fb-offer[hidden] { display: none; }
.fb-offer-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.fb-offer-row span { margin-right: 4px; }
.fb-offer-row .fb-vote { font-size: 16px; padding: 3px 9px; }
.fb-offer-x { margin-left: auto; border: 0; background: none; color: var(--faint); font-size: 18px; cursor: pointer; padding: 0 4px; }
.fb-offer-x:hover { color: var(--text); }
.fb-offer .fb-form { margin-top: 10px; }

/* ---------- the language dropdown (src/lang-picker.js), on every page's top bar ---------- */
.lang-picker { position: relative; margin-left: auto; flex: none; }
.site-nav + .lang-picker, .status + .lang-picker { margin-left: 0; }
.lang-btn {
  display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px;
  background: transparent; border: 1px solid var(--border); border-radius: 999px;
  color: var(--muted); font: 13px var(--sans); cursor: pointer;
}
.lang-btn:hover, .lang-btn[aria-expanded="true"] { color: var(--text); border-color: var(--faint); }
.lang-flag { width: 20px; height: 13px; border-radius: 2px; box-shadow: 0 0 0 1px color-mix(in srgb, var(--text) 14%, transparent); flex: none; }
.lang-caret { width: 7px; height: 7px; margin: -3px 0 0 2px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
.lang-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 150px; margin: 0; padding: 4px;
  list-style: none; background: var(--panel); border: 1px solid var(--border); border-radius: var(--r-inner);
  box-shadow: 0 10px 30px color-mix(in srgb, var(--shadow) 16%, transparent); outline: none;
}
.lang-menu li { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--text); font-size: 14px; cursor: pointer; }
.lang-menu li.active { background: var(--panel-2); }
.lang-menu li[aria-selected="true"] { color: var(--accent); }
.theme-btn { flex: none; font-size: 16px; }

/* ---------- neuron controls: the Intro Visualization and The Neuron's Concept mode (src/neuron-controls.js) ---------- */

.demo-code {
  margin: 0;
  padding: 16px 16px 12px;
  font: 14px/1.9 var(--mono);
  color: var(--text);
  white-space: pre;
  overflow-x: auto;
  border-top: 1px solid var(--border);
}
.tok-c { color: var(--muted); font-style: italic; white-space: pre-wrap; }
.tok-p { color: var(--accent); }
.tok-b { color: var(--accent); }
.demo-code .num {
  font: inherit;
  color: var(--accent);
  font-weight: 700;
  background: color-mix(in srgb, var(--brand) 14%, transparent);
  border: 0;
  border-bottom: 1px dashed var(--brand);
  border-radius: 6px;
  padding: 0 5px;
  text-align: center;
  cursor: ew-resize;
  touch-action: none; /* a finger drag scrubs the number instead of scrolling */
  outline: none;
}
.demo-code .num:hover, .demo-code .num.dragging { background: color-mix(in srgb, var(--brand) 26%, transparent); }
.demo-code .num:focus { cursor: text; background: color-mix(in srgb, var(--brand) 20%, transparent); box-shadow: 0 0 0 1px var(--brand); }

.demo-check {
  margin: 4px 16px 0;
  padding: 9px 12px;
  border-radius: var(--r-inner);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid;
}
.demo-check .mark { font-weight: 800; margin-right: 4px; }
.demo-check.fail { color: var(--fail); background: color-mix(in srgb, var(--fail) 8%, transparent); border-color: color-mix(in srgb, var(--fail) 35%, transparent); }
.demo-check.pass { color: var(--pass); background: color-mix(in srgb, var(--pass) 10%, transparent); border-color: color-mix(in srgb, var(--pass) 40%, transparent); }
.demo-prompt { margin: 12px 16px 16px; font-size: 14px; color: var(--body); }
.demo-prompt code { font: 13px var(--mono); color: var(--accent); }
.demo-prompt strong { color: var(--text); }
.demo-prompt a { font-weight: 600; }

/* ---------- Concept mode: the switch in the Visualization header, and its panel ---------- */

.mode-switch { display: inline-flex; margin-left: 12px; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.mode-switch button { font: inherit; font-size: 12px; font-weight: 600; padding: 3px 12px; border: 0; background: none; color: var(--muted); cursor: pointer; }
.mode-switch button[aria-pressed=true] { color: var(--text); background: color-mix(in srgb, var(--accent) 16%, transparent); }
.concept { display: none; }
.concept-on .concept { display: block; }
.concept-on #viz-root, .concept-on #viz-error, .concept-on #py-loading, .concept-on #viz-state { display: none !important; }
.concept-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; font-size: 13px; color: var(--body); }
.concept-bar p { margin: 0; flex: 1; }
.concept-bar strong { color: var(--text); }
.concept-controls { padding: 4px 0 0; grid-column: 1 / -1; } /* the whole row, above the Visualization's cards */
/* The Challenge's cards sit in a wrapper (app.js): let them lay out like Code mode's, gap and columns included. */
#concept-root > div { display: contents; }
/* Room for the longest prompt and its button, so a changing hint doesn't push the cards below up and down. */
.concept-controls .demo-prompt { min-height: 4.6em; line-height: 1.5; }
.concept-controls .demo-code { border-top: 0; }
.concept-controls .demo-prompt .btn { margin-left: 6px; }
.concept-controls .demo-code { white-space: pre-wrap; }
.concept-controls .concept-act { font: 600 12px var(--mono); padding: 2px 10px; margin: 2px 0; vertical-align: baseline; }
.concept-controls .pick { cursor: pointer; }
.concept-controls .tick { cursor: pointer; white-space: nowrap; }
