:root {
  --bg: #10151c;
  --panel: #18202a;
  --panel-hi: #1f2936;
  --line: #2b3644;
  --text: #e8edf4;
  --muted: #93a0b2;
  --signal: #ffb02e;
  --danger: #ef4f4f;
  --radius: 14px;
  color-scheme: dark;
  font-family: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; color: var(--text); background: var(--bg); font-size: 16px; line-height: 1.4; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Kopfzeile */
.bar { position: sticky; top: 0; z-index: 10; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
  padding: 14px clamp(16px, 3vw, 32px); background: rgba(16, 21, 28, .94); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { margin: 0; font-size: 1.15rem; font-weight: 650; letter-spacing: .01em; }
.search { flex: 1 1 240px; max-width: 460px; }
.search input { width: 100%; height: 42px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); }
.search input::placeholder { color: var(--muted); }
.ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-left: auto; }
.master { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .9rem; }
.master input { width: 140px; accent-color: var(--signal); }
.master output { min-width: 3.6ch; text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.toggle { height: 42px; padding: 0 14px; display: inline-flex; align-items: center; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); }
.toggle::before { content: ""; width: 8px; height: 8px; margin-right: 8px; border-radius: 50%; background: var(--line); }
.toggle[aria-pressed="true"] { color: var(--text); border-color: var(--signal); background: rgba(255, 176, 46, .12); }
.toggle[aria-pressed="true"]::before { background: var(--signal); }
.stop { height: 42px; padding: 0 16px; display: inline-flex; align-items: center; gap: 8px; border-radius: 10px; border: 1px solid var(--danger); background: transparent; color: #ff8a8a; font-weight: 600; }
.stop svg { width: 14px; height: 14px; }
.stop:hover { background: rgba(239, 79, 79, .16); }
.stop.armed { background: var(--danger); color: #fff; }

/* Kategorien */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 14px clamp(16px, 3vw, 32px) 4px; scrollbar-width: none; }
.chip { flex: none; height: 36px; padding: 0 14px; display: inline-flex; align-items: center; gap: 8px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--d, var(--muted)); }
.chip:hover { color: var(--text); border-color: #3b4a5d; }
.chip[aria-pressed="true"] { color: var(--text); background: var(--panel-hi); border-color: var(--text); }

/* Bereiche */
main { padding: 4px clamp(16px, 3vw, 32px) 64px; }
.sec { margin-top: 26px; }
.head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; }
.head h2 { margin: 0; font-size: 1.05rem; font-weight: 650; }
.hint { color: var(--muted); font-size: .85rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }

/* Sound-Kachel: Farbstreifen oben, Fortschritt füllt die Kachel */
.tile { --p: 0; position: relative; display: flex; flex-direction: column; min-height: 132px; overflow: hidden;
  border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel);
  box-shadow: inset 0 3px 0 var(--c); transition: background .15s, border-color .15s; }
.tile:hover { background: var(--panel-hi); }
.prog { position: absolute; inset: 0; background: var(--c); opacity: 0; transform: scaleX(var(--p)); transform-origin: left; pointer-events: none; }
.tile.is-playing { border-color: var(--c); }
.tile.is-playing .prog { opacity: .26; }
.tile.is-preview .prog { opacity: .12; }
.tile-main { position: relative; flex: 1; display: flex; flex-direction: column; justify-content: space-between; gap: 10px;
  padding: 16px 14px 8px; text-align: left; background: none; border: 0; }
