/* ArchivBox — Weboberflaeche.
 *
 * Hell und dunkel sind gleichwertig: die Farben stehen als Variablen, der
 * Umschalter setzt nur ein Merkmal am Wurzelelement. Ohne eigene Wahl gilt
 * die Einstellung des Systems.
 *
 * Kein Baukasten von der Stange — diese paar hundert Zeilen sind
 * ueberschaubarer als eine Abhaengigkeit, die bei jeder Fassung neu bricht.
 */

:root {
    --grund: #f7f8fa;
    --flaeche: #ffffff;
    --rand: #e2e6ec;
    --rand-stark: #cbd2dc;
    --text: #12171e;
    --text-leise: #5b6675;
    --marke: #1b3a5c;
    --marke-hell: #2e5c8a;
    --siegel: #d9a13a;
    --gut: #1a7a4a;
    --warnung: #b4760a;
    --fehler: #b3261e;
    --schatten: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 12px rgba(16, 24, 40, .06);
    --schatten-hoch: 0 8px 28px rgba(16, 24, 40, .12);
    --rundung: 12px;
    --rundung-klein: 8px;
    --knopf-schrift: #ffffff;
}

:root[data-erscheinung="dunkel"] {
    --grund: #0f1319;
    --flaeche: #161b23;
    --rand: #2a323e;
    --rand-stark: #3a4552;
    --text: #e9edf3;
    --text-leise: #98a4b3;
    --marke: #7aa9dd;
    --marke-hell: #9cc2ec;
    --siegel: #e0a83b;
    --gut: #4fb37e;
    --warnung: #e0a83b;
    --fehler: #e0705f;
    --schatten: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
    --schatten-hoch: 0 10px 32px rgba(0, 0, 0, .45);
    --knopf-schrift: #0f1319;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-erscheinung="hell"]) {
        --grund: #0f1319;
        --flaeche: #161b23;
        --rand: #2a323e;
        --rand-stark: #3a4552;
        --text: #e9edf3;
        --text-leise: #98a4b3;
        --marke: #7aa9dd;
        --marke-hell: #9cc2ec;
        --siegel: #e0a83b;
        --gut: #4fb37e;
        --warnung: #e0a83b;
        --fehler: #e0705f;
        --schatten: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
        --schatten-hoch: 0 10px 32px rgba(0, 0, 0, .45);
        --knopf-schrift: #0f1319;
    }
}

* { box-sizing: border-box; }

/* `hidden` muss staerker sein als jede eigene Regel.
 *
 * Die Vorgabe des Browsers ist `display: none` mit der schwaechsten
 * Staerke, die es gibt — jede eigene Regel mit `display` schlaegt sie.
 * `button { display: inline-block }` genuegt, und ein Knopf, der
 * `hidden` traegt, steht trotzdem da. Genau das ist beim Vorlesen
 * passiert: der Stopp-Knopf war sichtbar, bevor etwas lief. */
[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--grund);
    color: var(--text);
    font: 15px/1.55 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--marke); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------- Kopfleiste */

header.kopf {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 0 22px;
    height: 62px;
    background: color-mix(in srgb, var(--flaeche) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--rand);
}

.marke { display: flex; align-items: center; gap: 10px; font-weight: 650; letter-spacing: -.01em; }
.marke svg { width: 26px; height: 26px; display: block; }
.marke .beiwort { font-weight: 400; font-size: 12.5px; color: var(--text-leise); }

.kopf-rechts { margin-left: auto; display: flex; align-items: center; gap: 10px; }

/* Die Wegleiste traegt beliebig viele Bereiche: sie schiebt sich zur Seite,
   statt umzubrechen und die Kopfzeile zu sprengen. Auf schmalen Geraeten
   wischt man sie durch — das ist dort die gewohnte Bewegung. */
nav.wegleiste {
    position: sticky;
    top: 62px;
    z-index: 19;
    background: color-mix(in srgb, var(--flaeche) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--rand);
}
nav.wegleiste .wege {
    display: flex;
    gap: 2px;
    max-width: 1180px;
    margin: 0 auto;
    padding: 6px 18px;
    overflow-x: auto;
    scrollbar-width: thin;
}
nav.wegleiste a {
    padding: 7px 13px;
    border-radius: var(--rundung-klein);
    color: var(--text-leise);
    font-weight: 500;
    white-space: nowrap;
}
nav.wegleiste a:hover { background: var(--grund); color: var(--text); text-decoration: none; }
nav.wegleiste a.hier {
    background: color-mix(in srgb, var(--marke) 14%, transparent);
    color: var(--marke);
}
/* Sichtbar auch fuer den, der mit der Tastatur geht. */
nav.wegleiste a:focus-visible { outline: 2px solid var(--marke); outline-offset: 1px; }

