/* Components: buttons, runner (editor + results), result table, chart,
   errors, callouts, syntax, quiz, exercise, controls, overlays. */

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 6px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--fs-sm);
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast), color var(--dur-fast), transform var(--dur-fast);
}

.btn:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--rule));
  color: var(--accent);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* The site's primary action: the brand gradient with white text. */
.btn-primary {
  background: var(--brand-gradient);
  border-color: transparent;
  color: var(--on-btn);
  box-shadow: 0 10px 30px -14px color-mix(in srgb, var(--btn-b) 70%, transparent);
  transition: filter var(--dur-fast), box-shadow var(--dur-fast), transform var(--dur-fast);
}

.btn-primary:hover {
  background: var(--brand-gradient);
  color: var(--on-btn);
  filter: brightness(1.1);
  box-shadow: 0 14px 36px -14px color-mix(in srgb, var(--btn-b) 85%, transparent);
}

.btn-ok {
  background: var(--ok);
  border-color: var(--ok);
  color: var(--ok-ink);
}

.btn-ok:hover {
  background: var(--ok);
  color: var(--ok-ink);
  filter: brightness(1.08);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-2);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--ink);
}

.btn-sm {
  min-height: 30px;
  padding: 4px 10px;
  font-size: var(--fs-xs);
}

.btn-lg {
  min-height: 46px;
  padding: 10px 22px;
  font-size: var(--fs-base);
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
}

.kbd-hint {
  font-size: var(--fs-2xs);
  color: var(--ink-3);
  white-space: nowrap;
}

/* ---------------------------------------------------------------- chips & badges */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  border: 1px solid var(--rule);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  line-height: 1.7;
  white-space: nowrap;
}

.chip svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.chip-ok {
  border-color: transparent;
  background: var(--ok-soft);
  color: var(--ok);
}

.chip-accent {
  border-color: transparent;
  background: var(--accent-soft);
  color: var(--accent);
}

.chip-code {
  direction: ltr;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
}

/* ---------------------------------------------------------------- progress bar */
.bar {
  position: relative;
  height: 6px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  overflow: hidden;
}

.bar-fill {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  border-radius: inherit;
  background: var(--accent);
  transition: width 600ms var(--ease);
}

.bar-fill.is-complete {
  background: var(--ok);
}

/* ---------------------------------------------------------------- block frame */
.block {
  margin-block: var(--s-5);
  min-width: 0;
}

/* Text inside flex rows may shrink and wrap. */
.quiz-option > .md,
.hint > .md,
.lint-item > .md,
.lab-info-item {
  flex: 1 1 auto;
  min-width: 0;
}

/* Grid containers size their single column to the container, never to their content. */
.prose,
.block-md,
.quiz,
.quiz-options,
.callout,
.syntax,
.exercise-head,
.exercise-prompt,
.feedback,
.hints,
.solution,
.tutor,
.tutor-thread,
.step-body {
  grid-template-columns: minmax(0, 1fr);
}

.block-title {
  font-size: var(--fs-md);
  font-weight: 650;
  margin-block-end: var(--s-2);
}

.block-md {
  display: grid;
  gap: var(--s-3);
}

.block-md + .runner,
.block-md + .param-controls,
.block-md + .lab,
.block-md + .compare-grid {
  margin-block-start: var(--s-3);
}

.md p,
.md li {
  color: var(--ink);
}

.md ul,
.md ol {
  margin: 0;
  padding-inline-start: 1.4em;
  display: grid;
  gap: 4px;
}

.md li::marker {
  color: var(--ink-3);
}

.md .md-heading {
  font-size: var(--fs-md);
  font-weight: 700;
  margin-block-start: var(--s-3);
}

.md pre.md-code {
  margin: 0;
}

.prose {
  display: grid;
  gap: var(--s-3);
}

/* ---------------------------------------------------------------- runner */
.runner {
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.runner-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: 42px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface-2);
}

