:root {
  --bg: #eef1f0;
  --panel: #ffffff;
  --canvas: #f8faf9;
  --ink: #18211f;
  --muted: #5b6864;
  --line: #d5dcda;
  --accent: #1f5f8b;
  --accent-ink: #ffffff;
  --site-stroke: #18211f;
  --zone-alpha: 0.2;
  --font-display: "Literata", Georgia, "Times New Roman", serif;
  --font-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1413;
    --panel: #161c1b;
    --canvas: #121817;
    --ink: #e2e8e6;
    --muted: #93a19c;
    --line: #2a3331;
    --accent: #7db3da;
    --accent-ink: #0f1413;
    --site-stroke: #e2e8e6;
    --zone-alpha: 0.26;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1413;
  --panel: #161c1b;
  --canvas: #121817;
  --ink: #e2e8e6;
  --muted: #93a19c;
  --line: #2a3331;
  --accent: #7db3da;
  --accent-ink: #0f1413;
  --site-stroke: #e2e8e6;
  --zone-alpha: 0.26;
}

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--font-body);
}
.app {
  box-sizing: border-box;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
  padding: 16px;
}
.stage {
  position: relative;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--canvas);
  overflow: hidden;
}
#view { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.hint {
  position: absolute;
  left: 12px;
  bottom: 10px;
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
}
.readout {
  position: absolute;
  right: 12px;
  top: 10px;
  margin: 0;
  font: 12px/1.4 var(--font-mono);
  color: var(--muted);
  text-align: right;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
aside {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 18px 18px 22px;
}
h1 {
  margin: 0;
  font: 600 22px/1.2 var(--font-display);
  text-wrap: balance;
}
h2 {
  margin: 0 0 8px;
  font: 600 11px/1.3 var(--font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.lede { margin: 6px 0 0; color: var(--muted); }
section { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
label { display: flex; gap: 8px; align-items: center; }
select, button {
  font: inherit;
  color: var(--ink);
  background: var(--canvas);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 5px 9px;
}
button { cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
input[type="checkbox"] { accent-color: var(--accent); }
.level { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
dl.stats {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  margin: 0;
  font: 12.5px/1.5 var(--font-mono);
  font-variant-numeric: tabular-nums;
}
dl.stats dt { color: var(--muted); }
dl.stats dd { margin: 0; text-align: right; }
.skeleton { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.skeleton .zone { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--line);
  font: 11.5px/1.5 var(--font-mono);
}
.chip i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.chip.straight { border-style: dashed; }
.chip.open { color: var(--muted); }
.skeleton .owner { font: 600 12px/1.5 var(--font-mono); min-width: 2.6em; }
.legend { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12.5px; }
.legend svg { flex: none; }
.legend div { display: flex; gap: 8px; align-items: center; }
.note { margin: 0; color: var(--muted); font-size: 12.5px; }

@media (max-width: 640px) {
  .app { height: auto; grid-template-columns: 1fr; }
  .stage { height: 72vh; min-height: 360px; }
  aside { overflow: visible; }
}
