/* ==========================================================================
   Side control panel
   ========================================================================== */

#panel-tab {
  position: fixed;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 200;
  writing-mode: vertical-rl;
  background: rgba(8, 8, 14, 0.88);
  border: 1px solid rgba(255,255,255,0.14);
  border-left: none;
  border-radius: 0 10px 10px 0;
  color: rgba(255,255,255,0.55);
  font-size: 10px;
  font-family: system-ui, sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 14px 7px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: left 0.32s cubic-bezier(0.4,0,0.2,1), color 0.2s;
  user-select: none;
}

#panel-tab.open { left: 300px; color: #fff; }

/* Panel container */
#panel {
  position: fixed;
  left: 0; top: 0;
  width: 300px;
  height: 100%;
  background: rgba(8, 8, 14, 0.93);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-right: 1px solid rgba(255,255,255,0.09);
  z-index: 199;
  overflow-y: auto;
  overflow-x: hidden;
  transform: translateX(-100%);
  transition: transform 0.32s cubic-bezier(0.4,0,0.2,1);
  display: flex;
  flex-direction: column;
  padding-top: 16px;
  padding-bottom: 32px;
}

#panel.open { transform: translateX(0); }

/* Scrollbar */
#panel::-webkit-scrollbar { width: 3px; }
#panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.18); border-radius: 2px; }

/* Panel header */
.panel-head {
  padding: 10px 18px 16px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  letter-spacing: 0.06em;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

/* ---- Collapsible groups ------------------------------------------------- */
.pg {
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.pg > summary {
  padding: 12px 18px;
  cursor: pointer;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.45);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  transition: color 0.18s;
}

.pg > summary::-webkit-details-marker { display: none; }

.pg > summary::before {
  content: '▶';
  font-size: 7px;
  opacity: 0.45;
  transition: transform 0.2s, opacity 0.2s;
  flex-shrink: 0;
}

.pg[open] > summary { color: rgba(255,255,255,0.80); }
.pg[open] > summary::before { transform: rotate(90deg); opacity: 0.8; }

.pg-body {
  padding: 4px 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

/* ---- Control row -------------------------------------------------------- */
.crow {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 22px;
}

.clabel {
  font-size: 11px;
  color: rgba(255,255,255,0.40);
  min-width: 88px;
  flex-shrink: 0;
}

.cval {
  font-size: 10px;
  color: rgba(255,255,255,0.28);
  min-width: 30px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ---- Sliders ------------------------------------------------------------ */
.sl {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 3px;
  border-radius: 2px;
  background: rgba(255,255,255,0.14);
  outline: none;
  cursor: pointer;
}

.sl::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(120,180,255,0.85);
  cursor: pointer;
}

.sl::-moz-range-thumb {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid rgba(120,180,255,0.85);
  cursor: pointer;
  box-sizing: border-box;
}

/* ---- Button grid -------------------------------------------------------- */
.brow {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.pbtn {
  flex: 1;
  min-width: 0;
  padding: 6px 4px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.20);
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.60);
  font-size: 11px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
  text-align: center;
  user-select: none;
  white-space: nowrap;
}

.pbtn:hover  { background: rgba(255,255,255,0.12); color: #fff; }

.pbtn.active {
  background: rgba(255,255,255,0.20);
  border-color: rgba(255,255,255,0.70);
  color: #fff;
}

.pfile {
  display: block;
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.20);
  background: rgba(255,255,255,0.05);
  color: rgba(255,255,255,0.72);
  font-size: 11px;
  text-align: center;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
}

.pfile:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-color: rgba(255,255,255,0.34);
}

.pfile-compact {
  display: flex;
  align-items: center;
  justify-content: center;
  width: auto;
  flex: 1;
  padding: 6px 4px;
}

#audio-player {
  width: 100%;
  height: 30px;
  color-scheme: dark;
}

.input-status,
.input-help {
  font-size: 10px;
  line-height: 1.45;
  color: rgba(255,255,255,0.38);
}

.input-status.active { color: rgba(150,220,255,0.82); }

.input-meter {
  width: 100%;
  height: 4px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255,255,255,0.09);
}

