/* Unstub's practice panel: the problem, its gaps, its tests and the Check, shown in the extension's side panel and on the
   website's problem page. What matters is the code and its gaps, the help with the gap in hand, and what a Check found,
   so the work is on plain cards with nothing behind them to draw the eye. With the room, the problem and its tests are on
   the left and the work on the right, each scrolling on its own; in a side panel, the problem, the work and the tests
   follow one another. Check is at the foot. It lays itself out by the room it is given, not by the window. Every rule is
   under .cz, so the page it sits in is not touched. The tokens are in shared/tokens.css and the pieces both hosts share
   (buttons, the switch, stars) in shared/ui.css. */

.practice-host {
  container: practice / inline-size;
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
}

/* The panel's buttons take their type from shared/ui.css. On the website this file is outside the site's cascade layers,
   so a rule here would beat the shared ones. */
.cz button {
  cursor: pointer;
}

/* The panel's cards and their edges, and the rhythm of a line of code. */
.cz {
  --surface: var(--card);
  --edge: var(--rule);
  --code-line: 28px;
  --code-size: 14px;
}

.cz .practice {
  flex: 1;
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 28px 36px;
}

.cz .editor-sheet {
  border: 1px solid var(--edge);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

/* ---------------------------------------------------------------- the problem, and its levels as steps */

/* The problem's side: what it asks, then its tests, straight on the page. */
.cz .brief-panel {
  min-width: 0;
  padding: 10px 6px 20px 4px;
}

.cz .about {
  margin: 0 0 22px;
}

.cz .practice h1 {
  margin: 0 0 8px;
  font: 400 clamp(30px, 6cqi, 44px) / 1.05 var(--serif);
  letter-spacing: -0.035em;
}

/* The task, in our own words, straight under the title and in line with it, set for reading. */
.cz .task {
  margin: 0;
  color: var(--ink-2);
  font-size: 15.5px;
  line-height: 1.6;
  white-space: pre-line;
  text-wrap: pretty;
}

/* The four levels: the chips a quest's path draws (shared/ui.css .level-chips), in a row above the code. */
.cz .levels {
  flex: none;
  margin: 0;
}

/* The ways of solving the problem (premium), above the work: a row of tabs, and a line on the one chosen. */
.cz .approaches {
  margin: 0 0 16px;
}

.cz .approach-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--edge);
  border-radius: var(--pill);
  background: var(--surface);
}

.cz .approach-tabs button {
  min-height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--pill);
  background: transparent;
  color: var(--muted);
  font: 600 13px var(--sans);
}

.cz .approach-tabs button:hover {
  color: var(--fg);
}

.cz .approach-tabs button[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--fg);
}

.cz .approach-summary,
.cz .premium-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.cz .premium-note {
  margin: 18px 0 0;
  font-size: 12px;
}

.cz .premium-note a {
  color: var(--accent-strong);
}

/* ---------------------------------------------------------------- the work */

.cz .work {
  min-width: 0;
}

/* Clipped to its corners, but not a scroller of its own (as `hidden` would make it), so the help at its foot is seen in sight
   or not by the page that scrolls it, and Check can rest under it (the foot, below). */
.cz .editor-sheet {
  display: flow-root;
  overflow: clip;
  border-radius: 18px;
}

/* Above the code: the levels, the language, how far the gaps are filled, and what a solve is worth now. */
.cz .code-caption {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 10px 12px 10px 10px;
  border-bottom: 1px solid var(--edge);
}

.cz .code-caption .switch {
  padding: 3px;
  border: 0;
  border-radius: var(--pill);
  background: color-mix(in srgb, var(--fg) 6%, transparent);
}

.cz .code-caption .switch button {
  min-height: 28px;
  padding-inline: 12px;
  border-radius: var(--pill);
  font-size: 12px;
}

.cz .code-caption .switch button[aria-pressed="true"] {
  background: var(--card);
  color: var(--fg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

.cz .toolbar-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 6px 12px;
  margin-left: auto;
}

/* What a solve would earn now, for a learner who is signed in: the level's XP above what the problem has earned, and less
   once help has been taken. */
.cz .worth {
  margin: 0;
  padding: 2px 10px;
  border: 1px solid var(--edge);
  border-radius: var(--pill);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.cz .worth strong {
  color: var(--fg);
  font-weight: 700;
}

.cz .worth.is-less strong {
  color: var(--shown);
}

/* Where a signed-in learner stands on the problem (ADR 0017), under what it asks: a star for each level cleared in this
   language, the problem's XP out of its worth, and the next level with what it adds, or, with every level cleared, that it
   is mastered. */
.cz .problem-standing {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin: 14px 0 0;
  font-size: 12.5px;
}

.cz .problem-standing .problem-xp progress,
.cz .summary .problem-xp progress {
  width: 72px;
}

.cz .problem-next {
  color: var(--muted);
}

/* Listen: a small pill with a speaker and a word, which reads what it stands for aloud; while it reads, it says Stop in the accent. */
.cz .listen {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 12px 0 10px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--pill);
  background: var(--card);
  color: var(--ink-2);
  font: 600 12px / 1 var(--sans);
  cursor: pointer;
}

.cz .listen:hover {
  border-color: var(--accent-strong);
  color: var(--accent-strong);
}

.cz .listen[aria-pressed="true"] {
  border-color: transparent;
  background: var(--accent-strong);
  color: var(--accent-fg);
}

.cz .problem-head > .listen {
  margin-top: 14px;
}

/* While the natural voice loads, the button that is reading has a bar along its foot that fills as the model comes. */
.cz .listen {
  position: relative;
  overflow: hidden;
}

.cz .listen[data-loading]::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: var(--load, 0%);
  height: 3px;
  background: color-mix(in srgb, var(--accent-fg) 75%, transparent);
  transition: width 200ms var(--ease);
}

.cz .problem-head > .voice-status {
  max-width: 52ch;
  margin-top: 10px;
}

.cz .explanation > .voice-status {
  margin: 14px 20px 0;
}

.cz .help-dock > .voice-status {
  margin-top: 2px;
}

.cz .explanation summary .listen {
  grid-column: 2;
  grid-row: 1 / span 2;
}

.cz .help-given > .listen {
  margin-left: auto;
}

/* What is being read: marked on the screen as the voice reaches it, so the eye and the ear are in the same place. */
.cz [data-beat] {
  transition:
    background-color 160ms var(--ease),
    box-shadow 160ms var(--ease);
}

.cz [data-beat].is-reading {
  border-radius: 6px;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 14%, transparent);
}

