/* Formsache – Gestaltung für alle Seiten
   ======================================
   Farben, Schriften und Abstände stehen als Variablen ganz oben. Wer etwas ändern will, ändert
   es dort einmal, und es gilt überall. Im dunklen Design werden nur diese Variablen
   ausgetauscht.

   Grundsätze (eigene Festlegungen zur Gestaltung, keine APA-Vorgaben):
   - Eine Schmuckfarbe: gedecktes Marineblau (--akzent) für Marke, Überschrift, aktive Seite
     und Hauptknopf. Sonst steht Farbe nur dort, wo sie etwas bedeutet: Fehler, Warnung,
     in Ordnung, und Blau für Links.
   - Was später im Manuskript steht, erscheint als weißes Blatt in Times New Roman
     (--blatt), auch im dunklen Modus. Alles andere ist Werkzeug.
   - Ein Abstandsmaß (--abstand) zwischen Flächen, ein Maß für Innenränder (--innen). */

:root {
  /* Palette „Research Lab / Academic Journal“ (Skill ui-ux-pro-max): Marineblau, kühles Grau,
     Blau für Links, etwas Gold. Die Kopfleiste ist die eine Farbfläche der Seite. Eigene Festlegung, keine APA-Vorgabe. */
  --grund: #f5f7fa;      /* Seitenhintergrund */
  --flaeche: #ffffff;    /* Karten, Felder */
  --erhaben: #e9eef5;    /* Schalter, Hover, aktive Seite */
  --linie: #dbe2ec;      /* Kanten von Karten */
  --regel: #e9eef4;      /* Trennlinien innerhalb von Karten */
  --rahmen: #c3cdda;     /* Kanten von Eingabefeldern und Knöpfen */
  --tinte: #0f172a;
  --grau: #475569;       /* Nebentext, mindestens 4.5:1 auf Weiß und auf --grund */
  --akzent: #1c477f;     /* gedecktes Blau: Überschrift, aktive Reiter, Namen der Werkzeuge */
  --haupt: #1c477f;      /* gefüllter Hauptknopf */
  --kopf: #1c477f;       /* Kopfleiste */
  --kopf-tinte: #ffffff;
  --kopf-grau: #cfdcee;  /* nicht gewählte Einträge in der Kopfleiste */
  --haupt-tinte: #ffffff;
  --link: #2156c9;
  --gold: #e6bb5c;       /* nur im Zeichen der Marke */

  --ok: #247b50;        --ok-bg: #dcf5e6;      --ok-tinte: #0b3d24;
  --warn: #92400e;      --warn-bg: #fdf1d3;    --warn-tinte: #6b2f08;   --warn-rand: #ecd08a;
  --fehler: #c4242a;    --fehler-bg: #fde8e6;  --fehler-tinte: #831c1e;
  --hinweis-bg: #e4ebf5;

  /* Das Blatt: immer weiß mit schwarzer Schrift, wie eine Manuskriptseite */
  --blatt: #ffffff;
  --blatt-tinte: #000000;

  /* Systemschriften: Es wird nichts von fremden Servern geladen. */
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --manuskript: "Times New Roman", Times, serif;

  --radius: 12px;        /* Karten */
  --radius-klein: 6px;   /* Felder, Knöpfe */
  --abstand: 12px;
  --innen: 20px;
  --feldhoehe: 36px;
  --breite: 1120px;
  --schatten: 0 1px 2px rgb(15 23 42 / 0.05);
  --schatten-hoch: 0 10px 28px rgb(15 23 42 / 0.12);
  color-scheme: only light;
}

/* Dunkles Design. js/thema.js setzt data-thema am <html>-Element (Wahl des Nutzers, sonst die
   Einstellung des Systems). Eigene Farben statt umgekehrter heller: tiefer blaugrauer Grund,
   deutlich hellere Flächen, fast weiße Schrift. Jedes Paar aus Schrift und Fläche ist auf
   mindestens 4.5:1 geprüft, Fließtext liegt über 7:1.
   "only dark"/"only light" sagt dem Browser, dass er die Farben nicht selbst umrechnen soll
   (Opera und Chrome können Seiten sonst zwangsweise abdunkeln und zerstören dabei Kontraste). */
:root[data-thema="dunkel"] {
  --grund: #0e1626;
  --flaeche: #1b2740;
  --erhaben: #2b3a5a;
  --linie: #3b4b6e;
  --regel: #2e3d5c;
  --rahmen: #7d8fb3;
  --tinte: #f5f8fc;
  --grau: #c9d3e3;
  --akzent: #b9d4fb;
  --haupt: #b9d4fb;
  --haupt-tinte: #0d1b33;
  --kopf: #17335f;
  --kopf-grau: #cbd9ee;
  --link: #b9d4fb;

  --ok: #74e2ad;      --ok-bg: #174330;      --ok-tinte: #c9f5de;
  --warn: #f4cc70;    --warn-bg: #4d3c0e;    --warn-tinte: #fde7ae;   --warn-rand: #8a6f1f;
  --fehler: #ffa0a8;  --fehler-bg: #5c222c;  --fehler-tinte: #ffd6da;
  --hinweis-bg: #37476a;

  --schatten: 0 1px 2px rgb(0 0 0 / 0.3);
  --schatten-hoch: 0 10px 28px rgb(0 0 0 / 0.45);
  color-scheme: only dark;
}

