/* vidtesla – Hauptoberfläche
   Farbidee: Schieferblau wie ein abgedunkelter Schnittplatz, dazu ein Bernstein-Ton als „Tally-Licht“,
   das wie an einer Studiokamera anzeigt, wo das Video gerade läuft. */

:root {
  --bg: #eceef4;
  --surface: #ffffff;
  --raised: #f3f4f8;
  --sunken: #e2e5ee;
  --line: #d5d9e4;
  --line-strong: #b9bfd0;
  --text: #171b2d;
  --muted: #565d75;
  --faint: #868ca3;
  --tally: #f2b33d;
  --tally-ink: #241800;
  --accent-text: #8a5600;
  --danger: #c2333b;
  --ok: #1d8556;
  --stage: #0c1020;
  --stage-text: #c9cde0;
  --shadow: 0 1px 2px rgb(23 27 45 / 0.05), 0 10px 30px -18px rgb(23 27 45 / 0.35);
  --shadow-pop: 0 18px 50px -20px rgb(15 18 34 / 0.45), 0 2px 6px rgb(15 18 34 / 0.08);
  --ring: 0 0 0 3px color-mix(in srgb, var(--tally) 60%, transparent);

  --r-xs: 6px;
  --r-s: 9px;
  --r-m: 12px;
  --r-l: 18px;

  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Display", Roboto, sans-serif;

  --fs-xs: 0.75rem;
  --fs-s: 0.8125rem;
  --fs-m: 0.9375rem;
  --fs-l: 1.125rem;
  --fs-xl: 1.375rem;

  --ctl-h: 48px;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141826;
    --surface: #1b2032;
    --raised: #232a3f;
    --sunken: #10131f;
    --line: #2d3450;
    --line-strong: #424a68;
    --text: #e8eaf2;
    --muted: #a0a6bf;
    --faint: #6f7693;
    --tally: #f5b841;
    --tally-ink: #1e1400;
    --accent-text: #f6c661;
    --danger: #ff6d72;
    --ok: #4cc38a;
    --stage: #090c17;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 14px 34px -18px rgb(0 0 0 / 0.7);
    --shadow-pop: 0 24px 60px -20px rgb(0 0 0 / 0.75), 0 2px 8px rgb(0 0 0 / 0.3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141826;
  --surface: #1b2032;
  --raised: #232a3f;
  --sunken: #10131f;
  --line: #2d3450;
  --line-strong: #424a68;
  --text: #e8eaf2;
  --muted: #a0a6bf;
  --faint: #6f7693;
  --tally: #f5b841;
  --tally-ink: #1e1400;
  --accent-text: #f6c661;
  --danger: #ff6d72;
  --ok: #4cc38a;
  --stage: #090c17;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.3), 0 14px 34px -18px rgb(0 0 0 / 0.7);
  --shadow-pop: 0 24px 60px -20px rgb(0 0 0 / 0.75), 0 2px 8px rgb(0 0 0 / 0.3);
  color-scheme: dark;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 400 var(--fs-m) / 1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
[hidden] { display: none !important; }

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: var(--r-s);
  background: var(--tally);
  color: var(--tally-ink);
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-lg { width: 32px; height: 32px; }

kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 0.4em;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  font: 600 0.78em/1.55 var(--font);
  text-align: center;
  color: var(--muted);
  background: var(--raised);
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: var(--surface);
  color: var(--text);
  font-weight: 550;
  font-size: var(--fs-s);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { background: var(--raised); border-color: var(--line-strong); }
.btn:active { transform: translateY(1px); }
.btn .icon { width: 18px; height: 18px; }
.btn-primary {
  background: var(--tally);
  border-color: transparent;
  color: var(--tally-ink);
}
.btn-primary:hover { background: color-mix(in srgb, var(--tally) 88%, var(--text)); border-color: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 8%, var(--surface)); }
.btn-small { min-height: 32px; padding: 0 11px; }

.btn-text {
  border: 0;
  padding: 2px 4px;
  margin: 0 -4px;
  border-radius: var(--r-xs);
  background: none;
  color: var(--muted);
  font-size: var(--fs-s);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 35%, transparent);
  text-underline-offset: 3px;
}
.btn-text:hover { color: var(--text); text-decoration-color: currentColor; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: var(--r-s);
  background: transparent;
  color: var(--muted);
  transition: background-color 0.15s, color 0.15s;
}
.icon-btn:hover:not(:disabled) { background: var(--raised); color: var(--text); }
.icon-btn:disabled { opacity: 0.4; }

