:root {
  --bg: #14110f;
  --panel: #1d1916;
  --panel-2: #26201c;
  --line: #3a312a;
  --grid: #2f2823;
  --text: #f3e9dc;
  --muted: #a8998a;
  --accent: #e8a33d;
  --accent-ink: #1a1208;
  --ok: #7cc68a;
  --warn: #f0b35a;
  --bad: #e5776b;
  --spotify: #1ed760;
  --radius: 10px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 11px;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.link { background: none; border: none; padding: 4px 0; color: var(--muted); text-decoration: underline; }
button.link.inline { padding: 0; color: var(--accent); }
button.spotify-btn { border-color: var(--spotify); }
button.spotify-btn:hover:not(:disabled) { background: color-mix(in srgb, var(--spotify) 18%, var(--panel-2)); }

input[type="text"], input[type="search"], input[type="number"], textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 9px;
  width: 100%;
}
input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; }
code { background: var(--bg); padding: 1px 5px; border-radius: 4px; user-select: all; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }
.warn { color: var(--warn); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; margin-top: 14px; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

/* Kopfzeile */
.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { font-size: 20px; font-weight: 800; letter-spacing: 0.5px; white-space: nowrap; }
.brand small { font-size: 11px; font-weight: 400; letter-spacing: 0; }
a { color: var(--accent); }
.folder-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand span { color: var(--accent); }
.toolbar { display: flex; gap: 8px; }
.status { margin-left: auto; color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }

/* Aufteilung */
.layout { flex: 1; display: flex; min-height: 0; }
.list-pane { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.detail-pane {
  width: 460px;
  flex: none;
  border-left: 1px solid var(--line);
  background: var(--panel);
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-controls { padding: 12px 16px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.filters button { border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.filters button span { color: var(--muted); margin-left: 3px; font-variant-numeric: tabular-nums; }
.filters button.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.filters button.active span { color: var(--accent-ink); opacity: 0.7; }

.table-wrap { flex: 1; overflow: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  position: sticky; top: 0; z-index: 1;
  background: var(--bg);
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
thead th.sorted { color: var(--text); }
thead th.sorted::after { content: " " attr(data-dir); font-size: 9px; }
th.num, td.num { text-align: right; }
tbody td { padding: 5px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 320px; }
tbody tr { cursor: pointer; }
tbody tr:hover td { background: var(--panel); }
tbody tr.selected td { background: #3a2a17; }
tbody tr.st-missing td { opacity: 0.5; }
td.strong { font-weight: 700; font-size: 15px; }
.c-cover { width: 44px; padding-right: 0; }
.c-cover img { width: 32px; height: 32px; border-radius: 4px; object-fit: cover; display: block; }
td.c-cover:empty::before { content: ""; display: block; width: 32px; height: 32px; border-radius: 4px; background: var(--panel-2); }

.badge { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.b-verified { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
.b-unverified { color: var(--text); }
.b-uncertain, .b-error { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.b-missing { color: var(--bad); }
.b-running { color: var(--accent); border-color: var(--accent); }

.empty { padding: 80px 30px; text-align: center; }
.empty p { font-size: 16px; }
.empty .hint { font-size: 13px; color: var(--muted); max-width: 460px; margin: 18px auto; }

/* Detailansicht */
.card { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.card h3 { margin: 0 0 8px; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }

.detail-head { display: flex; gap: 14px; align-items: center; }
.cover-lg { width: 96px; height: 96px; border-radius: 8px; object-fit: cover; flex: none; background: var(--panel-2); }
.detail-title { min-width: 0; }
.detail-title h2 { margin: 0; font-size: 20px; line-height: 1.2; }
.detail-title p { margin: 3px 0 0; }

.player-row { display: flex; align-items: center; gap: 8px; }
.player-row + .player-row { margin-top: 8px; flex-wrap: wrap; }
.player-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.player-row .check { margin-left: auto; }
button.round { width: 38px; height: 38px; border-radius: 50%; padding: 0; background: var(--accent); color: var(--accent-ink); border: none; font-size: 14px; }

.bpm-card { display: grid; grid-template-columns: 160px 1fr; gap: 12px; }
.bpm-main { display: flex; flex-direction: column; gap: 6px; }
.bpm-input {
  font-size: 54px !important;
  font-weight: 800;
  line-height: 1;
  padding: 4px 8px !important;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.detail-pane.verified .bpm-input { border-color: var(--ok); }
.bpm-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.bpm-buttons button { padding: 4px 0; }
.verify { font-weight: 600; margin-top: 2px; }
.bpm-analysis { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
#a-curve { width: 100%; height: 120px; background: var(--bg); border-radius: 6px; }

.tap-card { display: flex; gap: 14px; align-items: center; }
button.tap {
  width: 110px; height: 110px; border-radius: 50%; flex: none;
  font-size: 22px; font-weight: 800; letter-spacing: 1px;
  background: var(--bg); border: 3px solid var(--accent); color: var(--accent);
}
button.tap.flash { animation: flash 0.18s ease-out; }
@keyframes flash { from { background: var(--accent); color: var(--accent-ink); } to { background: var(--bg); color: var(--accent); } }
.tap-info { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.tap-result { font-size: 40px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }

.meta-card { display: flex; flex-direction: column; gap: 8px; }
.meta-card label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.images { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.image-slot { display: flex; flex-direction: column; gap: 5px; }
.img-box { position: relative; width: 100%; aspect-ratio: 1; border-radius: 6px; background: var(--bg); border: 1px dashed var(--line); overflow: hidden; }
.img-box::before { content: attr(data-empty); position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.img-box img { position: relative; width: 100%; height: 100%; object-fit: cover; display: block; }
.spotify-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.shortcuts { margin: 2px 2px 8px; line-height: 1.6; }

/* Dialoge */
dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px 22px;
  width: 520px;
  max-width: calc(100vw - 32px);
}
dialog.wide { width: 640px; }
dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
dialog h3 { margin: 0 0 10px; }
dialog h4 { margin: 18px 0 6px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
dialog label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
dialog .row label { flex-direction: row; align-items: center; gap: 6px; }
dialog .row input[type="number"] { width: 90px; }
dialog .row input[type="search"] { flex: 1; width: auto; }

.sp-results { list-style: none; margin: 8px 0; padding: 0; max-height: 330px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.sp-results li { display: grid; grid-template-columns: 48px 1fr auto; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 8px; border: 1px solid transparent; cursor: pointer; }
.sp-results li:hover { background: var(--panel-2); }
.sp-results li.chosen { border-color: var(--spotify); background: color-mix(in srgb, var(--spotify) 10%, var(--panel)); }
.sp-results img { width: 48px; height: 48px; border-radius: 4px; object-fit: cover; background: var(--bg); }
.sp-results .match { color: var(--spotify); font-weight: 600; }

/* Decks und Mischpult */
.decks {
  display: grid;
  grid-template-columns: 1fr 190px 1fr;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.deck {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.deck.drop { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--panel-2)); }
.deck.playing { border-color: color-mix(in srgb, var(--accent) 60%, var(--line)); }
.deck.is-empty .deck-mid, .deck.is-empty .deck-progress { opacity: 0.35; }
.deck-head { display: flex; align-items: center; gap: 10px; min-width: 0; }
.deck-letter {
  width: 28px; height: 28px; flex: none; border-radius: 6px;
  display: grid; place-items: center; font-weight: 800;
  background: var(--bg); color: var(--accent); border: 1px solid var(--line);
}
.deck-cover { width: 40px; height: 40px; border-radius: 5px; object-fit: cover; flex: none; }
.deck-titles { min-width: 0; flex: 1; }
.deck-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-artist { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.onair { font-size: 11px; font-weight: 800; letter-spacing: 0.08em; padding: 3px 8px; border-radius: 4px; background: #c8402f; color: #fff; }
.deck-mid { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.deck-bpm { display: flex; flex-direction: column; }
.bpm-big { font-size: 44px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.deck.unverified .bpm-big { color: var(--warn); }
.deck-eq { display: flex; flex-direction: column; gap: 2px; }
.deck-eq label { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.deck-eq input { width: 110px; accent-color: var(--accent); }
.deck-progress { display: flex; align-items: center; gap: 8px; }
.deck-progress .bar { flex: 1; height: 8px; background: var(--bg); border-radius: 4px; cursor: pointer; overflow: hidden; }
.deck-progress .fill { height: 100%; width: 0; background: var(--accent); }
.deck.ending .fill { background: #c8402f; }
.deck-controls { display: flex; align-items: center; gap: 6px; }
.deck-controls button { padding: 5px 9px; }
.deck-controls button.round { width: 34px; height: 34px; padding: 0; }
.d-cue[aria-pressed="true"] { background: #3d6fd1; border-color: #3d6fd1; color: #fff; font-weight: 700; }
.d-tempo { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.d-rate { flex: 1; min-width: 50px; accent-color: var(--accent); }
.d-rate-label { width: 62px; text-align: right; white-space: nowrap; }

.mixer {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.faders { display: flex; justify-content: space-around; }
.vfader { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.vfader input { writing-mode: vertical-lr; direction: rtl; height: 86px; width: 22px; accent-color: var(--accent); }
.xfader { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.xfader input { width: 100%; accent-color: var(--accent); }
.hp { display: flex; flex-direction: column; gap: 2px; }
.hp label { display: flex; flex-direction: column; color: var(--muted); font-size: 11px; }
.hp input { width: 100%; accent-color: #3d6fd1; }

.now-playing {
  margin-left: auto;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: color-mix(in srgb, #c8402f 25%, var(--panel));
  border: 1px solid #c8402f;
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw;
}
.now-playing:not([hidden]) + .status { margin-left: 12px; }
.player-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.player-head h3 { margin: 0; }
.out-row { display: grid; grid-template-columns: 150px 1fr 120px auto; gap: 6px; align-items: center; margin: 4px 0; font-size: 13px; }
.out-row select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 7px; padding: 5px 6px; min-width: 0; }
dialog { max-height: calc(100vh - 40px); overflow-y: auto; }
dialog#settings { width: 640px; }

/* Seitenleiste und Ansichten */
.list-pane { overflow: hidden; }
.browser { flex: 1; display: flex; min-height: 0; }
.browser-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.sidebar {
  width: 200px; flex: none; overflow-y: auto;
  border-right: 1px solid var(--line); background: var(--panel);
  padding: 10px 8px; display: flex; flex-direction: column; gap: 2px;
}
.side-item {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  width: 100%; text-align: left; background: none; border: 1px solid transparent;
  padding: 5px 8px; border-radius: 6px; font-size: 13px;
}
.side-item:hover:not(:disabled) { background: var(--panel-2); border-color: transparent; }
.side-item.active { background: color-mix(in srgb, var(--accent) 20%, var(--panel)); color: var(--text); }
.side-item.live .side-label { color: #ff8a7a; font-weight: 700; }
.side-item.drop { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 15%, var(--panel)); }
.side-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-count { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.side-head {
  margin: 12px 4px 4px; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.06em;
  display: flex; justify-content: space-between; align-items: center;
}
.side-add { padding: 0 7px; font-size: 14px; line-height: 18px; }
.side-empty { margin: 2px 8px; font-size: 12px; color: var(--muted); }
.view-head { display: flex; align-items: baseline; gap: 10px; }
.view-head h2 { margin: 0; font-size: 17px; }
.view-head .spacer, .row .spacer { flex: 1; }
#view-info { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* Tabelle: Position, Favorit, gespielt */
.c-pos { width: 30px; display: none; }
table.ordered .c-pos { display: table-cell; }
.c-fav { width: 26px; padding-left: 2px !important; padding-right: 2px !important; text-align: center; }
.star { background: none; border: none; padding: 0 2px; color: var(--muted); font-size: 15px; line-height: 1; }
.star.on { color: var(--accent); }
.mini-rating { color: var(--accent); font-size: 10px; letter-spacing: -1px; }
tbody tr.played td:not(.c-fav) { opacity: 0.55; }
tbody tr.played.selected td { opacity: 0.85; }
.b-played { color: #ff8a7a; border-color: color-mix(in srgb, #ff8a7a 45%, transparent); }
tbody tr.drop-before td { box-shadow: inset 0 2px 0 var(--accent); }

/* Detailansicht: Favorit, Bewertung, Playlist */
.d-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 8px; }
.d-actions button, .d-actions select { font-size: 12px; padding: 4px 8px; }
.d-actions select { font: inherit; font-size: 12px; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; }
.fav-btn.on { color: var(--accent); border-color: var(--accent); }
.rating { display: inline-flex; }
.rating button { background: none; border: none; padding: 0 1px; color: var(--line); font-size: 16px; }
.rating button.on { color: var(--accent); }
.played-note { color: #ff8a7a; font-weight: 600; }

/* Party-Knopf */
.party-btn.running { background: #c8402f; border-color: #c8402f; color: #fff; font-weight: 700; }

/* Regeln für intelligente Playlisten */
.rules { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 6px; }
.rules li { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.rules select, .rules input, #pl-dialog select, #pl-dialog input[type="number"] {
  font: inherit; font-size: 13px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; width: auto;
}
#pl-dialog .rules input[type="number"] { width: 80px; }
#pl-dialog .rules input[type="text"] { width: 200px; }
label.inline { flex-direction: row !important; align-items: center; gap: 6px !important; }
#pl-dialog #pl-limit { width: 80px; }
button.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 50%, transparent); }

/* Autoplay */
.autoplay-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 16px; border-bottom: 1px solid var(--line); background: var(--panel);
  min-width: 0;
}
.autoplay-bar .spacer { flex: 1; }
#ap-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 0 1 auto; }
#ap-next { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32%; color: #7fb2ff; }
.ap-toggle { font-weight: 700; }
.autoplay-bar.on .ap-toggle { background: #3d6fd1; border-color: #3d6fd1; color: #fff; }
.deck-note { color: #7fb2ff; margin-top: -4px; }
.ap-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px 12px; margin-bottom: 6px; }
.ap-grid select, .ap-grid input {
  font: inherit; font-size: 13px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 5px 6px;
}
.ap-grid label > span { display: flex; align-items: center; gap: 6px; color: var(--muted); }
#ap-dialog .ap-grid input[type="number"] { width: 80px; }
#ap-dialog .check { flex-direction: row; font-size: 13px; color: var(--text); margin: 4px 0; }
.autoplay-bar button { flex: none; white-space: nowrap; }

/* Fortschrittsbalken für Einlesen und Analyse */
.progress { background: var(--panel); border-bottom: 1px solid var(--line); padding: 6px 18px 8px; }
.progress-track { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width 0.4s ease; }
.progress-fill.indeterminate { width: 30% !important; animation: indeterminate 1.2s ease-in-out infinite; }
@keyframes indeterminate { from { margin-left: -30%; } to { margin-left: 100%; } }
.progress-row { display: flex; align-items: center; gap: 8px; margin-top: 5px; font-size: 13px; min-width: 0; }
.progress-row .spacer { flex: 1; }
.progress-label { font-weight: 600; white-space: nowrap; }
#progress-detail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#progress-eta { white-space: nowrap; color: var(--accent); }
.small-btn { padding: 2px 10px; font-size: 12px; }