.input-meter > span {
  display: block;
  width: 100%;
  height: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  border-radius: inherit;
  background: linear-gradient(90deg, #50b8ff, #a86cff, #ff6ab4);
  transition: transform 70ms linear;
}

/* Theme colour accents */
.pbtn.t-bw.active     { background:rgba(200,200,200,0.18); border-color:#ccc; }
.pbtn.t-earth.active  { background:rgba(150,90,30,0.35);   border-color:#c8884a; color:#ffd080; }
.pbtn.t-forest.active { background:rgba(20,100,20,0.35);   border-color:#4caf50; color:#a0f060; }
.pbtn.t-fire.active   { background:rgba(180,40,0,0.35);    border-color:#ff5020; color:#ffb060; }
.pbtn.t-water.active  { background:rgba(0,60,160,0.35);    border-color:#40a0ff; color:#80d0ff; }

.pbtn.t-bw     { color:rgba(200,200,200,0.65); }
.pbtn.t-earth  { color:rgba(220,165,90,0.75);  }
.pbtn.t-forest { color:rgba(90,195,70,0.75);   }
.pbtn.t-fire   { color:rgba(255,130,50,0.75);  }
.pbtn.t-water  { color:rgba(70,175,255,0.75);  }

/* ---- Dropdown ----------------------------------------------------------- */
.psel {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.20);
  border-radius: 10px;
  color: #fff;
  font-size: 11px;
  padding: 5px 26px 5px 10px;
  cursor: pointer;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='rgba(255,255,255,0.40)'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
}

.psel option { background: #12121e; }

.trail-swatches {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.trail-swatch {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 10px;
  height: 22px;
  padding: 0;
  cursor: pointer;
  background: var(--swatch);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06);
  transition: transform 0.16s, border-color 0.16s, box-shadow 0.16s;
}

.trail-swatch:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,0.42);
}

.trail-swatch.active {
  border-color: rgba(255,255,255,0.92);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.18), 0 0 10px rgba(255,255,255,0.14);
}

/* ---- Camera status ------------------------------------------------------ */
#panel-cam-status {
  font-size: 10.5px;
  color: rgba(255,255,255,0.42);
  min-height: 14px;
  line-height: 1.4;
}

/* ---- Reset button ------------------------------------------------------- */
#reset-btn {
  width: 100%;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(255,80,80,0.35);
  background: rgba(180,20,20,0.12);
  color: rgba(255,130,130,0.85);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.2s;
  letter-spacing: 0.04em;
}

#reset-btn:hover { background: rgba(180,20,20,0.26); }

#reset-btn.washing {
  border-color: rgba(255,80,80,0.7);
  animation: btnPulse 0.75s ease-in-out infinite;
}

@keyframes btnPulse {
  0%,100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

/* ---- Gesture HUD (bottom-centre) ---------------------------------------- */
#gesture-hud {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  font-size: 12px;
  font-family: system-ui, sans-serif;
  color: rgba(255,255,255,0.65);
  background: rgba(0,0,0,0.45);
  padding: 6px 18px;
  border-radius: 20px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  pointer-events: none;
  white-space: nowrap;
  transition: opacity 0.5s;
}

#gesture-hud.hide { opacity: 0; }

/* ---- 3-finger effect scroll indicator ----------------------------------- */
#fx-hud {
  position: fixed;
  right: 22px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 5px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s;
}

#fx-hud.show { opacity: 1; }

.fx-item {
  font-size: 11px;
  font-family: system-ui, sans-serif;
  color: rgba(255,255,255,0.30);
  text-align: right;
  padding: 3px 10px;
  border-radius: 10px;
  transition: color 0.2s, background 0.2s;
}

.fx-item.sel {
  color: #fff;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.25);
}

/* ---- Reset wash overlay ------------------------------------------------- */
#wash-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  opacity: 0;
  pointer-events: none;
  z-index: 150;
  transition: opacity 0.5s;
}

#wash-overlay.active { opacity: 0; animation: washIn 20s linear forwards; }

@keyframes washIn {
  0%   { opacity: 0; }
  80%  { opacity: 0.85; }
  100% { opacity: 0; }
}