/* ---------- Kopfzeile ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px clamp(16px, 3vw, 32px);
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  flex: none;
  border-radius: var(--r-xs);
}
.brand-mark {
  position: relative;
  width: 26px;
  height: 20px;
  border-radius: 6px;
  background: var(--text);
}
.brand-mark::after {
  content: "";
  position: absolute;
  right: 3px;
  bottom: 3px;
  width: 11px;
  height: 8px;
  border-radius: 2.5px;
  background: var(--tally);
}
.brand-name {
  font: 650 1.1875rem/1 var(--font-display);
  letter-spacing: -0.02em;
}

.source {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  max-width: 720px;
  margin: 0 auto;
  height: 46px;
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.source:focus-within { border-color: color-mix(in srgb, var(--tally) 70%, var(--line)); box-shadow: var(--shadow), var(--ring); }
.source[data-invalid] { border-color: var(--danger); }
.source-icon { margin-left: 14px; color: var(--faint); }
.source input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 12px;
  border: 0;
  background: transparent;
  outline: none;
  font-size: var(--fs-m);
}
.source input::placeholder { color: var(--faint); }
.source-hint { margin-right: 8px; }
.source:focus-within .source-hint { display: none; }
.source-submit { margin-right: 4px; min-height: 36px; }

.source-error {
  max-width: 720px;
  margin: -4px auto 8px;
  padding: 0 16px;
  color: var(--danger);
  font-size: var(--fs-s);
  width: 100%;
}

/* ---------- Layout ---------- */

.layout {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 8px clamp(16px, 3vw, 32px) 32px;
  display: grid;
  gap: 32px;
}

.player {
  width: 100%;
  max-width: min(1080px, calc((100dvh - 290px) * 16 / 9));
  min-width: min(100%, 520px);
  margin: 0 auto;
}

/* ---------- Bühne (Video + Steuerleiste) ---------- */

.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-l);
  background: var(--stage);
  box-shadow: var(--shadow);
  overflow: hidden;
  outline: none;
}

.frame {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--stage);
}