* { box-sizing: border-box; }

/* "hidden" muss gewinnen, auch wenn ein Element sonst display: flex hat */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--grund);
  color: var(--tinte);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--link); text-underline-offset: 2px; }
h1, h2, h3 { font-weight: 600; line-height: 1.25; }
h1 { font-size: 26px; letter-spacing: -0.015em; margin: 0 0 6px; text-wrap: balance; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }

/* Weiche Übergänge beim Überfahren; wer Bewegung reduziert hat, bekommt keine */
a, button, .knopf, .knopf-leise {
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- Seitenkopf ---------- */

.kopf { background: var(--kopf); color: var(--kopf-tinte); }
.kopf :focus-visible { outline-color: var(--kopf-tinte); }
.kopf-innen {
  max-width: var(--breite);
  margin: 0 auto;
  padding: 0 24px;
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 8px 28px;
}
.marke {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--kopf-tinte);
  text-decoration: none;
  white-space: nowrap;
}
.marke svg { flex: none; }
.marke .zeichen-oben { stroke: var(--gold); }

.hauptnav { display: flex; gap: 4px; flex: 1; min-width: 0; }
.hauptnav a {
  padding: 6px 10px;
  border-radius: var(--radius-klein);
  color: var(--kopf-grau);
  text-decoration: none;
  white-space: nowrap;
}
.hauptnav a:hover { color: var(--kopf-tinte); background: rgb(255 255 255 / 0.1); }
.hauptnav a[aria-current="page"] { color: var(--kopf-tinte); background: rgb(255 255 255 / 0.16); font-weight: 600; }
/* „Arbeit prüfen“ fasst die übrigen Werkzeuge zusammen: steht vorn, durch eine feine Linie getrennt */
.hauptnav .nav-pruefen { position: relative; margin-right: 13px; color: var(--kopf-tinte); }
.hauptnav .nav-pruefen::after {
  content: "";
  position: absolute;
  right: -9px;
  top: 7px;
  bottom: 7px;
  width: 1px;
  background: rgb(255 255 255 / 0.28);
}
.nav-kurz { display: none; }

.variante { display: flex; align-items: center; gap: 8px; font-size: 13px; white-space: nowrap; }
.variante-label { color: var(--kopf-grau); }
/* Sprachschalter in der Kopfleiste: helle Schrift, gewählte Sprache als weiße Fläche */
.kopf .schalter { background: rgb(255 255 255 / 0.14); }
.kopf .schalter button { color: #e8effa; }
.kopf .schalter button:hover { color: var(--kopf-tinte); }
.kopf .schalter button[aria-pressed="true"] { background: #ffffff; color: #1c477f; }
.schalter {
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius-klein);
  background: var(--erhaben);
}
.schalter button {
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--grau);
  font: inherit;
  padding: 4px 10px;
  cursor: pointer;
}
.schalter button:hover { color: var(--tinte); }
.schalter button[aria-pressed="true"] {
  background: var(--flaeche);
  color: var(--akzent);
  font-weight: 600;
}

/* Umschalter helles/dunkles Design: Mond im hellen, Sonne im dunklen Design */
.thema-knopf {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: none;
  margin-left: -16px;
  border: 0;
  border-radius: var(--radius-klein);
  background: transparent;
  color: var(--kopf-grau);
  cursor: pointer;
}
.thema-knopf:hover { color: var(--kopf-tinte); background: rgb(255 255 255 / 0.12); }
.thema-knopf .bei-dunkel, :root[data-thema="dunkel"] .thema-knopf .bei-hell { display: none; }
:root[data-thema="dunkel"] .thema-knopf .bei-dunkel { display: block; }

/* Band unter der Kopfleiste: Titel und ein Satz zur Seite, in derselben Farbe wie der Kopf */
.band { background: var(--kopf); color: var(--kopf-tinte); border-top: 1px solid rgb(255 255 255 / 0.12); }
.band-innen { max-width: var(--breite); margin: 0 auto; padding: 24px 24px 28px; }
.band .lead { color: var(--kopf-grau); margin: 0; }
.band a { color: inherit; }
.band :focus-visible { outline-color: var(--kopf-tinte); }
@media (max-width: 860px) { .band-innen { padding: 20px 16px 22px; } }

/* Schmale Bildschirme: Werkzeuge in einer eigenen Zeile, die sich seitlich schieben lässt */
@media (max-width: 860px) {
  .kopf-innen { flex-wrap: wrap; justify-content: space-between; gap: 8px; padding: 8px 16px 0; }
  .variante { margin-left: auto; }
  .thema-knopf { margin-left: 0; }
  .hauptnav { order: 3; flex: 0 0 calc(100% + 32px); margin: 0 -16px; padding: 4px 12px 8px; overflow-x: auto; }
  .hauptnav a { padding: 8px 10px; }
}
@media (max-width: 480px) {
  /* Sechs Werkzeuge passen nicht in eine Zeile: Raster mit drei Spalten, alle sichtbar.
     „Arbeit prüfen“ heißt hier „Prüfen“ und steht oben links. */
  .hauptnav { display: grid; grid-template-columns: repeat(3, auto); justify-content: space-between; gap: 0; padding: 2px 12px 8px; overflow: visible; }
  .hauptnav a { padding: 7px 4px; }
  .hauptnav .nav-pruefen { margin-right: 0; }
  .hauptnav .nav-pruefen::after { display: none; }
  .hauptnav a[aria-current="page"] { background: none; text-decoration: underline; text-underline-offset: 6px; text-decoration-thickness: 2px; }
  .hauptnav a:hover { background: none; }
  .nav-lang { display: none; }
  .nav-kurz { display: inline; }
}
@media (max-width: 420px) {
  /* Die Beschriftung bleibt für Bildschirmleser erhalten */
  .variante-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
}

