:root {
  --bg: #fafafa;
  --bg-elev: #fff;
  --fg: #1a1a1a;
  --muted: #6b6b6b;
  --border: #e0e0e0;
  --accent: #1f6feb;
  --accent-soft: #ddebff;
  --read: #2ea043;
  --warn: #d29922;
  --danger: #cf222e;
  --shadow: 0 1px 4px rgba(0,0,0,.06);
}
[data-theme="dark"] {
  --bg: #0d1117;
  --bg-elev: #161b22;
  --fg: #e6edf3;
  --muted: #8b949e;
  --border: #30363d;
  --accent: #58a6ff;
  --accent-soft: #1e3a5f;
  --read: #3fb950;
  --warn: #d29922;
  --danger: #f85149;
  --shadow: 0 1px 4px rgba(0,0,0,.3);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
}

/* ---- Auth-Seite (Login/Install) ---- */
body.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
body.auth .card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  box-shadow: var(--shadow);
}
body.auth h1 { margin-top: 0; }
body.auth label { display: block; margin: 14px 0; }
body.auth label.checkbox { display: flex; align-items: center; gap: 8px; }
body.auth input[type="text"],
body.auth input[type="password"],
body.auth input:not([type]) {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font-size: 15px;
}
body.auth button {
  width: 100%;
  margin-top: 16px;
  padding: 12px;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
body.auth button:hover { filter: brightness(1.05); }
.err { color: var(--danger); }
.ok { color: var(--read); }

/* ---- Portal-Seite ---- */
body.portal {
  display: grid;
  grid-template-columns: 340px 1fr;
  grid-template-rows: 56px 1fr;
  grid-template-areas: "topbar topbar" "sidebar main";
  height: 100vh;
  overflow: hidden;
}
.topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.topbar .brand {
  font-weight: 700;
  font-size: 17px;
  text-decoration: none;
  color: var(--fg);
}
.topbar .progress { flex: 1; max-width: 360px; }
.topbar .progress-bar {
  height: 8px; background: var(--border); border-radius: 4px; overflow: hidden;
}
.topbar .progress-bar > div { height: 100%; background: var(--read); transition: width .3s; }
.topbar .progress-text { font-size: 13px; color: var(--muted); margin-top: 2px; }
.topbar input[type="search"] {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  width: 220px;
}
.topbar button {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-elev);
  color: var(--fg);
  cursor: pointer;
}
.topbar button:hover { background: var(--accent-soft); }
.topbar .me { font-size: 13px; color: var(--muted); }
.topbar .me a { color: var(--accent); text-decoration: none; }
.menu-toggle { display: none; }

.sidebar {
  grid-area: sidebar;
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px 0;
}
.sidebar details { margin: 0; }
.sidebar summary {
  padding: 10px 16px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  color: var(--fg);
  border-bottom: 1px solid var(--border);
  list-style: none;
}
.sidebar summary::-webkit-details-marker { display: none; }
.sidebar summary:hover { background: var(--accent-soft); }
.sidebar summary .count { color: var(--muted); font-weight: normal; margin-left: 6px; font-size: 12px; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar li a {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  padding: 7px 16px 7px 32px;
  color: var(--fg);
  text-decoration: none;
  font-size: 13.5px;
  border-left: 3px solid transparent;
}
.sidebar li a:hover { background: var(--accent-soft); }
.sidebar li a.active { background: var(--accent-soft); border-left-color: var(--accent); font-weight: 600; }
.sidebar li a.read { color: var(--muted); }
.sidebar li a.read::before { content: "✓ "; color: var(--read); }
.sidebar li a.due { border-left-color: var(--warn); }
.sidebar li a .date { color: var(--muted); font-size: 11px; flex-shrink: 0; }

.lernpfad-block { background: var(--accent-soft); border-bottom: 2px solid var(--accent); }
.lernpfad-block summary { background: transparent; }
.lernpfad-block .lp-list { padding: 0 16px 12px; }
.lernpfad-block .lp-section h4 { margin: 12px 0 4px; font-size: 12px; text-transform: uppercase; color: var(--muted); }
.lernpfad-block .lp-item {
  display: block;
  padding: 6px 8px;
  margin: 3px 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  color: var(--fg);
  font-size: 13px;
}
.lernpfad-block .lp-item:hover { border-color: var(--accent); }
.lernpfad-block .lp-empty { font-size: 13px; color: var(--muted); margin: 4px 0; }

.main {
  grid-area: main;
  overflow-y: auto;
  padding: 28px 36px 80px;
}
.main .container { max-width: 880px; margin: 0 auto; }

h1, h2, h3, h4 { line-height: 1.25; }
h1 { font-size: 26px; margin-top: 0; }
h2 { font-size: 20px; border-bottom: 2px solid var(--border); padding-bottom: 6px; margin-top: 36px; }
h3 { font-size: 17px; margin-top: 24px; }
h4 { font-size: 15px; margin-top: 18px; }
p { margin: 12px 0; }
ul, ol { padding-left: 24px; }
li { margin: 4px 0; }
em { color: var(--muted); }
strong { color: var(--fg); }
hr { border: none; border-top: 1px solid var(--border); margin: 28px 0; }

.welcome-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin: 24px 0; }
.welcome-tile {
  padding: 18px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-align: center;
}
.welcome-tile h3 { font-size: 13px; text-transform: uppercase; color: var(--muted); margin: 0; }
.welcome-tile .big { font-size: 32px; font-weight: 700; margin: 6px 0; color: var(--accent); }
.welcome-tile p { margin: 0; font-size: 13px; color: var(--muted); }

