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

:root {
  --panel-bg: rgba(255, 255, 255, 0.86);
  --panel-fg: #1c1c1e;
  --panel-dim: #8a8a8e;
  --panel-line: rgba(0, 0, 0, 0.10);
  --panel-field: rgba(0, 0, 0, 0.045);
  --accent: #2f6fed;
  --thumb: #1c1c1e;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.18);
}

html, body { height: 100%; }

body {
  overflow: hidden;
  font-family: -apple-system, "SF Pro Text", "Helvetica Neue", Segoe UI, sans-serif;
  background: #111;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- panel ---------- */
#panel {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 320px;
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--panel-bg);
  color: var(--panel-fg);
  border: 1px solid var(--panel-line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 10;
}

#panel.dark {
  --panel-bg: rgba(24, 24, 28, 0.82);
  --panel-fg: #f2f2f4;
  --panel-dim: #97979d;
  --panel-line: rgba(255, 255, 255, 0.12);
  --panel-field: rgba(255, 255, 255, 0.07);
  --thumb: #f2f2f4;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
}

body.ui-hidden #panel,
body.ui-hidden #credit {
  opacity: 0;
  transform: translateX(12px);
  pointer-events: none;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--panel-line);
}

.panel-title h1 {
  font-size: 15px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 700;
}

.panel-title h1 span { font-weight: 300; color: var(--panel-dim); }

.tagline {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--panel-dim);
  margin-top: 2px;
}

.panel-actions { display: flex; gap: 6px; }

.icon-btn {
  width: 26px;
  height: 26px;
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  background: transparent;
  color: var(--panel-fg);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { background: var(--panel-field); }

/* ---------- preset bar ---------- */
#preset-bar {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--panel-line);
}

#preset-bar select { flex: 1; }

/* ---------- sections ---------- */
#sections {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 0 8px;
  scrollbar-width: thin;
}

details.sec { border-bottom: 1px solid var(--panel-line); }
details.sec:last-child { border-bottom: none; }

details.sec > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 16px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--panel-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::after { content: "+"; font-size: 13px; font-weight: 400; }
details.sec[open] > summary::after { content: "–"; }
details.sec > summary:hover { color: var(--panel-fg); }

.sec-body { padding: 2px 16px 14px; display: grid; gap: 11px; }

/* ---------- controls ---------- */
.ctl { display: grid; gap: 5px; }

.ctl-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--panel-dim);
}

.ctl-label output {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px;
  letter-spacing: 0;
  color: var(--panel-fg);
  font-variant-numeric: tabular-nums;
}

textarea, select, input[type="text"] {
  width: 100%;
  border: 1px solid var(--panel-line);
  border-radius: 9px;
  background: var(--panel-field);
  color: var(--panel-fg);
  font: 12.5px/1.45 -apple-system, "Helvetica Neue", sans-serif;
  padding: 8px 9px;
  outline: none;
}
textarea:focus, select:focus, input[type="text"]:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 52px; }

select { appearance: none; -webkit-appearance: none; cursor: pointer; padding-right: 24px;
  background-image: linear-gradient(45deg, transparent 50%, var(--panel-dim) 50%),
                    linear-gradient(135deg, var(--panel-dim) 50%, transparent 50%);
  background-position: calc(100% - 14px) 55%, calc(100% - 10px) 55%;
  background-size: 4px 4px;
  background-repeat: no-repeat;
}

/* sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--panel-line);
  border-radius: 2px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--thumb);
  border: none;
  transition: transform 0.12s ease;
}
input[type="range"]:hover::-webkit-slider-thumb { transform: scale(1.25); }
input[type="range"]::-moz-range-track { height: 2px; background: var(--panel-line); border-radius: 2px; }
input[type="range"]::-moz-range-thumb { width: 13px; height: 13px; border-radius: 50%; background: var(--thumb); border: none; }

/* toggles */
.ctl-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.ctl-toggle .ctl-label { text-transform: uppercase; }

.switch {
  position: relative;
  width: 34px;
  height: 19px;
  flex: none;
}
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; cursor: pointer; margin: 0; }
.switch .knob {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--panel-line);
  transition: background 0.15s ease;
}
.switch .knob::after {
  content: "";
  position: absolute;
  top: 2.5px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform 0.15s ease;
}
.switch input:checked + .knob { background: var(--accent); }
.switch input:checked + .knob::after { transform: translateX(14px); }

/* color inputs */
.color-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.color-item { display: grid; gap: 4px; }
.color-item .ctl-label { font-size: 9px; }
input[type="color"] {
  width: 100%;
  height: 30px;
  border: 1px solid var(--panel-line);
  border-radius: 9px;
  background: var(--panel-field);
  padding: 3px;
  cursor: pointer;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }

/* theme swatches */
.swatches { display: flex; flex-wrap: wrap; gap: 7px; }
.swatch {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid var(--panel-line);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  padding: 0;
}
.swatch:hover { transform: scale(1.1); }
.swatch i {
  position: absolute;
  left: 6px;
  right: 6px;
  height: 2.5px;
  border-radius: 2px;
}
.swatch i:nth-child(1) { top: 8px; }
.swatch i:nth-child(2) { top: 14px; opacity: 0.75; }
.swatch i:nth-child(3) { top: 20px; width: 12px; }

/* buttons */
.btn {
  border: 1px solid var(--panel-line);
  background: var(--panel-field);
  color: var(--panel-fg);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); color: #fff; }
.btn.recording { background: #d3382c; border-color: #d3382c; color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.65; } }

.btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn-grid .wide { grid-column: 1 / -1; }
.hint { font-size: 10.5px; line-height: 1.5; color: var(--panel-dim); }

.panel-foot {
  flex: none;
  padding: 8px 16px 10px;
  border-top: 1px solid var(--panel-line);
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--panel-dim);
  text-align: center;
}

/* ---------- floating bits ---------- */
.chip {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 9;
  border: 1px solid rgba(127,127,127,0.35);
  background: rgba(20,20,20,0.55);
  color: #fff;
  backdrop-filter: blur(10px);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}
body.ui-hidden .chip { opacity: 1; pointer-events: auto; }

#credit {
  position: fixed;
  left: 14px;
  bottom: 12px;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(127,127,127,0.85);
  z-index: 5;
  transition: opacity 0.25s ease;
}
#credit a { color: inherit; }

/* toasts */
#toasts {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  z-index: 20;
  pointer-events: none;
}
.toast {
  background: rgba(20, 20, 24, 0.92);
  color: #fff;
  font-size: 12px;
  padding: 9px 16px;
  border-radius: 999px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
  animation: toast-in 0.25s ease, toast-out 0.3s ease 2.4s forwards;
  max-width: min(80vw, 460px);
  text-align: center;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ---------- small screens ---------- */
@media (max-width: 560px) {
  #panel {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-height: 62vh;
    border-radius: 18px 18px 0 0;
  }
  body.ui-hidden #panel { transform: translateY(16px); }
  .chip { top: auto; bottom: 14px; }
}