/* ---------- Allgemeiner Inhalt ---------- */

main {
  max-width: var(--breite);
  margin: 0 auto;
  padding: 24px 24px 56px;
}
/* Einleitungen und Hilfetexte ohne eigene Höchstbreite: Sie nutzen die Breite der Seite bzw. Karte
   und brechen nicht um, solange sie in eine Zeile passen (Wunsch des Nutzers, 15.11.2026). */
.lead { font-size: 15px; color: var(--grau); margin: 0 0 24px; }

.fuss {
  max-width: var(--breite);
  margin: 0 auto;
  padding: 16px 24px 40px;
  color: var(--grau);
  font-size: 12px;
  border-top: 1px solid var(--linie);
}
@media (max-width: 860px) {
  main { padding: 24px 16px 48px; }
  .fuss { padding: 16px 16px 32px; }
}

/* ---------- Flächen ----------
   Karte: weiße Fläche mit feiner Kante. Dieselbe Form für Eingabeblöcke (fieldset), Ergebnis,
   Prüfbereiche und die Tafel der Startseite. */

.karte, form fieldset, .ergebnis, .r-treffer, .kachel, .datenschutz {
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
}
.karte { margin-top: var(--abstand); padding: 16px var(--innen) var(--innen); }
.karte h2, .ergebnis h2 { font-size: 16px; margin: 0 0 12px; }
/* Überschrift mit Zähl-Marken: Bricht die Zeile um, stehen die Marken bündig darunter */
.karte h2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; }
.karte h3, .ergebnis h3 { font-size: 13px; font-weight: 500; color: var(--grau); margin: 20px 0 8px; }
.legende-hilfe { font-weight: 400; font-size: 13px; color: var(--grau); }

/* ---------- Startseite ----------
   Oben die Hauptkachel „Arbeit prüfen“: Sie fasst die anderen Werkzeuge zusammen und ragt in
   das blaue Band hinein. Man kann dort direkt eine Datei wählen oder ablegen. Darunter die
   einzelnen Werkzeuge als Kacheln im Raster (oben drei, unten zwei breite). Jede zeigt ein
   Stück Blatt mit dem, was das Werkzeug liefert, darunter Name und Stichworte. */

.band-start .band-innen { padding-top: 36px; padding-bottom: 104px; }
.band-start h1 { font-size: 30px; }
.einstieg { padding-top: 0; }

.pruef-kachel {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  margin-top: -76px;
  overflow: hidden;
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: 16px;
  box-shadow: var(--schatten);
  transition: border-color 0.15s ease;
}
/* Datei wird darübergezogen */
.pruef-kachel.ziehen { border-color: var(--akzent); outline: 2px dashed var(--akzent); outline-offset: -8px; }
.pruef-text { display: flex; flex-direction: column; justify-content: center; padding: 30px 32px; }
.pruef-text h2 { font-size: 26px; letter-spacing: -0.01em; margin: 0 0 8px; color: var(--akzent); }
.pruef-text h2 a { color: inherit; text-decoration: none; }
.pruef-text h2 a:hover { text-decoration: underline; text-underline-offset: 5px; text-decoration-thickness: 2px; }
.pruef-lead { font-size: 15px; color: var(--grau); margin: 0 0 20px; }
.pruef-knoepfe { display: flex; flex-wrap: wrap; gap: 8px; }
.knopf-gross { min-height: 42px; padding: 8px 18px; font-size: 15px; text-decoration: none; }
.pruef-hilfe { font-size: 13px; color: var(--grau); margin: 14px 0 0; }
.pruef-text .import-meldung { margin: 12px 0 0; }

/* Bild: ein Blatt mit Markierungen, davor der Prüfbericht als kleine Karte */
.pruef-bild {
  position: relative;
  min-height: 270px;
  overflow: hidden;
  background: var(--erhaben);
  border-left: 1px solid var(--linie);
}
.pruef-bild .blatt { left: 32px; top: 30px; bottom: -24px; min-height: 0; font-size: 15px; padding: 20px 48px 20px 22px; }
.bericht-vorschau {
  position: absolute;
  right: 28px;
  bottom: 18px;
  width: 240px;
  padding: 12px 14px 14px;
  font-size: 13px;
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: 10px;
  /* schwebt als kleine Karte über dem Blatt; der Schatten bleibt leicht */
  box-shadow: 0 4px 12px rgb(15 23 42 / 0.08);
}
.bericht-titel { font-weight: 600; margin: 0 0 8px; }
.bericht-vorschau ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.bericht-vorschau li { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--grau); }

.abschnitt-titel { font-size: 15px; font-weight: 600; color: var(--grau); margin: 32px 0 12px; }

