/* ── P&P Soundboard — mobile first ── */
:root {
  --bg: #12141c;
  --bg2: #191c27;
  --card: #1f2330;
  --card-hi: #262b3b;
  --border: #323848;
  --text: #e8e6df;
  --text2: #a8aab5;
  --muted: #6b6f7e;
  --accent: #e0a838;
  --accent-dim: rgba(224, 168, 56, .14);
  --solo: #4db8c9;
  --danger: #d05555;
  --radius: 12px;
  --font-head: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --font-body: -apple-system, "Segoe UI", system-ui, sans-serif;
}

/* touch-action: manipulation unterbindet den Doppeltipp-Zoom auf iOS;
   Chips und Bühne überschreiben das mit touch-action: none fürs Ziehen. */
* { box-sizing: border-box; margin: 0; padding: 0; touch-action: manipulation; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  background:
    radial-gradient(1100px 500px at 50% -10%, #1d2233 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: flex;
  flex-direction: column;
}

/* ── Header: flach, Titel mittig ── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px 48px;
  border-bottom: 1px solid var(--border);
  background: rgba(18, 20, 28, .75);
  backdrop-filter: blur(8px);
}
.topbar h1 {
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .03em;
  color: var(--accent);
  white-space: nowrap;
}
.btn-icon {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  padding: 5px 9px;
  min-height: 0;
  font-size: .9rem;
  line-height: 1;
}

/* ── Layout ── */
main {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 10px 12px calc(14px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-label {
  font-size: .66rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  font-size: .76rem;
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  cursor: pointer;
}
.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1503;
  font-weight: 600;
}

/* ── Palette & Chips ── */
.palette {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.palette-empty {
  font-size: .75rem;
  color: var(--muted);
  font-style: italic;
  padding: 4px 2px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  background: linear-gradient(to bottom, var(--card-hi), var(--card));
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .82rem;
  font-family: var(--font-body);
  color: var(--text);
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .25);
  transition: border-color .15s, box-shadow .15s;
}
.chip:active { cursor: grabbing; }

/* Pegel-Balken: zeigen an, dass ein Sound wirklich spielt */
.eq {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}
.eq i {
  width: 3px;
  background: var(--accent);
  border-radius: 1px;
  animation: eqbar .9s ease-in-out infinite;
}
.eq i:nth-child(2) { animation-delay: .25s; }
.eq i:nth-child(3) { animation-delay: .5s; }
@keyframes eqbar {
  0%, 100% { height: 3px; }
  50% { height: 12px; }
}
.solo .eq i { background: var(--solo); }

/* ── Einmal-Sounds ── */
.oneshots {
  display: flex;
  align-items: center;
  gap: 10px;
}
.oneshot-list {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}
.oneshot-list::-webkit-scrollbar { display: none; }
.oneshot {
  flex: 0 0 auto;
  cursor: pointer;
  touch-action: manipulation;
  border-style: dashed;
}
.oneshot.flash {
  border-color: var(--accent);
  box-shadow: 0 0 14px rgba(224, 168, 56, .5);
}

/* ── Bühne ── */
.stage {
  position: relative;
  height: 42vh;
  min-height: 240px;
  max-height: 420px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background:
    repeating-linear-gradient(to bottom, transparent 0 24%, rgba(224, 168, 56, .045) 24% 25%),
    linear-gradient(to bottom, rgba(224, 168, 56, .02), rgba(224, 168, 56, .09)),
    var(--bg2);
  overflow: hidden;
  touch-action: none;
}
.stage-hint {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: .64rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  pointer-events: none;
}
.stage-hint-top { top: 7px; }
.stage-hint-bottom { bottom: 7px; }

.on-stage {
  position: absolute;
  background: var(--card-hi);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
}
.playing {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 0 18px rgba(224, 168, 56, .25);
}
.solo {
  border-color: var(--solo);
  box-shadow: 0 0 0 1px var(--solo), 0 0 18px rgba(77, 184, 201, .35);
}
.loading { opacity: .55; }
.loading::after {
  content: '…';
  color: var(--accent);
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: .3; }
  50% { opacity: 1; }
}
.badge-mp3 {
  font-size: .56rem;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--bg);
  background: var(--accent);
  border-radius: 4px;
  padding: 1px 4px;
}

.ghost {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  opacity: .85;
  background: var(--card-hi);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .5);
}

/* ── Steuerung ── */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}
.btn {
  font-family: var(--font-body);
  font-size: .82rem;
  padding: 9px 13px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
  min-height: 40px;
}
.btn:disabled { opacity: .4; cursor: default; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1503;
  font-weight: 600;
}
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.active { border-color: var(--accent); color: var(--accent); }
.btn-sm { font-size: .74rem; padding: 6px 11px; min-height: 32px; }

.vol {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 130px;
  justify-content: flex-end;
}
.vol input[type=range] {
  flex: 1;
  max-width: 180px;
  accent-color: var(--accent);
}

.btn.rec {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
  animation: pulse 1s infinite;
}

/* ── Mischpult ── */
.mixer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.mix-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.mix-row .section-label { width: 96px; flex: 0 0 auto; }
.mix-row input[type=range] {
  flex: 1;
  accent-color: var(--accent);
}

/* ── Musik ── */
.music {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.music-title {
  flex: 1;
  font-size: .74rem;
  color: var(--text2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 60px;
}
.music input[type=range] {
  width: 90px;
  accent-color: var(--accent);
}

/* ── Szenen & Vorlagen ── */
.scenes {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.scene-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.preset-select {
  flex: 1;
  min-width: 0;
  font-size: .78rem;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
}
.scene-slots {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  flex: 1;
}
.scene-btn {
  font-size: .74rem;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  cursor: pointer;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.scene-btn.filled { color: var(--text); border-color: var(--accent); }

/* ── Modal ── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: center;
  z-index: 200;
  padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.modal {
  width: 100%;
  max-width: 420px;
  max-height: 85dvh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.modal h3 {
  font-family: var(--font-head);
  font-size: 1rem;
  color: var(--accent);
  margin-bottom: 8px;
}
.modal p { font-size: .8rem; color: var(--text2); margin-bottom: 12px; }
.modal label {
  display: block;
  font-size: .72rem;
  color: var(--muted);
  margin: 10px 0 4px;
}
.modal label .mono { color: var(--text2); font-variant-numeric: tabular-nums; }
.modal input[type=text] {
  width: 100%;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
  font-size: .85rem;
}
.modal input[type=text]:focus { outline: 1px solid var(--accent); }
.modal input[type=range] {
  width: 100%;
  accent-color: var(--accent);
}
.modal .ip-select {
  width: 100%;
  font-size: .82rem;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text);
}
.modal .check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .78rem;
  color: var(--text2);
  text-transform: none;
  letter-spacing: 0;
  margin-top: 12px;
}
.modal .check-row input { accent-color: var(--accent); }
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

/* ── Größere Screens ── */
@media (min-width: 600px) {
  .topbar h1 { font-size: 1.1rem; }
  .chip { padding: 9px 15px; font-size: .88rem; }
  .stage { height: 360px; }
}