.mount,
.mount > iframe,
.mount > div {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
.stage[data-state="empty"] .mount,
.stage:not([data-output="local"]) .mount { visibility: hidden; }

.panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  color: var(--stage-text);
  background:
    radial-gradient(120% 90% at 50% 120%, rgb(245 184 65 / 0.07), transparent 60%),
    var(--stage);
}
.panel-title {
  font: 600 clamp(1.125rem, 2.4vw, 1.5rem)/1.25 var(--font-display);
  letter-spacing: -0.01em;
  color: #f1f2f7;
}
.panel-text {
  max-width: 46ch;
  font-size: var(--fs-s);
  color: #a3a9c2;
}
.panel kbd { color: #d6d9e7; background: #1b2034; border-color: #3a415e; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.panel .btn:not(.btn-primary) { background: #1b2034; border-color: #353c58; color: #e4e6ef; }
.panel .btn:not(.btn-primary):hover { background: #252b44; }
.panel-error .icon-lg { color: var(--tally); }

.stage[data-state="empty"] .panel-empty { display: grid; }
.stage:not([data-state="empty"]) .panel-empty { display: none; }

/* Tally-Licht */
.tally {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--line-strong);
  flex: none;
  transition: background-color 0.2s, box-shadow 0.2s;
}
.tally-lg {
  width: 14px;
  height: 14px;
  background: var(--tally);
  box-shadow: 0 0 0 6px rgb(245 184 65 / 0.14), 0 0 24px rgb(245 184 65 / 0.55);
  animation: tally-pulse 2.4s var(--ease) infinite;
}
@keyframes tally-pulse {
  50% { box-shadow: 0 0 0 9px rgb(245 184 65 / 0.06), 0 0 30px rgb(245 184 65 / 0.35); }
}

/* Steuerleiste – liegt unter dem Video, nie darüber (YouTube-Richtlinien) */
.controls {
  position: relative;
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.controls-row {
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--ctl-h);
  padding: 0 10px;
}
.stage[data-state="empty"] .controls-row { opacity: 0.55; }

.ctl {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  flex: none;
  border: 0;
  border-radius: var(--r-s);
  background: transparent;
  color: var(--text);
  transition: background-color 0.15s;
}
.ctl:hover:not(:disabled) { background: var(--raised); }
.ctl:disabled { color: var(--faint); }
.ctl-play { width: 40px; height: 40px; }
.ctl-play .icon { width: 22px; height: 22px; }

.time {
  min-width: 4.2ch;
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  text-align: center;
  flex: none;
}
.time-total[data-live] {
  color: var(--danger);
  font-weight: 650;
}

.range {
  --pct: 0%;
  --buf: 0%;
  -webkit-appearance: none;
  appearance: none;
  height: 28px;
  margin: 0;
  background: transparent;
  cursor: pointer;
  border-radius: 6px;
}
.range:disabled { cursor: default; }
.range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(to right,
    var(--tally) var(--pct),
    color-mix(in srgb, var(--line-strong) 55%, var(--text) 12%) var(--pct) var(--buf),
    var(--line) var(--buf));
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border: 0;
  border-radius: 50%;
  background: var(--text);
  transition: transform 0.12s;
}
.range:hover::-webkit-slider-thumb { transform: scale(1.15); }
.range:disabled::-webkit-slider-thumb { background: var(--line-strong); }
.range::-moz-range-track { height: 4px; border-radius: 4px; background: var(--line); }
.range::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--tally); }
.range::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--text); }
.range:focus-visible { box-shadow: var(--ring); }

.seek { flex: 1; min-width: 60px; }

.volume { display: flex; align-items: center; flex: none; }
.vol { width: 84px; }

.rate {
  height: 30px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-xs);
  background: var(--surface);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  flex: none;
}

.compact-only { display: none; }

.progress-line {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  top: -1px;
  height: 3px;
  background: var(--line);
}
.progress-line i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--tally);
}

/* ---------- Titel ---------- */

.meta {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 4px 0;
}
.meta-text { flex: 1; min-width: 0; }
.title {
  font: 600 var(--fs-xl)/1.25 var(--font-display);
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.stage[data-state="empty"] ~ .meta .title { color: var(--faint); font-weight: 500; }
.subtitle { margin-top: 2px; font-size: var(--fs-s); color: var(--muted); }
#fav-toggle[aria-pressed="true"] { color: var(--accent-text); }

.player-alert {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--tally) 45%, var(--line));
  border-radius: var(--r-m);
  background: color-mix(in srgb, var(--tally) 9%, var(--surface));
}
.player-alert > .icon { color: var(--accent-text); margin-top: 2px; }
.player-alert > div:first-of-type { flex: 1; }
.player-alert-title { font-weight: 600; }
.player-alert-text { font-size: var(--fs-s); color: var(--muted); }
.player-alert-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Modusleiste ---------- */

.modebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.seg {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  border-radius: var(--r-m);
  background: var(--sunken);
}
.seg-btn,
.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px 0 12px;
  border: 0;
  border-radius: var(--r-s);
  background: transparent;
  color: var(--muted);
  font-size: var(--fs-s);
  font-weight: 550;
  transition: background-color 0.18s, color 0.18s, box-shadow 0.18s;
}
.seg-btn .icon,
.tool-btn .icon { width: 18px; height: 18px; }
.seg-btn:hover { color: var(--text); }
.seg-btn[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08), 0 0 0 1px var(--line);
}
.seg-btn[aria-pressed="true"] .tally {
  background: var(--tally);
  box-shadow: 0 0 0 3px rgb(245 184 65 / 0.22), 0 0 10px rgb(245 184 65 / 0.6);
}
.seg-btn[aria-disabled="true"] { opacity: 0.55; }
.seg-btn[aria-disabled="true"] .seg-label::after { content: " *"; color: var(--faint); }

.modebar-tools { display: inline-flex; gap: 4px; }
.tool-btn { border: 1px solid transparent; }
.tool-btn:hover:not(:disabled) { background: var(--surface); color: var(--text); border-color: var(--line); }
.tool-btn:disabled,
.tool-btn[aria-disabled="true"] { opacity: 0.45; }

/* ---------- Bibliothek ---------- */

.library {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
}
.lib-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 20px; }
.tab {
  position: relative;
  padding: 6px 0;
  border: 0;
  background: none;
  font: 600 var(--fs-l)/1.3 var(--font-display);
  letter-spacing: -0.01em;
  color: var(--faint);
  border-radius: var(--r-xs);
}
.tab[aria-selected="true"] { color: var(--text); }
.tab[aria-selected="true"]::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -11px;
  height: 2px;
  border-radius: 2px;
  background: var(--tally);
}
.count { font: 500 var(--fs-xs)/1 var(--font); color: var(--faint); font-variant-numeric: tabular-nums; vertical-align: 2px; }

.lib-list {
  list-style: none;
  margin: 0;
  padding: 6px 0 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 460px), 1fr));
  column-gap: 24px;
}
.lib-item {
  display: flex;
  align-items: center;
  gap: 4px;
  border-radius: var(--r-m);
  transition: background-color 0.15s;
}
.lib-item:hover,
.lib-item:focus-within { background: color-mix(in srgb, var(--surface) 70%, transparent); }
.lib-item[data-current] .lib-title { color: var(--accent-text); }

.lib-open {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 14px;
  align-items: center;
  padding: 8px;
  border: 0;
  border-radius: var(--r-m);
  background: none;
  text-align: left;
}
.thumb {
  position: relative;
  aspect-ratio: 16 / 9;
  border-radius: var(--r-s);
  overflow: hidden;
  background: linear-gradient(135deg, var(--raised), var(--sunken));
  display: grid;
  place-items: center;
  color: var(--faint);
}
.thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.thumb-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  background: var(--tally);
}
.lib-text { min-width: 0; display: grid; gap: 2px; }
.lib-title {
  font-weight: 550;
  font-size: var(--fs-m);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.lib-sub { font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.lib-actions { display: flex; flex-direction: column; opacity: 0; transition: opacity 0.15s; padding-right: 4px; }
.lib-item:hover .lib-actions,
.lib-item:focus-within .lib-actions { opacity: 1; }
.lib-actions .icon-btn { width: 34px; height: 34px; }
.lib-actions .icon { width: 18px; height: 18px; }
.lib-actions [aria-pressed="true"] { color: var(--accent-text); }

/* Kanäle */
.channels { display: grid; gap: 10px; padding: 14px 0 4px; }
.ch-bar { display: flex; gap: 12px 20px; align-items: center; flex-wrap: wrap; }
.ch-form {
  flex: 1 1 360px;
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 560px;
  height: 40px;
  padding: 0 4px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  background: var(--surface);
}
.ch-form:focus-within { border-color: color-mix(in srgb, var(--tally) 70%, var(--line)); box-shadow: var(--ring); }
.ch-input { flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: none; font-size: var(--fs-s); }
.ch-input::placeholder { color: var(--faint); }
.ch-input:focus-visible,
.source input:focus-visible { box-shadow: none; }
.ch-tools { display: flex; align-items: center; gap: 18px; margin-left: auto; }
.ch-toggle { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-s); color: var(--muted); cursor: pointer; }
.switch-small { width: 32px; height: 20px; }
.switch-small::after { top: 3px; left: 3px; width: 14px; height: 14px; }
.switch-small:checked::after { transform: translateX(12px); }
.ch-error { color: var(--danger); font-size: var(--fs-s); }
.ch-status { font-size: var(--fs-xs); color: var(--faint); min-height: 1em; }
.ch-status[data-tone="warn"] { color: var(--accent-text); }

.ch-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: var(--fs-s);
  transition: border-color 0.15s, background-color 0.15s;
}
.chip-main {
  border: 0;
  background: none;
  padding: 4px 4px 4px 12px;
  border-radius: 999px;
  font-weight: 550;
  max-width: 24ch;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.chip-remove {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  margin-right: 2px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--faint);
}
.chip-remove .icon { width: 14px; height: 14px; }
.chip-remove:hover { color: var(--danger); background: var(--raised); }
.chip[data-active] { border-color: var(--tally); background: color-mix(in srgb, var(--tally) 14%, var(--surface)); }
.chip[data-failed] .chip-main { color: var(--faint); text-decoration: line-through; text-decoration-color: var(--danger); }

