:root {
  --bg: #14171c;
  --panel: rgba(22, 26, 33, 0.86);
  --panel-solid: #171b22;
  --fg: #e6e9ef;
  --muted: #9aa3b2;
  --accent: #7cc4ff;
  --p0: #e5484d;
  --p1: #3b82f6;
  --p2: #eab308;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); overflow: hidden; }
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
aside {
  position: fixed; top: 12px; padding: 14px 16px; background: var(--panel);
  border: 1px solid rgba(255,255,255,0.06); border-radius: 12px; backdrop-filter: blur(8px);
  max-height: calc(100% - 24px); overflow: auto; font-size: 14px;
}
#hud { left: 12px; min-width: 240px; max-width: 320px; }
h1 { font-size: 20px; margin: 0 0 8px; letter-spacing: 0.02em; }
.status { font-weight: 600; margin-bottom: 8px; min-height: 1.4em; }
.seats { display: grid; gap: 6px; margin-bottom: 10px; }
.seat { display: grid; grid-template-columns: 14px 1fr auto auto; gap: 8px; align-items: center; padding: 4px 6px; border-radius: 6px; }
.seat.active { background: rgba(255,255,255,0.08); outline: 1px solid rgba(255,255,255,0.15); }
.seat .bot { color: var(--muted); font-size: 12px; margin-left: 6px; }
.seat .clock { font-variant-numeric: tabular-nums; font-weight: 600; }
.seat .clock.low { color: #f87171; }
.swatch { width: 14px; height: 14px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0,0,0,0.4); }
.meter { color: var(--muted); font-variant-numeric: tabular-nums; }
.buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.controls-hint { color: var(--muted); font-size: 11px; line-height: 1.4; margin: 8px 0 0; }
button {
  background: #262c36; color: var(--fg); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px; padding: 6px 10px; cursor: pointer; font: inherit;
}
button:hover { background: #313949; }
button.primary { border-color: rgba(124,196,255,0.45); }
button[hidden] { display: none; }
.summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 12px; }

/* ---- settings dialog ---- */
dialog#settings {
  background: var(--panel-solid); color: var(--fg);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 14px; padding: 0;
  width: min(560px, calc(100% - 24px)); max-height: calc(100% - 24px);
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}
dialog#settings::backdrop { background: rgba(0,0,0,0.5); backdrop-filter: blur(3px); }
.settings-body { padding: 16px 20px 20px; display: grid; gap: 14px; font-size: 14px; }
.settings-body header { display: flex; justify-content: space-between; align-items: center; }
.settings-body header h2 { margin: 0; font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--fg); }
button.close { width: 32px; height: 32px; padding: 0; font-size: 20px; line-height: 1; border-radius: 50%; }
fieldset { border: 1px solid rgba(255,255,255,0.08); border-radius: 10px; padding: 10px 12px 4px; margin: 0; min-width: 0; }
legend { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: 0 6px; }
label { display: grid; grid-template-columns: 84px 1fr auto; gap: 8px; align-items: center; margin-bottom: 8px; }
label.check { grid-template-columns: auto 1fr; }
label[hidden] { display: none; }
label > span:first-child { color: var(--muted); }
label.check > span { color: var(--fg); }
select, input[type=range] { width: 100%; font: inherit; }
select { background: #1c2129; color: var(--fg); border: 1px solid rgba(255,255,255,0.1); border-radius: 6px; padding: 4px; }
output { min-width: 2ch; text-align: right; color: var(--muted); }
.readout { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 2px 0 8px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge.clean { background: #16391f; color: #8be59a; }
.badge.pinched { background: #3d2a12; color: #f3c56b; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.4; margin: -2px 0 10px; }
.hint.warn { color: #f3c56b; }

#toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: grid; gap: 6px; pointer-events: none; }
.toast { background: var(--panel); border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; padding: 8px 14px; animation: fade 3s forwards; }
@keyframes fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }
.nojs { position: fixed; inset: 0; display: grid; place-items: center; color: var(--fg); }
.home-link {
   position: fixed; top: 12px; right: 12px; z-index: 10;
   background: var(--panel); color: var(--fg); text-decoration: none;
   border: 1px solid rgba(255,255,255,0.1); border-radius: 8px;
   padding: 6px 12px; font-size: 13px; backdrop-filter: blur(8px);
}
.home-link:hover { background: #313949; }
@media (max-width: 720px) {
  #hud { min-width: 0; max-width: calc(100% - 24px); }
  label { grid-template-columns: 70px 1fr auto; }
}