.cz .problem-mastered {
  padding: 2px 9px;
  border-radius: var(--pill);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

/* The code, as a source file: numbered lines that wrap under their own indentation. Lines and gaps share one rhythm. */
.cz .code {
  --gutter: 4.5ch;
  counter-reset: line;
  min-width: 0;
  padding: 18px 0 20px;
  background: var(--code-bg);
  font: var(--code-size) / var(--code-line) var(--mono);
  font-variant-ligatures: none;
  overflow-wrap: anywhere;
}

.cz .line {
  position: relative;
  min-height: var(--code-line);
  padding: 0 16px 0 calc(var(--gutter) + (var(--indent) + 2) * 1ch);
  text-indent: -2ch;
  white-space: pre-wrap;
  counter-increment: line;
}

.cz .line::before,
.cz .gap-gutter span::before {
  content: counter(line);
  position: absolute;
  left: 0;
  width: calc(var(--gutter) - 1.5ch);
  color: color-mix(in srgb, var(--muted) 60%, transparent);
  text-align: right;
  text-indent: 0;
  user-select: none;
}

/* A line with words from its author keeps its number as the control, with a small dot after it; the words open just
   under the line, in the same margin note as the help with a gap. */
.cz .line.has-guide::before {
  content: none;
}

.cz .line-guide {
  position: absolute;
  inset: 0 auto auto 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
  width: calc(var(--gutter) - 1.5ch);
  height: var(--code-line);
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

/* The dot sits after the number, midway between it and the code, and takes no room of its own, so the number stays in
   line with the others. */
.cz .line-guide-number {
  position: relative;
}

.cz .line-guide-number::before {
  content: "";
  position: absolute;
  top: 50%;
  left: calc(100% + 0.75ch - 2.5px);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-strong);
  translate: 0 -50%;
}

.cz .line-guide:hover,
.cz .line-guide[aria-expanded="true"] {
  color: var(--accent-strong);
}

.cz .line-guide:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: 1px;
}

/* A blank: a field in its line, as wide as what is in it, on a soft tint of the accent, so it reads as the part of the code
   that is yours; empty, it says so in words (…), which is how it is found, as well as by its tint. The one with the caret is
   ringed in the strong accent, 2px, which keeps 3:1 against the code in every palette (practice/scripts/palettes.test.ts);
   shown, it is in the colour of a shown answer; wrong, in the colour of a fail. */
.cz .blank {
  position: relative;
  display: inline-block;
  margin: 0 1px;
  text-indent: 0;
  vertical-align: baseline;
}

.cz .blank .gap-field {
  box-sizing: content-box;
  width: calc(var(--chars, 4) * 1ch);
  height: calc(var(--code-line) - 4px);
  margin: 0;
  padding: 0 6px;
  border: 0;
  border-radius: 6px;
  background: color-mix(in srgb, var(--gap-ink) 20%, transparent);
  color: transparent;
  caret-color: var(--fg);
  font: inherit;
  line-height: calc(var(--code-line) - 4px);
  vertical-align: baseline;
  transition:
    box-shadow 140ms var(--ease),
    background 140ms var(--ease),
    width 80ms linear;
}

.cz .gap-field::placeholder {
  color: var(--muted);
  opacity: 1;
}

.cz .blank .gap-field:hover {
  background: color-mix(in srgb, var(--gap-ink) 26%, transparent);
}

.cz .blank .gap-field:focus {
  outline: none;
  background: color-mix(in srgb, var(--gap-ink) 24%, transparent);
  box-shadow: 0 0 0 2px var(--accent-strong);
}

.cz .blank.is-shown .gap-field {
  background: var(--shown-soft);
}

.cz .blank.is-error .gap-field {
  background: var(--fail-soft);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--fail) 60%, transparent);
}

/* A gap of whole lines: a band of the code's lines on the same soft tint, numbered on with the lines around it, which says
   in words how much goes in it while it is empty. The one with the caret is a shade deeper, with a bar down its left edge in
   the strong accent, as a notebook marks the cell being written in; one that went wrong has the bar in the colour of a fail. */
.cz .gap {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin: 2px 0;
  border-radius: 0 8px 8px 0;
  background: color-mix(in srgb, var(--gap-ink) 12%, transparent);
  box-shadow: inset 3px 0 0 transparent;
  transition:
    background 140ms var(--ease),
    box-shadow 140ms var(--ease);
}

.cz .gap.is-active,
.cz .gap:focus-within {
  background: color-mix(in srgb, var(--gap-ink) 17%, transparent);
  box-shadow: inset 3px 0 0 var(--accent-strong);
}

.cz .gap.is-shown {
  background: var(--shown-soft);
}

.cz .gap.is-error {
  background: var(--fail-soft);
  box-shadow: inset 3px 0 0 var(--fail);
}

.cz .gap .gap-field::placeholder {
  font-family: var(--sans);
  font-style: italic;
}

.cz .gap-gutter {
  position: absolute;
  inset: 0 auto auto 0;
  display: grid;
}

.cz .gap-gutter span {
  position: relative;
  height: var(--code-line);
  counter-increment: line;
}

.cz .gap-gutter span::before {
  color: color-mix(in srgb, var(--accent-strong) 75%, transparent);
}

.cz .gap .gap-field {
  position: relative;
  grid-area: 1 / 1;
  align-self: stretch;
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-height: var(--code-line);
  margin: 0;
  padding: 0 16px 0 calc(var(--gutter) + var(--indent) * 1ch);
  border: 0;
  background: none;
  color: transparent;
  caret-color: var(--fg);
  font: inherit;
  line-height: var(--code-line);
  tab-size: 4;
  resize: none;
  overflow: hidden;
}

.cz .gap .gap-field:focus {
  outline: none;
}

/* What is typed in a gap is coloured as the code around it: the field's own text is clear, and a coloured copy of it lies over
   it in the same place, out of the way of the pointer, so the caret, the selection and the keys stay the field's. A shown
   answer is in the colour of a shown answer, not the code's. */
.cz .gap-mirror {
  position: absolute;
  color: var(--fg);
  font: inherit;
  pointer-events: none;
}

.cz .gap-field::selection {
  color: transparent;
  background: color-mix(in srgb, var(--accent-strong) 30%, transparent);
}

/* The field is centred in its blank, which is as tall as the line, so its copy is too. */
.cz .blank .gap-mirror {
  inset: 2px 0;
  padding: 0 6px;
  line-height: calc(var(--code-line) - 4px);
  white-space: pre;
  overflow: hidden;
}

/* A gap's lines and their copy share one cell, and the copy sets its height: a line that wraps on a narrow screen makes the
   field taller with it, so the field never scrolls away from what is painted over it. */
.cz .gap .gap-mirror {
  position: relative;
  grid-area: 1 / 1;
  padding: 0 16px 0 calc(var(--gutter) + var(--indent) * 1ch);
  line-height: var(--code-line);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  tab-size: 4;
}

/* An empty last line still takes its row, as it does in the field. */
.cz .gap .gap-mirror::after {
  content: " ";
}

/* A faint line at each step of a typed line's indentation, so lines that belong together are seen to line up. */
.cz .gap-mirror .indent-guide {
  box-shadow: inset 1px 0 0 color-mix(in srgb, var(--fg) 14%, transparent);
}

.cz .is-shown > .gap-mirror,
.cz .is-shown > .gap-mirror span {
  color: var(--shown);
}

/* Under a gap, or under a line with blanks: what went wrong, and the reference beside an answer that differs. */
.cz .gap-notes {
  padding: 2px 16px 6px calc(var(--gutter) + var(--indent) * 1ch);
  font-size: 12px;
  line-height: 1.6;
}