.chapter-header { padding-bottom: 16px; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.chapter-header h1 { margin: 4px 0 0; }
.part-tag { font-size: 12px; text-transform: uppercase; color: var(--muted); }
.chapter-meta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.chapter-body { font-size: 16px; }
.chapter-body h2 { font-size: 24px; margin: 30px 0 10px; padding-top: 6px; }
.chapter-body h3 { font-size: 20px; margin: 24px 0 8px; }
.chapter-body h4 { font-size: 17px; margin: 20px 0 6px; }
.chapter-body h5 { font-size: 15px; margin: 16px 0 6px; color: var(--muted); }
.chapter-body p { margin: 0 0 14px; }
.chapter-body ul, .chapter-body ol { margin: 0 0 14px; padding-left: 24px; }
.chapter-body li { margin: 4px 0; }
.chapter-body strong { font-weight: 700; }
.chapter-body img { max-width: 100%; height: auto; }
.chapter-body hr { border: 0; border-top: 1px solid var(--border); margin: 28px 0; }
.chapter-body code {
  background: var(--accent-soft); padding: 1px 5px; border-radius: 4px;
  font-size: 14px; font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}
.chapter-body pre { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 8px; padding: 12px; overflow-x: auto; }
.chapter-body pre code { background: none; padding: 0; }

/* Tabellen (die SHK-Kapitel sind tabellenlastig) */
.chapter-body table {
  width: 100%; border-collapse: collapse; margin: 8px 0 22px; font-size: 14.5px;
  display: block; overflow-x: auto;
}
.chapter-body th, .chapter-body td {
  border: 1px solid var(--border); padding: 8px 11px; text-align: left; vertical-align: top;
}
.chapter-body thead th { background: var(--accent-soft); font-weight: 700; }
.chapter-body tbody tr:nth-child(even) { background: rgba(127,127,127,.06); }

/* „Merke“- und Hinweis-Callouts (Markdown-Blockquotes) */
.chapter-body blockquote {
  margin: 16px 0; padding: 12px 16px;
  background: var(--accent-soft);
  border-left: 4px solid var(--accent);
  border-radius: 0 8px 8px 0;
}
.chapter-body blockquote p { margin: 0 0 6px; }
.chapter-body blockquote p:last-child { margin-bottom: 0; }

.quiz-card {
  margin: 32px 0 16px;
  padding: 22px;
  background: var(--bg-elev);
  border: 2px solid var(--accent);
  border-radius: 10px;
}
.quiz-card h3 { margin-top: 0; }
.quiz-card .hint { font-size: 13px; color: var(--muted); }
.quiz-card button {
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-right: 8px;
}
.quiz-card button.primary { background: var(--accent); color: white; border-color: var(--accent); }
.quiz-card button:hover { filter: brightness(1.05); }
.quiz-card button:disabled { opacity: 0.6; cursor: not-allowed; }
.quiz-start-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.quiz-start-row button { flex: 1; min-width: 200px; margin-right: 0; padding: 14px; }
.quiz-mode-badge {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  background: var(--accent-soft); color: var(--accent); margin-bottom: 12px;
}
.quiz-mode-badge.learn { background: color-mix(in srgb, var(--read) 25%, transparent); color: var(--read); }

/* Lernmodus: Sofort-Feedback je Frage */
.quiz-q .live-feedback {
  margin-top: 12px; padding: 12px 14px; border-radius: 6px;
  font-size: 14px; display: none;
}
.quiz-q.answered.correct .live-feedback {
  display: block;
  background: color-mix(in srgb, var(--read) 18%, transparent);
  border-left: 4px solid var(--read);
}
.quiz-q.answered.wrong .live-feedback {
  display: block;
  background: color-mix(in srgb, var(--danger) 18%, transparent);
  border-left: 4px solid var(--danger);
}
.quiz-q.answered .quiz-opt input[type="radio"]:checked,
.quiz-q.answered .quiz-opt input[type="checkbox"]:checked { pointer-events: none; }
.quiz-q.answered .quiz-opt.correct { border-color: var(--read); background: color-mix(in srgb, var(--read) 10%, transparent); }
.quiz-q.answered .quiz-opt.picked-wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.quiz-q.answered .quiz-opt input { pointer-events: none; }
.quiz-q .check-row { margin-top: 10px; }
.quiz-q .check-row button { padding: 8px 16px; }

.quiz-q {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  margin: 12px 0;
}
.quiz-q legend {
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 8px;
}
.quiz-question { font-weight: 600; margin: 4px 0 12px; }
.quiz-opt {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 8px 12px;
  margin: 6px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}
.quiz-opt:hover { background: var(--accent-soft); }
.quiz-opt input { margin-top: 4px; }

.quiz-score {
  padding: 18px;
  border-radius: 8px;
  margin-bottom: 12px;
  border: 2px solid var(--border);
}
.quiz-score h3 { margin: 0 0 6px; font-size: 22px; }
.quiz-score.good { border-color: var(--read); background: color-mix(in srgb, var(--read) 12%, transparent); }
.quiz-score.okay { border-color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.quiz-score.fail { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }

.quiz-review { margin: 14px 0; }
.quiz-review summary { cursor: pointer; padding: 8px 0; font-weight: 600; }
.quiz-review-item { padding: 12px 14px; margin: 8px 0; border-left: 4px solid var(--border); background: var(--bg); border-radius: 4px; }
.quiz-review-item.ok { border-left-color: var(--read); }
.quiz-review-item.fail { border-left-color: var(--danger); }
.quiz-review-item ul { list-style: none; padding-left: 0; }
.quiz-review-item li { padding: 4px 8px; margin: 2px 0; border-radius: 4px; }
.quiz-review-item li.correct { background: color-mix(in srgb, var(--read) 20%, transparent); font-weight: 600; }
.quiz-review-item li.wrong { background: color-mix(in srgb, var(--danger) 20%, transparent); text-decoration: line-through; }

.chapter-nav { display: flex; gap: 12px; margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); }
.chapter-nav a {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 6px;
  text-decoration: none;
  color: var(--fg);
  background: var(--bg-elev);
  flex: 1;
  font-size: 14px;
  max-width: 48%;
}
.chapter-nav a:hover { background: var(--accent-soft); border-color: var(--accent); }
.chapter-nav a.next { text-align: right; margin-left: auto; }
.chapter-nav .label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; }

