:root {
  --bg: #f6f7f9; --flaeche: #ffffff; --flaeche2: #eef1f5; --linie: #dde2ea; --linie2: #c9d0db;
  --text: #1c2330; --text2: #4e586a; --text3: #7a8496;
  --akzent: #1f4f9c; --akzent2: #e8eef8; --akzent-text: #fff;
  --ok: #2e7d4f; --warn: #a86a00; --fehler: #b3261e;
  --norm: #1f4f9c; --norm-bg: rgba(31, 79, 156, .07);
  --m-gelb: #fff1a8; --m-gruen: #c9f0cf; --m-blau: #cfe3ff; --m-rot: #ffd1cc; --m-lila: #e6d6ff;
  --treffer: #ffe27a;
  --lesefont: Georgia, Cambria, "Times New Roman", serif;
  --uifont: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --lesegroesse: 17px;
  --schatten: 0 1px 2px rgba(20, 30, 50, .06), 0 4px 16px rgba(20, 30, 50, .06);
  --radius: 8px;
}
html[data-thema="sepia"] {
  --bg: #f3eee3; --flaeche: #fbf7ee; --flaeche2: #efe8da; --linie: #e0d6c2; --linie2: #d1c4aa;
  --text: #2f2618; --text2: #5d5040; --text3: #8a7c66; --akzent: #7a4b12; --akzent2: #f1e5cf; --norm: #7a4b12; --norm-bg: rgba(122, 75, 18, .08);
}
html[data-thema="dunkel"] {
  --bg: #14181f; --flaeche: #1b2029; --flaeche2: #232a35; --linie: #2e3643; --linie2: #3b4553;
  --text: #e3e7ee; --text2: #b2bac8; --text3: #8590a2; --akzent: #8fb4ff; --akzent2: #22304a; --akzent-text: #0e1420;
  --norm: #9dbdff; --norm-bg: rgba(143, 180, 255, .10);
  --m-gelb: #5c5220; --m-gruen: #24502f; --m-blau: #1f3d66; --m-rot: #5e2a26; --m-lila: #43305f; --treffer: #6b5a10;
  --schatten: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14.5px/1.5 var(--uifont); }
a { color: var(--akzent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }

/* ---------- Kopf ---------- */
.kopf { position: fixed; inset: 0 0 auto 0; height: 54px; display: flex; align-items: center; gap: 18px; padding: 0 16px;
  background: var(--flaeche); border-bottom: 1px solid var(--linie); z-index: 20; }
.marke { display: flex; align-items: center; gap: 9px; color: var(--akzent); font-weight: 700; font-size: 16px; white-space: nowrap; width: 216px; }
.marke span { color: var(--text); }
.marke:hover { text-decoration: none; }
.kopfsuche { flex: 1; max-width: 680px; }
.kopfsuche input { width: 100%; height: 36px; border: 1px solid var(--linie2); border-radius: 18px; padding: 0 16px; background: var(--flaeche2); }
.kopfsuche input:focus { outline: none; border-color: var(--akzent); background: var(--flaeche); box-shadow: 0 0 0 3px var(--akzent2); }
.kopf-status { margin-left: auto; color: var(--text3); font-size: 12.5px; white-space: nowrap; }
.icon-knopf { border: 1px solid var(--linie); background: var(--flaeche); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 18px; line-height: 1; color: var(--text2); }

/* ---------- Rahmen ---------- */
.rahmen { display: flex; padding-top: 54px; min-height: 100%; }
.navi { position: fixed; top: 54px; bottom: 0; left: 0; width: 232px; overflow-y: auto; padding: 12px 10px 30px; border-right: 1px solid var(--linie); background: var(--flaeche); }
.navi a { display: flex; align-items: center; gap: 9px; padding: 6px 10px; border-radius: 6px; color: var(--text2); font-size: 13.5px; }
.navi a:hover { background: var(--flaeche2); text-decoration: none; color: var(--text); }
.navi a.aktiv { background: var(--akzent2); color: var(--akzent); font-weight: 600; }
.navi a .ni { width: 18px; text-align: center; color: var(--text3); font-size: 13px; }
.navi a.aktiv .ni { color: var(--akzent); }
.navi a .zahl { margin-left: auto; font-size: 11.5px; color: var(--text3); }
.navi a.unter { padding-left: 37px; font-size: 13px; }
.navi-titel { margin: 16px 10px 4px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text3); }
.inhalt { margin-left: 232px; flex: 1; min-width: 0; padding: 24px 32px 80px; outline: none; }

