:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-subtle: #f1f1ee;
  --surface-muted: #ecece8;

  --text: #171717;
  --text-secondary: #5f5f5a;
  --text-tertiary: #898983;

  --border: #d9d9d4;
  --border-strong: #b8b8b1;

  --accent: #2563eb;
  --accent-subtle: #eaf0ff;
  --accent-dark: #1e4fb9;
  --plot-blue: #2563eb;
  --plot-orange: #b45309;
  --plot-residual: #8d9aaa;

  --danger: #b42318;
  --warning: #a15c00;
  --success: #287a4b;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;

  --sidebar-width: 232px;
  --content-max: 1120px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  color-scheme: light;
  font-family: Inter, "IBM Plex Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  line-height: 1.45;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}

button,
input {
  font: inherit;
}

button,
a,
input[type="range"] {
  -webkit-tap-highlight-color: transparent;
}

button,
a {
  color: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.32);
  outline-offset: 3px;
}

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

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  z-index: 20;
  flex: 0 0 var(--sidebar-width);
  height: 100vh;
  border-right: 1px solid var(--border);
  background: #f3f3f0;
}

.sidebar-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 30px 18px 20px;
}

.wordmark,
.mobile-wordmark {
  color: var(--text);
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.sidebar-search {
  margin-top: 32px;
}

.search-field {
  display: flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.search-glyph {
  flex: 0 0 auto;
  margin-left: 10px;
  color: var(--text-tertiary);
  font-size: 20px;
  line-height: 1;
  transform: translateY(-1px);
}

.search-field input {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 10px 0 7px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 13px;
}

.search-field input::placeholder {
  color: var(--text-tertiary);
}

.playground-nav {
  margin-top: 36px;
}

.nav-group + .nav-group {
  margin-top: 28px;
}

.nav-group h2 {
  margin: 0 0 8px 10px;
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  line-height: 1.2;
  text-transform: uppercase;
}

.nav-item {
  position: relative;
  display: block;
  padding: 9px 10px 9px 13px;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary);
  font-size: 14px;
  text-decoration: none;
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.75);
  color: var(--text);
}

.nav-item.is-active {
  border-left-color: var(--accent);
  background: var(--accent-subtle);
  color: var(--text);
  font-weight: 600;
}

.no-results {
  margin: 12px 10px;
  color: var(--text-tertiary);
  font-size: 13px;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding: 16px 10px 0;
  border-top: 1px solid var(--border);
  color: var(--text-tertiary);
  font-size: 12px;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.page-column {
  flex: 1 1 auto;
  min-width: 0;
}

.mobile-topbar {
  display: none;
}

main {
  min-width: 0;
}

.playground {
  width: min(100%, var(--content-max));
  margin: 0 auto;
  padding: 46px 48px 72px;
}

.playground-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.105em;
  line-height: 1.2;
  text-transform: uppercase;
}

.eyebrow span {
  margin: 0 4px;
  color: var(--border-strong);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(26px, 3vw, 30px);
  font-weight: 650;
  letter-spacing: -0.035em;
  line-height: 1.12;
}

.playground-description {
  max-width: 640px;
  margin-bottom: 0;
  color: var(--text-secondary);
  font-size: 15px;
}

.header-note {
  display: grid;
  flex: 0 0 auto;
  gap: 3px;
  padding-top: 32px;
  color: var(--text-tertiary);
  font-size: 11px;
  text-align: right;
}

.note-label {
  color: var(--text-tertiary);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.experiment-section,
.metrics-section,
.teaching-section,
.formula-section {
  margin-top: 34px;
}

.section-heading-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 17px;
}

.section-heading-row h2,
.teaching-section h2,
.formula-section h2 {
  margin-bottom: 0;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.105em;
  line-height: 1.2;
  text-transform: uppercase;
}

.section-hint,
.section-copy,
.formula-intro {
  color: var(--text-secondary);
  font-size: 13px;
}

.section-hint {
  margin-bottom: 0;
}

.parameter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
  padding: 18px 0 4px;
  border-top: 1px solid var(--border);
}


.parameter-row,
.inference-parameter {
  min-width: 0;
}