#search-results { padding: 12px 0; }
.search-result {
  padding: 12px 16px;
  margin: 8px 0;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
}
.search-result:hover { border-color: var(--accent); background: var(--accent-soft); }
.search-result h4 { margin: 0 0 4px 0; font-size: 15px; }
.search-result .snippet { color: var(--muted); font-size: 13px; }
.search-result .part-tag { font-size: 11px; }
mark { background: yellow; color: black; padding: 0 2px; border-radius: 2px; }

/* ---- Admin-Seite ---- */
body.admin .topbar {
  position: sticky; top: 0;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex; gap: 16px; align-items: center;
  font-size: 14px;
}
body.admin .topbar .brand { color: var(--accent); text-decoration: none; }
body.admin .topbar .me { margin-left: auto; color: var(--muted); }
body.admin .topbar .me a { color: var(--accent); }
body.admin .container { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }
body.admin .card { background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; padding: 22px; margin: 18px 0; }
body.admin .card h2 { margin-top: 0; }
body.admin .row { display: flex; flex-wrap: wrap; gap: 12px; }
body.admin .row label { flex: 1; min-width: 180px; }
body.admin label { display: block; margin: 8px 0; font-size: 14px; }
body.admin input, body.admin select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--fg); font-size: 14px; width: 100%;
}
body.admin .inline { display: inline; }
body.admin button {
  padding: 8px 14px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--accent); color: white; font-weight: 600; cursor: pointer;
}
body.admin button.danger { background: var(--danger); }
body.admin table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
body.admin th, body.admin td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
body.admin .actions { white-space: nowrap; }
body.admin .actions form + form { margin-left: 8px; }
body.admin .hint { font-size: 13px; color: var(--muted); margin-top: 8px; }

