:root {
  --bg: #05070c;
  --panel: rgba(13, 17, 26, 0.62);
  --line: rgba(190, 220, 255, 0.10);
  --line-strong: rgba(190, 220, 255, 0.20);
  --text: #e9f1fb;
  --muted: #8a97ab;
  --accent: #7fe3ff;
  --accent-2: #ff4d78;
  --panel-w: 328px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background: var(--bg); overflow: hidden; }
body {
  font: 13px/1.4 "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
#gl { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
#gl.dragging { cursor: grabbing; }

#panel {
  position: fixed; top: 14px; right: 14px; bottom: 14px; width: var(--panel-w);
  display: flex; flex-direction: column; gap: 2px;
  padding: 18px 16px 12px;
  background: linear-gradient(180deg, rgba(24, 31, 46, 0.66), var(--panel));
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.07);
  -webkit-backdrop-filter: blur(26px) saturate(1.5);
  backdrop-filter: blur(26px) saturate(1.5);
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
  transition: transform 0.45s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s;
  z-index: 5;
}
body.panel-hidden #panel { transform: translateX(calc(100% + 24px)); opacity: 0; pointer-events: none; }

.panel-head { padding: 0 2px 12px; }
.panel-title { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 600; letter-spacing: 0.035em; }
.panel-title .mark {
  display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px;
  font-size: 15px; font-weight: 700; color: #04131b;
  background: linear-gradient(140deg, #d8f8ff, var(--accent) 55%, #5aa8ff);
  box-shadow: 0 0 18px rgba(127, 227, 255, 0.45);
}
.panel-sub { margin-top: 5px; color: var(--muted); font-size: 11.5px; letter-spacing: 0.02em; }

.sec { border-top: 1px solid var(--line); padding: 12px 2px 10px; }
.sec h2 {
  margin: 0; font-size: 10.5px; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted);
}
section.sec h2 { margin-bottom: 10px; }
.sec summary { display: flex; align-items: center; justify-content: space-between; cursor: pointer; list-style: none; padding: 1px 0; border-radius: 6px; }
.sec summary::-webkit-details-marker { display: none; }
.sec summary:hover h2 { color: var(--text); }
.chev { width: 7px; height: 7px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(-45deg); transition: transform 0.2s; margin-right: 4px; }
details[open] > summary .chev { transform: rotate(45deg); }
.sec-body { display: grid; gap: 11px; padding-top: 12px; }

.presets { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.chip {
  display: flex; align-items: center; gap: 8px; padding: 7px 9px; min-width: 0;
  font: inherit; font-size: 12.5px; color: var(--text); text-align: left;
  background: rgba(255, 255, 255, 0.035); border: 1px solid var(--line); border-radius: 11px;
  cursor: pointer; transition: background 0.2s, border-color 0.2s, transform 0.15s;
}
.chip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip:hover { background: rgba(255, 255, 255, 0.08); border-color: var(--line-strong); }
.chip:active { transform: scale(0.97); }
.chip[aria-pressed="true"] {
  background: linear-gradient(180deg, rgba(127, 227, 255, 0.20), rgba(127, 227, 255, 0.07));
  border-color: rgba(127, 227, 255, 0.55);
  box-shadow: 0 0 0 1px rgba(127, 227, 255, 0.12), 0 6px 20px rgba(60, 180, 255, 0.14);
}
.swatch { flex: none; width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35), inset -2px -3px 5px rgba(0, 0, 0, 0.25); }

.row { display: grid; gap: 5px; }
.row-top, .row-color, .row-toggle, .row-text, .row-segment { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.name { color: #c3cedd; }
.val { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 16px; margin: 0; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 4px;
  background: linear-gradient(90deg, var(--accent) 0, #5aa8ff var(--p, 0%), rgba(255, 255, 255, 0.11) var(--p, 0%));
}
input[type="range"]::-moz-range-track { height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.11); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px; border-radius: 50%;
  background: #f4fbff; border: 0; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5), 0 0 0 0 rgba(127, 227, 255, 0.35);
  transition: box-shadow 0.15s, transform 0.15s;
}
input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: #f4fbff; border: 0; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5); }
input[type="range"]:hover::-webkit-slider-thumb, input[type="range"]:active::-webkit-slider-thumb { box-shadow: 0 1px 6px rgba(0, 0, 0, 0.5), 0 0 0 6px rgba(127, 227, 255, 0.16); }
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.12); }