.cz .gap-error {
  margin: 0;
  color: var(--fail);
  font: 12px / 1.6 var(--mono);
  overflow-wrap: anywhere;
}

.cz .gap-error::before {
  content: "↳ ";
}

.cz .gap-reference span {
  color: var(--muted);
  font: 600 10px / 1.5 var(--sans);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.cz .gap-reference pre {
  margin: 2px 0 0;
  padding: 0 8px;
  border-left: 2px solid var(--rule-strong);
  font: var(--code-size) / 1.7 var(--mono);
  white-space: pre-wrap;
}

/* ---------------------------------------------------------------- the help with the gap in hand */

/* A piece of help to take, as a small pill: its picture, its word, and what it costs for a learner who is told. The answer is
   quieter, without a border until it is pointed at, so it is not taken by mistake. */
.cz .help-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 24px;
  padding: 0 10px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--pill);
  background: var(--card);
  color: var(--ink-2);
  font: 600 12px / 1 var(--sans);
  white-space: nowrap;
  cursor: pointer;
  transition:
    border-color 140ms var(--ease),
    background 140ms var(--ease),
    color 140ms var(--ease);
}

.cz .help-pill .icon {
  width: 12px;
  height: 12px;
  color: var(--accent-strong);
}

.cz .help-pill:hover {
  border-color: var(--accent-strong);
  background: var(--accent-soft);
  color: var(--fg);
}

.cz .help-pill.is-answer {
  border-color: transparent;
  background: none;
  color: var(--muted);
}

.cz .help-pill.is-answer .icon {
  color: currentColor;
}

.cz .help-pill.is-answer:hover {
  border-color: var(--rule-strong);
  background: var(--wash);
  color: var(--fg);
}

.cz .help-cost {
  color: var(--muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.cz .help-cost::before {
  content: "·";
  margin-right: 5px;
}

/* The line the help is about, underlined with a squiggle as a spell checker marks a word, so the help at the foot of the editor
   points back to it: the line of the blank with the caret, once help with it is given, in the accent; a line whose comment
   shows, in gold, as long as its comment does. It runs under the code and its blanks alike, never its indentation; a band of
   whole lines has it along its foot. */
.cz .code {
  --squiggle: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 4'%3E%3Cpath d='M0 2 Q2 0 4 2 T8 2' fill='none' stroke='black' stroke-width='1.3'/%3E%3C/svg%3E");
}

.cz .line-code {
  position: relative;
}

.cz .line.has-guide .line-code::after,
.cz .line:has(.blank.is-active.is-helped) .line-code::after,
.cz .gap.is-active.is-helped::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: -3px;
  left: 0;
  height: 4px;
  background: var(--accent-strong);
  mask: var(--squiggle) left center / 8px 4px repeat-x;
  pointer-events: none;
}

.cz .line.has-guide .line-code::after {
  background: var(--gold);
  opacity: 0;
  transition: opacity 120ms var(--ease);
}

.cz .line:has(.blank.is-active.is-helped) .line-code::after {
  background: var(--accent-strong);
  opacity: 1;
  transition: none;
}

/* A line's comment, once comments are on: a tooltip under the line, as an editor shows one, starting where its code starts.
   Pointing at the line shows it after a moment, so a pointer passing over the code does not flash every comment; the
   keyboard's focus on the line's number, or pressing it, shows it at once. It never takes the pointer, so the line it lies
   over can be pointed at in turn. */
.cz .line-comment {
  position: absolute;
  top: calc(100% - 1px);
  left: calc(var(--gutter) + var(--indent) * 1ch);
  z-index: 3;
  width: max-content;
  max-width: min(52ch, calc(100% - var(--gutter) - var(--indent) * 1ch - 16px));
  padding: 6px 10px;
  border: 1px solid var(--rule-strong);
  border-left: 2px solid var(--gold);
  border-radius: 0 8px 8px 0;
  background: var(--card);
  box-shadow: var(--shadow-card);
  color: var(--fg);
  font: 400 13px / 1.45 var(--sans);
  text-indent: 0;
  white-space: normal;
  pointer-events: none;
  user-select: none;
  visibility: hidden;
  opacity: 0;
  translate: 0 -3px;
  transition:
    opacity 120ms var(--ease),
    translate 120ms var(--ease),
    visibility 0s 120ms;
}

.cz .line.has-guide:hover .line-comment,
.cz .line.has-guide:hover .line-code::after {
  visibility: visible;
  opacity: 1;
  translate: 0;
  transition-delay: 350ms;
}

.cz .line:has(.line-guide:focus-visible) .line-comment,
.cz .line:has(.line-guide[aria-expanded="true"]) .line-comment,
.cz .line:has(.line-guide:focus-visible) .line-code::after,
.cz .line:has(.line-guide[aria-expanded="true"]) .line-code::after {
  visibility: visible;
  opacity: 1;
  translate: 0;
  transition-delay: 0s;
}

.cz .gap.is-active.is-helped::after {
  right: 16px;
  bottom: 1px;
  left: calc(var(--gutter) + var(--indent) * 1ch);
}

/* The help, at the foot of the editor like an editor's bottom panel, so the code stays as it is: which gap, with arrows to
   the others; the ladder of help in order, each rung done (ticked, and said), to take now (a pill that says what it costs)
   or not yet (dashed); and what was given, in words large enough to read, with a bar in the accent that says it is help. At its
   foot, the switch for the lines' comments. */
.cz .help-dock {
  display: grid;
  gap: 12px;
  padding: 14px 18px 16px;
  border-top: 1px solid var(--rule);
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
  font-family: var(--sans);
}

.cz .help-dock-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cz .help-dock-title {
  margin: 0;
  font: 600 13px / 1.4 var(--sans);
}

.cz .help-dock-where {
  color: var(--muted);
  font-weight: 400;
}

.cz .help-dock-nav {
  display: inline-flex;
  gap: 4px;
}

.cz .help-dock-arrow {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--rule-strong);
  border-radius: 50%;
  background: var(--card);
  color: var(--ink-2);
  font: 500 16px / 1 var(--sans);
  cursor: pointer;
}

.cz .help-dock-arrow:hover {
  border-color: var(--accent-strong);
  color: var(--accent-strong);
}

/* The small voice button in the help: on, a hint is read aloud as it opens. */
.cz .help-aloud .icon {
  width: 14px;
  height: 14px;
}

.cz .help-aloud[aria-pressed="true"] {
  border-color: transparent;
  background: var(--accent-strong);
  color: var(--accent-fg);
}

.cz .help-ladder {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cz .help-rung {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* A short line between rungs, so they read as steps in order. */
.cz .help-rung + .help-rung::before {
  content: "";
  width: 14px;
  height: 1px;
  background: var(--rule-strong);
}

.cz .help-rung-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--pill);
  color: var(--muted);
  font: 600 12px / 1 var(--sans);
}

