:root {
  color-scheme: dark;
  --bg: #0e1117;
  --bg-soft: #151a22;
  --surface: #1c2430;
  --surface-2: #222c3b;
  --border: #354255;
  --border-strong: #56667b;
  --text: #eef3fb;
  --muted: #aab5c5;
  --faint: #748197;
  --blue: #5aa7ff;
  --blue-soft: rgba(90, 167, 255, 0.18);
  --amber: #ffc857;
  --amber-soft: rgba(255, 200, 87, 0.2);
  --green: #6ee7a8;
  --green-soft: rgba(110, 231, 168, 0.2);
  --violet: #b195ff;
  --violet-soft: rgba(177, 149, 255, 0.18);
  --red: #ff7a90;
  --red-soft: rgba(255, 122, 144, 0.18);
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.32);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    linear-gradient(135deg, rgba(90, 167, 255, 0.08), transparent 34%),
    radial-gradient(circle at top right, rgba(177, 149, 255, 0.14), transparent 28%),
    var(--bg);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0 12px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

button:hover {
  border-color: var(--blue);
  background: #29364a;
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button.primary {
  background: linear-gradient(180deg, #3479d7, #2862b7);
  border-color: #5594e6;
}

.nav-button {
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0 12px;
  background: #121923;
  color: var(--text);
  display: inline-grid;
  place-items: center;
  text-decoration: none;
}

.nav-button:hover {
  border-color: var(--blue);
  background: #29364a;
}

button:focus-visible,
.nav-button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
}

select,
input[type="range"] {
  accent-color: var(--blue);
  min-width: 0;
  width: 100%;
}

.app-shell {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.topbar > * {
  min-width: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 0.95;
  letter-spacing: 0;
  overflow-wrap: break-word;
}

h2 {
  font-size: 0.98rem;
  letter-spacing: 0;
}

.subtitle {
  margin-top: 10px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.45;
}

.status-card {
  min-width: 180px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: rgba(28, 36, 48, 0.88);
  box-shadow: var(--shadow);
  display: grid;
  gap: 3px;
  align-content: center;
}

.status-card strong {
  font-size: 1.65rem;
  line-height: 1;
}

.status-label,
.status-card span:last-child,
.panel-header span {
  color: var(--muted);
  font-size: 0.82rem;
}

.control-panel,
.legend,
.matrix-panel,
.side-panel > section,
.explanation-card,
.algorithm-card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(28, 36, 48, 0.9);
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 14px;
}

.control-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.control-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto 220px;
  gap: 12px;
  margin-top: 12px;
  align-items: center;
}

.control-row label,
.memory-control-row label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.control-row select,
.memory-control-row select {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0 28px 0 10px;
  background: var(--surface-2);
  color: var(--text);
}

.memory-control-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, auto)) 1fr;
  gap: 12px;
  margin-top: 12px;
  align-items: end;
}

.thread-control-row {
  display: grid;
  grid-template-columns: 1fr repeat(3, minmax(100px, auto)) 220px;
  gap: 12px;
  margin-top: 12px;
  align-items: center;
}

.thread-control-row label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.thread-control-row select {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0 28px 0 10px;
  background: var(--surface-2);
  color: var(--text);
}

.cache-note {
  justify-self: end;
  color: var(--muted);
  font-size: 0.82rem;
  padding-bottom: 8px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin: 14px 0;
  padding: 10px 12px;
  color: var(--muted);
  font-size: 0.84rem;
}

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

.swatch {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  display: inline-block;
}

.swatch.fetched {
  background: var(--amber);
}

.swatch.tile {
  background: var(--violet-soft);
  border-color: var(--violet);
}

.swatch.write {
  background: var(--blue);
}

.swatch.partial {
  background: var(--blue-soft);
  border-color: var(--blue);
}

.swatch.complete {
  background: var(--green);
}

.swatch.unused {
  background:
    repeating-linear-gradient(135deg, rgba(116, 129, 151, 0.16) 0 4px, rgba(116, 129, 151, 0.04) 4px 8px),
    #111722;
}

