:root {
  color-scheme: dark;
  --bg: #07172b;
  --surface: #10243d;
  --field: #0b2039;
  --ink: #f0f4fa;
  --muted: #c1cddd;
  --line: #4e6684;
  --accent: #c2d2eb;
  --signal: #ffb0bc;
  font-family: "Segoe UI", system-ui, sans-serif;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--accent); text-underline-offset: 0.24em; }
a:hover { color: var(--ink); }
button, select { font: inherit; }
button, select, .back, .tool-options label { min-height: 44px; }
button, select {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: var(--field);
}
button { padding: 0.5rem 0.85rem; font-weight: 650; cursor: pointer; }
select { padding: 0.45rem 0.5rem; }
button:hover:not(:disabled), select:hover:not(:disabled) { border-color: var(--accent); }
:is(a, button, select, input):focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
button:disabled, select:disabled { opacity: 0.6; cursor: default; }
[hidden] { display: none !important; }

.shell { width: min(1300px, calc(100% - 48px)); margin: 0 auto; }
.masthead { background: #081c36; border-bottom: 1px solid var(--line); }
.masthead-inner { display: flex; min-height: 56px; justify-content: space-between; align-items: center; gap: 0.5rem 1.2rem; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.9rem; font-weight: 650; }
.brand { color: var(--muted); font-size: 0.78rem; letter-spacing: 0.06em; }
.intro { padding: clamp(2rem, 4vw, 3rem) 0 1.6rem; }
.eyebrow { display: flex; gap: 0.65rem; flex-wrap: wrap; color: var(--accent); font-size: 0.78rem; font-weight: 720; letter-spacing: 0.11em; text-transform: uppercase; }
.eyebrow span:first-child { color: var(--signal); }
h1 { margin: 0.25rem 0 0.6rem; font-size: clamp(2rem, 5vw, 3.6rem); line-height: 1.05; letter-spacing: -0.04em; text-wrap: balance; }
.intro > p:last-child, .model > p { max-width: 69ch; margin: 0; color: var(--muted); }
.noscript { padding: 0.8rem 1rem; border-left: 3px solid var(--signal); background: var(--surface); }

.bench { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 320px); align-items: start; gap: 1rem; }
.panel { min-width: 0; border: 1px solid var(--line); border-top: 3px solid #a74357; border-radius: 5px; background: var(--surface); }
.stage { overflow: hidden; }
.stage-heading { display: flex; justify-content: space-between; align-items: center; gap: 0.8rem; padding: 0.75rem 1rem; }
h2 { margin: 0; font-size: 1.1rem; line-height: 1.3; }
.state { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--muted); font-size: 0.82rem; }
.state::before { content: ""; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--accent); }
.state[data-running="true"]::before { background: #a9ecc7; }
.rope-stage { display: block; width: 100%; height: auto; cursor: grab; touch-action: none; user-select: none; }
.rope-stage[data-tool="cut"] { cursor: crosshair; }
.rope-stage[data-dragging="true"] { cursor: grabbing; }
.anchor-bracket, .stage-floor { fill: none; stroke: #657e9e; stroke-width: 3; }
.stage-floor { stroke: #4e6684; stroke-dasharray: 10 8; }
.link { stroke: #9cbde6; stroke-width: 4; stroke-linecap: round; }
.link[data-selected="true"] { stroke: var(--signal); stroke-width: 7; }
.point { fill: #dce8fa; stroke: #0a1d36; stroke-width: 2; }
.point[data-selected="true"] { fill: var(--signal); stroke: #512238; stroke-width: 3; }
.pin { fill: #f0f4fa; stroke: #102e53; stroke-width: 3; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; border-top: 1px solid var(--line); }
.metrics > div { padding: 0.65rem 0.8rem; }
.metrics > div + div { border-inline-start: 1px solid var(--line); }
.metrics dt { color: var(--muted); font-size: 0.75rem; line-height: 1.35; }
.metrics dd { margin: 0.22rem 0 0; font-size: clamp(0.9rem, 2vw, 1.2rem); font-weight: 650; font-variant-numeric: tabular-nums; }

.controls { padding: 1rem; }
.transport, .nudges { display: grid; gap: 0.35rem; }
.transport { grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0.8rem 0 1rem; }
.primary { color: #07172b; background: var(--accent); border-color: var(--accent); }
.primary:hover:not(:disabled) { background: var(--ink); }
.setting { display: grid; gap: 0.35rem; color: var(--muted); font-size: 0.85rem; font-weight: 650; }
.setting select { width: 100%; font-weight: 600; }
.tools { min-width: 0; margin: 0.9rem 0 0; padding: 0; border: 0; }
.tools legend { padding: 0; color: var(--muted); font-size: 0.85rem; font-weight: 650; }
.tool-options { display: flex; flex-wrap: wrap; gap: 0.2rem 0.75rem; }
.tool-options label { display: inline-flex; align-items: center; gap: 0.38rem; cursor: pointer; font-size: 0.9rem; }
.tool-options input { width: 1rem; height: 1rem; margin: 0; accent-color: var(--accent); }
.hint { min-height: 2.6em; margin: 0 0 0.7rem; color: var(--muted); font-size: 0.82rem; line-height: 1.35; }
.nudges { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-top: 0.5rem; }
.nudges button { font-size: 1.1rem; padding-inline: 0.3rem; }
.cut-button { width: 100%; margin-top: 0.5rem; color: var(--signal); }
.notice { min-height: 1.35em; margin: 0.8rem 0 0; color: var(--accent); font-size: 0.8rem; }
.model { max-width: 69ch; margin: 2rem 0 3rem; border-top: 1px solid var(--line); padding-top: 0.6rem; }
.model h2 { margin-bottom: 0.5rem; font-size: 1.35rem; }
.model p.note { margin-top: 0.8rem; font-size: 0.9rem; }

@media (max-width: 800px) {
  .bench { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 420px) {
  .shell { width: calc(100% - 24px); }
  .masthead-inner { padding-bottom: 0.4rem; }
  .masthead-inner .brand { padding: 0.15rem 0; }
  .metrics > div { padding-inline: 0.42rem; }
}