@media (max-width: 760px) {
  .pruef-kachel { grid-template-columns: minmax(0, 1fr); }
  .pruef-text { padding: 22px 20px 24px; }
  .pruef-text h2 { font-size: 23px; }
  .pruef-bild { min-height: 220px; border-left: 0; border-top: 1px solid var(--linie); }
  .pruef-bild .blatt { left: 20px; top: 20px; font-size: 14px; padding: 16px 40px 16px 18px; }
  .bericht-vorschau { right: 16px; bottom: 16px; width: 220px; }
}
/* Auf dem Handy nur Text und Knöpfe: Das Bild würde sich selbst verdecken */
@media (max-width: 600px) { .pruef-bild { display: none; } }
/* Ohne Maus (Touch) gibt es kein Ziehen und Ablegen */
@media (hover: none) { .nur-maus { display: none; } }

.kacheln {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 16px;
}
.kacheln li { grid-column: span 2; display: flex; }
.kacheln li.breit { grid-column: span 3; }
.kachel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  border-radius: 16px;
  color: inherit;
  text-decoration: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.kachel:hover, .kachel:focus-visible { border-color: var(--akzent); box-shadow: var(--schatten-hoch); transform: translateY(-3px); }
.kachel:active { transform: translateY(-1px); }

/* Das Bild: ein Blatt, das unten und rechts aus der Kachel läuft */
.kachel-bild {
  position: relative;
  height: 168px;
  overflow: hidden;
  background: var(--erhaben);
  border-bottom: 1px solid var(--linie);
}
.blatt {
  /* Auf dem Blatt gelten immer die hellen Farben, auch im dunklen Design */
  --ok-bg: #dcf5e6;     --ok-tinte: #0b3d24;
  --warn-bg: #fdf1d3;   --warn-tinte: #6b2f08;
  --fehler-bg: #fde8e6; --fehler-tinte: #831c1e;
  --hinweis-bg: #e4ebf5; --tinte: #0f172a;
  position: absolute;
  left: 24px;
  right: -28px;
  top: 22px;
  min-height: 200px;
  padding: 16px 44px 16px 18px;
  background: var(--blatt);
  color: var(--blatt-tinte);
  font-family: var(--manuskript);
  font-size: 13px;
  line-height: 1.45;
  border-radius: 6px 0 0 0;
  box-shadow: 0 2px 8px rgb(15 23 42 / 0.08);
  transition: transform 0.25s ease;
}
.kachel:hover .blatt { transform: translateY(-4px); }
.blatt p { margin: 0; }
.blatt-gross { font-size: 19px; }
.blatt-marke { margin-top: 12px !important; font-family: var(--sans); }
.blatt-tabelle { margin-top: 6px; border-collapse: collapse; border-top: 1px solid #000; border-bottom: 1px solid #000; }
.blatt-tabelle th, .blatt-tabelle td { padding: 2px 14px 2px 4px; font-weight: 400; text-align: left; white-space: nowrap; }
.blatt-tabelle th { border-bottom: 1px solid #000; }
.blatt-tabelle :is(th, td):not(:first-child) { text-align: right; font-variant-numeric: tabular-nums; }
.blatt-grafik { display: block; width: 100%; max-width: 250px; height: auto; margin-top: 6px; }
.blatt-angabe { padding-left: 2em; text-indent: -2em; margin-bottom: 6px !important; }
.blatt-absatz { line-height: 1.75; }
.blatt-titelseite { text-align: center; padding-top: 38px; line-height: 1.7; }
.blatt-seitenzahl { position: absolute; top: 12px; right: 48px; }

.kachel-text { padding: 14px 18px 16px; }
.kachel-text h2 { font-size: 17px; margin: 0 0 2px; color: var(--akzent); }
.kachel-text p { margin: 0; font-size: 13px; color: var(--grau); }
/* Beim Überfahren wird der Name unterstrichen: Die ganze Kachel ist der Link */
.kachel:hover .kachel-text h2 { text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1.5px; }

@media (max-width: 900px) {
  .kacheln li, .kacheln li.breit { grid-column: span 3; }
  .kacheln li:nth-child(3) { grid-column: span 6; }
}
@media (max-width: 600px) {
  .band-start .band-innen { padding-top: 24px; padding-bottom: 92px; }
  .band-start h1 { font-size: 26px; }
  .kacheln { gap: 12px; }
  .kacheln li, .kacheln li.breit, .kacheln li:nth-child(3) { grid-column: span 6; }
  .kachel-bild { height: 148px; }
}

.datenschutz {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 16px 0 0;
  padding: 14px 18px;
  color: var(--grau);
}
.datenschutz svg { flex: none; margin-top: 1px; color: var(--akzent); }
.datenschutz strong { color: var(--tinte); }

/* ---------- Eingabe: Felder und Knöpfe (alle Seiten) ---------- */

.modul-raster {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
  gap: var(--abstand);
  align-items: start;
}
.raster-breit { grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); }
@media (max-width: 900px) {
  .modul-raster, .raster-breit { grid-template-columns: minmax(0, 1fr); }
}

form fieldset {
  padding: 16px var(--innen) var(--innen);
  margin: 0 0 var(--abstand);
  min-width: 0;
}
/* Die Beschriftung steht in der Karte, nicht auf ihrer Kante */
form legend {
  float: left;
  width: 100%;
  padding: 0;
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
}
form legend + * { clear: both; }

.felder {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px 16px;
}
.felder.breit { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.feld { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.feld label { font-size: 13px; font-weight: 500; }
.feld .hilfe { font-size: 12px; color: var(--grau); }
.feld.lang { grid-column: span 2; }
.feld.lang-voll { grid-column: 1 / -1; }
@media (max-width: 420px) { .feld.lang { grid-column: auto; } }
.feld-hilfe { font-size: 13px; color: var(--grau); margin: 10px 0 0; }

input:not([type="checkbox"]):not([type="file"]), select, textarea {
  font: inherit;
  color: var(--tinte);
  background: var(--flaeche);
  border: 1px solid var(--rahmen);
  border-radius: var(--radius-klein);
}
input:not([type="checkbox"]):not([type="file"]), select {
  min-height: var(--feldhoehe);
  padding: 6px 10px;
  font-variant-numeric: tabular-nums;
}
.feld input, .feld select { width: 100%; }
textarea { display: block; width: 100%; padding: 10px 12px; line-height: 1.5; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--grau); opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: var(--grau); }
input:focus, select:focus, textarea:focus { border-color: var(--link); }
.feld input[aria-invalid="true"] { border-color: var(--fehler); background: var(--fehler-bg); }
input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--haupt); }
/* Auf dem Handy mindestens 16 px: Sonst vergrößert iOS die Seite beim Antippen eines Feldes */
@media (max-width: 760px) {
  input:not([type="checkbox"]):not([type="file"]), select, textarea, .daten-eingabe { font-size: 16px; }
  /* und größere Tippflächen */
  :root { --feldhoehe: 42px; }
  .knopf, .knopf-leise { min-height: 40px; }
}