.cz .help-rung.is-done .help-rung-label {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.cz .help-rung.is-later .help-rung-label {
  border: 1px dashed var(--rule-strong);
}

.cz .help-rung-mark:empty {
  display: none;
}

.cz .help-given {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 14px;
  padding: 10px 14px;
  border-left: 2px solid var(--accent-strong);
  border-radius: 0 10px 10px 0;
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  color: var(--fg);
  font: 400 15px / 1.5 var(--sans);
}

.cz .help-given.is-shown {
  border-left-color: var(--shown);
}

.cz .help-dock-done {
  flex-basis: 100%;
  margin: 0;
  color: var(--shown);
  font-size: 13px;
  font-weight: 600;
}

.cz .help-dock-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--rule);
}

.cz .help-comments {
  font-size: 13px;
  font-weight: 600;
}

.cz .help-comments .toggle-track {
  scale: 0.85;
}

.cz .help-dock-note {
  color: var(--muted);
  font-size: 12.5px;
}

.cz .help-say,
.cz .help-shape {
  margin: 0;
  text-wrap: pretty;
}

.cz .help-shape code,
.cz .gap-line-shape {
  display: inline-block;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--code-bg);
  box-shadow: inset 0 0 0 1px var(--rule);
  font: var(--code-size) / 1.7 var(--mono);
}

/* A blank in a shape, where a name or a value goes: a small tinted box, like the blanks themselves. */
.cz .help-shape .blank,
.cz .gap-line .blank {
  display: inline-block;
  width: 2.4ch;
  height: 1.1em;
  margin: 0 1px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--gap-ink) 22%, transparent);
  vertical-align: -0.2em;
}

.cz .help-shape .blank::before,
.cz .gap-line .blank::before {
  content: none;
}

/* A gap of several lines, line by line, under what it does: each at its indentation, a dotted line until help with it is
   taken, then its words, its shape or itself, with a pill for the next help it gives. */
.cz .gap-lines {
  flex-basis: 100%;
  margin: 2px 0 0;
  padding: 0;
  list-style: none;
}

.cz .gap-line {
  display: grid;
  grid-template-columns: 2.5ch minmax(0, 1fr) auto;
  align-items: center;
  gap: 0 10px;
  min-height: 32px;
  border-top: 1px solid color-mix(in srgb, var(--accent) 16%, transparent);
}

.cz .gap-line-no {
  color: var(--muted);
  font: 11px / 1 var(--mono);
  text-align: right;
}

.cz .gap-line-body {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  min-width: 0;
  padding: 4px 0 4px calc(var(--indent) * 1ch);
  font: var(--code-size) / 1.6 var(--mono);
  overflow-wrap: anywhere;
}

.cz .gap-line-words {
  color: var(--fg);
  font: 400 14px / 1.45 var(--sans);
}

.cz .gap-line-blank {
  display: inline-block;
  width: min(14ch, 100%);
  height: 0.8em;
  border-bottom: 1.5px dotted var(--muted);
}

.cz .gap-line.is-shown code {
  color: var(--shown);
}

/* On the lines of a longer gap the pills are quiet, so a column of them does not shout; one fills in when its line is
   pointed at. */
.cz .gap-line .help-pill {
  border-color: transparent;
  background: none;
  color: var(--muted);
}

.cz .gap-line .help-pill .icon {
  color: currentColor;
}

.cz .gap-line:hover .help-pill {
  border-color: var(--rule-strong);
  background: var(--card);
  color: var(--ink-2);
}

.cz .gap-line .help-pill:hover {
  border-color: var(--accent-strong);
  background: var(--accent-soft);
  color: var(--fg);
}

/* The keys, under the code on the row Check shares, at its right. */
.cz .editor-shortcuts {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  min-height: 40px;
  margin: 12px 4px 0;
  padding-right: 150px;
  color: var(--muted);
  font-size: 11px;
}

.cz .editor-shortcuts kbd {
  padding: 1px 5px;
  border: 1px solid var(--edge);
  border-radius: 4px;
  background: var(--surface);
  font: 10px var(--mono);
}

.cz .editor-shortcuts > span {
  margin-inline: 6px;
}

/* ---------------------------------------------------------------- the explanation */

/* Why the approach works, closed until it is asked for, under the code: a card set for reading, with the idea as a lead,
   the walk through a test, the steps numbered, and what to watch for set apart. */
.cz .explanation {
  margin: 18px 0 0;
  overflow: hidden;
  border: 1px solid var(--edge);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  color: var(--fg);
  font-size: 15px;
  line-height: 1.65;
}

.cz .explanation summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 2px 14px;
  padding: 16px 20px;
  list-style: none;
  cursor: pointer;
}

.cz .explanation summary::-webkit-details-marker {
  display: none;
}

/* A chevron that turns as it opens. */
.cz .explanation summary::after {
  content: "";
  grid-column: 3;
  grid-row: 1 / span 2;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: translateY(-2px) rotate(45deg);
}

.cz .explanation[open] summary::after {
  transform: translateY(2px) rotate(225deg);
}

.cz .explanation summary:hover {
  background: var(--wash);
}

.cz .explanation summary:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: -2px;
}

.cz .explanation[open] summary {
  border-bottom: 1px solid var(--edge);
}

.cz .explanation-title {
  font: 600 16px / 1.3 var(--sans);
}

.cz .explanation-sub {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.cz .explanation > section {
  margin: 22px 20px 0;
}

.cz .explanation > section:last-child {
  margin-bottom: 20px;
}

.cz .explanation h3 {
  margin: 0 0 8px;
  color: var(--accent-strong);
  font: 600 13px / 1.4 var(--sans);
  letter-spacing: 0.01em;
}

.cz .explanation-idea {
  max-width: 68ch;
  margin: 0;
  font-size: 16.5px;
  line-height: 1.7;
}

/* The steps, each with its number in a round mark. */
.cz .explanation-steps {
  display: grid;
  gap: 12px;
  max-width: 70ch;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.cz .explanation-steps li {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 12px;
  counter-increment: step;
}

.cz .explanation-steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font: 700 12px / 1 var(--sans);
}

/* What to watch out for, on a soft gold, each with a mark of its own. */
.cz .explanation-pitfalls {
  padding: 14px 16px 16px;
  border-radius: 14px;
  background: var(--gold-soft);
}

.cz .explanation .explanation-pitfalls h3 {
  color: var(--gold);
}

.cz .explanation-pitfalls ul {
  display: grid;
  gap: 8px;
  max-width: 70ch;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cz .explanation-pitfalls li {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 10px;
}

.cz .explanation-pitfalls li::before {
  content: "!";
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-top: 4px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--surface);
  font: 800 11px / 1 var(--sans);
}

/* ---------------------------------------------------------------- a walk through a test */

/* A readable timeline paired with one state diagram. The sequence stays visible; the picture shows the selected moment. */
.cz .walk {
  --walk-label: 7ch;
  container: trace / inline-size;
  padding: 16px;
  border: 1px solid var(--edge);
  border-radius: 14px;
  background: var(--code-bg);
}

.cz .explanation > .walk {
  margin: 22px 20px 0;
}

.cz .walk-head {
  display: flex;
  flex-wrap: wrap;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 18px;
}

.cz .walk-head h3 {
  margin: 0;
  color: var(--fg);
  font: 600 16px / 1.3 var(--sans);
  letter-spacing: normal;
}

.cz .walk-head > div:first-child {
  flex: 1 1 240px;
  min-width: 0;
}

.cz .walk-call {
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

.cz .walk-call code {
  display: inline-block;
  max-width: 100%;
  padding: 3px 9px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--fg) 6%, transparent);
  color: var(--ink-2);
  font: 13px / 1.5 var(--mono);
}

