:root {
  color-scheme: dark;
  --ink: #e6eef9;
  --muted: #8ea1bb;
  --subtle: #61738d;
  --panel: rgba(19, 28, 42, 0.86);
  --panel-strong: #151f2e;
  --line: rgba(152, 174, 205, 0.14);
  --line-strong: rgba(152, 174, 205, 0.27);
  --teal: #6ed4c0;
  --teal-deep: #2f9989;
  --gold: #f5b84b;
  --red: #f18a8a;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0b111b;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: #0b111b;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 87% 0%, rgba(40, 105, 111, 0.2), transparent 35rem),
    radial-gradient(circle at -4% 42%, rgba(69, 70, 130, 0.11), transparent 32rem),
    #0b111b;
}

button,
input,
textarea,
select {
  font: inherit;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: wait;
  opacity: 0.64;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(1420px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 38px 30px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 92px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  gap: 13px;
  align-items: center;
  color: var(--ink);
  text-decoration: none;
}

.brand > span:last-child {
  display: grid;
  gap: 1px;
}

.brand strong {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.06em;
}

.brand-dot {
  color: var(--teal);
}

.brand small {
  color: var(--subtle);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.brand-mark {
  display: block;
  flex: 0 0 auto;
  width: 96px;
  height: 48px;
  overflow: visible;
  transition: transform 160ms ease;
}

.brand-mark svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.logo-route {
  fill: none;
  stroke: var(--teal);
  stroke-width: 1.45;
  stroke-linecap: butt;
  stroke-linejoin: miter;
}

.logo-letter-underlay {
  fill: var(--teal-deep);
  stroke: none;
  opacity: 0.34;
}

.logo-node {
  fill: var(--ink);
  stroke: var(--teal);
  stroke-width: 0.7;
}

.brand:hover .brand-mark,
.brand:focus-visible .brand-mark {
  transform: scale(1.06) rotate(-1deg);
}

.topbar-context {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  justify-content: flex-end;
}

.eyebrow,
.step-label,
.metric-label,
.canvas-corner-label {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.eyebrow {
  color: var(--subtle);
}

.language-pill {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 10px;
}

.language-label {
  padding: 0 6px 0 8px;
  color: var(--subtle);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.language-option {
  min-width: 38px;
  padding: 5px 8px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-family: inherit;
  font-size: inherit;
  line-height: 1;
  transition: color 160ms ease, background 160ms ease;
}

.language-option:hover,
.language-option:focus-visible {
  color: var(--ink);
  background: rgba(152, 174, 205, 0.12);
}

.language-option[aria-pressed="true"] {
  color: #07141a;
  background: var(--teal);
}

.backend-pill {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  transition: border-color 180ms ease, color 180ms ease;
}

.backend-pill[data-state="connected"] {
  border-color: rgba(110, 212, 192, 0.4);
  color: var(--teal);
}

.backend-pill[data-state="offline"] {
  border-color: rgba(245, 184, 75, 0.36);
  color: var(--gold);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--subtle);
  box-shadow: 0 0 0 4px rgba(97, 115, 141, 0.1);
}

.backend-pill[data-state="connected"] .status-dot {
  background: var(--teal);
  box-shadow: 0 0 0 4px rgba(110, 212, 192, 0.12);
}

.backend-pill[data-state="offline"] .status-dot {
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(245, 184, 75, 0.12);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(300px, 390px) minmax(0, 1fr);
  gap: 22px;
  padding-top: 28px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.controls-panel {
  align-self: start;
  padding: 28px 26px 24px;
}

.panel-heading,
.visual-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.step-label {
  color: var(--teal);
  font-size: 9px;
}

h1,
h2,
p {
  margin: 0;
}

h1,
h2 {
  color: var(--ink);
  font-weight: 700;
  letter-spacing: -0.045em;
}

h1 {
  margin-top: 6px;
  font-size: clamp(24px, 3vw, 30px);
}

h2 {
  margin-top: 6px;
  font-size: 22px;
}

.heading-icon {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid rgba(110, 212, 192, 0.25);
  border-radius: 10px;
  color: var(--teal);
  font-size: 14px;
}

.intro-copy {
  max-width: 320px;
  margin-top: 17px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin: 25px 0 23px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(6, 10, 16, 0.2);
}

.mode-button {
  display: flex;
  gap: 9px;
  align-items: center;
  min-height: 58px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 9px;
  color: var(--subtle);
  text-align: left;
  background: transparent;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.mode-button:hover {
  color: var(--muted);
}

.mode-button[aria-selected="true"] {
  border-color: rgba(110, 212, 192, 0.22);
  color: var(--ink);
  background: rgba(110, 212, 192, 0.09);
}

.mode-icon {
  display: grid;
  flex: 0 0 27px;
  width: 27px;
  height: 27px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 8px;
  color: var(--teal);
  font-size: 15px;
}

.mode-button > span:last-child {
  display: grid;
  gap: 3px;
}

.mode-button strong {
  font-size: 10px;
  font-weight: 700;
}

.mode-button small {
  color: var(--subtle);
  font-size: 9px;
}

.control-group {
  display: grid;
  gap: 10px;
}

.field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.field-label output {
  color: var(--teal);
  font-family: "DM Mono", monospace;
  font-size: 14px;
}

.field-label.compact {
  margin-top: 9px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.field-hint {
  color: var(--subtle);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  font-weight: 400;
}

.range-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 63px;
  gap: 12px;
  align-items: center;
}

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

.number-input,
.seed-row input,
textarea,
select {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  outline: none;
  color: var(--ink);
  background: rgba(5, 10, 17, 0.3);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.number-input,
.seed-row input,
select {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  font-family: "DM Mono", monospace;
  font-size: 11px;
}

.number-input:focus,
.seed-row input:focus,
textarea:focus,
select:focus {
  border-color: rgba(110, 212, 192, 0.72);
  box-shadow: 0 0 0 3px rgba(110, 212, 192, 0.1);
}

.range-hints {
  display: flex;
  justify-content: space-between;
  color: var(--subtle);
  font-family: "DM Mono", monospace;
  font-size: 9px;
}

.seed-row,
.upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.quiet-button,
.secondary-button {
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  background: rgba(152, 174, 205, 0.04);
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.quiet-button:hover,
.secondary-button:hover {
  border-color: rgba(110, 212, 192, 0.42);
  color: var(--ink);
  background: rgba(110, 212, 192, 0.06);
}

textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  padding: 11px 12px;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  line-height: 1.65;
}

.upload-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.canvas-draw-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
  padding: 8px 9px;
  border: 1px solid rgba(110, 212, 192, 0.16);
  border-radius: 8px;
  color: var(--subtle);
  font-size: 9px;
  line-height: 1.4;
}

.canvas-draw-row .quiet-button {
  flex: 0 0 auto;
  height: 30px;
  padding: 0 9px;
  font-size: 9px;
}

.canvas-draw-mark {
  margin-right: 4px;
  color: var(--teal);
}

.file-button {
  display: flex;
  gap: 7px;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 9px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease;
}

.file-button:hover {
  border-color: rgba(110, 212, 192, 0.6);
  color: var(--teal);
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.algorithm-card {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 12px;
  margin-top: 24px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(110, 212, 192, 0.045);
}

.algorithm-symbol {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 9px;
  color: var(--teal);
  background: rgba(110, 212, 192, 0.12);
  font-size: 18px;
}

.algorithm-card select {
  height: 31px;
  margin-top: 6px;
  color: var(--ink);
  opacity: 1;
  font-size: 10px;
}

.algorithm-card p {
  margin-top: 8px;
  color: var(--subtle);
  font-size: 10px;
  line-height: 1.45;
}

.execution-mode {
  margin-top: 18px;
}

.execution-mode-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.execution-mode-heading .field-label {
  margin-top: 0;
}

.execution-mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-top: 8px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(6, 10, 16, 0.2);
}

.execution-button {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 49px;
  padding: 7px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  color: var(--subtle);
  text-align: left;
  background: transparent;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.execution-button:hover {
  color: var(--muted);
}

.execution-button[aria-selected="true"] {
  border-color: rgba(245, 184, 75, 0.3);
  color: var(--ink);
  background: rgba(245, 184, 75, 0.09);
}

.execution-icon {
  display: grid;
  flex: 0 0 22px;
  width: 22px;
  height: 22px;
  place-items: center;
  border: 1px solid currentColor;
  border-radius: 6px;
  color: var(--gold);
  font-size: 11px;
}

.execution-button > span:last-child {
  display: grid;
  gap: 2px;
}

.execution-button strong {
  font-size: 9px;
  font-weight: 700;
}

.execution-button small {
  color: var(--subtle);
  font-size: 8px;
}

.execution-help {
  margin-top: 8px;
  color: var(--subtle);
  font-size: 9px;
  line-height: 1.45;
}

.video-button {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  width: fit-content;
  margin-top: 0.7rem;
  padding: 0.58rem 0.78rem;
  border: 1px solid var(--line-strong);
  border-radius: 0.7rem;
  color: var(--ink);
  background: var(--panel-strong);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  text-decoration: none;
  transition: border-color 160ms ease, color 160ms ease, transform 160ms ease;
  cursor: pointer;
  list-style: none;
}

.video-button::-webkit-details-marker {
  display: none;
}

.video-panel {
  width: fit-content;
  margin-top: 0.7rem;
}

.video-panel[open] .video-button {
  color: var(--teal);
  border-color: var(--teal);
}

.video-button-icon {
  transition: transform 160ms ease;
}

.video-panel[open] .video-button-icon {
  transform: rotate(90deg);
}

.video-panel-body {
  width: min(100%, 560px);
  margin-top: 8px;
  padding: 8px;
  border: 1px solid rgba(110, 212, 192, 0.22);
  border-radius: 9px;
  background: rgba(6, 13, 22, 0.72);
}

.video-panel-body video {
  display: block;
  width: 100%;
  max-height: 330px;
  border-radius: 6px;
  background: #050a11;
}

.video-panel-body p {
  margin: 8px 2px 1px;
  color: var(--subtle);
  font-size: 9px;
  line-height: 1.45;
}

.video-button:hover,
.video-button:focus-visible {
  color: var(--teal);
  border-color: var(--teal);
  transform: translateY(-1px);
}

.action-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  margin-top: 24px;
}

.primary-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 45px;
  padding: 0 14px 0 16px;
  border: 1px solid rgba(110, 212, 192, 0.85);
  border-radius: 9px;
  color: #09201e;
  font-size: 12px;
  font-weight: 800;
  background: var(--teal);
  box-shadow: 0 9px 24px rgba(55, 166, 147, 0.19);
  transition: transform 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.primary-button:hover:not(:disabled) {
  background: #82e3cf;
  box-shadow: 0 12px 28px rgba(55, 166, 147, 0.28);
  transform: translateY(-1px);
}

[data-busy="true"] .primary-button .button-arrow {
  display: inline-block;
  animation: pulse-arrow 900ms ease-in-out infinite alternate;
}

@keyframes pulse-arrow {
  from { transform: translateX(0); opacity: 0.6; }
  to { transform: translateX(4px); opacity: 1; }
}

.button-arrow {
  font-size: 18px;
  font-weight: 400;
}

.secondary-button {
  height: 45px;
  padding: 0 14px;
}

.status-message,
.error-message {
  min-height: 20px;
  margin-top: 12px;
  color: var(--subtle);
  font-size: 10px;
  line-height: 1.5;
}

.status-message[data-kind="info"] {
  color: var(--gold);
}

.status-message[data-kind="success"] {
  color: var(--teal);
}

.error-message {
  margin-top: 6px;
  padding: 9px 10px;
  border: 1px solid rgba(241, 138, 138, 0.28);
  border-radius: 8px;
  color: var(--red);
  background: rgba(241, 138, 138, 0.06);
}

.explanation {
  margin-top: 19px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.explanation summary {
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
}

.explanation p {
  margin-top: 11px;
  color: var(--subtle);
  font-size: 10px;
  line-height: 1.65;
}

.visual-panel {
  display: flex;
  min-width: 0;
  flex-direction: column;
  padding: 28px 28px 20px;
}

.count-summary {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 10px;
}

.canvas-stage {
  position: relative;
  min-height: 530px;
  margin-top: 23px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: #101621;
}

.canvas-stage:fullscreen {
  display: flex;
  width: 100vw;
  height: 100vh;
  min-height: 0;
  align-items: stretch;
  justify-content: stretch;
  border: 0;
  border-radius: 0;
  background: #101621;
}

.canvas-stage:fullscreen #plot-canvas {
  width: 100vw;
  height: 100vh;
}

.canvas-stage::before {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(110, 212, 192, 0.06), transparent 33%);
  content: "";
}

#plot-canvas {
  display: block;
  width: 100%;
  height: 530px;
  cursor: grab;
  touch-action: none;
}

#plot-canvas[data-editable="true"] {
  cursor: crosshair;
}

#plot-canvas:active {
  cursor: grabbing;
}

.canvas-tools {
  position: absolute;
  top: 13px;
  right: 13px;
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 4px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  background: rgba(11, 17, 27, 0.82);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(10px);
}

.canvas-tool {
  display: grid;
  width: 29px;
  height: 29px;
  padding: 0;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 17px;
  line-height: 1;
  background: transparent;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.canvas-tool:hover {
  border-color: rgba(110, 212, 192, 0.35);
  color: var(--teal);
  background: rgba(110, 212, 192, 0.08);
}

.canvas-tool.wide {
  width: auto;
  min-width: 29px;
  padding: 0 8px;
  font-size: 13px;
}

.fullscreen-glyph {
  margin-right: 5px;
  font-size: 16px;
}

.zoom-level {
  min-width: 37px;
  color: var(--teal);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  text-align: center;
}

.tool-divider {
  width: 1px;
  height: 19px;
  margin: 0 2px;
  background: var(--line-strong);
}

.plot-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  gap: 7px;
  justify-items: center;
  color: var(--subtle);
  font-size: 11px;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.plot-empty strong {
  color: var(--muted);
  font-size: 13px;
}

.empty-glyph {
  color: var(--teal);
  font-size: 35px;
  line-height: 1;
  opacity: 0.7;
}

.canvas-corner-label {
  position: absolute;
  right: 13px;
  bottom: 11px;
  color: var(--subtle);
  font-size: 8px;
  pointer-events: none;
}

.hover-readout {
  min-height: 16px;
  margin: 10px 1px 0;
  color: var(--subtle);
  font-family: "DM Mono", monospace;
  font-size: 9px;
}

.edge-inspector {
  margin-top: 11px;
  padding: 12px 13px 11px;
  border: 1px solid rgba(245, 184, 75, 0.19);
  border-radius: 10px;
  background: rgba(245, 184, 75, 0.045);
  transition: border-color 160ms ease, background 160ms ease;
}

.edge-inspector:not([data-empty="true"]) {
  border-color: rgba(245, 184, 75, 0.45);
  background: rgba(245, 184, 75, 0.085);
}

.edge-inspector-heading,
.edge-inspector-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.edge-index {
  color: var(--subtle);
  font-family: "DM Mono", monospace;
  font-size: 9px;
}

.edge-inspector-body {
  gap: 14px;
  margin-top: 7px;
}

.edge-inspector-body strong {
  overflow: hidden;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 12px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.edge-inspector:not([data-empty="true"]) .edge-inspector-body strong {
  color: var(--gold);
}

.edge-inspector-body b {
  color: var(--gold);
  font-family: "DM Mono", monospace;
  font-size: 17px;
  font-weight: 500;
}

.edge-inspector-body small {
  color: var(--subtle);
  font-size: 9px;
}

.edge-inspector p {
  margin-top: 7px;
  color: var(--subtle);
  font-size: 9px;
  line-height: 1.45;
}

.vertex-inspector {
  margin-top: 11px;
  padding: 12px 13px 11px;
  border: 1px solid rgba(110, 212, 192, 0.28);
  border-radius: 10px;
  background: rgba(110, 212, 192, 0.06);
}

.vertex-inspector .edge-inspector-body {
  gap: 12px;
}

.vertex-inspector .edge-inspector-body strong {
  color: var(--teal);
}

.vertex-inspector .edge-inspector-body b {
  color: var(--teal);
  font-size: 11px;
  font-weight: 500;
}

.vertex-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 14px;
  margin-top: 8px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  line-height: 1.45;
}

.vertex-inspector p {
  margin-top: 7px;
  color: var(--subtle);
  font-size: 9px;
  line-height: 1.45;
}

.teaching-panel {
  margin-top: 14px;
  padding: 14px 14px 13px;
  border: 1px solid rgba(140, 166, 200, 0.31);
  border-radius: 11px;
  background:
    linear-gradient(145deg, rgba(140, 166, 200, 0.08), transparent 46%),
    rgba(8, 14, 24, 0.56);
}

.teaching-panel-heading,
.teaching-reading-meta,
.teaching-controls,
.teaching-speed,
.teaching-finish {
  display: flex;
  align-items: center;
}

.teaching-panel-heading {
  justify-content: space-between;
  gap: 12px;
}

.teaching-panel-heading h3 {
  margin: 5px 0 0;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.035em;
}

.teaching-progress-count {
  flex: 0 0 auto;
  color: var(--gold);
  font-family: "DM Mono", monospace;
  font-size: 9px;
}

.teaching-stage-list {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  margin-top: 13px;
}

.teaching-stage {
  display: flex;
  gap: 6px;
  align-items: center;
  min-width: 0;
  padding: 7px 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--subtle);
  text-align: left;
  background: rgba(152, 174, 205, 0.025);
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.teaching-stage:hover {
  border-color: rgba(140, 166, 200, 0.52);
  color: var(--muted);
}

.teaching-stage[data-active="true"] {
  border-color: rgba(110, 212, 192, 0.44);
  color: var(--ink);
  background: rgba(110, 212, 192, 0.09);
}

.teaching-stage-number {
  color: var(--teal);
  font-family: "DM Mono", monospace;
  font-size: 9px;
}

.teaching-stage > span:last-child {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.teaching-stage strong {
  overflow: hidden;
  font-size: 8px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.teaching-stage small {
  overflow: hidden;
  color: var(--subtle);
  font-size: 7px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.teaching-reading {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.teaching-reading-meta {
  flex-wrap: wrap;
  gap: 5px 12px;
  color: var(--subtle);
  font-family: "DM Mono", monospace;
  font-size: 8px;
}

.teaching-reading-meta span:first-child {
  color: var(--teal);
}

.teaching-reading h4 {
  margin: 7px 0 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.teaching-reading p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.52;
}

.teaching-state-readout {
  display: grid;
  gap: 3px;
  margin-top: 10px;
  padding: 8px 9px;
  border: 1px solid rgba(245, 184, 75, 0.2);
  border-radius: 7px;
  background: rgba(245, 184, 75, 0.055);
}

.teaching-state-readout strong {
  color: var(--gold);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.teaching-state-readout span {
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 8px;
  line-height: 1.45;
}

.teaching-code {
  margin-top: 9px;
  padding-top: 8px;
  border-top: 1px solid rgba(152, 174, 205, 0.1);
}

.teaching-code-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  color: var(--subtle);
  font-family: "DM Mono", monospace;
  font-size: 8px;
}

.teaching-code-heading code {
  overflow: hidden;
  color: var(--muted);
  font-size: 8px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.teaching-code-lines {
  display: grid;
  gap: 2px;
  margin-top: 7px;
  padding: 6px 7px;
  border: 1px solid rgba(110, 212, 192, 0.16);
  border-radius: 6px;
  background: rgba(6, 13, 22, 0.55);
}

.teaching-code-lines code {
  display: block;
  padding: 3px 5px;
  border-left: 2px solid transparent;
  color: var(--subtle);
  font-family: "DM Mono", monospace;
  font-size: 8px;
  line-height: 1.5;
  white-space: pre-wrap;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease;
}

.teaching-code-lines code[data-active="true"] {
  border-left-color: var(--teal);
  color: var(--teal);
  background: rgba(110, 212, 192, 0.1);
}

.teaching-code > code {
  display: block;
  margin-top: 7px;
  padding: 8px 9px;
  overflow-x: auto;
  border: 1px solid rgba(110, 212, 192, 0.16);
  border-radius: 6px;
  color: var(--teal);
  font-family: "DM Mono", monospace;
  font-size: 8px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.teaching-timeline {
  margin-top: 11px;
}

.teaching-timeline input[type="range"] {
  display: block;
  margin: 0;
}

.teaching-controls {
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 10px;
}

.teaching-controls-dock {
  position: sticky;
  top: 10px;
  z-index: 8;
  margin-top: 8px;
  padding: 7px 9px;
  border: 1px solid rgba(110, 212, 192, 0.28);
  border-radius: 9px;
  background: rgba(11, 17, 27, 0.94);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(10px);
}

.teaching-controls-dock .teaching-controls {
  margin-top: 0;
}

.teaching-control,
.teaching-play,
.teaching-finish {
  min-height: 29px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  background: rgba(152, 174, 205, 0.04);
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.teaching-control {
  width: 29px;
  padding: 0;
  font-family: "DM Mono", monospace;
  font-size: 16px;
}

.teaching-play {
  min-width: 79px;
  padding: 0 10px;
  border-color: rgba(110, 212, 192, 0.54);
  color: var(--teal);
  background: rgba(110, 212, 192, 0.08);
}

.teaching-control:hover,
.teaching-play:hover,
.teaching-finish:hover {
  border-color: rgba(110, 212, 192, 0.62);
  color: var(--ink);
  background: rgba(110, 212, 192, 0.1);
}

.teaching-speed {
  gap: 6px;
  min-height: 29px;
  margin-left: auto;
  color: var(--subtle);
  font-family: "DM Mono", monospace;
  font-size: 8px;
  text-transform: uppercase;
}

.teaching-speed select {
  width: auto;
  height: 29px;
  padding: 0 7px;
  font-size: 9px;
}

.teaching-finish {
  gap: 7px;
  padding: 0 9px;
  border-color: rgba(245, 184, 75, 0.34);
  color: var(--gold);
  background: rgba(245, 184, 75, 0.07);
}

.plot-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 13px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 9px;
}

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

.legend-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.legend-dot.start {
  background: var(--gold);
}

.legend-line {
  display: inline-block;
  width: 20px;
  height: 2px;
  border-radius: 2px;
}

.legend-line.route {
  background: var(--teal);
}

.legend-line.preview {
  background: repeating-linear-gradient(90deg, var(--preview) 0 5px, transparent 5px 9px);
}

.legend-line.desire {
  background: repeating-linear-gradient(90deg, var(--red) 0 5px, transparent 5px 9px);
}

.legend-line.agreement {
  background: var(--teal);
  box-shadow: 0 0 7px rgba(110, 212, 192, 0.4);
}

.legend-line.candidate {
  background: repeating-linear-gradient(90deg, var(--teal) 0 5px, transparent 5px 9px);
}

.legend-line.removed {
  background: repeating-linear-gradient(90deg, var(--red) 0 5px, transparent 5px 9px);
}

.legend-line.focus {
  height: 3px;
  background: var(--gold);
  box-shadow: 0 0 7px rgba(245, 184, 75, 0.35);
}

.results-strip {
  display: grid;
  grid-template-columns: minmax(160px, 1.4fr) repeat(3, minmax(110px, 0.8fr)) minmax(250px, 2fr);
  gap: 0;
  margin-top: 22px;
  padding: 21px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.results-heading,
.metric,
.route-order {
  min-width: 0;
  padding: 0 22px;
  border-right: 1px solid var(--line);
}

.results-heading {
  padding-left: 0;
}

.results-heading h2 {
  margin-top: 7px;
  font-size: 17px;
}

.metric {
  display: grid;
  align-content: start;
  gap: 7px;
}

.metric-label {
  color: var(--subtle);
  font-size: 9px;
}

.metric strong {
  color: var(--ink);
  font-family: "DM Mono", monospace;
  font-size: 17px;
  font-weight: 500;
}

.route-metric strong {
  color: var(--teal);
}

.metric small {
  color: var(--subtle);
  font-size: 9px;
}

.route-order {
  border-right: 0;
}

.route-order-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.route-toggle {
  min-height: 24px;
  padding: 3px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 8px;
  background: rgba(152, 174, 205, 0.04);
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
}

.route-toggle:hover {
  border-color: rgba(110, 212, 192, 0.48);
  color: var(--teal);
  background: rgba(110, 212, 192, 0.08);
}

.route-order p {
  overflow: hidden;
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#route-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  max-height: 72px;
  overflow-x: hidden;
  overflow-y: auto;
  margin: 9px 0 0;
  padding: 0 5px 4px 0;
  list-style: none;
  scrollbar-color: rgba(110, 212, 192, 0.42) transparent;
  scrollbar-width: thin;
}

.route-order[data-expanded="true"] #route-list {
  max-height: 230px;
}

#route-list li {
  display: grid;
  min-width: 23px;
  height: 22px;
  padding: 0 5px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 9px;
}

#route-list li[data-start="true"] {
  border-color: rgba(245, 184, 75, 0.45);
  color: var(--gold);
}

#route-list:focus-visible {
  outline: 1px solid rgba(110, 212, 192, 0.72);
  outline-offset: 3px;
}

.footer {
  display: flex;
  justify-content: space-between;
  padding-top: 18px;
  color: var(--subtle);
  font-family: "DM Mono", monospace;
  font-size: 9px;
}

.footer-meta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-align: right;
}

.footer-link {
  color: var(--teal);
  text-decoration: none;
}

.footer-link:hover,
.footer-link:focus-visible {
  text-decoration: underline;
  text-underline-offset: 3px;
}

@media (max-width: 1080px) {
  .app-shell {
    padding-right: 24px;
    padding-left: 24px;
  }

  .workspace {
    grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  }

  .results-strip {
    grid-template-columns: 1.1fr repeat(3, 0.75fr);
  }

  .route-order {
    grid-column: 1 / -1;
    margin-top: 21px;
    padding: 17px 0 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 820px) {
  .topbar-context .eyebrow {
    display: none;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .controls-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 26px;
  }

  .controls-panel .panel-heading,
  .controls-panel .intro-copy,
  .controls-panel .mode-switch,
  .controls-panel form,
  .controls-panel .explanation {
    grid-column: 1 / -1;
  }

  .controls-panel .intro-copy {
    max-width: 620px;
  }

  .canvas-stage,
  #plot-canvas {
    min-height: 460px;
    height: 460px;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 0 14px 22px;
  }

  .topbar {
    min-height: 76px;
  }

  .brand {
    gap: 9px;
  }

  .brand-mark {
    width: 64px;
    height: 32px;
  }

  .backend-pill {
    padding: 7px 9px;
    font-size: 9px;
  }

  .topbar-context {
    gap: 7px;
  }

  .eyebrow {
    display: none;
  }

  .language-label {
    display: none;
  }

  .controls-panel,
  .visual-panel {
    padding: 21px 17px 18px;
  }

  .controls-panel {
    display: block;
  }

  .mode-switch {
    margin-top: 20px;
  }

  .mode-button {
    min-height: 52px;
    padding: 7px;
  }

  .mode-button small {
    display: none;
  }

  .execution-button small {
    display: none;
  }

  .execution-button {
    min-height: 44px;
  }

  .canvas-stage,
  #plot-canvas {
    min-height: 380px;
    height: 380px;
  }

  .canvas-tools {
    top: 9px;
    right: 9px;
  }

  .canvas-draw-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .canvas-tool.wide {
    padding: 0 6px;
  }

  .fullscreen-label {
    display: none;
  }

  .fullscreen-glyph {
    margin-right: 0;
  }

  .results-strip {
    grid-template-columns: 1fr 1fr;
    gap: 18px 0;
  }

  .results-heading {
    grid-column: 1 / -1;
    padding: 0 0 5px;
  }

  .metric {
    padding: 0 14px 0 0;
    border-right: 0;
  }

  .metric:nth-of-type(odd) {
    padding-left: 14px;
  }

  .route-order {
    grid-column: 1 / -1;
    margin-top: 2px;
    padding: 17px 0 0;
  }

  .footer {
    display: grid;
    gap: 7px;
  }

  .teaching-stage-list {
    grid-template-columns: 1fr 1fr;
  }

  .teaching-speed {
    margin-left: 0;
  }

  .teaching-finish {
    flex: 1 1 100%;
    justify-content: space-between;
  }
}