.color-wrap { display: flex; align-items: center; gap: 9px; }
input[type="color"] { -webkit-appearance: none; appearance: none; width: 34px; height: 22px; padding: 0; border: 1px solid var(--line-strong); border-radius: 7px; background: none; cursor: pointer; overflow: hidden; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: 0; }
input[type="color"]::-moz-color-swatch { border: 0; }

input[type="text"] {
  width: 150px; padding: 6px 9px; font: inherit; color: var(--text); letter-spacing: 0.03em;
  background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line); border-radius: 8px; outline: none;
}
input[type="text"]:focus { border-color: rgba(127, 227, 255, 0.6); box-shadow: 0 0 0 3px rgba(127, 227, 255, 0.12); }

.row-toggle { cursor: pointer; }
.row-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.switch { position: relative; flex: none; width: 34px; height: 20px; border-radius: 20px; background: rgba(255, 255, 255, 0.12); transition: background 0.2s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #f4fbff; box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5); transition: transform 0.22s cubic-bezier(0.3, 1.4, 0.5, 1); }
.row-toggle input:checked + .switch { background: linear-gradient(90deg, #4fb8ff, var(--accent)); }
.row-toggle input:checked + .switch::after { transform: translateX(14px); }
.row-toggle input:focus-visible + .switch, .chip:focus-visible, .segment button:focus-visible, .ghost:focus-visible, #panelToggle:focus-visible, .sec summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.segment { display: inline-flex; padding: 2px; gap: 2px; background: rgba(0, 0, 0, 0.28); border: 1px solid var(--line); border-radius: 9px; }
.segment button { font: inherit; font-size: 12px; color: var(--muted); padding: 4px 9px; border: 0; border-radius: 7px; background: transparent; cursor: pointer; transition: background 0.2s, color 0.2s; }
.segment button:hover { color: var(--text); }
.segment button[aria-pressed="true"] { color: #04131b; background: linear-gradient(180deg, #e6fbff, var(--accent)); font-weight: 600; }
.segment button:disabled { opacity: 0.35; cursor: not-allowed; }

.panel-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); padding: 12px 2px 2px; margin-top: auto; }
.ghost { font: inherit; font-size: 12px; color: var(--text); padding: 6px 13px; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line-strong); border-radius: 9px; cursor: pointer; }
.ghost:hover { background: rgba(255, 255, 255, 0.11); }
.hint { color: var(--muted); font-size: 10.5px; text-align: right; }

#panelToggle {
  position: fixed; top: 26px; right: 28px; z-index: 6; width: 34px; height: 34px;
  display: grid; place-content: center; gap: 4px; padding: 0;
  background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  transition: background 0.2s;
}
#panelToggle:hover { background: rgba(255, 255, 255, 0.12); }
#panelToggle span { display: block; width: 14px; height: 1.5px; border-radius: 2px; background: var(--text); transition: transform 0.3s, opacity 0.2s; }
body:not(.panel-hidden) #panelToggle span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
body:not(.panel-hidden) #panelToggle span:nth-child(2) { opacity: 0; }
body:not(.panel-hidden) #panelToggle span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }

#hud {
  position: fixed; left: 18px; bottom: 16px; z-index: 4; pointer-events: none;
  font-size: 11px; letter-spacing: 0.05em; color: rgba(200, 215, 235, 0.55); font-variant-numeric: tabular-nums;
}
#fallback { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; padding: 24px; background: var(--bg); z-index: 10; }
#fallback[hidden] { display: none; }
#fallback h1 { font-size: 20px; margin: 0 0 8px; }
#fallback p { color: var(--muted); margin: 0; }
body.no-ui #panel, body.no-ui #panelToggle, body.no-ui #hud { display: none; }

@media (max-width: 760px) {
  #panel { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 52vh; border-radius: 18px; }
  body.panel-hidden #panel { transform: translateY(calc(100% + 24px)); }
  #panelToggle { top: 12px; right: 12px; }
  #hud { top: 16px; bottom: auto; left: 14px; }
  .hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  #panel, .chip, .switch::after { transition: none; }
}