.runner-title {
  font-size: var(--fs-sm);
  font-weight: 650;
  color: var(--ink);
}

.runner-tag {
  font-size: var(--fs-2xs);
  font-weight: 600;
  color: var(--ink-3);
  letter-spacing: 0.03em;
}

.runner-head .btn-row {
  margin-inline-start: auto;
}

.runner-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  padding: 8px 12px;
  border-bottom: 1px solid var(--rule);
  background: var(--surface);
}

.runner-bar .spacer {
  flex: 1;
}

.runner-body > .md {
  padding: 10px 14px 0;
}

.runner-note {
  padding: 10px 14px 12px;
  border-top: 1px dashed var(--rule);
  color: var(--ink-2);
  font-size: var(--fs-sm);
}

.runner.is-running .result {
  opacity: 0.55;
}

/* ---------------------------------------------------------------- results */
.result {
  transition: opacity var(--dur-fast);
}

.result:empty {
  display: none;
}

.result-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  padding: 8px 12px;
  font-size: var(--fs-xs);
  color: var(--ink-2);
}

.result-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.result-status svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
}

.result-status.is-ok {
  color: var(--ok);
}

.result-meta .spacer {
  flex: 1;
}

.seg {
  display: inline-flex;
  padding: 2px;
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}

.seg button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
}

.seg button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-1);
}

.seg svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.result-table-wrap {
  direction: ltr;
  max-height: 440px;
  overflow: auto;
  border-top: 1px solid var(--rule);
  background: var(--surface);
}

.result-table {
  width: max-content;
  min-width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.86rem;
  line-height: 1.5;
  text-align: left;
}

.result-table th,
.result-table td {
  padding: 6px 14px;
  border-bottom: 1px solid var(--rule);
  white-space: nowrap;
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.result-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface-2);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  border-bottom: 1px solid var(--rule-strong);
}

.result-table td {
  font-family: var(--font-mono);
  color: var(--ink);
}

.result-table tbody tr:nth-child(even) td {
  background: color-mix(in srgb, var(--surface-2) 45%, var(--surface));
}

.result-table tbody tr:hover td {
  background: var(--highlight-wash);
}

.result-table .rownum {
  width: 1%;
  padding-inline: 10px;
  color: var(--ink-3);
  text-align: right;
  font-size: 0.76rem;
  border-right: 1px solid var(--rule);
  user-select: none;
}

.result-table td.is-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.result-table td.is-text {
  font-family: var(--font-body);
  unicode-bidi: plaintext;
}

.null-cell {
  display: inline-block;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--ink-3);
  font-size: 0.72rem;
  font-style: italic;
  letter-spacing: 0.03em;
}

.result-more {
  display: flex;
  justify-content: center;
  padding: 8px;
  border-top: 1px solid var(--rule);
}

.result-empty,
.result-dml {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
  padding: 12px 14px;
  font-size: var(--fs-sm);
  color: var(--ink-2);
  border-top: 1px solid var(--rule);
}

.result-dml {
  color: var(--ok);
  background: var(--ok-soft);
}

.result-truncated {
  padding: 6px 14px;
  font-size: var(--fs-xs);
  color: var(--warn);
  background: var(--warn-soft);
  border-top: 1px solid var(--rule);
}

/* Error explanation */
.error-panel {
  display: grid;
  gap: var(--s-2);
  padding: 12px 14px 14px;
  border-top: 1px solid var(--rule);
  background: var(--bad-soft);
}

.error-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--bad);
  font-size: var(--fs-sm);
}

.error-title svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.error-raw {
  direction: ltr;
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--ink-3);
  overflow-wrap: anywhere;
}

.error-panel .md {
  font-size: var(--fs-sm);
}

/* Lint warnings (shown above results) */
.lint-list {
  display: grid;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--rule);
  background: var(--warn-soft);
}

.lint-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-sm);
  color: var(--ink);
}

.lint-item::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
  flex-shrink: 0;
}

