:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --soft: #f1f5f9;
  --node: #94a3b8;
  --accent: #2563eb;
  --block: #0f172a;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --card: #131a2c;
    --ink: #e5e9f2;
    --muted: #8a96ad;
    --line: #26304a;
    --soft: #1a2338;
    --node: #56627c;
    --accent: #60a5fa;
    --block: #f8fafc;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 0 20px 24px;
}
button { font: inherit; color: inherit; cursor: pointer; }

.top {
  max-width: 1280px; margin: 0 auto; padding: 24px 0 16px;
  display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap;
}
h1 { margin: 0; font-size: 24px; letter-spacing: -0.02em; }
.sub { margin: 4px 0 0; color: var(--muted); max-width: 70ch; }
.badge {
  border: 1px dashed var(--muted); color: var(--muted); border-radius: 999px;
  padding: 3px 10px; font-size: 12px; white-space: nowrap;
}

.layout {
  max-width: 1280px; margin: 0 auto;
  display: grid; grid-template-columns: minmax(0, 1fr) 450px; gap: 16px;
}
.bench { grid-column: 1 / -1; }
@media (max-width: 960px) { .layout { grid-template-columns: minmax(0, 1fr); } }

.card, .mapcard {
  min-width: 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px;
}
.side { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
h2 { margin: 0 0 10px; font-size: 15px; }
.label { margin: 0 0 6px; color: var(--muted); font-size: 12px; }
.note { color: var(--muted); margin: 10px 0 0; font-size: 13px; }
.note:empty { display: none; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; justify-content: space-between; margin-bottom: 10px; }
.seg { display: inline-flex; background: var(--soft); border-radius: 10px; padding: 3px; flex-wrap: wrap; }
.seg button {
  border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; color: var(--muted);
}
.seg button.on { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgb(0 0 0 / .12); font-weight: 600; }

.mapwrap { position: relative; }
#map { display: block; width: 100%; height: auto; touch-action: manipulation; }
.hint {
  position: absolute; left: 10px; top: 10px; pointer-events: none;
  background: var(--card); border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 10px; font-size: 12px; color: var(--muted);
}
.hint:empty { display: none; }

.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; color: var(--muted); font-size: 12px; margin-top: 8px; }
.legend .ramp { width: 70px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, #22c55e, #eab308, #ef4444); }
.legend .sep { width: 10px; }
.legend .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); opacity: .55; }
.legend .dash { width: 22px; border-top: 2.5px dashed var(--block); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line);
  background: transparent; border-radius: 999px; padding: 5px 12px;
}
.chip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.chip.on { border-color: currentColor; font-weight: 600; }

.buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.buttons button { border: 1px solid var(--line); background: var(--soft); border-radius: 8px; padding: 6px 12px; }
.buttons button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.buttons button:disabled { opacity: .5; cursor: default; }
.speed { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--muted); font-size: 12px; }
.speed input { flex: 1; accent-color: var(--accent); }

.tripline { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.tablewrap { overflow-x: auto; }
table.results { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.results th { text-align: right; font-weight: 500; color: var(--muted); font-size: 12px; padding: 4px 5px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.results td { text-align: right; padding: 7px 5px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.results th:first-child, .results td:first-child { text-align: left; }
.results tbody tr { cursor: pointer; }
.results tbody tr.on { background: var(--soft); }
.results .algo { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.results .algo i { width: 10px; height: 10px; border-radius: 50%; }
.results .bad { color: #dc2626; }
.results .good { color: #16a34a; }
.results .bar { display: inline-block; height: 6px; border-radius: 3px; margin-right: 6px; vertical-align: middle; opacity: .7; }

.benchhead { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; }
.benchhead .note { margin: 0; }
.findings { margin: 12px 0 0; padding-left: 18px; color: var(--ink); }
.findings li { margin: 3px 0; }

.foot { max-width: 1280px; margin: 16px auto 0; color: var(--muted); font-size: 12px; }

/* map */
.edge { stroke-linecap: round; }
.edge-hit { stroke: transparent; stroke-width: 14; }
.block-mode .edge-hit { cursor: pointer; }
.block-mode .edge-hit:hover + .edge { stroke-width: 6; }
.blocked { stroke: var(--block); stroke-width: 3; stroke-dasharray: 5 4; }
.node { fill: var(--node); }
.node-hit { fill: transparent; cursor: pointer; }
.block-mode .node-hit { cursor: default; }
.path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.pin circle { stroke: var(--card); stroke-width: 2.5; }
.pin text { fill: #fff; font-size: 11px; font-weight: 700; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.edge-hit { pointer-events: none; }
.block-mode .edge-hit { pointer-events: stroke; }
.block-mode .node-hit { pointer-events: none; }
