:root {
  --font: "Geist", ui-sans-serif, system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, monospace;
  --r-panel: 14px;
  --r-ctl: 10px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Themes: Glow follows the user's reference, Atlas is clinical, Slate is the designer pick */
[data-theme="glow"] {
  --bg: #07080a; --vignette: rgba(0, 0, 0, 0.55);
  --panel: rgba(17, 18, 21, 0.74); --panel-solid: #141518;
  --line: rgba(255, 255, 255, 0.08); --line-strong: rgba(255, 255, 255, 0.16);
  --text: #ede8e2; --muted: #a39d95; --faint: #6f6a64;
  --accent: #ff8a3d; --accent-ink: #1b0d03; --accent-soft: rgba(255, 138, 61, 0.14);
  --ok: #7fd3a0; --bad: #f28b82;
}
[data-theme="atlas"] {
  --bg: #e4e8ec; --vignette: rgba(120, 132, 146, 0.28);
  --panel: rgba(255, 255, 255, 0.84); --panel-solid: #ffffff;
  --line: rgba(22, 32, 44, 0.10); --line-strong: rgba(22, 32, 44, 0.20);
  --text: #18212b; --muted: #4f5b68; --faint: #7d8793;
  --accent: #b77d00; --accent-ink: #ffffff; --accent-soft: rgba(214, 160, 20, 0.16);
  --ok: #1e7a4c; --bad: #b3261e;
}
[data-theme="slate"] {
  --bg: #0d1116; --vignette: rgba(0, 0, 0, 0.5);
  --panel: rgba(19, 25, 32, 0.76); --panel-solid: #161c24;
  --line: rgba(220, 232, 245, 0.08); --line-strong: rgba(220, 232, 245, 0.16);
  --text: #e4e9ef; --muted: #96a2b0; --faint: #687584;
  --accent: #f2c14e; --accent-ink: #1d1503; --accent-soft: rgba(242, 193, 78, 0.14);
  --ok: #7fd3a0; --bad: #f28b82;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.4s var(--ease);
}
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse at 50% 45%, transparent 55%, var(--vignette) 100%);
}
#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; z-index: 0; touch-action: none; }
.mono { font-family: var(--mono); font-size: 12px; }
button, input { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line-strong); background: transparent; border-radius: var(--r-ctl);
  padding: 7px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: background-color 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.1s;
}
button:hover { background: var(--accent-soft); border-color: var(--accent); }
button:active { transform: scale(0.98); }
button:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button .ti { font-size: 16px; }
a { color: inherit; }

.panel {
  position: fixed; z-index: 2; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--r-panel); backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
}
@media (prefers-reduced-transparency: reduce) { .panel { background: var(--panel-solid); backdrop-filter: none; } }

.brand { position: fixed; z-index: 2; top: 18px; left: 20px; display: flex; flex-direction: column; pointer-events: none; }
.brand-name { font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
.brand-sub { color: var(--muted); font-size: 12.5px; }

.rail { top: 72px; left: 20px; width: 272px; padding: 16px; display: flex; flex-direction: column; gap: 18px; max-height: calc(100dvh - 160px); overflow: auto; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); padding: 0 10px; }
.search:focus-within { border-color: var(--accent); }
.search .ti { color: var(--muted); font-size: 16px; }
.search input { flex: 1; border: 0; background: transparent; padding: 8px 0; outline: none; min-width: 0; }
.search input::placeholder { color: var(--faint); }
.results { list-style: none; margin: -10px 0 0; padding: 4px; border: 1px solid var(--line); border-radius: var(--r-ctl); max-height: 260px; overflow: auto; }
.results li { padding: 6px 8px; border-radius: 7px; cursor: pointer; display: flex; justify-content: space-between; gap: 8px; }
.results li span:last-child { color: var(--faint); font-size: 12px; white-space: nowrap; }
.results li:hover, .results li[aria-selected="true"] { background: var(--accent-soft); }
.results .empty { color: var(--muted); cursor: default; }