/* Tabellen und R-Output: Spalten bleiben mit Tabulatoren untereinander */
.daten-eingabe { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13px; tab-size: 12; }
.daten-eingabe.kurz, #ta-anmerkung, #einfuegen { font-family: inherit; font-size: inherit; }

/* Kästchen mit Text: Der Text darf umbrechen und kursive Symbole enthalten, das Kästchen
   bleibt links davor stehen */
.haken { display: block; position: relative; padding-left: 24px; margin-top: 12px; }
.haken input[type="checkbox"] { position: absolute; left: 0; top: 0.2em; }
.haken select { margin-left: 2px; }
/* Steht ein Auswahlfeld in der Zeile, rückt das Kästchen auf dessen Mitte */
.haken:has(select) input[type="checkbox"] { top: 0.6em; }

.formular-kopf { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-bottom: 8px; }
.formular-kopf.links { justify-content: flex-start; margin-top: 8px; }

.knopf, .knopf-leise {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 12px;
  border-radius: var(--radius-klein);
  font: inherit;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}
.knopf { border: 1px solid var(--haupt); background: var(--haupt); color: var(--haupt-tinte); }
.knopf:hover:not(:disabled) { filter: brightness(1.18); }
.knopf:active:not(:disabled), .knopf-leise:active:not(:disabled) { transform: translateY(1px); }
.knopf-leise { border: 1px solid var(--rahmen); background: var(--flaeche); color: var(--tinte); }
.knopf-leise:hover:not(:disabled) { background: var(--erhaben); }
/* Gesperrte Knöpfe bleiben lesbar */
.knopf:disabled { background: var(--erhaben); border-color: var(--erhaben); color: var(--grau); cursor: default; }
.knopf-leise:disabled { color: var(--grau); border-color: var(--linie); cursor: default; }