/* What happened, first and large, with which step it is. */
.cz .walk-say {
  display: flex;
  flex-direction: column;
  align-items: start;
  gap: 8px;
  margin: 0 0 16px;
  font-size: 15px;
  line-height: 1.6;
}

.cz .walk-step {
  flex: none;
  padding: 2px 10px;
  border-radius: var(--pill);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font: 600 12px / 1.6 var(--sans);
  white-space: nowrap;
}

.cz .walk-returns code {
  padding: 1px 7px;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font: 600 14px var(--mono);
}

.cz .walk-stage {
  display: grid;
  gap: 14px;
  min-height: 60px;
  padding: 16px;
  overflow-x: auto;
  border-radius: 12px;
  background: var(--surface);
  scrollbar-width: thin;
}

/* Each thing in the picture: its name on the left, what it holds on the right. */
.cz .walk-row,
.cz .walk-list,
.cz .walk-track,
.cz .walk-map,
.cz .walk-var {
  display: grid;
  grid-template-columns: var(--walk-label) minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.cz .walk-name {
  margin: 0;
  color: var(--ink-2);
  font: 600 13px / 1.4 var(--mono);
  text-align: right;
  overflow-wrap: anywhere;
}

.cz .walk-cells,
.cz .walk-nodes {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cz .walk-cell,
.cz .walk-node,
.cz .walk-null {
  display: grid;
  grid-template-rows: 20px auto 16px;
  justify-items: center;
  gap: 2px;
  min-width: 36px;
  font: 15px / 1.2 var(--mono);
}

/* A row's cells give up a little width each, so a row of nine still fits a side panel. */
.cz .walk-cell {
  flex: 0 1 40px;
  min-width: 26px;
}

.cz .walk-cell .walk-value {
  width: 100%;
  min-width: 0;
  padding: 0 2px;
}

/* A pointer is a small tag over the cell it is at. */
.cz .walk-pointers {
  align-self: end;
  padding: 0 6px;
  border-radius: var(--pill);
  background: var(--accent-strong);
  color: var(--accent-fg);
  font: 700 11px / 17px var(--sans);
  white-space: nowrap;
}

.cz .walk-pointers:empty {
  visibility: hidden;
}

.cz .walk-value {
  display: grid;
  place-items: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--code-bg);
}

.cz .walk-index {
  color: var(--muted);
  font-size: 11px;
}

.cz .walk-cell.is-span .walk-value {
  border-color: var(--olive);
  background: color-mix(in srgb, var(--olive) 16%, var(--code-bg));
}

.cz .walk-cell.is-picked .walk-value,
.cz .walk-node.is-picked .walk-value,
.cz .walk-interval.is-picked {
  border-color: var(--accent-strong);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
}

.cz .walk-cell.is-dim,
.cz .walk-node.is-dim,
.cz .walk-interval.is-dim {
  opacity: 0.35;
}

.cz .walk-cell.is-ghost .walk-value {
  border-style: dashed;
  background: none;
}

.cz .walk-empty {
  color: var(--muted);
  font: italic 13px / 36px var(--sans);
}

/* Bars: each cell's value as a bar as tall as it, on a shared floor, with the value at its foot. */
.cz .is-bars .walk-cell {
  grid-template-rows: 20px 100px 16px;
}

.cz .is-bars .walk-value {
  align-self: end;
  height: max(22px, calc(var(--h, 0) * 100px));
  place-items: end center;
  padding-bottom: 3px;
  border-radius: 6px 6px 0 0;
  background: color-mix(in srgb, var(--ocean) 22%, var(--code-bg));
}

/* A linked list: nodes, the arrows between them, and the null at each end. */
.cz .walk-null .walk-value {
  border: 0;
  background: none;
  color: var(--muted);
}

.cz .walk-link {
  align-self: center;
  min-width: 16px;
  margin-top: 4px;
  color: var(--accent-strong);
  font: 700 17px / 1 var(--mono);
  text-align: center;
}

/* Intervals on a line shared by every track of the walk, overlapping ones in lanes one above another. */
.cz .walk-lanes,
.cz .walk-axis {
  position: relative;
  margin: 0 12px 0 6px;
}

.cz .walk-lanes {
  height: calc(var(--lanes) * 28px);
}

.cz .walk-interval {
  position: absolute;
  top: calc(var(--lane) * 28px);
  left: calc(var(--left) * 100%);
  width: max(8px, calc(var(--width) * 100%));
  height: 24px;
  overflow: hidden;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  background: var(--code-bg);
  font: 12px / 22px var(--mono);
  text-align: center;
  white-space: nowrap;
}

.cz .walk-axis {
  height: 18px;
  margin-left: calc(var(--walk-label) + 14px + 6px);
  border-top: 1px solid var(--rule-strong);
}

.cz .walk-tick {
  position: absolute;
  left: calc(var(--left) * 100%);
  color: var(--muted);
  font: 11px / 18px var(--mono);
  transform: translateX(-50%);
}

/* Maps and variables, each by name like the rest. */
.cz .walk-state,
.cz .walk-vars {
  display: grid;
  gap: 14px;
  margin: 0;
}

.cz .walk-map dl,
.cz .walk-set {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cz .walk-map dl > div,
.cz .walk-set li,
.cz .walk-var dd {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--code-bg);
  font: 14px / 1.4 var(--mono);
}

.cz .walk-var dd {
  justify-self: start;
  margin: 0;
  font-weight: 700;
}

.cz .walk-map dd {
  margin: 0;
  font-weight: 700;
}

.cz .walk-map dl span {
  color: var(--muted);
}

/* What changed since the step before keeps a gold ring for the step, and glows once as it comes, unless the learner asked
   for less motion. */
.cz .walk .is-changed .walk-value,
.cz .walk-cell.is-changed .walk-value,
.cz .walk-var.is-changed dd,
.cz .walk-map dl > div.is-changed,
.cz .walk-track.is-changed .walk-interval {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--star) 65%, transparent);
}

@media (prefers-reduced-motion: no-preference) {
  .cz .walk .is-changed .walk-value,
  .cz .walk-cell.is-changed .walk-value,
  .cz .walk-var.is-changed dd,
  .cz .walk-map dl > div.is-changed,
  .cz .walk-track.is-changed .walk-interval {
    animation: walk-glow 900ms var(--ease);
  }
}

@keyframes walk-glow {
  from {
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--star) 60%, transparent);
  }
}

/* The whole sequence can be read without advancing the diagram. Numbered buttons also jump straight to a moment. */
.cz .walk-body {
  display: grid;
  gap: 22px;
  min-width: 0;
}

.cz .walk-inspect {
  min-width: 0;
  padding: 14px 0 20px;
  scroll-margin: 70px 0 140px;
}