/* ---------- Bausteine ---------- */
.knopf { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 13px; border-radius: 7px; border: 1px solid var(--linie2);
  background: var(--flaeche); cursor: pointer; font-size: 13.5px; white-space: nowrap; color: var(--text); }
.knopf:hover { border-color: var(--akzent); color: var(--akzent); text-decoration: none; }
.knopf.primaer { background: var(--akzent); color: var(--akzent-text); border-color: var(--akzent); }
.knopf.primaer:hover { filter: brightness(1.08); color: var(--akzent-text); }
.knopf.klein { height: 26px; padding: 0 9px; font-size: 12.5px; }
.knopf.gefahr:hover { border-color: var(--fehler); color: var(--fehler); }
.knopf:disabled { opacity: .5; cursor: default; }
.knopf.an { background: var(--akzent2); color: var(--akzent); border-color: var(--akzent); }
.knopfleiste { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--schatten); }
.inhalt > .karte + .karte, .leser-rechts .karte + .karte { margin-top: 16px; }
.raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.kachel { display: block; background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); padding: 14px 16px; color: var(--text); }
.kachel:hover { border-color: var(--akzent); text-decoration: none; }
.kachel .k-titel { font-weight: 650; margin-bottom: 3px; }
.kachel .k-text { color: var(--text2); font-size: 13px; }
.kachel .k-meta { color: var(--text3); font-size: 12px; margin-top: 8px; }
.gedimmt { color: var(--text3); }
.klein { font-size: 12.5px; }
.marke-q { display: inline-block; padding: 1px 7px; border-radius: 10px; background: var(--flaeche2); color: var(--text2); font-size: 11.5px; border: 1px solid var(--linie); white-space: nowrap; }
.marke-q.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.marke-q.warn { color: var(--warn); }
.marke-q.fehler { color: var(--fehler); }
.seitenkopf { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.seitenkopf .titelblock { flex: 1; min-width: 260px; }
.seitenkopf p { margin: 2px 0 0; color: var(--text2); }
.hinweis { background: var(--akzent2); border: 1px solid var(--linie); border-left: 3px solid var(--akzent); padding: 10px 14px; border-radius: 6px; margin: 12px 0; color: var(--text2); }
.hinweis.warn { border-left-color: var(--warn); }
.hinweis.fehler { border-left-color: var(--fehler); }
.leer { text-align: center; color: var(--text3); padding: 40px 20px; }
input[type=text], input[type=search], input[type=number], input[type=password], input[type=url], select, textarea {
  border: 1px solid var(--linie2); border-radius: 6px; padding: 6px 9px; background: var(--flaeche); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--akzent); box-shadow: 0 0 0 3px var(--akzent2); }
