/* Schlicht und modern: viel Weißraum, eine Akzentfarbe, Text in Serifenschrift. */
:root {
  --bg: #f6f6f4;
  --flaeche: #ffffff;
  --linie: #dcdcd6;
  --text: #1d1f23;
  --gedaempft: #6b6f76;
  --akzent: #1f4e8c;
  --akzent-hell: #e7eef8;
  --rot: #b3261e;
  --lf: 1fr;
  --rf: 1fr;
  --kopf-h: 60px;
  --fuss-h: 34px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, "Segoe UI", Roboto, sans-serif;
}

button, select {
  font: inherit;
  color: inherit;
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover, select:hover { border-color: var(--akzent); }
button:focus-visible, select:focus-visible, .teiler:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }

/* Kopf */
.kopf {
  height: var(--kopf-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  background: var(--flaeche);
  border-bottom: 1px solid var(--linie);
}
.titel h1 { margin: 0; font-size: 18px; font-weight: 650; letter-spacing: -0.01em; }
.titel p { margin: 0; font-size: 12.5px; color: var(--gedaempft); }
.blatt-nav { display: flex; gap: 6px; margin-left: auto; }
.blatt-nav button { width: 36px; padding: 6px 0; font-size: 18px; line-height: 1; }
.blatt-nav select { min-width: 90px; }
.schalter { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--gedaempft); cursor: pointer; user-select: none; }
.schalter input { accent-color: var(--akzent); width: 16px; height: 16px; }