.cz .walk-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.cz .walk-timeline {
  display: grid;
  align-content: start;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cz .walk-timeline > li {
  position: relative;
}

.cz .walk-timeline > li:not(:last-child)::before {
  content: "";
  position: absolute;
  top: 30px;
  bottom: -10px;
  left: 23px;
  border-left: 1px solid var(--rule-strong);
}

.cz .walk-moment {
  position: relative;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-2);
  font: 13px / 1.6 var(--sans);
  text-align: left;
}

.cz .walk-number {
  display: grid;
  place-items: center;
  height: 26px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--pill);
  background: var(--code-bg);
  color: var(--muted);
  font: 600 11px / 1 var(--mono);
}

.cz .walk-moment[aria-current="step"] {
  border-color: var(--rule-strong);
  background: var(--surface);
  color: var(--fg);
}

.cz .walk-moment[aria-current="step"] .walk-number {
  border-color: var(--accent-strong);
  background: var(--accent-strong);
  color: var(--accent-fg);
}

.cz .walk-moment:hover {
  background: var(--wash);
  color: var(--fg);
}

.cz .walk-moment:focus-visible {
  outline: 2px solid var(--accent-strong);
  outline-offset: -2px;
}

.cz .walk-var s {
  color: var(--muted);
  font-weight: 400;
  text-decoration-thickness: 1px;
}

.cz .walk-var dd > span[aria-hidden] {
  color: var(--muted);
  font-weight: 400;
}

/* In the inline layout, the selected button already states the reasoning. Keep the diagram next to it without repeating it. */
@container trace (max-width: 679px) {
  .cz .walk-text,
  .cz .walk-timeline > li:has(.walk-inspect)::before {
    display: none;
  }
}

@container trace (min-width: 680px) {
  .cz .walk-timeline {
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.4fr);
    gap: 4px 24px;
  }

  .cz .walk-inspect {
    position: sticky;
    top: 12px;
    grid-column: 2;
    grid-row: 1 / span var(--trace-steps);
    align-self: start;
    padding: 0;
  }

  .cz .walk-timeline > li {
    display: contents;
  }

  .cz .walk-timeline > li::before {
    display: none;
  }

  .cz .walk-moment {
    grid-column: 1;
    grid-row: var(--trace-step);
  }
}

/* In a side panel, names go above what they hold, so the picture has the whole width. */
@container practice (max-width: 520px) {
  .cz .walk-row,
  .cz .walk-list,
  .cz .walk-track,
  .cz .walk-map,
  .cz .walk-var {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
  }

  .cz .walk-name {
    text-align: left;
  }

  .cz .walk-axis {
    margin-left: 6px;
  }

  .cz .walk-say {
    flex-direction: column;
    gap: 6px;
  }

  .cz .explanation > section,
  .cz .explanation > .walk {
    margin-inline: 14px;
  }

  .cz .walk {
    padding: 12px;
  }

  .cz .walk-stage {
    padding: 12px;
  }
}

/* ---------------------------------------------------------------- the tests */

.cz .tests {
  min-width: 0;
  padding-top: 20px;
  border-top: 1px solid var(--edge);
}

.cz .tests h2 {
  margin: 0 0 12px;
  color: var(--fg);
  font: 600 14px / 1.4 var(--sans);
}

.cz .tests h2 span {
  color: var(--muted);
  font-weight: 400;
}

.cz .tests ol {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

/* A test: a small soft card with no outline, tinted in the colour of a fail when it fails. */
.cz .tests li {
  padding: 10px 12px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--fg) 4%, transparent);
  font-size: 13px;
}

.cz .tests li.is-fail {
  background: color-mix(in srgb, var(--fail-soft) 55%, transparent);
}

/* A mark for each case, to go to it, where the tests are a row to swipe through (a narrow panel, below). */
.cz .case-marks {
  display: none;
}

.cz .case-marks .mark {
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  font-size: 11px;
  cursor: pointer;
}

.cz .case-marks .mark:hover {
  box-shadow: inset 0 0 0 1px var(--rule-strong);
}

/* The case in view: its mark filled, in its state's colour after a Check, and a size up, so it reads at a glance as the row is swiped. */
.cz .case-marks .mark[aria-current="true"] {
  background: var(--accent);
  color: var(--card);
  transform: scale(1.12);
}

.cz .case-marks .mark.is-pass[aria-current="true"] {
  background: var(--pass);
}

.cz .case-marks .mark.is-fail[aria-current="true"] {
  background: var(--fail);
}

.cz .mark.is-pass {
  background: var(--pass-soft);
  color: var(--pass);
}

.cz .mark.is-fail {
  background: var(--fail-soft);
  color: var(--fail);
}

.cz .case-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
}

.cz .mark {
  display: grid;
  flex: none;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--fg) 8%, transparent);
  color: var(--muted);
  font: 700 10px / 1 var(--sans);
}

.cz .is-pass .mark {
  background: var(--pass-soft);
  color: var(--pass);
}

.cz .is-fail .mark {
  background: var(--fail-soft);
  color: var(--fail);
}

.cz .case-title {
  flex: 1;
  margin: 0;
  color: var(--fg);
  font: 600 12.5px var(--sans);
}

.cz .case-state {
  padding: 1px 8px;
  border-radius: var(--pill);
  font: 600 11px / 1.5 var(--sans);
}

.cz .is-pass .case-state {
  background: var(--pass-soft);
  color: var(--pass);
}

.cz .is-fail .case-state {
  background: var(--fail-soft);
  color: var(--fail);
}

/* A test's values, each by its name: drawn in the shape of its type when the whole of it fits (view/drawn.ts, drawn as
   shared/ui.css says), and written out when not. What it should come to is under a dashed rule, and after a Check that
   fails, what it got, named in the colour of a fail. A name sits level with the middle of a tile. */
.cz .case-values {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: start;
  gap: 6px 0;
  margin: 0;
}

.cz .case-values > div {
  display: contents;
}

.cz .case-values dt {
  padding-right: 12px;
  color: var(--muted);
  font: 12px / 26px var(--mono);
  white-space: nowrap;
}

.cz .case-values dd {
  min-width: 0;
  margin: 0;
}

.cz .case-values .case-expect > * {
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px dashed var(--edge);
}

.cz .case-values .case-got dt {
  color: var(--fail);
  font-weight: 600;
}

/* A value too large to draw whole, as the language writes it. */
.cz .drawn-written {
  display: block;
  padding: 3px 0;
  color: var(--fg);
  font: 12.5px / 1.65 var(--mono);
  overflow-wrap: anywhere;
}

.cz .call,
.cz .got {
  font: 12.5px / 1.65 var(--mono);
  overflow-wrap: anywhere;
}

.cz .got {
  margin-top: 6px;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--fail-soft);
  color: var(--fail);
}

/* A test of a class: its calls in order, each with what it returns, and a call that returned something else marked. */
.cz .tests .case-calls {
  gap: 0;
  font: 12.5px / 1.65 var(--mono);
}

.cz .tests .case-calls li {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 0.8ch;
  padding: 0;
  border-radius: 0;
  background: none;
  font-size: inherit;
}

.cz .case-calls .call {
  color: var(--muted);
}

.cz .case-calls .returns::before {
  content: "→ ";
  color: var(--muted);
}