textarea { width: 100%; resize: vertical; }
textarea.code { font: 12.5px/1.45 ui-monospace, Consolas, "Courier New", monospace; min-height: 340px; }
label.feld { display: block; margin-bottom: 10px; }
label.feld > span { display: block; font-size: 12.5px; color: var(--text2); margin-bottom: 3px; }
.zweispaltig { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
table.tabelle { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tabelle th { text-align: left; font-weight: 600; color: var(--text2); font-size: 12px; border-bottom: 1px solid var(--linie2); padding: 6px 8px; }
table.tabelle td { border-bottom: 1px solid var(--linie); padding: 7px 8px; vertical-align: top; }
table.tabelle tr:hover td { background: var(--flaeche2); }
.protokoll { font: 12px/1.5 ui-monospace, Consolas, monospace; background: var(--flaeche2); border-radius: 6px; padding: 8px 10px; max-height: 180px; overflow: auto; white-space: pre-wrap; color: var(--text2); }
.fortschritt { height: 6px; background: var(--flaeche2); border-radius: 3px; overflow: hidden; margin: 6px 0; }
.fortschritt > div { height: 100%; background: var(--akzent); transition: width .3s; }
.ablage { border: 2px dashed var(--linie2); border-radius: 8px; padding: 16px; text-align: center; color: var(--text3); }
.ablage.drueber { border-color: var(--akzent); background: var(--akzent2); color: var(--akzent); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--linie); margin-bottom: 10px; }
.tabs button { border: 0; background: none; padding: 7px 12px; cursor: pointer; color: var(--text2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-size: 13px; }
.tabs button.aktiv { color: var(--akzent); border-bottom-color: var(--akzent); font-weight: 600; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 12px; background: var(--akzent2); color: var(--akzent); font-size: 12px; margin: 2px 4px 2px 0; }
.chip button { border: 0; background: none; cursor: pointer; padding: 0; color: inherit; opacity: .7; }

/* ---------- Leseansicht ---------- */
.leser { display: grid; grid-template-columns: 250px minmax(0, 1fr) 300px; gap: 26px; align-items: start; }
.leser.ohne-links { grid-template-columns: minmax(0, 1fr) 300px; }
.leser-links, .leser-rechts { position: sticky; top: 74px; max-height: calc(100vh - 94px); overflow-y: auto; font-size: 13px; }
.leser-rechts .karte { padding: 14px 16px; box-shadow: none; }
.leser-rechts h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--text3); }
.lesetext { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); padding: 34px 46px 60px; font: var(--lesegroesse)/1.68 var(--lesefont); max-width: 860px; }
html[data-lesefont="sans"] .lesetext { font-family: var(--uifont); }
.lesetext h1 { font: 650 1.45em/1.25 var(--uifont); margin-bottom: .35em; }
.lesetext h2 { font: 650 1.12em/1.3 var(--uifont); margin: 1.4em 0 .5em; }
.lesetext h3, .lesetext h4 { font: 650 1em/1.3 var(--uifont); margin: 1.2em 0 .4em; }
.lesetext p { margin: 0 0 .8em; }
.lesetext .li { margin: 0 0 .5em; padding-left: 1.2em; position: relative; }
.lesetext .li::before { content: "•"; position: absolute; left: .2em; color: var(--text3); }
.lesetext .seite { font: 11.5px var(--uifont); color: var(--text3); border-top: 1px dashed var(--linie2); margin: 1.6em 0 1em; padding-top: 3px; text-align: right; }
.lesetext .td { margin: 0 0 .35em; padding-left: .8em; border-left: 2px solid var(--linie); }
.doc-meta { font: 13px/1.5 var(--uifont); color: var(--text2); margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px solid var(--linie); }
.doc-meta .knopfleiste { margin-top: 10px; }
a.norm { color: var(--norm); background: var(--norm-bg); border-radius: 3px; padding: 0 1px; text-decoration: none; border-bottom: 1px dotted var(--norm); }
a.norm:hover { background: color-mix(in srgb, var(--norm) 18%, transparent); }
mark { color: inherit; border-radius: 2px; padding: 0; cursor: pointer; }
mark.m-gelb { background: var(--m-gelb); } mark.m-gruen { background: var(--m-gruen); } mark.m-blau { background: var(--m-blau); }
mark.m-rot { background: var(--m-rot); } mark.m-lila { background: var(--m-lila); }
mark.m-notiz { border-bottom: 2px solid var(--text3); }
mark.fund { background: var(--treffer); cursor: default; box-shadow: 0 0 0 1px color-mix(in srgb, var(--treffer) 60%, #000 10%); }
mark.blink { animation: blink 1.4s ease-in-out 2; }
@keyframes blink { 50% { outline: 3px solid var(--akzent); } }

/* Gesetz */
.norm-einheit { scroll-margin-top: 80px; padding: 6px 0 14px; border-bottom: 1px solid var(--linie); margin-bottom: 18px; }
.norm-kopf { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; font-family: var(--uifont); margin-bottom: 10px; }
.norm-kopf .nr { font-weight: 750; font-size: 1.05em; color: var(--akzent); }
.norm-kopf .titel { font-weight: 650; font-size: 1.02em; }
.norm-kopf .aktionen { margin-left: auto; display: flex; gap: 6px; opacity: .55; transition: opacity .15s; }
.norm-einheit:hover .norm-kopf .aktionen, .norm-kopf .aktionen:focus-within { opacity: 1; }
.norm-einheit.ziel { animation: ziel 2s ease-out; }
@keyframes ziel { from { background: var(--akzent2); } to { background: transparent; } }
.gruppe-titel { font: 700 12px var(--uifont); letter-spacing: .05em; text-transform: uppercase; color: var(--text3); margin: 28px 0 14px; padding-bottom: 6px; border-bottom: 2px solid var(--linie); }
.toc a { display: block; padding: 3px 8px; border-radius: 5px; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toc a:hover { background: var(--flaeche2); text-decoration: none; }
.toc a.aktiv { background: var(--akzent2); color: var(--akzent); }
.toc .toc-gruppe { font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: .04em; margin: 12px 8px 3px; white-space: normal; }
.toc a b { color: var(--text); font-weight: 650; margin-right: 4px; }
.sprung { display: flex; gap: 6px; margin-bottom: 10px; }
.sprung input { width: 100%; }
.eg-liste .eg { font: 14.5px/1.55 var(--lesefont); margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--linie); }
.eg-liste .eg b { font-family: var(--uifont); font-size: 12.5px; }
.seitenliste a { display: block; padding: 6px 0; border-bottom: 1px solid var(--linie); color: var(--text); }
.seitenliste a small { display: block; color: var(--text3); }

/* Suche */
.suchfeld-gross { display: flex; gap: 8px; margin-bottom: 16px; }
.suchfeld-gross input { flex: 1; height: 42px; font-size: 16px; padding: 0 14px; border-radius: 8px; }
.suche-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 24px; align-items: start; }
.filter { position: sticky; top: 74px; }
.filter label { display: flex; align-items: center; gap: 7px; padding: 3px 0; font-size: 13px; cursor: pointer; }
.filter label .zahl { margin-left: auto; color: var(--text3); font-size: 12px; }
.filter h3 { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text3); margin: 14px 0 6px; }
.treffer-liste { display: flex; flex-direction: column; gap: 10px; }
.treffer { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); padding: 12px 16px; }
.treffer:hover { border-color: var(--linie2); }
.treffer .t-kopf { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.treffer .t-titel { font-weight: 650; font-size: 15px; }
.treffer .t-ausschnitt { color: var(--text2); margin-top: 4px; font: 14px/1.55 var(--lesefont); }
.treffer .t-meta { display: flex; gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; font-size: 12px; color: var(--text3); }
.direkt { border-color: var(--akzent); background: var(--akzent2); }

/* Popups */
.werkzeugleiste { position: absolute; z-index: 50; display: flex; gap: 4px; align-items: center; background: var(--flaeche); border: 1px solid var(--linie2);
  border-radius: 9px; padding: 5px; box-shadow: var(--schatten); font: 13px var(--uifont); }
.werkzeugleiste .farbe { width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--linie2); cursor: pointer; padding: 0; }
.werkzeugleiste .farbe.m-gelb { background: var(--m-gelb); } .werkzeugleiste .farbe.m-gruen { background: var(--m-gruen); }
.werkzeugleiste .farbe.m-blau { background: var(--m-blau); } .werkzeugleiste .farbe.m-rot { background: var(--m-rot); } .werkzeugleiste .farbe.m-lila { background: var(--m-lila); }
.werkzeugleiste .farbe.gewaehlt { outline: 2px solid var(--akzent); outline-offset: 1px; }
.werkzeugleiste .trenner { width: 1px; align-self: stretch; background: var(--linie); margin: 0 3px; }
.werkzeugleiste button.txt { border: 0; background: none; cursor: pointer; padding: 3px 7px; border-radius: 5px; color: var(--text); }
.werkzeugleiste button.txt:hover { background: var(--flaeche2); }
.werkzeugleiste.spalte { flex-direction: column; align-items: stretch; width: 300px; padding: 10px; }
.vorschau { position: absolute; z-index: 60; width: 420px; max-height: 340px; overflow: auto; background: var(--flaeche); border: 1px solid var(--linie2); border-radius: 9px;
  padding: 12px 14px; box-shadow: var(--schatten); font: 13.5px/1.55 var(--uifont); white-space: pre-line; }