/* Keep the warning text beside its dot; the fix button wraps below when space runs out. */
.lint-item > .md {
  flex-basis: 12rem;
}

/* ---------------------------------------------------------------- chart */
.chart-wrap {
  direction: ltr;
  position: relative;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--rule);
  background: var(--surface);
}

.chart-svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.chart-svg text {
  font-family: var(--font-body);
  fill: var(--ink-3);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart-grid line {
  stroke: var(--chart-grid);
  stroke-width: 1;
}

.chart-axis line {
  stroke: var(--chart-axis);
  stroke-width: 1;
}

.chart-bar {
  transition: opacity var(--dur-fast);
}

.chart-bar.is-dim {
  opacity: 0.45;
}

.chart-line {
  fill: none;
  stroke-width: 2;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-area {
  opacity: 0.1;
}

.chart-dot {
  stroke: var(--surface);
  stroke-width: 2;
}

.chart-crosshair {
  stroke: var(--rule-strong);
  stroke-width: 1;
}

.chart-hit {
  fill: transparent;
  cursor: crosshair;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-bottom: 6px;
  font-size: var(--fs-xs);
  color: var(--ink-2);
}

.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-key {
  width: 14px;
  height: 3px;
  border-radius: 2px;
}

.chart-key.is-rect {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}

.chart-tooltip {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  min-width: 120px;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  font-size: var(--fs-xs);
  color: var(--ink-2);
}

.chart-tooltip-title {
  margin-bottom: 4px;
  color: var(--ink-2);
  font-family: var(--font-mono);
}

.chart-tooltip-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chart-tooltip-row strong {
  color: var(--ink);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.chart-note {
  padding: 10px 14px;
  font-size: var(--fs-sm);
  color: var(--ink-3);
}

/* ---------------------------------------------------------------- callouts */
.callout {
  display: grid;
  gap: 6px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--callout-line, var(--rule));
  background: var(--callout-bg, var(--surface));
}

.callout-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-sm);
}

.callout-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 1px 9px;
  border-radius: var(--r-pill);
  background: var(--callout-chip, var(--surface-2));
  color: var(--callout-ink, var(--ink));
  font-size: var(--fs-2xs);
  font-weight: 700;
  letter-spacing: 0.03em;
}

.callout-label svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
}

.callout-title {
  font-weight: 700;
  color: var(--ink);
}

.callout .md {
  font-size: 0.98rem;
}

.callout-tip {
  --callout-bg: var(--ok-soft);
  --callout-line: color-mix(in srgb, var(--ok) 25%, transparent);
  --callout-chip: color-mix(in srgb, var(--ok) 16%, var(--surface));
  --callout-ink: var(--ok);
}

.callout-info {
  --callout-bg: var(--accent-soft);
  --callout-line: color-mix(in srgb, var(--accent) 22%, transparent);
  --callout-chip: color-mix(in srgb, var(--accent) 14%, var(--surface));
  --callout-ink: var(--accent);
}

.callout-warn {
  --callout-bg: var(--warn-soft);
  --callout-line: color-mix(in srgb, var(--warn) 28%, transparent);
  --callout-chip: color-mix(in srgb, var(--warn) 16%, var(--surface));
  --callout-ink: var(--warn);
}

.callout-pro {
  --callout-bg: var(--surface);
  --callout-line: color-mix(in srgb, var(--grad-a) 35%, var(--rule));
  --callout-chip: var(--brand-gradient);
  --callout-ink: var(--on-btn);
}

.callout-dialect {
  --callout-bg: var(--surface-2);
  --callout-line: var(--rule);
  --callout-chip: var(--surface);
  --callout-ink: var(--ink-2);
}

/* ---------------------------------------------------------------- syntax block */
.syntax {
  display: grid;
  gap: var(--s-3);
}

