:root {
  --bg-color: #0b0c10;
  --panel-bg: rgba(18, 20, 26, 0.85);
  --accent: #45a29e;
  --accent-hover: #66fcf1;
  --text-main: #c5c6c7;
  --text-muted: #888;
  --border: rgba(69, 162, 158, 0.3);
  --radius: 8px;
  --grid: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

body.embed-mode #main-header { display: none; }

#webgl-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

#ui-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  padding: calc(var(--grid) * 3);
}

#main-header, .controls-drawer, .readouts-panel {
  pointer-events: auto;
  background: var(--panel-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: calc(var(--grid) * 2);
  margin-bottom: calc(var(--grid) * 2);
}

#main-header { width: max-content; }
#main-header h1 { font-size: 1.2rem; font-weight: 600; color: #fff; }
.subtitle { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

.controls-drawer {
  width: 320px;
  max-height: 80vh;
  overflow-y: auto;
}

.readouts-panel {
  position: absolute;
  top: calc(var(--grid) * 3);
  right: calc(var(--grid) * 3);
  width: 280px;
}

.control-group { margin-bottom: calc(var(--grid) * 2); }
.control-group:last-child { margin-bottom: 0; }
.control-group h3 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 1px; color: var(--accent); margin-bottom: var(--grid); }

button {
  display: block;
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: var(--grid) calc(var(--grid) * 1.5);
  margin-bottom: var(--grid);
  border-radius: calc(var(--radius) / 2);
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: left;
  font-size: 0.9rem;
}

button:hover { background: rgba(69, 162, 158, 0.1); border-color: var(--accent); color: #fff; }
button.active { background: var(--accent); color: #000; font-weight: 600; }
button:focus-visible { outline: 2px solid var(--accent-hover); outline-offset: 2px; }

input[type="range"] {
  width: 100%;
  margin-bottom: calc(var(--grid) * 1.5);
  accent-color: var(--accent);
}

label { display: block; font-size: 0.8rem; margin-bottom: 4px; }

.readout { display: flex; justify-content: space-between; font-family: "Courier New", Courier, monospace; font-size: 0.95rem; margin-bottom: var(--grid); }
.readout .label { color: var(--text-muted); font-family: system-ui; font-size: 0.85rem; }
.readout .val { color: var(--accent-hover); font-weight: bold; }
hr { border: none; border-top: 1px solid var(--border); margin: calc(var(--grid)*2) 0; }

details { font-size: 0.8rem; line-height: 1.4; color: var(--text-muted); }
summary { cursor: pointer; color: var(--accent); margin-bottom: 8px; outline: none; }
summary:focus-visible { outline: 2px solid var(--accent); }

@media (max-width: 768px) {
  #ui-layer { padding: var(--grid); justify-content: space-between; }
  .controls-drawer, .readouts-panel { width: 100%; position: relative; top: auto; right: auto; margin-bottom: var(--grid); }
  .controls-drawer { order: 2; max-height: 40vh; }
  .readouts-panel { order: 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}