/* ------------------------------------------------------------ Grundgeruest */

main { max-width: 1180px; margin: 0 auto; padding: 26px 22px 60px; }

h1 { font-size: 25px; font-weight: 640; letter-spacing: -.02em; margin: 0 0 4px; }
h2 { font-size: 17px; font-weight: 600; margin: 30px 0 12px; }
.unterzeile { color: var(--text-leise); margin: 0 0 22px; }

/* ---------------------------------------------------------------- Kacheln */

.kacheln { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 14px; }

.kachel {
    background: var(--flaeche);
    border: 1px solid var(--rand);
    border-radius: var(--rundung);
    padding: 16px 18px;
    box-shadow: var(--schatten);
}
.kachel .wert { font-size: 30px; font-weight: 640; letter-spacing: -.03em; line-height: 1.1; }
.kachel .was { font-size: 12.5px; color: var(--text-leise); margin-top: 3px; }
.kachel.gut .wert { color: var(--gut); }
.kachel.warnung .wert { color: var(--warnung); }
.kachel.fehler .wert { color: var(--fehler); }

/* ----------------------------------------------------------------- Karten */

.karte {
    background: var(--flaeche);
    border: 1px solid var(--rand);
    border-radius: var(--rundung);
    padding: 18px 20px;
    box-shadow: var(--schatten);
}
.karte + .karte { margin-top: 12px; }
.karte.eng { padding: 0; overflow: hidden; }
.karte.eng table { margin: 0; }
.karte.eng thead th { padding-top: 14px; }

/* --------------------------------------------------------------- Hinweise */

.hinweis {
    display: flex;
    gap: 11px;
    align-items: flex-start;
    padding: 13px 16px;
    border-radius: var(--rundung);
    border: 1px solid;
    margin: 16px 0;
    line-height: 1.5;
}
.hinweis .lampe { flex: 0 0 auto; margin-top: 4px; }
.hinweis.gut { background: color-mix(in srgb, var(--gut) 10%, transparent); border-color: color-mix(in srgb, var(--gut) 35%, transparent); }
.hinweis.warnung { background: color-mix(in srgb, var(--warnung) 12%, transparent); border-color: color-mix(in srgb, var(--warnung) 40%, transparent); }
.hinweis.fehler { background: color-mix(in srgb, var(--fehler) 10%, transparent); border-color: color-mix(in srgb, var(--fehler) 38%, transparent); }
.hinweis.leise { background: var(--flaeche); border-color: var(--rand); color: var(--text-leise); }

/* Lampen werden gezeichnet, nicht geschrieben — Zeichensaetze fehlen mal. */
.lampe { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.lampe.gut { background: var(--gut); }
.lampe.warnung { background: var(--warnung); border-radius: 2px; transform: rotate(45deg); }
.lampe.fehler { background: var(--fehler); border-radius: 2px; }
.lampe.leise { background: transparent; border: 2px solid var(--text-leise); }

/* --------------------------------------------------------------- Tabellen */

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
    text-align: left;
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-leise);
    padding: 0 14px 9px;
    border-bottom: 1px solid var(--rand);
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--rand); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--grund); }
td.zahl, th.zahl { text-align: right; font-variant-numeric: tabular-nums; }
td.leise { color: var(--text-leise); }
.einzeilig { white-space: nowrap; }

/* -------------------------------------------------------------- Bedienung */

button, .knopf {
    font: inherit;
    font-weight: 550;
    padding: 9px 16px;
    border-radius: var(--rundung-klein);
    border: 1px solid var(--rand-stark);
    background: var(--flaeche);
    color: var(--text);
    cursor: pointer;
    display: inline-block;
    transition: background .12s, border-color .12s;
}
button:hover, .knopf:hover { background: var(--grund); text-decoration: none; }
button.haupt, .knopf.haupt {
    background: var(--marke);
    border-color: var(--marke);
    color: var(--knopf-schrift);
}
button.haupt:hover, .knopf.haupt:hover { background: var(--marke-hell); border-color: var(--marke-hell); }
button.leise { border-color: transparent; background: transparent; color: var(--text-leise); padding: 7px 10px; }
button.leise:hover { background: var(--grund); color: var(--text); }