.syntax-notes {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.syntax-note {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px var(--s-3);
  padding: 6px 10px;
  border-radius: var(--r-sm);
  transition: background var(--dur-fast);
  cursor: default;
}

.syntax-note:hover,
.syntax-note:focus-within,
.syntax-note.is-active {
  background: var(--highlight-wash);
}

.syntax-note code {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}

.syntax-note .md {
  flex: 1 1 200px;
  min-width: 0;
}

.syntax-note .md {
  font-size: var(--fs-sm);
  color: var(--ink-2);
}

/* ---------------------------------------------------------------- static table */
.md-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  background: var(--surface);
}

.md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.md-table th,
.md-table td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--rule);
  text-align: start;
  vertical-align: top;
}

.md-table thead th {
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.md-table tbody tr:last-child td {
  border-bottom: 0;
}

.md-table :not(pre) > code {
  white-space: normal;
}

/* ---------------------------------------------------------------- param controls */
.param-controls {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3) var(--s-5);
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: var(--r-md) var(--r-md) 0 0;
  border-bottom: 0;
  background: var(--surface-2);
}

.param-controls + .runner {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}

.param-field {
  display: grid;
  gap: 4px;
  min-width: 170px;
  flex: 1 1 170px;
  max-width: 320px;
}

.param-label {
  display: flex;
  justify-content: space-between;
  gap: var(--s-2);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink-2);
}

.param-value {
  direction: ltr;
  font-family: var(--font-mono);
  color: var(--accent);
}

.param-field input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.param-field select,
.param-field input[type="text"],
.field-input {
  width: 100%;
  min-height: 36px;
  padding: 5px 10px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--fs-sm);
}

.param-field input[type="text"] {
  direction: ltr;
  font-family: var(--font-mono);
}

/* ---------------------------------------------------------------- compare & steps */
.compare-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--s-3);
  align-items: start;
}

.compare-item .runner-head {
  background: var(--surface);
}

.compare-label {
  direction: ltr;
  unicode-bidi: plaintext;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--accent);
}

.steps-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-block-end: var(--s-3);
}

.step-pill {
  display: inline-grid;
  place-items: center;
  min-width: 32px;
  height: 32px;
  padding-inline: 8px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-pill);
  background: var(--surface);
  color: var(--ink-2);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
}

.step-pill[aria-current="step"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.step-pill.is-seen:not([aria-current="step"]) {
  border-color: var(--accent-line);
  color: var(--accent);
}

.steps-connector {
  width: 18px;
  height: 1px;
  background: var(--rule-strong);
}

.step-body {
  display: grid;
  gap: var(--s-3);
}

.step-title {
  font-weight: 700;
}

/* ---------------------------------------------------------------- quiz */
.quiz {
  display: grid;
  gap: var(--s-3);
  padding: 16px 18px;
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  background: var(--surface);
}

.quiz-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
}

.quiz-question {
  font-weight: 650;
  font-size: var(--fs-md);
}

.quiz-options {
  display: grid;
  gap: 8px;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
  text-align: start;
  cursor: pointer;
  transition: background var(--dur-fast), border-color var(--dur-fast);
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.quiz-option:disabled {
  cursor: default;
}

.quiz-letter {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--ink-2);
  font-size: var(--fs-xs);
  font-weight: 700;
}

.quiz-option.is-correct {
  border-color: var(--ok);
  background: var(--ok-soft);
}

.quiz-option.is-correct .quiz-letter {
  background: var(--ok);
  color: var(--ok-ink);
}

.quiz-option.is-wrong {
  border-color: var(--bad);
  background: var(--bad-soft);
}

.quiz-option.is-wrong .quiz-letter {
  background: var(--bad);
  color: var(--bad-ink);
}

.quiz-explain {
  padding: 10px 14px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: var(--fs-sm);
}

/* ---------------------------------------------------------------- exercise */
.exercise {
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}

.exercise.is-solved {
  border-color: color-mix(in srgb, var(--ok) 55%, var(--rule));
}