.group { display: flex; flex-direction: column; gap: 8px; }
.layers { display: grid; gap: 2px; }
.layer { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer; user-select: none; }
.layer:hover { background: var(--accent-soft); }
.layer input { appearance: none; width: 30px; height: 18px; border-radius: 99px; background: var(--line-strong); position: relative; cursor: pointer; flex: none; margin: 0; transition: background-color 0.2s; }
.layer input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--text); transition: transform 0.2s var(--ease); }
.layer input:checked { background: var(--accent); }
.layer input:checked::after { transform: translateX(12px); background: var(--accent-ink); }
.layer .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.layer .count { margin-left: auto; color: var(--faint); font-family: var(--mono); font-size: 11.5px; }
.views { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.views button { justify-content: center; padding: 6px 0; font-size: 13px; }

.info { top: 20px; right: 20px; width: 340px; padding: 18px; max-height: calc(100dvh - 120px); overflow: auto; }
.info-empty { color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.info-empty .ti { font-size: 22px; color: var(--accent); }
.info-empty p { margin: 0; }
.info-empty .hint { font-size: 12.5px; color: var(--faint); }
.crumbs { display: flex; flex-wrap: wrap; gap: 2px 4px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.crumbs button { border: 0; padding: 1px 4px; border-radius: 5px; font-size: 12px; color: var(--muted); }
.crumbs button:hover { color: var(--text); }
.crumbs .sep { color: var(--faint); }
.info h2 { margin: 0 0 6px; font-size: 19px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.chip { font-size: 12px; padding: 2px 9px; border-radius: 99px; background: var(--accent-soft); color: var(--text); }
.chip.quiet { background: transparent; border: 1px solid var(--line-strong); color: var(--muted); }
.info p.summary { margin: 0 0 10px; }
.info ul { margin: 0; padding-left: 18px; color: var(--muted); }
.info li { margin-bottom: 4px; }
.info .actions { display: flex; gap: 8px; margin-top: 14px; flex-wrap: wrap; }

.dock { bottom: 20px; left: 50%; transform: translateX(-50%); padding: 6px; display: flex; gap: 6px; align-items: center; }
.seg { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: var(--r-ctl); }
.seg button { border-color: transparent; padding: 6px 11px; font-size: 13px; }
.seg button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.dock .icon { padding: 7px 9px; }
.dock .icon.on { background: var(--accent-soft); border-color: var(--accent); }

.quiz { bottom: 82px; left: 50%; transform: translateX(-50%); width: min(560px, calc(100vw - 32px)); padding: 16px; }
.quiz-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 12px; font-weight: 500; }
.quiz-head .mono { color: var(--muted); font-weight: 400; }
.quiz-options { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quiz-options button { justify-content: flex-start; text-align: left; padding: 10px 12px; }
.quiz-options button.ok { border-color: var(--ok); color: var(--ok); }
.quiz-options button.bad { border-color: var(--bad); color: var(--bad); }
.quiz-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 12px; min-height: 34px; color: var(--muted); }
.quiz-foot:empty { display: none; }

.tip { position: fixed; z-index: 3; pointer-events: none; padding: 5px 9px; border-radius: 8px; background: var(--panel-solid); border: 1px solid var(--line-strong); font-size: 12.5px; white-space: nowrap; transform: translate(14px, 14px); }

.loader { position: fixed; inset: 0; z-index: 4; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: var(--bg); transition: opacity 0.5s var(--ease); }
.loader.done { opacity: 0; visibility: hidden; pointer-events: none; transition: opacity 0.5s var(--ease), visibility 0s 0.5s; }
.loader-title { font-weight: 500; }
.bar { width: 220px; height: 3px; border-radius: 99px; background: var(--line-strong); overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.loader .mono { color: var(--muted); }
.loader.error .loader-title { color: var(--bad); }

.credit { position: fixed; z-index: 2; left: 20px; bottom: 16px; font-size: 11.5px; color: var(--faint); max-width: 300px; }

@media (max-width: 860px) {
  .brand { top: 12px; left: 14px; }
  .rail { top: 56px; left: 12px; right: 12px; width: auto; padding: 10px; gap: 10px; max-height: 40dvh; }
  .rail .group { display: none; }
  .info { top: auto; bottom: 74px; left: 12px; right: 12px; width: auto; max-height: 38dvh; }
  .quiz { bottom: 74px; }
  .dock { bottom: 12px; max-width: calc(100vw - 24px); overflow-x: auto; }
  .credit { display: none; }
  .quiz-options { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
