/* Sound-Board — Party-Look, Pink #db2777 + Neon. Eigenes Design. */
:root {
  --pink: #db2777;
  --pink-bright: #ff3ea5;
  --cyan: #22d3ee;
  --lime: #a3e635;
  --violet: #a855f7;
  --amber: #fbbf24;
  --orange: #fb7185;
  --space-sm: 8px;
  --space: 14px;
  --radius: 18px;
  --radius-sm: 12px;
  --tap: 56px;
  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* Dunkelmodus (Default) */
[data-theme="dark"] {
  --bg: #160a18;
  --bg-2: #221033;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-2: rgba(255, 255, 255, 0.1);
  --text: #fdf2f8;
  --text-dim: #d8b4e8;
  --border: rgba(255, 255, 255, 0.14);
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  --bar: rgba(22, 10, 24, 0.85);
}

/* Hellmodus */
[data-theme="light"] {
  --bg: #fff1f8;
  --bg-2: #ffe4f3;
  --surface: rgba(219, 39, 119, 0.06);
  --surface-2: rgba(219, 39, 119, 0.12);
  --text: #3b0a2c;
  --text-dim: #8a3a6b;
  --border: rgba(219, 39, 119, 0.22);
  --shadow: 0 10px 28px rgba(219, 39, 119, 0.18);
  --bar: rgba(255, 241, 248, 0.9);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(168, 85, 247, 0.22), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(34, 211, 238, 0.18), transparent 55%),
    linear-gradient(160deg, var(--bg), var(--bg-2));
  background-attachment: fixed;
  min-height: 100dvh;
  padding:
    env(safe-area-inset-top) env(safe-area-inset-right)
    env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-x: hidden;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--pink);
  color: #fff;
  padding: 10px 14px;
  border-radius: 10px;
  z-index: 100;
}
.skip-link:focus { left: 8px; }

/* App-Bar */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
  background: var(--bar);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--pink-bright), var(--violet));
  box-shadow: 0 0 18px rgba(255, 62, 165, 0.55);
}
.brand-text {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.5px;
  background: linear-gradient(90deg, var(--pink-bright), var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}
.app-bar-actions { display: flex; gap: 8px; }

.icon-btn {
  display: grid;
  place-items: center;
  width: var(--tap); height: 44px;
  min-width: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.18s ease;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(0.94); }
.ico-sun { display: none; }
[data-theme="light"] .ico-moon { display: none; }
[data-theme="light"] .ico-sun { display: block; }

main {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 40px;
}

/* Master-Panel */
.master-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.master-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.vol-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  white-space: nowrap;
}
.vol-ico { display: grid; place-items: center; color: var(--pink-bright); }
.vol-value {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--cyan);
  min-width: 3.2ch;
  text-align: right;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1 1 160px;
  min-width: 120px;
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--pink-bright), var(--violet), var(--cyan));
  outline: none;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--pink-bright);
  box-shadow: 0 0 12px rgba(255, 62, 165, 0.7);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--pink-bright);
  box-shadow: 0 0 12px rgba(255, 62, 165, 0.7);
  cursor: pointer;
}
input[type="range"]:focus-visible { box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.6); }

.chip-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 16px;
  font-weight: 700;
  cursor: pointer;
  min-height: 40px;
  transition: background 0.18s ease, transform 0.1s ease;
}
.chip-btn:hover { background: var(--surface-2); }
.chip-btn:active { transform: scale(0.95); }
.chip-btn[aria-pressed="true"] {
  background: var(--pink);
  border-color: var(--pink);
  color: #fff;
}

.hint {
  margin: 12px 0 0;
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.45;
}
.hint.warn {
  color: var(--amber);
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

/* Grid mit Klang-Kacheln */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}
.pad {
  position: relative;
  border: none;
  border-radius: var(--radius);
  padding: 18px 12px;
  min-height: 116px;
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-align: center;
  font-family: var(--font);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.08s ease, filter 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}
.pad::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120px 80px at 50% 0%, rgba(255, 255, 255, 0.35), transparent 70%);
  opacity: 0.5;
  pointer-events: none;
}
.pad:hover { filter: brightness(1.08); }
.pad:active { transform: scale(0.95); }
.pad.is-playing { animation: pulse 0.5s ease; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.7), var(--shadow); }
  100% { box-shadow: 0 0 0 16px rgba(255, 255, 255, 0), var(--shadow); }
}
.pad-emoji { font-size: 2.1rem; line-height: 1; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.35)); }
.pad-label {
  font-weight: 800;
  font-size: 0.98rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  word-break: break-word;
  overflow-wrap: anywhere;
}
.pad-key {
  position: absolute;
  top: 8px; left: 8px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: 8px;
  padding: 2px 7px;
}
.pad-del {
  position: absolute;
  top: 6px; right: 6px;
  width: 28px; height: 28px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
}
.pad-del:hover { background: rgba(0, 0, 0, 0.6); }