.exercise-head {
  display: grid;
  gap: var(--s-2);
  padding: 16px 18px 12px;
}

.exercise-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
}

.exercise-kicker {
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.03em;
}

.difficulty {
  display: inline-flex;
  gap: 3px;
}

.difficulty i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--surface-3);
}

.difficulty i.is-on {
  background: var(--ink-2);
}

.exercise-title {
  font-size: var(--fs-lg);
  font-weight: 700;
}

.exercise-prompt {
  display: grid;
  gap: 6px;
}

.exercise-expected {
  margin-inline: 18px;
  margin-block-end: 12px;
}

.exercise-expected summary {
  width: max-content;
  cursor: pointer;
  color: var(--ink-2);
  font-size: var(--fs-sm);
  font-weight: 600;
}

.exercise-expected[open] summary {
  margin-block-end: 8px;
}

.expected-card {
  border: 1px dashed var(--rule-strong);
  border-radius: var(--r-sm);
  overflow: hidden;
}

.expected-caption {
  padding: 6px 12px;
  font-size: var(--fs-xs);
  color: var(--ink-3);
  background: var(--surface-2);
}

.exercise .runner {
  border-radius: 0;
  border-inline: 0;
  border-bottom: 0;
  box-shadow: none;
}

.feedback {
  display: grid;
  gap: 6px;
  padding: 12px 18px;
  border-top: 1px solid var(--rule);
}

.feedback:empty {
  display: none;
}

.feedback-ok {
  background: var(--ok-soft);
}

.feedback-bad {
  background: var(--bad-soft);
}

.feedback-info {
  background: var(--surface-2);
}

.feedback-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.feedback-ok .feedback-title {
  color: var(--ok);
}

.feedback-bad .feedback-title {
  color: var(--bad);
}

.feedback-title svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.feedback .md {
  font-size: var(--fs-sm);
}

.xp-gain {
  display: inline-flex;
  padding: 0 8px;
  border-radius: var(--r-pill);
  background: var(--highlight);
  color: var(--highlight-ink);
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  font-weight: 700;
}

.hints {
  display: grid;
  gap: 6px;
  padding: 0 18px 12px;
}

.hints:empty {
  display: none;
}

.hint {
  display: flex;
  gap: var(--s-2);
  padding: 8px 12px;
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  border-radius: var(--r-sm);
  background: var(--warn-soft);
  font-size: var(--fs-sm);
}

.hint-num {
  flex-shrink: 0;
  font-weight: 700;
  color: var(--warn);
}

.solution {
  display: grid;
  gap: 8px;
  padding: 0 18px 14px;
}

.solution-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--ink-2);
}

/* ---------------------------------------------------------------- AI tutor */
.tutor {
  display: grid;
  gap: var(--s-2);
  margin: 0 18px 14px;
  padding: 12px 14px;
  border: 1px solid var(--accent-line);
  border-radius: var(--r-md);
  background: var(--accent-soft);
}

.tutor-standalone {
  margin: 0;
}

.tutor-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  font-size: var(--fs-sm);
  font-weight: 700;
  color: var(--accent);
}

.tutor-head svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.tutor-head .btn-row {
  margin-inline-start: auto;
}

.tutor-thread {
  display: grid;
  gap: var(--s-2);
}

.tutor-msg {
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: var(--fs-sm);
}

.tutor-msg.is-user {
  background: transparent;
  border: 1px dashed var(--accent-line);
  color: var(--ink-2);
}

.tutor-msg.is-thinking {
  color: var(--ink-3);
  font-style: italic;
}

.tutor-form {
  display: flex;
  gap: var(--s-2);
}

.tutor-form input {
  flex: 1;
  min-width: 0;
}

/* ---------------------------------------------------------------- overlays */
.toast-root {
  position: fixed;
  inset-inline: 0;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 90;
  display: grid;
  justify-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 460px);
  padding: 10px 16px;
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: var(--shadow-2);
  font-size: var(--fs-sm);
  pointer-events: auto;
  animation: toast-in 260ms var(--ease);
}