.thumb-badge {
  position: absolute;
  right: 4px;
  top: 4px;
  padding: 0 6px;
  border-radius: 5px;
  background: rgb(10 12 24 / 0.75);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 650;
  line-height: 1.6;
}
.new-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin: 0 7px 2px 0;
  border-radius: 50%;
  background: var(--tally);
  vertical-align: middle;
}
.count-new {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--tally);
  color: var(--tally-ink);
  font-weight: 700;
  text-align: center;
}

.follow-btn { flex: none; margin-top: 4px; }
.follow-btn[data-following] { color: var(--muted); }
.follow-btn[data-following]::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tally);
}

.lib-empty {
  padding: 28px 4px;
  color: var(--muted);
  font-size: var(--fs-s);
  max-width: 60ch;
}

@media (hover: none) {
  .lib-actions { opacity: 1; }
}

/* ---------- Fußzeile ---------- */

.footer {
  padding: 18px clamp(16px, 3vw, 32px) 24px;
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  color: var(--faint);
  font-size: var(--fs-xs);
}
.footer p { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; }
.footer .btn-text { font-size: var(--fs-xs); }

/* ---------- Hinweis, Toasts ---------- */

.notice {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 40;
  width: min(380px, calc(100vw - 32px));
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  background: var(--surface);
  box-shadow: var(--shadow-pop);
  font-size: var(--fs-s);
  color: var(--muted);
  animation: rise 0.35s var(--ease);
}
.notice-title { color: var(--text); font-weight: 600; margin-bottom: 4px; font-size: var(--fs-m); }
.notice-actions { display: flex; gap: 16px; align-items: center; margin-top: 12px; }

.toasts {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 60;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  justify-items: center;
  width: max-content;
  max-width: calc(100vw - 32px);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 10px 16px;
  border-radius: var(--r-m);
  background: var(--text);
  color: var(--bg);
  font-size: var(--fs-s);
  box-shadow: var(--shadow-pop);
  pointer-events: auto;
  animation: rise 0.25s var(--ease);
}
.toast[data-type="error"] { background: var(--danger); color: #fff; }
.toast .toast-action {
  border: 0;
  padding: 6px 10px;
  border-radius: var(--r-xs);
  background: color-mix(in srgb, var(--bg) 16%, transparent);
  color: inherit;
  font-weight: 650;
  font-size: var(--fs-s);
}
.toast .toast-action:hover { background: color-mix(in srgb, var(--bg) 26%, transparent); }
.toast[data-leaving] { opacity: 0; transform: translateY(6px); transition: opacity 0.2s, transform 0.2s; }

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
}

/* ---------- Dialoge ---------- */

