:root {
  color-scheme: light dark;
  --paper: #f5f3ed;
  --ink: #252c29;
  --muted: #5e665f;
  --line: #cccfc6;
  --surface: #e9ebe3;
  --accent: #a84022;
  --accent-soft: #f5e5dc;
  --good: #266147;
  --good-soft: #dfebe1;
  --error: #9a292e;
  --error-soft: #f4e0df;
  --button-ink: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #1c211f;
    --ink: #edece3;
    --muted: #b4beb3;
    --line: #49534c;
    --surface: #2b332e;
    --accent: #ed9c71;
    --accent-soft: #413024;
    --good: #a3d2b2;
    --good-soft: #223c2d;
    --error: #f1aaa9;
    --error-soft: #442c2e;
    --button-ink: #1c211f;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.75 -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif; }
button, input, select { font: inherit; color: inherit; }
button, select { cursor: pointer; }
button { padding: 8px 14px; min-height: 44px; background: transparent; border: 1px solid var(--line); border-radius: 3px; }
button:hover:not(:disabled) { background: var(--surface); }
button:disabled { opacity: .45; cursor: default; }
button.primary { color: var(--button-ink); background: var(--accent); border-color: var(--accent); }
button.primary:hover:not(:disabled) { filter: brightness(.92); background: var(--accent); }
button.quiet { border-color: transparent; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
a { color: var(--accent); }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(27px, 3.5vw, 42px); line-height: 1.45; letter-spacing: -.035em; margin-bottom: 16px; }
h2 { font-size: clamp(23px, 2.6vw, 30px); line-height: 1.5; letter-spacing: -.02em; margin-bottom: 0; }
h3 { font-size: 14px; font-weight: 600; margin-bottom: 16px; }
code, pre { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
code { font-size: .9em; overflow-wrap: anywhere; }
pre { padding: 20px; background: var(--surface); overflow-x: auto; line-height: 1.8; font-size: 14px; }
pre code { font-size: inherit; overflow-wrap: normal; }
label { display: block; font-size: 14px; font-weight: 600; }
input[type="text"], select { display: block; width: 100%; padding: 10px 12px; min-height: 44px; border: 1px solid var(--line); border-radius: 3px; background: var(--paper); font-size: 16px; }
.site-header { max-width: 1160px; margin: auto; padding: 24px 32px; display: flex; justify-content: space-between; gap: 20px; align-items: center; border-bottom: 1px solid var(--line); }
.wordmark { color: var(--ink); font-size: 15px; font-weight: 800; text-decoration: none; letter-spacing: .07em; white-space: nowrap; }
.wordmark span { font-weight: 500; color: var(--muted); }
.header-note { color: var(--muted); font-size: 12px; }
main { max-width: 1160px; margin: auto; padding: 48px 32px 24px; }
.intro { margin-bottom: 34px; }
.intro > p:last-child { color: var(--muted); max-width: 720px; margin-bottom: 0; }
.eyebrow { color: var(--accent); font-size: 11px; font-weight: 700; letter-spacing: .14em; margin-bottom: 12px; }
.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line); margin-bottom: 32px; }
.tabs button { border: 0; border-radius: 0; border-bottom: 3px solid transparent; padding: 12px 0; font-size: 15px; }
.tabs button[aria-selected="true"] { border-color: var(--accent); font-weight: 700; }
.tabs button span { color: var(--muted); margin-right: 6px; font: 12px "SFMono-Regular", monospace; }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 28px; margin-bottom: 28px; }
.section-heading .eyebrow { margin-bottom: 6px; }
.select-label { min-width: 204px; }
.select-label select { margin-top: 6px; }
.ownership-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 36px; }
.source-area { min-width: 0; }
.code-list { margin: 0 0 20px; padding: 12px 10px 12px 42px; background: var(--surface); min-height: 206px; }
.code-list li { font: 13px/1.8 "SFMono-Regular", Consolas, monospace; padding: 9px 8px; overflow-wrap: anywhere; }
.code-list li::marker { color: var(--muted); font-size: 11px; }
.code-list li.current { background: var(--accent-soft); border-left: 3px solid var(--accent); padding-left: 5px; }
.code-list li code { font-size: inherit; }
.step-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.step-label { color: var(--muted); font: 12px "SFMono-Regular", monospace; min-width: 36px; text-align: center; }
.diagram-area { min-width: 0; }
.memory-board { min-height: 206px; padding-top: 8px; }
.memory-header, .memory-columns { display: grid; grid-template-columns: minmax(90px, 1fr) 52px minmax(100px, 1fr); gap: 8px; align-items: center; }
.memory-header { font-size: 11px; color: var(--muted); margin-bottom: 12px; }
.variables-column, .edges-column, .data-column { display: flex; flex-direction: column; gap: 14px; }
.data-column { align-self: center; }
.edges-column .edge { min-height: 57px; display: flex; align-items: center; justify-content: center; font: 16px "SFMono-Regular", monospace; }
.variable, .data-node { border: 1px solid var(--line); padding: 10px 12px; min-height: 57px; }
.variable { background: var(--paper); }
.variable strong, .data-node strong { display: block; font-size: 14px; line-height: 1.5; }
.variable small, .data-node small { display: block; font-size: 11px; color: var(--muted); line-height: 1.6; }
.data-node { background: var(--good-soft); border-color: var(--good); }
.variable.invalid { border-style: dashed; }
.variable.invalid strong { text-decoration: line-through; color: var(--muted); }
.variable.reference { border-style: dashed; }
.variable.pending, .data-node.dropped { opacity: .6; }
.data-node.dropped { background: transparent; border-style: dashed; border-color: var(--line); }
.edge { color: var(--good); text-align: center; font-size: 24px; }
.edge.reference { font-size: 20px; }
.diagram-caption { color: var(--muted); font-size: 11px; margin-top: 16px; }
.observation { margin-top: 28px; padding: 18px 20px; background: var(--accent-soft); border-left: 3px solid var(--accent); }
.observation strong { display: block; font-size: 16px; margin-bottom: 4px; }
.observation p { font-size: 14px; margin: 0; }
.observation.error { background: var(--error-soft); border-color: var(--error); }
.observation.success { background: var(--good-soft); border-color: var(--good); }
.prediction { margin-top: 28px; }
.prediction h3 { margin-bottom: 6px; }
.prediction p { font-size: 14px; margin-bottom: 8px; }
details { margin-top: 14px; font-size: 14px; }
summary { cursor: pointer; padding: 8px 0; color: var(--accent); min-height: 44px; }
details p { margin: 8px 0 0; max-width: 740px; }
.run-note { margin: 26px 0 0; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.section-description { color: var(--muted); font-size: 15px; max-width: 750px; margin: 0 0 26px; }
.result-layout { display: grid; grid-template-columns: 1.25fr 1fr; gap: 48px; }
.result-layout > div { min-width: 0; }
.input-row { display: flex; gap: 10px; margin-top: 6px; }
.input-row input { flex: 1; min-width: 0; }
.input-row button { flex: none; }
.samples { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.samples button { font-size: 12px; padding: 6px 10px; }
.flow-diagram { padding: 2px 0; }
.flow-node { text-align: center; padding: 12px; border: 1px solid var(--line); font-size: 14px; }
.flow-node.inactive { opacity: .5; border-style: dashed; }
.flow-node.active { border-color: var(--good); background: var(--good-soft); }
.flow-node.failed { border-color: var(--error); background: var(--error-soft); }
.flow-arrow { text-align: center; color: var(--muted); padding: 2px; }
.flow-output { text-align: center; font: 700 20px/1.8 "SFMono-Regular", monospace; padding: 14px; color: var(--good); background: var(--good-soft); }
.flow-output.error { color: var(--error); background: var(--error-soft); }
.debug-controls { display: flex; align-items: center; gap: 40px; margin-bottom: 32px; }
.debug-controls label { width: 320px; max-width: 100%; }
.debug-controls strong { margin-left: 12px; color: var(--accent); }
.debug-controls p { margin: 16px 0 0; }
input[type="range"] { display: block; width: 100%; accent-color: var(--accent); margin: 12px 0; min-height: 32px; }
.array-cells { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.array-cell { border-top: 4px solid var(--line); padding: 16px 12px 12px; background: var(--surface); }
.array-cell.visited { border-color: var(--accent); background: var(--accent-soft); }
.array-cell.counted { border-color: var(--good); background: var(--good-soft); }
.array-cell .index { font: 12px "SFMono-Regular", monospace; color: var(--muted); }
.array-cell strong { display: block; font: 700 40px/1.5 "SFMono-Regular", monospace; margin: 8px 0; }
.array-cell small { display: block; font-size: 12px; }
.debug-summary { display: flex; gap: 40px; margin-top: 30px; }
.debug-summary p { font-size: 13px; margin: 0; }
.debug-summary strong { display: block; font: 700 30px/1.8 "SFMono-Regular", monospace; }
footer { border-top: 1px solid var(--line); padding-top: 20px; margin-top: 48px; font-size: 11px; color: var(--muted); }
[hidden] { display: none !important; }
@media (max-width: 800px) {
  .ownership-layout, .result-layout { grid-template-columns: 1fr; gap: 30px; }
  .memory-board { min-height: auto; }
  .code-list { min-height: auto; }
  .header-note { display: none; }
}
@media (max-width: 520px) {
  .site-header { padding: 20px; }
  main { padding: 28px 20px 20px; }
  .intro { margin-bottom: 24px; }
  .intro > p:last-child { font-size: 14px; }
  .tabs { gap: 18px; }
  .tabs button { font-size: 13px; }
  .tabs button span { display: none; }
  .section-heading { flex-direction: column; align-items: stretch; gap: 18px; }
  .array-cells { gap: 8px; }
  .array-cell { padding: 10px 6px; }
  .array-cell strong { font-size: 30px; }
  .array-cell small, .array-cell .index { font-size: 10px; }
  .debug-controls { flex-direction: column; align-items: stretch; gap: 0; }
  .step-controls { gap: 8px; }
  .step-controls button { padding-inline: 10px; font-size: 14px; }
  .observation { padding: 14px 16px; }
}
