:root {
  --bg: #14110e;
  --bg-elev: #1f1a16;
  --bg-elev2: #2a231d;
  --surface: #211c18;
  --text: #f3ece2;
  --muted: #b8ae9f;
  --faint: #8a8073;
  --primary: #2fcfa0;
  --primary-dim: #12a17a;
  --amber: #f0b45e;
  --line: #342d25;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }

/* ---------- Icons ---------- */
.ic { display: block; flex: none; }
button.has-label, a.has-label { display: inline-flex; align-items: center; gap: 8px; }
button.has-label .ic, a.has-label .ic { flex: none; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
img { display: block; }

/* ---------- Login ---------- */
.login {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 50% -10%, #1c2a24, var(--bg));
}
.login-card {
  display: flex; flex-direction: column; gap: 12px;
  width: min(360px, 90vw); padding: 32px;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 20px;
}
.login-logo { font-size: 34px; font-weight: 800; letter-spacing: -1px; }
.login-sub { margin: -6px 0 8px; color: var(--muted); }
.login-card input {
  padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 15px;
}
.login-card button {
  padding: 12px; border: 0; border-radius: 999px; font-weight: 700; font-size: 15px;
  background: var(--primary); color: #08211a;
}
.login-error { color: #f2b8af; font-size: 13px; min-height: 16px; }

/* ---------- Auth (Login/Registrierung/SSO/QR) ---------- */
.auth {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 50% -10%, #1c2a24, var(--bg));
}
.auth-shell { display: flex; align-items: stretch; gap: 22px; }
.auth-card {
  width: min(380px, 92vw); padding: 30px 28px;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 20px;
}
/* QR steht dauerhaft daneben, kein Umweg über einen eigenen Schritt. */
.qr-side {
  width: 280px; padding: 30px 24px;
  display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: 20px;
}
.qr-side .auth-hint { text-align: center; }
.qr-toggle { display: none; }
@media (max-width: 880px) {
  .auth-shell { flex-direction: column; align-items: center; }
  .qr-side { width: min(380px, 92vw); display: none; }
  .qr-side.show { display: flex; }
  .qr-toggle { display: inline; }
}
.auth-logo { display: flex; align-items: center; gap: 12px; font-size: 32px; font-weight: 800; letter-spacing: -1px; margin-bottom: 6px; }
.auth-logo-mark { display: inline-flex; flex: none; filter: drop-shadow(0 3px 10px rgba(47,207,160,.3)); }
.auth-logo-mark svg { width: 38px; height: 38px; }
.auth-sub { font-size: 15px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.auth-msg { font-size: 13px; min-height: 18px; margin: 6px 0 10px; }
.auth-msg.err { color: #f2b8af; }
.auth-msg.ok { color: var(--primary); }
.auth-step { display: flex; flex-direction: column; gap: 12px; }
.auth-step input {
  padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 15px;
}
.auth-email { font-size: 14px; color: var(--muted); }
.auth-primary {
  padding: 12px; border: 0; border-radius: 999px; font-weight: 700; font-size: 15px;
  background: var(--primary); color: #08211a;
}
.auth-primary:hover { filter: brightness(1.08); }
.sso-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.sso-btn {
  display: block; text-align: center; text-decoration: none;
  padding: 11px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 14px; font-weight: 600;
}
.sso-btn:hover { background: var(--bg-elev2); }
.auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.auth-hint { font-size: 13px; color: var(--muted); text-align: center; line-height: 1.5; }
.auth-hint.ok { color: var(--primary); }
.auth-hint.err { color: #f2b8af; }
#ar-invite { text-transform: uppercase; letter-spacing: .06em; }
/* Einladungsverwaltung (Alpha) */
.inv-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.inv-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px;
}
.inv-code { font-size: 16px; font-weight: 700; letter-spacing: .08em; }
.inv-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.qr-box { display: grid; place-items: center; background: #fff; border-radius: 14px; padding: 14px; }
.qr-box img { width: 220px; height: 220px; display: block; }
.user-label { font-size: 12px; color: var(--faint); margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- „Hinzufügen"-Nav + Create-View ---------- */
.nav-create { color: var(--text); font-weight: 600; }
.nav-create .ic { color: var(--primary); }
.nav-create:hover { background: var(--bg-elev2); }
.create-card {
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px; margin-bottom: 16px;
}
.cc-title { display: flex; align-items: center; gap: 9px; font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.cc-title .ic { color: var(--primary); flex: none; }
.cc-hint { font-size: 13px; color: var(--muted); margin-bottom: 14px; line-height: 1.5; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  border: 2px dashed var(--line); border-radius: 12px; padding: 30px; text-align: center;
  color: var(--muted); cursor: pointer; transition: .15s; font-weight: 600;
}
.dropzone .ic { color: var(--faint); transition: color .15s; }
.dropzone:hover, .dropzone.over { border-color: var(--primary); color: var(--text); background: var(--bg-elev2); }
.dropzone:hover .ic, .dropzone.over .ic { color: var(--primary); }
.cc-row { display: flex; gap: 10px; }
.cc-input {
  flex: 1; padding: 11px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 14px;
}
.create-status { font-size: 14px; min-height: 20px; color: var(--muted); }
.create-status.ok { color: var(--primary); }
.create-status.err { color: #f2b8af; }
.mg-field { margin-bottom: 10px; }
textarea.cc-input { resize: vertical; font-family: inherit; line-height: 1.5; }
/* Metadaten-Anklicken */
.meta-fieldsel { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 12px; }
.meta-fbtn { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 6px 14px; font-size: 13px; font-weight: 600; cursor: pointer; }
.meta-fbtn.active { background: var(--primary); color: #08211a; border-color: var(--primary); }
.meta-blocks { max-height: 420px; overflow-y: auto; border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: var(--surface); }
.meta-block { padding: 7px 10px; border-radius: 8px; cursor: pointer; color: var(--text); line-height: 1.35; border-left: 3px solid transparent; margin-bottom: 2px; }
.meta-block:hover { background: var(--bg-elev2); }
.meta-block.bold { font-weight: 700; }
.meta-block.marked { background: #123d30; border-left-color: var(--primary); }
.meta-block.marked[data-field="authors"] { border-left-color: var(--amber); }
.meta-block.marked[data-field="abstract"] { border-left-color: #7db5ff; }
.meta-block.marked[data-field="year"], .meta-block.marked[data-field="doi"], .meta-block.marked[data-field="isbn"] { border-left-color: #c58cff; }
.meta-block.marked[data-field="extra"] { border-left-color: #9aa0a6; }
.meta-pagesel { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; max-height: 84px; overflow-y: auto; }
.meta-pbtn { min-width: 32px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 8px; padding: 5px 9px; font-size: 13px; font-weight: 600; cursor: pointer; }
.meta-pbtn.active { background: var(--primary); color: #08211a; border-color: var(--primary); }
.mg-label { display: block; font-size: 12px; color: var(--faint); margin-bottom: 4px; }
.mg-hint { font-size: 12px; color: var(--faint); margin-top: 5px; line-height: 1.45; }
.voice-prev { display: grid; place-items: center; padding: 0; width: 46px; flex: none; background: var(--bg-elev2); color: var(--text); border-radius: 999px; }
.voice-prev:hover { filter: brightness(1.2); }
.btn.danger { background: #73251a; color: #f9ddd8; }
.btn.danger:hover { filter: brightness(1.12); }
.btn { text-decoration: none; }
select.cc-input { appearance: auto; }

/* ---------- Popup-Player (PiP) ---------- */
.pip-body { margin: 0; background: var(--bg-elev); color: var(--text); font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif; }
.pip { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.pip-cover { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: #123d30; flex: none; }
.pip-meta { flex: 1; min-width: 0; }
.pip-title { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pip-chapter { font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pip-ctr { display: flex; align-items: center; gap: 4px; }
.pip-ctr button { display: grid; place-items: center; background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 50%; }
.pip-ctr button:hover { color: var(--text); }
.pip-ctr .pip-play { width: 40px; height: 40px; background: var(--primary); color: #08211a; }
.pip-ctr .pip-play:hover { color: #08211a; }
/* PiP mit Seitenansicht (Hochformat) */
.pip-body.pip-pages { background: var(--bg-elev); }
.pipp { display: flex; flex-direction: column; height: 100vh; }
.pipp-page { width: 100%; flex: 1; min-height: 0; object-fit: contain; background: #fff; }
.pipp-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }

/* ---------- Geräte / Fernsteuerung ---------- */
.p-devwrap { position: relative; }
.p-devbadge {
  position: absolute; top: -3px; right: -3px; display: grid; place-items: center;
  min-width: 15px; height: 15px; padding: 0 4px; border-radius: 999px;
  background: var(--primary); color: #08211a; font-size: 9px; font-weight: 800;
  border: 2px solid var(--bg-elev);
}
.devices-pop {
  position: absolute; bottom: 46px; right: 0; width: 280px; z-index: 60;
  background: var(--bg-elev2); border: 1px solid var(--line); border-radius: 14px; padding: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.5);
}
.dev-head { font-size: 13px; font-weight: 700; color: var(--muted); padding: 4px 6px 8px; }
.dev-empty { font-size: 13px; color: var(--faint); padding: 8px 6px; }
.dev-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 8px; }
.dev-row:hover { background: var(--bg-elev); }
.dev-info { flex: 1; min-width: 0; }
.dev-name { font-size: 13px; font-weight: 600; }
.dev-doc { font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dev-btn { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--primary); color: #08211a; font-size: 13px; cursor: pointer; }

/* ---------- App layout ---------- */
.app {
  display: grid;
  grid-template-columns: 250px 1fr;
  grid-template-rows: 1fr auto;   /* Player-Zeile klappt zu, wenn nichts spielt */
  grid-template-areas: "side main" "player player";
  height: 100vh;
}
.sidebar {
  grid-area: side; background: #100d0b; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 18px 14px; gap: 14px; overflow: hidden;
}
.brand { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; display: flex; align-items: center; gap: 10px; padding: 2px 4px; }
.brand-logo { display: inline-flex; flex: none; filter: drop-shadow(0 3px 8px rgba(47,207,160,.28)); }
.brand-logo svg { display: block; }
.search-wrap { position: relative; display: flex; align-items: center; }
.search-ic { position: absolute; left: 12px; display: grid; place-items: center; color: var(--faint); pointer-events: none; }
.search {
  width: 100%; padding: 10px 12px 10px 34px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font-size: 14px;
}
.search:focus { outline: none; border-color: var(--primary-dim); }
.nav { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }   /* kein sichtbarer Balken, Rad/Wischen scrollt weiter */
/* Seitenleiste einklappbar: Toggle im Kopf, Ausklappen ueber den kleinen Knopf oben links im Inhalt. */
.side-toggle { margin-left: auto; background: transparent; border: 0; color: var(--faint); display: grid; place-items: center; width: 26px; height: 26px; border-radius: 7px; }
.side-toggle:hover { color: var(--text); background: var(--bg-elev); }
.side-expand { position: fixed; top: 12px; left: 12px; z-index: 40; display: none; background: var(--bg-elev); border: 1px solid var(--line); color: var(--muted); width: 32px; height: 32px; border-radius: 9px; place-items: center; }
.side-expand:hover { color: var(--text); }
body.side-collapsed .app { grid-template-columns: 0 1fr; }
body.side-collapsed .sidebar { display: none; }
body.side-collapsed .side-expand { display: grid; }
.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px; color: var(--faint); margin: 14px 6px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  text-align: left; background: transparent; border: 0; color: var(--muted);
  padding: 9px 11px; border-radius: 9px; font-size: 14px; width: 100%;
}
.nav-item .ic { color: var(--faint); transition: color .15s; }
.nav-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item:hover { background: var(--bg-elev); color: var(--text); }
.nav-item:hover .ic { color: var(--muted); }
.nav-item.active { background: var(--bg-elev2); color: var(--text); font-weight: 600; }
.nav-item.active .ic { color: var(--primary); }
.nav-create { color: var(--text); }
.sidebar-foot { border-top: 1px solid var(--line); padding-top: 12px; }
/* Impressum/Datenschutz: auf der Anmeldeseite unten, in der App unter dem Konto. */
.legal { display: flex; gap: 14px; justify-content: center; font-size: 12px; }
.legal a, .legal a:visited { color: var(--faint); text-decoration: none; }
.legal a:hover { color: var(--text); text-decoration: underline; }
.legal-menu { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.linkbtn { background: transparent; border: 0; color: var(--faint); font-size: 13px; padding: 4px; }
.linkbtn:hover { color: var(--text); }

/* Konto-Chip („PB in der Ecke") + Aufklapp-Menü */
.account-wrap { position: relative; }
.account { display: inline-flex; padding: 3px; background: transparent; border: 0; border-radius: 999px; }
.avatar {
  display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(150deg, #2a6b57, #17493a); color: #d9f5ea;
  font-size: 15px; font-weight: 700; border: 1px solid var(--line);
}
.account:hover .avatar { border-color: var(--primary); }
.account-menu {
  position: absolute; right: 0; top: 48px; width: 232px; z-index: 60;
  background: var(--bg-elev2); border: 1px solid var(--line); border-radius: 14px; padding: 8px;
  box-shadow: 0 14px 36px rgba(0,0,0,.55);
}
.am-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.am-name { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.am-mail { font-size: 12px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.am-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: transparent; border: 0; color: var(--muted); padding: 9px 10px; border-radius: 9px; font-size: 14px; }
.am-item .ic { color: var(--faint); }
.am-item:hover { background: var(--bg-elev); color: var(--text); }
.am-item:hover .ic { color: var(--muted); }

.main { grid-area: main; overflow-y: auto; padding: 26px 30px 40px; }
.view { max-width: 1100px; margin: 0 auto; }

/* ---------- Library grid ---------- */
.hero-title { font-size: 30px; font-weight: 800; letter-spacing: -0.5px; margin: 2px 0 20px; }
.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 20px 18px;
}
.card {
  background: var(--bg-elev); border: 1px solid transparent; border-radius: var(--radius);
  padding: 12px; cursor: pointer; transition: background .15s, transform .15s;
}
.card:hover { background: var(--bg-elev2); transform: translateY(-2px); }
.cover {
  position: relative; width: 100%; aspect-ratio: 0.72; border-radius: 10px; overflow: hidden;
  background: linear-gradient(160deg, #123d30, #0c261e); margin-bottom: 10px;
  display: grid; place-items: center;
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover .initial { font-size: 40px; font-weight: 800; color: #b9f0dc; }
.cover .play-fab {
  position: absolute; right: 8px; bottom: 8px; width: 44px; height: 44px; border-radius: 50%;
  background: var(--primary); color: #08211a; border: 0; font-size: 18px; display: grid; place-items: center;
  opacity: 0; transform: translateY(6px); transition: .15s; box-shadow: 0 6px 16px rgba(0,0,0,.4);
}
.card:hover .play-fab { opacity: 1; transform: translateY(0); }
.card-title { font-size: 14px; font-weight: 600; line-height: 1.3; max-height: 2.6em; overflow: hidden; }
.card-sub { font-size: 12px; color: var(--faint); margin-top: 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.badge {
  position: absolute; left: 8px; top: 8px; font-size: 11px; padding: 3px 8px; border-radius: 999px;
  background: rgba(0,0,0,.55); color: var(--amber); backdrop-filter: blur(4px);
}
.prog-strip { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: rgba(0,0,0,.45); }
.prog-strip > i { display: block; height: 100%; background: var(--primary); }
.empty { color: var(--muted); padding: 60px 0; text-align: center; }

/* ---------- Home / „Für dich"-Feed ---------- */
.greeting { font-size: 32px; font-weight: 800; letter-spacing: -0.6px; margin: 2px 0 22px; }
.hero {
  position: relative; height: 232px; border-radius: 18px; overflow: hidden;
  cursor: pointer; margin-bottom: 36px; box-shadow: 0 16px 42px rgba(0,0,0,.45);
  background: linear-gradient(160deg, #123d30, #0c261e);
}
.hero:hover .hero-play { transform: scale(1.06); }
.hero-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.hero-scrim { position: absolute; inset: 0;
  background: linear-gradient(90deg, rgba(10,12,10,.94) 0%, rgba(10,12,10,.72) 36%, rgba(10,12,10,.10) 100%),
              linear-gradient(0deg, rgba(10,12,10,.6), transparent 62%); }
.hero-body { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 12px; padding: 26px 30px; max-width: 700px; }
.hero-kicker { font-size: 11px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; color: var(--primary); }
.hero-row { display: flex; align-items: flex-end; gap: 18px; }
.hero-tw { flex: 1; min-width: 0; }
.hero-title2 { font-size: 28px; font-weight: 800; letter-spacing: -0.5px; line-height: 1.14; max-height: 2.3em; overflow: hidden; }
.hero-authors { color: var(--muted); font-size: 14px; margin-top: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hero-play { flex: none; display: grid; place-items: center; width: 56px; height: 56px; border-radius: 50%; background: var(--primary); color: #08211a; border: 0; box-shadow: 0 8px 22px rgba(0,0,0,.45); transition: transform .1s; }
.hero-play:active { transform: scale(0.96); }
.hero-prog { height: 5px; border-radius: 999px; background: rgba(255,255,255,.22); overflow: hidden; max-width: 440px; }
.hero-prog > i { display: block; height: 100%; background: var(--primary); border-radius: 999px; }

.feed-row { margin-bottom: 30px; }
.row-head { display: flex; align-items: center; justify-content: space-between; margin: 0 2px 14px; }
.row-title { font-size: 19px; font-weight: 700; letter-spacing: -0.3px; margin: 0; }
.row-scroll { display: flex; gap: 16px; overflow-x: auto; padding: 2px 2px 12px; scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
.row-scroll::-webkit-scrollbar { height: 8px; }
.row-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 999px; }
.row-scroll::-webkit-scrollbar-track { background: transparent; }
.card-compact { flex: none; width: 150px; scroll-snap-align: start; }

/* ---------- Karten-„⋯" + Kontextmenü ---------- */
.card-more { position: absolute; top: 8px; right: 8px; z-index: 4; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: rgba(0,0,0,.5); color: #fff; border: 0; opacity: 0; transition: opacity .12s; }
.card:hover .card-more { opacity: 1; }
.card-more:hover { background: rgba(0,0,0,.72); }
.ctx-menu { position: fixed; z-index: 200; min-width: 214px; background: var(--bg-elev2); border: 1px solid var(--line); border-radius: 12px; padding: 6px; box-shadow: 0 16px 40px rgba(0,0,0,.55); }
.ctx-item { display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; background: transparent; border: 0; color: var(--text); padding: 9px 11px; border-radius: 8px; font-size: 14px; }
.ctx-item .ic { color: var(--muted); flex: none; }
.ctx-item:hover { background: var(--bg-elev); }
.ctx-item.danger, .ctx-item.danger .ic { color: #f2b8af; }
.ctx-item.current, .ctx-item.current .ic { color: var(--primary); }
.ctx-sep { height: 1px; background: var(--line); margin: 5px 4px; }

/* ---------- Modal (Ordner verwalten) ---------- */
.modal-ov { position: fixed; inset: 0; z-index: 150; background: rgba(0,0,0,.5); display: grid; place-items: center; padding: 20px; }
.modal { width: min(460px, 94vw); max-height: 82vh; overflow-y: auto; overflow-x: hidden; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 18px; padding: 22px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-title { font-size: 19px; font-weight: 800; }
.modal-x { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--bg-elev2); color: var(--muted); border: 0; }
.modal-x:hover { color: var(--text); }
/* Ordner-Verwalter: Zeilen muessen schrumpfen duerfen, sonst schieben die
   Eingabefelder (Standardbreite ~170px) die Knoepfe aus dem Dialog. */
.modal.fm { width: min(560px, 94vw); }
.fm-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; min-width: 0; }
.fm-row .cc-input { flex: 1 1 0; min-width: 0; width: auto; }
.fm-indent { display: flex; align-items: center; }
.fm-indent::before { content: ""; flex: none; border-left: 1px solid var(--line); align-self: stretch;
  margin: 2px 10px 2px 0; }
.fm-count { min-width: 26px; text-align: center; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.fm-btn { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border: 0; border-radius: 9px; background: var(--bg-elev2); color: var(--text); }
.fm-btn:hover { filter: brightness(1.2); }
.fm-btn.danger { color: #f2b8af; }

/* ---------- Dialoge (eigene statt window.*) + Toast ---------- */
.modal.dialog { width: min(400px, 94vw); }
.dialog-msg { font-size: 14px; line-height: 1.55; color: var(--text); margin-bottom: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.modal.dialog .cc-input { width: 100%; }
.toast {
  position: fixed; left: 50%; bottom: 108px; transform: translate(-50%, 20px);
  background: var(--bg-elev2); color: var(--text); border: 1px solid var(--line);
  padding: 12px 18px; border-radius: 12px; font-size: 14px; z-index: 300;
  box-shadow: 0 12px 32px rgba(0,0,0,.5); opacity: 0; pointer-events: none; transition: .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { border-color: var(--primary); color: var(--primary); }
/* ---------- Kontext-Einblendung erwähnter Abbildungen/Tabellen ---------- */
.fig-panel {
  position: fixed; right: 22px; top: 96px; width: 300px; z-index: 90;
  background: var(--bg-elev2); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.5); cursor: pointer;
  animation: figpop .18s ease;
}
@keyframes figpop { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.fig-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.fig-label { font-size: 13px; font-weight: 700; color: var(--primary); }
.fig-x { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: transparent; border: 0; color: var(--muted); }
.fig-x:hover { color: var(--text); background: var(--bg-elev); }
.fig-crop { width: 100%; background-repeat: no-repeat; background-color: #fff; border-radius: 8px; min-height: 80px; }
.fig-sub { font-size: 12px; color: var(--faint); margin-top: 8px; }
@media (max-width: 1180px) { .fig-panel { display: none; } }

.nav-group-row { display: flex; align-items: center; justify-content: space-between; }
.nav-group-btn { background: transparent; border: 0; color: var(--faint); display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; }
.nav-group-btn:hover { color: var(--text); background: var(--bg-elev); }
.nav-hint { font-size: 12px; color: var(--faint); padding: 4px 10px 8px; line-height: 1.4; }

/* ---------- Playlist-Kopf ---------- */
.pl-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.pl-head .hero-title { margin: 0 0 4px; }
.pl-head-info .meta { color: var(--faint); font-size: 13px; }
.pl-head .doc-actions { margin: 0; }

/* ---------- Statistik ---------- */
.stat-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.stat-kpi { background: var(--bg-elev2); border: 1px solid var(--line); border-radius: 12px; padding: 16px; text-align: center; }
.stat-val { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.stat-lbl { font-size: 12px; color: var(--faint); margin-top: 4px; }
.stat-chart { display: flex; align-items: flex-end; gap: 6px; height: 120px; margin: 10px 0 18px; }
.stat-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.stat-bar { width: 100%; max-width: 22px; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 3px; }
.stat-day { font-size: 9px; color: var(--faint); }
.stat-top { display: flex; flex-direction: column; gap: 2px; }
.stat-toprow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.stat-topname { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat-topsec { font-size: 13px; color: var(--faint); font-variant-numeric: tabular-nums; flex: none; }
.stat-kpis { grid-template-columns: repeat(4, 1fr); }
.stat-sub { font-size: 11px; color: var(--faint); margin-top: 1px; }
/* Balken-Liste (Top-Doks / Ordner / Kategorien) */
.bl-row { display: flex; align-items: center; gap: 12px; padding: 7px 2px; }
.bl-name { width: 34%; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: none; }
.bl-track { flex: 1; height: 8px; background: var(--bg-elev2); border-radius: 999px; overflow: hidden; }
.bl-track > i { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.bl-sec { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; width: 64px; text-align: right; flex: none; }
/* Aktivitäts-Heatmap */
.heat { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 1fr); gap: 4px; overflow-x: auto; padding-bottom: 4px; }
.heat-cell { width: 13px; height: 13px; border-radius: 3px; background: var(--bg-elev2); }
.heat-cell.empty { background: transparent; }
.heat-cell.l0 { background: var(--bg-elev2); }
.heat-cell.l1 { background: rgba(47,207,160,.28); }
.heat-cell.l2 { background: rgba(47,207,160,.5); }
.heat-cell.l3 { background: rgba(47,207,160,.75); }
.heat-cell.l4 { background: var(--primary); }
.wd-chart { height: 90px; }
.wd-chart .stat-bar { max-width: 40px; }

/* ---------- Document view ---------- */
.doc-head { display: flex; gap: 24px; align-items: flex-end; margin-bottom: 22px; }
.doc-cover { width: 190px; aspect-ratio: 0.72; border-radius: 12px; overflow: hidden; box-shadow: 0 12px 30px rgba(0,0,0,.5); flex: none; background: #123d30; }
.doc-cover img { width: 100%; height: 100%; object-fit: cover; }
.doc-info h1 { font-size: 32px; margin: 0 0 6px; letter-spacing: -0.5px; }
.doc-info .authors { color: var(--muted); margin-bottom: 4px; }
.doc-info .meta { color: var(--faint); font-size: 13px; }
.doc-actions { display: flex; gap: 12px; margin-top: 16px; }
.btn {
  border: 0; border-radius: 999px; padding: 11px 22px; font-weight: 700; font-size: 14px;
  background: var(--bg-elev2); color: var(--text);
}
.btn.primary { background: var(--primary); color: #08211a; }
.btn:hover { filter: brightness(1.08); }
.back { background: transparent; border: 0; color: var(--muted); font-size: 14px; margin-bottom: 14px; padding: 4px 0; }
.back:hover { color: var(--text); }

.tabs { display: flex; gap: 6px; background: var(--bg-elev); padding: 5px; border-radius: 999px; width: max-content; max-width: 100%; margin: 8px 0 18px; flex-wrap: wrap; }
.tab { border: 0; background: transparent; color: var(--muted); padding: 8px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; }
.tab.active { background: var(--primary); color: #08211a; }

/* ---------- Übersicht / Insights ---------- */
.info-card { background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; margin-bottom: 16px; }
.info-h { font-size: 13px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--faint); margin-bottom: 12px; }
.abstract { margin: 0; color: var(--text); line-height: 1.65; font-size: 15px; white-space: pre-wrap; }
.detail-grid { display: grid; grid-template-columns: max-content 1fr; gap: 10px 24px; margin: 0; }
.detail-grid dt { color: var(--faint); font-size: 13px; }
.detail-grid dd { margin: 0; color: var(--text); font-size: 14px; overflow-wrap: anywhere; }
.status-chip { display: inline-flex; align-items: center; gap: 9px; padding: 9px 16px; border-radius: 999px; background: var(--bg-elev2); color: var(--amber); font-size: 14px; font-weight: 600; }
.status-chip .status-dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; animation: livepulse 1.6s infinite; }
.status-chip.status-error { color: #f2b8af; }
.proc-line { display: flex; align-items: center; gap: 12px; }
.proc-msg { font-size: 15px; color: var(--text); }
.proc-line.err .proc-msg { color: #f2b8af; }
.proc-err { margin: 12px 0 0; padding: 12px 14px; background: #2a1512; border: 1px solid #73251a; border-radius: 10px; color: #f9ddd8; font-size: 13px; white-space: pre-wrap; overflow-x: auto; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--primary); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.proc-bar { height: 8px; border-radius: 999px; background: var(--bg-elev2); overflow: hidden; margin-top: 14px; }
.proc-bar > i { display: block; height: 100%; background: var(--primary); border-radius: 999px; transition: width .5s ease; }
.proc-pct { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; margin-top: 6px; }

/* chapters */
.chapters { display: flex; flex-direction: column; }
.chapter {
  display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 8px; cursor: pointer; color: var(--text);
}
.chapter:hover { background: var(--bg-elev); }
.chapter.playing { color: var(--primary); }
.chapter .num { color: var(--faint); font-size: 13px; text-align: right; }
.chapter .ctitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter .cdur { color: var(--faint); font-size: 13px; }

/* Kapitel-Editor */
.chapter.chapter-edit { grid-template-columns: 28px 1fr auto auto; cursor: default; }
.chapter.chapter-edit:hover { background: none; }
.chapter.chapter-edit .cc-input { min-width: 0; }
.split-list { margin: 2px 0 8px 40px; border-left: 2px solid var(--bg-elev2); max-height: 320px; overflow-y: auto; }
.split-seg { padding: 7px 12px; font-size: 13.5px; color: var(--muted); cursor: pointer; border-radius: 0 8px 8px 0; }
.split-seg:hover { background: var(--bg-elev); color: var(--text); }

/* reader */
.reader { display: flex; flex-direction: column; align-items: center; }
.page-wrap { position: relative; max-width: 820px; width: 100%; box-shadow: 0 10px 30px rgba(0,0,0,.5); border-radius: 8px; overflow: hidden; background: #fff; }
.page-wrap img { width: 100%; height: auto; display: block; }
.rect { position: absolute; pointer-events: none; }
.rect.cur { background: rgba(47,207,160,.22); outline: 2px solid var(--primary); }
.rect.cue { outline: 2px solid var(--amber); }
.page-nav { display: flex; align-items: center; gap: 14px; margin: 14px 0; color: var(--muted); width: 100%; max-width: 820px; }
.pn-btn { display: grid; place-items: center; background: var(--bg-elev2); border: 0; color: var(--text); border-radius: 50%; width: 38px; height: 38px; transition: filter .12s; }
.pn-btn:hover { filter: brightness(1.25); }
.pn-label { font-size: 14px; font-variant-numeric: tabular-nums; color: var(--muted); }
.pn-spacer { flex: 1; }
.page-nav .reader-mark { padding: 9px 16px; font-size: 13px; }
.reader-hint { font-size: 12px; color: var(--faint); text-align: center; margin: 4px 0 10px; }
/* Auswählbare Wort-Text-Ebene über dem Seitenbild */
.textlayer { position: absolute; inset: 0; container-type: size; z-index: 2; }
.textlayer span { position: absolute; color: transparent; white-space: pre; line-height: 1; cursor: text; transform-origin: 0 0; }
.textlayer span::selection { background: rgba(47, 207, 160, 0.4); }
.textlayer span::-moz-selection { background: rgba(47, 207, 160, 0.4); }
/* Gespeicherte Markierungen */
.hl { position: absolute; background: rgba(240, 180, 94, 0.4); border-radius: 2px; z-index: 3; cursor: pointer; mix-blend-mode: multiply; }
.hl:hover { background: rgba(240, 180, 94, 0.6); }
.follow { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }

.textlist { width: 100%; max-width: 760px; }
.seg { padding: 8px 12px; border-radius: 8px; color: var(--muted); line-height: 1.55; cursor: pointer; }
.seg:hover { background: var(--bg-elev); color: var(--text); }
.seg.cur { background: #123d30; color: var(--text); }
.seg.marked { border-left: 3px solid var(--amber); background: rgba(240,180,94,0.10); }
.seg.heading { color: var(--text); font-weight: 700; font-size: 18px; }

/* ---------- Player bar ---------- */
.player {
  grid-area: player; border-top: 1px solid var(--line); background: var(--bg-elev);
  display: grid; grid-template-columns: 1fr 1.6fr 1fr; align-items: center; gap: 16px; padding: 0 18px;
  min-height: 92px;
}
.p-now { display: flex; align-items: center; gap: 12px; min-width: 0; cursor: pointer; padding: 6px 8px; margin: 0 -8px; border-radius: 10px; transition: background .12s; }
.p-now:hover { background: var(--bg-elev2); }
.p-now .p-title { text-decoration: underline; text-decoration-color: transparent; transition: text-decoration-color .12s; }
.p-now:hover .p-title { text-decoration-color: var(--muted); }
.p-cover { width: 56px; height: 56px; border-radius: 8px; object-fit: cover; background: #123d30; flex: none; }
.p-meta { min-width: 0; }
.p-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-chapter { color: var(--faint); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-center { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.p-controls { display: flex; align-items: center; gap: 6px; }
.p-ctrl { display: grid; place-items: center; width: 38px; height: 38px; background: transparent; border: 0; color: var(--muted); border-radius: 50%; transition: color .12s, background .12s; }
.p-ctrl:hover { color: var(--text); background: var(--bg-elev2); }
.p-play { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; background: var(--primary); color: #08211a; border: 0; transition: transform .1s; }
.p-play:hover { transform: scale(1.06); }
.p-play:active { transform: scale(0.97); }
.p-scrub { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 560px; }
.p-time { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; width: 40px; text-align: center; }
.p-seek { flex: 1; accent-color: var(--primary); }
.p-right { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.p-iconbtn { position: relative; display: grid; place-items: center; width: 38px; height: 38px; background: transparent; border: 1px solid transparent; color: var(--muted); border-radius: 10px; transition: .12s; }
.p-iconbtn:hover { color: var(--text); background: var(--bg-elev2); }
.p-live { display: grid; place-items: center; width: 30px; height: 38px; }
.p-live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 0 rgba(47,207,160,.55); animation: livepulse 2s infinite; }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 rgba(47,207,160,.5); } 70% { box-shadow: 0 0 0 7px rgba(47,207,160,0); } 100% { box-shadow: 0 0 0 0 rgba(47,207,160,0); } }
.p-speed select { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; font-size: 13px; }

@media (max-width: 780px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "main" "player"; }
  .sidebar { display: none; }
  .p-right { display: none; }
  .player { grid-template-columns: 1fr 1.4fr; }
}

/* ---------- Reflexionspunkte + Notizen (STT) ---------- */
.p-iconbtn.recording, .mic-btn.recording { color: #ff6b5e; }
.reflect { max-width: 460px; }
.reflect-head { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; margin-bottom: 10px; }
.reflect-head .ic { color: var(--primary); }
.reflect-q { font-size: 17px; line-height: 1.45; margin-bottom: 14px; font-weight: 600; }
.reflect-ta { width: 100%; margin-bottom: 8px; }
.mic-row { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.mic-btn { width: 42px; flex: none; display: grid; place-items: center; padding: 0; height: 40px; border-radius: 999px; background: var(--bg-elev2); }
.mic-btn.recording { background: #3a1a17; border-color: #ff6b5e; animation: micpulse 1.1s infinite; }
@keyframes micpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,107,94,.5); } 50% { box-shadow: 0 0 0 6px rgba(255,107,94,0); } }
.mic-status { font-size: 13px; color: var(--muted); flex: 1; min-height: 18px; }

.notes-modal { max-width: 560px; width: 92vw; }
.cc-x { margin-left: auto; background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 4px; }
.cc-x:hover { color: var(--text); }
.notes-list { max-height: 46vh; overflow-y: auto; margin: 6px 0 14px; display: flex; flex-direction: column; gap: 10px; }
.notes-empty { color: var(--muted); font-size: 14px; padding: 18px 4px; text-align: center; }
.note-item { border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; background: var(--surface); }
.note-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.note-ch { font-size: 12px; color: var(--muted); font-weight: 600; }
.note-badge { font-size: 11px; font-weight: 700; color: var(--primary); background: #123d30; padding: 2px 8px; border-radius: 999px; }
.note-prompt { font-size: 13px; color: var(--muted); font-style: italic; margin-bottom: 4px; line-height: 1.4; }
.note-text { font-size: 15px; line-height: 1.5; white-space: pre-wrap; }
.note-text.editing { outline: 1px solid var(--primary); border-radius: 6px; padding: 4px 6px; }
.note-acts { display: flex; gap: 6px; margin-top: 9px; }
.note-a { background: var(--bg-elev2); border: 1px solid var(--line); color: var(--muted); border-radius: 8px; padding: 5px 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; font-size: 13px; }
.note-a:hover { color: var(--text); border-color: var(--primary-dim); }
.note-a.has-label { padding: 5px 11px; }
.note-compose { border-top: 1px solid var(--line); padding-top: 12px; }
.note-compose-bar { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.note-compose-bar .btn.primary { margin-left: auto; flex: none; }

/* ---------- Vorlese-Filter (Regel-Editor) ---------- */
.filter-list { display: flex; flex-direction: column; gap: 6px; margin: 6px 0; }
.filter-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.filter-row input[type=checkbox] { flex: none; }
.filter-info { flex: 1; min-width: 0; }
.filter-name { font-size: 14px; font-weight: 600; }
.filter-pat { font-size: 12px; color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }
.filter-badge { flex: none; font-size: 11px; font-weight: 700; color: var(--primary); background: #123d30; padding: 3px 9px; border-radius: 999px; white-space: nowrap; }
.filter-row.custom { display: block; }
.filter-cgrid { display: grid; grid-template-columns: 1fr 1.6fr auto auto auto; gap: 6px; align-items: center; }
.filter-f { padding: 7px 9px; font-size: 13px; }
.filter-f.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
@media (max-width: 640px) { .filter-cgrid { grid-template-columns: 1fr 1fr; } }

/* ---------- Spaced-Review ---------- */
.review-banner { display: flex; align-items: center; gap: 14px; padding: 14px 18px; margin: 0 0 18px; border: 1px solid var(--primary-dim); border-radius: var(--radius); background: linear-gradient(120deg, #10281f, var(--bg-elev)); }
.rb-info { display: flex; align-items: center; gap: 10px; flex: 1; font-weight: 600; }
.rb-info .ic { color: var(--primary); }
/* Durchsicht-Rückstand: gleiche Banner-Mechanik, aber Bernstein statt Grün,
   das hier ist wartende Arbeit, keine Empfehlung. */
.plotrev-banner { border-color: rgba(240,180,94,.45); background: linear-gradient(120deg, #2b2113, var(--bg-elev)); flex-wrap: wrap; }
.plotrev-banner .rb-info .ic { color: var(--amber); }
.rb-docs { display: flex; gap: 8px; flex-wrap: wrap; }
.card-review {
  position: absolute; left: 8px; bottom: 8px; font-size: 11px; font-weight: 700; padding: 3px 8px;
  border: none; border-radius: 999px; cursor: pointer;
  background: rgba(0,0,0,.55); color: var(--amber); backdrop-filter: blur(4px);
}
.card-review:hover { background: rgba(0,0,0,.75); }
.review-doc { font-size: 12px; color: var(--muted); font-weight: 600; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.review-answer { border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; background: var(--surface); font-size: 15px; line-height: 1.5; margin-bottom: 10px; white-space: pre-wrap; }
.review-answer.hidden { display: none; }
.btn.review-stop { color: var(--muted); font-size: 13px; margin-right: auto; }

/* ---------- Sleep-Timer ---------- */
#p-sleep.active { color: var(--primary); }
.sleep-pop { position: absolute; bottom: 44px; right: 0; background: var(--bg-elev2); border: 1px solid var(--line); border-radius: 12px; padding: 6px; display: flex; flex-direction: column; min-width: 150px; z-index: 60; box-shadow: 0 8px 26px rgba(0,0,0,.45); }
.sleep-opt { background: transparent; border: 0; color: var(--text); text-align: left; padding: 8px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.sleep-opt:hover { background: var(--bg-elev); }
.sleep-opt.off { color: var(--muted); border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; margin-top: 4px; }

/* ---------- Filter-Vorschläge ---------- */
.filter-row.sug { border-color: var(--primary-dim); }
.filter-sample { font-size: 12px; color: var(--muted); font-style: italic; margin-top: 2px; }
.bl-sub { font-size: 13px; color: var(--muted); margin: 10px 0 6px; font-weight: 600; }

/* ---------- Volltext-Treffer ---------- */
.hitlist { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.hit-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-elev); cursor: pointer; }
.hit-row:hover { border-color: var(--primary-dim); }
.hit-info { flex: 1; min-width: 0; }
.hit-doc { font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 3px; }
.hit-snippet { font-size: 14px; line-height: 1.45; }
.hit-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.hit-play { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--primary); color: #08211a; cursor: pointer; display: grid; place-items: center; }
.info-dlrow { margin-bottom: 14px; } .info-dlrow .btn { display: inline-flex; align-items: center; gap: 8px; }

/* ---------- Figuren-Umrandung in der Seiten-Ansicht ---------- */
.fig-box { position: absolute; border: 1.5px solid rgba(47,207,160,.55); border-radius: 6px; cursor: zoom-in; transition: border-color .15s, background .15s; }
.fig-box:hover { border-color: var(--primary); background: rgba(47,207,160,.07); }
.fig-box.table { border-color: rgba(255,193,94,.55); }
.fig-box.table:hover { border-color: #ffc15e; background: rgba(255,193,94,.07); }
.fig-chip { position: absolute; top: -11px; left: 6px; font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--primary); color: #08211a; white-space: nowrap; }
.fig-box.table .fig-chip { background: #ffc15e; color: #2b1f06; }

/* ---------- Abbildungs-Galerie (Tab „Abbildungen") ---------- */
.figgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-top: 16px; }
.figcard { background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 10px; cursor: pointer; transition: border-color .15s, transform .15s; }
.figcard:hover { border-color: var(--primary); transform: translateY(-2px); }
.figcard-crop { width: 100%; background-repeat: no-repeat; background-color: #fff; border-radius: 8px; min-height: 70px; }
.figcard-cap { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; font-size: 12.5px; color: var(--text); }
.figcard-num { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.figcard-page { color: var(--muted); flex-shrink: 0; }
#fig-lightbox { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.72); display: flex; align-items: center; justify-content: center; padding: 24px; }
#fig-lightbox.hidden { display: none; }
.figlb-box { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 16px; max-width: min(860px, 94vw); max-height: 92vh; overflow: auto; }
.figlb-crop { width: min(780px, 88vw); background-repeat: no-repeat; background-color: #fff; border-radius: 10px; min-height: 100px; }
.figlb-cap { margin-top: 12px; font-size: 13.5px; color: var(--text); line-height: 1.45; }
.figlb-row { display: flex; gap: 10px; margin-top: 12px; }

/* Figuren-Feedback + Toast */
.figlb-fb { border-top: 1px solid var(--border); padding-top: 10px; margin-top: 12px; }
.btn.subtle { font-size: 12.5px; padding: 6px 12px; opacity: .85; }
.btn.subtle.danger { color: #ff7a7a; border-color: rgba(255,122,122,.4); }
.fig-missing { display: flex; align-items: center; gap: 12px; margin: 14px 0 2px;
  font-size: 13px; color: var(--muted); }
#toast { position: fixed; left: 50%; bottom: 96px; transform: translate(-50%, 16px);
  background: var(--card); border: 1px solid var(--border); color: var(--text);
  padding: 10px 18px; border-radius: 999px; font-size: 13.5px; opacity: 0;
  pointer-events: none; transition: opacity .2s, transform .2s; z-index: 95;
  box-shadow: 0 6px 24px rgba(0,0,0,.35); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ================= Annotator (Seiten bemalen) ================= */
.anno-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 8px 0 4px; padding: 6px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px; }
.anno-grp { display: flex; align-items: center; gap: 3px; }
.anno-grp + .anno-grp { padding-left: 8px; border-left: 1px solid var(--line); }
.anno-tool { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--muted); cursor: pointer; }
.anno-tool:hover { background: var(--bg-elev2); color: var(--text); }
.anno-tool.on { background: var(--primary-dim); color: #fff; border-color: var(--primary); }
.anno-swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); cursor: pointer; padding: 0; }
.anno-swatch.on { border-color: var(--text); box-shadow: 0 0 0 2px var(--bg); outline: 2px solid var(--primary); }
.anno-w { min-width: 40px; height: 30px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; }
.anno-w.on { background: var(--bg-elev2); color: var(--text); border-color: var(--primary); }
.anno-sliders input[type="range"] { width: 84px; accent-color: var(--primary); }
.anno-select { height: 30px; padding: 0 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-elev); color: var(--text); font-size: 12px; max-width: 150px; }
.idx-dialog { max-width: 640px; width: min(94vw, 640px); }
.modal-title.sub { font-size: 14px; margin-top: 10px; color: var(--muted); }
.idx-list { max-height: 34vh; overflow-y: auto; display: flex; flex-direction: column; }
.idx-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.idx-term { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.idx-term.own { font-weight: 700; }
.idx-pages { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.idx-row.hit { cursor: pointer; }
.idx-row.hit:hover { background: var(--bg-elev2); }
.hit-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
.hit-body { flex: 1; min-width: 0; }
.search-row { align-items: center; }
.search-input { flex: 1; height: 34px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg-elev); color: var(--text); }
/* Volle Farbpalette: klappt unter der Leiste als Raster auf (24 Farben). */
.anno-palette { flex-basis: 100%; display: grid; grid-template-columns: repeat(12, 22px); gap: 6px; padding: 6px 2px 2px; }
.anno-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; z-index: 6; }

/* Versionen-Dialog */
.version-list { max-height: 46vh; overflow-y: auto; margin: 6px 0; }
.version-row { padding: 8px 0; border-bottom: 1px solid var(--line); }
.version-name { font-weight: 600; }
.version-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.version-acts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.page-wrap.custom-page { background: #fbf8f3; border: 1px solid var(--line); border-radius: 6px; }
.page-wrap.custom-page.bg-lines { background-image: repeating-linear-gradient(#fbf8f3 0 30px, #d9e2ec 30px 31px); }
.page-wrap.custom-page.bg-grid { background-image: repeating-linear-gradient(#fbf8f3 0 26px, #dbe4ee 26px 27px), repeating-linear-gradient(90deg, #fbf8f3 0 26px, #dbe4ee 26px 27px); }
.page-wrap.custom-page.bg-dots { background-image: radial-gradient(#c7d2de 1.4px, transparent 1.5px); background-size: 24px 24px; }
.bg-choices { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 6px 0 4px; }
.bg-choice { height: 74px; border: 1px solid var(--line); border-radius: 10px; background: #fbf8f3; cursor: pointer; position: relative; display: grid; align-items: end; }
.bg-choice.bg-lines { background-image: repeating-linear-gradient(#fbf8f3 0 11px, #d9e2ec 11px 12px); }
.bg-choice.bg-grid { background-image: repeating-linear-gradient(#fbf8f3 0 11px, #dbe4ee 11px 12px), repeating-linear-gradient(90deg, #fbf8f3 0 11px, #dbe4ee 11px 12px); }
.bg-choice.bg-dots { background-image: radial-gradient(#c7d2de 1.3px, transparent 1.4px); background-size: 12px 12px; }
.bg-choice-lbl { background: rgba(20,17,14,.82); color: #fff; font-size: 12px; font-weight: 600; padding: 3px 0; border-radius: 0 0 9px 9px; text-align: center; }

/* Diagramm-Badges */
.figcard-crop { position: relative; }
.figcard-chart { position: absolute; top: 6px; left: 6px; display: inline-flex; align-items: center; gap: 4px; background: rgba(18,161,122,.92); color: #fff; font-size: 11px; font-weight: 700; padding: 2px 7px 2px 5px; border-radius: 999px; }
.fig-box.chart { border-color: var(--primary); }

/* ================= Plot-Digitizer ================= */
.dig-ov { position: fixed; inset: 0; z-index: 120; background: rgba(8,6,4,.86); backdrop-filter: blur(3px); display: grid; place-items: center; padding: 2vh; }
.dig-wrap { display: grid; grid-template-columns: 1fr 340px; gap: 0; width: min(1200px, 96vw); height: min(92vh, 900px); background: var(--bg-elev); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.dig-stage { position: relative; background: #0d0b09; overflow: hidden; }
.dig-canvas { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.dig-err, .dig-empty { color: var(--muted); padding: 16px; font-size: 14px; }
.dig-panel { background: var(--bg-elev); border-left: 1px solid var(--line); padding: 14px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.dig-head { display: flex; align-items: center; justify-content: space-between; }
.dig-title { font-size: 15px; font-weight: 700; }
.dig-step { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); margin-top: 6px; }
.dig-axis { display: flex; align-items: center; gap: 6px; }
.dig-axis-name { width: 16px; font-weight: 700; color: var(--muted); }
.dig-cal { flex: 1; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; }
.dig-cal.set { color: var(--text); border-color: var(--primary-dim); }
.dig-log { height: 32px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font-size: 12px; }
.dig-ds { display: flex; flex-direction: column; gap: 4px; }
.dig-ds-row { display: flex; align-items: center; gap: 7px; padding: 5px 7px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; }
.dig-ds-row.on { border-color: var(--primary); background: var(--bg-elev2); }
.dig-ds-dot { width: 15px; height: 15px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); padding: 0; cursor: pointer; flex: none; }
.dig-ds-name { flex: 1; font-size: 13px; font-weight: 600; }
.dig-ds-a { width: 26px; height: 26px; display: grid; place-items: center; border: 0; background: transparent; color: var(--muted); border-radius: 6px; cursor: pointer; }
.dig-ds-a:hover { background: var(--bg); color: var(--text); }
.dig-ds-add { align-self: flex-start; margin-top: 2px; }
.dig-hint { font-size: 12px; color: var(--muted); line-height: 1.45; }
.dig-hint.armed { color: var(--primary); font-weight: 600; }
.dig-table { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; max-height: 200px; overflow-y: auto; }
.dig-tr { display: grid; grid-template-columns: 30px 1fr 1fr 24px; align-items: center; font-size: 12px; padding: 3px 8px; border-bottom: 1px solid var(--line); }
.dig-tr:last-child { border-bottom: 0; }
.dig-th { font-weight: 700; color: var(--faint); position: sticky; top: 0; background: var(--bg-elev2); }
.dig-x { border: 0; background: transparent; color: var(--faint); cursor: pointer; font-size: 15px; }
.dig-x:hover { color: #e5484d; }
.dig-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; padding-top: 8px; }
.dig-actions .btn { flex: 1; min-width: 64px; }
@media (max-width: 720px) { .dig-wrap { grid-template-columns: 1fr; grid-template-rows: 1fr auto; height: 94vh; } .dig-panel { max-height: 42vh; } }

.dig-auto { display: flex; gap: 8px; margin: 4px 0 2px; }
.dig-auto .btn { flex: 1; }

/* Fernwiedergabe: nur Play/Pause ist fernsteuerbar, der Rest wäre irreführend. */
.player.remote .p-ctrl, .player.remote .p-seek { opacity: .4; pointer-events: none; }
.player.remote .p-chapter { color: var(--primary); }

.plot-canvas { width: 100%; height: auto; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 10px; margin: 6px 0; }

/* ================= Diagrammdaten durchsehen ================= */
/* Ungeprüfte Modellausgabe faellt bewusst auf: sie ist Rohmaterial, kein Messwert. */
.plotrev-head { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 14px; }
.plotrev-counts { font-size: 15px; font-weight: 700; }
.plotrev-hint { font-size: 12.5px; color: var(--muted); line-height: 1.5; max-width: 70ch; }
.plotrev-run { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.plotrev-runnote { font-size: 12.5px; color: var(--muted); }
.plotrev-sub { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); margin: 26px 0 8px; }
.plotrev-list, .plotrev-rejected { display: flex; flex-direction: column; gap: 10px; }
.plotrev-row {
  display: grid; grid-template-columns: 132px 1fr auto; gap: 14px; align-items: center;
  padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.plotrev-row.open { border-color: var(--amber); }
.plotrev-crop { width: 132px; background: #fff center/cover no-repeat; border-radius: 8px; cursor: pointer; min-height: 74px; position: relative; }
.plotrev-ovl { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.plot-ovl-cap { font-size: 12px; color: var(--muted); margin: -2px 0 6px; }
.plotrev-rejimg { width: 132px; height: auto; border-radius: 8px; background: #fff; }
.plotrev-mid { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.plotrev-title { display: flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 700; }
.plotrev-facts { font-size: 12.5px; color: var(--muted); }
.plotrev-warn { font-size: 12.5px; color: var(--amber); line-height: 1.4; }
.plotrev-retry { font-size: 12.5px; color: var(--primary); font-weight: 600; }
/* Befunde: Hinweise gedaempft, schwere Faelle rot, der Nutzer soll die drei
   wirklich kaputten Plots auf einen Blick von den zwoelf auffaelligen trennen. */
.plotrev-flaw { display: flex; gap: 7px; align-items: baseline; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.plotrev-flaw.severe { color: #f2555a; }
.plotrev-flawdot {
  flex: none; width: 15px; height: 15px; border-radius: 999px; font-size: 10.5px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg-elev2); color: var(--muted); border: 1px solid var(--line);
}
.plotrev-flaw.severe .plotrev-flawdot { background: rgba(242,85,90,.16); color: #f2555a; border-color: rgba(242,85,90,.45); }
.plotrev-flawbox { display: flex; flex-direction: column; gap: 5px; margin: 2px 0 10px; }
.plot-badge-flaw { background: var(--bg-elev2); color: var(--muted); border: 1px solid var(--line); }
.plot-badge-flaw.severe { background: rgba(242,85,90,.16); color: #f2555a; border: 1px solid rgba(242,85,90,.45); }
.plotrev-filters { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 12px; }
.plotrev-chip {
  font-size: 12.5px; font-weight: 600; padding: 5px 12px; border-radius: 999px; cursor: pointer;
  background: var(--bg-elev2); color: var(--muted); border: 1px solid var(--line);
}
.plotrev-chip:hover { color: var(--text); }
.plotrev-chip.active { background: rgba(47,207,160,.14); color: var(--primary); border-color: rgba(47,207,160,.4); }
.plotrev-acts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 320px; }
.plot-badge { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.plot-badge-raw { background: rgba(240,180,94,.18); color: var(--amber); border: 1px solid rgba(240,180,94,.45); }
.plot-badge-checked { background: rgba(47,207,160,.14); color: var(--primary); border: 1px solid rgba(47,207,160,.4); }
.plot-badge-corrected { background: rgba(47,207,160,.14); color: var(--primary); border: 1px solid rgba(47,207,160,.4); }
.plot-badge-manual { background: var(--bg-elev2); color: var(--muted); border: 1px solid var(--line); }
.dig-axisbox { display: flex; flex-direction: column; gap: 4px; }
.dig-axlabel { height: 30px; font-size: 12px; }
@media (max-width: 720px) {
  .plotrev-row { grid-template-columns: 96px 1fr; }
  .plotrev-crop, .plotrev-rejimg { width: 96px; }
  .plotrev-acts { grid-column: 1 / -1; justify-content: flex-start; max-width: none; }
}

/* ---------- Admin-Panel ---------- */
.adm-kpis { grid-template-columns: repeat(3, 1fr); }
.adm-wrap { overflow-x: auto; }
.adm-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.adm-table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--faint); padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.adm-table td { padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.adm-table tr:last-child td { border-bottom: 0; }
.adm-empty { color: var(--faint); text-align: center; }
.adm-strong { font-weight: 600; color: var(--text); }
.adm-sub { font-size: 12px; color: var(--faint); }
.adm-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .5px; }
.adm-pills { display: flex; gap: 5px; flex-wrap: wrap; }
.adm-pill { display: inline-block; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--bg-elev2); color: var(--muted); border: 1px solid var(--line); }
.adm-pill.ok { color: var(--primary); border-color: rgba(47,207,160,.35); }
.adm-pill.err { color: #f2b8af; border-color: rgba(242,184,175,.35); }
.adm-pill.code { font-family: ui-monospace, Menlo, monospace; }
.adm-actions { display: flex; gap: 6px; justify-content: flex-end; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.adm-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.adm-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 12px; border-radius: 999px; background: var(--bg-elev2); border: 1px solid var(--line); font-size: 13px; }
.adm-chip-x { background: transparent; border: 0; color: var(--faint); font-size: 15px; line-height: 1; padding: 0 2px; }
.adm-chip-x:hover { color: #f2b8af; }

/* ---------- Kleine Hinweise oben rechts auf der Startseite ---------- */
.home-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.home-head .greeting { margin-right: auto; }
.home-hints { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; padding-top: 6px; }
.hint-wrap { position: relative; }
.hint-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; padding: 6px 11px; border-radius: 999px; background: var(--bg-elev); border: 1px solid var(--line); color: var(--muted); }
.hint-chip .ic { color: var(--primary); }
.hint-chip.amber .ic { color: var(--amber); }
.hint-chip:hover { color: var(--text); background: var(--bg-elev2); }
.hint-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 30; min-width: 260px; display: flex; flex-direction: column; gap: 2px; padding: 6px; background: var(--bg-elev); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.hint-item { text-align: left; background: transparent; border: 0; color: var(--muted); font-size: 13px; padding: 8px 10px; border-radius: 8px; white-space: nowrap; }
.hint-item:hover { background: var(--bg-elev2); color: var(--text); }

/* ---------- Upload-Fortschritt + Einrichten-Seite ---------- */
.dropzone.uploading { cursor: default; border-style: solid; border-color: var(--primary); color: var(--text); }
.up-name { font-weight: 600; font-size: 14px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-bar { width: min(420px, 90%); height: 8px; border-radius: 999px; background: var(--bg-elev2); overflow: hidden; }
.up-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width .2s ease; }
.up-pct { font-size: 13px; color: var(--muted); }
.setup-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.setup-head .hero-title { margin-bottom: 8px; }

/* Alpha-Kennzeichnung neben dem Logo: kleiner gelber runder Tag. */
.alpha-tag { display: inline-block; margin-left: 8px; padding: 2px 9px; border-radius: 999px; font-size: 10px; font-weight: 700; letter-spacing: .6px; text-transform: uppercase; background: rgba(240,180,94,.16); color: var(--amber); border: 1px solid rgba(240,180,94,.45); vertical-align: 3px; }
.ok-hint { color: var(--primary); }
.mp3-row { align-items: center; flex-wrap: wrap; }
.mp3-page { max-width: 170px; flex: none; }
.dl-modal { width: min(520px, 94vw); }
.dl-actions { flex-wrap: wrap; }
.dl-actions .btn:first-child { margin-right: auto; }
/* Doppel-Schieberegler im Download-Modal */
.rng-label { font-size: 14px; font-weight: 600; margin: 10px 0 6px; }
.rng { position: relative; height: 28px; margin: 0 8px 6px; }
.rng-track { position: absolute; left: 0; right: 0; top: 12px; height: 4px; border-radius: 999px; background: var(--bg-elev2); }
.rng-fill { position: absolute; top: 0; height: 100%; border-radius: 999px; background: var(--primary); }
.rng input[type="range"] {
  position: absolute; left: 0; right: 0; top: 0; width: 100%; height: 28px; margin: 0;
  -webkit-appearance: none; appearance: none; background: transparent; pointer-events: none;
}
.rng input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; pointer-events: auto;
  width: 18px; height: 18px; border-radius: 50%; background: var(--primary);
  border: 2px solid var(--bg-elev); box-shadow: 0 1px 4px rgba(0,0,0,.4); cursor: pointer;
}
.rng input[type="range"]::-moz-range-thumb {
  pointer-events: auto; width: 16px; height: 16px; border-radius: 50%;
  background: var(--primary); border: 2px solid var(--bg-elev); cursor: pointer;
}
.rng input[type="range"]::-moz-range-track { background: transparent; }
.adm-click { cursor: pointer; }
.adm-click:hover td { background: var(--bg-elev2); }
/* Lade-Spinner in Buttons (Export) */
.btn .spin { display: inline-block; width: 13px; height: 13px; border-radius: 50%; border: 2px solid rgba(255,255,255,.3); border-top-color: currentColor; animation: btnspin .8s linear infinite; }
@keyframes btnspin { to { transform: rotate(360deg); } }
.btn.loading { opacity: .85; cursor: progress; }

/* ---------- Reader: Seite + Werkzeuge nebeneinander, Nav oben und unten ---------- */
.reader-main { display: flex; gap: 14px; width: 100%; justify-content: center; align-items: flex-start; }
.reader-main .page-wrap { flex: 1 1 auto; min-width: 0; }
.anno-side { flex: none; width: 118px; position: sticky; top: 10px; max-height: calc(100vh - 90px); overflow-y: auto; scrollbar-width: none; }
.anno-side::-webkit-scrollbar { display: none; }
.anno-side .anno-bar { flex-direction: column; align-items: stretch; margin: 0; }
.anno-side .anno-grp { flex-wrap: wrap; justify-content: center; row-gap: 3px; }
.anno-side .anno-grp + .anno-grp { border-left: 0; padding-left: 0; border-top: 1px solid var(--line); padding-top: 8px; }
.anno-side .anno-sliders { flex-direction: column; align-items: stretch; gap: 6px; }
.anno-side .anno-sliders input[type="range"] { width: 100%; }
.anno-side .anno-select { max-width: 100%; width: 100%; }
.anno-side .btn.subtle { width: 100%; justify-content: center; font-size: 11.5px; padding: 6px 4px; }
.anno-side .anno-palette { position: static; }
.page-nav-bottom { margin-top: 14px; justify-content: center; }
@media (max-width: 1000px) {
  .reader-main { flex-direction: column; align-items: center; }
  .anno-side { position: static; width: 100%; max-height: none; order: -1; }
  .anno-side .anno-bar { flex-direction: row; }
  .anno-side .anno-grp + .anno-grp { border-top: 0; padding-top: 0; border-left: 1px solid var(--line); padding-left: 8px; }
}
/* "Audio folgen" als richtiger Schalter */
.follow { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--muted); user-select: none; }
.follow input { position: absolute; opacity: 0; pointer-events: none; }
.follow .switch { flex: none; width: 34px; height: 20px; border-radius: 999px; background: var(--bg-elev2); border: 1px solid var(--line); position: relative; transition: background .15s, border-color .15s; }
.follow .switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--muted); transition: left .15s, background .15s; }
.follow input:checked + .switch { background: var(--primary-dim); border-color: var(--primary); }
.follow input:checked + .switch::after { left: 16px; background: var(--primary); }
.follow:hover { color: var(--text); }

/* Themen-Reiter links, Inhalts-Ansicht (Kapitel/Text/Seiten) rechts */
.tab-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tab-row .tabs { margin-bottom: 18px; }
.viewmodes { flex: none; }
.tab.vm { display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px; }
.tab.vm .ic { opacity: .8; }
/* Lange Titel in Admin-Tabellen abschneiden statt die Tabelle zu sprengen */
.adm-doccell { max-width: 340px; }
.adm-doccell .adm-strong, .adm-doccell .adm-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ================= Mobile (vollumfänglich) ================= */
.m-nav { display: none; }
.nav-backdrop { display: none; }
@supports (height: 100dvh) { .app { height: 100dvh; } }
@media (max-width: 780px) {
  /* --- Navigation als Schublade --- */
  .m-nav {
    display: grid; place-items: center; position: fixed; top: 10px; left: 12px; z-index: 70;
    width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
    background: var(--bg-elev); color: var(--text);
  }
  .side-expand { display: none !important; }
  body.nav-open .sidebar {
    display: flex !important; position: fixed; top: 0; left: 0; bottom: 0; z-index: 80;
    width: min(300px, 84vw); box-shadow: 18px 0 50px rgba(0,0,0,.55);
    padding-top: 16px;
  }
  body.nav-open .nav-backdrop { display: block; position: fixed; inset: 0; z-index: 75; background: rgba(0,0,0,.55); }
  .side-toggle { display: none; }           /* Einklappen ist Desktop-Komfort */
  body.side-collapsed .app { grid-template-columns: 1fr; }

  /* --- Grundlayout --- */
  .main { padding: 60px 14px 40px; }        /* Platz für den Menü-Knopf */
  .greeting, .hero-title { font-size: 24px; }
  .home-head { flex-direction: column; align-items: stretch; gap: 4px; }
  .home-hints { justify-content: flex-start; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 14px 12px; }

  /* --- Startseiten-Hero --- */
  .hero { height: 190px; margin-bottom: 22px; }
  .hero-body { padding: 16px 18px; }
  .hero-title2 { font-size: 20px; }
  .hero-row { align-items: center; }

  /* --- Dokumentkopf + Reiter --- */
  .doc-head { flex-direction: column; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
  .doc-actions { flex-wrap: wrap; gap: 8px; }
  .tab-row { flex-direction: column; gap: 0; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; max-width: 100%; margin-bottom: 12px; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { padding: 8px 13px; font-size: 13px; white-space: nowrap; }

  /* --- Player --- */
  .player { grid-template-columns: 1fr auto; gap: 8px; padding: 8px 12px; min-height: 0; }
  .p-cover { width: 44px; height: 44px; }
  .p-center { order: 3; grid-column: 1 / -1; }
  .p-scrub { max-width: none; }
  .p-right { display: flex; }
  .p-right .p-live, .p-right .p-devwrap, .p-right .p-pip, .p-speed { display: none; }

  /* --- Formulare, Karten, Modale --- */
  .create-card { padding: 14px; }
  .cc-row { flex-wrap: wrap; }
  .cc-input, .search { font-size: 16px; }   /* verhindert iOS-Autozoom */
  .modal { width: min(94vw, 560px); }
  .dialog-actions { flex-wrap: wrap; }

  /* --- Statistik/Admin --- */
  .stat-kpis, .adm-kpis { grid-template-columns: 1fr 1fr; }
  .adm-doccell { max-width: 55vw; }

  /* --- Reader --- */
  .page-nav { flex-wrap: wrap; gap: 8px; }
  .anno-side .anno-bar { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: none; }
  .anno-side .anno-bar::-webkit-scrollbar { display: none; }
  .anno-side .anno-grp { flex-wrap: nowrap; }
}
@media (max-width: 480px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); }
  .hero { height: 160px; }
  .stat-kpis, .adm-kpis { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-val { font-size: 18px; }
}

/* ---------- Topbar oben rechts: Glocke + Konto ---------- */
.topbar { position: fixed; top: 12px; right: 16px; z-index: 66; display: flex; align-items: center; gap: 6px; }
.topbar .p-iconbtn { background: var(--bg-elev); border: 1px solid var(--line); }
.topbar .p-iconbtn:hover { background: var(--bg-elev2); }
.bell-wrap { position: relative; }
.bell-badge {
  position: absolute; top: -4px; right: -4px; min-width: 17px; height: 17px; padding: 0 4px;
  display: grid; place-items: center; border-radius: 999px; background: var(--amber); color: #241a08;
  font-size: 10px; font-weight: 800; border: 2px solid var(--bg);
}
.bell-menu { width: 300px; max-height: 60vh; overflow-y: auto; }
.bell-menu .am-item span { white-space: normal; }
.home-head { padding-right: 104px; }        /* Platz unter der Topbar */
@media (max-width: 780px) {
  .topbar { top: 10px; right: 12px; }
  .topbar .avatar { width: 34px; height: 34px; font-size: 13px; }
  .home-head { padding-right: 0; }          /* home-head ist mobil gestapelt, Topbar drueber */
  .main { padding-top: 64px; }
  .bell-menu, .account-menu { position: fixed; top: 56px; right: 10px; left: auto; width: min(320px, 92vw); }
}
/* Unter-Reiter (z. B. Galerie/Diagrammdaten innerhalb Abbildungen) */
.subtabs { padding: 4px; margin: -6px 0 14px; }
.subtabs .tab { padding: 6px 14px; font-size: 13px; }
.dl-pdf { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; }
/* ---------- Stimmen als Personen ---------- */
.voice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; margin-bottom: 12px; }
.voice-card { display: flex; align-items: center; gap: 10px; text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-elev2); color: var(--text); cursor: pointer; }
.voice-card:hover { border-color: var(--primary-dim); }
.voice-card.on { border-color: var(--primary); background: var(--primary-dim); }
.v-avatar { flex: none; display: grid; place-items: center; width: 46px; height: 46px; border-radius: 50%; overflow: hidden; color: #eafff6; font-weight: 700; font-size: 17px; }
.v-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.v-meta { min-width: 0; flex: 1; }
.v-name { font-weight: 700; font-size: 14px; }
.v-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-card.on .v-sub { color: var(--text); opacity: .8; }
.v-play { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--bg-elev); color: var(--muted); }
.v-play:hover { color: var(--text); }
/* Übersicht: Kennzahlen + Fortschritt */
.info-kpis { grid-template-columns: repeat(6, 1fr); margin-bottom: 14px; }
@media (max-width: 900px) { .info-kpis { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 520px) { .info-kpis { grid-template-columns: repeat(2, 1fr); } }
.info-progress { height: 6px; border-radius: 999px; background: var(--bg-elev2); overflow: hidden; margin: -4px 0 16px; }
.info-progress-fill { height: 100%; border-radius: 999px; background: var(--primary); }
/* Direkte Seitenzahl-Eingabe im Reader */
.pn-jump { display: inline-flex; align-items: center; gap: 4px; }
.pn-input { width: 58px; text-align: center; padding: 5px 4px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 14px; font-variant-numeric: tabular-nums; }
.pn-input:focus { outline: none; border-color: var(--primary); }
.pn-input::-webkit-outer-spin-button, .pn-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.pn-input { -moz-appearance: textfield; appearance: textfield; }
/* Persona-Modal + klickbare Kennzahl */
.stat-kpi-btn { cursor: pointer; transition: border-color .12s; }
.stat-kpi-btn:hover { border-color: var(--primary); }
.voice-modal { width: min(720px, 94vw); }
.vm-grid { max-height: 55vh; overflow-y: auto; }
.voice-card.vmc { cursor: pointer; }
.v-tag { font-size: 11px; color: var(--faint); margin-top: 2px; }
.v-tag.ok { color: var(--primary); }
.voice-card .btn.small { flex: none; }
/* Seiten-Galerie in der Übersicht: aktuelle Seite mittig, Nachbarn als Preview.
   Breiten sind prozentual, die Galerie nutzt die volle Kartenbreite dynamisch. */
.page-gal { position: relative; margin: 6px 0 22px; width: 100%; height: 320px;
  overflow: hidden; touch-action: pan-y; cursor: grab; }
.page-gal.dragging { cursor: grabbing; }
.page-gal .pg-item { position: absolute; left: 50%; top: 50%; width: 22%;
  transform-origin: center center; will-change: transform, opacity; transition: none; }
.pg-item { padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; cursor: pointer; transition: border-color .13s; box-shadow: 0 10px 26px rgba(0,0,0,.38); flex: none; }
.pg-item img { display: block; width: 100%; height: auto; }
.pg-item.pg-d0, .pg-spacer.pg-d0 { width: 22%; }
.pg-item.pg-d1, .pg-spacer.pg-d1 { width: 17%; }
.pg-item.pg-d2, .pg-spacer.pg-d2 { width: 13.5%; }
.pg-item.pg-d3, .pg-spacer.pg-d3 { width: 10.5%; }
.pg-item.pg-d0 { border-color: var(--primary); }
.pg-item.pg-d1 { opacity: .88; }
.pg-item.pg-d2 { opacity: .68; }
.pg-item.pg-d3 { opacity: .45; }
.pg-item:hover { transform: translateY(-5px); opacity: 1; border-color: var(--primary); }
.pg-num { position: absolute; left: 0; right: 0; bottom: 0; text-align: center; font-size: 11px; font-weight: 600; color: #fff; background: linear-gradient(transparent, rgba(0,0,0,.65)); padding: 14px 0 5px; }
@media (max-width: 900px) {
  .pg-item.pg-d3, .pg-spacer.pg-d3 { display: none; }
  .pg-item.pg-d0, .pg-spacer.pg-d0 { width: 30%; }
  .pg-item.pg-d1, .pg-spacer.pg-d1 { width: 22%; }
  .pg-item.pg-d2, .pg-spacer.pg-d2 { width: 16%; }
}
@media (max-width: 560px) {
  .pg-item.pg-d2, .pg-spacer.pg-d2 { display: none; }
  .pg-item.pg-d0, .pg-spacer.pg-d0 { width: 44%; }
  .pg-item.pg-d1, .pg-spacer.pg-d1 { width: 26%; }
}
/* Galerie-Karussell: greifbar */
.page-gal { cursor: grab; user-select: none; touch-action: pan-y; will-change: transform; }
.page-gal.dragging { cursor: grabbing; }
.page-gal.dragging .pg-item { pointer-events: none; }
.pg-item.pg-here:not(.pg-d0) { border-color: var(--amber); }
/* Stimmen-Kachel mit Profilbild */
.stat-voice-row { display: flex; align-items: center; justify-content: center; gap: 8px; }
.stat-voice-row .v-avatar { width: 30px; height: 30px; font-size: 13px; }
/* Lautstärke-Popup */
.vol-pop { padding: 12px 14px; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 190px; }
.vol-pop input[type="range"] { width: 100%; accent-color: var(--primary); }
.vol-label { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 780px) { .p-right .p-volwrap { display: block; } }
/* KI-Vorbefund: Vorspann-Struktur */
.spin-dark { border-color: rgba(255,255,255,.15); border-top-color: var(--primary); }
.meta-busy { display: flex; align-items: center; gap: 8px; }
.fm-list { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 10px; }
.fm-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 6px 10px; border-radius: 8px; background: var(--bg-elev2); }
.fm-kind { font-weight: 600; }
.fm-pages { color: var(--muted); font-variant-numeric: tabular-nums; }
.fm-btn { width: 100%; border: 0; color: var(--text); cursor: pointer; text-align: left; }
.fm-btn:hover { background: var(--bg-elev); }
.fm-start .fm-kind { color: var(--primary); }
/* Label unter der Galerie-Seite (Vorspann-Art / Inhaltsbeginn) */
.pg-item { overflow: visible; }
.pg-item img, .pg-num { border-radius: 10px; }
.pg-tag { position: absolute; left: 50%; top: 100%; transform: translate(-50%, 6px); white-space: nowrap; font-size: 11px; font-weight: 600; color: var(--muted); background: var(--bg-elev); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; pointer-events: none; }
.pg-tag-start { color: var(--primary); border-color: var(--primary); }
.page-gal { margin-bottom: 40px; }
/* Kapitel-Ebenen aus dem Inhaltsverzeichnis */
.chapter.sub-2 .ctitle { padding-left: 18px; color: var(--muted); }
.chapter.sub-3 .ctitle { padding-left: 36px; color: var(--muted); font-size: 13px; }
.chapter.top .ctitle { font-weight: 600; }
.vm-translate { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.vm-translate .auth-sub { margin-bottom: 8px; }
.v-tag.amber { color: var(--amber); }
/* Übersetzen: Flaggen -> Personen */
.vm-tr-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.vm-flags { display: flex; gap: 10px; flex-wrap: wrap; }
.vm-flag { display: grid; place-items: center; width: 48px; height: 48px; padding: 0; border-radius: 50%; border: 2px solid var(--line); background: var(--bg-elev2); cursor: pointer; transition: transform .12s, border-color .12s; }
.vm-flag svg { width: 40px; height: 40px; display: block; }
.vm-flag:hover { transform: translateY(-2px); border-color: var(--primary-dim); }
.vm-flag.on { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47,207,160,.25); }
.vm-flag.off { opacity: .28; filter: grayscale(1); cursor: not-allowed; }
.vm-flag.off:hover { transform: none; border-color: var(--line); }
.vm-tr-head { flex-direction: column; align-items: flex-start; }
.vm-flag-ic { display: inline-flex; line-height: 0; }
.vm-flag-ic svg { display: block; box-shadow: 0 1px 2px rgba(0,0,0,.4); border-radius: 3px; }
.vm-flag-code { font-size: 11px; font-weight: 800; letter-spacing: .5px; }

/* ---------- Empfehlungen (Weiterhören) ---------- */
.rec { margin-top: 34px; }
.rec .row-head { margin-bottom: 6px; }
.rec-sub { font-size: 13px; color: var(--muted); line-height: 1.5; margin: 0 2px 14px; max-width: 70ch; }
.rec-mini {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600;
  padding: 6px 11px; border-radius: 999px; background: var(--bg-elev);
  border: 1px solid var(--line); color: var(--muted);
}
.rec-mini:hover { color: var(--text); background: var(--bg-elev2); }
.rec-topics { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 2px 16px; }
.rec-chip {
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px;
  font-size: 13px; font-weight: 600; background: var(--bg-elev); color: var(--muted);
}
.rec-chip:hover { color: var(--text); background: var(--bg-elev2); }
.rec-chip.on { background: var(--primary); border-color: var(--primary); color: #08211a; }
.rec-note { color: var(--muted); font-size: 13.5px; padding: 14px 2px; }
.rec-list { display: flex; flex-direction: column; gap: 10px; }
.rec-item {
  display: flex; align-items: flex-start; gap: 18px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
}
.rec-item:hover { background: var(--bg-elev2); }
.rec-main { flex: 1; min-width: 0; }
.rec-title { font-size: 15px; font-weight: 650; line-height: 1.35; }
.rec-meta { font-size: 12.5px; color: var(--faint); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-why { font-size: 13px; color: var(--muted); margin-top: 7px; line-height: 1.5; }
.rec-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.rec-badge {
  font-size: 11px; font-weight: 600; letter-spacing: .2px; padding: 3px 9px;
  border-radius: 999px; background: var(--bg-elev); border: 1px solid var(--line); color: var(--faint);
}
.rec-badge.src { color: var(--text); }
.rec-badge.ok { color: var(--primary); border-color: rgba(47,207,160,.32); }
.rec-actions { display: flex; flex-direction: column; gap: 8px; flex: none; align-items: stretch; }
.rec-actions .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; font-size: 13px; white-space: nowrap; }
.rec-actions .btn[disabled] { opacity: .6; cursor: default; filter: none; }
.rec-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--faint); font-size: 12.5px; padding: 6px 2px 0; }
@media (max-width: 720px) {
  .rec-item { flex-direction: column; gap: 12px; }
  .rec-actions { flex-direction: row; width: 100%; }
}

/* ---- Cowork ---- */
.cw-wrap { display: flex; gap: 16px; min-height: 60vh; align-items: stretch; }
.cw-map { flex: 0 0 240px; border-right: 1px solid var(--border, #333); padding-right: 12px; overflow-y: auto; max-height: 75vh; }
.cw-node { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: left;
  background: none; border: none; color: inherit; padding: 6px 8px; border-radius: 8px; cursor: pointer; font: inherit; }
.cw-node:hover { background: var(--hover, rgba(255,255,255,.06)); }
.cw-node.active { background: var(--hover, rgba(255,255,255,.1)); }
.cw-node.merged .cw-node-line::after { content: " ⇄"; opacity: .6; }
.cw-node-line { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.cw-node-meta { font-size: 11px; opacity: .6; }
.cw-chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.cw-chatbar { display: flex; flex-direction: column; gap: 6px; padding-bottom: 8px; border-bottom: 1px solid var(--border, #333); }
.cw-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cw-chip { font-size: 12px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border, #444);
  background: none; color: inherit; cursor: pointer; }
.cw-chip:hover { text-decoration: line-through; }
.cw-chip-add:hover { text-decoration: none; opacity: .8; }
.cw-msgs { flex: 1; overflow-y: auto; padding: 12px 4px; display: flex; flex-direction: column; gap: 10px; max-height: 55vh; }
.cw-msg { max-width: 92%; padding: 10px 12px; border-radius: 12px; position: relative; }
.cw-msg.user { align-self: flex-end; background: var(--accent-dim, rgba(200,150,62,.15)); }
.cw-msg.assistant { align-self: flex-start; background: var(--hover, rgba(255,255,255,.05)); }
.cw-msg-body { white-space: pre-wrap; font-size: 14px; line-height: 1.5; word-break: break-word; }
.cw-msg-actions { display: none; gap: 6px; margin-top: 6px; }
.cw-msg:hover .cw-msg-actions { display: flex; }
.cw-mini { font-size: 11px; padding: 1px 8px; border-radius: 6px; border: 1px solid var(--border, #444);
  background: none; color: inherit; cursor: pointer; opacity: .8; }
.cw-mini:hover { opacity: 1; }
.cw-compose { display: flex; gap: 8px; padding-top: 10px; align-items: flex-end; }
.cw-input { flex: 1; resize: vertical; }
@media (max-width: 800px) { .cw-wrap { flex-direction: column; } .cw-map { flex: none; border-right: none; max-height: 30vh; } }

/* ---- Drag & Drop: Bibliothek und Ordner ---- */
.lib-drop { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,.55); color: #fff; font-size: 20px; border: 3px dashed rgba(255,255,255,.5);
  pointer-events: none; }
.lib-drop.hidden { display: none; }
.nav-item.drop-target { outline: 2px dashed var(--accent, #c8963e); outline-offset: -2px; }
body.dragging-doc .card { opacity: .85; }
#up-panel { position: fixed; right: 18px; bottom: 18px; z-index: 70; min-width: 260px; max-width: 360px;
  background: var(--card, #1c1c1e); border: 1px solid var(--border, #333); border-radius: 12px;
  padding: 10px 14px; box-shadow: 0 8px 30px rgba(0,0,0,.4); display: flex; flex-direction: column; gap: 6px; }
#up-panel.hidden { display: none; }
.up-row { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.up-row-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-row-pct { opacity: .7; flex: none; }

/* ---- Empfehlungs-Feed: Reihe + eigene Themen ---- */
.rec-row { padding: 4px 2px 12px; }
.rec-row .rec-item { flex: 0 0 320px; max-width: 320px; flex-direction: column; align-items: stretch; scroll-snap-align: start; }
.rec-add { display: inline-flex; gap: 4px; align-items: center; margin-left: 6px; }
.rec-add-input { background: var(--bg-elev, rgba(255,255,255,.05)); border: 1px solid var(--line, #333);
  color: inherit; border-radius: 999px; padding: 4px 12px; font-size: 13px; width: 150px; }

/* ---- Empfehlungskarten wie Bibliothekstitel ---- */
.rec-row { padding: 4px 2px 12px; }
.rec-card { cursor: pointer; }
.rec-card .cover { position: relative; }
.cover-fallback { display: flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, var(--bg-elev2, #23231f), var(--bg-elev, #1a1a18)); }
.cover-fallback::after { content: attr(data-letter); font-size: 44px; font-weight: 600; opacity: .35; }
.rec-corner { position: absolute; left: 6px; bottom: 6px; font-size: 10px; letter-spacing: .04em;
  text-transform: uppercase; padding: 2px 7px; border-radius: 999px;
  background: rgba(0,0,0,.6); color: #fff; backdrop-filter: blur(3px); }

/* ---- Vorschau-Fenster eines Vorschlags ---- */
.rec-modal { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; padding: 24px; }
.rec-modal-box { background: var(--bg-elev, #151513); border: 1px solid var(--line, #333);
  border-radius: 14px; width: min(1100px, 100%); max-height: 90vh; display: flex; flex-direction: column; overflow: hidden; }
.rec-modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding: 16px 18px; border-bottom: 1px solid var(--line, #333); }
.rec-modal-title { font-size: 19px; margin: 0 0 4px; }
.rec-modal-body { display: flex; gap: 18px; padding: 16px 18px; overflow: hidden; min-height: 0; }
.rec-modal-info { flex: 0 0 340px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.rec-abstract { font-size: 13px; line-height: 1.55; opacity: .85; }
.rec-modal-prev { flex: 1; min-width: 0; display: flex; }
.rec-frame { flex: 1; min-height: 62vh; border: 1px solid var(--line, #333); border-radius: 10px; background: #fff; }
@media (max-width: 900px) {
  .rec-modal-body { flex-direction: column; overflow-y: auto; }
  .rec-modal-info { flex: none; } .rec-frame { min-height: 50vh; }
}

/* Rücksprung in die App, wenn der Deep-Link nicht greift */
.auth-return { display: flex; flex-direction: column; gap: 10px; margin-top: 18px;
  padding-top: 16px; border-top: 1px solid var(--line); }

/* Platzhalter, solange der Vorrat noch nicht im Browser ist */
.rec-skel { pointer-events: none; opacity: .5; }
.rec-skel .cover { aspect-ratio: 1 / 1.414; background: var(--bg-elev2, #23231f); border-radius: 10px; }
.skel-line { height: 11px; margin-top: 8px; border-radius: 5px; background: var(--bg-elev2, #23231f); color: transparent; }
.skel-line.short { width: 60%; }
.row-sub { font-size: 12px; color: var(--faint); margin-top: 2px; }

/* Kapitel-Hierarchie: Hauptkapitel tragen, Unterabschnitte ordnen sich unter */
.chapter.top .ctitle { font-weight: 600; }
.chapter.top { margin-top: 6px; }
.chapter.sub .ctitle { color: var(--muted); font-size: 14px; }
.chapter.sub-2 .ctitle { padding-left: 20px; }
.chapter.sub-3 .ctitle { padding-left: 38px; font-size: 13px; }
.chapter.sub .ctitle::before { content: ""; position: absolute; margin-left: -12px;
  width: 6px; height: 1px; background: var(--line); transform: translateY(10px); }
.chapter.sub .num { opacity: .55; }
.chapter { position: relative; }

/* Titelbild-Auswahl im Adminbereich */
.bw-kopf { margin: 14px 0 10px; }
.bw-gitter { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.bw-zelle { position: relative; padding: 0; border: 2px solid var(--line); border-radius: 10px;
  overflow: hidden; background: var(--bg-elev2); cursor: pointer; display: block; }
.bw-zelle img { display: block; width: 100%; height: 150px; object-fit: cover; object-position: top center; background: #fff; }
.bw-zelle.an { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary) inset; }
.bw-zelle.an::after { content: "✓"; position: absolute; top: 6px; right: 8px; color: var(--primary);
  font-weight: 700; background: rgba(0,0,0,.55); border-radius: 999px; width: 22px; height: 22px;
  display: grid; place-items: center; }
.bw-fuss { font-size: 11px; padding: 4px 6px; color: var(--faint); text-align: left; }

/* Kapitelvorschlag: kein Buchdeckel, sondern eine schlichte Karte */
.kap-karte { flex: 0 0 240px; text-align: left; padding: 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg-elev); color: inherit; cursor: pointer;
  display: flex; flex-direction: column; gap: 6px; }
.kap-karte:hover { background: var(--bg-elev2); }
.kap-titel { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kap-buch { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kap-fuss { font-size: 11px; color: var(--faint); margin-top: auto; }

/* Stimmenwerkstatt */
.ws-refs { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.ws-ref { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; }
.ws-proben { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.ws-probe { display: grid; grid-template-columns: 1fr minmax(240px, 380px); gap: 14px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg-elev); }
.ws-probe audio { width: 100%; }
@media (max-width: 700px) { .ws-probe { grid-template-columns: 1fr; } }