.dialog {
  width: min(640px, calc(100vw - 24px));
  max-height: min(86dvh, 900px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-l);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-pop);
}
.dialog-wide { width: min(820px, calc(100vw - 24px)); }
.dialog-small { width: min(420px, calc(100vw - 24px)); }
.dialog[open] { animation: dialog-in 0.22s var(--ease); }
.dialog::backdrop {
  background: rgb(10 12 24 / 0.45);
  backdrop-filter: blur(3px);
}
@keyframes dialog-in {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
}
.dialog { overflow: hidden; }
.dialog-inner {
  display: flex;
  flex-direction: column;
  max-height: min(86dvh, 900px);
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px 24px;
}
.dialog-head h2 { font: 600 var(--fs-xl)/1.2 var(--font-display); letter-spacing: -0.015em; }
.dialog-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 24px 8px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dialog-body > * { flex-shrink: 0; }
.dialog-body h3 {
  margin-top: 8px;
  font: 600 var(--fs-m)/1.3 var(--font-display);
  color: var(--text);
}
.dialog-foot {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 24px 18px;
  border-top: 1px solid var(--line);
}
.muted { color: var(--muted); font-size: var(--fs-s); }

.set-group { display: grid; gap: 2px; padding-bottom: 10px; }
.set-group + .set-group { border-top: 1px solid var(--line); padding-top: 6px; }
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 9px 0;
}
.set-text { display: grid; gap: 1px; min-width: 0; }
.set-label { font-weight: 550; }
.set-desc { font-size: var(--fs-s); color: var(--muted); }
.set-note {
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: var(--r-m);
  background: var(--raised);
  font-size: var(--fs-s);
  color: var(--muted);
}
.set-note strong { color: var(--text); }
.hosts { font-weight: 600; color: var(--text); white-space: nowrap; }
.set-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 10px; }

.select {
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: var(--r-s);
  background: var(--surface);
  font-size: var(--fs-s);
  max-width: 50%;
}

.choice {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--r-s);
  background: var(--sunken);
}
.choice label { position: relative; }
.choice input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.choice span {
  display: block;
  padding: 5px 12px;
  border-radius: 7px;
  font-size: var(--fs-s);
  color: var(--muted);
  font-weight: 550;
}
.choice input:checked + span { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line); }
.choice input:focus-visible + span { box-shadow: var(--ring); }

.switch {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  flex: none;
  width: 40px;
  height: 24px;
  margin: 0;
  border-radius: 999px;
  background: var(--line-strong);
  cursor: pointer;
  transition: background-color 0.18s;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.25);
  transition: transform 0.18s var(--ease);
}
.switch:checked { background: var(--tally); }
.switch:checked::after { transform: translateX(16px); }

.keys { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 6px 18px; margin: 0; }
.keys div { display: flex; gap: 10px; align-items: baseline; }
.keys dt { min-width: 92px; }
.keys dd { margin: 0; font-size: var(--fs-s); color: var(--muted); }