.vorschau b { display: block; margin-bottom: 4px; color: var(--akzent); }
.dialog-hg { position: fixed; inset: 0; background: rgba(10, 15, 25, .35); z-index: 70; display: flex; align-items: center; justify-content: center; padding: 20px; }
.dialog { background: var(--flaeche); border-radius: 10px; padding: 20px 22px; width: min(620px, 100%); max-height: 90vh; overflow: auto; box-shadow: var(--schatten); }
.dialog .knopfleiste { justify-content: flex-end; margin-top: 14px; }
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 80; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--text); color: var(--bg); padding: 10px 14px; border-radius: 8px; box-shadow: var(--schatten); max-width: 420px; font-size: 13.5px; }
.toast.fehler { background: var(--fehler); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
.original-rahmen { width: 100%; height: calc(100vh - 170px); min-height: 560px; border: 1px solid var(--linie); border-radius: 6px; background: #fff; display: block; }
.bookmarklet { display: inline-block; padding: 7px 14px; background: var(--akzent); color: var(--akzent-text); border-radius: 18px; font-weight: 600; cursor: grab; }
.bookmarklet:hover { text-decoration: none; }
.liste-markierung { border-left: 4px solid var(--linie2); padding: 6px 12px; margin: 8px 0; background: var(--flaeche); border-radius: 0 6px 6px 0; }
.liste-markierung.m-gelb { border-left-color: #e8c400; } .liste-markierung.m-gruen { border-left-color: #3daa55; } .liste-markierung.m-blau { border-left-color: #3f7fe0; }
.liste-markierung.m-rot { border-left-color: #e0503f; } .liste-markierung.m-lila { border-left-color: #8d5ce0; }
.liste-markierung .zitat { font: 14.5px/1.55 var(--lesefont); }
.liste-markierung .notiz { color: var(--text2); font-size: 13px; margin-top: 4px; white-space: pre-wrap; }
.stat { font-size: 26px; font-weight: 700; color: var(--akzent); line-height: 1.1; }
.statreihe { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 14px 0 22px; }
.statreihe .karte { padding: 12px 16px; box-shadow: none; }

@media (max-width: 1250px) {
  .leser { grid-template-columns: 220px minmax(0, 1fr); }
  .leser.ohne-links { grid-template-columns: minmax(0, 1fr); }
  .leser-rechts { position: static; max-height: none; grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .navi { display: none; }
  .inhalt { margin-left: 0; padding: 16px; }
  .leser { grid-template-columns: minmax(0, 1fr); }
  .leser-links { position: static; max-height: 260px; }
  .lesetext { padding: 20px; }
  .suche-layout { grid-template-columns: 1fr; }
  .marke { width: auto; }
  .marke span { display: none; }
}
@media print {
  .kopf, .navi, .leser-links, .leser-rechts, .norm-kopf .aktionen, .doc-meta .knopfleiste { display: none !important; }
  .inhalt { margin: 0; padding: 0; }
  .rahmen { padding: 0; }
  .leser { display: block; }
  .lesetext { border: 0; padding: 0; max-width: none; }
}

/* ---------- Serverbetrieb ---------- */
body.kein-admin .nur-admin { display: none !important; }
.kopf-benutzer { font-size: 12.5px; color: var(--text2); white-space: nowrap; }
.anmeldung { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.anmeldung .karte { width: min(400px, 100%); padding: 28px 30px; }
.anmeldung h1 { display: flex; align-items: center; gap: 10px; color: var(--akzent); margin-bottom: 4px; }
.anmeldung input { width: 100%; height: 38px; }
.anmeldung .knopf { width: 100%; justify-content: center; height: 38px; margin-top: 6px; }
.anmeldung .meldung { color: var(--fehler); min-height: 1.4em; font-size: 13px; margin-top: 8px; }
tr.gelesen td a { color: var(--text2); }

/* Breite der Lesefläche: Originalansicht ohne rechte Spalte, Griff zum Ziehen */
.lesetext { position: relative; }
.leser.original { grid-template-columns: minmax(0, 1fr); }
.leser.original .lesetext { max-width: none; padding: 22px 26px 26px; }
.breiten-griff { position: absolute; top: 0; right: -11px; width: 16px; height: 100%; cursor: col-resize; z-index: 5; touch-action: none; }
.breiten-griff::before { content: ""; position: sticky; display: block; top: calc(50vh - 30px); margin-top: 40px; margin-left: 4px; width: 8px; height: 60px; border-radius: 4px;
  background-color: var(--flaeche); border: 1px solid var(--linie2);
  background-image: radial-gradient(circle, var(--text3) 1.1px, transparent 1.4px); background-size: 4px 6px; background-position: center; opacity: .75; }
.breiten-griff:hover::before, body.zieht .breiten-griff::before { opacity: 1; border-color: var(--akzent); }
body.zieht { cursor: col-resize; user-select: none; }
body.zieht iframe { pointer-events: none; }
@media (max-width: 900px) { .breiten-griff { display: none; } }
@media print { .breiten-griff { display: none; } }