/* Zweispaltige Arbeitsfläche */
.seiten {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, var(--lf)) 10px minmax(0, var(--rf));
}
.bild, .text-bereich { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--flaeche); }
.bild { position: relative; background: #ececea; }

.teiler { cursor: col-resize; background: var(--bg); border-left: 1px solid var(--linie); border-right: 1px solid var(--linie); position: relative; }
.teiler::after { content: ""; position: absolute; left: 3px; top: 50%; width: 2px; height: 36px; margin-top: -18px; background: var(--linie); border-radius: 2px; }
.teiler:hover::after, .teiler.zieht::after { background: var(--akzent); }

/* Bild */
.buehne { position: relative; flex: 1; overflow: hidden; cursor: grab; touch-action: none; }
.buehne.zieht { cursor: grabbing; }
.zoomflaeche { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.zoomflaeche img { display: block; max-width: none; user-select: none; box-shadow: 0 2px 14px rgba(0, 0, 0, .18); }
.zoomflaeche svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#z-rot[aria-pressed="true"] { background: var(--akzent); color: #fff; border-color: var(--akzent); }
.rot-rahmen rect { fill: rgba(40, 160, 70, .12); stroke: #1f9d46; stroke-width: 3; vector-effect: non-scaling-stroke; }
.rot-rahmen rect.geschaetzt { fill: rgba(60, 100, 200, .08); stroke: #3c64c8; stroke-dasharray: 3 5; }
.rot-rahmen rect.unsicher { stroke: #d08a00; stroke-dasharray: 8 4; }
#markierung { fill: rgba(31, 78, 140, .22); stroke: var(--akzent); stroke-width: 6; vector-effect: non-scaling-stroke; display: none; }
.meldung { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--gedaempft); background: #ececea; }
.meldung[hidden] { display: none; }
.zoom-leiste { position: absolute; z-index: 2; top: 12px; left: 12px; display: flex; gap: 6px; }
.zoom-leiste button { box-shadow: 0 1px 4px rgba(0, 0, 0, .1); padding: 5px 11px; font-size: 13.5px; }
.zoom-leiste #z-plus, .zoom-leiste #z-minus { width: 34px; padding: 5px 0; font-size: 17px; line-height: 1.1; }

/* Transkription */
.text-kopf { flex: none; padding: 12px 24px; border-bottom: 1px solid var(--linie); font-weight: 600; font-size: 14px; color: var(--gedaempft); }
.text { flex: 1; overflow: auto; padding: 18px 24px 40px; font-family: "EB Garamond", Georgia, "Times New Roman", serif; font-size: 20.5px; line-height: 1.55; }
.zeile { display: grid; grid-template-columns: 2.4em 1fr 2.2em; border-radius: 6px; padding: 0 6px; margin: 0 -6px; }
.zeile:hover { background: var(--akzent-hell); }
.zeile .nr { color: var(--gedaempft); font: 12px/2.8 system-ui, sans-serif; text-align: right; padding-right: 12px; user-select: none; }
.spalte { margin: 18px 0 6px; font: 600 11.5px system-ui, sans-serif; letter-spacing: .08em; text-transform: uppercase; color: var(--gedaempft); }

.text .ex { font-style: italic; }
.text.nicht .ex { display: none; }
.text .rot { color: var(--rot); }
.text .del { text-decoration: line-through; color: var(--gedaempft); }
.text .add { color: var(--akzent); }
.text .unclear { border-bottom: 1.5px dotted var(--gedaempft); }
.text .note { font: 13px system-ui, sans-serif; color: var(--akzent); cursor: help; margin-left: 2px; }
.text .initial { font-weight: 600; }

/* Fuß */
.fuss { height: var(--fuss-h); flex: none; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 0 20px; background: var(--flaeche); border-top: 1px solid var(--linie); font-size: 12.5px; color: var(--gedaempft); }

/* Schmale Fenster: Bild oben, Text unten */
@media (max-width: 800px) {
  .kopf { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 10px 16px; }
  .blatt-nav { margin-left: 0; }
  .seiten { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) 0 minmax(0, 1fr); }
  .teiler { display: none; }
  .fuss { flex-direction: column; height: auto; padding: 6px 14px; gap: 2px; }
}

/* ---------- Prüfung ---------- */
.text-kopf { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 8px; padding-bottom: 8px; }
.reiter { display: flex; gap: 4px; background: var(--bg); padding: 3px; border-radius: 10px; }
.reiter button { border: 0; background: transparent; padding: 5px 12px; border-radius: 8px; font-size: 13.5px; color: var(--gedaempft); }
.reiter button[aria-selected="true"] { background: var(--flaeche); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.zaehler { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--akzent); color: #fff; font-size: 11.5px; text-align: center; }
.zaehler[hidden], .pruefung[hidden], .text[hidden], #reiter-auto[hidden] { display: none; }

.pruefung { flex: 1; overflow: auto; padding: 16px 24px 40px; display: flex; flex-direction: column; gap: 12px; }
.leiste { display: flex; flex-wrap: wrap; gap: 8px; }
.leiste .haupt, .einfuegen .haupt { background: var(--akzent); color: #fff; border-color: var(--akzent); }
.leiste .haupt:disabled { background: var(--flaeche); color: var(--gedaempft); border-color: var(--linie); cursor: not-allowed; }
.api-status { margin: 0; font-size: 13px; color: var(--gedaempft); }
.info { display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; border-radius: 8px; background: var(--akzent-hell); font-size: 13.5px; }
.einfuegen { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
textarea { width: 100%; font: 13px/1.4 ui-monospace, Consolas, monospace; border: 1px solid var(--linie); border-radius: 8px; padding: 8px; }
.fehler { margin: 0; color: var(--rot); font-size: 13px; }
.demo-hinweis { margin: 0; padding: 8px 12px; border-radius: 8px; background: #fff4e0; color: #7a4b00; font-size: 13px; }
.leer { color: var(--gedaempft); margin: 12px 0; }
.summe { display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; color: var(--gedaempft); }
button.klein { padding: 3px 10px; font-size: 12.5px; }
button.export { align-self: flex-start; margin-top: 8px; }

.karte { border: 1px solid var(--linie); border-radius: 12px; padding: 12px 14px; background: var(--flaeche); display: flex; flex-direction: column; gap: 8px; }
.karte:hover { border-color: var(--akzent); }
.karte.ja { border-left: 4px solid #1e7d3a; }
.karte.nein { border-left: 4px solid var(--rot); opacity: .65; }
.karte-kopf { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 13.5px; }
.chip { padding: 1px 8px; border-radius: 10px; background: var(--bg); color: var(--gedaempft); font-size: 12px; }
.chip.hoch { background: #e3f3e8; color: #1e7d3a; }
.chip.mittel { background: #fff4e0; color: #7a4b00; }
.chip.niedrig { background: #fbe6e4; color: var(--rot); }
.diff { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; font-family: "EB Garamond", Georgia, serif; font-size: 21px; }
.diff .alt { background: #fbe6e4; text-decoration: line-through; padding: 0 6px; border-radius: 5px; }
.diff .neu { background: #e3f3e8; padding: 0 6px; border-radius: 5px; }
.diff .pfeil { color: var(--gedaempft); font-family: system-ui, sans-serif; }
.grund { margin: 0; font-size: 14px; }
.warnung { margin: 0; font-size: 13px; color: var(--rot); }
.aktion { display: flex; align-items: center; gap: 10px; }
.aktion .ja, .aktion .nein { width: 44px; height: 38px; padding: 0; font-size: 20px; line-height: 1; color: #fff; border: 0; }
.aktion .ja { background: #1e7d3a; }
.aktion .nein { background: var(--rot); }
.aktion .ja:disabled { background: var(--linie); cursor: not-allowed; }
.aktion .ja:hover:not(:disabled), .aktion .nein:hover { filter: brightness(1.1); }
.entschieden { font-size: 13.5px; font-weight: 600; }
.aktion .rueck { padding: 3px 10px; font-size: 12.5px; }

/* Angenommene Änderungen im Transkriptionstext */
.korrigiert { background: #f1faf4; border-radius: 4px; }
.korrigiert ins { background: #c9ecd3; text-decoration: none; border-radius: 3px; padding: 0 2px; }

/* Richtlinien-Fenster */
dialog { width: min(760px, 92vw); max-height: 86vh; border: 1px solid var(--linie); border-radius: 14px; padding: 18px 22px; background: var(--flaeche); color: var(--text); box-shadow: 0 12px 40px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(20, 22, 26, .4); }
.dlg-kopf { display: flex; justify-content: space-between; align-items: center; }
.dlg-kopf h2 { margin: 0; font-size: 17px; }
.hinweis { font-size: 13px; color: var(--gedaempft); }
#richtlinien-text { max-height: 40vh; overflow: auto; white-space: pre-wrap; font: 13px/1.5 system-ui, sans-serif; background: var(--bg); padding: 12px; border-radius: 8px; }
.dlg-feld { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--gedaempft); margin-top: 12px; }

/* "hidden" soll immer gewinnen */
[hidden] { display: none !important; }

/* Zeile im Zusammenhang, nur das betroffene Wort markiert */
.kontext { font-family: "EB Garamond", Georgia, serif; font-size: 19px; line-height: 1.4; padding: 6px 10px; background: var(--bg); border-radius: 8px; overflow-wrap: anywhere; }
.kontext mark { background: #ffe58a; color: inherit; padding: 0 3px; border-radius: 4px; box-shadow: 0 0 0 1px #e8c84a; }
.kontext mark.neu-wort { background: #c9ecd3; box-shadow: 0 0 0 1px #8fcfa2; }

/* Bearbeiten */
.kopf-links { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kopf-links #blatt-titel { margin-right: 4px; }
#bearbeiten-knopf[aria-pressed="true"] { background: var(--akzent); color: #fff; border-color: var(--akzent); }
.text.bearbeiten .zeile { cursor: text; }
.text.bearbeiten .zeile:hover { outline: 1px dashed var(--akzent); background: transparent; }
.zeilen-eingabe { width: 100%; font: inherit; padding: 0 6px; border: 1px solid var(--akzent); border-radius: 6px; background: #fff; color: var(--text); outline: none; box-shadow: 0 0 0 3px var(--akzent-hell); }
.korrigiert.bearbeitet { background: #eef3fb; }
.zurueck { display: none; margin-left: 10px; padding: 0 7px; font: 14px/1.5 system-ui, sans-serif; vertical-align: middle; }
.text.bearbeiten .zurueck { display: inline-block; }

/* Dritte Ansicht: Zeilenansicht (ca. 50 % der Arbeitsfläche) */
.arbeit { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.zeilenansicht { position: fixed; z-index: 20; left: calc(50% - min(780px, 48vw)); bottom: 40px; width: min(1560px, 96vw); height: min(78vh, calc(100vh - 90px)); min-height: 360px; display: flex; flex-direction: column; background: var(--flaeche); border: 1px solid var(--akzent); border-radius: 14px; box-shadow: 0 18px 60px rgba(10, 14, 22, .45), 0 0 0 1px rgba(255, 255, 255, .4); overflow: hidden; }
.zv-kopf { flex: none; display: flex; justify-content: space-between; align-items: center; padding: 8px 14px 8px 20px; border-bottom: 1px solid var(--linie); font-size: 14px; cursor: move; touch-action: none; user-select: none; background: var(--bg); }
.zv-nav { display: flex; gap: 6px; }
.zv-nav button { padding: 3px 12px; }
.zv-buehne { position: relative; flex: 1; min-height: 0; display: grid; place-items: center; background: #15171b; overflow: hidden; }
.zv-ausschnitt { position: relative; overflow: hidden; }
.zv-ausschnitt img { position: absolute; max-width: none; user-select: none; }
.zv-ausschnitt svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#zv-dunkel { fill: rgba(10, 12, 16, .6); }
#zv-poly { fill: none; stroke: rgba(255, 210, 74, .4); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.zv-meldung { margin: 0; padding: 0 20px; color: #c9ccd2; text-align: center; }
.zv-eingabe { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; padding: 10px 20px 12px; border-top: 1px solid var(--linie); }
.zv-eingabe label { font-size: 12.5px; color: var(--gedaempft); }
#zv-feld { flex: 1 1 420px; min-width: 0; font: 22px/1.4 "EB Garamond", Georgia, serif; padding: 4px 10px; border: 1px solid var(--akzent); border-radius: 8px; box-shadow: 0 0 0 3px var(--akzent-hell); outline: none; color: var(--text); background: #fff; }
.zv-hinweis { flex-basis: 100%; font-size: 12px; color: var(--gedaempft); }
#zeilen-knopf[aria-pressed="true"] { background: var(--akzent); color: #fff; border-color: var(--akzent); }
.zeile.aktiv { background: var(--akzent-hell); box-shadow: inset 3px 0 0 var(--akzent); }

@media (max-width: 800px) {
  .zeilenansicht { left: 3vw !important; width: 94vw; bottom: 8px; }
}

/* Eigene Spalte: Knopf pro Zeile für die Zeilenansicht */
.zv-oeffnen { align-self: center; justify-self: center; width: 28px; height: 28px; padding: 0; display: grid; place-items: center; border: 0; background: transparent; color: var(--gedaempft); opacity: .45; border-radius: 6px; }
.zeile:hover .zv-oeffnen, .zeile.aktiv .zv-oeffnen, .zv-oeffnen:focus-visible { opacity: 1; }
.zv-oeffnen:hover { background: var(--akzent-hell); color: var(--akzent); border: 0; }

/* Eingabefeld: Breite und Schriftgröße werden per JS an die Länge der Handschrift angepasst */
.zv-eingabe { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 6px; padding: 10px 0 12px; }
.zv-eingabe label, .zv-hinweis { padding-left: 20px; flex-basis: auto; }
#zv-feld { flex: none; max-width: calc(100% - 24px); margin-left: 12px; width: calc(100% - 24px); }

/* Zeilenansicht: Transkription in serifenloser Schrift (Größe setzt das Skript) */
#zv-feld { font-family: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; line-height: 1.3; white-space: pre; overflow: hidden; cursor: text; }
#zv-feld .note, #zv-feld .luecke { user-select: none; }

/* Speicherstatus */
.speicher-status { font-size: 12px; color: var(--gedaempft); max-width: 36ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.speicher-status.ok { color: #1e7d3a; }
.speicher-status.warn { color: var(--rot); white-space: normal; }

/* Auszeichnungen (Vorschau und bearbeitete Zeilen) */
.text .f-blau, #zv-feld .f-blau { color: #1f4e8c; }
.text .f-gruen, #zv-feld .f-gruen { color: #1e7d3a; }
.text .f-gold, #zv-feld .f-gold { color: #9a7400; }
/* Rotstrich: leichter roter senkrechter Strich durch den Buchstaben */
.text.mit-anfangsstrich .anfangsstrich, .text .rotstrich, #zv-feld .rotstrich { background: linear-gradient(to right, transparent calc(50% - 1px), rgba(179, 38, 30, .5) calc(50% - 1px), rgba(179, 38, 30, .5) calc(50% + 1px), transparent calc(50% + 1px)); }
#zv-feld .rot { color: var(--rot); }
.text .rotunterstrichen, #zv-feld .rotunterstrichen { text-decoration: underline; text-decoration-color: var(--rot); }
.text .nachgezogen, #zv-feld .nachgezogen { text-shadow: 0 0 1px var(--rot); }
.text .versal, #zv-feld .versal { font-weight: 700; }
.text .kadelle, #zv-feld .kadelle { font-style: italic; font-weight: 600; }
.text .unterstrichen, #zv-feld .unterstrichen { text-decoration: underline; }
.text .damage, #zv-feld .damage { background: rgba(120, 100, 60, .18); border-radius: 3px; }
.text .luecke, #zv-feld .luecke { color: var(--gedaempft); letter-spacing: .05em; }
.text .add-oben, #zv-feld .add-oben { vertical-align: super; font-size: .75em; }
.text .add-unten, #zv-feld .add-unten { vertical-align: sub; font-size: .75em; }
.text .add-randl, .text .add-randr, .text .add-spaltel, .text .add-spalter,
#zv-feld .add-randl, #zv-feld .add-randr, #zv-feld .add-spaltel, #zv-feld .add-spalter { border-bottom: 1.5px dashed var(--akzent); }
#zv-feld .del { text-decoration: line-through; color: var(--gedaempft); }
#zv-feld .add { color: var(--akzent); }
#zv-feld .unclear { border-bottom: 1.5px dotted var(--gedaempft); }
#zv-feld .ex { font-style: italic; }
#zv-feld .initial { font-weight: 600; }
#zv-feld .note { font: 13px system-ui, sans-serif; color: var(--akzent); margin-left: 2px; }

/* Werkzeugleiste, Vorschau und Hilfe in der Zeilenansicht */
.werkzeug { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 20px; }
.werkzeug button, .werkzeug select { padding: 3px 10px; font-size: 13px; border-radius: 7px; }
.werkzeug .w-rot { color: var(--rot); }
.werkzeug .w-weg { margin-left: auto; color: var(--gedaempft); }
.werkzeug-hilfe { padding: 0 20px; font-size: 12.5px; color: var(--gedaempft); }
.werkzeug-hilfe summary { cursor: pointer; }
.werkzeug-hilfe table { border-collapse: collapse; margin-top: 6px; }
.werkzeug-hilfe td { padding: 2px 12px 2px 0; vertical-align: top; }
.werkzeug-hilfe code { font: 12px ui-monospace, Consolas, monospace; background: var(--bg); padding: 0 4px; border-radius: 4px; color: var(--text); }
.zv-eingabe { max-height: 52%; overflow: auto; }

/* Werkzeugleiste in der normalen Ansicht (über dem Text) */
.werkzeug-leiste { flex: none; padding: 8px 24px 4px; border-bottom: 1px solid var(--linie); background: var(--flaeche); }
.werkzeug-leiste[hidden] { display: none; }
.werkzeug-leiste .werkzeug { padding: 0; align-items: center; }
.werkzeug-leiste .werkzeug-hilfe { padding: 4px 0 2px; }
.werkzeug button, .werkzeug select { opacity: .5; }
.werkzeug.aktiv button, .werkzeug.aktiv select { opacity: 1; }
.werkzeug .w-hinweis { font-size: 12.5px; color: var(--gedaempft); }
.werkzeug.aktiv .w-hinweis { display: none; }
.zeilen-vorschau { margin-top: 2px; padding: 0 6px; font-size: .9em; color: var(--gedaempft); background: var(--bg); border-radius: 6px; min-height: 1.4em; overflow-wrap: anywhere; }
.zeilen-vorschau .rot { color: var(--rot); }

.roh { font-size: 12.5px; color: var(--gedaempft); }
.roh summary { cursor: pointer; }
.roh pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 240px; overflow: auto; background: var(--bg); padding: 8px; border-radius: 8px; font: 12px/1.4 ui-monospace, Consolas, monospace; }

/* Auffällige Wortformen (js/wortpruefung.js) */
.text .auffaellig-wort { background: rgba(255, 200, 40, .35); border-bottom: 2px wavy var(--rot); cursor: help; }
.text .auffaellig-wort.blinkt { outline: 2px solid var(--rot); }
.auffaellig { flex: none; max-height: 9rem; overflow: auto; padding: 8px 24px; border-top: 1px solid #d8dbe0; font: 14px/1.6 system-ui, sans-serif; color: var(--gedaempft); }
.auffaellig button { margin: 2px 4px 2px 0; }
.auffaellig p { margin: 4px 0 0; font-style: italic; }
.text.auff-aus .auffaellig-wort { background: none; border-bottom: 0; cursor: inherit; }
.chip.richter { background: #efe6ff; color: #4a2c8a; border-color: #c9b6f0; }
.richter-titel { margin: 14px 0 6px; font-size: 14px; color: #4a2c8a; }
.weitere { margin-top: 12px; }
.weitere > summary { cursor: pointer; color: var(--gedaempft); font-size: 13px; margin-bottom: 8px; }
.chip.kontext { background: #e4f1f7; color: #0b5671; }

.hs-wahl { max-width: 20em; }

/* Prüf-Raster: großer Prüfen-Knopf, weitere Optionen im Aufklappmenü */
.pruef-leiste { flex-wrap: nowrap; align-items: stretch; gap: 10px; }
.pruef-leiste .haupt { flex: 1; padding: 16px 22px; font-size: 19px; font-weight: 600; border-radius: 12px; box-shadow: 0 2px 8px rgba(31, 78, 140, .3); letter-spacing: .01em; }
.pruef-leiste .haupt:disabled { box-shadow: none; }
.mehr { position: relative; align-self: center; }
.mehr > summary { list-style: none; cursor: pointer; padding: 8px 12px; font-size: 13px; color: var(--gedaempft); border: 1px solid var(--linie); border-radius: 8px; background: var(--flaeche); user-select: none; white-space: nowrap; }
.mehr > summary::-webkit-details-marker { display: none; }
.mehr > summary:hover, .mehr[open] > summary { border-color: var(--akzent); color: var(--text); }
.mehr-menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 10; min-width: 230px; display: flex; flex-direction: column; padding: 4px; background: var(--flaeche); border: 1px solid var(--linie); border-radius: 10px; box-shadow: 0 8px 24px rgba(10, 14, 22, .18); }
.mehr-menu button { text-align: left; border: 0; background: transparent; padding: 8px 12px; font-size: 13.5px; border-radius: 6px; }
.mehr-menu button:hover { background: var(--akzent-hell); }
.richter-nichts { margin: 4px 0 10px; font-size: 14px; color: var(--gedaempft); }
.geprueft { margin: 0 0 8px; font-size: 13.5px; line-height: 1.5; color: var(--gedaempft); }
.geprueft strong { color: var(--text); }
.mehr:not([open]) > .mehr-menu { display: none; }

/* Freie Transkription (Wien A): nur Bild und Eingabefeld, keine Prüfung */
body.frei #reiter-pruef, body.frei #werkzeug-leiste, body.frei #richtlinien-knopf, body.frei label.schalter { display: none; }
.frei-feld { width: 100%; box-sizing: border-box; resize: none; border: 1px solid var(--linie); border-radius: 8px; padding: 12px 14px; font: inherit; line-height: 1.6; background: var(--flaeche); color: var(--text); white-space: pre; overflow: auto; }
.frei-feld:focus { outline: 2px solid var(--akzent); }
.frei-hinweis { margin: 0 0 8px; font: 13px system-ui, sans-serif; color: var(--gedaempft); }
.text.frei-text { display: flex; flex-direction: column; }
.text.frei-text .frei-feld { flex: 1; min-height: 0; }
.fz-leiste { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 0 0 8px; font: 13px system-ui, sans-serif; color: var(--gedaempft); }
.fz-leiste button[aria-pressed="true"] { background: var(--akzent-hell); border-color: var(--akzent); }
.fz-n input { width: 54px; margin-left: 4px; }
.fz-nr { margin-left: auto; }
.fz-streifen { position: relative; flex: none; overflow: hidden; background: #15171b; border-radius: 8px; margin: 0 0 8px; }
.fz-streifen img { position: absolute; max-width: none; user-select: none; }
.fz-band { position: absolute; left: 0; right: 0; border-top: 1.5px solid rgba(255, 210, 74, .7); border-bottom: 1.5px solid rgba(255, 210, 74, .7); pointer-events: none; }
.fz-meldung { margin: 0; padding: 12px 14px; color: #c9ccd2; font: 13px system-ui, sans-serif; }
.fz-dialog { flex: none; max-height: 70vh; display: flex; flex-direction: column; margin: 0 0 8px; padding: 8px; border: 1px solid var(--akzent); border-radius: 8px; background: var(--bg); }
.fz-dialog[hidden], .fz-streifen[hidden] { display: none; }
.fz-seite { position: relative; overflow: auto; cursor: crosshair; touch-action: none; }
.fz-seite img { display: block; width: 100%; user-select: none; }
.fz-rechteck { position: absolute; border: 2px solid #e0a800; background: rgba(255, 210, 74, .15); pointer-events: none; }
.text.frei-text .fz-dialog + .frei-feld { min-height: 140px; }
.fz-streifen { overflow-x: auto; overflow-y: hidden; }
.fz-fl { position: relative; min-width: 100%; }
.fz-band { width: 100%; }

/* Befunde der Prüfung direkt im Text */
.zeile.befund > :nth-child(2) { background: #fff8e1; border-radius: 4px; }
.zeile.befund-richter > :nth-child(2) { background: #fdecea; border-radius: 4px; }
.zeile > [data-befund]::after { content: attr(data-befund); margin-left: .6em; padding: 0 .4em; font-size: .78em; font-family: system-ui, sans-serif; color: #5d4037; background: #ffe9a8; border-radius: 3px; }
.zeile.befund-richter > [data-befund]::after { color: var(--rot); background: #f9c9c4; }
/* Zeile-für-Zeile-Ansicht (Wien A), nach dem Vorbild der Transkriptionsansicht von eScriptorium */
.fz-liste { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.fz-zeile { margin: 0 0 6px; padding: 4px; border: 1px solid transparent; border-radius: 8px; }
.fz-zeile.aktiv { border-color: var(--akzent); background: var(--akzent-hell); }
.fz-crop { position: relative; overflow: hidden; background: #15171b; border-radius: 6px; }
.fz-crop img { position: absolute; max-width: none; user-select: none; }
.fz-eingabezeile { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.fz-zeilennr { flex: none; width: 24px; text-align: right; font: 12px system-ui, sans-serif; color: var(--gedaempft); }
.fz-eingabe { flex: 1; min-width: 0; font: 20px/1.3 system-ui, "Segoe UI", Arial, sans-serif; padding: 4px 10px; border: 1px solid var(--linie); border-radius: 8px; background: var(--flaeche); color: var(--text); }
.fz-eingabe:focus { outline: 2px solid var(--akzent); border-color: var(--akzent); }
.fz-eingabe { width: 100%; box-sizing: border-box; margin-top: 8px; }
.fz-zeile.aktiv { max-width: 940px; }
.fz-crop[hidden] { display: none; }
/* Zeilenansicht Wien A als Fenster im Fenster (Grundstil von .zeilenansicht) */
.zeilenansicht.frei-fenster { left: 24px; bottom: 24px; width: min(940px, 54vw); height: auto; min-height: 0; }
.zeilenansicht.frei-fenster[hidden] { display: none; }
.frei-buehne { flex: none; display: flex; justify-content: center; padding: 12px; }
.frei-fenster .zv-eingabe { padding: 10px 12px 12px; }
.frei-fenster .fz-eingabe { margin-top: 0; font-size: 22px; }
.text.frei-text .frei-feld { flex: 1; min-height: 0; }
/* Wien A: Zeilenansicht größer, Eingabe serifenlos und genauso breit wie die Zeile im Bild */
.zeilenansicht.frei-fenster { width: min(1560px, 94vw); left: 3vw; }
.frei-fenster .fz-eingabe { width: 100%; box-sizing: border-box; font-family: system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; line-height: 1.3; white-space: pre; padding-right: 8px; }

/* ---------- Darkmode (Umschalter in der Kopfzeile; folgt zuerst der Systemeinstellung, danach der Wahl) ---------- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15171b;
  --flaeche: #1e2127;
  --linie: #343a43;
  --text: #e4e6ea;
  --gedaempft: #9aa0a9;
  --akzent: #6ea0e6;
  --akzent-hell: #263449;
  --rot: #ef7a72;
}
:root[data-theme="dark"] .bild, :root[data-theme="dark"] .meldung { background: #101215; }
:root[data-theme="dark"] #z-rot[aria-pressed="true"], :root[data-theme="dark"] .zaehler,
:root[data-theme="dark"] .leiste .haupt, :root[data-theme="dark"] .einfuegen .haupt,
:root[data-theme="dark"] #bearbeiten-knopf[aria-pressed="true"], :root[data-theme="dark"] #zeilen-knopf[aria-pressed="true"] { color: #0e1116; }
:root[data-theme="dark"] .demo-hinweis, :root[data-theme="dark"] .chip.mittel { background: #3b2f14; color: #f0c870; }
:root[data-theme="dark"] .chip.hoch { background: #173323; color: #7fd69a; }
:root[data-theme="dark"] .chip.niedrig, :root[data-theme="dark"] .diff .alt { background: #43201d; color: #f0a39d; }
:root[data-theme="dark"] .diff .neu, :root[data-theme="dark"] .korrigiert ins { background: #1b3d28; color: #bfe9cc; }
:root[data-theme="dark"] .korrigiert { background: #17261d; }
:root[data-theme="dark"] .korrigiert.bearbeitet { background: #1d2a3f; }
:root[data-theme="dark"] .zeilen-eingabe, :root[data-theme="dark"] #zv-feld { background: #14161a; color: var(--text); }
:root[data-theme="dark"] .kontext mark { background: #5a4a10; color: #fff3c4; box-shadow: 0 0 0 1px #8a7420; }
:root[data-theme="dark"] .kontext mark.neu-wort { background: #1b4a2c; box-shadow: 0 0 0 1px #3f8a5c; }
:root[data-theme="dark"] .chip.richter { background: #2d2347; color: #cdbbf5; border-color: #55457f; }
:root[data-theme="dark"] .richter-titel { color: #cdbbf5; }
:root[data-theme="dark"] .chip.kontext { background: #173542; color: #8fd0e8; }
:root[data-theme="dark"] .zeile.befund > :nth-child(2) { background: #3a3114; }
:root[data-theme="dark"] .zeile.befund-richter > :nth-child(2) { background: #43201d; }
:root[data-theme="dark"] .zeile > [data-befund]::after { color: #f0d9a0; background: #5a4a1d; }
:root[data-theme="dark"] .zeile.befund-richter > [data-befund]::after { color: #ffd0cb; background: #6b2a25; }
:root[data-theme="dark"] .text .f-blau, :root[data-theme="dark"] #zv-feld .f-blau { color: #7fb0f0; }
:root[data-theme="dark"] .text .f-gruen, :root[data-theme="dark"] #zv-feld .f-gruen { color: #6fcf8d; }
:root[data-theme="dark"] .text .f-gold, :root[data-theme="dark"] #zv-feld .f-gold { color: #e0b840; }
:root[data-theme="dark"] .speicher-status.ok { color: #6fcf8d; }
:root[data-theme="dark"] .frei-feld, :root[data-theme="dark"] .fz-eingabe { background-color: #14161a; color: var(--text); }
:root[data-theme="dark"] .zeilenansicht { box-shadow: 0 18px 60px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .12); }
.thema-knopf { font-size: 16px; line-height: 1; padding: 6px 10px; }
.text.frei-text > button.klein { align-self: flex-start; margin: 0 0 8px; }
/* Wien A: Zeilennummern, Korrekturknöpfe */
body.frei #txt-knopf { display: none; }
.frei-box { flex: 1; min-height: 0; display: flex; border: 1px solid var(--linie); border-radius: 8px; overflow: hidden; background: var(--flaeche); }
.frei-box .frei-feld { border: 0; border-radius: 0; flex: 1; min-width: 0; height: auto; outline: none; }
.frei-box:focus-within { outline: 2px solid var(--akzent); }
.frei-nr { flex: none; overflow: hidden; padding: 12px 8px 40px; text-align: right; font: inherit; line-height: 1.6; color: var(--gedaempft); background: var(--bg); border-right: 1px solid var(--linie); user-select: none; font-variant-numeric: tabular-nums; }
.frei-nr .aktiv { color: var(--akzent); font-weight: 700; }
.frei-nr .ueber { color: var(--rot); }
.frei-korrektur { display: flex; flex-wrap: wrap; gap: 4px 16px; padding-left: 12px; }
button.link { border: 0; background: none; padding: 0; font-size: 12.5px; color: var(--gedaempft); text-decoration: underline; cursor: pointer; }
button.link:hover { color: var(--akzent); }
/* Wien A: dünne graue Trennlinie unter jeder Zeile (Textfeld und Nummernspalte); Zeilenhöhe 1,6 em wie im Textfeld */
.frei-box .frei-feld { background-image: linear-gradient(to bottom, transparent calc(100% - 1px), var(--linie) calc(100% - 1px)); background-size: 100% 1.6em; background-position: 0 12px; background-repeat: repeat-y; background-attachment: local; }
.frei-nr > div { height: 1.6em; border-bottom: 1px solid var(--linie); }
:root[data-theme="dark"] .frei-box .frei-feld { background-color: #14161a; }
/* Wien A: Fenster stabil (feste Höhe von Bühne und Eingabefeld, nichts springt beim Zeilenwechsel) */
.frei-buehne { align-items: center; }
.frei-fenster .fz-eingabe { height: 92px; overflow: hidden; }
/* Wien A: Textfeld nutzt die Fläche aus (kleine Ränder, etwas größere Schrift) */
body.frei .text.frei-text { padding: 8px 8px 8px; font-size: 22px; }
body.frei .text-kopf { padding-left: 10px; padding-right: 10px; }
body.frei .frei-hinweis { margin: 0 0 6px 2px; }
body.frei .frei-box { margin: 0; }
.zeilenansicht.frei-fenster { width: min(1200px, 94vw); }
.frei-fenster .zv-kopf { height: 46px; box-sizing: border-box; }
.frei-fenster .zv-eingabe { height: 170px; box-sizing: border-box; overflow: hidden; }
.zeilenansicht.frei-fenster { min-height: 0; }
.zeilenansicht.frei-fenster { width: min(1440px, 96vw); left: 2vw; }
.frei-fenster .zv-eingabe { height: 186px; }
.frei-fenster .fz-eingabe { height: 108px; }
/* Wien A: Prüfung, Auszeichnungen und Richtlinien wie bei den anderen Handschriften */
body.frei #reiter-pruef, body.frei #werkzeug-leiste, body.frei #richtlinien-knopf { display: revert; }
body.frei #werkzeug-leiste[hidden] { display: none; }
body.frei .werkzeug-leiste { padding: 6px 10px 2px; }
.frei-fenster .zv-eingabe { height: 226px; }
.frei-labelzeile { display: flex; justify-content: space-between; gap: 12px; font-size: 12.5px; color: var(--gedaempft); padding-left: 12px; }
.frei-auff { color: var(--rot); }
.frei-fenster .zeilen-vorschau { height: 34px; margin: 0; padding: 0 12px; overflow: hidden; white-space: nowrap; font: 21px/34px "EB Garamond", Georgia, serif; }
.frei-nr .auff::before { content: "●"; color: #e0a800; font-size: .45em; margin-right: 5px; vertical-align: middle; }

/* ---- Wien A: Zeilenliste (Klick = Code, sonst Farben und Zeichen für die Auszeichnungen) ---- */
.frei-liste { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; border: 1px solid var(--linie); border-radius: 8px; background: var(--flaeche); padding: 2px 6px; }
.frei-liste .zeile { margin: 0; align-items: center; border-bottom: 1px solid var(--linie); border-radius: 0; padding: 2px 4px; grid-template-columns: 2.6em 1fr 2.2em; }
.frei-liste .zeile:last-child { border-bottom: 0; }
.frei-liste .zeile > span:nth-child(2) { min-height: 1.55em; line-height: 1.55; }
.frei-liste .zeile.gewaehlt { background: var(--akzent-hell); box-shadow: inset 3px 0 0 var(--akzent); }
.frei-liste .zeile .nr { font: 12.5px/1.2 system-ui, sans-serif; padding-right: 10px; }
.frei-liste .zeile.auff .nr::before { content: "●"; color: #e0a800; font-size: .7em; margin-right: 4px; vertical-align: middle; }
.fz-auf { align-self: center; justify-self: center; width: 28px; height: 28px; padding: 0; display: grid; place-items: center; border: 0; background: transparent; color: var(--gedaempft); opacity: .35; border-radius: 6px; }
.frei-liste .zeile:hover .fz-auf, .frei-liste .zeile.gewaehlt .fz-auf, .fz-auf:focus-visible { opacity: 1; }
.fz-auf:hover { background: var(--akzent-hell); color: var(--akzent); border: 0; }
.frei-liste .zeilen-eingabe { font: 18px/1.4 ui-monospace, Consolas, monospace; }
:root[data-theme="dark"] .frei-liste .zeilen-eingabe { background: #14161a; }
/* Initialen und weitere Auszeichnungen in der normalen Ansicht */
.text .initial { font-weight: 700; font-size: 1.3em; line-height: 1; padding: 0 .18em; margin-right: .05em; border-radius: 4px; background: rgba(179, 38, 30, .12); color: var(--rot); }
.text .initial.blau { background: rgba(31, 78, 140, .14); color: #1f4e8c; }
.text .rotstrich { color: inherit; }
.text .rotunterstrichen { text-decoration: underline; text-decoration-color: var(--rot); text-decoration-thickness: 2px; }
.text .del { text-decoration: line-through; text-decoration-thickness: 2px; color: var(--gedaempft); }
.text .add { color: var(--akzent); }
.text .unclear { border-bottom: 2px dotted var(--gedaempft); }
.text .damage { background: rgba(224, 168, 0, .22); }
.text .luecke { color: var(--rot); font-weight: 600; }
.text .note { color: var(--akzent); }
.text sup { color: var(--akzent); }
:root[data-theme="dark"] .text .initial.blau { background: rgba(110, 160, 230, .2); color: #7fb0f0; }
:root[data-theme="dark"] .text .initial { background: rgba(239, 122, 114, .18); }
/* In der Zeilenansicht keine Auszeichnungen */
.frei-fenster .zeilen-vorschau { display: none; }
.frei-fenster .zv-eingabe { height: 176px; }

/* Wien D: keine Lupe in den Zeilen (Zeilenansicht per Doppelklick) */
body.ohne-lupe .zv-oeffnen { display: none; }
body.ohne-lupe .zeile { grid-template-columns: 2.4em 1fr; }

.frei-vers { margin: 0 0 4px; font-weight: 600; color: var(--akzent); font-size: 14px; }

/* Fehlende Zeile einzeichnen (Wien A) */
.frei-einz { position: fixed; inset: 0; z-index: 60; background: rgba(10, 14, 22, .6); display: grid; place-items: center; }
.frei-einz-kasten { background: var(--flaeche); color: var(--text); border-radius: 12px; padding: 12px 16px; max-width: 96vw; max-height: 96vh; display: flex; flex-direction: column; gap: 8px; }
.frei-einz-kopf { display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.frei-einz-kopf span { color: var(--gedaempft); font-size: 13px; }
.frei-einz-bild { position: relative; line-height: 0; overflow: hidden; align-self: center; }
.frei-einz-bild img { height: calc(96vh - 130px); width: auto; max-width: 90vw; display: block; user-select: none; }
.frei-einz-bild svg { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.frei-einz-bild polygon.bekannt { fill: rgba(31, 78, 140, .10); stroke: #1f4e8c; stroke-width: 1px; vector-effect: non-scaling-stroke; }
.frei-einz-bild rect.neu { fill: rgba(224, 168, 0, .30); stroke: #e0a800; stroke-width: 2px; vector-effect: non-scaling-stroke; }
.frei-einz-fuss { display: flex; justify-content: flex-end; gap: 12px; align-items: center; }

/* durchgehende Zeilennummern (bis vierstellig) */
.frei-liste .zeile { grid-template-columns: 3.6em 1fr; }

.frei-liste .zeile { grid-template-columns: 2.6em 1fr; }

.frei-entwurf { margin: 2px 0 6px; font-size: 0.9em; }
.frei-entwurf summary { cursor: pointer; }
.frei-entwurf-zeile { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin: 4px 0; }
.frei-entwurf-raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.2em, 1fr)); gap: 2px 6px; max-height: 9em; overflow-y: auto; border: 1px solid var(--muted, #888); padding: 4px 6px; margin: 4px 0; }
.frei-entwurf-blatt.aus { opacity: 0.45; }
.frei-entwurf-blatt { white-space: nowrap; }
.frei-entwurf-uebersicht { margin: 6px 0 0; font-weight: 600; }
.frei-entwurf-legende { margin: 2px 0 4px; color: var(--muted, #666); font-size: 0.9em; }
.frei-entwurf-info { color: var(--muted, #666); }


/* Handschriften ohne Transkription: nur Bild und Hinweis */
body.nur-bilder #reiter-pruef, body.nur-bilder #werkzeug-leiste, body.nur-bilder #richtlinien-knopf,
body.nur-bilder label.schalter, body.nur-bilder #txt-knopf { display: none; }
.nur-bilder-hinweis { margin: 16px; color: var(--muted, #666); }

/* Reiter „Automatisch“ (Wien A): Entwürfe für mehrere Blätter im Hintergrund */
.automatik .frei-entwurf { font-size: 1em; }
.automatik .frei-entwurf > summary { pointer-events: none; list-style: none; font-weight: 600; margin-bottom: 6px; }
.automatik .frei-entwurf > summary::-webkit-details-marker { display: none; }
.automatik .frei-entwurf-raster { max-height: 40vh; }
.automatik .frei-entwurf-info { display: block; margin-top: 8px; }