.swatch.mem-read {
  background: var(--amber);
}

.swatch.mem-write {
  background: var(--blue);
}

.swatch.mem-cache {
  background: rgba(255, 200, 87, 0.14);
  border-color: rgba(255, 200, 87, 0.46);
}

.swatch.thread0 { background: rgba(255, 200, 87, 0.62); }
.swatch.thread1 { background: rgba(90, 167, 255, 0.62); }
.swatch.thread2 { background: rgba(110, 231, 168, 0.62); }
.swatch.thread3 { background: rgba(177, 149, 255, 0.62); }

.workspace {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr) minmax(280px, 1.12fr) minmax(250px, 0.8fr);
  gap: 14px;
  align-items: start;
}

.matrix-panel {
  min-width: 0;
  padding: 12px;
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.matrix-grid {
  display: grid;
  gap: 4px;
}

.cell {
  min-width: 0;
  aspect-ratio: 1;
  border: 1px solid #2f3b4d;
  border-radius: 5px;
  background: #121923;
  color: #dfe8f5;
  display: grid;
  place-items: center;
  font-size: clamp(0.62rem, 1.15vw, 0.88rem);
  font-variant-numeric: tabular-nums;
  position: relative;
  overflow: hidden;
  transition: background 180ms ease, border-color 180ms ease, color 180ms ease, opacity 180ms ease;
}

.cell small {
  position: absolute;
  right: 3px;
  bottom: 2px;
  color: rgba(238, 243, 251, 0.62);
  font-size: 0.52rem;
}

.cell.unused {
  color: #7d899a;
  background:
    repeating-linear-gradient(135deg, rgba(116, 129, 151, 0.1) 0 4px, transparent 4px 9px),
    #101620;
  border-color: #222c3b;
  opacity: 0.72;
}

.cell.tile {
  background: var(--violet-soft);
  border-color: rgba(177, 149, 255, 0.82);
}

.cell.row-col-path {
  background: rgba(177, 149, 255, 0.28);
}

.cell.outer-vector {
  background: rgba(110, 231, 168, 0.14);
  border-color: rgba(110, 231, 168, 0.52);
  color: #c9f7dc;
}

.cell.shared-read {
  box-shadow: inset 0 0 0 2px rgba(238, 243, 251, 0.6), 0 0 22px rgba(255, 200, 87, 0.2);
}

.cell.owner-t0 { background: rgba(255, 200, 87, 0.1); border-color: rgba(255, 200, 87, 0.42); }
.cell.owner-t1 { background: rgba(90, 167, 255, 0.1); border-color: rgba(90, 167, 255, 0.42); }
.cell.owner-t2 { background: rgba(110, 231, 168, 0.1); border-color: rgba(110, 231, 168, 0.42); }
.cell.owner-t3 { background: rgba(177, 149, 255, 0.1); border-color: rgba(177, 149, 255, 0.42); }
.cell.owner-t4 { background: rgba(255, 122, 144, 0.1); border-color: rgba(255, 122, 144, 0.42); }
.cell.owner-t5 { background: rgba(76, 213, 219, 0.1); border-color: rgba(76, 213, 219, 0.42); }
.cell.owner-t6 { background: rgba(255, 159, 91, 0.1); border-color: rgba(255, 159, 91, 0.42); }
.cell.owner-t7 { background: rgba(200, 220, 120, 0.1); border-color: rgba(200, 220, 120, 0.42); }

.cell.thread-write-t0 { box-shadow: 0 0 0 2px rgba(255, 200, 87, 0.4), 0 0 24px rgba(255, 200, 87, 0.24); }
.cell.thread-write-t1 { box-shadow: 0 0 0 2px rgba(90, 167, 255, 0.4), 0 0 24px rgba(90, 167, 255, 0.24); }
.cell.thread-write-t2 { box-shadow: 0 0 0 2px rgba(110, 231, 168, 0.4), 0 0 24px rgba(110, 231, 168, 0.24); }
.cell.thread-write-t3 { box-shadow: 0 0 0 2px rgba(177, 149, 255, 0.4), 0 0 24px rgba(177, 149, 255, 0.24); }

.cell.fetched {
  color: #101620;
  background: var(--amber);
  border-color: #ffe49b;
  box-shadow: 0 0 0 2px rgba(255, 200, 87, 0.28), 0 0 22px rgba(255, 200, 87, 0.24);
  animation: pulseRead 700ms ease;
  z-index: 1;
}

.cell.partial {
  background: var(--blue-soft);
  border-color: rgba(90, 167, 255, 0.72);
}

.cell.writing {
  color: #07111e;
  background: var(--blue);
  border-color: #b2d8ff;
  box-shadow: 0 0 0 2px rgba(90, 167, 255, 0.28), 0 0 24px rgba(90, 167, 255, 0.26);
  animation: pulseWrite 700ms ease;
  z-index: 2;
}

.cell.complete {
  color: #061511;
  background: var(--green);
  border-color: #bdf8d8;
}

.cell.queued {
  outline: 2px dashed var(--amber);
  outline-offset: -4px;
}

@keyframes pulseRead {
  0% { transform: scale(0.94); }
  55% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

@keyframes pulseWrite {
  0% { transform: scale(0.92); }
  55% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.side-panel {
  display: grid;
  gap: 14px;
}

.side-panel > section {
  padding: 12px;
}

.thread-workspace {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr) minmax(300px, 1.12fr) minmax(260px, 0.82fr);
  gap: 14px;
  align-items: start;
}

.thread-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 14px;
  margin-top: 14px;
}

.audit-panel {
  display: grid;
  gap: 9px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.42;
}

.audit-panel p,
.audit-panel ul {
  margin: 0;
}

.audit-panel ul {
  display: grid;
  gap: 6px;
  padding: 0;
  list-style: none;
}

.audit-panel li {
  display: flex;
  align-items: center;
  gap: 7px;
}

.audit-pass {
  color: var(--green);
  font-weight: 750;
}

.audit-fail {
  color: var(--red);
  font-weight: 750;
}

.thread-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
}