/* ---- Mobile ---- */
@media (max-width: 800px) {
  body.portal {
    grid-template-columns: 1fr;
    grid-template-areas: "topbar" "main";
  }
  body.portal .sidebar {
    position: fixed; top: 56px; left: 0; bottom: 0; width: 320px; max-width: 90vw;
    transform: translateX(-100%); transition: transform .25s; z-index: 4;
  }
  body.portal.sidebar-open .sidebar { transform: translateX(0); }
  .menu-toggle { display: inline-block; }
  .topbar input[type="search"] { width: 130px; }
  .topbar .brand { font-size: 15px; }
  .topbar .progress, .topbar .me { display: none; }
  .main { padding: 18px 16px 80px; }
}

@media print {
  .topbar, .sidebar, .chapter-nav, .srs-card { display: none !important; }
  body.portal { display: block; height: auto; overflow: visible; }
  .main { overflow: visible; padding: 0; }
}

/* ======================================================================
   QUIZ-ENGINE v2 — Prüfungs-Topbar/Navigator, neue Fragetypen, Auswertung
   ====================================================================== */

/* Sticky Topbar im Prüfungsmodus */
.quiz-topbar {
  position: sticky; top: -6px; z-index: 3;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; margin: -4px 0 14px;
  background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px;
}
.quiz-topbar.learn { border-style: dashed; }
.quiz-time {
  font-variant-numeric: tabular-nums; font-weight: 700;
  padding: 3px 9px; border-radius: 6px; background: var(--bg); border: 1px solid var(--border);
}
.quiz-count { font-size: 13px; color: var(--muted); }
.quiz-nav { display: flex; flex-wrap: wrap; gap: 5px; margin-left: auto; }
.navdot {
  width: 30px; height: 30px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg); color: var(--fg);
  font-size: 13px; font-weight: 600;
}
.navdot.answered { background: var(--accent); color: #fff; border-color: var(--accent); }
.navdot.marked { box-shadow: inset 0 0 0 2px var(--warn); }
.navdot:hover { filter: brightness(1.08); }

.mark-btn {
  background: none; border: none; cursor: pointer; font-size: 15px;
  filter: grayscale(1) opacity(.5); padding: 0 4px; margin: 0;
}
.mark-btn.active { filter: none; }
.quiz-q.marked { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn); }
.q-type { text-transform: none; color: var(--accent); font-weight: 600; }

.quiz-submit-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.quiz-submit-row button { flex: 1; min-width: 160px; margin-right: 0; padding: 13px; }

/* Wahr/Falsch */
.type-truefalse .quiz-opt { max-width: 220px; }

/* Zuordnung (matching) */
.match-grid { display: flex; flex-direction: column; gap: 8px; }
.match-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: center;
  padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px;
}
.match-left { font-weight: 600; }
.match-sel, .cloze-sel {
  padding: 7px 9px; border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg); color: var(--fg); font-size: 14px; max-width: 100%;
}
.match-row.correct { border-color: var(--read); background: color-mix(in srgb, var(--read) 10%, transparent); }
.match-row.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.match-fix { grid-column: 1 / -1; font-size: 13px; color: var(--read); font-weight: 600; }

/* Reihenfolge (ordering) */
.order-list { list-style: none; padding-left: 0; margin: 6px 0; counter-reset: ord; }
.order-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; margin: 6px 0; background: var(--bg-elev);
  border: 1px solid var(--border); border-radius: 8px; cursor: grab;
}
.order-item::before { counter-increment: ord; content: counter(ord); font-weight: 700; color: var(--accent); min-width: 18px; }
.order-item.dragging { opacity: .5; }
.order-item.correct { border-color: var(--read); background: color-mix(in srgb, var(--read) 10%, transparent); }
.order-item.wrong { border-color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.order-grip { color: var(--muted); cursor: grab; }
.order-text { flex: 1; }
.order-btns button {
  padding: 2px 8px; margin: 0 2px; font-size: 12px; border: 1px solid var(--border);
  border-radius: 5px; background: var(--bg); color: var(--fg); cursor: pointer;
}
.order-solution { margin: 8px 0 0; padding-left: 20px; font-size: 14px; color: var(--read); }
.order-solution li { margin: 2px 0; }

/* Lückentext (cloze) */
.cloze-text { line-height: 2.2; }
.cloze-sel { margin: 0 3px; }
.cloze-sel.correct { border-color: var(--read); }
.cloze-sel.wrong { border-color: var(--danger); }
.cloze-fix { color: var(--read); font-weight: 600; font-size: 13px; }

/* Ergebnis: Score-Ring + Aktionen */
.quiz-score { display: flex; align-items: center; gap: 20px; }
.score-ring {
  --pct: 0; width: 92px; height: 92px; border-radius: 50%; flex: 0 0 auto;
  display: grid; place-items: center;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--border) 0);
}
.score-ring span {
  width: 68px; height: 68px; border-radius: 50%; background: var(--bg-elev);
  display: grid; place-items: center; font-weight: 700; font-size: 18px;
}
.quiz-score.good .score-ring { --accent: var(--read); }
.quiz-score.fail .score-ring { --accent: var(--danger); }
.score-txt h3 { margin: 0 0 4px; }
.result-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.result-actions button {
  padding: 11px 16px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--fg); font-weight: 600; cursor: pointer;
}
.result-actions button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Review-Listen: kein Durchstreichen bei Zuordnung/Reihenfolge/Lücke */
.quiz-review-item .rev-opts, .quiz-review-item .rev-order { list-style: none; padding-left: 0; }
.quiz-review-item .rev-opts li.wrong, .quiz-review-item .rev-order li.wrong { text-decoration: none; }
.quiz-review-item .rev-order { counter-reset: rev; }
.quiz-review-item .rev-order li::before { counter-increment: rev; content: counter(rev) ". "; font-weight: 700; }
.rev-your { color: var(--danger); font-size: 13px; }
.rev-line { margin: 4px 0; }