input[type=text], input[type=password], input[type=search], select, textarea {
    font: inherit;
    width: 100%;
    padding: 9px 12px;
    border-radius: var(--rundung-klein);
    border: 1px solid var(--rand-stark);
    background: var(--flaeche);
    color: var(--text);
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid color-mix(in srgb, var(--marke) 45%, transparent);
    outline-offset: 1px;
    border-color: var(--marke);
}
label { display: block; font-size: 12.5px; font-weight: 550; color: var(--text-leise); margin-bottom: 5px; }
.feld + .feld { margin-top: 13px; }

/* ------------------------------------------------------------------ Suche */

.suchzeile { display: flex; gap: 10px; align-items: center; }
.suchzeile input { flex: 1; }

.treffer { display: block; padding: 14px 16px; border-radius: var(--rundung); border: 1px solid var(--rand); background: var(--flaeche); color: inherit; }
.treffer + .treffer { margin-top: 9px; }
.treffer:hover { border-color: var(--marke); text-decoration: none; box-shadow: var(--schatten); }
.treffer .titel { font-weight: 600; }
.treffer .datei { font-size: 12.5px; color: var(--text-leise); margin-top: 1px; }
.treffer .fundstelle { font-size: 13px; margin-top: 7px; color: var(--text-leise); }
.treffer .fundstelle b { color: var(--text); background: color-mix(in srgb, var(--siegel) 32%, transparent); border-radius: 3px; padding: 0 3px; }

/* -------------------------------------------------------------- Kleinkram */

.marken { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 550; background: var(--grund); border: 1px solid var(--rand); color: var(--text-leise); }
.marken.gut { color: var(--gut); border-color: color-mix(in srgb, var(--gut) 35%, transparent); }
.marken.warnung { color: var(--warnung); border-color: color-mix(in srgb, var(--warnung) 40%, transparent); }
.marken.fehler { color: var(--fehler); border-color: color-mix(in srgb, var(--fehler) 40%, transparent); }