/* Farb-Themen der Kacheln (Party) */
.c-pink { background: linear-gradient(150deg, #ff3ea5, #db2777); }
.c-violet { background: linear-gradient(150deg, #c084fc, #7c3aed); }
.c-cyan { background: linear-gradient(150deg, #2dd4ff, #0891b2); }
.c-lime { background: linear-gradient(150deg, #bef264, #65a30d); color: #1a2e05; }
.c-amber { background: linear-gradient(150deg, #fcd34d, #f59e0b); color: #3a2400; }
.c-orange { background: linear-gradient(150deg, #fb7185, #e11d48); }
.c-blue { background: linear-gradient(150deg, #818cf8, #4f46e5); }
.c-teal { background: linear-gradient(150deg, #5eead4, #0d9488); color: #04201c; }
.c-rec { background: linear-gradient(150deg, #f0abfc, #c026d3); }
.c-lime .pad-label, .c-amber .pad-label, .c-teal .pad-label { text-shadow: none; }

/* Aufnahme-Panel */
.rec-panel {
  margin-top: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.rec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.rec-head h2 { margin: 0; font-size: 1.1rem; }
.rec-status { margin: 10px 0 0; color: var(--text-dim); min-height: 1.2em; font-size: 0.9rem; }

.primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  border: none;
  border-radius: 999px;
  padding: 11px 20px;
  font-weight: 800;
  font-size: 0.95rem;
  color: #fff;
  background: linear-gradient(135deg, var(--pink-bright), var(--violet));
  cursor: pointer;
  min-height: 44px;
  box-shadow: 0 6px 16px rgba(219, 39, 119, 0.4);
  transition: transform 0.1s ease, filter 0.18s ease;
}
.primary-btn:hover { filter: brightness(1.08); }
.primary-btn:active { transform: scale(0.96); }
.rec-dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.6);
}
.primary-btn.recording { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.primary-btn.recording .rec-dot { animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

.ghost-btn, .danger-btn {
  border-radius: 999px;
  padding: 11px 18px;
  font-weight: 800;
  cursor: pointer;
  min-height: 44px;
  border: 1px solid var(--border);
  transition: transform 0.1s ease, filter 0.18s ease;
}
.ghost-btn { background: var(--surface); color: var(--text); }
.ghost-btn:hover { background: var(--surface-2); }
.danger-btn { background: linear-gradient(135deg, #ef4444, #b91c1c); color: #fff; border: none; }
.ghost-btn:active, .danger-btn:active { transform: scale(0.96); }

.foot {
  margin-top: 26px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(8, 4, 12, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(160deg, var(--bg-2), var(--bg));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.modal h3 { margin: 0 0 12px; font-size: 1.2rem; }
.modal-text { margin: 0 0 16px; color: var(--text-dim); }
.field-label { display: block; font-weight: 700; margin-bottom: 6px; font-size: 0.9rem; }
.modal input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1rem;
  font-family: var(--font);
}
.modal input[type="text"]:focus-visible {
  outline: none;
  border-color: var(--pink-bright);
  box-shadow: 0 0 0 3px rgba(255, 62, 165, 0.35);
}
.emoji-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0 4px;
}
.emoji-pick {
  width: 44px; height: 44px;
  font-size: 1.4rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  cursor: pointer;
  transition: transform 0.1s ease;
}
.emoji-pick:hover { background: var(--surface-2); }
.emoji-pick[aria-pressed="true"] {
  border-color: var(--pink-bright);
  box-shadow: 0 0 0 3px rgba(255, 62, 165, 0.35);
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* Toasts */
.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 360px);
  pointer-events: none;
}
.toast {
  background: linear-gradient(135deg, var(--pink), var(--violet));
  color: #fff;
  padding: 12px 16px;
  border-radius: 14px;
  font-weight: 700;
  box-shadow: var(--shadow);
  text-align: center;
  animation: toastIn 0.25s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.toast.out { animation: toastOut 0.3s ease forwards; }
@keyframes toastOut {
  to { opacity: 0; transform: translateY(12px); }
}

.hidden { display: none !important; }

:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 2px;
}

@media (max-width: 420px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .brand-text { font-size: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