.thread-dot.t0 { background: var(--amber); }
.thread-dot.t1 { background: var(--blue); }
.thread-dot.t2 { background: var(--green); }
.thread-dot.t3 { background: var(--violet); }
.thread-dot.t4 { background: var(--red); }
.thread-dot.t5 { background: #4cd5db; }
.thread-dot.t6 { background: #ff9f5b; }
.thread-dot.t7 { background: #c8dc78; }

.thread-lanes,
.wave-cards {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.thread-card,
.wave-card {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #121923;
}

.thread-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 8px;
  padding: 9px;
  color: var(--muted);
  font-size: 0.78rem;
}

.thread-card strong {
  color: var(--text);
  grid-row: span 3;
}

.thread-card code {
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.thread-card.active.t0,
.wave-card.t0 { border-color: rgba(255, 200, 87, 0.68); }
.thread-card.active.t1,
.wave-card.t1 { border-color: rgba(90, 167, 255, 0.68); }
.thread-card.active.t2,
.wave-card.t2 { border-color: rgba(110, 231, 168, 0.68); }
.thread-card.active.t3,
.wave-card.t3 { border-color: rgba(177, 149, 255, 0.68); }
.thread-card.active.t4,
.wave-card.t4 { border-color: rgba(255, 122, 144, 0.68); }

.wave-cards {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.wave-card {
  padding: 10px;
}

.wave-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 9px;
}

.wave-card-head strong {
  font-size: 1rem;
}

.wave-card-head span {
  color: var(--muted);
  font-size: 0.76rem;
}

.thread-mini-flow {
  display: grid;
  grid-template-columns: minmax(38px, 0.55fr) auto minmax(76px, 1fr) auto minmax(92px, 1.1fr);
  gap: 6px;
  align-items: center;
}

.thread-mini-flow > span {
  color: var(--faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 800;
}

.thread-mini-flow b {
  min-height: 25px;
  border: 1px solid #3a485d;
  border-radius: 5px;
  background: #0f1722;
  color: var(--text);
  display: grid;
  place-items: center;
  padding: 2px 4px;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.thread-mini-flow > div,
.mini-row,
.mini-grid {
  display: grid;
  gap: 4px;
}

.mini-row {
  grid-template-columns: repeat(2, minmax(28px, 1fr));
}

.mini-grid {
  grid-template-columns: repeat(var(--mini-cols, 2), minmax(28px, 1fr));
}

.loop-state {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.loop-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}

.loop-row code {
  color: var(--text);
  font-size: 0.82rem;
}

.meter {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #111923;
  border: 1px solid #2b3648;
}

.meter span {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--blue), var(--green));
}

.tile-map,
.k-tile-map {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

.tile-chip,
.k-chip {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #121923;
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}

.tile-chip.active,
.k-chip.active {
  color: #101620;
  background: var(--amber);
  border-color: #ffe29a;
}

.tile-chip.done,
.k-chip.done {
  color: #061511;
  background: var(--green);
  border-color: #bdf8d8;
}

.tile-chip.partial,
.k-chip.partial {
  background: var(--blue-soft);
  border-color: rgba(90, 167, 255, 0.72);
  color: var(--text);
}

.explanation-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 14px;
  margin-top: 14px;
}

.outer-subview {
  display: none;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 14px;
  margin-top: 14px;
}

.outer-subview.visible {
  display: grid;
}

.outer-subview.dot-memory-only {
  grid-template-columns: minmax(0, 1fr);
}

.outer-subview.dot-memory-only .micro-panel {
  display: none;
}

.micro-panel,
.memory-panel {
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(28, 36, 48, 0.9);
  box-shadow: var(--shadow);
  padding: 14px;
}

.micro-flow {
  display: grid;
  grid-template-columns: minmax(72px, 0.6fr) auto minmax(120px, 0.9fr) auto minmax(190px, 1.25fr) auto minmax(190px, 1.25fr);
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.micro-block {
  min-width: 0;
  display: grid;
  gap: 8px;
  align-content: start;
}

.micro-block h3,
.memory-grid h3 {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 650;
}

.flow-arrow {
  color: var(--faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.4rem;
  font-weight: 800;
  text-align: center;
}

.flow-arrow.transmute {
  color: var(--blue);
}

.micro-vector,
.micro-grid {
  display: grid;
  gap: 5px;
}

.micro-vector.vertical {
  grid-template-columns: minmax(44px, 1fr);
}

.micro-vector.horizontal {
  grid-template-columns: repeat(var(--micro-cols, 2), minmax(42px, 1fr));
}

.micro-grid {
  grid-template-columns: repeat(var(--micro-cols, 2), minmax(42px, 1fr));
}

.micro-cell {
  min-height: 42px;
  border: 1px solid #3a485d;
  border-radius: 6px;
  background: #111923;
  color: var(--text);
  display: grid;
  place-items: center;
  padding: 4px;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.micro-cell.source {
  color: #101620;
  background: var(--amber);
  border-color: #ffe29a;
}

.micro-cell.product {
  background: rgba(177, 149, 255, 0.18);
  border-color: rgba(177, 149, 255, 0.72);
}

.micro-cell.result {
  background: var(--blue-soft);
  border-color: rgba(90, 167, 255, 0.78);
}

.micro-cell small {
  display: block;
  color: rgba(238, 243, 251, 0.68);
  font-size: 0.64rem;
  margin-top: 2px;
}

.micro-copy {
  margin-top: 12px;
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.92rem;
}

.memory-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

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

.memory-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.memory-grid section {
  min-width: 0;
}

.memory-lines {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}

.cache-line {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 5px;
  align-items: stretch;
}

.line-label {
  display: grid;
  place-items: center;
  border: 1px solid #293447;
  border-radius: 5px;
  color: var(--faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.62rem;
}

.line-elements {
  display: grid;
  grid-template-columns: repeat(var(--line-count, 8), minmax(0, 1fr));
  gap: 3px;
}

.mem-cell {
  min-height: 25px;
  border: 1px solid #263246;
  border-radius: 4px;
  background:
    repeating-linear-gradient(135deg, rgba(116, 129, 151, 0.07) 0 3px, transparent 3px 7px),
    #101620;
  color: #718098;
  display: grid;
  place-items: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.58rem;
  overflow: hidden;
}

.mem-cell.cache {
  background: rgba(255, 200, 87, 0.08);
  border-color: rgba(255, 200, 87, 0.28);
}

.mem-cell.read {
  color: #101620;
  background: var(--amber);
  border-color: #ffe29a;
}

.mem-cell.write {
  color: #07111e;
  background: var(--blue);
  border-color: #b2d8ff;
}

.mem-cell.readwrite {
  color: #061511;
  background: linear-gradient(135deg, var(--amber) 0 48%, var(--blue) 52% 100%);
  border-color: #d8edff;
}

.mem-cell.hot {
  box-shadow: 0 0 0 2px rgba(255, 200, 87, 0.18), 0 0 18px rgba(255, 200, 87, 0.18);
}

.explanation-card,
.algorithm-card {
  padding: 14px;
}

.explanation {
  margin-top: 9px;
  display: grid;
  gap: 10px;
  color: var(--muted);
  line-height: 1.5;
  font-size: 0.96rem;
}

.formula {
  border: 1px solid #405069;
  border-radius: 7px;
  background: #111923;
  color: var(--text);
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow-x: auto;
}

.callout {
  border-left: 3px solid var(--blue);
  padding-left: 10px;
}

.algorithm-card {
  margin-top: 14px;
}

.algorithm-card pre {
  margin: 10px 0 0;
  overflow-x: auto;
  border-radius: 7px;
  background: #0a0f16;
  border: 1px solid #2c3749;
  padding: 12px;
}

.algorithm-card code {
  color: #d8e4f4;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.45;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: repeat(3, minmax(220px, 1fr));
  }

  .thread-workspace {
    grid-template-columns: repeat(3, minmax(220px, 1fr));
  }

  .side-panel {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .thread-detail-grid {
    grid-template-columns: 1fr;
  }

  .outer-subview,
  .memory-grid {
    grid-template-columns: 1fr;
  }

  .micro-flow {
    grid-template-columns: minmax(72px, 0.8fr) auto minmax(130px, 1fr) auto minmax(210px, 1.25fr);
  }

  .micro-block.wide:last-child {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .app-shell {
    width: min(100vw - 20px, 720px);
    padding-top: 16px;
  }

  .topbar,
  .explanation-grid {
    grid-template-columns: 1fr;
    display: grid;
  }

  h1 {
    font-size: clamp(1.82rem, 8.5vw, 2.45rem);
    line-height: 1.04;
  }

  .status-card {
    min-width: 0;
  }

  .control-group button {
    flex: 1 1 auto;
  }

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

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

  .side-panel {
    grid-column: auto;
    grid-template-columns: 1fr;
  }

  .control-row {
    grid-template-columns: 1fr;
  }

  .thread-control-row {
    grid-template-columns: 1fr;
  }

  .memory-control-row {
    grid-template-columns: 1fr 1fr;
  }

  .cache-note {
    justify-self: start;
    grid-column: 1 / -1;
  }

  .micro-flow {
    grid-template-columns: 1fr;
  }

  .wave-cards {
    grid-template-columns: 1fr;
  }

  .thread-mini-flow {
    grid-template-columns: 1fr;
  }

  .flow-arrow {
    transform: rotate(90deg);
  }

  .cell {
    font-size: 0.8rem;
  }
}

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