:root {
  color-scheme: light;
  --ink: #202d3b;
  --muted: #586777;
  --paper: #ffffff;
  --wash: #f6f8fa;
  --line: #dce3e8;
  --accent: #087f8c;
  --accent-wash: #eaf8f7;
  --warm: #b94f20;
  --warm-wash: #fff4e9;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button {
  font: inherit;
  cursor: pointer;
}
button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
button:disabled {
  cursor: default;
  opacity: 0.35;
}
[hidden] {
  display: none !important;
}
.walkthrough {
  max-width: 940px;
  margin: auto;
  padding: 24px;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 13px;
}
h1 {
  font-size: 25px;
  letter-spacing: -0.6px;
  line-height: 1.2;
  margin: 0;
  font-weight: 650;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--accent-wash);
  color: var(--accent);
  font:
    italic 32px Georgia,
    serif;
}
.scenarios {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 4px;
  gap: 4px;
  border-radius: 10px;
  background: var(--wash);
}
.scenarios button {
  padding: 9px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
}
.scenarios button[aria-pressed="true"] {
  color: var(--ink);
  background: var(--paper);
  border-color: var(--line);
  box-shadow: 0 2px 4px #20304709;
  font-weight: 600;
}
.route {
  --position: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  position: relative;
  list-style: none;
  margin: 21px 0 20px;
  padding: 0;
}
.route::before {
  content: "";
  height: 2px;
  background: var(--line);
  position: absolute;
  left: 8.33%;
  right: 8.33%;
  top: 5px;
}
.route::after {
  content: "";
  position: absolute;
  width: 12px;
  height: 12px;
  left: calc((var(--position) + 0.5) * 100% / 6);
  top: 0;
  transform: translateX(-50%);
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px var(--accent-wash);
  transition: left 0.65s cubic-bezier(0.4, 0, 0.2, 1);
}
.route li {
  position: relative;
  padding-top: 23px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.route li::before {
  content: "";
  display: block;
  width: 8px;
  height: 8px;
  position: absolute;
  left: calc(50% - 4px);
  top: 2px;
  border-radius: 50%;
  background: var(--line);
}
.route li.active {
  color: var(--accent);
  font-weight: 650;
}
.route li.skipped {
  opacity: 0.45;
}
.board {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 14px;
}
.source-panel,
.state-panel {
  min-width: 0;
  height: 270px;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.source-panel {
  padding: 21px 16px;
  background: var(--wash);
}
.source-code {
  margin: 0 0 18px;
  font: 14px/1.85 var(--mono);
  overflow: auto;
}
.source-code span {
  display: block;
  border-radius: 4px;
  transition:
    background 0.3s,
    color 0.3s;
}
.source-code span.active {
  background: var(--warm-wash);
  color: var(--warm);
  box-shadow: -5px 0 0 var(--warm);
}
.input-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
  font-size: 13px;
}
.input-meta code,
#shape {
  font: 13px var(--mono);
}
#shape {
  margin-left: auto;
  color: var(--accent);
}
.input-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}
.input-note {
  font-size: 12px;
  color: var(--muted);
  margin: 10px 0 0;
}
.state-panel {
  padding: 15px 16px;
  background: var(--paper);
}
.state-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}
#state-view {
  height: 208px;
  display: grid;
  align-items: center;
}
#state-view > * {
  min-width: 0;
}
.scene-enter {
  animation: scene-enter 0.42s ease both;
}
.graph {
  width: 100%;
  height: 208px;
  overflow: visible;
}
.graph text {
  font-family: var(--mono);
  font-size: 17px;
  fill: var(--ink);
}
.graph rect {
  fill: var(--paper);
  stroke: var(--line);
  stroke-width: 1.5;
}
.graph .input rect {
  fill: var(--accent-wash);
  stroke: var(--accent);
}
.graph .node.active rect {
  stroke: var(--warm);
  fill: var(--warm-wash);
}
.graph .node.active text {
  fill: var(--warm);
}
.graph .pending {
  opacity: 0.1;
}
.graph .edge {
  stroke: var(--muted);
  stroke-width: 1.5;
  fill: none;
}
.graph .reveal {
  animation: scene-enter 0.55s ease both;
}
.graph .edge.reveal {
  stroke-dasharray: 250;
  animation: draw 0.7s ease both;
}
.compiled {
  margin: 0;
  font: 12px/1.8 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--ink);
}
.bindings {
  border-top: 1px solid var(--line);
  padding-top: 8px;
  margin: 8px 0 0;
  font: 11px/1.6 var(--mono);
  color: var(--muted);
}
.guard-list {
  list-style: none;
  margin: 0;
  padding: 0;
  font: 14px/1.5 var(--mono);
}
.guard-list li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.guard-list .mark {
  color: var(--accent);
  font-family: system-ui, sans-serif;
}
.guard-list .fail {
  color: var(--warm);
}
.small-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
  margin: 9px 0 0;
}
.stage-center {
  text-align: center;
}
.stage-center .symbol {
  display: block;
  width: fit-content;
  margin: 0 auto 12px;
  padding: 10px 20px;
  border: 1px solid var(--line);
  background: var(--wash);
  border-radius: 10px;
  font: 18px var(--mono);
}
.stage-center .big {
  font-size: 31px;
  font-weight: 650;
  letter-spacing: -0.7px;
  margin: 0 0 7px;
}
.stage-center .sub {
  font: 13px/1.6 var(--mono);
  color: var(--muted);
  margin: 0;
}
.stage-center.hit .symbol {
  color: var(--accent);
  background: var(--accent-wash);
  border-color: var(--accent);
  animation: hit 0.8s ease both;
}
.stage-center.result .big {
  color: var(--accent);
  font: 37px var(--mono);
}
.stage-center.result .symbol {
  font-size: 13px;
}
.cache-strip {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px 0 0;
  min-height: 43px;
  font-size: 12px;
}
.cache-label {
  color: var(--muted);
}
#cache-entries {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.cache-entry {
  font: 12px var(--mono);
  color: var(--muted);
  background: var(--wash);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 5px 8px;
}
.cache-entry.matched {
  color: var(--accent);
  background: var(--accent-wash);
  border-color: var(--accent);
}
.cache-entry.missed {
  color: var(--warm);
  border-color: var(--warm);
}
.cache-empty {
  color: var(--muted);
  font-style: italic;
}
.narration {
  min-height: 88px;
  padding-top: 18px;
}
h2 {
  margin: 0 0 6px;
  font-size: 19px;
  line-height: 1.3;
  letter-spacing: -0.2px;
}
.narration p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}
.controls {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.controls button {
  min-height: 38px;
  border-radius: 7px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--paper);
}
.controls .primary {
  padding: 8px 17px;
  min-width: 144px;
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}
.step-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}
.step-controls button {
  width: 38px;
  font-size: 20px;
}
#step-count {
  min-width: 45px;
  text-align: center;
  font: 12px var(--mono);
  color: var(--muted);
}
@keyframes scene-enter {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes draw {
  from {
    stroke-dashoffset: 250;
  }
  to {
    stroke-dashoffset: 0;
  }
}
@keyframes hit {
  40% {
    box-shadow: 0 0 0 9px var(--accent-wash);
  }
}
@media (max-width: 640px) {
  .walkthrough {
    padding: 16px;
  }
  header {
    margin-bottom: 14px;
  }
  h1 {
    font-size: 22px;
  }
  .brand-mark {
    width: 36px;
    height: 36px;
    font-size: 27px;
  }
  .eyebrow {
    font-size: 12px;
  }
  .scenarios button {
    font-size: 12px;
    padding: 9px 2px;
  }
  .route {
    margin: 17px 0 14px;
  }
  .route li {
    font-size: 11px;
    padding-top: 20px;
  }
  .board {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .source-panel {
    height: 190px;
    padding: 12px 16px;
  }
  .source-code {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 8px;
  }
  .input-meta {
    padding-top: 8px;
  }
  .input-note {
    margin-top: 6px;
  }
  .state-panel {
    height: auto;
    min-height: 236px;
    padding: 12px 16px;
  }
  #state-view,
  .graph {
    height: 186px;
  }
  .compiled {
    font-size: 12px;
    line-height: 1.65;
  }
  .bindings {
    font-size: 11px;
  }
  .narration {
    min-height: 105px;
    padding-top: 14px;
  }
  h2 {
    font-size: 18px;
  }
  .narration p {
    font-size: 13px;
    line-height: 1.5;
  }
  .controls {
    padding-top: 12px;
  }
  .controls .primary {
    min-width: 128px;
    padding: 8px 10px;
    font-size: 13px;
  }
  .step-controls {
    gap: 5px;
  }
  .step-controls button {
    width: 32px;
  }
  #step-count {
    min-width: 38px;
    font-size: 11px;
  }
  .guard-list {
    font-size: 13px;
  }
  .stage-center.result .big {
    font-size: 26px;
  }
  .cache-entry {
    padding: 4px 6px;
    font-size: 11px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --ink: #e4ebf2;
    --muted: #a8b5c4;
    --paper: #19232e;
    --wash: #202e3b;
    --line: #3b4b5a;
    --accent: #60cec8;
    --accent-wash: #233e43;
    --warm: #ffb084;
    --warm-wash: #49362c;
  }
  .controls .primary {
    color: #142b30;
  }
}
