:root {
  --bg: #eef1f4;
  --panel: rgba(255, 255, 255, 0.92);
  --ink: #1d232b;
  --muted: #5d6773;
  --line: #d9dee4;
  --accent: #2f6fdd;
  --accent-ink: #fff;
  --keep: #cfcac0;
  --demo: #d64541;
  --new: #2e9e5b;
  --radius: 10px;
  --shadow: 0 6px 24px rgba(20, 30, 45, 0.14);
  font: 13px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; }

button {
  font: inherit; color: inherit; cursor: pointer;
  border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 5px 9px;
}
button:hover { border-color: #b9c1ca; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button:disabled { opacity: 0.45; cursor: default; }
kbd {
  font: 11px ui-monospace, SFMono-Regular, Menlo, monospace;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px;
  padding: 0 4px; background: #fafbfc;
}

/* ---- panel ------------------------------------------------------------ */
.panel {
  position: fixed; top: 12px; left: 12px; bottom: 12px; width: 268px;
  background: var(--panel); backdrop-filter: blur(8px);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 14px 10px; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.panel.collapsed { transform: translateX(calc(-100% - 20px)); opacity: 0; pointer-events: none; }
.panel-toggle {
  position: fixed; top: 12px; left: 12px; z-index: 3; width: 34px; height: 34px; padding: 0;
  display: none; box-shadow: var(--shadow); font-size: 16px;
}
.panel-head h1 { font-size: 16px; margin: 0; letter-spacing: 0.01em; }
.panel-head .sub { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.panel-head { padding-left: 0; }
.panel section h2 {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin: 0 0 6px;
}
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { flex: 1; border: 0; border-radius: 0; padding: 6px 4px; background: transparent; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-checked="true"] { background: var(--accent); color: var(--accent-ink); }
.row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.row.btns button { flex: 1; }
.toggle { cursor: pointer; user-select: none; }
.toggle.small { font-size: 12px; color: var(--muted); margin-top: 0; }
.slider input { flex: 1; accent-color: var(--accent); }
.slider output { width: 44px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.slider.disabled { opacity: 0.4; pointer-events: none; }
.cats { display: grid; grid-template-columns: 1fr; gap: 3px; }
.cats label { display: flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.legend { display: flex; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.sw { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }
.sw.keep { background: var(--keep); }
.sw.demo { background: var(--demo); opacity: 0.7; }
.sw.new { background: var(--new); }
.panel-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 10px; }
.panel-foot details { margin-top: 6px; color: var(--muted); font-size: 12px; }
.panel-foot summary { cursor: pointer; }
.help { padding-left: 16px; margin: 6px 0 0; }
.help li { margin-bottom: 4px; }

/* ---- overlays ----------------------------------------------------------- */
.compass {
  position: fixed; top: 14px; right: 14px; width: 52px; height: 52px;
  background: var(--panel); border-radius: 50%; box-shadow: var(--shadow);
}
.compass svg { width: 100%; height: 100%; }
.compass .ring { fill: none; stroke: var(--line); stroke-width: 1.5; }
.compass .n { fill: var(--demo); }
.compass .nlabel { font: 700 7px sans-serif; fill: #fff; text-anchor: middle; dominant-baseline: middle; }

.info {
  position: fixed; right: 14px; bottom: 14px; width: 300px; max-width: calc(100vw - 28px);
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 12px 14px;
}
.info h3 { margin: 0 24px 6px 0; font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; word-break: break-all; }
.info dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; }
.info dt { color: var(--muted); }
.info dd { margin: 0; font-variant-numeric: tabular-nums; }
.info .x { position: absolute; top: 6px; right: 6px; border: 0; background: transparent; font-size: 18px; line-height: 1; padding: 4px 8px; }
.pill { display: inline-block; padding: 0 7px; border-radius: 999px; font-size: 11px; color: #fff; }
.pill.keep { background: #8a8478; } .pill.demo { background: var(--demo); } .pill.new { background: var(--new); }

.walk-hint {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  background: rgba(20, 26, 34, 0.82); color: #fff; padding: 8px 14px; border-radius: 999px;
  font-size: 12px; white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis;
}
.walk-hint kbd { background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.25); color: #fff; }

.toast {
  position: fixed; left: 50%; top: 14px; transform: translateX(-50%);
  background: rgba(20, 26, 34, 0.88); color: #fff; padding: 7px 14px; border-radius: 8px; font-size: 12px;
  max-width: calc(100vw - 32px);
}
.toast.error { background: #a8322f; }

/* ---- small screens ------------------------------------------------------ */
@media (max-width: 720px) {
  .panel-toggle { display: block; }
  .panel { top: 56px; left: 8px; right: 8px; width: auto; bottom: auto; max-height: calc(100vh - 64px); }
  .info { left: 8px; right: 8px; bottom: 8px; width: auto; }
  .compass { top: 12px; right: 12px; width: 42px; height: 42px; }
}