@media (max-width: 560px) {
  .match-row { grid-template-columns: 1fr; gap: 4px; }
  .quiz-nav { width: 100%; margin-left: 0; }
  .quiz-score { flex-direction: column; text-align: center; }
}

/* ======================================================================
   INTERAKTIVE KAPITEL — Callouts, Glossar-Tooltips, klappbare Abschnitte,
   Lesefortschritt (enhance.js)
   ====================================================================== */

/* Callout-Boxen (aus Blockquotes) */
.chapter-body blockquote.callout {
  position: relative; padding: 12px 16px 12px 46px; border-radius: 8px;
  border-left: 4px solid var(--accent); background: var(--accent-soft);
}
.chapter-body blockquote.callout::before {
  content: attr(data-icon); position: absolute; left: 14px; top: 11px; font-size: 18px; line-height: 1;
}
.callout .callout-label { display: inline-block; margin-right: 4px; text-transform: uppercase; font-size: 12px; letter-spacing: .04em; }
.callout-merke  { border-left-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.callout-warn   { border-left-color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.callout-warn .callout-label { color: var(--danger); }
.callout-praxis { border-left-color: var(--read); background: color-mix(in srgb, var(--read) 12%, transparent); }
.callout-praxis .callout-label { color: var(--read); }
.callout-info   { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }

/* Klappbare Abschnitte */
.ch-section { margin: 6px 0 4px; }
.ch-sec-head {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: none; border: none; cursor: pointer; color: var(--fg);
  font-size: 24px; font-weight: 700; padding: 8px 0; margin: 0;
  border-bottom: 1px solid transparent;
}
.ch-sec-head:hover { border-bottom-color: var(--border); }
.ch-sec-caret { color: var(--accent); font-size: 16px; transition: transform .18s; }
.ch-section.collapsed .ch-sec-caret { transform: rotate(-90deg); }
.ch-section.collapsed .ch-sec-body { display: none; }
.ch-sec-body { animation: fadein .18s; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* Glossar-Tooltips */
.glossterm {
  border-bottom: 1px dotted var(--accent); cursor: help; position: relative; outline: none;
}
.glossterm::after {
  content: attr(data-def);
  position: absolute; left: 0; top: 130%; z-index: 20; width: max-content; max-width: 320px;
  background: var(--fg); color: var(--bg); padding: 8px 11px; border-radius: 8px;
  font-size: 13px; font-weight: 400; line-height: 1.45; box-shadow: var(--shadow);
  opacity: 0; visibility: hidden; transition: opacity .15s; pointer-events: none;
}
.glossterm:hover::after, .glossterm:focus::after, .glossterm.show::after { opacity: 1; visibility: visible; }

/* Lesefortschritt oben */
#reading-progress {
  position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 30;
  background: transparent; opacity: 0; transition: opacity .2s; pointer-events: none;
}
#reading-progress.visible { opacity: 1; }
#reading-progress-fill { height: 100%; width: 0; background: var(--accent); }

/* Hersteller-Vergleichstabelle + Filter */
.cmp-filter {
  width: 100%; max-width: 420px; padding: 9px 12px; margin: 6px 0 14px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg-elev); color: var(--fg);
}
.chapter-body table.cmp-table { font-size: 13.5px; }
.chapter-body table.cmp-table td { vertical-align: top; }
.chapter-body table.cmp-table td:first-child { font-weight: 700; white-space: nowrap; }
