:root {
  --bg: #0a0c10;
  --fg: #e8ecf3;
  --muted: #8794a6;
  --line: rgba(255, 255, 255, 0.10);
  --panel: rgba(14, 17, 22, 0.78);
  --accent: #4a7bff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(120% 90% at 50% 8%, #1a2130 0%, #0b0e13 55%, #07090c 100%);
  color: var(--fg);
  font: 13px/1.5 -apple-system, "PingFang SC", "Noto Sans SC", "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#view:active { cursor: grabbing; }

.hud {
  position: fixed;
  z-index: 3;
  pointer-events: none;
}

.hud-top {
  top: max(16px, env(safe-area-inset-top));
  left: 20px;
  right: 20px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  letter-spacing: 0.02em;
}
.brand .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px 2px rgba(74, 123, 255, 0.7);
}
.brand .sep, .brand .muted { color: var(--muted); font-weight: 400; }

.hint { color: var(--muted); font-size: 12px; }

.presets {
  position: fixed;
  z-index: 3;
  top: max(48px, calc(env(safe-area-inset-top) + 34px));
  right: 20px;
  display: flex;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px;
  backdrop-filter: blur(10px);
}
.presets button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.presets button:hover { color: var(--fg); }
.presets button.active { background: rgba(74, 123, 255, 0.18); color: #cfe0ff; }

.panel {
  position: fixed;
  z-index: 3;
  right: 20px;
  bottom: max(20px, env(safe-area-inset-bottom));
  width: 224px;
  padding: 14px 14px 10px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}
.panel h2 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.row {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  color: #c3ccd9;
  font-size: 12px;
}
.row.switch { grid-template-columns: 1fr auto; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 18px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 3px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.16);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  margin-top: -4.5px;
  border-radius: 50%;
  background: #dce6ff;
  box-shadow: 0 0 0 3px rgba(74, 123, 255, 0.22);
}
input[type="range"]::-moz-range-track {
  height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.16);
}
input[type="range"]::-moz-range-thumb {
  width: 12px; height: 12px; border: 0; border-radius: 50%; background: #dce6ff;
}

input[type="checkbox"] {
  appearance: none;
  width: 34px; height: 19px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  position: relative;
  cursor: pointer;
  transition: background 0.18s;
}
input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2.5px; left: 2.5px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #e9eef8;
  transition: transform 0.18s;
}
input[type="checkbox"]:checked { background: rgba(74, 123, 255, 0.75); }
input[type="checkbox"]:checked::after { transform: translateX(15px); }

.reset {
  width: 100%;
  margin-top: 8px;
  padding: 7px 0;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: #c9d4e4;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.reset:hover { background: rgba(255, 255, 255, 0.08); }

.note {
  margin: 8px 0 2px;
  color: #6d7a8c;
  font-size: 11px;
  line-height: 1.45;
}

#loading {
  position: fixed;
  inset: 0;
  z-index: 9;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity 0.5s ease, visibility 0.5s;
}
body.ready #loading { opacity: 0; visibility: hidden; }
.loading-inner { width: 220px; text-align: center; color: var(--muted); }
.bar {
  height: 2px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px;
  overflow: hidden;
}
.bar i {
  display: block;
  height: 100%;
  width: 8%;
  background: linear-gradient(90deg, #4a7bff, #8fb4ff);
  transition: width 0.25s ease;
}
#loading-text { margin: 12px 0 0; font-size: 12px; }

@media (max-width: 720px) {
  .hint { display: none; }
  .presets { top: auto; bottom: max(20px, env(safe-area-inset-bottom)); right: 16px; }
  .panel {
    left: 12px; right: 12px; bottom: calc(max(20px, env(safe-area-inset-bottom)) + 44px);
    width: auto;
  }
  .presets { left: 12px; right: auto; }
  .presets { left: 12px; right: auto; }
}