.cz .case-calls .got {
  margin: 0;
  padding: 0 6px;
}

.cz .summary .is-pass {
  color: var(--pass);
}

.cz .printed {
  margin: 8px 0 0;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--fg) 6%, transparent);
  font: 12px / 1.5 var(--mono);
  white-space: pre-wrap;
}

/* ---------------------------------------------------------------- the foot: what the last Check found, and Check */

/* Check, on its own, at the right of the row of keys under the code, and kept in sight while a long solution scrolls. */
.cz .foot {
  position: sticky;
  bottom: 12px;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 8px 12px;
  width: fit-content;
  max-width: 100%;
  margin: -40px 0 4px auto;
}

/* But not over the help at the editor's foot, whose controls it would cover: as soon as the help comes into sight, Check stops
   floating and rests in its place under it. A browser without scroll-driven animations keeps it floating; without the guard,
   the animation would run at once and Check would never float. */
@supports (timeline-scope: --help-dock) and (animation-range: entry) {
  .cz .work {
    timeline-scope: --help-dock;
  }

  .cz .help-dock {
    view-timeline: --help-dock block;
  }

  .cz .foot {
    animation: foot-rests linear forwards;
    animation-timeline: --help-dock;
    animation-range: entry 0% entry 100%;
  }
}

@keyframes foot-rests {
  from,
  to {
    bottom: auto;
  }
}

/* Once a Check has run, what it found rises over Check as a small card, its tail pointing down at it: what went wrong, or
   that it passed, what that earned, and the step onward. The card is plain; the mark and the headline carry the colour of how
   it went, and say it in words too. */
.cz .summary.is-pass,
.cz .summary.is-fail {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  align-items: flex-start;
  width: max-content;
  max-width: min(380px, calc(100cqi - 24px));
  padding: 14px 16px;
  border: 1px solid var(--edge);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 12px 32px rgb(0 0 0 / 0.22);
}

.cz .summary.is-fail {
  align-items: center;
  border-color: color-mix(in srgb, var(--fail) 40%, var(--edge));
}

/* The tail: a small square turned on its corner, sharing the bubble's edge, over the middle of Check. */
.cz .summary.is-pass::after,
.cz .summary.is-fail::after {
  content: "";
  position: absolute;
  right: 54px;
  bottom: -7px;
  width: 12px;
  height: 12px;
  border: inherit;
  border-width: 0 1px 1px 0;
  background: inherit;
  rotate: 45deg;
}

@media (prefers-reduced-motion: no-preference) {
  .cz .summary.is-pass,
  .cz .summary.is-fail {
    animation: summary-rise 220ms var(--ease);
  }
}

@keyframes summary-rise {
  from {
    opacity: 0;
    translate: 0 6px;
  }
}

.cz .summary {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
}

.cz .summary-text {
  min-width: 0;
}

.cz .summary .button-quiet {
  margin: -4px 0;
}

/* The mark: a dot before a Check, a turning ring while it runs, then a tick or a cross. */
.cz .summary-mark {
  display: grid;
  flex: none;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--fg) 7%, transparent);
  color: var(--muted);
  font: 800 14px / 1 var(--sans);
}

.cz .is-idle .summary-mark::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
}

.cz .is-running .summary-mark {
  border: 2.5px solid color-mix(in srgb, var(--accent-strong) 25%, transparent);
  border-top-color: var(--accent-strong);
  background: none;
  animation: summary-turn 800ms linear infinite;
}

.cz .is-pass .summary-mark {
  background: var(--pass);
  color: var(--surface);
}

.cz .is-pass .summary-mark::before {
  content: "✓";
}

.cz .is-fail .summary-mark {
  background: var(--fail);
  color: var(--surface);
}

.cz .is-fail .summary-mark::before {
  content: "✕";
}

/* A passing Check: a card that glows in the colour of a pass along its top, the result as its headline, what it earned as a
   small chip among the details, and the step onward as one wide button. The headline's tick says it, so the round mark
   steps aside. */
.cz .summary.is-pass {
  display: block;
  width: min(380px, calc(100cqi - 24px));
  padding: 16px 18px 18px;
  border-color: color-mix(in srgb, var(--pass) 35%, var(--edge));
  background: radial-gradient(120% 90px at 50% 0, color-mix(in srgb, var(--pass) 22%, transparent), transparent), var(--surface);
}

.cz .summary.is-pass .summary-mark {
  display: none;
}

.cz .summary.is-pass::after {
  background: var(--surface);
}

.cz .summary.is-pass::after {
  background: var(--surface);
}

.cz .summary.is-pass .summary-text {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.cz .summary.is-pass strong {
  display: block;
  margin-bottom: 4px;
  color: var(--pass);
  font: 700 19px / 1.25 var(--sans);
  letter-spacing: -0.01em;
}

/* A word from someone who shaped computing, set like a pull quote, with who said it under it. */
.cz .summary-quote {
  display: block;
  margin-top: 10px;
  padding-left: 12px;
  border-left: 2px solid color-mix(in srgb, var(--pass) 45%, transparent);
  color: var(--fg);
  font: italic 400 15px / 1.45 var(--serif);
}

.cz .summary-quote q {
  quotes: "“" "”";
}

.cz .summary-quote-by {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font: 500 12px / 1.4 var(--sans);
  font-style: normal;
}

.cz .summary-quote-by::before {
  content: "— ";
}

.cz .summary-quote-by a {
  color: var(--fg);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--fg) 30%, transparent);
  text-underline-offset: 2px;
}

.cz .summary-earned {
  display: inline-block;
  margin-left: 4px;
  padding: 0 8px;
  border-radius: var(--pill);
  background: color-mix(in srgb, var(--pass) 16%, transparent);
  color: var(--pass);
  font-weight: 600;
}

/* What a pass earned sits in the card's top right corner, as on a score card, clear of the headline. */
.cz .summary.is-pass .summary-earned {
  position: absolute;
  top: 14px;
  right: 14px;
  margin: 0;
  padding: 3px 10px;
  font-size: 13px;
  white-space: nowrap;
}

.cz .summary.is-pass:has(.summary-earned) strong {
  padding-right: 140px;
}

/* What a host kept, in its own words (on Reddit: the day, the streak and the place on the board, or why the day did not
   count): a line of its own under the headline, wrapping as it needs, where the corner chip would run over the headline. */
.cz .summary-kept {
  display: block;
  color: var(--fg);
  font-weight: 600;
}

/* Under the headline of a kept pass, the problem's XP out of its worth, so a solve shows how far up the problem it went. */
.cz .summary > .problem-xp {
  display: flex;
  width: fit-content;
  margin: 8px 0 2px;
}

.cz .summary.is-pass .button-primary {
  display: flex;
  justify-content: center;
  width: 100%;
  min-height: 40px;
  margin-top: 14px;
}

.cz .summary.is-pass .button-quiet {
  margin: 0;
}

/* With the step onward in the card, Check steps back. */
.cz .foot:has(.summary.is-pass) > .button-primary {
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--fg);
}

/* Before a Check, and while it runs, there is only Check (it says "Checking…" itself); the words are still the status a
   screen reader hears. */