.kopierzeile { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.export-zeile { flex-wrap: wrap; }
.kopierzeile .knopf-leise[data-uebernehmen] { margin-left: auto; }
.kopiert { font-size: 13px; color: var(--ok); }

.abstand-oben { margin-top: 12px; }
.abstand-unten { margin-bottom: 12px; }

/* ---------- Ergebnis und Blatt ---------- */

.ergebnis { position: sticky; top: 16px; padding: 16px var(--innen) var(--innen); }
@media (max-width: 900px) { .ergebnis { position: static; } }

/* So steht die Angabe später im Manuskript: Times New Roman, schwarz auf weiß */
.apa-text, .tabelle-vorschau, .abbildung-vorschau {
  background: var(--blatt);
  color: var(--blatt-tinte);
  font-family: var(--manuskript);
  border: 1px solid var(--rahmen);
  border-radius: var(--radius-klein);
}
.apa-text {
  font-size: 17px;
  line-height: 1.6;
  padding: 12px 16px;
  min-height: 3em;
  overflow-wrap: anywhere;
}
.apa-text a { color: inherit; }
/* Noch nichts auszugeben: kein Blatt, nur ein Hinweis */
.apa-text.leer {
  background: transparent;
  color: var(--grau);
  border-style: dashed;
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
}
.apa-text.leer:empty { display: none; }
/* Solange es nichts zu kopieren gibt, stehen dort keine gesperrten Knöpfe */
.apa-text.leer + .kopierzeile, h3:has(+ .apa-text.leer:empty) { display: none; }

.tabelle-vorschau, .abbildung-vorschau { font-size: 15px; line-height: 1.45; padding: 20px; }
.tabelle-vorschau { overflow-x: auto; }
.tabelle-vorschau table { min-width: 60%; }
/* nur für die Vorschau: Zellen nicht umbrechen, lieber seitlich scrollen */
.tabelle-vorschau td, .tabelle-vorschau th { white-space: nowrap; }
.vorschau-leer { font-family: var(--sans); font-size: 13px; color: #5f5f5c; margin: 0; }
.abbildung-vorschau p { margin: 0; }
.abb-titel { margin-bottom: 8px !important; }
.abb-bild svg { display: block; width: 100%; height: auto; }
.abb-anmerkung { margin-top: 8px !important; }

.einstellung-zeile { font-size: 13px; color: var(--grau); margin: 16px 0 0; }
.einstellung-zeile select { min-height: 28px; padding: 2px 6px; margin: 0 2px; }

/* ---------- Meldungen, Marken, Befunde ----------
   Stufen überall gleich: fehler, warnung, hinweis, ok (siehe js/anzeige.js). */

/* Meldung: ein Punkt in der Farbe der Stufe, daneben der Text */
.meldungen { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.meldungen li { position: relative; padding-left: 16px; font-size: 13px; overflow-wrap: anywhere; }
.meldungen li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.5em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--rahmen);
}
.meldungen li.ok::before { background: var(--ok); }
.meldungen li.warnung::before { background: var(--warn); }
.meldungen li.fehler::before { background: var(--fehler); }
.meldungen li.hinweis::before { background: var(--grau); }
.meldungen li strong { display: block; font-weight: 600; }

/* Zähl-Marken: blasse Fläche, dunkle Schrift im selben Farbton */
.chip {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  line-height: 20px;
  padding: 0 8px;
  border-radius: 4px;
  background: var(--hinweis-bg);
  color: var(--tinte);
  white-space: nowrap;
}
.chip.fehler { background: var(--fehler-bg); color: var(--fehler-tinte); }
.chip.warnung { background: var(--warn-bg); color: var(--warn-tinte); }
.chip.ok { background: var(--ok-bg); color: var(--ok-tinte); }
.karten-chips { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.karten-chips:empty { display: none; }

.text-zusammenfassung {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
  font-size: 15px;
  font-weight: 600;
  margin: 24px 0 8px;
}
.karte .text-zusammenfassung { margin-top: 0; }
/* Übersicht des Prüfberichts: ein Feld je Bereich, Klick springt zur Karte */
.bericht-uebersicht ul { list-style: none; margin: 4px 0 4px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 8px; }
.bericht-uebersicht a {
  display: flex;
  flex-direction: column;
  gap: 6px;
  height: 100%;
  padding: 10px 14px 12px;
  color: var(--tinte);
  text-decoration: none;
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: var(--radius-klein);
}
.bericht-uebersicht a:hover { border-color: var(--akzent); }
.bericht-uebersicht a:hover .uebersicht-name { text-decoration: underline; text-underline-offset: 3px; }
.uebersicht-name { font-weight: 600; font-size: 13px; }
#text-ergebnis .karte { scroll-margin-top: 16px; }
@media (max-width: 600px) {
  .bericht-uebersicht ul { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
  .bericht-uebersicht a { padding: 8px 10px 10px; }
}

/* Befund: die Stufe steht als Wort über der Erklärung, nicht als farbiger Rand */
.befunde { list-style: none; padding: 0; margin: 0; }
* + .befunde { margin-top: 14px; }
.befund { padding: 12px 0; border-top: 1px solid var(--regel); }
.befund:first-child { border-top: 0; padding-top: 0; }
.befund:last-child { padding-bottom: 0; }
.befund::before { display: block; font-size: 12px; font-weight: 600; margin-bottom: 2px; }
.befund.fehler::before { content: "Fehler"; color: var(--fehler); }
.befund.warnung::before { content: "Warnung"; color: var(--warn); }
.befund.hinweis::before { content: "Hinweis"; color: var(--grau); }
.befund.ok::before { content: "In Ordnung"; color: var(--ok); }
.befund-kopf { display: flex; gap: 8px; align-items: baseline; }
.befund-nr { font-weight: 600; text-decoration: none; min-width: 1.2em; color: var(--tinte); }
.befund-vorher { overflow-wrap: anywhere; }
.befund-nachher { font-family: var(--manuskript); font-size: 16px; margin: 4px 0 0; }
.befund .meldungen { margin-top: 8px; }

/* Fundstellen im Text des Nutzers */
.stellen { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 6px; font-size: 13px; color: var(--grau); }
.stellen li { overflow-wrap: anywhere; }
.befund-umgebung { overflow-wrap: anywhere; }
.stelle-detail { color: var(--grau); }
.stelle-nachher { font-family: var(--manuskript); font-size: 16px; color: var(--tinte); margin-top: 2px; }
mark { color: var(--tinte); border-radius: 3px; padding: 1px 2px; }
.stellen mark, .befund-umgebung mark, mark.befund-warnung { background: var(--warn-bg); }
.befund.fehler .befund-umgebung mark, mark.befund-fehler { background: var(--fehler-bg); }
mark.befund-ok { background: var(--ok-bg); }
mark.befund-hinweis { background: var(--hinweis-bg); }

.mehr-stellen { margin-top: 8px; font-size: 13px; }
.mehr-stellen summary { cursor: pointer; color: var(--link); width: fit-content; }
.gliederung { list-style: none; padding: 0; margin: 8px 0 0; }

/* Rückmeldung nach dem Laden einer Datei */
.import-meldung {
  font-size: 13px;
  margin: 0 0 12px;
  padding: 6px 10px;
  border-radius: var(--radius-klein);
  background: var(--ok-bg);
  color: var(--ok-tinte);
}
.import-meldung.fehler { background: var(--fehler-bg); color: var(--fehler-tinte); }

/* ---------- Statistik ---------- */

/* Eingabeweg wählen: zwei große Wahlflächen nebeneinander. Die gewählte hat einen blauen
   Rahmen und einen gefüllten Punkt (wie ein Optionsfeld). */
.modus-wahl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--abstand); }
.modus-wahl button {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 18px 14px 48px;
  text-align: left;
  font: inherit;
  color: var(--tinte);
  background: var(--flaeche);
  border: 1px solid var(--rahmen);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  cursor: pointer;
}
.modus-wahl button::before {
  content: "";
  position: absolute;
  left: 18px;
  top: 18px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--rahmen);
  background: var(--flaeche);
}
.modus-wahl button:hover { border-color: var(--akzent); }
.modus-wahl button[aria-pressed="true"] { border-color: var(--akzent); outline: 1px solid var(--akzent); background: var(--erhaben); }
.modus-wahl button[aria-pressed="true"]:focus-visible { outline: 2px solid var(--link); }
.modus-wahl button[aria-pressed="true"]::before { border-color: var(--akzent); background: var(--akzent); box-shadow: inset 0 0 0 3px var(--erhaben); }
.modus-titel { font-size: 16px; font-weight: 600; }
.modus-wahl button[aria-pressed="true"] .modus-titel { color: var(--akzent); }
.modus-text { font-size: 13px; color: var(--grau); }
@media (max-width: 600px) { .modus-wahl { grid-template-columns: minmax(0, 1fr); gap: 8px; } }

