:root {
  --bg: #f6f5f2; --card: #fff; --text: #1d1c1a; --muted: #6f6b64; --line: #e4e1da;
  --accent: #2f6f5e; --ok: #2f7d4f; --warn: #b7791f; --err: #c2413a; --run: #2b6cb0;
  --chip: #efece6;
  --k-dai: #d0453d; --k-host_read: #d9901a; --k-promo: #7c5cd6;
  /* Abstände: ein Raster für alles */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s6: 24px; --s8: 32px;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615; --card: #1f1f1d; --text: #ecebe7; --muted: #9c988f; --line: #33322f;
    --accent: #6cc2a8; --ok: #6cc28a; --warn: #e2b04a; --err: #ef7d75; --run: #7fb2ef; --chip: #2a2a27;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
h1, h2, p, ul, blockquote { margin: 0; }
h1 { font-size: 22px; line-height: 1.25; }
h2 { font-size: 16px; }
a { color: var(--accent); }
ul { padding-left: 20px; }
code { font-size: 13px; word-break: break-all; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--err); }

/* ---------- Gerüst ---------- */
header { display: flex; align-items: center; gap: var(--s6); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); background: var(--card); position: sticky; top: 0; z-index: 2; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
nav { display: flex; gap: var(--s4); }
nav a { color: var(--muted); text-decoration: none; }
nav a.active { color: var(--text); font-weight: 600; }
main { max-width: 1100px; margin: 0 auto; padding: var(--s6) var(--s4) 64px; }

/* Seite = Stapel mit festem Abstand; Überschriften leiten neue Abschnitte mit mehr Luft ein. */
#app, .stack { display: flex; flex-direction: column; gap: var(--s4); }
#app > h2 { margin-top: var(--s4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s2); }

/* ---------- Bausteine ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); }
.warnbox { border-color: var(--warn); }
.errbox { border-color: var(--err); }
.grid { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat { gap: var(--s1); }
.stat .value { font-size: 24px; font-weight: 700; line-height: 1.2; }
.stat .label { color: var(--muted); font-size: 13px; }
.row { display: flex; gap: var(--s2) var(--s3); align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.nowrap { flex-wrap: nowrap; }
.head { gap: var(--s4); align-items: flex-start; }
.head > div { display: flex; flex-direction: column; gap: var(--s2); min-width: 0; }
.cover { display: inline-block; flex: none; border-radius: 6px; object-fit: cover; background: var(--chip); }
.label-muted { font-size: 13px; color: var(--muted); }

.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 99px; font-size: 12px; background: var(--chip); white-space: nowrap; }
.s-ready { color: var(--ok); } .s-failed { color: var(--err); } .s-queued { color: var(--warn); }
.s-downloading, .s-transcribing, .s-detecting, .s-cutting { color: var(--run); }
.s-skipped, .s-new, .s-purged { color: var(--muted); }
/* Laufende Schritte pulsieren */
.chip.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; transform: scale(.7); } }

table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
th, td { text-align: left; padding: var(--s2) var(--s3); border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; white-space: nowrap; }
td .row { gap: var(--s3); }
td .row > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); }

/* ---------- Formulare & Knöpfe ---------- */
button, .btn { font: inherit; display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--text); cursor: pointer; text-decoration: none; line-height: 1.3; }
button:hover:not(:disabled), .btn:hover { border-color: var(--muted); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.small { padding: 2px 8px; font-size: 12px; }
button:disabled { opacity: .5; cursor: default; }
/* Knopf, dessen Aktion gerade läuft */
button.busy { opacity: .8; cursor: progress; }
button.busy::after { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
input[type=text], input[type=password], textarea { font: inherit; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--text); width: 100%; }
textarea { min-height: 120px; font-family: ui-monospace, monospace; font-size: 13px; }
label { display: inline-flex; align-items: center; gap: var(--s2); }
.login { max-width: 340px; margin: 80px auto 0; width: 100%; }

/* ---------- Laden ---------- */
#progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 10; overflow: hidden; opacity: 0; transition: opacity .2s; pointer-events: none; }
#progress::before { content: ""; position: absolute; inset: 0; width: 40%; background: var(--accent); animation: slide 1s ease-in-out infinite; }
body.loading #progress { opacity: 1; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
/* Beim Seitenwechsel bleibt die alte Seite gedimmt stehen, bis die neue da ist. */
body.navigating #app { opacity: .5; pointer-events: none; transition: opacity .15s .1s; }
.loader { display: flex; align-items: center; gap: var(--s2); color: var(--muted); padding: var(--s8) 0; }
.loader::before { content: ""; width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }

/* Verarbeitungsschritte einer Folge */
.steps { display: flex; gap: var(--s1); flex-wrap: wrap; }
.steps span { flex: 1 1 120px; padding: 6px 10px; border-radius: 8px; background: var(--chip); color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.steps span.done { color: var(--ok); }
.steps span.now { color: var(--run); background: color-mix(in srgb, var(--run) 15%, var(--chip)); font-weight: 600; }
.steps span.now::before { content: ""; width: 10px; height: 10px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }

/* ---------- Werbeblöcke ---------- */
.k-dai { background: var(--k-dai); } .k-host_read { background: var(--k-host_read); } .k-promo { background: var(--k-promo); }
.cut { gap: var(--s2); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.cut.off { opacity: .65; }
.cut blockquote { padding: 6px 10px; border-left: 3px solid var(--line); font-size: 14px; }
.cut blockquote em { color: var(--muted); }
.cut audio { height: 32px; max-width: 100%; }

/* ---------- Zeitstrahl ---------- */
.timeline { gap: var(--s2); }
.timeline audio { width: 100%; margin-top: var(--s2); }
.tl { position: relative; height: 30px; border-radius: 6px; background: color-mix(in srgb, var(--ok) 28%, var(--chip)); cursor: pointer; }
.tl .seg { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.tl .seg:hover { outline: 2px solid var(--text); z-index: 1; }
.tl .seg.off { background: repeating-linear-gradient(45deg, transparent 0 4px, var(--muted) 4px 6px); opacity: .7; }
.tl .ch { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--text); opacity: .55; }
.tl .playhead { position: absolute; top: -6px; bottom: -6px; width: 2px; background: var(--run); pointer-events: none; }
.tl-axis { position: relative; height: 18px; }
.tl-axis span { position: absolute; transform: translateX(-50%); }
.tl-axis span:first-child { transform: none; }
.tl-gap { height: var(--s2); }
.legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.legend i.off { background: repeating-linear-gradient(45deg, transparent 0 3px, var(--muted) 3px 5px); }
.legend i.ch { width: 2px; background: var(--text); }

/* ---------- Balken ---------- */
.bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--chip); }
.mini { height: 4px; border-radius: 2px; background: var(--chip); margin-top: var(--s1); min-width: 60px; }
.mini span { display: block; height: 100%; border-radius: 2px; background: var(--k-dai); }

.history { display: flex; flex-direction: column; gap: 2px; }
.toast { position: fixed; bottom: var(--s4); left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: var(--s2) 14px; border-radius: 8px; z-index: 10; }

@media (max-width: 640px) {
  .hide-sm { display: none; }
  .head .cover { width: 56px; height: 56px; }
  main { padding-top: var(--s4); }
}