/* Diagnose */
.diag {
  display: grid;
  grid-template-columns: minmax(170px, max-content) 1fr;
  margin: 0;
  font-size: var(--fs-s);
  border: 1px solid var(--line);
  border-radius: var(--r-m);
  overflow: hidden;
}
.diag dt,
.diag dd {
  margin: 0;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
}
.diag dt { color: var(--muted); background: var(--raised); }
.diag dd { display: flex; gap: 8px; align-items: baseline; overflow-wrap: anywhere; }
.diag dt:nth-last-of-type(1),
.diag dd:last-of-type { border-bottom: 0; }
.diag small { display: block; color: var(--muted); }
.badge {
  flex: none;
  display: inline-block;
  min-width: 52px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 650;
  text-align: center;
  background: var(--raised);
  color: var(--muted);
}
.badge[data-tone="ok"] { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.badge[data-tone="warn"] { background: color-mix(in srgb, var(--tally) 22%, transparent); color: var(--accent-text); }
.badge[data-tone="bad"] { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

.diag-causes {
  padding: 12px 16px;
  border-radius: var(--r-m);
  background: color-mix(in srgb, var(--tally) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--tally) 40%, var(--line));
}
.diag-causes h3 { margin-top: 0; }
.diag-causes ul { margin: 6px 0 0; padding-left: 20px; font-size: var(--fs-s); display: grid; gap: 4px; }

.diag-log {
  margin: 0;
  padding: 10px 12px 10px 42px;
  max-height: 220px;
  overflow: auto;
  border-radius: var(--r-m);
  background: var(--sunken);
  font-size: var(--fs-xs);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.diag-log li[data-level="error"] { color: var(--danger); }
.diag-log li[data-level="warn"] { color: var(--accent-text); }

/* ---------- Vollbild ---------- */

.stage:fullscreen { border-radius: 0; width: 100%; height: 100%; }
.stage:fullscreen .frame { flex: 1; aspect-ratio: auto; }
.stage:-webkit-full-screen { border-radius: 0; width: 100%; height: 100%; }
.stage:-webkit-full-screen .frame { flex: 1; aspect-ratio: auto; }

/* ---------- Kompaktmodus ---------- */

html[data-mode="compact"] body { height: 100dvh; overflow: hidden; }
html[data-mode="compact"] .topbar,
html[data-mode="compact"] .source-error,
html[data-mode="compact"] .library,
html[data-mode="compact"] .footer,
html[data-mode="compact"] .meta,
html[data-mode="compact"] .modebar,
html[data-mode="compact"] .player-alert,
html[data-mode="compact"] .notice { display: none !important; }
html[data-mode="compact"] .layout { padding: 0; display: block; max-width: none; }
html[data-mode="compact"] .player { max-width: none; min-width: 0; height: 100dvh; }
html[data-mode="compact"] .stage { height: 100%; border-radius: 0; box-shadow: none; }
html[data-mode="compact"] .frame { flex: 1; aspect-ratio: auto; }
html[data-mode="compact"] .compact-only { display: flex; gap: 2px; }
html[data-mode="compact"] .controls-row { --ctl-h: 44px; gap: 4px; padding: 0 6px; }
html[data-mode="compact"] .ctl { width: 34px; height: 34px; }
html[data-mode="compact"] .rate,
html[data-mode="compact"] #ctl-prev,
html[data-mode="compact"] #ctl-next { display: none; }

/* Inaktiv: Leiste schrumpft auf eine Fortschrittslinie, Zeigen darauf öffnet sie wieder */
html[data-mode="compact"][data-idle] .controls { height: 8px; overflow: hidden; border-top: 0; cursor: pointer; }
html[data-mode="compact"][data-idle] .controls-row { visibility: hidden; }
html[data-mode="compact"][data-idle] .progress-line { display: block; top: auto; bottom: 0; height: 8px; }

@media (max-width: 640px) {
  html[data-mode="compact"] .vol,
  html[data-mode="compact"] .time-total { display: none; }
}
@media (max-width: 420px) {
  html[data-mode="compact"] .time { display: none; }
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .player { max-width: none; min-width: 0; }
}

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 10px 12px; }
  .source { order: 3; flex-basis: 100%; max-width: none; }
  #theme-toggle { margin-left: auto; }
  .source-hint { display: none; }
  .seg-label { display: none; }
  .seg-btn, .tool-btn { padding: 0 11px; }
  .seg-btn .tally { display: none; }
  .vol { width: 64px; }
  .modebar { justify-content: center; }
}

@media (max-width: 520px) {
  .rate { display: none; }
  .vol { display: none; }
  .time-total { display: none; }
  .lib-open { grid-template-columns: 88px 1fr; gap: 10px; }
  .tabs { gap: 14px; }
  .ch-tools { margin-left: 0; }
  .follow-btn { padding: 0 9px; }
  .title { font-size: var(--fs-l); }
  .set-row { flex-wrap: wrap; }
  .select { max-width: 100%; }
  .diag { grid-template-columns: 1fr; }
  .diag dt { border-bottom: 0; padding-bottom: 2px; }
}

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