:root {
  --bg: #fafaf7;
  --surface: #ffffff;
  --stage: #ffffff;
  --fg: #16181d;
  --muted: #5d6370;
  --line: #e3e3dc;
  --polygon: #9aa0aa;
  --accent: #21918c;
  --accent-fg: #ffffff;
  --point: #16181d;
  --point-ring: #ffffff;
  --head: #fde725;
  --code-bg: #f2f2ec;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115;
    --surface: #171a20;
    --stage: #12151a;
    --fg: #e9eaee;
    --muted: #9ba1ad;
    --line: #2a2f38;
    --polygon: #5d6472;
    --accent: #35b779;
    --accent-fg: #0f1115;
    --point: #e9eaee;
    --point-ring: #12151a;
    --head: #fde725;
    --code-bg: #1d2128;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1115;
  --surface: #171a20;
  --stage: #12151a;
  --fg: #e9eaee;
  --muted: #9ba1ad;
  --line: #2a2f38;
  --polygon: #5d6472;
  --accent: #35b779;
  --accent-fg: #0f1115;
  --point: #e9eaee;
  --point-ring: #12151a;
  --head: #fde725;
  --code-bg: #1d2128;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--accent); }

var { font-style: italic; font-family: Georgia, "Times New Roman", serif; }

.top, main, footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 18px;
  padding-bottom: 6px;
}

.brand {
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.01em;
  color: var(--fg);
  text-decoration: none;
}

.top nav { display: flex; gap: 18px; }
.top nav a { color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.top nav a:hover { color: var(--fg); }

.intro { padding: 22px 0 14px; max-width: 720px; }
.intro h1 { font-size: clamp(1.6rem, 4vw, 2.3rem); line-height: 1.15; margin: 0 0 10px; letter-spacing: -0.02em; }
.intro p { margin: 0; color: var(--muted); }

.stage-wrap {
  background: var(--stage);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

#stage {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  max-height: 68vh;
  touch-action: none;
  cursor: crosshair;
  outline: none;
}
#stage:focus-visible { box-shadow: inset 0 0 0 3px var(--accent); }
#stage.over-point { cursor: grab; }
#stage.dragging { cursor: grabbing; }

.hint {
  margin: 0;
  padding: 8px 14px;
  font-size: 0.85rem;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.controls {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.group-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  min-width: 48px;
}

.spacer { flex: 1; }

button, select {
  font: inherit;
  font-size: 0.92rem;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover, select:hover { border-color: var(--polygon); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

button.primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
  min-width: 84px;
  font-weight: 600;
}

.t-control {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 260px;
}
.t-control span { white-space: nowrap; font-variant-numeric: tabular-nums; min-width: 72px; }
.t-control input { flex: 1; accent-color: var(--accent); }

.inline { display: flex; align-items: center; gap: 8px; font-size: 0.92rem; color: var(--muted); }

.check { display: flex; align-items: center; gap: 6px; font-size: 0.92rem; cursor: pointer; }
.check input { accent-color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { border-radius: 999px; padding: 4px 12px; }
.chips button[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); font-weight: 600; }

.readout {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.panels {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
  margin: 26px 0 10px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px 20px;
  min-width: 0;
}
.panel h2 { font-size: 1.05rem; margin: 0 0 8px; }
.panel p { margin: 0 0 10px; color: var(--muted); font-size: 0.95rem; }

.legend { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.85rem; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

.code { position: relative; }
.code pre {
  margin: 0;
  background: var(--code-bg);
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  font: 13px/1.5 ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
}
.copy { position: absolute; top: 8px; right: 8px; font-size: 0.8rem; padding: 3px 10px; }

.install code {
  font: 13px ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  background: var(--code-bg);
  padding: 3px 8px;
  border-radius: 6px;
}

footer { padding-top: 10px; padding-bottom: 30px; font-size: 0.88rem; color: var(--muted); }

@media (max-width: 560px) {
  .top nav { gap: 12px; }
  .group-label { min-width: 0; width: 100%; }
  .spacer { display: none; }
  #stage { aspect-ratio: 4 / 3.4; }
}