/* Verfahren: Reiter auf einer durchgehenden Linie */
.verfahren-wahl {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 1px solid var(--linie);
  margin: 16px 0 16px;
}
.verfahren-wahl button {
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  background: none;
  color: var(--grau);
  font: inherit;
  padding: 8px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.verfahren-wahl button:hover { color: var(--tinte); }
.verfahren-wahl button[aria-selected="true"] { color: var(--akzent); font-weight: 600; border-bottom-color: var(--akzent); }

#modus-text { margin-top: 20px; }
.einfuegen-label { display: block; font-weight: 600; margin-bottom: 8px; }

.text-raster {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: var(--abstand) 24px;
  align-items: start;
}
@media (max-width: 900px) { .text-raster { grid-template-columns: minmax(0, 1fr); } }
.text-raster h2 { font-size: 14px; margin: 16px 0 8px; }

.text-markiert {
  padding: 12px 16px;
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: var(--radius-klein);
  line-height: 1.8;
  overflow-wrap: anywhere;
}
.text-markiert mark { scroll-margin-top: 80px; }
.text-markiert mark sup { font-size: 0.7em; font-weight: 700; margin-left: 2px; }

.r-liste { display: grid; gap: var(--abstand); grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); }
.r-treffer { padding: 16px var(--innen) var(--innen); }
.r-treffer h3 { font-size: 14px; margin: 0 0 10px; }
.r-treffer .meldungen { margin-top: 12px; }

/* ---------- Tabellen ---------- */

.spalten-optionen { display: grid; }
.spalten-zeile {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px 16px;
  padding: 8px 0;
  border-top: 1px solid var(--regel);
}
.spalten-zeile:first-child { border-top: 0; padding-top: 0; }
.spalten-zeile:last-child { padding-bottom: 0; }
.spalten-name { font-weight: 600; overflow-wrap: anywhere; }
@media (max-width: 480px) { .spalten-zeile { grid-template-columns: minmax(0, 1fr); } }
.spalten-zeile .haken { margin-top: 0; }
.spalten-zeile > label:not(.haken) { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.spalten-zeile .haken { white-space: nowrap; }
.spalten-zeile select { min-height: 30px; padding: 2px 6px; }

/* ---------- Literatur ---------- */

.lit-eingabe { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--abstand); margin-bottom: var(--abstand); }
@media (max-width: 900px) { .lit-eingabe { grid-template-columns: minmax(0, 1fr); } }
.lit-eingabe fieldset { margin: 0; }
/* Hängender Einzug wie im Manuskript: erste Zeile links, Folgezeilen eingerückt */
.lit-liste p { margin: 0 0 10px; padding-left: 2em; text-indent: -2em; }
.lit-liste p:last-child { margin-bottom: 0; }
.lit-roh { font-family: var(--manuskript); font-size: 16px; }
/* Zitierformen: die Zitate in der Schrift des Manuskripts, damit klar ist, was in den Text kommt */
.tabelle-rollen { overflow-x: auto; }
.zitier-tabelle { width: 100%; border-collapse: collapse; }
.zitier-tabelle th { font-size: 12px; font-weight: 600; color: var(--grau); text-align: left; padding: 0 12px 6px 0; border-bottom: 1px solid var(--linie); }
.zitier-tabelle td { font-family: var(--manuskript); font-size: 16px; padding: 6px 12px 6px 0; border-bottom: 1px solid var(--regel); white-space: nowrap; }
.zitier-tabelle tr:last-child td { border-bottom: 0; }
.zitier-tabelle tr.mehrdeutig td { background: var(--warn-bg); color: var(--warn-tinte); }
.tabelle-rollen + .meldungen { margin-top: 10px; }
/* Der eine Ort, an dem Daten den Rechner verlassen: deutlich, aber ohne Alarm */
.online-hinweis {
  padding: 10px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--warn-rand);
  border-radius: var(--radius-klein);
  background: var(--warn-bg);
  color: var(--warn-tinte);
}