.parameter-label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.parameter-label-row label {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.math-inline {
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
}

output,
.metric-item strong,
.prediction-readout strong {
  font-variant-numeric: tabular-nums;
}

.parameter-label-row output {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 650;
}

input[type="range"] {
  width: 100%;
  height: 22px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

input[type="range"]:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.range-limits {
  display: flex;
  justify-content: space-between;
  margin-top: 2px;
  color: var(--text-tertiary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
}

.action-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
}

.button {
  min-height: 37px;
  padding: 7px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 650;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.button-primary:hover {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

.button-secondary {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.button-secondary:hover {
  border-color: var(--text-secondary);
  background: var(--surface-subtle);
}

.button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.action-status {
  margin-left: 4px;
  color: var(--text-tertiary);
  font-size: 12px;
}

.visualization-section {
  margin-top: 39px;
}

.plot-surface {
  overflow: hidden;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
}

#regression-plot {
  display: block;
  width: 100%;
  height: 460px;
  min-height: 0;
}

.classification-plot {
  display: block;
  width: 100%;
  height: 460px;
  min-height: 0;
}

.classification-grid-line {
  stroke: #e8e8e4;
  stroke-width: 1;
}

.classification-axis-line {
  stroke: #8e8e88;
  stroke-width: 1.3;
}

.classification-tick {
  stroke: #8e8e88;
  stroke-width: 1;
}

.classification-tick-label,
.classification-axis-label,
.classification-inference-label {
  fill: #5f5f5a;
  font-family: Inter, "IBM Plex Sans", system-ui, sans-serif;
}

.classification-tick-label {
  font-size: 12px;
}

.classification-axis-label {
  font-size: 13px;
  font-weight: 650;
}

.classification-point {
  stroke-width: 2.5;
}

.classification-point.class-a {
  fill: var(--accent-subtle);
  stroke: var(--plot-blue);
}

.classification-point.class-b {
  fill: #fff0e8;
  stroke: var(--plot-orange);
}

.logistic-boundary,
.svm-boundary-line {
  stroke: var(--text);
  stroke-width: 3;
  stroke-linecap: round;
}

.svm-margin-line {
  stroke: var(--plot-residual);
  stroke-width: 1.6;
  stroke-dasharray: 6 5;
}

.classification-inference-marker {
  fill: var(--plot-orange);
  stroke: var(--surface);
  stroke-width: 2;
}

.classification-inference-label {
  fill: var(--plot-orange);
  font-size: 12px;
  font-weight: 650;
}

.knn-distance-line {
  stroke: var(--plot-orange);
  stroke-width: 1.2;
  stroke-dasharray: 4 4;
  opacity: 0.7;
}

.knn-neighbor-point {
  stroke-width: 3.2;
}

.knn-neighbor-ring {
  fill: none;
  stroke: var(--plot-orange);
  stroke-width: 1.5;
  opacity: 0.85;
}

.svm-support-point {
  stroke-width: 3.2;
}

.svm-support-ring {
  fill: none;
  stroke: var(--warning);
  stroke-width: 1.7;
}

#knn .metric-strip {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.tree-visualization-surface {
  overflow: hidden;
}

.tree-views {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tree-view {
  min-width: 0;
  padding: 0 10px;
}

.tree-view + .tree-view {
  border-left: 1px solid var(--border);
}

.tree-panel-svg {
  display: block;
  width: 100%;
  height: 430px;
}

.tree-grid-line {
  stroke: #e8e8e4;
  stroke-width: 1;
}

.tree-axis-line,
.tree-tick {
  stroke: #8e8e88;
}

.tree-axis-line {
  stroke-width: 1.3;
}

.tree-tick {
  stroke-width: 1;
}

.tree-tick-label,
.tree-axis-label,
.tree-view-label,
.tree-view-description,
.tree-split-label,
.tree-branch-label,
.tree-empty-label {
  fill: var(--text-secondary);
  font-family: Inter, "IBM Plex Sans", system-ui, sans-serif;
}

.tree-tick-label {
  font-size: 11px;
}

.tree-axis-label {
  font-size: 12px;
  font-weight: 650;
}

.tree-view-label {
  fill: var(--text);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tree-view-description {
  fill: var(--text-tertiary);
  font-size: 10px;
}

.tree-point {
  stroke-width: 2.5;
}

.tree-point.class-a {
  fill: var(--accent-subtle);
  stroke: var(--plot-blue);
}

.tree-point.class-b {
  fill: #fff0e8;
  stroke: var(--plot-orange);
}

.tree-active-region {
  fill: var(--accent-subtle);
  stroke: var(--accent);
  stroke-width: 1.5;
  opacity: 0.58;
}

.tree-split-line {
  stroke: var(--border-strong);
  stroke-width: 1.8;
  stroke-dasharray: 6 5;
}

.tree-split-line.is-selected,
.tree-split-line.is-path {
  stroke: var(--accent);
  stroke-width: 2.7;
  stroke-dasharray: none;
}

.tree-inference-marker {
  fill: var(--plot-orange);
  stroke: var(--surface);
  stroke-width: 2;
}

.tree-inference-label {
  fill: var(--plot-orange);
  font-size: 11px;
  font-weight: 650;
}

.tree-branch-line {
  stroke: var(--border-strong);
  stroke-width: 1.5;
}

.tree-branch-line.is-path {
  stroke: var(--accent);
  stroke-width: 2.7;
}

.tree-branch-label {
  font-size: 10px;
}

.tree-branch-label.is-path {
  fill: var(--accent-dark);
  font-weight: 700;
}

.tree-node {
  cursor: pointer;
  outline: none;
}

.tree-node rect {
  fill: var(--surface);
  stroke: var(--border-strong);
  stroke-width: 1.3;
}

.tree-node.is-selected rect {
  fill: var(--accent-subtle);
  stroke: var(--accent);
  stroke-width: 2;
}

.tree-node.is-path rect {
  stroke: var(--plot-orange);
  stroke-width: 2;
}

.tree-node:focus rect {
  stroke: var(--accent-dark);
  stroke-width: 2.5;
}

.tree-node-label {
  fill: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.tree-node-meta {
  fill: var(--text-tertiary);
  font-size: 10px;
}

.tree-empty-label {
  fill: var(--text-tertiary);
  font-size: 13px;
}

.legend-symbol.tree-region {
  width: 14px;
  height: 11px;
  border: 1px solid var(--accent);
  background: var(--accent-subtle);
}

#kmeans .metric-strip {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.kmeans-plot {
  display: block;
  width: 100%;
  height: 460px;
}

.kmeans-grid-line {
  stroke: #e8e8e4;
  stroke-width: 1;
}

.kmeans-axis-line,
.kmeans-tick {
  stroke: #8e8e88;
}

.kmeans-axis-line {
  stroke-width: 1.3;
}

.kmeans-tick {
  stroke-width: 1;
}

.kmeans-tick-label,
.kmeans-axis-label {
  fill: #5f5f5a;
  font-family: Inter, "IBM Plex Sans", system-ui, sans-serif;
}

.kmeans-tick-label {
  font-size: 12px;
}

.kmeans-axis-label {
  font-size: 13px;
  font-weight: 650;
}

.kmeans-point {
  fill: var(--surface-muted);
  stroke: var(--border-strong);
  stroke-width: 2.2;
}

.kmeans-point.is-selected {
  stroke: var(--text);
  stroke-width: 3.2;
}

.kmeans-cluster-0 {
  color: #2563eb;
}

.kmeans-cluster-1 {
  color: #b45309;
}

.kmeans-cluster-2 {
  color: #287a4b;
}

.kmeans-cluster-3 {
  color: #7c4d9c;
}

.kmeans-cluster-4 {
  color: #2b7c86;
}

.kmeans-point.kmeans-cluster-0 {
  fill: #eaf0ff;
  stroke: #2563eb;
}

.kmeans-point.kmeans-cluster-1 {
  fill: #fff0e8;
  stroke: #b45309;
}

.kmeans-point.kmeans-cluster-2 {
  fill: #eaf6ef;
  stroke: #287a4b;
}

.kmeans-point.kmeans-cluster-3 {
  fill: #f2ecf7;
  stroke: #7c4d9c;
}

.kmeans-point.kmeans-cluster-4 {
  fill: #e8f4f4;
  stroke: #2b7c86;
}

.kmeans-point.is-selected {
  stroke: var(--text);
  stroke-width: 3.2;
}

.kmeans-centroid line {
  stroke: currentColor;
  stroke-width: 3.2;
  stroke-linecap: round;
}

.kmeans-centroid-label {
  fill: currentColor;
  font-size: 12px;
  font-weight: 750;
}

.kmeans-previous-centroid {
  opacity: 0.5;
}

.kmeans-previous-centroid line {
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-dasharray: 4 4;
}

.kmeans-movement-line {
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-dasharray: 5 5;
  opacity: 0.75;
}

.kmeans-distance-line,
.kmeans-inference-line {
  stroke: var(--plot-residual);
  stroke-width: 1.2;
  stroke-dasharray: 4 4;
  opacity: 0.75;
}

.kmeans-distance-line.is-nearest,
.kmeans-inference-line.is-nearest {
  stroke: var(--plot-orange);
  stroke-width: 2.4;
  opacity: 0.95;
}

.kmeans-inference-marker {
  fill: var(--plot-orange);
  stroke: var(--surface);
  stroke-width: 2;
}

.kmeans-inference-label {
  fill: var(--plot-orange);
  font-size: 12px;
  font-weight: 650;
}

.kmeans-observation {
  width: 10px;
  height: 10px;
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  background: var(--surface-muted);
}

.legend-symbol.kmeans-centroid,
.legend-symbol.kmeans-previous {
  color: var(--text);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
}

.legend-symbol.kmeans-previous {
  color: var(--text-tertiary);
}

.kmeans-transport-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.kmeans-phase-readout {
  margin-left: 6px;
  color: var(--text-secondary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.kmeans-point-detail {
  min-height: 20px;
  margin: 12px 0 0;
  color: var(--text-tertiary);
  font-size: 12px;
}

.kmeans-mode-switch {
  display: flex;
  gap: 8px;
  margin-top: 19px;
}

.kmeans-mode-switch .button.is-active {
  border-color: var(--accent);
  background: var(--accent-subtle);
  color: var(--accent-dark);
}

.kmeans-inference-details {
  display: grid;
  gap: 7px;
  max-width: 420px;
  margin-top: 15px;
  color: var(--text-secondary);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

.kmeans-inference-heading {
  color: var(--text);
  font-family: Inter, "IBM Plex Sans", system-ui, sans-serif;
  font-size: 13px;
  font-weight: 650;
}

.kmeans-distance-row.is-nearest {
  color: var(--plot-orange);
  font-weight: 700;
}

.kmeans-inference-result {
  margin-top: 3px;
  color: var(--success);
  font-family: Inter, "IBM Plex Sans", system-ui, sans-serif;
  font-weight: 650;
}

.legend-symbol.class-a,
.legend-symbol.class-b {
  width: 10px;
  height: 10px;
  border: 2px solid;
  border-radius: 50%;
}

.legend-symbol.class-a {
  border-color: var(--plot-blue);
  background: var(--accent-subtle);
}

.legend-symbol.class-b {
  border-color: var(--plot-orange);
  background: #fff0e8;
}

.legend-symbol.boundary {
  width: 16px;
  height: 3px;
  background: var(--text);
}

.legend-symbol.neighbor {
  width: 12px;
  height: 12px;
  border: 2px solid var(--plot-orange);
  border-radius: 50%;
}

.legend-symbol.margin {
  width: 16px;
  height: 0;
  border-top: 2px dashed var(--plot-residual);
}

.plot-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin-top: 13px;
  color: var(--text-secondary);
  font-size: 12px;
}

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

.legend-symbol {
  position: relative;
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
}

.legend-symbol.observation {
  width: 10px;
  height: 10px;
  border: 2px solid var(--plot-blue);
  border-radius: 50%;
}

.legend-symbol.residual {
  width: 15px;
  height: 1px;
  background: var(--plot-residual);
}

.legend-symbol.model {
  width: 16px;
  height: 3px;
  background: var(--text);
}

.legend-symbol.inference {
  color: var(--plot-orange);
  font-size: 13px;
  line-height: 1;
}

.inference-section {
  padding-top: 2px;
  border-top: 1px solid var(--border);
}

.section-copy {
  margin: 7px 0 0;
}

.mode-label {
  color: var(--text-tertiary);
  font-size: 12px;
}

.inference-control-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 130px minmax(220px, 1.25fr);
  align-items: end;
  gap: 24px;
  padding-bottom: 4px;
}

.classification-screen .inference-control-row,
.tree-screen .inference-control-row {
  grid-template-columns: repeat(2, minmax(220px, 1fr)) minmax(220px, 1.25fr);
}

.prediction-readout {
  display: grid;
  gap: 4px;
  align-self: center;
  padding-left: 18px;
  border-left: 1px solid var(--border);
}

.readout-label,
.metric-label {
  color: var(--text-tertiary);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.02em;
}

.prediction-readout strong {
  font-size: 21px;
  font-weight: 600;
}

.inline-status {
  align-self: center;
  margin: 0;
  color: var(--text-tertiary);
  font-size: 12px;
}

.inline-status.is-ready {
  color: var(--success);
}

.inline-status.is-stale {
  color: var(--warning);
}

.metrics-section {
  margin-top: 28px;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border);
}


.metric-item {
  display: grid;
  gap: 6px;
  min-height: 83px;
  align-content: center;
  padding: 13px 18px 14px 0;
}

.metric-item + .metric-item {
  padding-left: 18px;
  border-left: 1px solid var(--border);
}

.metric-item strong {
  font-size: 23px;
  font-weight: 550;
  letter-spacing: -0.02em;
}

.metric-item-emphasis strong {
  color: var(--accent-dark);
}

.metric-item-primary {
  padding-left: 14px;
  border-left: 3px solid var(--accent);
}

.metric-item-primary strong {
  color: var(--accent-dark);
  font-size: 29px;
}

.metric-note {
  color: var(--text-tertiary);
  font-size: 11px;
}

.model-state {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  margin-left: 4px;
  padding-left: 11px;
  border-left: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 12px;
  line-height: 1.35;
}

.model-state::before {
  width: 7px;
  height: 7px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  content: "";
}

.model-state.is-unfitted {
  color: var(--text-secondary);
}

.model-state.is-fitting {
  color: var(--accent);
}

.model-state.is-fitted {
  color: var(--success);
}

.model-state.is-stale {
  color: var(--warning);
}

.teaching-section {
  display: grid;
  grid-template-columns: 180px minmax(0, 620px);
  gap: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.teaching-section h2,
.formula-section h2 {
  color: var(--text-secondary);
}

.teaching-section p {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
}

.formula-section {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.formula-intro {
  max-width: 260px;
  margin: 10px 0 0;
  line-height: 1.5;
}

.formula-list {
  display: grid;
  gap: 13px;
}

.formula-line {
  display: grid;
  grid-template-columns: 145px minmax(0, 1fr);
  align-items: baseline;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.formula-line:last-child {
  padding-bottom: 0;
  border-bottom: 0;
}

.formula-symbol {
  color: var(--text-secondary);
  font-size: 12px;
}

.formula-line code {
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
}




.update-equation {
  min-width: 0;
  overflow-x: auto;
  padding: 13px 16px;
  border-left: 3px solid var(--accent);
  background: var(--surface-subtle);
}

.update-equation code {
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 18px;
  white-space: nowrap;
}

.plot-grid-line {
  stroke: #e8e8e4;
  stroke-width: 1;
}

.plot-axis-line {
  stroke: #8e8e88;
  stroke-width: 1.3;
}

.plot-tick {
  stroke: #8e8e88;
  stroke-width: 1;
}

.plot-tick-label,
.plot-axis-label,
.plot-inference-label,
.plot-prediction-label {
  fill: #5f5f5a;
  font-family: Inter, "IBM Plex Sans", system-ui, sans-serif;
}

.plot-tick-label {
  font-size: 12px;
}

.plot-axis-label {
  font-size: 13px;
  font-weight: 650;
}

.plot-residual {
  stroke: var(--plot-residual);
  stroke-width: 1.5;
  stroke-dasharray: 4 4;
  opacity: 0.82;
}

.plot-model-line {
  stroke: var(--text);
  stroke-width: 3;
  stroke-linecap: round;
}

.plot-observation {
  fill: var(--accent-subtle);
  stroke: var(--plot-blue);
  stroke-width: 2.5;
}

.plot-observation-label {
  fill: var(--text-secondary);
  font-size: 11px;
}

.plot-inference-guide {
  stroke: var(--plot-orange);
  stroke-width: 1.5;
  stroke-dasharray: 5 5;
  opacity: 0.75;
}

.plot-inference-marker {
  fill: var(--plot-orange);
  stroke: var(--surface);
  stroke-width: 2;
}

.plot-inference-axis-marker {
  fill: var(--surface);
  stroke: var(--plot-orange);
  stroke-width: 1.8;
}

.plot-inference-label,
.plot-prediction-label {
  fill: var(--plot-orange);
  font-size: 12px;
  font-weight: 650;
}

.drawer-overlay {
  display: none;
}

@media (max-width: 1099px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(86vw, var(--sidebar-width));
    transform: translateX(-102%);
    transition: transform 220ms ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .drawer-overlay {
    position: fixed;
    inset: 0;
    z-index: 10;
    display: block;
    background: rgba(23, 23, 23, 0.24);
  }

  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 8;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 58px;
    padding: 0 24px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
  }

  .menu-button {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 36px;
    padding: 6px 0 6px 10px;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 650;
  }

  .menu-button-lines {
    display: grid;
    gap: 3px;
  }

  .menu-button-lines i {
    display: block;
    width: 15px;
    height: 1px;
    background: currentColor;
  }

  .playground {
    padding-top: 38px;
  }
}

@media (max-width: 760px) {
  .mobile-topbar {
    padding: 0 18px;
  }

  .playground {
    padding: 30px 20px 56px;
  }

  .playground-header {
    display: block;
    padding-bottom: 25px;
  }

  .header-note {
    display: flex;
    gap: 8px;
    padding-top: 19px;
    text-align: left;
  }

  .parameter-grid,
  .metric-strip {
    grid-template-columns: 1fr;
  }

  .parameter-grid {
    gap: 22px;
  }

  .metric-item {
    min-height: auto;
    padding: 15px 0;
  }

  .metric-item + .metric-item {
    padding-left: 0;
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .inference-control-row,
  .teaching-section,
  .formula-section {
    grid-template-columns: 1fr;
    gap: 17px;
  }

  .classification-screen .inference-control-row,
  .tree-screen .inference-control-row {
    grid-template-columns: 1fr;
  }

  .tree-views {
    grid-template-columns: 1fr;
  }

  .tree-view {
    padding: 0;
  }

  .tree-view + .tree-view {
    border-top: 1px solid var(--border);
    border-left: 0;
  }

  .tree-panel-svg {
    height: auto;
  }

  .prediction-readout {
    width: fit-content;
    padding-left: 0;
    border-left: 0;
  }

  .section-heading-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  .section-hint,
  .mode-label {
    display: block;
  }

  .action-row {
    flex-wrap: wrap;
  }

  .action-status {
    flex-basis: 100%;
    margin: 2px 0 0;
  }

  #regression-plot {
    height: auto;
    min-height: 0;
  }

  .classification-plot {
    height: auto;
    min-height: 0;
  }

  #logistic-regression .metric-strip,
  #knn .metric-strip,
  #svm .metric-strip,
  #k-means .metric-strip {
    grid-template-columns: 1fr;
  }

  .kmeans-plot {
    height: auto;
    min-height: 0;
  }

  .kmeans-phase-readout {
    flex-basis: 100%;
    margin-left: 0;
  }

  .formula-line {
    grid-template-columns: 1fr;
    gap: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

body.drawer-open {
  overflow: hidden;
}