.toast.is-leaving {
  animation: toast-out 200ms var(--ease) forwards;
}

.toast-ok {
  border-color: color-mix(in srgb, var(--ok) 40%, var(--rule));
}

.toast-bad {
  border-color: color-mix(in srgb, var(--bad) 40%, var(--rule));
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(6px); }
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: var(--s-4);
  background: rgb(6 9 19 / 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fade-in 180ms var(--ease);
}

@keyframes fade-in {
  from { opacity: 0; }
}

.dialog {
  display: grid;
  gap: var(--s-3);
  width: min(100%, 440px);
  padding: 20px 22px;
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-2);
}

.dialog-title {
  font-size: var(--fs-lg);
  font-weight: 700;
}

.dialog .btn-row {
  justify-content: flex-end;
  margin-block-start: var(--s-2);
}

.drawer-overlay {
  place-items: stretch;
  justify-items: end;
  padding: 0;
}

[dir="rtl"] .drawer-overlay {
  justify-items: start;
}

.drawer {
  display: flex;
  flex-direction: column;
  width: min(92vw, 420px);
  height: 100%;
  background: var(--surface);
  box-shadow: var(--shadow-2);
  animation: drawer-in 240ms var(--ease);
}

/* The drawer sits on the right in both directions, so it slides in from the right edge. */
@keyframes drawer-in {
  from { transform: translateX(24px); opacity: 0; }
}

.drawer-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 14px 16px;
  border-bottom: 1px solid var(--rule);
}

.drawer-title {
  font-weight: 700;
}

.drawer-head .icon-button {
  margin-inline-start: auto;
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 24px;
}

/* ---------------------------------------------------------------- schema list */
.schema-list {
  display: grid;
  gap: var(--s-2);
}

.schema-table {
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}

.schema-table > summary {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 9px 12px;
  cursor: pointer;
  list-style: none;
}

.schema-table > summary::-webkit-details-marker {
  display: none;
}

/* Chevron from a physical right+bottom corner: open points down, closed points along the reading direction. */
.schema-table > summary::before {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--ink-3);
  border-bottom: 2px solid var(--ink-3);
  transform: rotate(45deg);
  transition: transform var(--dur-fast);
  flex-shrink: 0;
}

.schema-table:not([open]) > summary::before {
  transform: rotate(-45deg);
}

[dir="rtl"] .schema-table:not([open]) > summary::before {
  transform: rotate(135deg);
}

.schema-table-name {
  direction: ltr;
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: var(--fs-sm);
}

.schema-table-title {
  color: var(--ink-3);
  font-size: var(--fs-xs);
}

.schema-table-count {
  margin-inline-start: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--ink-3);
}

.schema-columns {
  margin: 0;
  padding: 0 0 6px;
  list-style: none;
  border-top: 1px solid var(--rule);
}

.schema-column {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px var(--s-3);
  padding: 6px 12px;
  border-bottom: 1px dashed var(--rule);
}

.schema-column:last-child {
  border-bottom: 0;
}

.schema-column-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  direction: ltr;
  font-family: var(--font-mono);
  font-size: var(--fs-xs);
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.schema-column-name:hover {
  color: var(--accent);
}

.schema-column-type {
  justify-self: end;
  direction: ltr;
  font-family: var(--font-mono);
  font-size: var(--fs-2xs);
  color: var(--ink-3);
}

.schema-column-desc {
  grid-column: 1 / -1;
  font-size: var(--fs-xs);
  color: var(--ink-2);
  line-height: 1.6;
}

.key-badge {
  display: inline-block;
  padding: 0 5px;
  border-radius: 4px;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.6;
  letter-spacing: 0.04em;
}

.key-badge.is-pk {
  background: var(--highlight);
  color: var(--highlight-ink);
}

.key-badge.is-fk {
  background: var(--accent-soft);
  color: var(--accent);
}