/* ---------- Arbeit prüfen: Checkliste und Drucken ---------- */

.bericht-drucken { margin-left: auto; font-size: 13px; font-weight: 500; }
.checkliste { margin-top: 24px; }
.checkliste-raster { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 8px 32px; }
.checkliste-raster h3 { margin-top: 4px; }
.haken-liste { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.haken-liste .haken { margin-top: 6px; font-size: 13px; }
/* Erledigte Punkte treten zurück */
.haken-liste .haken:has(input:checked) { color: var(--grau); text-decoration: line-through; text-decoration-color: var(--rahmen); }
@media (max-width: 760px) { .checkliste-raster { grid-template-columns: minmax(0, 1fr); } }

/* Druck: nur der Bericht, hell, ohne Bedienelemente; Befunde nicht über Seitenwechsel zerreißen */
@media print {
  .kopf, .band, #text-form, #kopie-karte, .checkliste, .fuss, .bericht-drucken, .bericht-uebersicht { display: none !important; }
  body { background: #fff; font-size: 11pt; }
  main { padding: 0; max-width: none; }
  .karte { box-shadow: none; border: 0; padding: 0; margin-top: 18pt; }
  .karte h2 { break-after: avoid; }
  .befund { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}

/* ---------- Word-Vorlage ----------
   Die Titelseite als Blatt in echten Proportionen: Alle Maße hängen an der Blattbreite (cqw),
   js/vorlage-seite.js setzt Rand, Kopfzeilenabstand und Schriftgröße passend zum Papier. */

.vorschau-kopf { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 12px; }
.vorschau-kopf h2 { margin: 0 !important; }
.seiten-vorschau { padding: 18px; background: var(--erhaben); border-radius: var(--radius-klein); }
.seite {
  --rand: 12.095cqw;
  --kopf: 5.952cqw;
  --pt: 2.016cqw;
  position: relative;
  container-type: inline-size;
  width: 100%;
  max-width: 440px;
  margin: 0 auto;
  aspect-ratio: 210 / 297;
  background: var(--blatt);
  color: var(--blatt-tinte);
  font-family: var(--manuskript);
  box-shadow: 0 1px 3px rgb(15 23 42 / 0.12), 0 4px 14px rgb(15 23 42 / 0.08);
}
.seite-zahl { position: absolute; top: var(--kopf); right: var(--rand); font-size: var(--pt); line-height: 1; }
/* Doppelter Abstand in Word ist etwa das 2,3-Fache der Schriftgröße */
.seite-innen { position: absolute; inset: var(--rand); overflow: hidden; font-size: var(--pt); line-height: 2.3; text-align: center; overflow-wrap: anywhere; }
.seite-innen p { margin: 0; }
.aufbau { margin: 0; padding-left: 20px; display: grid; gap: 4px; font-size: 13px; }

/* Die fünf Überschriftenebenen: links die Regel, rechts so, wie es auf dem Blatt aussieht */
.ebenen { border: 1px solid var(--linie); border-radius: var(--radius-klein); overflow: hidden; }
.ebene-zeile { display: grid; grid-template-columns: minmax(0, 230px) minmax(0, 1fr); border-top: 1px solid var(--linie); }
.ebene-zeile:first-child { border-top: 0; }
.ebene-name { padding: 12px 14px; font-size: 13px; font-weight: 600; background: var(--erhaben); }
.ebene-name span { display: block; font-weight: 400; color: var(--grau); }
.ebene-blatt {
  display: flex;
  align-items: center;
  padding: 12px 22px;
  background: var(--blatt);
  color: var(--blatt-tinte);
  font-family: var(--vorlage-schrift, var(--manuskript));
  font-size: 16px;
  line-height: 1.5;
}
.ebene-blatt p { margin: 0; width: 100%; }
.ebene-blatt .e1 { text-align: center; }
.ebene-blatt .e4 { text-indent: 3em; }
#vo-ebenen-karte .ebenen { margin-bottom: 4px; }
@media (max-width: 600px) {
  .ebene-zeile { grid-template-columns: minmax(0, 1fr); }
  .ebene-name { padding: 8px 12px; }
}

/* ---------- Dateien wählen und ablegen ---------- */

.ablage.ziehen { border-color: var(--akzent); border-style: dashed; background: var(--erhaben); }
.datei-zeile { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 12px; }
.datei-zeile .feld-hilfe { margin: 0; flex: 1 1 240px; }
.datei-knopf:focus-within { outline: 2px solid var(--link); outline-offset: 2px; }
/* Für Bildschirmleser und Tastatur erreichbar, aber nicht sichtbar */
.unsichtbar { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
input.unsichtbar { min-height: 0; padding: 0; border: 0; }

/* ---------- Testseite ---------- */

.test-zusammenfassung { font-size: 16px; font-weight: 600; }
.test-zusammenfassung.ok { color: var(--ok); }
.test-zusammenfassung.fehler { color: var(--fehler); }
.test-liste { list-style: none; padding: 0; font-size: 13px; }
.test-liste li { padding: 4px 0; border-bottom: 1px solid var(--regel); }
.test-liste li.fehler { color: var(--fehler); }
.test-liste .gruppe { font-weight: 600; margin-top: 16px; border: 0; }
