:root {
  --bg: #141415;
  --bg2: #19191b;
  --card: #1e1e20;
  --card2: #26262a;
  --line: #313135;
  --line2: #46464c;
  --text: #ececee;
  --muted: #9b9ba1;
  --green: #22c55e;
  --green-bg: rgba(34, 197, 94, .12);
  --red: #ef4444;
  --red-bg: rgba(239, 68, 68, .12);
  --yellow: #f59e0b;
  --orange: #f5a524;
  --purple: #d05ce3;
  --radius: 12px;
  --bar-h: 0px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--text); }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: var(--card2); padding: 2px 6px; border-radius: 4px; }

/* ---------- Topbar ---------- */
.topbar { position: sticky; top: 0; z-index: 30; background: rgba(20, 20, 21, .94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-bottom: 1px solid #262628; padding-top: env(safe-area-inset-top); }
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 1320px; margin: 0 auto; padding: 12px 16px; }
.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.topbar h1 { font-size: 19px; margin: 0; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.icon-btn { background: transparent; border: 1px solid var(--line); border-radius: 999px; width: 38px; height: 38px; display: grid; place-items: center; color: var(--muted); text-decoration: none; flex: none; }
.icon-btn:hover { color: var(--text); border-color: var(--line2); }
.icon-btn.back { border-color: transparent; }

.user-menu { position: relative; }
.user-menu summary { list-style: none; cursor: pointer; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu[open] summary { color: var(--text); border-color: var(--line2); }
.menu-pop { position: absolute; right: 0; top: 46px; min-width: 220px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 6px; box-shadow: 0 12px 30px rgba(0, 0, 0, .45); z-index: 40; }
.menu-head { padding: 8px 10px 10px; font-size: 13px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-head b { color: var(--text); font-size: 15px; }
.menu-pop a, .menu-pop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 7px; text-decoration: none; background: none; border: none; font-size: 14px; color: var(--text); text-align: left; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--card2); }
.menu-pop svg { width: 17px; height: 17px; color: var(--muted); }
.menu-pop form { margin: 0; }

/* Fortschritt */
.progress-wrap { max-width: 1320px; margin: 0 auto; padding: 0 16px 12px; display: flex; align-items: center; gap: 14px; }
.progress { flex: 1; display: flex; gap: 2px; height: 4px; background: transparent; }
.progress span { height: 100%; border-radius: 1px; transition: flex-grow .3s; min-width: 0; }
.p-green { background: var(--green); }
.p-yellow { background: var(--yellow); }
.p-red { background: var(--red); }
.p-done { background: #7a7a80; }
.p-open { background: #2c2c30; }
.progress-legend { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.progress-legend b { color: var(--text); font-weight: 600; }

/* ---------- Allgemeine Seiten ---------- */
.page { max-width: 1000px; margin: 0 auto; padding: 22px 16px 60px; }
.page.narrow { max-width: 460px; }
.page.wide { max-width: 1200px; }
.page-title { font-size: 22px; font-weight: 600; margin: 4px 0 20px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.panel h3 { margin: 0 0 14px; font-size: 16px; }
.panel.empty { text-align: center; color: var(--muted); padding: 50px 20px; }

.flash { border-radius: 10px; padding: 11px 14px; margin-bottom: 14px; font-size: 14px; border: 1px solid; }
.flash a { color: inherit; font-weight: 600; }
.flash-ok { background: rgba(34, 197, 94, .1); border-color: rgba(34, 197, 94, .4); color: #b6f0c9; }
.flash-error { background: rgba(239, 68, 68, .1); border-color: rgba(239, 68, 68, .45); color: #ffc4c4; }
.flash-warn { background: rgba(245, 158, 11, .1); border-color: rgba(245, 158, 11, .45); color: #ffe0ad; }
.flash-info { background: var(--card2); border-color: var(--line2); color: var(--text); }

/* Formulare */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input[type=text], input[type=password], input:not([type]), input[type=file], input[type=search], input[type=date], select, textarea {
  background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font: inherit; font-size: 15px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #8a8a90; }
input[type=file] { padding: 7px; font-size: 13px; }
textarea { resize: vertical; line-height: 1.45; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 14px; }
.check input, .toggle input { accent-color: var(--green); width: 16px; height: 16px; }
.row-form { flex-direction: row; flex-wrap: wrap; align-items: flex-end; }
.row-form label { flex: 1 1 200px; }
.row-form label.check { flex: 0 0 auto; padding-bottom: 10px; }
.pw-wrap { display: flex; gap: 6px; }
.inline-form { display: flex; gap: 6px; align-items: center; margin: 0; }
.inline-form input { padding: 6px 9px; font-size: 14px; min-width: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--card2); border: 1px solid var(--line); border-radius: 8px; padding: 9px 14px; font-size: 14px; text-decoration: none; color: var(--text); white-space: nowrap; }
.btn:hover { border-color: var(--line2); background: #2c2c30; }
.btn.primary { background: var(--text); color: #141415; border-color: var(--text); font-weight: 600; }
.btn.primary:hover { background: #fff; }
.btn.danger { color: #ff8a8a; border-color: rgba(239, 68, 68, .35); background: transparent; }
.btn.danger:hover { background: rgba(239, 68, 68, .1); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.inline { width: auto; }

/* Login */
.center-page { display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 380px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 30px 26px; }
.auth-card h1 { margin: 10px 0 4px; font-size: 24px; }
.auth-card p { margin: 0 0 20px; }
.auth-logo { width: 52px; height: 52px; border-radius: 16px; background: var(--card2); display: grid; place-items: center; color: var(--muted); }
.auth-logo svg { width: 28px; height: 28px; }
.face-logo { background: none; color: var(--green); }
.face-logo svg { width: 52px; height: 52px; }

/* Fächer-Auswahl */
.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.subject-card { display: flex; flex-direction: column; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; text-decoration: none; transition: border-color .15s, transform .15s; }
.subject-card:hover { border-color: var(--line2); transform: translateY(-2px); }
.subject-top { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.subject-top h3 { margin: 0; font-size: 18px; }
.subject-card .progress { flex: none; height: 5px; background: #2c2c30; border-radius: 3px; overflow: hidden; }
.subject-meta { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.subject-meta b { color: var(--text); }
.subject-ratings { display: flex; gap: 14px; align-items: center; font-size: 13px; color: var(--muted); }
.subject-ratings .go { margin-left: auto; color: var(--text); font-weight: 600; }
.dot-l { display: inline-flex; align-items: center; gap: 5px; margin-right: 8px; font-size: 13px; }
.dot-l i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; }

/* Admin */
.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: 10px 14px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--text); border-bottom-color: var(--text); }
.tabs .count { background: var(--red); color: #fff; font-size: 11px; border-radius: 999px; padding: 0 7px; font-weight: 700; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr.dim td { color: var(--muted); }
.table td.actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.table td.actions form { margin: 0; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--card2); border: 1px solid var(--line); color: var(--muted); }
.pill-admin { color: var(--purple); border-color: rgba(208, 92, 227, .5); }
.pill-done { color: var(--green); border-color: rgba(34, 197, 94, .5); }
.mini-bar { height: 4px; background: #2c2c30; border-radius: 2px; overflow: hidden; margin-bottom: 4px; max-width: 160px; }
.mini-bar span { display: block; height: 100%; background: var(--green); }
.subject-admin-list { display: flex; flex-direction: column; gap: 10px; }
.subject-admin { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: var(--bg2); }
.sa-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.sa-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.sa-actions form { margin: 0; }
.format-help { margin-top: 14px; font-size: 14px; color: var(--muted); }
.format-help summary { cursor: pointer; color: var(--text); }
.report.done { opacity: .6; }
.report-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.report-text { margin: 0 0 12px; white-space: pre-wrap; }
.report-q { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }

/* ---------- Lernseite ---------- */
.learn-layout { max-width: 1320px; margin: 0 auto; padding: 18px 16px 40px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; }
.learn-main { max-width: 960px; width: 100%; margin: 0 auto; }

.filters { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 14px; color: var(--muted); white-space: nowrap; }
.chip:hover { color: var(--text); }
.chip.active { color: var(--text); border-color: #8a8a90; background: #2c2c30; }
.chip .dot { width: 10px; height: 10px; border-radius: 50%; }
.chip .n { font-size: 12px; background: #2e2e32; border-radius: 999px; padding: 0 7px; }
.filter-right { display: flex; gap: 10px; align-items: center; }
.filter-right select { width: auto; max-width: 280px; font-size: 14px; padding: 7px 10px; }
.toggle { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; color: var(--muted); cursor: pointer; user-select: none; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px 18px; min-height: 340px; }
.card-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.card-head .face { width: 26px; height: 26px; }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 5px; border: 1px solid; white-space: nowrap; }
.tag-chapter { color: var(--orange); border-color: var(--orange); background: rgba(245, 165, 36, .08); }
.tag-topic { color: var(--purple); border-color: var(--purple); background: rgba(208, 92, 227, .08); max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.tag-num { color: var(--muted); border-color: var(--line); font-variant-numeric: tabular-nums; }
.card-head .spacer { flex: 1; }
.link-btn { background: none; border: none; color: var(--muted); font-size: 13px; display: inline-flex; gap: 6px; align-items: center; padding: 5px 7px; border-radius: 6px; }
.link-btn:hover { color: var(--text); background: var(--card2); }
.link-btn svg { width: 16px; height: 16px; }
.question { font-size: 20px; font-weight: 500; text-align: center; margin: 6px auto; max-width: 820px; }
.sub { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 18px; }

.answers { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.answer { border-bottom: 1px solid var(--line); }
.answer-row { width: 100%; display: flex; align-items: center; gap: 14px; background: none; border: none; text-align: left; padding: 12px 10px; }
.answer-row:hover { background: var(--card2); }
.letter { flex: none; width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--muted); color: var(--muted); display: grid; place-items: center; font-size: 12px; font-weight: 600; }
.answer-text { flex: 1; }
.answer-mark { flex: none; color: var(--muted); font-size: 18px; width: 22px; text-align: center; }
.explanation { padding: 2px 16px 16px 50px; color: #d6d6da; }
.answer.wrong { background: var(--red-bg); box-shadow: inset 0 0 0 1px rgba(239, 68, 68, .55); }
.answer.wrong .letter { background: var(--red); border-color: var(--red); color: #fff; }
.answer.wrong .answer-mark { color: var(--red); }
.answer.right { background: var(--green-bg); box-shadow: inset 0 0 0 1px rgba(34, 197, 94, .6); }
.answer.right .letter { border-color: var(--green); color: var(--green); }
.answer.right .answer-mark { color: var(--green); }
.answer.wrong .answer-row:hover, .answer.right .answer-row:hover { background: rgba(255, 255, 255, .03); }
.answer.solved-dim .answer-text { color: var(--muted); }
.result { margin: 14px 0 0; font-size: 14px; color: var(--muted); text-align: center; }
.result.ok { color: var(--green); }
.empty { text-align: center; color: var(--muted); padding: 80px 20px; }

/* Notiz */
.note-box { margin-top: 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.note-box summary { display: flex; align-items: center; gap: 8px; padding: 10px 14px; cursor: pointer; color: var(--muted); font-size: 14px; list-style: none; }
.note-box summary::-webkit-details-marker { display: none; }
.note-box summary svg { width: 17px; height: 17px; }
.note-box summary small { margin-left: auto; font-size: 12px; }
.note-box[open] summary { color: var(--text); }
.note-box textarea { display: block; width: calc(100% - 24px); margin: 0 12px 12px; background: var(--bg2); }

/* Gesichter & Bewertung */
.face { display: inline-block; width: 28px; height: 28px; }
.face svg { width: 100%; height: 100%; stroke-width: 1.8; }
.rating-bar { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 20px; }
.nav-btn { width: 42px; height: 42px; border-radius: 50%; background: var(--card); border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted); flex: none; }
.nav-btn:hover:not(:disabled) { color: var(--text); }
.nav-btn:disabled { opacity: .35; }
.nav-btn.next svg { transform: rotate(180deg); }
.rating-group { display: flex; gap: 4px; padding: 5px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; }
.rate { display: flex; align-items: center; gap: 10px; padding: 9px 16px 9px 10px; border: 1px solid transparent; border-radius: 11px; background: transparent; font-size: 14px; transition: background .15s, transform .08s; }
.rate .face { width: 26px; height: 26px; transition: transform .15s; }
.rate b { color: var(--muted); font-weight: 600; transition: color .15s; }
.rate kbd { margin-left: 2px; }
.rate:hover:not(:disabled) { background: var(--card2); }
.rate:hover:not(:disabled) b { color: var(--text); }
.rate:hover:not(:disabled) .face { transform: rotate(-8deg) scale(1.08); }
.rate:active { transform: scale(.97); }
.rate:disabled { opacity: .4; }
.rate-red { color: var(--red); }
.rate-yellow { color: var(--yellow); }
.rate-green { color: var(--green); }
.rate.selected b { color: var(--text); }
.rate-red.selected { background: rgba(239, 68, 68, .14); border-color: rgba(239, 68, 68, .45); }
.rate-yellow.selected { background: rgba(245, 158, 11, .14); border-color: rgba(245, 158, 11, .45); }
.rate-green.selected { background: rgba(34, 197, 94, .14); border-color: rgba(34, 197, 94, .45); }
.hint { text-align: center; color: #66666c; font-size: 12px; margin-top: 16px; }
kbd { border: 1px solid #3a3a3f; border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-family: inherit; font-size: 11px; color: var(--muted); }

/* Seitenleiste / Übersicht */
.learn-side { background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.side-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.side-head h2 { font-size: 16px; margin: 0; }
.side-head small { color: var(--muted); font-weight: 400; font-size: 13px; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 11px; }
.stat b { display: block; font-size: 19px; font-variant-numeric: tabular-nums; }
.stat b small { font-size: 13px; color: var(--muted); font-weight: 400; }
.stat span { font-size: 12px; color: var(--muted); }
.qgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 5px; margin-bottom: 12px; }
.qcell { height: 36px; border-radius: 6px; border: 1px solid var(--line); background: var(--card); font-size: 12px; color: var(--muted); position: relative; font-variant-numeric: tabular-nums; }
.qcell:hover { color: var(--text); border-color: var(--line2); }
.qcell.attempted { color: var(--text); }
.qcell.r-red { background: #3a1814; border-color: #73302a; }
.qcell.r-yellow { background: #3a2a12; border-color: #6e4c1a; }
.qcell.r-green { background: #12301f; border-color: #1f6340; }
.qcell.current { outline: 2px solid var(--text); outline-offset: 1px; }
.qcell.first::after, .dot-first { content: ""; position: absolute; top: 3px; right: 3px; width: 5px; height: 5px; border-radius: 50%; background: var(--green); }
.dot-first { position: static; display: inline-block; }
.qcell.has-note::before { content: ""; position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%); width: 10px; height: 2px; border-radius: 1px; background: var(--muted); }
.side-legend { display: flex; flex-wrap: wrap; gap: 4px 0; font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.side-legend .dot-l { font-size: 12px; }
.learn-side .btn { width: 100%; margin-bottom: 8px; }
.side-backdrop { display: none; }

/* Dialog & Toast */
.dialog { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 20px; width: min(460px, calc(100% - 32px)); }
.dialog::backdrop { background: rgba(0, 0, 0, .6); }
.dialog h3 { margin: 0 0 6px; display: flex; align-items: center; gap: 8px; font-size: 17px; }
.dialog p { margin: 0 0 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.toast { position: fixed; bottom: calc(24px + var(--bar-h)); left: 50%; transform: translateX(-50%); background: #2a2a2e; border: 1px solid var(--line); padding: 10px 16px; border-radius: 8px; font-size: 14px; z-index: 60; white-space: nowrap; }

[hidden] { display: none !important; }

/* Herkunft der Fragen: Altfragen / KI */
.tag-src-alt { color: #8fb8ff; border-color: #5b84d6; background: rgba(91, 132, 214, .1); }
.tag-src-ai { color: #5eead4; border-color: #2a9d8f; background: rgba(42, 157, 143, .1); }
.subject-src { display: flex; gap: 6px; flex-wrap: wrap; margin-top: -4px; }
.seg { display: inline-flex; gap: 3px; padding: 3px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.seg button, .seg label span { display: inline-flex; align-items: center; gap: 6px; background: none; border: none; border-radius: 7px; padding: 6px 14px; font-size: 14px; color: var(--muted); cursor: pointer; }
.seg button:hover, .seg label span:hover { color: var(--text); }
.seg button.active, .seg input:checked + span { background: #2e2e33; color: var(--text); box-shadow: 0 0 0 1px var(--line2); }
.seg .n { font-size: 12px; background: #2e2e32; border-radius: 999px; padding: 0 7px; }
.seg label { display: contents; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.source-seg { margin-bottom: 12px; }
.seg-field { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; font-size: 13px; color: var(--muted); }
.upload-form .row-form { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.sa-parts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.sa-part { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.sa-part.empty { opacity: .7; border-style: dashed; }
.sa-part-info { display: flex; align-items: center; gap: 10px; }
.sa-part-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.sa-part-actions form { margin: 0; }
.pill-public { color: #8fb8ff; border-color: rgba(91, 132, 214, .5); }

/* Öffentliche Kommentare unter den Antworten (lila, damit sie sich von falschen Antworten abheben) */
.comments { margin-top: 14px; background: rgba(88, 28, 135, .26); border: 1px solid #6b21a8; border-radius: 10px; padding: 12px 14px; }
.comments.empty-comments { background: transparent; border-style: dashed; border-color: #4c1d6e; padding: 8px 12px; }
.comments-title { font-weight: 700; color: #d8b4fe; margin-bottom: 6px; }
.comment + .comment { margin-top: 10px; padding-top: 10px; border-top: 1px solid rgba(107, 33, 168, .6); }
.comment.reply { margin: 8px 0 0 18px; padding: 8px 0 0 12px; border-top: none; border-left: 2px solid rgba(168, 85, 247, .45); }
.comment-head { font-size: 13px; color: #e9d5ff; }
.comment-head b { color: #fff; }
.comment-head span { color: #c4a5f5; opacity: .85; }
.comment-text { margin-top: 2px; white-space: pre-wrap; color: #efe6fb; }
.comment-actions { display: flex; gap: 4px; margin-top: 4px; flex-wrap: wrap; }
.c-act { background: none; border: none; color: #b79ae0; font-size: 12px; padding: 3px 7px; border-radius: 6px; }
.c-act:hover { background: rgba(168, 85, 247, .15); color: #fff; }
.c-act.on { color: #fff; background: rgba(168, 85, 247, .3); }
.c-act.danger:hover { color: #fca5a5; }
.c-act.add { font-size: 13px; padding: 5px 8px; }
.comments-foot { margin-top: 10px; }
.comment-form textarea { background: rgba(0, 0, 0, .25); border-color: #6b21a8; margin-top: 6px; }
.comment-form-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 6px; }
.comments-hint { margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.check-line { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 14px; cursor: pointer; }
.check-line input { accent-color: var(--green); width: 16px; height: 16px; }

/* ---------- Neue Lern-Funktionen ---------- */
.filter-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.filter-row input[type=search] { flex: 1 1 220px; width: auto; padding: 7px 11px; font-size: 14px; }
.filter-row select { width: auto; max-width: 260px; font-size: 14px; padding: 7px 10px; }
.tag-sem { color: #93c5fd; border-color: #3b6ea8; background: rgba(59, 110, 168, .1); }
.tag-user { color: #cbd5e1; border-color: #4b5563; background: rgba(148, 163, 184, .08); }
.tag-user button { background: none; border: none; color: var(--muted); padding: 0 0 0 4px; font-size: 14px; }
.star-btn.on { color: #facc15; }
.star-btn.on svg { fill: #facc15; }
.sub-row { display: flex; justify-content: center; align-items: center; gap: 12px; margin: 0 0 18px; flex-wrap: wrap; }
.sub-row .sub { margin: 0; }
.guess-btn { background: transparent; border: 1px dashed var(--line2); color: var(--muted); border-radius: 999px; font-size: 12px; padding: 3px 10px; }
.guess-btn:hover { color: var(--text); }
.guess-btn.on { border-style: solid; border-color: #a78bfa; color: #ddd6fe; background: rgba(167, 139, 250, .12); }
.guess-badge { font-size: 12px; color: #c4b5fd; }
.answer.right.missed { background: transparent; box-shadow: inset 0 0 0 1px rgba(34, 197, 94, .55); outline: 1px dashed rgba(34, 197, 94, .7); outline-offset: -4px; }
.answer.right.missed .answer-mark { font-size: 12px; width: auto; white-space: nowrap; }
.multi-badge { display: inline-block; font-size: 12px; font-weight: 600; color: #bfdbfe; background: rgba(96, 165, 250, .15); border: 1px solid rgba(96, 165, 250, .5); border-radius: 999px; padding: 2px 10px; }
.answer.struck .answer-text { text-decoration: line-through; color: #6b6b72; }
.answer.struck .letter { opacity: .4; }
.answer.chosen { background: rgba(147, 197, 253, .1); box-shadow: inset 0 0 0 1px rgba(147, 197, 253, .6); }
.answer.chosen .letter { background: #93c5fd; border-color: #93c5fd; color: #10203a; }
#qtext mark { background: rgba(250, 204, 21, .32); color: inherit; border-radius: 3px; padding: 0 1px; cursor: pointer; }
.mark-btn { position: absolute; z-index: 70; background: #facc15; color: #1a1a1a; border: none; border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 600; box-shadow: 0 6px 18px rgba(0, 0, 0, .4); }
.q-images { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 4px 0 14px; }
.q-img { position: relative; margin: 0; }
.q-img img { display: block; max-height: 220px; max-width: 100%; border-radius: 8px; border: 1px solid var(--line); cursor: zoom-in; background: #000; }
.q-img figcaption { font-size: 11px; color: var(--muted); text-align: center; margin-top: 3px; }
.img-del { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; border: none; background: rgba(0, 0, 0, .7); color: #fff; display: grid; place-items: center; }
.img-del svg { width: 15px; height: 15px; }
.img-dialog { width: min(1100px, calc(100% - 24px)); padding: 12px; }
.img-dialog img { display: block; max-width: 100%; max-height: 80vh; margin: 0 auto; border-radius: 8px; }
.qcell.starred::before { content: "★"; position: absolute; top: 1px; left: 3px; font-size: 9px; color: #facc15; }
.qcell.r-exam { background: #1d2c44; border-color: #3b5b8c; }
.side-countdown { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 9px 12px; margin-bottom: 10px; font-size: 14px; }
.side-countdown span { font-size: 12px; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.field .seg { align-self: flex-start; }
.tag-edit { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }

/* Prüfungsmodus */
.exam-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; background: #172338; border: 1px solid #2c4366; color: #cfe0fb; border-radius: 10px; padding: 9px 14px; margin-bottom: 12px; font-size: 14px; }
.exam-time { font-variant-numeric: tabular-nums; font-weight: 700; }
.exam-time.urgent { color: #fca5a5; }
.exam-bar .btn.primary { padding: 10px 22px; }
.exam-result { padding: 6px 0; }
.exam-score { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 18px; border-radius: 12px; margin-bottom: 16px; text-align: center; }
.exam-score b { font-size: 44px; line-height: 1.1; }
.exam-score.pass { background: var(--green-bg); color: #b6f0c9; }
.exam-score.fail { background: var(--red-bg); color: #ffc4c4; }
.exam-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 18px; }
.exam-list { list-style: none; margin: 0; padding: 0; }
.exam-list li { display: flex; gap: 12px; padding: 10px 4px; border-top: 1px solid var(--line); font-size: 14px; }
.exam-list .mark { flex: none; width: 22px; font-weight: 700; }
.exam-list li.ok .mark { color: var(--green); }
.exam-list li.bad .mark { color: var(--red); }
.exam-list .ok-text { color: #9ee6b6; }
body.exam-mode .learn-side .btn, body.exam-mode .side-legend { display: none; }

/* Fokusmodus: nur Frage und Antworten */
body.focus .topbar, body.focus #learnFilters, body.focus .learn-side, body.focus .note-box, body.focus .hint, body.focus .side-backdrop { display: none !important; }
body.focus .learn-layout { grid-template-columns: minmax(0, 1fr) !important; padding-top: 30px; }
body.focus .learn-main { max-width: 860px; margin: 0 auto; }
.focus-exit { position: fixed; top: 12px; right: 12px; z-index: 40; display: inline-flex; gap: 6px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 13px; color: var(--muted); }
.focus-exit svg { width: 15px; height: 15px; }

/* Darstellung: Schriftgröße, Zeilenabstand */
html[data-size="s"] { font-size: 14px; }
html[data-size="l"] body { font-size: 17.5px; }
html[data-size="xl"] body { font-size: 19.5px; }
html[data-size="s"] body { font-size: 14.5px; }
html[data-size="l"] .question { font-size: 22px; }
html[data-size="xl"] .question { font-size: 25px; }
html[data-size="s"] .question { font-size: 18px; }
html[data-lh="wide"] body { line-height: 1.75; }

/* Helles Farbschema */
html[data-theme="light"] {
  --bg: #f4f4f5; --bg2: #ececee; --card: #ffffff; --card2: #f1f1f3; --line: #dcdce0; --line2: #b9b9c0;
  --text: #1b1b1f; --muted: #5d5d66; --green-bg: rgba(34, 197, 94, .14); --red-bg: rgba(239, 68, 68, .1);
}
html[data-theme="light"] .topbar, html[data-theme="light"] .rating-bar { background: rgba(255, 255, 255, .94) !important; border-color: var(--line); }
html[data-theme="light"] .chip.active, html[data-theme="light"] .seg button.active { background: #e4e4e8; border-color: #9a9aa2; }
html[data-theme="light"] .chip .n, html[data-theme="light"] .seg .n { background: #e6e6ea; }
html[data-theme="light"] .explanation { color: #303036; }
html[data-theme="light"] .p-open, html[data-theme="light"] .subject-card .progress { background: #dedee3; }
html[data-theme="light"] .qcell.r-red { background: #fde4e1; border-color: #f2a59b; }
html[data-theme="light"] .qcell.r-yellow { background: #fdf0d5; border-color: #ecc070; }
html[data-theme="light"] .qcell.r-green { background: #dcf5e5; border-color: #8fd3a8; }
html[data-theme="light"] .comments { background: #f5edff; border-color: #c9a6f0; }
html[data-theme="light"] .comments-title, html[data-theme="light"] .comment-head, html[data-theme="light"] .comment-head span, html[data-theme="light"] .c-act { color: #6b21a8; }
html[data-theme="light"] .comment-head b, html[data-theme="light"] .comment-text { color: #2a1440; }
html[data-theme="light"] .btn.primary { background: #1b1b1f; color: #fff; border-color: #1b1b1f; }
html[data-theme="light"] .exam-banner { background: #e6effc; color: #1d3b66; border-color: #b6cdf0; }
html[data-theme="light"] .menu-pop { box-shadow: 0 12px 30px rgba(0, 0, 0, .15); }
html[data-theme="light"] .flash-ok { color: #136b35; } html[data-theme="light"] .flash-error { color: #9b1c1c; } html[data-theme="light"] .flash-warn { color: #8a5300; }

/* Startseite & Statistik */
.today { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.today .stat { flex: 1 1 140px; }
.continue { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--card); border: 1px solid var(--line2); border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px; text-decoration: none; }
.continue:hover { border-color: #8a8a90; }
.continue span { color: var(--muted); font-size: 13px; }
.countdown { font-size: 13px; color: #93c5fd; }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 140px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; height: 100%; position: relative; }
.bars .bar i { display: block; background: #5a5a62; border-radius: 2px 2px 0 0; }
.bars .bar i.first { background: var(--green); border-radius: 0; }
.bars .bar.today::after { content: ""; position: absolute; bottom: -4px; left: 20%; right: 20%; height: 2px; background: var(--text); border-radius: 1px; }
.bars-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }
.chap-row { display: grid; grid-template-columns: minmax(0, 1fr) 160px 60px; gap: 10px; align-items: center; padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px; }
.chap-row .progress { height: 6px; background: #2c2c30; border-radius: 3px; overflow: hidden; }
.chap-row .pct { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.hide-mobile { }
.suggest-answer { display: flex; gap: 10px; align-items: flex-start; }
.suggest-right input { position: absolute; opacity: 0; }
.suggest-right span { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; border: 1.5px solid var(--muted); color: var(--muted); font-weight: 600; cursor: pointer; margin-top: 4px; }
.suggest-right input:checked + span { background: var(--green); border-color: var(--green); color: #0b2415; }
.suggest-fields { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.suggest-fields textarea { font-size: 14px; }
.link-box { display: flex; gap: 6px; margin-top: 8px; }
.link-box input { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.preview-q { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; font-size: 14px; background: var(--bg2); }
.preview-q ol { margin: 6px 0 0; padding-left: 20px; }
.preview-q li.ok { color: #9ee6b6; font-weight: 600; }
.dist { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: #2c2c30; min-width: 120px; }
.dist span { display: block; height: 100%; }
.dist-legend { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 4px; }
.dist-legend b.ok { color: var(--green); }

/* =========================================================
   PC (breit): Übersicht als feste Seitenleiste rechts
   ========================================================= */
@media (min-width: 1180px) {
  .learn-layout { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
  .learn-main { margin: 0; max-width: none; }
  .learn-side { position: sticky; top: 100px; max-height: calc(100vh - 116px); overflow: auto; }
  body.side-collapsed .learn-layout { grid-template-columns: minmax(0, 1fr); }
  body.side-collapsed .learn-main { max-width: 960px; margin: 0 auto; }
  body.side-collapsed .learn-side { display: none; }
}

/* =========================================================
   Tablet / schmaler PC: Übersicht als ausklappbare Leiste
   ========================================================= */
@media (max-width: 1179px) {
  .learn-side { position: fixed; top: 0; right: 0; bottom: 0; width: min(380px, 100%); z-index: 50; border-radius: 0; border-width: 0 0 0 1px; overflow: auto; transform: translateX(105%); transition: transform .22s ease; padding-top: calc(16px + env(safe-area-inset-top)); }
  body.side-open .learn-side { transform: none; }
  body.side-open .side-backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 45; }
}

/* =========================================================
   Handy
   ========================================================= */
@media (max-width: 700px) {
  body { font-size: 15.5px; }
  .topbar-row { padding: 8px 10px; gap: 8px; }
  .topbar h1 { font-size: 16px; }
  .icon-btn { width: 36px; height: 36px; }
  .progress-wrap { padding: 0 12px 9px; gap: 10px; }

  .page { padding: 16px 12px 40px; }
  .page-title { font-size: 19px; }
  .panel { padding: 14px; }
  .subject-grid { grid-template-columns: 1fr; }

  /* Lernseite */
  body.learn { --bar-h: 84px; }
  .learn-layout { padding: 10px 10px calc(var(--bar-h) + 24px + env(safe-area-inset-bottom)); gap: 0; }
  .filters { flex-direction: column; gap: 8px; margin-bottom: 10px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -10px; padding: 0 10px 2px; }
  .chips::-webkit-scrollbar { display: none; }
  .filter-right { width: 100%; }
  .filter-right select { flex: 1; max-width: none; min-width: 0; }
  .chips { max-width: calc(100% + 20px); }
  .card-head .tag-topic { flex: 0 1 auto; min-width: 0; }

  .card { padding: 14px 12px 12px; border-radius: 10px; min-height: 0; }
  .card-head { gap: 6px; margin-bottom: 10px; }
  .card-head .face { width: 22px; height: 22px; }
  .tag-topic { max-width: 170px; }
  .link-btn span { display: none; }
  .link-btn { padding: 7px; }
  .link-btn svg { width: 18px; height: 18px; }
  .question { font-size: 17px; text-align: left; margin: 2px 0 4px; }
  .sub { text-align: left; margin-bottom: 12px; }
  .answers { margin: 0 -12px; }
  .answer-row { padding: 14px 12px; gap: 12px; }
  .explanation { padding: 0 14px 14px 50px; font-size: 14.5px; }

  /* Bewertung fest am unteren Rand, gut mit dem Daumen erreichbar */
  .rating-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; margin: 0; gap: 6px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); background: rgba(20, 20, 21, .96); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-top: 1px solid #262628; }
  .rating-group { flex: 1; padding: 3px; gap: 3px; border-radius: 14px; }
  .rate { flex: 1; flex-direction: column; gap: 3px; padding: 7px 4px; font-size: 12px; }
  .rate .face { width: 26px; height: 26px; }
  .rate kbd { display: none; }
  .nav-btn { width: 40px; height: 40px; }
  .hint { display: none; }

  .learn-side { width: 100%; }
  .qgrid { grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); }
  .qcell { height: 42px; }

  /* Admin-Tabellen als Karten */
  .table thead { display: none; }
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table tr { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 10px; background: var(--bg2); }
  .table td { border: none; padding: 5px 0; }
  .table td[data-l]::before { content: attr(data-l); display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
  .table td.actions { justify-content: flex-start; }
  .inline-form { flex-wrap: wrap; }
  .inline-form input { flex: 1 1 140px; }
  .row-form { flex-direction: column; align-items: stretch; }
  .row-form label { flex: none; }
  .sa-actions { flex-direction: column; align-items: stretch; }
  .sa-actions .inline-form { width: 100%; }
  .source-seg { display: flex; }
  .source-seg button { flex: 1; justify-content: center; padding: 7px 6px; font-size: 13px; }
  .upload-form .row-form { flex-direction: column; align-items: stretch; }
  .sa-part-actions, .sa-part-actions form { width: 100%; }
  .comments { margin-left: -4px; margin-right: -4px; }
  .hide-mobile { display: none !important; }
  .filter-row { gap: 8px; margin-bottom: 10px; }
  .filter-row input[type=search] { flex-basis: 100%; }
  .filter-row select { flex: 1 1 40%; max-width: none; min-width: 0; }
  .sub-row { justify-content: flex-start; margin-bottom: 12px; }
  .q-img img { max-height: 180px; }
  .exam-banner { font-size: 13px; padding: 8px 10px; }
  .chap-row { grid-template-columns: minmax(0, 1fr) 90px 44px; font-size: 13px; }
  .card-head .link-btn { padding: 6px; }
  .sa-actions > form > .btn, .sa-actions > .btn { width: 100%; }
}
