:root {
  color-scheme: dark;
  --bg: #0b0f0f;
  --panel: #111717;
  --panel-2: #151d1c;
  --line: #293533;
  --text: #f3f6f4;
  --muted: #aebbb7;
  --green: #70d6a6;
  --amber: #f3ba63;
  --red: #f27973;
  --blue: #79b8ec;
  --lab-focus-color: #f3ba63;
  font-family: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.7; }
button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; }

.site-header {
  width: min(1480px, calc(100% - 40px));
  min-height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; font-size: 13px; font-weight: 800; letter-spacing: .12em; }
.brand-mark { display: grid; width: 34px; aspect-ratio: 1; place-items: center; border: 1px solid var(--amber); color: var(--amber); }
.site-header nav { display: flex; flex-wrap: wrap; gap: 22px; }
.site-header nav a { color: var(--muted); font-size: 14px; text-decoration: none; }
.site-header nav a:hover { color: var(--text); }

main { width: min(1480px, calc(100% - 40px)); margin: 0 auto; padding: 70px 0 96px; }
.hero { max-width: 880px; margin-bottom: 38px; }
.eyebrow, .panel-label { margin: 0; color: var(--amber); font: 800 12px/1.4 ui-monospace, SFMono-Regular, Consolas, monospace; letter-spacing: .17em; }
.hero h1 { margin: 15px 0 20px; font-size: clamp(42px, 6vw, 82px); line-height: 1.08; letter-spacing: -.055em; }
.hero h1 em { color: var(--amber); font-style: normal; }
.hero > p:last-child { max-width: 720px; margin: 0; color: var(--muted); font-size: 18px; line-height: 1.9; }

.boundary-strip {
  display: grid;
  grid-template-columns: auto 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 10px 16px;
  margin-bottom: 22px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  background: #0e1313;
}
.boundary-strip span { color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: .08em; }
.boundary-strip strong { font-size: 13px; font-weight: 700; }

