:root {
  color-scheme: dark;
  --bg: #06080c;
  --ink: #ece7dc;
  --muted: #9aa3ad;
  --line: rgba(236, 231, 220, 0.14);
  --glass: rgba(10, 13, 19, 0.72);
  --accent: #a9d6cc;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --pad: max(16px, env(safe-area-inset-left));
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--sans); overflow: hidden; }
.mono { font-family: var(--mono); }

#field { position: fixed; inset: 0; width: 100vw; height: 100vh; height: 100dvh; display: block; }

/* ---------- HUD ---------- */
.hud {
  position: fixed; top: 0; left: 0; right: 0;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: max(16px, env(safe-area-inset-top)) var(--pad) 32px;
  background: linear-gradient(to bottom, rgba(6, 8, 12, 0.55), rgba(6, 8, 12, 0));
  pointer-events: none;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
}
.hud > * { pointer-events: auto; }
.hud h1 { margin: 2px 0 0; font-size: 15px; font-weight: 600; letter-spacing: 0.01em; }
.hud p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.home { font-family: var(--mono); font-size: 11px; color: var(--muted); text-decoration: none; letter-spacing: 0.04em; }
.home:hover { color: var(--ink); }
.hud-right { display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); }

/* ---------- Buttons ---------- */
button, select {
  font: inherit; font-size: 13px; color: var(--ink);
  background: rgba(236, 231, 220, 0.06); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 14px; min-height: 36px; cursor: pointer;
}
button:hover, select:hover { border-color: rgba(236, 231, 220, 0.35); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ghost { background: var(--glass); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.small { padding: 4px 12px; min-height: 30px; font-size: 12px; }

/* ---------- Panel ---------- */
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: 340px; max-width: 100vw;
  padding: max(16px, env(safe-area-inset-top)) 20px 20px;
  background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-left: 1px solid var(--line);
  overflow-y: auto; overscroll-behavior: contain;
  transform: translateX(105%); transition: transform 0.28s ease;
}
.panel-open .panel { transform: none; }
.panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.panel section { padding: 14px 0; border-top: 1px solid var(--line); }
.label { display: block; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.panel-head .label { margin: 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.blurb { font-size: 13px; line-height: 1.5; color: var(--ink); margin: 12px 0 8px; }
.equation { font-family: var(--mono); font-size: 11.5px; line-height: 1.6; color: var(--accent); margin: 0; white-space: pre-wrap; }

.param { margin-bottom: 14px; }
.param-head { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 6px; }
.param-head output { font-family: var(--mono); color: var(--muted); }
input[type=range] { width: 100%; accent-color: var(--accent); height: 28px; margin: 0; }

.transport { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.transport .speed { margin-left: auto; }
.transport .speed .label { margin-bottom: 4px; }

.panel footer { font-size: 10.5px; color: var(--muted); padding-top: 12px; border-top: 1px solid var(--line); }

/* ---------- Phones: bottom sheet ---------- */
@media (max-width: 640px) {
  .hud h1 { font-size: 14px; }
  .panel {
    top: auto; left: 0; width: 100%; max-height: 62vh; max-height: 62dvh;
    border-left: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0;
    padding: 14px var(--pad) max(16px, env(safe-area-inset-bottom));
    transform: translateY(105%);
  }
}

@media (prefers-reduced-motion: reduce) { .panel { transition: none; } }
