:root {
  --bg: #0b0d14;
  --bg-soft: #141826;
  --panel: rgba(20, 24, 38, 0.62);
  --panel-border: rgba(140, 170, 255, 0.18);
  --text: #e9edff;
  --text-dim: #9aa3c7;
  --accent: #6ea8ff;
  --accent-2: #b07bff;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  touch-action: none;
  cursor: crosshair;
  background:
    radial-gradient(1200px 800px at 78% 12%, rgba(110, 168, 255, 0.10), transparent 60%),
    radial-gradient(900px 700px at 12% 88%, rgba(176, 123, 255, 0.10), transparent 60%),
    var(--bg);
}

#panel {
  position: fixed;
  top: 18px;
  right: 18px;
  width: 268px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  padding: 18px 18px 20px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  z-index: 10;
}

.panel-head h1 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  letter-spacing: 0.2px;
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.panel-head h1 span {
  margin-left: 5px;
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  opacity: 0.92;
}

.hint {
  margin: 6px 0 2px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--text-dim);
}

#pp-controls {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* A control row created by PP.addControl(). */
.pp-control {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}
#pp-controls .pp-control:first-child { border-top: none; padding-top: 0; }

.pp-control .pp-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* Range row: label on the left, live value readout on the right. */
.pp-control-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.pp-value {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  opacity: 0.85;
}

/* Checkbox row: control sits inline with its label. */
.pp-control-inline { flex-direction: row; }
.pp-check {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.pp-check .pp-label { text-transform: none; letter-spacing: 0.2px; font-size: 13px; }
.pp-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Sensible defaults so feature controls look native without extra CSS. */
.pp-control input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.pp-control select,
.pp-control button {
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--panel-border);
  border-radius: 9px;
  padding: 7px 10px;
  cursor: pointer;
}
.pp-control button:hover,
.pp-control select:hover { background: rgba(110, 168, 255, 0.16); }
.pp-control button:active { transform: translateY(1px); }

.pp-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pp-row > * { flex: 1; }

#panel::-webkit-scrollbar { width: 8px; }
#panel::-webkit-scrollbar-thumb {
  background: rgba(140, 170, 255, 0.25);
  border-radius: 8px;
}

/* Drawer chrome: hidden on desktop, revealed in the mobile media query. */
#panel-toggle,
#panel-close { display: none; }

/* ---- Mobile: dock the panel to the bottom as a collapsible drawer ------- */
@media (max-width: 640px) {
  #panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    max-height: 66vh;
    border-radius: 18px 18px 0 0;
    border-bottom: none;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    transform: translateY(110%);
    transition: transform 0.28s ease;
    -webkit-overflow-scrolling: touch;
  }
  #panel.open { transform: translateY(0); }

  .panel-head { position: relative; padding-right: 44px; }

  /* Floating button that opens the drawer. */
  #panel-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 20;
    min-height: 48px;
    padding: 0 20px;
    font: inherit;
    font-weight: 600;
    color: var(--text);
    background: linear-gradient(92deg, rgba(110, 168, 255, 0.92), rgba(176, 123, 255, 0.92));
    border: 1px solid var(--panel-border);
    border-radius: 999px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    cursor: pointer;
  }
  body.panel-open #panel-toggle { display: none; }

  /* In-header close button for the drawer. */
  #panel-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: -2px;
    right: 0;
    width: 40px;
    height: 40px;
    font-size: 24px;
    line-height: 1;
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    cursor: pointer;
  }

  /* Tap-friendly targets (>=40px) on touch screens. */
  .pp-control select,
  .pp-control button { min-height: 44px; padding: 10px 12px; }
  .pp-control input[type="range"] { height: 28px; }
  .pp-check { min-height: 44px; }
  .pp-check input[type="checkbox"] { width: 22px; height: 22px; }
  #pp-controls { gap: 14px; }
}