.lab { border: 1px solid var(--line); background: var(--panel); }
.scenario-bar { display: flex; justify-content: space-between; gap: 18px; padding: 16px; border-bottom: 1px solid var(--line); }
.scenario-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.scenario-tab, .speed-control button, .control-buttons button {
  border: 1px solid #34423f;
  border-radius: 3px;
  background: #101615;
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}
.scenario-tab { padding: 8px 11px; }
.scenario-tab:hover, .speed-control button:hover, .control-buttons button:hover { border-color: #60716d; background: #18201f; }
.scenario-tab.is-active, .speed-control button.is-active { border-color: var(--amber); color: var(--amber); background: #211b12; }
.step-readout { display: flex; min-width: 118px; align-items: center; justify-content: flex-end; gap: 9px; font: 700 12px/1.2 ui-monospace, Consolas, monospace; }
.step-readout span { color: var(--muted); }
.step-readout strong { color: var(--amber); font-size: 14px; }

.lab-grid { display: grid; grid-template-columns: minmax(460px, 1.55fr) minmax(280px, .8fr) minmax(310px, .9fr); min-height: 620px; }
.stage-panel, .explain-panel, .inspect-panel { min-width: 0; }
.stage-panel { padding: 20px; border-right: 1px solid var(--line); }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.panel-head h2 { margin: 5px 0 0; font-size: 20px; line-height: 1.35; }
.panel-head > p { max-width: 240px; margin: 0; color: var(--muted); text-align: right; font-size: 12px; }
#motion-stage { display: block; width: 100%; min-height: 390px; border: 1px solid #2b3735; background: #0d1212; }
.trace-path { fill: none; stroke: var(--amber); stroke-width: 5; stroke-linecap: round; opacity: .78; }
.trace-path.muted { stroke: #5e706c; stroke-dasharray: 9 8; opacity: .52; }
.sweep-body { fill: rgba(121,184,236,.09); stroke: var(--blue); stroke-width: 2; stroke-dasharray: 7 6; }
.projectile-body { fill: var(--amber); stroke: #fff1d2; stroke-width: 2; }
.source-body { fill: #18211f; stroke: var(--green); stroke-width: 3; }
.target-body { fill: #18201f; stroke: #82918d; stroke-width: 3; }
.target-body.candidate { stroke: var(--blue); }
.target-body.hit { fill: rgba(112,214,166,.22); stroke: var(--green); }
.target-body.blocked { fill: rgba(242,121,115,.18); stroke: var(--red); }
.obstacle { fill: #2b2222; stroke: var(--red); stroke-width: 2; }
.motion-arrow { stroke: var(--amber); stroke-width: 4; marker-end: url(#motion-arrow); }
.actual-arrow { stroke: var(--green); stroke-width: 5; marker-end: url(#motion-arrow); }
.world-label { fill: var(--text); font: 750 15px Inter, sans-serif; text-anchor: middle; paint-order: stroke; stroke: #0b0f0f; stroke-width: 5px; }
.world-note { fill: var(--muted); font: 700 13px Inter, sans-serif; text-anchor: middle; paint-order: stroke; stroke: #0b0f0f; stroke-width: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px 18px; margin-top: 12px; color: var(--muted); font-size: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; }
.projectile-dot { background: var(--amber); }
.candidate-dot { border: 2px solid var(--blue); }
.hit-dot { background: var(--green); }
.blocked-dot { background: var(--red); }

.explain-panel { padding: 24px; border-right: 1px solid var(--line); background: #101615; }
.phase { margin: 26px 0 8px; color: var(--green); font: 800 12px/1.4 ui-monospace, Consolas, monospace; letter-spacing: .13em; }
.explain-panel h2 { margin: 0 0 14px; font-size: 28px; line-height: 1.25; }
.explain-panel > p:not(.panel-label):not(.phase) { margin: 0; color: var(--muted); }
.change-box, .why-box, .decision-card { margin-top: 20px; padding: 15px 16px; border: 1px solid var(--line); background: var(--panel-2); }
.change-box > span, .why-box > span, .decision-card > span { color: var(--muted); font: 800 11px/1.3 ui-monospace, Consolas, monospace; letter-spacing: .12em; }
.change-box p, .why-box p, .decision-card p { margin: 7px 0 0; font-size: 14px; }
.why-box { border-left: 3px solid var(--amber); }
.decision-card { margin-top: 26px; border-color: #394845; }
.decision-card strong { display: block; margin-top: 9px; color: var(--amber); font-size: 18px; line-height: 1.4; }
.decision-card p { color: var(--muted); }

.inspect-panel { display: flex; flex-direction: column; background: #0e1413; }
.state-grid { display: grid; grid-template-columns: repeat(2, 1fr); border-bottom: 1px solid var(--line); }
.state-grid > div { min-height: 96px; padding: 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.state-grid > div:nth-child(even) { border-right: 0; }
.state-grid span { display: block; color: var(--muted); font: 800 10px/1.3 ui-monospace, Consolas, monospace; letter-spacing: .13em; }
.state-grid strong { display: block; overflow-wrap: anywhere; margin-top: 7px; color: var(--text); font: 800 16px/1.3 ui-monospace, Consolas, monospace; }
.state-grid small { display: block; margin-top: 4px; color: #879692; font-size: 12px; }
.state-grid .status-cell { grid-column: 1 / -1; border-right: 0; }
.status-cell strong { color: var(--green); }
.code-panel { flex: 1; min-height: 260px; }
.code-head { display: flex; justify-content: space-between; padding: 15px; border-bottom: 1px solid var(--line); color: var(--muted); font: 800 10px/1.3 ui-monospace, Consolas, monospace; letter-spacing: .12em; }
.code-head strong { color: var(--amber); }
#code-lines { margin: 0; padding: 14px 12px 18px 46px; font: 500 12px/1.7 ui-monospace, SFMono-Regular, Consolas, monospace; color: #b9c4c1; }
#code-lines li { min-height: 20px; padding: 1px 7px; white-space: pre-wrap; overflow-wrap: anywhere; border-left: 2px solid transparent; }
#code-lines li::marker { color: #576561; }
#code-lines li.is-active { color: #fff4dd; border-left-color: var(--amber); background: #231d13; }

.timeline-panel { display: grid; grid-template-columns: 230px 1fr; border-top: 1px solid var(--line); }
.timeline-head { padding: 17px 20px; border-right: 1px solid var(--line); }
.timeline-head span { display: block; color: var(--muted); font: 800 11px/1.3 ui-monospace, Consolas, monospace; letter-spacing: .12em; }
.timeline-head strong { display: block; margin-top: 8px; font-size: 14px; line-height: 1.5; }
#event-trace { display: flex; align-items: stretch; overflow-x: auto; margin: 0; padding: 13px; list-style: none; }
#event-trace li { position: relative; flex: 1 0 126px; min-height: 66px; padding: 9px 10px 9px 24px; border-right: 1px solid var(--line); color: var(--muted); font-size: 12px; line-height: 1.45; }
#event-trace li::before { content: ""; position: absolute; left: 8px; top: 14px; width: 7px; height: 7px; border-radius: 50%; border: 1px solid #63716d; background: var(--panel); }
#event-trace li.is-past, #event-trace li.is-current { color: var(--text); }
#event-trace li.is-past::before { border-color: var(--green); background: var(--green); }
#event-trace li.is-current { background: #211c13; }
#event-trace li.is-current::before { border-color: var(--amber); background: var(--amber); box-shadow: 0 0 0 4px rgba(243,186,99,.12); }

.controls { display: grid; grid-template-columns: 1fr auto; gap: 14px 24px; align-items: center; padding: 18px 20px; border-top: 1px solid var(--line); background: #0c1110; }
.progress { display: flex; align-items: center; justify-content: space-between; gap: 18px; min-width: 0; }
.step-dots { display: flex; flex-wrap: wrap; gap: 7px; }
.step-dot { width: 10px; height: 10px; border: 1px solid #5f6d69; border-radius: 50%; background: transparent; }
.step-dot.is-past { border-color: var(--green); background: var(--green); }
.step-dot.is-active { border-color: var(--amber); background: var(--amber); box-shadow: 0 0 0 4px rgba(243,186,99,.11); }
.speed-control { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.speed-control > span { margin-right: 4px; color: var(--muted); font-size: 12px; }
.speed-control button { min-width: 38px; padding: 5px 8px; font-size: 12px; }
.control-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.control-buttons button { min-height: 39px; padding: 8px 13px; }
.control-buttons button.primary { border-color: var(--amber); background: var(--amber); color: #16120b; }
.control-buttons button:disabled { opacity: .45; }
.keyboard-hint { grid-column: 1 / -1; margin: 0; color: #81908c; font-size: 12px; }

.notes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; margin-top: 28px; border: 1px solid var(--line); background: var(--line); }
.notes article { min-height: 190px; padding: 24px; background: var(--panel); }
.notes span { color: var(--amber); font: 800 12px/1 ui-monospace, Consolas, monospace; }
.notes h3 { margin: 20px 0 10px; font-size: 19px; }
.notes p { margin: 0; color: var(--muted); font-size: 14px; }
.related { display: grid; grid-template-columns: 180px repeat(2, 1fr); align-items: stretch; margin-top: 28px; border: 1px solid var(--line); }
.related > p { padding: 21px; }
.related a { display: flex; flex-direction: column; justify-content: center; padding: 18px 22px; border-left: 1px solid var(--line); text-decoration: none; }
.related a:hover { background: var(--panel-2); }
.related a span { color: var(--muted); font-size: 12px; }
.related a strong { margin-top: 5px; font-size: 15px; }

@media (max-width: 1180px) {
  .lab-grid { grid-template-columns: minmax(500px, 1.5fr) minmax(300px, .8fr); }
  .inspect-panel { grid-column: 1 / -1; display: grid; grid-template-columns: .9fr 1.1fr; border-top: 1px solid var(--line); }
  .state-grid { border-bottom: 0; border-right: 1px solid var(--line); }
  .code-panel { min-height: 320px; }
  .notes { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
  .site-header { align-items: flex-start; padding: 18px 0; }
  .site-header nav { justify-content: flex-end; gap: 10px 16px; }
  main { padding-top: 45px; }
  .boundary-strip { grid-template-columns: auto 1fr; }
  .scenario-bar, .panel-head, .progress { align-items: flex-start; flex-direction: column; }
  .step-readout { align-self: stretch; justify-content: space-between; }
  .lab-grid { display: block; }
  .stage-panel, .explain-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  #motion-stage { min-height: 310px; }
  .inspect-panel { display: block; }
  .state-grid { border-right: 0; }
  .timeline-panel { grid-template-columns: 1fr; }
  .timeline-head { border-right: 0; border-bottom: 1px solid var(--line); }
  .controls { grid-template-columns: 1fr; }
  .control-buttons { justify-content: flex-start; }
  .keyboard-hint { grid-column: 1; }
  .related { grid-template-columns: 1fr; }
  .related a { border-left: 0; border-top: 1px solid var(--line); }
}

@media (max-width: 560px) {
  .site-header, main { width: min(100% - 24px, 1480px); }
  .site-header { display: block; }
  .site-header nav { margin-top: 14px; justify-content: flex-start; }
  .hero h1 { font-size: 40px; }
  .hero > p:last-child { font-size: 16px; }
  .scenario-tab { flex: 1 1 42%; }
  .stage-panel, .explain-panel { padding: 16px; }
  #motion-stage { min-height: 250px; }
  .state-grid { grid-template-columns: 1fr; }
  .state-grid > div, .state-grid > div:nth-child(even) { border-right: 0; }
  .state-grid .status-cell { grid-column: 1; }
  .notes { grid-template-columns: 1fr; }
}
