:root {
  --slate-900: #171a21;
  --slate-800: #1f232c;
  --slate-700: #282d38;
  --slate-600: #353b48;
  --ink: #dde2ea;
  --ink-dim: #8e97a6;
  --signal: #5aa9e6;      /* Auswahl, Fokus */
  --tally: #e5484d;       /* Live / Aufnahme */
  --meter-ok: #3fb67a;
  --meter-warm: #e2b93b;
  --meter-hot: #e5484d;
  --font: "IBM Plex Sans", system-ui, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: grid;
  grid-template-rows: 46px 1fr;
  background: var(--slate-900);
  color: var(--ink);
  font: 13px/1.4 var(--font);
}
button, select, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 1px; }

/* ---------- Kopfzeile ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 14px;
  background: var(--slate-800);
  border-bottom: 1px solid var(--slate-600);
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 14px; }
.tally { width: 10px; height: 10px; border-radius: 2px; background: var(--slate-600); transition: background .2s; }
body.is-live .tally { background: var(--tally); box-shadow: 0 0 10px var(--tally); }
.indicators { display: flex; gap: 8px; margin-left: auto; }
.pill {
  padding: 4px 10px; border-radius: 4px;
  background: var(--slate-700); color: var(--ink-dim);
  font-variant-numeric: tabular-nums; font-weight: 500;
}
.pill.live { background: var(--tally); color: #fff; }

/* ---------- Vorschau ---------- */
main { display: grid; grid-template-rows: minmax(0, 1fr) 310px; min-height: 0; }
.stage {
  container-type: size;
  display: grid; place-items: center;
  padding: 16px; min-height: 0;
  background:
    repeating-linear-gradient(45deg, transparent 0 14px, rgba(255,255,255,.015) 14px 28px),
    #12141a;
}
.stage-frame {
  position: relative;
  width: min(100cqw, 100cqh * var(--ar-num, 1.7778));
  aspect-ratio: var(--ar, 16 / 9);
  background: #000;
  outline: 1px solid var(--slate-600);
}
body.is-live .stage-frame { outline: 2px solid var(--tally); }
.stage-frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#overlay { cursor: default; touch-action: none; }

/* ---------- Docks ---------- */
.docks {
  display: grid;
  grid-template-columns: minmax(150px, .9fr) minmax(210px, 1.2fr) minmax(230px, 1.3fr) minmax(230px, 1.3fr) minmax(210px, 1.1fr);
  gap: 1px;
  background: var(--slate-600);
  border-top: 1px solid var(--slate-600);
  min-height: 0;
  overflow-x: auto;
}
.dock { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--slate-800); }
.dock h2 {
  margin: 0; padding: 8px 10px;
  font-size: 12px; font-weight: 600; color: var(--ink-dim);
  border-bottom: 1px solid var(--slate-700);
}
.dock-foot { display: flex; gap: 4px; padding: 6px; border-top: 1px solid var(--slate-700); }
.dock-foot select { flex: 1; min-width: 0; }

.list { list-style: none; margin: 0; padding: 4px; overflow: auto; flex: 1; }
.list li {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 8px; border-radius: 3px;
  cursor: pointer; user-select: none;
}
.list li:hover { background: var(--slate-700); }
.list li.active { background: rgba(90, 169, 230, .18); box-shadow: inset 2px 0 0 var(--signal); }
.list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .tag { color: var(--ink-dim); font-size: 11px; }
.list .tag.warn { color: var(--meter-warm); }
.eye { width: 22px; height: 22px; padding: 0; border: 0; background: none; color: var(--ink); font-size: 14px; }
.eye.off { color: var(--slate-600); }

button {
  background: var(--slate-700); border: 1px solid var(--slate-600);
  border-radius: 3px; padding: 4px 10px; cursor: pointer;
}
button:hover { background: var(--slate-600); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--signal); border-color: var(--signal); color: #0d1a26; font-weight: 600; }
button.ghost { background: none; }
select, input[type=text], input[type=number], input[type=password], textarea {
  background: var(--slate-900); border: 1px solid var(--slate-600);
  border-radius: 3px; padding: 4px 6px; min-width: 0;
}
input[type=color] { width: 36px; height: 26px; padding: 0; border: 1px solid var(--slate-600); background: none; }

/* ---------- Eigenschaften ---------- */
.props { padding: 8px 10px; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 7px; }
.props .hint { color: var(--ink-dim); margin: 4px 0; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field > span { color: var(--ink-dim); font-size: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.inline { display: flex; gap: 6px; align-items: center; }
textarea { resize: vertical; min-height: 54px; }

/* ---------- Mixer ---------- */
.mixer { padding: 6px 10px; overflow: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.mix-row { display: flex; flex-direction: column; gap: 4px; }
.mix-head { display: flex; align-items: center; gap: 6px; }
.mix-head .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mix-head .vol { color: var(--ink-dim); font-variant-numeric: tabular-nums; width: 38px; text-align: right; }
.mix-row.master .name { font-weight: 600; }
.mix-row.dim .name { color: var(--ink-dim); }
.meter {
  position: relative; height: 7px; border-radius: 1px; overflow: hidden;
  background: linear-gradient(90deg, var(--meter-ok) 0 70%, var(--meter-warm) 70% 90%, var(--meter-hot) 90%);
}
.meter-cover { position: absolute; top: 0; right: 0; bottom: 0; width: 100%; background: var(--slate-900); }
.mix-row input[type=range] { width: 100%; accent-color: var(--signal); margin: 0; }
button.mute { padding: 1px 7px; font-size: 11px; }
button.mute.on { background: var(--tally); border-color: var(--tally); color: #fff; }
.mix-row select { width: 100%; font-size: 12px; }

/* ---------- Steuerung ---------- */
.controls { padding: 8px 10px; display: flex; flex-direction: column; gap: 7px; min-height: 0; flex: 1; }
button.big { padding: 9px; font-weight: 600; }
button.big.live { background: var(--tally); border-color: var(--tally); color: #fff; }
.stats { font-variant-numeric: tabular-nums; color: var(--ink-dim); white-space: pre-line; min-height: 18px; }
.stats.warn { color: var(--meter-warm); }
details summary { cursor: pointer; color: var(--ink-dim); }
.rec-list { list-style: none; margin: 4px 0 0; padding: 0; max-height: 80px; overflow: auto; }
.rec-list a { color: var(--signal); }
.log {
  flex: 1; min-height: 40px; margin: 0; overflow: auto;
  padding: 6px; background: var(--slate-900); border-radius: 3px;
  font: 11px/1.45 var(--mono); color: var(--ink-dim); white-space: pre-wrap;
}

/* ---------- Dialog & Toast ---------- */
dialog {
  background: var(--slate-800); color: var(--ink);
  border: 1px solid var(--slate-600); border-radius: 6px;
  width: min(460px, 94vw); padding: 18px;
}
dialog::backdrop { background: rgba(8, 10, 14, .65); }
dialog h3 { margin: 0 0 12px; font-size: 16px; font-weight: 600; }
dialog form { display: flex; flex-direction: column; gap: 10px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }

#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 20px);
  background: var(--slate-700); border: 1px solid var(--slate-600);
  padding: 9px 14px; border-radius: 4px; max-width: 90vw;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#media-pool { position: fixed; width: 1px; height: 1px; overflow: hidden; opacity: 0; pointer-events: none; }

@media (max-width: 1000px) {
  main { grid-template-rows: 45vh auto; }
  body { height: auto; }
  .docks { grid-template-columns: 1fr 1fr; overflow: visible; }
  .dock { min-height: 220px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
