:root {
  /* „Tinte & Pergament": tiefes Tintenblau, warme Schrift, Bernstein als Textmarker */
  --bg: #13151d; --surface: #1b1e29; --surface2: #252937; --line: #2d3141;
  --text: #ece4d4; --muted: #938d82; --accent: #e9a23b; --accent-soft: #e9a23b2e; --on-accent: #1a1408;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
/* Heller Modus des Geräts: warmes Papier, dunkle Tinte */
@media (prefers-color-scheme: light) {
  :root { --bg: #f5efe3; --surface: #ece4d4; --surface2: #e2d8c4; --line: #d8ccb5;
    --text: #22242c; --muted: #7a7266; --accent: #b8661a; --accent-soft: #e9a23b55; --on-accent: #fffaf0; }
}
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { padding-bottom: calc(84px + var(--safe-b)); }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
a { color: inherit; }
.muted { color: var(--muted); }
.icon-btn { min-width: 40px; height: 40px; border-radius: 8px; font-size: 20px; display: inline-grid; place-items: center; }
.icon-btn:hover { background: var(--surface2); }

/* ── Kopfzeile + Seiten ─────────────────────────────────────────── */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: calc(10px + var(--safe-t)) 16px 10px; display: flex; align-items: center; gap: 6px;
  max-width: 760px; margin: 0 auto; }
.top h1 { font-family: var(--serif); font-size: 24px; letter-spacing: .01em; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
main { padding: 0 16px; max-width: 760px; margin: 0 auto; }
h3.section { margin: 22px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.empty { color: var(--muted); padding: 40px 0; text-align: center; }

.prog { height: 3px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.prog i { display: block; height: 100%; background: var(--accent); }

/* Zeilen: Sammlungen, Weiterhören, Folgen – alles gleich aufgebaut */
.row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 12px 4px; border-bottom: 1px solid var(--line); }
.row:hover { background: var(--surface); }
.row .body { flex: 1; min-width: 0; }
.row .t { display: block; font-family: var(--serif); font-size: 17px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row small { color: var(--muted); font-size: 13px; }
.row .num { width: 24px; flex: none; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.row.playing .t { color: var(--accent); }
.row .done { color: var(--accent); }
.row .go { flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; font-size: 14px; }

.col-head { margin: 4px 0 8px; }
.col-head small { color: var(--muted); }
.play-all { margin-top: 10px; padding: 10px 22px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-weight: 700; }
.next-up { display: block; margin-top: 6px; color: var(--muted); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.add-link { display: flex; gap: 8px; margin: 6px 0 4px; }
.add-link input { flex: 1; min-width: 0; padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 16px; }
.add-link button { width: 42px; border-radius: 50%; background: var(--surface2); font-size: 22px; }
.q { background: var(--surface); border-radius: 8px; padding: 8px 12px; margin: 6px 0; font-size: 14px; }
.q span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q small { color: var(--muted); }
.q.error small { color: #ff6b6b; }

/* ── Mini-Player ────────────────────────────────────────────────── */
.mini { position: fixed; left: 50%; transform: translateX(-50%); width: min(744px, calc(100% - 16px));
  bottom: calc(8px + var(--safe-b)); z-index: 10; background: var(--surface2); border-radius: 12px;
  overflow: hidden; box-shadow: 0 6px 24px #0009; }
.mini-bar { height: 2px; background: var(--line); }
.mini-bar div { height: 100%; width: 0; background: var(--accent); }
.mini-row { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 14px; }
.mini-title { flex: 1; min-width: 0; text-align: left; }
.mini-title span, .mini-title small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-title small { color: var(--muted); font-size: 13px; }

/* ── Vollbild-Player ────────────────────────────────────────────── */
.player { position: fixed; inset: 0; z-index: 20; background: var(--bg); }
.p-wrap { height: 100%; max-width: 720px; margin: 0 auto; display: flex; flex-direction: column;
  padding: calc(6px + var(--safe-t)) 16px 0; }
.p-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: none; }
.p-top #p-sub { flex: 1; text-align: center; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#player-close { font-size: 26px; }
.p-title-row { flex: none; display: flex; align-items: flex-start; gap: 10px; margin: 6px 0 10px; }
#p-title { flex: 1; font-family: var(--serif); font-size: 21px; line-height: 1.3; margin: 0; }
.yt { flex: none; font-size: 13px; padding: 5px 10px; border-radius: 999px; background: var(--surface2);
  text-decoration: none; white-space: nowrap; }

/* Transkript: der Hauptinhalt. Aktueller Satz markiert, scrollt mit. */
.lines { flex: 1; min-height: 0; overflow-y: auto; padding: 0 2px; font-family: var(--serif); font-size: 20px; line-height: 1.65;
  -webkit-mask-image: linear-gradient(transparent, #000 12%, #000 85%, transparent); mask-image: linear-gradient(transparent, #000 12%, #000 85%, transparent); }
/* Abstandshalter statt padding: padding würde die Mindesthöhe erzwingen und die Steuerung abschneiden */
.lines::before { content: ""; display: block; height: 25vh; }
.lines::after { content: ""; display: block; height: 40vh; }
.lines span { color: var(--muted); cursor: pointer; border-radius: 4px; transition: color .2s, background .2s; }
.lines span:hover { color: var(--text); }
/* Gelesenes hell, Kommendes gedämpft, aktuelles Wort kräftig grün hinterlegt */
.lines span.past { color: var(--text); }
.lines span.now { color: var(--on-accent); background: var(--accent); box-shadow: 0 0 0 3px var(--accent); border-radius: 3px; }
.lines .none { color: var(--muted); text-align: center; padding-top: 10vh; }
.follow { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(190px + var(--safe-b));
  background: var(--surface2); border-radius: 999px; padding: 8px 16px; font-size: 14px; box-shadow: 0 4px 16px #0008; }

.p-controls { flex: none; padding: 10px 0 calc(14px + var(--safe-b)); border-top: 1px solid var(--line); }
input[type=range] { width: 100%; margin: 0; accent-color: var(--accent); }
.times { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.controls { display: flex; justify-content: center; align-items: center; gap: clamp(8px, 4vw, 28px); margin: 6px 0 10px; }
.controls .icon-btn { font-size: 18px; min-width: 48px; height: 48px; border-radius: 50%; }
.play-btn { width: 62px; height: 62px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: 24px;
  box-shadow: 0 6px 20px var(--accent-soft); }
.extras { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.pill { background: var(--surface2); border-radius: 999px; padding: 6px 14px; font-size: 14px; }
.pill.on { background: var(--accent); color: var(--on-accent); }

/* ── Login ──────────────────────────────────────────────────────── */
.login { max-width: 340px; margin: 18vh auto 0; padding: 0 16px; }
.login input { width: 100%; padding: 12px; margin: 6px 0; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 16px; }
.login h1 { font-family: var(--serif); }
.login button { width: 100%; padding: 12px; margin-top: 10px; border-radius: 999px; background: var(--accent);
  color: var(--on-accent); font-weight: 700; }
.login .err { color: #ff6b6b; }

.snip { display: block; font-size: 15px; color: var(--text); }
.snip { font-family: var(--serif); }
.snip mark { background: var(--accent-soft); color: var(--text); border-radius: 3px; padding: 0 2px; }

.sheet { position: fixed; inset: 0; z-index: 30; background: #0008; display: flex; align-items: flex-end; justify-content: center; }
.sheet-box { width: min(560px, 100%); background: var(--surface); border-radius: 16px 16px 0 0;
  padding: 16px 16px calc(16px + var(--safe-b)); }
.sheet h4 { margin: 10px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips .pill { padding: 9px 14px; font-size: 15px; }
.pill.wide { display: block; width: 100%; margin-top: 16px; padding: 12px; font-weight: 600; }
.small { font-size: 13px; }

/* ── Chat ──────────────────────────────────────────────────────── */
.p-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; flex: none; max-width: 50%; }
.p-actions .yt { font: inherit; font-size: 13px; color: var(--text); }
.chat-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 4px 0 10px; }
.chat-bar select { background: var(--surface2); color: var(--text); border: 0; border-radius: 999px; padding: 7px 12px; font: inherit; font-size: 14px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 5px 6px 5px 12px; font-size: 13px; max-width: 100%; }
.chip button { width: 22px; height: 22px; border-radius: 50%; background: var(--surface2); }
.msgs { margin: 16px 0 12px; display: flex; flex-direction: column; gap: 12px; }
.msg { border-radius: 14px; padding: 10px 14px; max-width: 92%; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--on-accent); }
.msg.ai { align-self: flex-start; background: var(--surface); }
.md { font-family: var(--serif); font-size: 17px; line-height: 1.55; }
.md p { margin: 0 0 8px; } .md ul, .md ol { margin: 0 0 8px; padding-left: 22px; } .md h4 { margin: 10px 0 6px; }
.md code { background: var(--surface2); padding: 1px 5px; border-radius: 4px; font-size: 14px; }
.cite { background: var(--accent-soft); color: var(--text); border-radius: 6px; padding: 0 6px; font-size: 13px; font-family: -apple-system, sans-serif; }
.msg-actions { display: flex; gap: 14px; margin-top: 4px; }
.link { color: var(--muted); font-size: 13px; }
.composer { position: sticky; bottom: calc(84px + var(--safe-b)); display: flex; gap: 8px; align-items: flex-end;
  background: var(--bg); padding: 8px 0; }
.composer textarea { flex: 1; resize: none; padding: 10px 14px; border-radius: 18px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px; line-height: 1.4; }
.send { width: 42px; height: 42px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: 20px; font-weight: 700; flex: none; }
.pick-q { width: 100%; padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 16px; }
.pick-list { max-height: 50vh; overflow-y: auto; margin-top: 8px; }