.pfad { font-family: ui-monospace, Cascadia Mono, Consolas, monospace; font-size: 12.5px; color: var(--text-leise); }
.reihe { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.abstand { margin-top: 18px; }
.leer { text-align: center; padding: 44px 20px; color: var(--text-leise); }

.anmelden { max-width: 400px; margin: 8vh auto; }
.anmelden .karte { padding: 26px; box-shadow: var(--schatten-hoch); }

/* ----------------------------------------------------- Bearbeitungsfelder */

/* Eine Zeile aus Beschriftung links und Eingabe rechts. Unter 720px klappt
   sie untereinander — auf dem Handy ist Nebeneinander unlesbar. */
/* Eine Filterleiste: so viele Felder nebeneinander, wie hineinpassen, und
   der Rest rutscht in die naechste Zeile. Ein festes Raster aus Beschriftung
   und Feld taugt dafuer nicht — es zwingt jedes Feld auf eine eigene Zeile
   und macht aus vier Filtern eine halbe Seite. */
.filter { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: flex-end; }
.filter .feld { margin: 0; }
.filter .feld + .feld { margin-top: 0; }
.filter label { display: block; color: var(--text-leise); font-size: 12.5px; margin-bottom: 4px; }
.filter label.kasten { display: flex; align-items: center; gap: 7px; margin: 0 0 9px; font-size: 14px; color: var(--text); }
.filter .weit { flex: 1 1 320px; min-width: 220px; }
.filter input[type="date"] { width: auto; }
.filter .knoepfe { display: flex; gap: 8px; margin-left: auto; }
.filterhilfe { color: var(--text-leise); font-size: 12.5px; margin: 10px 0 0; }

.feldzeile { display: grid; grid-template-columns: 140px 1fr; gap: 14px; align-items: start; padding: 12px 0; }
.feldzeile + .feldzeile { border-top: 1px solid var(--rand); }
.feldzeile > label { color: var(--text-leise); font-size: 13px; padding-top: 9px; }

/* Formulare, die in einer Zeile mitlaufen, statt sie zu sprengen. */
form.innen { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
form.innen input[type=text] { min-width: 260px; }
form.innen input[type=date] { min-width: 150px; }

.klein { font-size: 12.5px; margin: 6px 0 0; }

.liste { list-style: none; margin: 0 0 14px; padding: 0; }
.liste li { display: flex; gap: 12px; align-items: center; padding: 9px 0; }
.liste li + li { border-top: 1px solid var(--rand); }
.liste li a { flex: 1; }

/* Suchformular mit Filterleiste. */
.suchform { margin: 0; }
.filterleiste { margin-top: 10px; gap: 8px; }
.filterleiste select { padding: 7px 9px; }

/* Ungelesenes faellt auf, ohne zu schreien: kraeftigerer Titel und ein
   schmaler Balken links. Fett allein reicht nicht, wenn zwanzig Zeilen
   untereinander stehen. */
.treffer.ungelesen { border-left: 3px solid var(--marke); }
.treffer.ungelesen .titel { font-weight: 650; }

/* Zahl am Weg zum Eingang: was liegt, sieht man, ohne hinzugehen. */
.kopf nav .zaehler {
    display: inline-block; margin-left: 6px; padding: 1px 7px;
    border-radius: 999px; font-size: 11.5px; font-weight: 650;
    background: var(--marke); color: #fff; line-height: 1.5;
}

/* Die Glocke in der Kopfzeile. Sie steht auch dann da, wenn nichts anliegt:
   ein Weg, der nur erscheint, wenn man ihn braucht, ist keiner, den man
   kennt. Die Zahl dagegen erscheint nur bei Ungelesenem - eine Null waere
   nur Rauschen. */
.kopf-rechts .glocke {
    position: relative; display: inline-flex; align-items: center;
    text-decoration: none; font-size: 15px; line-height: 1;
    padding: 5px 7px; border-radius: 8px; color: var(--text);
}
.kopf-rechts .glocke:hover { background: var(--grund); }
.kopf-rechts .glocke svg { display: block; }
.kopf-rechts .glocke .zaehler {
    position: absolute; top: -2px; right: -4px;
    min-width: 16px; padding: 0 4px; box-sizing: border-box;
    border-radius: 999px; font-size: 10.5px; font-weight: 650;
    background: var(--fehler); color: #fff; text-align: center; line-height: 16px;
}

/* --------------------------------------------------------- Mailrumpf */

/* Fremdes HTML in einem abgeriegelten Rahmen. Er wird so hoch wie noetig
   gemacht - aber nicht vom Inhalt aus: ein Rahmen mit sandbox="" darf seine
   Hoehe nicht melden, und das ist richtig so. Also eine feste Hoehe mit
   eigenem Rollbalken. */
.mailrumpf {
    display: block;
    width: 100%;
    height: 460px;
    border: 0;
    /* Weiss, unabhaengig vom Erscheinungsbild: eine Mail von 2019 wurde
       fuer weissen Grund geschrieben, und ihre Farben umzurechnen hiesse,
       sie zu veraendern. */
    background: #fff;
}

/* Ein Textrumpf bricht um, statt in die Breite zu laufen. */
pre.mailtext {
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font: 13.5px/1.6 ui-monospace, "Cascadia Mono", Consolas, monospace;
    max-height: 460px;
    overflow-y: auto;
}

/* --------------------------------------------------------------- Meldungen */

/* Eine ungelesene Meldung faellt auf, ohne zu schreien: ein Balken links
   und fetter Text. Farbe allein traegt keine Auskunft fuer jemanden, der
   sie nicht sieht - die Art steht ohnehin als Wort daneben. */
tr.ungelesen td { font-weight: 600; }
tr.ungelesen td:first-child { box-shadow: inset 3px 0 0 var(--marke); }

/* --------------------------------------------------------------- Eingang */

/* Liste links, Blatt rechts. Unter 1000px untereinander — auf einem
   Notebook-Bildschirm ist die Liste sonst zu schmal zum Lesen. */
.eingang { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: start; }
.eingang-liste { max-height: 70vh; overflow-y: auto; }
.eingang-liste tr.gewaehlt { background: color-mix(in srgb, var(--marke) 10%, transparent); }
.eingang-liste tr.gewaehlt a { font-weight: 600; }
.eingang-blatt .karte + .karte { margin-top: 12px; }

/* Die Vorschau bekommt feste Hoehe: sonst springt die Seite bei jedem
   Dokument, und man verliert die Maske aus dem Blick. */
.vorschau { width: 100%; height: 420px; border: 1px solid var(--rand); border-radius: var(--rundung); background: var(--grund); display: block; }

@media (max-width: 1000px) {
    .eingang { grid-template-columns: 1fr; }
    .eingang-liste { max-height: 240px; }
}

/* Waehrend HTMX laedt, wird die Flaeche ruhig gestellt. */
.htmx-request { opacity: .55; transition: opacity .1s; }

@media (max-width: 720px) {
    header.kopf { height: auto; padding: 10px 16px; flex-wrap: wrap; }
    main { padding: 18px 16px 48px; }
    .marke .beiwort { display: none; }
    /* Die Kopfzeile ist hier hoch wie noetig — eine feste Kante darunter
       waere geraten. Also klebt die Wegleiste auf schmalen Geraeten nicht. */
    nav.wegleiste { position: static; }
    nav.wegleiste .wege { padding: 5px 12px; }
    .feldzeile { grid-template-columns: 1fr; gap: 6px; }
    .feldzeile > label { padding-top: 0; }
    form.innen input[type=text] { min-width: 0; width: 100%; }
}

/* Der Stand einer Mail. Die Farben sind die aus ecoMAILZ, damit sich
   niemand umgewoehnen muss — aber die Beschriftung steht immer daneben:
   eine Farbe allein traegt keine Auskunft fuer jemanden, der sie nicht
   unterscheiden kann. */
.marken.sichtung { color: var(--warnung); border-color: color-mix(in srgb, var(--warnung) 40%, transparent); }
.marken.vorgemerkt { color: var(--fehler); border-color: color-mix(in srgb, var(--fehler) 40%, transparent); }
.marken.endgueltig { color: var(--gut); border-color: color-mix(in srgb, var(--gut) 35%, transparent); }
.marken.beantragt { color: var(--text-leise); border-color: var(--rand); }
.marken.geloescht { color: var(--text); background: var(--rand); border-color: var(--rand); }

/* --- Schwaerzen ------------------------------------------------------- */

/* Das Blatt, auf dem gezogen wird. Position relativ, damit die Balken sich
   daran ausrichten und nicht an der Seite. */
.blatt {
    position: relative;
    display: inline-block;
    max-width: 100%;
    line-height: 0;
    border: 1px solid var(--rand);
    background: #fff;
    cursor: crosshair;
    user-select: none;
}

.blatt img {
    max-width: 100%;
    height: auto;
    display: block;
    pointer-events: none;
}

/* Voll deckend, nicht durchscheinend: was der Benutzer sieht, ist das
   Ergebnis. Ein halbdurchsichtiger Balken liesse ihn glauben, darunter
   bliebe etwas — genau der Irrtum, um den es hier geht. */
.balken {
    position: absolute;
    background: #000;
    cursor: pointer;
}

.balken.zieht {
    background: rgba(0, 0, 0, 0.55);
    outline: 1px dashed #fff;
    cursor: crosshair;
    pointer-events: none;
}

.blattwahl {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    margin: 0.6rem 0;
}

.blattwahl .knopf {
    min-width: 2.4rem;
    text-align: center;
}

/* --- Anmerkungen ------------------------------------------------------ */

/* Die Auflagen auf dem Blatt. Anders als beim Schwaerzen verdecken sie
   nichts: eine Markierung, die den Text unlesbar macht, ist ein Schwaerzer. */
.anmerkung {
    position: absolute;
    box-sizing: border-box;
    pointer-events: auto;
}

.anmerkung.markierung { opacity: 0.32; }
.anmerkung.kasten,
.anmerkung.stempel { background: none; border: 2px solid; }

.anmerkung.gelb  { background: #fbd426; border-color: #c9a400; color: #6b5600; }
.anmerkung.gruen { background: #33a652; border-color: #268040; color: #14401f; }
.anmerkung.rot   { background: #d43333; border-color: #a32020; color: #5c1212; }
.anmerkung.blau  { background: #2e70c7; border-color: #22539a; color: #12294d; }

.anmerkung.kasten.gelb,  .anmerkung.stempel.gelb  { border-color: #c9a400; }
.anmerkung.kasten.gruen, .anmerkung.stempel.gruen { border-color: #268040; }
.anmerkung.kasten.rot,   .anmerkung.stempel.rot   { border-color: #a32020; }
.anmerkung.kasten.blau,  .anmerkung.stempel.blau  { border-color: #22539a; }

/* Die Nummer ist der Faden zum Pruefbericht — ohne sie steht auf dem Blatt
   ein Kringel und im Bericht ein Satz. */
.anmnummer {
    position: absolute;
    top: 0;
    left: 0;
    background: currentColor;
    color: #fff;
    font-size: 0.7rem;
    line-height: 1;
    padding: 0.15rem 0.3rem;
    font-weight: 600;
}

.neu {
    position: absolute;
    box-sizing: border-box;
    border: 2px dashed #444;
    background: rgba(120, 120, 120, 0.2);
    pointer-events: none;
}

.neu.zieht { border-style: dotted; }

.werkzeuge {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: flex-end;
    margin: 0.6rem 0;
}

.werkzeuge label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    font-size: 0.85rem;
}

.werkzeuge label.wachsend { flex: 1 1 16rem; }
.werkzeuge input[type="text"] { width: 100%; }

.marke.anm.gelb  { background: #fdf3cd; color: #6b5600; }
.marke.anm.gruen { background: #d9f0e0; color: #14401f; }
.marke.anm.rot   { background: #f7d9d9; color: #5c1212; }
.marke.anm.blau  { background: #d7e5f7; color: #12294d; }

/* --- Formularbereiche ------------------------------------------------- */

/* Ein Bereich verdeckt nichts: man muss sehen, was darunter steht, sonst
   laesst sich nicht pruefen, ob der Kasten sitzt. */
.bereich {
    position: absolute;
    box-sizing: border-box;
    border: 2px solid #2e70c7;
    background: rgba(46, 112, 199, 0.12);
}

.bereichname {
    position: absolute;
    top: -1px;
    left: -1px;
    background: #2e70c7;
    color: #fff;
    font-size: 0.7rem;
    line-height: 1;
    padding: 0.15rem 0.3rem;
    white-space: nowrap;
}

/* --- Liste mit Vorschau daneben --------------------------------------- */

/* Zwei Spalten: Liste links, Vorschau rechts. Unter 62rem wird daraus
   wieder eine Spalte -- eine Vorschau, die neben einer Tabelle klemmt, die
   selbst schon zu schmal ist, hilft niemandem. */
.mitseitenteil {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 20rem;
    gap: 1rem;
    align-items: start;
}

@media (max-width: 62rem) {
    .mitseitenteil { grid-template-columns: minmax(0, 1fr); }
}

.seitenteil {
    position: sticky;
    top: 1rem;
    border: 1px solid var(--rand);
    border-radius: 6px;
    background: var(--karte);
    padding: 0.8rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}

.seitenteil h2 {
    font-size: 1rem;
    margin: 0 0 0.6rem;
}

.blickblatt {
    border: 1px solid var(--rand);
    background: #fff;
    line-height: 0;
    margin-bottom: 0.8rem;
}

.blickblatt img {
    width: 100%;
    height: auto;
    display: block;
}

.blickangaben {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.15rem 0.6rem;
    margin: 0;
    font-size: 0.85rem;
}

.blickangaben dt { color: var(--leise); }
.blickangaben dd { margin: 0; overflow-wrap: anywhere; }

.blickbemerkung {
    margin: 0.6rem 0 0;
    font-size: 0.85rem;
    border-left: 3px solid var(--rand);
    padding-left: 0.6rem;
}

/* Eine angeklickte Zeile bleibt erkennbar -- sonst weiss man nach dem
   dritten Klick nicht mehr, was rechts steht. */
tr.zeile { cursor: default; }
tr.zeile.offen { background: var(--hervor, rgba(46, 112, 199, 0.08)); }

/* --- Ansichtswahl ------------------------------------------------------ */

.ansichtswahl {
    margin: 0.4rem 0 0.8rem;
    font-size: 0.9rem;
}

.ansichtswahl summary {
    cursor: pointer;
    color: var(--leise);
}

.ansichtsform {
    border: 1px solid var(--rand);
    border-radius: 6px;
    padding: 0.8rem;
    margin-top: 0.4rem;
    background: var(--karte);
}

.spaltenwahl {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem 1rem;
    margin-bottom: 0.8rem;
}

.spaltenwahl label {
    white-space: nowrap;
}

/* --- Kartenansicht ----------------------------------------------------- */

/* Die Kachelbreite kommt aus der gewaehlten Stufe (--kachel). auto-fill statt
   fester Spaltenzahl: die Liste soll sich nach dem Fenster richten, nicht
   das Fenster nach der Liste. */
.karten {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--kachel, 10rem), 1fr));
    gap: 0.8rem;
    margin: 0.4rem 0;
}

.karte-kachel {
    position: relative;
    border: 1px solid var(--rand);
    border-radius: 6px;
    background: var(--karte);
    padding: 0.5rem;
    overflow: hidden;
}

.karte-kachel.offen {
    border-color: #2e70c7;
    box-shadow: 0 0 0 1px #2e70c7;
}

/* Das Blatt im Verhaeltnis A4 -- ein Vorschaubild, das mal hoch und mal
   quer ist, macht aus einer Kachelwand ein Durcheinander. */
.kachelblatt {
    display: block;
    aspect-ratio: 1 / 1.414;
    background: #fff;
    border: 1px solid var(--rand);
    overflow: hidden;
}

.kachelblatt img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    display: block;
}

.kachelblatt.ohnebild {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.4rem;
    word-break: break-all;
}

.kacheltitel {
    margin-top: 0.4rem;
    font-size: 0.85rem;
    line-height: 1.25;
    /* Hoechstens drei Zeilen: ein Titel, der die halbe Kachel fuellt,
       verdeckt genau das Blatt, wegen dem man diese Ansicht gewaehlt hat. */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.kachelangaben {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0 0.4rem;
    margin: 0.4rem 0 0;
    font-size: 0.75rem;
}

.kachelangaben dt { color: var(--leise); white-space: nowrap; }
.kachelangaben dd { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Die kleinste Stufe zeigt nur das Blatt und den Titel. */
.karten.klein .kacheltitel { font-size: 0.75rem; -webkit-line-clamp: 2; }

.kachelhaken {
    position: absolute;
    top: 0.6rem;
    left: 0.6rem;
    background: var(--karte);
    border-radius: 3px;
    padding: 0.1rem;
    z-index: 1;
}

/* --- Eingang: Zahlen und Blaettern ------------------------------------- */

.eingangszahlen {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin: 0.6rem 0 1rem;
}

.zahl-kachel {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    border: 1px solid var(--rand);
    border-radius: 6px;
    background: var(--karte);
    padding: 0.5rem 0.9rem;
    min-width: 6rem;
}

.zahl-kachel.breit { min-width: 11rem; }

.zahl-wert { font-size: 1.4rem; font-weight: 600; line-height: 1; }
.zahl-wert.klein { font-size: 1rem; padding-top: 0.25rem; }
.zahl-name { font-size: 0.75rem; color: var(--leise); }

/* Was liegen bleibt, faellt auf. Ein Eingang mit zwoelf Stuecken ist in
   Ordnung; einer, in dem das aelteste seit einer Woche liegt, nicht -- und
   beide sehen in der Liste gleich aus. */
.zahl-kachel.warnt { border-color: #c9a400; background: #fdf9e8; }
.zahl-kachel.warnt .zahl-wert { color: #6b5600; }
.zahl-kachel.schlimm { border-color: #a32020; background: #fdf3f3; }
.zahl-kachel.schlimm .zahl-wert { color: #a32020; }

.blaetterleiste {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.6rem;
    margin-bottom: 0.6rem;
}

/* Ein Knopf, der nirgends hinfuehrt, sieht auch nicht so aus. */
.knopf.aus {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

/* --- Tastenkuerzel ----------------------------------------------------- */

kbd {
    font-family: ui-monospace, monospace;
    font-size: 0.8em;
    border: 1px solid var(--rand);
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 0.05rem 0.35rem;
    background: var(--karte);
    white-space: nowrap;
}

/* Ein Kuerzel, das man nicht sieht, benutzt niemand. */
kbd.kuerzel {
    margin-right: 0.3rem;
    border: none;
    background: rgba(0, 0, 0, 0.08);
    padding: 0 0.25rem;
}

.tastenhilfe {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.tastenkasten {
    background: var(--karte);
    border: 1px solid var(--rand);
    border-radius: 8px;
    padding: 1.2rem 1.4rem;
    max-width: 26rem;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}

.tastenkasten h2 { margin-top: 0; font-size: 1.1rem; }

.tastenkasten dl {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 0.4rem 1rem;
    margin: 0.8rem 0;
    align-items: baseline;
}

.tastenkasten dd { margin: 0; }
