/* Reader – Bibliothek und Leseansicht. Alle Klassen mit Präfix rd-. */

.rd-icon { display: inline-flex; width: 18px; height: 18px; flex: none; vertical-align: -3px; }
.rd-icon svg { width: 100%; height: 100%; }
.rd-grow { flex: 1 1 auto; min-width: 0; }
.rd-wide { width: 100%; }
.rd-err { color: var(--bad); }
.rd-tag { color: var(--muted); font-size: .8rem; }
.rd-badge-cards { font-size: .75rem; padding: 0 7px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }

/* Highlight-Farben */
.rd-c-yellow { --hl: var(--hl-yellow); --hl-strong: #e2b93b; }
.rd-c-blue { --hl: var(--hl-blue); --hl-strong: #5b9bd5; }
.rd-c-green { --hl: var(--hl-green); --hl-strong: #5fb26d; }
.rd-c-pink { --hl: var(--hl-pink); --hl-strong: #d9799f; }

/* ===== Bibliothek ===================================================================== */
.rd-lib { max-width: 940px; margin: 0 auto; position: relative; min-height: 70vh; }
.rd-lib-head { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.rd-lib-title { margin: 0; font-family: var(--font-read); font-size: 1.9rem; font-weight: 600; letter-spacing: -.01em; }
.rd-search-wrap { position: relative; flex: 1 1 auto; max-width: 420px; margin-left: auto; }
.rd-search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); width: 16px; height: 16px; }
.rd-search { width: 100%; padding-left: 32px; border-radius: 999px; background: var(--bg-elev); }
.rd-add-btn { display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }

.rd-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 10px; overflow-x: auto; scrollbar-width: none; }
.rd-tab { font: inherit; background: none; border: 0; padding: 9px 14px 10px; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.rd-tab:hover { color: var(--fg); }
.rd-tab.active { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }
.rd-tab-n { font-size: .75rem; font-weight: 500; color: var(--muted); background: var(--border); border-radius: 999px; padding: 0 7px; }

.rd-filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; min-height: 34px; }
.rd-select { padding: 4px 8px; font-size: .88rem; }
.rd-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.rd-chip { font: inherit; font-size: .82rem; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border); background: transparent; color: var(--muted); cursor: pointer; }
.rd-chip:hover { border-color: var(--accent); color: var(--fg); }
.rd-chip.active { background: var(--accent); border-color: var(--accent); color: var(--bg-elev); }
.rd-filter-actions { margin-left: auto; display: flex; gap: 6px; }
.rd-filter-actions .btn { display: inline-flex; gap: 4px; align-items: center; font-size: .88rem; }

.rd-list { display: flex; flex-direction: column; }
.rd-row { display: grid; grid-template-columns: 52px 1fr auto; gap: 14px; padding: 14px 10px; border-bottom: 1px solid var(--border);
  color: var(--fg); text-decoration: none; border-radius: 8px; position: relative; }
.rd-row:hover { background: var(--bg-elev); }
.rd-row.selected { background: var(--accent-soft); }
.rd-row-icon { width: 52px; height: 52px; border-radius: 8px; background: var(--bg-elev); border: 1px solid var(--border);
  display: grid; place-items: center; color: var(--muted); overflow: hidden; }
.rd-row-icon img { width: 100%; height: 100%; object-fit: cover; }
.rd-row-icon .rd-icon { width: 24px; height: 24px; }
.rd-type-youtube { color: #c4302b; } .rd-type-podcast { color: #8a4fbf; } .rd-type-pdf { color: #b23b3b; }
.rd-type-rss { color: #d9822b; } .rd-type-book, .rd-type-epub { color: #2e7d4f; }
.rd-row-main { min-width: 0; }
.rd-row-title { font-family: var(--font-read); font-size: 1.08rem; font-weight: 600; line-height: 1.3; margin-bottom: 3px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rd-row-meta { display: flex; flex-wrap: wrap; gap: 4px 0; font-size: .82rem; color: var(--muted); }
.rd-row-meta > span + span::before { content: "·"; margin: 0 6px; color: var(--border); }
.rd-row-meta > .rd-tag::before { content: ""; margin: 0 0 0 8px; }
.rd-type-label { font-weight: 600; }
.rd-row-hl { color: var(--accent); }
.rd-row-sum { font-size: .88rem; color: var(--muted); margin-top: 5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rd-row-progress { height: 3px; background: var(--border); border-radius: 2px; margin-top: 8px; max-width: 240px; overflow: hidden; }
.rd-row-progress span { display: block; height: 100%; background: var(--accent); }
.rd-row-side { display: flex; flex-direction: column; align-items: flex-end; justify-content: space-between; gap: 6px; }
.rd-row-date { font-size: .78rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.rd-row-acts { display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.rd-row:hover .rd-row-acts, .rd-row.selected .rd-row-acts, .rd-row:focus-within .rd-row-acts { opacity: 1; }
.rd-row-act { background: none; border: 0; padding: 4px; border-radius: 6px; color: var(--muted); cursor: pointer; }
.rd-row-act:hover { background: var(--border); color: var(--fg); }
.rd-empty { padding: 50px 10px; text-align: center; color: var(--muted); }
.rd-empty p { margin: .3em 0; }

.rd-drop { display: none; position: absolute; inset: 0; border: 2px dashed var(--accent); border-radius: 14px;
  background: color-mix(in srgb, var(--accent-soft) 85%, transparent); place-items: center; font-size: 1.2rem; z-index: 5; text-align: center; }
.rd-lib.rd-dragging .rd-drop { display: grid; }

/* Highlights-Liste (Bibliothek) */
.rd-hlcard { padding: 14px 4px 14px 16px; border-bottom: 1px solid var(--border); position: relative; }
.rd-hlcard::before { content: ""; position: absolute; left: 0; top: 16px; bottom: 16px; width: 3px; border-radius: 2px; background: var(--hl-strong); }
.rd-hlcard-text { margin: 0 0 6px; font-family: var(--font-read); font-size: 1.04rem; line-height: 1.55; white-space: pre-wrap; }
.rd-hlcard-note { font-size: .9rem; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; margin-bottom: 6px; }
.rd-hlcard-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: .84rem; }
.rd-hlcard-doc { color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 3px; }
.rd-hlcard-doc:hover { color: var(--accent); }
.btn.small { font-size: .82rem; padding: 3px 8px; display: inline-flex; gap: 4px; align-items: center; }

/* Hinzufügen-Dialog */
.rd-seg { display: inline-flex; background: var(--bg); border: 1px solid var(--border); border-radius: 9px; padding: 3px; margin-bottom: 12px; }
.rd-seg button { font: inherit; border: 0; background: transparent; padding: 5px 16px; border-radius: 6px; cursor: pointer; color: var(--muted); }
.rd-seg button.active { background: var(--bg-elev); color: var(--fg); box-shadow: var(--shadow); font-weight: 600; }
.rd-add-common { display: flex; gap: 12px; margin-top: 14px; align-items: flex-end; }
.rd-dropzone { border: 2px dashed var(--border); border-radius: 12px; padding: 28px 14px; text-align: center; cursor: pointer; display: grid; gap: 4px; }
.rd-dropzone:hover, .rd-dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.rd-feeds { display: flex; flex-direction: column; gap: 4px; }
.rd-feed { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--border); }
.rd-feed .small { word-break: break-all; }

/* ===== Leseansicht ====================================================================== */
.rd-topbar { position: sticky; top: 0; z-index: 20; display: flex; gap: 2px; align-items: center;
  margin: -24px -32px 0; padding: 8px 20px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.rd-tb-btn { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: .9rem; padding: 6px 10px; }
.rd-tb-btn:hover { color: var(--fg); background: var(--bg-elev); }
.rd-tb-btn.active { color: var(--accent); }
.rd-hl-count { font-size: .75rem; min-width: 1.4em; text-align: center; }
.rd-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; }
.rd-progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s linear; }

.rd-doc { display: grid; grid-template-columns: 1fr 0; transition: grid-template-columns .2s ease; }
.rd-doc.panel-open { grid-template-columns: 1fr 330px; }
.rd-main { min-width: 0; padding: 0 16px; }
.rd-article { max-width: 680px; margin: 0 auto; padding: 44px 0 120px; }
.rd-doc-head { margin-bottom: 30px; }
.rd-doc-kicker { display: flex; gap: 8px; align-items: center; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 10px; }
.rd-doc-kicker .rd-tag { text-transform: none; letter-spacing: 0; }
.rd-doc-title { font-family: var(--font-read); font-size: clamp(1.7rem, 3.4vw, 2.35rem); line-height: 1.18; font-weight: 600; letter-spacing: -.015em; margin: 0 0 12px; }
.rd-doc-meta { color: var(--muted); font-size: .92rem; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.rd-orig { display: inline-flex; gap: 4px; align-items: center; text-decoration: none; }
.rd-nosubs { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: -10px 0 26px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-elev); }
.rd-nosubs-text { flex: 1 1 160px; color: var(--muted); font-size: .95rem; }
.rd-nosubs .btn { display: inline-flex; gap: 6px; align-items: center; }

.rd-content { font-family: var(--font-read); font-size: 1.16rem; line-height: 1.72; color: var(--fg); overflow-wrap: break-word; }
.rd-content > * { border-radius: 6px; transition: background-color .15s, box-shadow .15s; }
.rd-content p { margin: 0 0 1.05em; }
.rd-content h1, .rd-content h2, .rd-content h3, .rd-content h4 { font-family: var(--font-read); margin: 1.6em 0 .55em; line-height: 1.25; }
.rd-content h1 { font-size: 1.6rem; } .rd-content h2 { font-size: 1.38rem; } .rd-content h3 { font-size: 1.18rem; } .rd-content h4 { font-size: 1.05rem; }
.rd-content ul, .rd-content ol { padding-left: 1.4em; margin: 0 0 1.05em; }
.rd-content li { margin: .25em 0; }
.rd-content blockquote { margin: 0 0 1.05em; padding: 2px 0 2px 18px; border-left: 3px solid var(--border); color: var(--muted); font-style: italic; }
.rd-content pre { font-size: .82rem; line-height: 1.5; background: var(--bg-elev); border: 1px solid var(--border); }
.rd-content code { font-size: .86em; background: var(--bg-elev); padding: 1px 4px; border-radius: 4px; }
.rd-content pre code { background: none; padding: 0; }
.rd-content a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
.rd-content img { max-width: 100%; height: auto; }
.rd-content hr { border: 0; border-top: 1px solid var(--border); margin: 2em auto; width: 40%; }
.rd-content table { font-family: var(--font); font-size: .9rem; display: block; overflow-x: auto; }
.rd-content .rd-focus { background: var(--accent-soft); box-shadow: -10px 0 0 var(--accent-soft), 10px 0 0 var(--accent-soft), -13px 0 0 var(--accent); }

/* Transkripte */
.rd-ts { display: inline-block; font-family: var(--mono); font-size: .7rem; line-height: 1; padding: 4px 6px; border-radius: 6px;
  background: var(--bg-elev); border: 1px solid var(--border); color: var(--muted); vertical-align: 3px; font-style: normal; }
.rd-ts.link { cursor: pointer; }
.rd-ts.link:hover { color: var(--accent); border-color: var(--accent); }

/* Highlights im Text */
mark.rd-hl { background: var(--hl); color: inherit; border-radius: 2px; padding: 1px 0; cursor: pointer;
  box-decoration-break: clone; -webkit-box-decoration-break: clone; }
mark.rd-hl.has-note { border-bottom: 2px solid var(--hl-strong); }
mark.rd-hl.flash { animation: rd-flash 1.3s ease; }
@keyframes rd-flash { 0%, 60% { box-shadow: 0 0 0 3px var(--hl-strong); } 100% { box-shadow: 0 0 0 0 transparent; } }

.rd-doc-foot { margin-top: 50px; padding-top: 24px; border-top: 1px solid var(--border); text-align: center; }
.rd-doc-foot .btn { display: inline-flex; gap: 6px; align-items: center; }

/* Seitenleiste */
.rd-panel { position: sticky; top: 50px; align-self: start; height: calc(100vh - 50px); overflow: hidden;
  border-left: 1px solid var(--border); display: flex; flex-direction: column; background: var(--bg); min-width: 0; }
.rd-doc:not(.panel-open) .rd-panel { visibility: hidden; }
.rd-panel-head { display: flex; gap: 8px; align-items: center; padding: 16px 16px 10px; }
.rd-panel-list { flex: 1; overflow-y: auto; padding: 0 12px 12px; }
.rd-panel-empty { padding: 20px 16px; flex: 1; }
.rd-panel-foot { padding: 8px 12px; border-top: 1px solid var(--border); }
.rd-pi { position: relative; padding: 10px 6px 8px 14px; border-bottom: 1px solid var(--border); }
.rd-pi::before { content: ""; position: absolute; left: 2px; top: 12px; bottom: 12px; width: 3px; border-radius: 2px; background: var(--hl-strong); }
.rd-pi.lost { opacity: .7; }
.rd-pi-text { font-family: var(--font-read); font-size: .95rem; line-height: 1.5; cursor: pointer; white-space: pre-wrap; }
.rd-pi-text:hover { color: var(--accent); }
.rd-pi-note { margin-top: 6px; font-size: .86rem; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 7px; padding: 5px 8px; white-space: pre-wrap; }
.rd-pi-foot { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.rd-mini { background: none; border: 0; padding: 3px; border-radius: 6px; color: var(--muted); cursor: pointer; opacity: .55; }
.rd-mini .rd-icon { width: 16px; height: 16px; }
.rd-pi:hover .rd-mini { opacity: 1; }
.rd-mini:hover { background: var(--border); color: var(--fg); }
.rd-note-quote { margin: 0; padding: 6px 0 6px 12px; border-left: 3px solid var(--hl-strong); font-family: var(--font-read); color: var(--muted); max-height: 160px; overflow: auto; }

/* Reiter und KI-Chat in der Seitenleiste */
.rd-ptab { background: none; border: 0; padding: 4px 2px; margin-right: 8px; font: inherit; font-weight: 600; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent; }
.rd-ptab.active { color: var(--fg); border-bottom-color: var(--accent); }
.rd-chat { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.rd-chat-log { flex: 1; overflow-y: auto; padding: 4px 12px 12px; display: flex; flex-direction: column; gap: 10px; }
.rd-chat-msg { padding: 8px 11px; border-radius: 10px; font-size: .92rem; line-height: 1.5; max-width: 100%; overflow-wrap: anywhere; }
.rd-chat-msg.user { align-self: flex-end; background: var(--accent); color: var(--bg-elev); white-space: pre-wrap; max-width: 92%; }
.rd-chat-msg.assistant { background: var(--bg-elev); border: 1px solid var(--border); }
.rd-chat-msg.assistant .md p:last-child { margin-bottom: 0; }
.rd-chat-msg-quote { font-size: .82rem; opacity: .85; border-left: 2px solid currentColor; padding-left: 7px; margin-bottom: 5px; }
.rd-chat-drafts { margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--border); display: flex; gap: 8px; align-items: center; }
.rd-chat-hint { padding: 8px 4px; font-size: .9rem; }
.rd-chat-sugg { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; margin: 10px 0; }
.rd-chat-compose { border-top: 1px solid var(--border); padding: 8px 12px 10px; display: flex; flex-direction: column; gap: 6px; }
.rd-chat-compose textarea { width: 100%; resize: vertical; min-height: 56px; box-sizing: border-box; }
.rd-chat-row { display: flex; align-items: center; gap: 8px; }
.rd-chat-full { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; }
.rd-chat-quote { display: flex; gap: 6px; align-items: flex-start; font-family: var(--font-read); font-size: .85rem; color: var(--muted);
  border-left: 3px solid var(--hl-strong); padding: 2px 0 2px 8px; max-height: 90px; overflow: auto; }
.rd-chat-quote-text { flex: 1; white-space: pre-wrap; }

.rd-chat-quote[hidden] { display: none; }

/* Im Lernportal scrollt .lp-host (Innenabstand 22px 30px), nicht das Fenster:
   Kopfleiste bündig oben, Seitenleiste genau darunter und so hoch wie der Bereich. */
.lp-host.view:has(> .rd-topbar) { container-type: size; }
.lp-host.view > .rd-topbar { margin: -22px -30px 0; top: -22px; }
.lp-app.mobile .lp-host.view > .rd-topbar { margin: -14px -14px 0; top: -14px; }
@media (min-width: 1001px) {
  .lp-host.view .rd-panel { top: 31px; height: calc(100cqh - 9px); }
}

/* Schwebende Werkzeugleiste */
.rd-toolbar { position: fixed; z-index: 60; display: flex; gap: 4px; align-items: center; padding: 5px 6px; border-radius: 12px;
  background: var(--fg); color: var(--bg); box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.rd-toolbar[hidden] { display: none; }
.rd-tb-color { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; background: var(--hl-strong); cursor: pointer; padding: 0; margin: 0 1px; }
.rd-tb-color:hover { transform: scale(1.12); }
.rd-tb-color.active { border-color: var(--bg); }
.rd-tb-sep { width: 1px; height: 20px; background: color-mix(in srgb, var(--bg) 35%, transparent); margin: 0 4px; }
.rd-tb-act { font: inherit; font-size: .82rem; background: none; border: 0; color: inherit; display: inline-flex; gap: 4px; align-items: center;
  padding: 4px 7px; border-radius: 7px; cursor: pointer; }
.rd-tb-act:hover { background: color-mix(in srgb, var(--bg) 18%, transparent); }
.rd-tb-act .rd-icon { width: 16px; height: 16px; }

/* Menü */
.rd-menu { position: fixed; z-index: 70; min-width: 240px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.18); padding: 5px; display: flex; flex-direction: column; }
.rd-menu button { font: inherit; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 7px; color: var(--fg); cursor: pointer; }
.rd-menu button:hover { background: var(--accent-soft); }
.rd-menu button:last-child { color: var(--bad); }

/* Tastenkürzel */
.rd-keys { border-collapse: collapse; width: 100%; }
.rd-keys td { padding: 5px 8px; border-bottom: 1px solid var(--border); }
.rd-keys td:first-child { white-space: nowrap; width: 1%; color: var(--muted); }
kbd { font-family: var(--mono); font-size: .8rem; padding: 1px 6px; border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 5px; background: var(--bg-elev); color: var(--fg); }

/* ===== Mobil ===================================================================== */
@media (max-width: 1000px) {
  .rd-doc.panel-open { grid-template-columns: 1fr; }
  .rd-panel { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: min(62vh, 520px); z-index: 40;
    border-left: 0; border-top: 1px solid var(--border); border-radius: 16px 16px 0 0; box-shadow: 0 -10px 30px rgba(0,0,0,.18);
    background: var(--bg-elev); transform: translateY(105%); transition: transform .22s ease; visibility: visible; }
  .rd-doc.panel-open .rd-panel { transform: none; }
  .rd-doc:not(.panel-open) .rd-panel { visibility: visible; }
}
@media (max-width: 760px) {
  .rd-topbar { margin: -16px -16px 0; padding: 6px 8px; }
  .rd-tb-label { display: none; }
  .rd-main { padding: 0; }
  .rd-article { padding-top: 26px; }
  .rd-content { font-size: 1.08rem; }
  .rd-lib-head { flex-wrap: wrap; }
  .rd-search-wrap { order: 3; max-width: none; flex-basis: 100%; }
  .rd-add-btn { margin-left: auto; }
  .rd-row { grid-template-columns: 40px 1fr; gap: 10px; padding: 12px 4px; }
  .rd-row-icon { width: 40px; height: 40px; }
  .rd-row-side { grid-column: 2; flex-direction: row; align-items: center; }
  .rd-row-acts { opacity: 1; }
  .rd-add-common { flex-direction: column; align-items: stretch; }
}