.cz .summary.is-idle,
.cz .summary.is-running {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: no-preference) {
  .cz .summary.is-pass {
    transform-origin: 80% 100%;
    animation: summary-pop 420ms var(--ease);
  }
}

@keyframes summary-pop {
  0% {
    opacity: 0;
    transform: translateY(8px) scale(0.92);
  }

  60% {
    opacity: 1;
    transform: translateY(-2px) scale(1.02);
  }

  100% {
    transform: none;
  }
}

/* The confetti of a passing Check, over everything and in the way of nothing. */
.confetti {
  position: fixed;
  inset: 0;
  z-index: 60;
  overflow: hidden;
  pointer-events: none;
}

.confetti span {
  position: absolute;
  width: 6px;
  height: 12px;
  border-radius: 2px;
}

.confetti .is-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

@keyframes summary-turn {
  to {
    transform: rotate(1turn);
  }
}

/* A guest is told in the editor's bar, where a solve's worth would be, that nothing is kept, and how to change that. */
.cz .guest-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.cz .guest-note .button-quiet {
  margin: -4px 0;
}

.cz .guest-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border: 1.5px dashed var(--muted);
  border-radius: 50%;
}

.cz .foot .button-primary {
  flex: none;
  box-shadow: var(--shadow-card);
  gap: 10px;
  min-height: 40px;
  padding-inline: 18px;
  border-radius: 16px;
  font-size: 15px;
}

.cz .foot > .button-primary {
  margin-left: auto;
}

.cz .foot .button-primary kbd {
  padding: 1px 6px;
  border-radius: 5px;
  background: color-mix(in srgb, var(--accent-fg) 12%, transparent);
  font: 600 11px / 1.5 var(--sans);
}

/* ---------------------------------------------------------------- by the room there is */

/* With the room, two sides that fill the window under the page's bar and scroll on their own: the problem and its tests on
   the left, the work on the right. */
@container practice (min-width: 880px) {
  .cz .practice {
    display: grid;
    grid-template-columns: minmax(300px, 420px) minmax(0, 1fr);
    gap: 18px;
    flex: 1 1 auto;
    min-height: 0;
    /* A host that gives the panel a height of its own (the website) sets this to auto. */
    height: var(--practice-height, max(520px, calc(100dvh - var(--practice-top, 80px) - 16px)));
    max-width: none;
    /* A host whose page already has a gutter (the website) sets this to 0, so the panel lines up with its bar. */
    padding: 16px var(--practice-gutter, 20px) 12px;
  }

  .cz .brief-panel {
    padding: 10px 18px 20px 0;
  }

  .cz .brief-panel,
  .cz .work {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }

  /* Room for the editor's shadow and focus rings inside the scrolling side, taken back from the gap so its edge lines up. */
  .cz .work {
    margin: 0 -6px;
    padding: 6px 6px 20px;
  }
}

/* In a side panel or on a phone, one column: the problem, its tests, then the work. A long task scrolls in its own few lines,
   and the tests are a row to swipe through, one case at a time with the next showing at the edge, so the code stays near
   the top. A mark for each case, with how it went, goes to it. */
@container practice (max-width: 879px) {
  .cz .practice {
    display: flex;
    flex-direction: column;
    gap: 18px;
  }

  .cz .brief-panel {
    display: contents;
  }

  .cz .about {
    order: 1;
    margin: 0;
  }

  .cz .tests {
    order: 2;
    padding-top: 0;
    border-top: 0;
  }

  .cz .work {
    order: 3;
  }

  .cz .tests-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 12px;
    margin: 0 0 10px;
  }

  .cz .tests h2 {
    margin: 0;
  }

  .cz .case-marks {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
  }

  .cz .tests > ol {
    position: relative;
    display: flex;
    align-items: stretch;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .cz .tests > ol::-webkit-scrollbar {
    display: none;
  }

  .cz .tests > ol > li {
    flex: 0 0 88%;
    min-width: 0;
    scroll-snap-align: start;
  }

  .cz .task {
    max-height: calc(15.5px * 1.6 * 6);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
  }
}

/* A task cut to its few lines fades at its foot while there is more of it to scroll to, so the cut reads as more, not as its
   end. A task that fits has no scroll to follow, so it does not fade; a browser without scroll-driven animations shows it cut. */
@property --task-more {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

@keyframes task-more {
  from {
    --task-more: 2.4em;
  }

  to {
    --task-more: 0px;
  }
}

@supports (animation-timeline: scroll()) {
  .cz .task {
    mask-image: linear-gradient(#000 calc(100% - var(--task-more)), transparent);
    animation: task-more linear both;
    animation-timeline: scroll(self);
  }
}

/* In a side panel: tighter, the steps smaller, and the code a size down. */
@container practice (max-width: 520px) {
  .cz {
    --code-size: 12.5px;
    --code-line: 26px;
  }

  .cz .practice {
    padding: 18px 12px 24px;
  }

  .cz .code {
    --gutter: 3.5ch;
  }

  .cz .line {
    padding-left: calc(var(--gutter) + (var(--indent) * 0.5 + 2) * 1ch);
  }

  /* The coloured copy of what is typed moves with its field, or the caret is a few characters away from the text. */
  .cz .gap .gap-field,
  .cz .gap .gap-mirror {
    padding-left: calc(var(--gutter) + var(--indent) * 0.5ch);
  }

  .cz .gap-notes {
    padding-left: calc(var(--gutter) + var(--indent) * 0.5ch);
  }

  .cz .gap.is-active.is-helped::after,
  .cz .line-comment {
    left: calc(var(--gutter) + var(--indent) * 0.5ch);
  }

  .cz .line-comment {
    max-width: calc(100% - var(--gutter) - var(--indent) * 0.5ch - 12px);
  }

  .cz .gap-line-body {
    padding-left: calc(var(--indent) * 0.5ch);
  }

  .cz .help-dock {
    padding: 12px 12px 14px;
  }

  /* With little room the ladder may wrap, so its rungs go without the lines between them. */
  .cz .help-rung + .help-rung::before {
    display: none;
  }

  /* With little room, the keys take the row, and Check has one of its own under them. */
  .cz .foot {
    bottom: 10px;
    margin-top: 12px;
  }

  .cz .editor-shortcuts {
    min-height: 0;
    padding-right: 0;
  }
}

/* On a touch screen, the code is 16px: iOS zooms the page into a field set any smaller as it takes the caret, and leaves it
   zoomed, and a finger wants the larger mark anyway. The keys are a keyboard's, so they go, and Check has a row of its own. */
@media (pointer: coarse) {
  .cz {
    --code-size: 16px;
    --code-line: 30px;
  }

  .cz .editor-shortcuts,
  .cz .foot .button-primary kbd {
    display: none;
  }

  .cz .foot {
    margin-top: 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cz .is-running .summary-mark {
    animation-duration: 2.4s;
  }

  .cz .blank .gap-field,
  .cz .gap,
  .cz .help-pill {
    transition: none;
  }

  .cz .line-comment {
    translate: 0;
  }

  .cz [data-beat] {
    transition: none;
  }
}
