:root {
  --ink: #eaf3f5;
  --muted: #9bb3ba;
  --glass: rgba(10, 22, 30, 0.58);
  --glass-strong: rgba(8, 18, 25, 0.82);
  --line: rgba(190, 230, 235, 0.14);
  --accent: #7fe0d0;
  --accent-ink: #062a27;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #0b1a24; color: var(--ink); overflow: hidden; }
body { font: 13px/1.45 Inter, system-ui, -apple-system, Segoe UI, sans-serif; -webkit-font-smoothing: antialiased; }
canvas#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
canvas#view:active { cursor: grabbing; }

.brand { position: fixed; left: 22px; top: 18px; pointer-events: none; text-shadow: 0 1px 12px rgba(0, 0, 0, 0.35); }
.brand h1 { font: 600 30px/1 Fraunces, Georgia, serif; letter-spacing: -0.01em; margin: 0; }
.brand p { margin: 4px 0 0; color: rgba(234, 243, 245, 0.78); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; }

.chip {
  appearance: none; border: 1px solid var(--line); background: var(--glass); color: var(--ink);
  font: 500 12px Inter, system-ui, sans-serif; padding: 7px 11px; border-radius: 999px; cursor: pointer;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); transition: background 0.15s, border-color 0.15s;
}
.chip:hover { border-color: rgba(190, 230, 235, 0.35); }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
kbd { font: 500 10px Inter, sans-serif; opacity: 0.6; margin-left: 4px; }

#panel-toggle { position: fixed; right: 18px; top: 18px; z-index: 3; display: none; }
#panel {
  position: fixed; right: 16px; top: 16px; bottom: 16px; width: 300px; overflow-y: auto; overscroll-behavior: contain;
  padding: 14px 16px 16px; border-radius: 16px; background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2); z-index: 2;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.group h2 { font: 600 11px Inter, sans-serif; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin: 16px 0 6px; }
.ctl { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 2px 8px; margin: 7px 0; }
.ctl label { color: var(--ink); }
.ctl output { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.ctl input[type=range] { grid-column: 1 / -1; width: 100%; margin: 2px 0 0; accent-color: var(--accent); height: 18px; }
.ctl select { grid-column: 2; background: rgba(255, 255, 255, 0.06); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; padding: 4px 6px; font: 12px Inter, sans-serif; }
.ctl select option { background: #10222c; }
.row-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }

#about { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
#about summary { cursor: pointer; color: var(--accent); font-weight: 500; }
#about ul { padding-left: 16px; margin: 8px 0 0; color: #cfe0e4; }
#about li { margin: 0 0 8px; }
#about b { color: var(--ink); }

#views { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; max-width: calc(100vw - 360px); }
#hud { position: fixed; left: 22px; bottom: 20px; color: rgba(234, 243, 245, 0.8); font-size: 11px; font-variant-numeric: tabular-nums; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.5); pointer-events: none; line-height: 1.6; }
#hint { position: fixed; left: 22px; top: 82px; color: rgba(234, 243, 245, 0.72); font-size: 11.5px; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.45); pointer-events: none; transition: opacity 1.2s; }

body.hide-ui #panel, body.hide-ui #views, body.hide-ui #hud, body.hide-ui #hint, body.hide-ui .brand, body.hide-ui #panel-toggle { opacity: 0; pointer-events: none; }
#panel, #views, #hud, .brand { transition: opacity 0.3s; }

#loader { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(ellipse at 50% 120%, #1d4b57 0%, #0b1a24 60%); z-index: 10; transition: opacity 0.8s; }
#loader.done { opacity: 0; pointer-events: none; }
.loader-inner { text-align: center; }
.loader-title { font: 600 40px Fraunces, Georgia, serif; letter-spacing: -0.01em; }
.loader-bar { width: 220px; height: 2px; background: rgba(255, 255, 255, 0.12); margin: 18px auto 10px; overflow: hidden; border-radius: 2px; }
.loader-bar span { display: block; height: 100%; width: 40%; background: var(--accent); animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.loader-msg { color: var(--muted); font-size: 12px; letter-spacing: 0.04em; }
#error { position: fixed; inset: 0; display: grid; place-items: center; background: #0b1a24; z-index: 20; padding: 24px; text-align: center; white-space: pre-wrap; color: #ffd0c8; font: 12px/1.5 ui-monospace, monospace; }
#error[hidden] { display: none; }

@media (max-width: 760px) {
  #panel-toggle { display: block; }
  #panel { top: auto; bottom: 0; right: 0; left: 0; width: auto; max-height: 56vh; border-radius: 16px 16px 0 0; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  #panel.closed { transform: translateY(105%); }
  #panel { transition: transform 0.3s, opacity 0.3s; }
  #views { bottom: auto; top: 64px; left: 16px; right: 16px; transform: none; max-width: none; justify-content: flex-start; }
  .brand { left: 16px; top: 14px; }
  .brand h1 { font-size: 24px; }
  .brand p { display: none; }
  #hint { display: none; }
  #hud { display: none; }
}
@media (prefers-reduced-motion: reduce) { .loader-bar span { animation: none; } }