.tile-top { display: flex; align-items: center; gap: 12px; min-height: 34px; width: 100%; }
.tile-icon { width: 34px; height: 34px; display: grid; place-items: center; font-size: 1.9rem; line-height: 1; }
.tile-icon svg { width: 26px; height: 26px; fill: none; stroke: var(--c); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tile-title { font-size: 1.02rem; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.tile-key { margin-left: auto; align-self: flex-start; min-width: 22px; height: 22px; padding: 0 6px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: .78rem; color: var(--muted); }

.meter { display: flex; align-items: flex-end; gap: 3px; height: 20px; opacity: 0; transition: opacity .15s; }
.meter i { width: 3px; height: 100%; border-radius: 2px; background: var(--c); transform-origin: bottom; transform: scaleY(.3); }
.is-playing .meter { opacity: 1; }
.is-playing .meter i { animation: meter .9s ease-in-out infinite alternate; }
.meter i:nth-child(2) { animation-delay: -.3s; }
.meter i:nth-child(3) { animation-delay: -.6s; animation-duration: .7s; }
.meter i:nth-child(4) { animation-delay: -.15s; animation-duration: 1.1s; }
@keyframes meter { from { transform: scaleY(.25); } to { transform: scaleY(1); } }

.tile-foot { position: relative; display: flex; align-items: center; gap: 4px; padding: 0 8px 8px 14px; }
.vol { flex: 1; min-width: 0; height: 28px; accent-color: var(--c); opacity: .55; transition: opacity .15s; }
.tile:hover .vol, .tile:focus-within .vol { opacity: 1; }
@media (hover: none) { .vol { opacity: 1; } }
.ibtn { flex: none; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 8px; border: 0; background: transparent; color: var(--muted); }
.ibtn:hover { color: var(--text); background: rgba(255, 255, 255, .07); }
.ibtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ibtn[aria-pressed="true"] { color: var(--signal); }
.ibtn[aria-pressed="true"] svg { fill: currentColor; }

.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.empty button { margin-top: 12px; height: 40px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); max-width: calc(100% - 32px); padding: 10px 16px;
  border-radius: 10px; background: var(--panel-hi); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }

/* Profile */
.profile { position: relative; }
.pbtn { height: 42px; max-width: 200px; padding: 0 14px 0 12px; display: inline-flex; align-items: center; gap: 8px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); }
.pbtn:hover, .pbtn[aria-expanded="true"] { border-color: #3b4a5d; background: var(--panel-hi); }
.pbtn svg { flex: none; width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
.pbtn span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu { position: absolute; left: 0; top: calc(100% + 8px); z-index: 20; width: 270px; padding: 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel-hi); box-shadow: 0 12px 32px rgba(0, 0, 0, .45); }
.menu-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 2px; max-height: 240px; overflow-y: auto; }
.menu-item { width: 100%; height: 38px; padding: 0 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; border: 0; border-radius: 8px; background: none; text-align: left; }
.menu-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-item:hover { background: rgba(255, 255, 255, .07); }
.menu-item[aria-current="true"] { color: var(--signal); font-weight: 600; }
.menu-item[aria-current="true"]::after { content: "✓"; }
.menu-new { display: flex; gap: 6px; padding-top: 8px; border-top: 1px solid var(--line); }
.menu-new input { flex: 1; min-width: 0; height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }
.mini { height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); }
.mini:hover { border-color: var(--signal); }
.menu-err { margin: 8px 2px 0; color: #ff8a8a; font-size: .88rem; }
.menu-del { margin-top: 8px; width: 100%; height: 34px; border: 0; border-radius: 8px; background: none; color: #ff8a8a; font-size: .9rem; }
.menu-del:hover { background: rgba(239, 79, 79, .14); }

@media (max-width: 640px) {
  /* Kopfzeile scrollt mit (spart Platz); "Alle stoppen" bleibt als schwebende Taste erreichbar, solange etwas läuft. */
  .bar { position: static; backdrop-filter: none; }
  .stop.armed { position: fixed; right: 16px; bottom: 16px; z-index: 30; height: 52px; padding: 0 20px; box-shadow: 0 8px 24px rgba(0, 0, 0, .5); }
  .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .ctl { width: 100%; margin-left: 0; }
  .master input { width: 110px; }
  .stop { margin-left: auto; }
}
@media (prefers-reduced-motion: reduce) {
  .is-playing .meter i { animation: none; }
  .meter i:nth-child(odd) { transform: scaleY(.8); }
  .tile, .meter, .vol { transition: none; }
}
