/* ==========================================================================
   qr.giit.ch - styles for the editor and the text pages
   Light theme, dark theme by system setting or by choice.
   ========================================================================== */

:root {
    --bg: #f3f4f7;
    --flaeche: #ffffff;
    --flaeche-2: #f7f8fa;
    --text: #1a1d26;
    --leise: #5d6475;
    --linie: #e1e3ea;
    --linie-stark: #c9ccd6;
    --marke: #2c55c9;
    --marke-hell: #e6ecfb;
    --marke-text: #ffffff;
    --gefahr: #c62f2f;
    --ai-an: #1f9d55;
    --ai-warte: #f2b632;
    --fehler-bg: #fdecec;
    --auswahl: #1a73e8;
    --buehne: #e8eaef;
    --karo-a: #ffffff;
    --karo-b: #e6e8ee;
    --raster: rgba(26, 115, 232, 0.16);
    --raster-stark: rgba(26, 115, 232, 0.34);
    --schatten: 0 1px 2px rgba(20, 22, 40, 0.06), 0 10px 30px -16px rgba(20, 22, 40, 0.28);
    --code-bg: #fbfbfd;
    --c-tag: #7a3dd8;
    --c-attr: #b25b00;
    --c-wert: #0b7a4b;
    --c-punkt: #8a8fa0;
    --c-komm: #8a8fa0;
    --c-ent: #c2185b;
    --c-sonder: #2b6cb0;
    --mark-sel: rgba(26, 115, 232, 0.14);
    --mark-err: rgba(198, 47, 47, 0.16);
    --r: 10px;
    --mono: ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
    color-scheme: light dark;
}
/* Dark theme: by system setting while no choice has been made
   (no data-theme), or fixed with data-theme="dark". */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0f1116;
        --flaeche: #171a21;
        --flaeche-2: #1c2029;
        --text: #e9ebf1;
        --leise: #9ba2b4;
        --linie: #282c37;
        --linie-stark: #3a3f4d;
        --marke: #7aa2ff;
        --marke-hell: #1a2546;
        --marke-text: #0a1020;
        --gefahr: #ff6b6b;
        --ai-an: #3ccf7e;
        --ai-warte: #f2b632;
        --fehler-bg: #3a1c1f;
        --auswahl: #5aa2ff;
        --buehne: #0b0d11;
        --karo-a: #2a2e38;
        --karo-b: #22262f;
        --raster: rgba(90, 162, 255, 0.18);
        --raster-stark: rgba(90, 162, 255, 0.36);
        --schatten: 0 1px 2px rgba(0, 0, 0, 0.35), 0 14px 36px -18px rgba(0, 0, 0, 0.8);
        --code-bg: #12151b;
        --c-tag: #c39bff;
        --c-attr: #ffb86b;
        --c-wert: #6fdca5;
        --c-punkt: #7d8394;
        --c-komm: #6d7385;
        --c-ent: #ff7fb0;
        --c-sonder: #7cb7ff;
        --mark-sel: rgba(90, 162, 255, 0.2);
        --mark-err: rgba(255, 107, 107, 0.22);
    }
}
:root[data-theme="dark"] {
    --bg: #0f1116;
    --flaeche: #171a21;
    --flaeche-2: #1c2029;
    --text: #e9ebf1;
    --leise: #9ba2b4;
    --linie: #282c37;
    --linie-stark: #3a3f4d;
    --marke: #7aa2ff;
    --marke-hell: #1a2546;
    --marke-text: #0a1020;
    --gefahr: #ff6b6b;
    --ai-an: #3ccf7e;
    --ai-warte: #f2b632;
    --fehler-bg: #3a1c1f;
    --auswahl: #5aa2ff;
    --buehne: #0b0d11;
    --karo-a: #2a2e38;
    --karo-b: #22262f;
    --raster: rgba(90, 162, 255, 0.18);
    --raster-stark: rgba(90, 162, 255, 0.36);
    --schatten: 0 1px 2px rgba(0, 0, 0, 0.35), 0 14px 36px -18px rgba(0, 0, 0, 0.8);
    --code-bg: #12151b;
    --c-tag: #c39bff;
    --c-attr: #ffb86b;
    --c-wert: #6fdca5;
    --c-punkt: #7d8394;
    --c-komm: #6d7385;
    --c-ent: #ff7fb0;
    --c-sonder: #7cb7ff;
    --mark-sel: rgba(90, 162, 255, 0.2);
    --mark-err: rgba(255, 107, 107, 0.22);
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--marke); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.leise { color: var(--leise); }
:focus-visible { outline: 2px solid var(--auswahl); outline-offset: 1px; }

/* ---------- Buttons and fields ---------- */

.knopf {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 34px; padding: 0 12px;
    background: var(--flaeche); border: 1px solid var(--linie-stark); border-radius: 8px;
    cursor: pointer; white-space: nowrap; font-weight: 500;
    transition: background .12s, border-color .12s;
}
.knopf:hover { background: var(--flaeche-2); border-color: var(--leise); }
.knopf.haupt { background: var(--marke); border-color: var(--marke); color: var(--marke-text); font-weight: 600; }
.knopf.haupt:hover { filter: brightness(1.08); }
.knopf.klein { height: 28px; padding: 0 9px; font-size: 13px; border-radius: 7px; }
.knopf.an { background: var(--marke-hell); border-color: var(--marke); color: var(--marke); }
.knopf.gefahr { color: var(--gefahr); }
.knopf.symbol { width: 34px; padding: 0; font-weight: 700; }
.knopf.mit-symbol { padding: 0 11px 0 9px; }
.knopf:disabled, .wz:disabled { opacity: .4; cursor: not-allowed; }
.knopf:disabled:hover { background: var(--flaeche); border-color: var(--linie-stark); }
.knopf svg, .wz svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
select.knopf { padding-right: 6px; }

input:not([type=checkbox]):not([type=color]):not([type=range]), select:not(.knopf), textarea {
    width: 100%; min-width: 0; height: 30px; padding: 4px 8px;
    background: var(--flaeche); border: 1px solid var(--linie-stark); border-radius: 7px;
}
textarea { height: auto; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--auswahl); box-shadow: 0 0 0 3px var(--mark-sel); }
input[type=color] { width: 34px; height: 30px; padding: 2px; border: 1px solid var(--linie-stark); border-radius: 7px; background: var(--flaeche); cursor: pointer; }

/* ---------- Header ---------- */

.kopf {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 9px 16px; background: var(--flaeche); border-bottom: 1px solid var(--linie);
    position: relative; z-index: 3;
}
.marke { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--text); margin-right: auto; }
.marke h1 { font-size: 17px; margin: 0; font-weight: 750; letter-spacing: -0.01em; }
.marke h1 span { color: var(--leise); font-weight: 500; }
.leiste { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.schema { display: inline-flex; padding: 2px; gap: 2px; border: 1px solid var(--linie-stark); border-radius: 8px; background: var(--flaeche); }
.schema button {
    width: 28px; height: 28px; display: inline-grid; place-items: center; padding: 0;
    border: 0; border-radius: 6px; background: transparent; color: var(--leise); cursor: pointer;
}
.schema button:hover { color: var(--text); background: var(--flaeche-2); }
.schema button[aria-checked="true"] { background: var(--marke-hell); color: var(--marke); }
.schema svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.trenn { width: 1px; height: 22px; background: var(--linie); margin: 0 4px; }

/* The open drawing (opens "My drawings") and the "New" menu */
.datei-knopf { max-width: 240px; min-width: 0; padding-right: 7px; }
.datei-titel { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.datei-knopf svg { flex: none; }
.knopf svg.pfeil { width: 14px; height: 14px; flex: none; opacity: .6; }
.menue-anker { position: relative; display: inline-flex; }
.menue {
    position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; display: grid; gap: 2px;
    width: min(310px, calc(100vw - 24px)); padding: 6px;
    background: var(--flaeche); border: 1px solid var(--linie-stark); border-radius: 12px; box-shadow: var(--schatten);
}
.menue[hidden] { display: none; }
.menue button {
    display: grid; gap: 1px; padding: 8px 10px; text-align: left;
    border: 0; border-radius: 8px; background: none; cursor: pointer;
}
.menue button:hover, .menue button:focus-visible { background: var(--flaeche-2); outline: none; }
.menue b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menue button span { font-size: 12.5px; color: var(--leise); }
#new-restart { margin-top: 4px; border-top: 1px solid var(--linie); border-radius: 0 0 8px 8px; padding-top: 10px; }

/* ---------- Work area ---------- */

.ansichten { display: none; }
.arbeit {
    --code-fr: 1fr;
    --view-fr: 1fr;
    display: grid;
    grid-template-columns: minmax(0, var(--code-fr)) 6px minmax(0, var(--view-fr)) 290px;
    height: calc(100vh - 53px);
    height: calc(100dvh - 53px);
    min-height: 520px;
}
.pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--flaeche); }
.pane-kopf {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    min-height: 44px; padding: 6px 10px; border-bottom: 1px solid var(--linie);
}
.pane-kopf .rechts { margin-left: auto; display: flex; gap: 6px; }

.splitter { background: var(--linie); cursor: col-resize; position: relative; touch-action: none; }
.splitter::after { content: ""; position: absolute; inset: 50% 1px auto; height: 36px; transform: translateY(-50%); border-left: 2px dotted var(--leise); left: 2px; opacity: .6; }
.splitter:hover, .splitter:focus-visible { background: var(--linie-stark); }

/* ---------- Code ---------- */

.fehler { padding: 8px 12px; background: var(--fehler-bg); color: var(--text); border-bottom: 1px solid var(--linie); font-size: 13px; }
.fehler b { color: var(--gefahr); }
.editor { position: relative; flex: 1; display: flex; min-height: 0; background: var(--code-bg); overflow: hidden; }
.gutter {
    flex: none; width: 46px; overflow: hidden; padding: 10px 8px 10px 0; text-align: right;
    font: 13px/20px var(--mono); color: var(--c-punkt); border-right: 1px solid var(--linie); user-select: none;
}
#gutter { white-space: pre; will-change: transform; }
.code-feld { position: relative; flex: 1; min-width: 0; overflow: hidden; }
.schicht, #code {
    margin: 0; padding: 10px 14px; border: 0;
    font: 13px/20px var(--mono); tab-size: 2; white-space: pre; letter-spacing: 0;
    font-variant-ligatures: none;
}
.schicht { position: absolute; inset: 0 auto auto 0; min-width: 100%; pointer-events: none; will-change: transform; overflow: visible; }
.marks { color: transparent; }
.marks mark { color: transparent; border-radius: 3px; }
.marks mark.sel { background: var(--mark-sel); box-shadow: 0 0 0 1px var(--mark-sel); }
.marks mark.err { background: var(--mark-err); }
#code {
    position: absolute; inset: 0; width: 100%; height: 100%; resize: none; outline: none;
    background: transparent; color: transparent; caret-color: var(--marke);
    overflow: auto; border-radius: 0; box-shadow: none !important;
}
.zeilen-band { position: absolute; left: 0; right: 0; top: 0; height: 20px; background: var(--mark-sel); opacity: 0.45; pointer-events: none; will-change: transform; }
.code-feld:focus-within .zeilen-band { opacity: 1; }
#code::selection { background: rgba(26, 115, 232, 0.28); color: transparent; }
.hl { color: var(--text); }
.hl .k { color: var(--c-tag); }
.hl .a { color: var(--c-attr); }
.hl .s { color: var(--c-wert); }
.hl .p { color: var(--c-punkt); }
.hl .c { color: var(--c-komm); font-style: italic; }
.hl .e { color: var(--c-ent); }
.hl .d { color: var(--c-sonder); }

/* ---------- Tools ---------- */

.werkzeuge { justify-content: space-between; gap: 6px 8px; padding: 6px 8px; }
.gruppe { display: flex; align-items: center; gap: 2px; }
.werkzeuge .trenn { margin: 0 3px; }
.wz {
    width: 30px; height: 30px; display: inline-grid; place-items: center;
    border: 1px solid transparent; border-radius: 7px; background: transparent; cursor: pointer; color: var(--text);
}
.wz:hover { background: var(--flaeche-2); border-color: var(--linie); }
.wz[aria-pressed="true"] { background: var(--marke-hell); border-color: var(--marke); color: var(--marke); }
/* ---------- Stage ---------- */

.buehne {
    position: relative; flex: 1; overflow: hidden; background: var(--buehne);
    touch-action: none; outline: none; cursor: default; user-select: none;
}
.veraltet-hinweis {
    position: absolute; top: 10px; left: 50%; transform: translateX(-50%); display: none;
    padding: 4px 12px; border-radius: 99px; background: var(--fehler-bg); color: var(--gefahr); font-size: 12px; font-weight: 600;
    box-shadow: var(--schatten);
}
.buehne.veraltet .veraltet-hinweis { display: block; }

/* ---------- Properties ---------- */

.inspector { border-left: 1px solid var(--linie); }
.reiter { gap: 4px; padding: 6px; }
.reiter button, .ansichten button {
    flex: 1; height: 30px; border: 0; border-radius: 7px; background: transparent; cursor: pointer; font-weight: 600; color: var(--leise);
}
.inspector .reiter { flex-wrap: nowrap; gap: 2px; padding: 6px 4px; }
.inspector .reiter button { flex: 1 1 auto; min-width: 0; padding: 0 6px; font-size: 12.5px; white-space: nowrap; }
.reiter button[aria-selected="true"], .ansichten button[aria-selected="true"] { background: var(--flaeche-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--linie); }
.inspector-body { flex: 1; overflow: auto; padding: 4px 14px 18px; }
.inspector-body h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--leise); margin: 18px 0 8px; font-weight: 700; }
.inspector-body h3 code { text-transform: none; letter-spacing: 0; font: 12px var(--mono); color: var(--c-tag); margin-left: 4px; }
.pfad { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 4px; padding-top: 10px; font: 12px var(--mono); color: var(--leise); }
.pfad button { border: 0; background: none; padding: 1px 3px; border-radius: 4px; color: var(--marke); cursor: pointer; font: inherit; }
.pfad button:hover { background: var(--marke-hell); }
.pfad b { color: var(--text); }
.hinweis { font-size: 12.5px; color: var(--leise); margin: 8px 0; }
.feld { display: grid; grid-template-rows: subgrid; grid-row: span 2; gap: 3px; font-size: 12.5px; min-width: 0; }
.feld > span:first-child { align-self: end; color: var(--leise); font-weight: 500; }
.feld small { font-weight: 400; opacity: .8; }
label.feld + label.feld { margin-top: 0; }
.inspector-body > .feld { margin-top: 10px; grid-template-rows: auto auto; }
.zeile3 { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; gap: 3px 10px; margin-top: 10px; }
.geo { display: grid; grid-template-columns: repeat(4, 1fr); grid-template-rows: auto auto; gap: 3px 6px; }
.geo input { padding: 4px 5px !important; font-variant-numeric: tabular-nums; }
.knopfreihe { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.knopfreihe .knopf { flex: 1 1 auto; }
.knopfreihe.zwei { display: grid; grid-template-columns: 1fr 1fr; }
.vorgaben { display: grid; grid-template-columns: auto 34px 1fr; align-items: center; gap: 8px 10px; font-size: 12.5px; color: var(--leise); }
.vorgaben input[type=number] { grid-column: 2 / -1; max-width: 120px; }
.mit-keine { display: flex; align-items: center; gap: 6px; min-height: 30px; }
.kasten { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; cursor: pointer; white-space: nowrap; }


/* ---------- Dialogs, messages ---------- */

.dialog {
    width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0;
    border: 1px solid var(--linie); border-radius: 14px; background: var(--flaeche); color: var(--text); box-shadow: var(--schatten);
}
.dialog { overflow: auto; }
.dialog::backdrop { background: rgba(10, 12, 18, 0.45); }
.dialog-kopf { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--linie); margin: 0; }
.dialog-kopf h2 { margin: 0; font-size: 17px; }
.schliessen { width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-size: 16px; }
.schliessen:hover { background: var(--flaeche-2); }
.dialog-inhalt { padding: 16px 18px 18px; }
.ex-zeile { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; gap: 3px 12px; margin-bottom: 14px; }
.ex-zeile.vier { grid-template-columns: repeat(4, 1fr); }
.ex-text { width: 100%; height: 240px !important; font: 12px/1.5 var(--mono) !important; white-space: pre; background: var(--code-bg) !important; }
.dialog[data-raster="true"] .nur-text { display: none; }
.dialog[data-raster="false"] .nur-bild { display: none; }
.dialog-fuss { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.dialog-fuss .leise { margin-right: auto; }
.dialog.frage { width: min(440px, calc(100vw - 32px)); }

/* My drawings */
.dialog.dateien { width: min(900px, calc(100vw - 32px)); }
.dateien-leiste { display: flex; gap: 8px; margin-bottom: 14px; }
.dateien-leiste input { flex: 1; height: 34px !important; }
.datei-raster {
    list-style: none; margin: 0 0 12px; padding: 0;
    display: grid; grid-template-columns: repeat(auto-fill, minmax(168px, 1fr)); gap: 12px;
}
.datei-karte {
    display: flex; flex-direction: column; min-width: 0; overflow: hidden; cursor: pointer;
    border: 1px solid var(--linie); border-radius: 12px; background: var(--flaeche);
    transition: border-color .12s, box-shadow .12s;
}
.datei-karte:hover { border-color: var(--linie-stark); box-shadow: var(--schatten); }
.datei-karte.aktuell { border-color: var(--marke); box-shadow: 0 0 0 1px var(--marke); }
.datei-oeffnen { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; }
.datei-oeffnen:focus-visible { outline-offset: -2px; }
.datei-bild {
    display: grid; place-items: center; aspect-ratio: 4 / 3; padding: 12px;
    background-color: var(--karo-a);
    background-image: linear-gradient(45deg, var(--karo-b) 25%, transparent 25%, transparent 75%, var(--karo-b) 75%),
                      linear-gradient(45deg, var(--karo-b) 25%, transparent 25%, transparent 75%, var(--karo-b) 75%);
    background-size: 12px 12px; background-position: 0 0, 6px 6px;
    border-bottom: 1px solid var(--linie);
}
.datei-bild img { width: 100%; height: 100%; object-fit: contain; }
.datei-bild.kaputt img { display: none; }
.datei-bild.kaputt::after { content: "The code has an error"; font-size: 12px; color: var(--gefahr); }
.datei-text { display: grid; padding: 8px 10px 0; min-width: 0; }
.datei-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.datei-info { font-size: 12px; }
.datei-karte.aktuell .datei-info { color: var(--marke); font-weight: 600; }
input.datei-umbenennen { height: 26px !important; font-weight: 600; }
.datei-knoepfe { display: flex; gap: 2px; padding: 4px 6px 6px; }
.datei-knoepfe .ek { display: inline-block; width: 28px; height: 28px; line-height: 28px; border-radius: 7px; }
.datei-knoepfe .ek:hover { background: var(--flaeche-2); }
.datei-knoepfe .ek.gefahr { margin-left: auto; }
.datei-leer { grid-column: 1 / -1; text-align: center; padding: 24px 0; }

/* AI Assistant: change the open drawing or make a new one */
.ai-ziel { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 14px 0 6px; padding: 0; border: 0; }
.ai-ziel legend { padding: 0; margin-bottom: 6px; font-weight: 600; }
.ai-ziel label {
    display: flex; align-items: flex-start; gap: 8px; padding: 9px 11px; cursor: pointer;
    border: 1px solid var(--linie-stark); border-radius: 10px;
}
.ai-ziel label:has(:checked) { border-color: var(--marke); background: var(--marke-hell); }
.ai-ziel input { flex: none; width: auto !important; height: auto !important; margin: 3px 0 0; accent-color: var(--marke); }
.ai-ziel b { display: block; overflow-wrap: anywhere; }
.ai-ziel small { display: block; color: var(--leise); font-size: 12.5px; }
.frage #ask-text { margin: 0; }

.ai-einfuegen { display: grid; gap: 4px; margin: 4px 0 12px; }
.ai-einfuegen textarea { font: 12px var(--mono); min-height: 44px; }

/* Notice in a tab that was opened by an AI link */
.empfang { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(10, 12, 18, 0.5); }
.empfang[hidden] { display: none; }
.empfang-box { max-width: 420px; padding: 24px; text-align: center; background: var(--flaeche); border-radius: 14px; box-shadow: var(--schatten); }
.empfang-box h2 { margin: 12px 0 6px; font-size: 19px; }
.empfang-box p { margin: 0 0 16px; color: var(--leise); }
.empfang-knoepfe { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.empfang-knoepfe [hidden] { display: none; }
.empfang.laedt .empfang-box p:empty { display: none; }
.empfang.laedt .empfang-box img { animation: empfang-laedt 0.9s ease-in-out infinite alternate; }
@keyframes empfang-laedt { to { opacity: 0.35; transform: scale(0.88); } }
@media (prefers-reduced-motion: reduce) { .empfang.laedt .empfang-box img { animation: none; } }

.kuerzel dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; margin: 0; }
.kuerzel dt { white-space: nowrap; }
.kuerzel dd { margin: 0; color: var(--leise); }
kbd {
    display: inline-block; min-width: 22px; padding: 1px 6px; text-align: center;
    border: 1px solid var(--linie-stark); border-bottom-width: 2px; border-radius: 5px; background: var(--flaeche-2); font: 12px var(--mono);
}

.toast {
    position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
    padding: 9px 16px; border-radius: 10px; background: var(--text); color: var(--bg); font-weight: 500; box-shadow: var(--schatten);
    transition: opacity .18s, transform .18s; z-index: 20; max-width: calc(100vw - 32px);
}
.toast.zeigen { opacity: 1; transform: translate(-50%, 0); }
.ablage-hinweis {
    position: fixed; inset: 0; display: none; place-items: center; z-index: 30; pointer-events: none;
    background: rgba(26, 127, 82, 0.12); border: 3px dashed var(--marke);
}
.ablage-hinweis span { padding: 14px 22px; border-radius: 12px; background: var(--flaeche); font-size: 18px; font-weight: 700; box-shadow: var(--schatten); }
body.ablegen .ablage-hinweis { display: grid; }

/* ---------- Text section below the editor ---------- */

.seite { max-width: 980px; margin: 0 auto; padding: 48px 16px 24px; font-size: 16px; line-height: 1.65; }
.text-abschnitt { margin-bottom: 44px; }
.text-abschnitt h2 { font-size: 26px; line-height: 1.2; letter-spacing: -0.015em; margin: 0 0 14px; }
.text-abschnitt h3 { font-size: 17px; margin: 0 0 6px; }
.text-abschnitt p { margin: 0 0 12px; }
.einstieg p { font-size: 17px; color: var(--leise); max-width: 760px; }
.kacheln { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.kachel { padding: 18px 20px; background: var(--flaeche); border: 1px solid var(--linie); border-radius: 14px; }
.kachel p { color: var(--leise); margin: 0; font-size: 15px; }
.schritte { padding-left: 22px; margin: 0; }
.schritte li { margin-bottom: 8px; }
.fragen details { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; padding: 0 18px; margin-bottom: 8px; }
.fragen summary { cursor: pointer; font-weight: 600; padding: 13px 0; }
.fragen details p { color: var(--leise); margin: 0 0 14px; }
/* German interface: hidden for the moment until its texts are there (i18n.js). */
html.uebersetzen :is(.kopf, .ansichten, #work, dialog) { visibility: hidden; }
.ai-knopf { position: relative; }
/* An AI is connected: the button lights up green with a check mark; waiting for the key: a yellow dot. */
.knopf.ai-knopf[data-ai="an"], .knopf.ai-knopf[data-ai="an"]:hover { color: var(--ai-an); border-color: var(--ai-an); background: color-mix(in srgb, var(--ai-an) 14%, var(--flaeche)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ai-an) 22%, transparent); }
.ai-knopf[data-ai="an"]::after { content: "✓"; position: absolute; top: -7px; right: -7px; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--ai-an); color: #fff; font-size: 11px; font-weight: 700; line-height: 1; box-shadow: 0 0 0 2px var(--flaeche); }
.ai-knopf[data-ai="warte"]::after { content: ""; position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--ai-warte); box-shadow: 0 0 0 2px var(--flaeche); }
.ai-status { list-style: none; margin: 0 0 14px; padding: 10px 12px; border: 1px solid var(--linie); border-radius: 12px; font-size: 14px; color: var(--leise); }
.ai-status li { display: flex; gap: 8px; align-items: baseline; }
.ai-status li + li { margin-top: 4px; }
.ai-status li::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--linie-stark); transform: translateY(-1px); }
.ai-status li[data-ai] { color: var(--text); }
.ai-status li[data-ai="an"]::before { background: var(--ai-an); }
.ai-status li[data-ai="warte"]::before { background: var(--ai-warte); }
.ai-remote { margin: 0 0 14px; padding: 12px 14px; border: 1px solid var(--marke); border-radius: 12px; background: var(--mark-sel); }
.ai-remote p { margin: 0; }
.ai-remote details { margin-top: 8px; font-size: 14px; }
.ai-remote summary { cursor: pointer; }
.ai-remote-prompt { margin: 6px 0 0; padding: 8px 10px; max-height: 160px; overflow: auto; white-space: pre-wrap; font: 12px/1.45 var(--mono); background: var(--flaeche); border: 1px solid var(--linie); border-radius: 8px; }
.ai-prompt-text { width: 100%; margin: 4px 0 10px; font: 12px/1.45 var(--mono); resize: vertical; }
.beispiel { margin: 0 0 14px; padding: 14px 16px; background: var(--flaeche); border: 1px solid var(--linie); border-radius: 12px; overflow-x: auto; font-size: 13px; line-height: 1.5; }
.beispiel code { background: none; padding: 0; white-space: pre; }
.text-abschnitt h3 + p { margin-top: 0; }
.text-abschnitt p + h3, .beispiel + h3 { margin-top: 22px; }
.fuss {
    display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 20px;
    max-width: 980px; margin: 0 auto; padding: 22px 16px 34px; border-top: 1px solid var(--linie); color: var(--leise); font-size: 14px;
}
.fuss nav { display: flex; gap: 18px; }
.fuss a { color: var(--leise); }
.fuss a:hover { color: var(--marke); }

/* Legal pages */
.recht { max-width: 760px; margin: 0 auto; padding: 36px 16px 20px; font-size: 16px; line-height: 1.65; }
.recht h1 { font-size: 30px; margin: 0 0 4px; letter-spacing: -0.02em; }
.recht h2 { font-size: 19px; margin: 30px 0 8px; }
.recht .stand { color: var(--leise); margin: 0 0 22px; }
.recht address { font-style: normal; margin-bottom: 10px; }
.recht ul { padding-left: 20px; }
.recht h3 { font-size: 17px; margin: 22px 0 6px; }
.recht table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: 14px; margin: 10px 0 16px; }
.recht th, .recht td { text-align: left; vertical-align: top; padding: 6px 10px; border-bottom: 1px solid var(--linie); }
.recht code { overflow-wrap: anywhere; }
.zurueck { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 18px; text-decoration: none; font-weight: 600; }

/* ---------- Medium width: narrower properties ---------- */

@media (max-width: 1180px) {
    .arbeit { grid-template-columns: minmax(0, var(--code-fr)) 6px minmax(0, var(--view-fr)) 250px; }
}

/* ---------- Narrow: one view at a time ---------- */

@media (max-width: 860px) {
    .kopf { padding: 8px 12px; gap: 8px; }
    .marke h1 span { display: none; }
    .leiste.datei .trenn, #btn-download { display: none; }
    .marke h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .leiste { gap: 4px; }
    .leiste.datei { order: 1; flex-wrap: nowrap; }
    .leiste.aus { order: 2; width: 100%; flex-wrap: nowrap; }
    .leiste.aus #btn-export { margin-left: auto; }
    #btn-undo, #btn-redo, #btn-new { width: 34px; padding: 0; }
    #btn-undo .txt, #btn-redo .txt, #btn-new .txt { display: none; }
    .datei-knopf { max-width: 42vw; }
    .menue { position: fixed; top: 52px; left: 12px; right: 12px; width: auto; }
    .leiste.datei { flex: 1; min-width: 0; }
    .dateien-leiste { flex-wrap: wrap; }
    .dateien-leiste input { flex-basis: 100%; }
    .dateien-leiste .knopf { flex: 1; }
    .datei-raster { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
    .ai-ziel { grid-template-columns: 1fr; }
    .ansichten { display: flex; gap: 4px; padding: 6px 12px; background: var(--flaeche); border-bottom: 1px solid var(--linie); }
    .arbeit { display: block; height: calc(100dvh - 148px); min-height: 440px; }
    .hinweiszeile {
        top: 8px; right: 8px; bottom: auto; left: 8px; padding: 4px 9px; border-radius: 8px;
        background: var(--flaeche); border: 1px solid var(--linie); text-shadow: none; font-size: 12px;
    }
    .veraltet-hinweis { top: 46px; }
    .buehne .zoom { left: 8px; right: 8px; bottom: 8px; justify-content: center; }
    .ex-text { height: 140px !important; }
    .dialog { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
    .dialog-inhalt { padding: 14px 14px 0; }
    .dialog-fuss { position: sticky; bottom: 0; padding: 10px 0 14px; background: var(--flaeche); display: grid; grid-template-columns: 1fr 1fr; }
    .dialog-fuss .leise:empty { display: none; }
    .dialog-fuss .leise, .dialog-fuss .haupt:last-child { grid-column: 1 / -1; }
    .arbeit > .pane, .splitter { display: none; height: 100%; }
    .arbeit[data-show="code"] .code-pane,
    .arbeit[data-show="zeichnung"] .zeichen-pane,
    .arbeit[data-show="eigenschaften"] .inspector { display: flex; }
    .inspector { border-left: 0; }
    .werkzeuge { justify-content: flex-start; }
    .seite { padding-top: 32px; }
    .text-abschnitt h2 { font-size: 22px; }
    .ex-zeile.vier { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto auto auto; }
}
@media (max-width: 480px) {
    #btn-open { display: none; }
    .ex-zeile { grid-template-columns: 1fr; grid-template-rows: auto auto auto auto; }
    .kuerzel dl { grid-template-columns: 1fr; gap: 2px; }
    .kuerzel dd { margin-bottom: 8px; }
}

/* ==========================================================================
   CSV editor
   ========================================================================== */

/* Code: columns in colors, separators and quotes muted, the header row bold */
.hl .h { font-weight: 700; }
.hl .f0 { color: var(--text); }
.hl .f1 { color: var(--c-tag); }
.hl .f2 { color: var(--c-wert); }
.hl .f3 { color: var(--c-attr); }
.hl .f4 { color: var(--c-sonder); }
.hl .f5 { color: var(--c-ent); }
.hl .p { color: var(--c-punkt); font-weight: 700; }
.hl .p.tab { background: var(--mark-sel); border-radius: 2px; }
.hl .q { color: var(--c-punkt); }
.schicht, #code { tab-size: 4; }

/* Problems above the code */
.probleme { display: grid; gap: 2px; max-height: 30%; overflow: auto; padding: 6px 10px; }
.probleme .pr-kopf { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.probleme .pr-kopf button { margin-left: auto; }
.probleme ul { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 1px; }
.probleme li .pr-zeile {
    display: flex; gap: 8px; width: 100%; padding: 3px 6px; border: 0; border-radius: 6px; background: none;
    text-align: left; cursor: pointer; font-size: 12.5px; color: var(--text);
}
.probleme li .pr-zeile:hover { background: rgba(127, 127, 127, .14); }
.probleme .zeile-nr { flex: none; min-width: 52px; color: var(--leise); font-variant-numeric: tabular-nums; }
.probleme .err .art { color: var(--gefahr); }
.probleme .art { flex: none; font-weight: 700; width: 14px; text-align: center; color: #b7791f; }
.fehler.nur-warnungen { background: var(--flaeche-2); }

/* Table toolbar */
.werkzeuge { flex-wrap: wrap; }
.filter-gruppe { gap: 6px; flex: 1 1 320px; min-width: 0; }
.filter-gruppe input { flex: 1 1 140px; min-width: 90px; }
.filter-gruppe select { flex: 0 1 150px; min-width: 80px; }
#view-info { white-space: nowrap; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.sortierung { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--leise); margin-right: 6px; }
.sortierung b { color: var(--text); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The table */
.buehne.tabelle { touch-action: auto; user-select: none; background: var(--flaeche); }
.raster { position: absolute; inset: 0; overflow: auto; outline: none; font-size: 13px; overscroll-behavior: contain; }
.raster:focus-visible { box-shadow: inset 0 0 0 2px var(--auswahl); }
.raster-flaeche { position: relative; min-width: 100%; }
.raster-kopf { position: sticky; top: 0; z-index: 3; display: flex; height: 30px; background: var(--flaeche-2); border-bottom: 1px solid var(--linie-stark); }
.raster-zeilen { position: absolute; left: 0; right: 0; top: 30px; }
.zr { position: absolute; left: 0; display: flex; height: 26px; }
.ecke, .nr {
    position: sticky; left: 0; z-index: 2; flex: none; width: 58px; padding: 0 8px; text-align: right;
    background: var(--flaeche-2); border-right: 1px solid var(--linie-stark); color: var(--leise);
    font-size: 11.5px; font-variant-numeric: tabular-nums; cursor: pointer;
}
.ecke { display: block; border-bottom: 0; }
.nr { line-height: 26px; border-bottom: 1px solid var(--linie); }
.zr.zeile-an .nr { background: var(--marke-hell); color: var(--marke); font-weight: 700; }
.zr.neu .nr { color: var(--marke); font-size: 14px; }
.kz {
    position: relative; flex: none; display: flex; align-items: center; gap: 5px; padding: 0 22px 0 7px; overflow: hidden;
    border-right: 1px solid var(--linie); cursor: pointer; white-space: nowrap;
}
.kz small { flex: none; color: var(--leise); font-size: 10.5px; font-weight: 600; }
.kz b { overflow: hidden; text-overflow: ellipsis; font-weight: 650; }
.kz em { color: var(--leise); font-weight: 400; }
.kz.spalte-an { background: var(--marke-hell); }
.kz.spalte-an small { color: var(--marke); }
.kz.a { box-shadow: inset 0 0 0 2px var(--auswahl); }
.kz.leer { cursor: default; }
.sortieren {
    position: absolute; right: 4px; top: 6px; width: 17px; height: 17px; padding: 0; border: 0; border-radius: 4px;
    background: transparent; color: var(--leise); font-size: 10px; line-height: 17px; cursor: pointer; opacity: .55;
}
.kz:hover .sortieren, .sortieren.an { opacity: 1; }
.sortieren.an { color: var(--marke); background: var(--flaeche); }
.ziehen { position: absolute; right: -3px; top: 0; bottom: 0; width: 7px; cursor: col-resize; z-index: 1; }
.z {
    flex: none; height: 26px; padding: 0 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    line-height: 25px; border-right: 1px solid var(--linie); border-bottom: 1px solid var(--linie); cursor: cell;
}
.z.zahl { text-align: right; font-variant-numeric: tabular-nums; }
.z.leer { background: repeating-linear-gradient(135deg, transparent 0 6px, var(--flaeche-2) 6px 7px); }
.z.fehlt { background: color-mix(in srgb, #d69e2e 12%, transparent); }
.z.b { background: var(--mark-sel); }
.z.a { box-shadow: inset 0 0 0 2px var(--auswahl); background: var(--flaeche); }
.z.b.a { background: var(--mark-sel); }
.z .nl { color: var(--leise); font-style: normal; padding: 0 2px; }
.zelle-feld {
    position: absolute; z-index: 4; min-height: 26px; padding: 3px 7px !important; resize: none;
    font: 13px/18px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif !important; border-radius: 0 !important;
    border: 2px solid var(--auswahl) !important; box-shadow: var(--schatten) !important; white-space: pre; overflow: hidden;
}
.leer-hinweis { position: absolute; left: 50%; top: 110px; transform: translateX(-50%); width: min(420px, 90%); margin: 0; padding: 12px 16px; text-align: center; color: var(--leise); background: var(--flaeche); border: 1px dashed var(--linie-stark); border-radius: 10px; pointer-events: none; }

/* Side panel */
.doc-form { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; padding-top: 10px; }
.doc-form .knopf, .einfuege-gitter.eins .knopf { white-space: normal; height: auto; min-height: 28px; padding-top: 4px; padding-bottom: 4px; line-height: 1.25; text-align: left; }
.doc-form .zeile2 { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.doc-form .zeile2.unten { align-items: end; }
.doc-form select, .doc-form input:not([type=checkbox]) { min-width: 0; width: 100%; }
.doc-form .feld { grid-row: auto; grid-template-rows: auto auto; }
.doc-form .kasten { font-size: 13px; white-space: normal; align-items: flex-start; gap: 7px; }
.doc-form .kasten input { flex: none; width: 16px; height: 16px; margin-top: 2px; accent-color: var(--marke); }
.doc-form .unter { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--leise); font-weight: 700; margin: 10px 0 0; }
.doc-info { padding: 10px 12px; border: 1px solid var(--linie); border-radius: var(--r); background: var(--flaeche-2); font-size: 12.5px; color: var(--leise); }
.spalten-info { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin: 8px 0 0; font-size: 13px; }
.spalten-info dt { color: var(--leise); }
.spalten-info dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.haeufig { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; font-size: 13px; }
.haeufig li { display: flex; justify-content: space-between; gap: 10px; padding: 3px 8px; border-radius: 6px; background: var(--flaeche-2); }
.haeufig span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.haeufig b { color: var(--leise); font-weight: 600; font-variant-numeric: tabular-nums; }
.einfuege-gruppe h3 { margin-top: 16px !important; }
.einfuege-gitter { display: grid; grid-template-columns: repeat(2, 1fr); gap: 5px; }
.einfuege-gitter.eins { grid-template-columns: 1fr; }
.einfuege-gitter .knopf { height: 30px; padding: 0 8px; justify-content: flex-start; font-size: 12.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; }

/* My documents: the first rows as the picture */
.datei-bild.dok { background: var(--buehne); padding: 12px 10px 0; place-items: stretch; overflow: hidden; }
.mini-tabelle { display: grid; align-content: start; gap: 1px; height: 100%; padding: 6px; overflow: hidden; background: #ffffff; color: #222222; box-shadow: 0 1px 4px rgba(0, 0, 0, .2); font: 8px/1.5 system-ui, sans-serif; }
.mz { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; border-bottom: 1px solid #e3e6ec; }
.mz span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mz.kopfzeile { font-weight: 700; color: #1a7f52; }

/* Export */
.dialog[data-format="xlsx"] .nur-csv, .dialog[data-format="json"] .nur-csv, .dialog[data-format="md"] .nur-csv, .dialog[data-format="html"] .nur-csv { display: none; }
.dialog[data-format="tsv"] .nur-sep { visibility: hidden; }

/* Save to server */
.sync-felder { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: auto auto; gap: 3px 12px; margin: 14px 0 10px; }
.sync-wahl { display: flex; align-items: flex-start; gap: 8px; white-space: normal; margin: 6px 0; font-size: 13.5px; }
.sync-wahl input { margin-top: 3px; accent-color: var(--marke); }
.sync-hilfe { margin-top: 10px; border: 1px solid var(--linie); border-radius: 10px; padding: 0 12px; }
.sync-hilfe summary { cursor: pointer; padding: 9px 0; font-weight: 600; }
.code-beispiel { margin: 0 0 10px; padding: 10px; overflow: auto; background: var(--code-bg); border: 1px solid var(--linie); border-radius: 8px; font: 11.5px/1.5 var(--mono); }
#btn-sync.an { color: var(--marke); border-color: var(--marke); background: var(--marke-hell); }

/* Embedded in another website: only the editor */
.eingebettet .seite, .eingebettet .fuss, .eingebettet .marke h1 span { display: none; }
.eingebettet .arbeit { height: calc(100vh - 53px); height: calc(100dvh - 53px); min-height: 320px; }
.eingebettet body { overflow: hidden; }

@media (max-width: 860px) {
    .arbeit[data-show="zeichnung"] .zeichen-pane { display: flex; }
    .sync-felder { grid-template-columns: 1fr; grid-template-rows: auto auto auto auto; }
    .eingebettet .arbeit { height: calc(100dvh - 148px); }
    .filter-gruppe { flex-basis: 100%; }
}
@media (max-width: 480px) {
    #btn-ai { width: 34px; padding: 0; }
    #btn-ai .txt { display: none; }
}
.inspector .knopfreihe.zwei { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Footer: the links wrap on narrow screens. */
.fuss { flex-wrap: wrap; }
.fuss nav { flex-wrap: wrap; gap: 6px 14px; }

/* Language menu in the top bar (i18n.js fills [data-sprachen]). */
.sprachen:empty { display: none; }
.sprachwahl { height: 34px; padding: 0 8px; border: 1px solid var(--linie); border-radius: 10px; background: var(--flaeche); color: var(--text); font: inherit; font-size: 14px; cursor: pointer; }
.sprachwahl:hover { border-color: var(--marke); }

/* The side panel never scrolls sideways: everything wraps inside its width -
   buttons with long labels, paths, code and the text of every language. */
.inspector-body { overflow-x: hidden; }
.inspector-body .knopf { height: auto; min-height: 34px; max-width: 100%; padding-block: 4px; white-space: normal; overflow-wrap: anywhere; text-align: center; }
.inspector-body .knopf.klein { min-height: 28px; padding-block: 3px; }
.inspector-body :is(.feld, label, p, li, h3, span, code, small) { min-width: 0; overflow-wrap: anywhere; }
.inspector-body :is(select, input, textarea) { max-width: 100%; min-width: 0; }
.inspector-body textarea { white-space: pre-wrap; overflow-wrap: anywhere; overflow-x: hidden; }

/* The viewer (?viewer=1): only the document and a small bar. */
.betrachter .seite, .betrachter .fuss, .betrachter .code-pane, .betrachter #splitter, .betrachter .inspector,
.betrachter .marke, .betrachter .kopf .leiste.datei, .betrachter .zeichen-pane > .pane-kopf, .betrachter .tabellen-pane > .pane-kopf,
.betrachter .ansicht-reiter, .betrachter .leiste.aus > *:not(#btn-download):not(#btn-export) { display: none !important; }
.betrachter .pfad-fuss, .betrachter .baum-pfad, .betrachter #hint, .betrachter .hinweiszeile,
.betrachter .tabelle .neu, .betrachter .tabelle .leer, .betrachter .tabelle .sortieren { display: none !important; }
.betrachter .kopf { justify-content: flex-end; flex-wrap: nowrap; }
.betrachter .leiste.aus { flex: none; flex-wrap: nowrap; }
.betrachter-hinweis { flex: 1 1 0; min-width: 0; font-size: 12px; line-height: 1.25; color: var(--leise); display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; }
.betrachter-leer .betrachter-hinweis { display: none; }
.betrachter .arbeit { display: block !important; height: calc(100vh - 53px); height: calc(100dvh - 53px); }
.betrachter .zeichen-pane, .betrachter .tabellen-pane { display: flex !important; flex-direction: column; width: 100%; height: 100%; }
.betrachter .zoom > *:not(#zoom-out):not(#zoom-100):not(#zoom-in):not(#zoom-fit):not(#zoom-page):not(#size-down):not(#size-100):not(#size-up) { display: none !important; }
.betrachter-leer .zeichen-pane, .betrachter-leer .tabellen-pane { visibility: hidden; }

/* Export: open the document in another editor. All buttons are the same size. */
.ex-umwandeln { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-top: 12px; }
.ex-umwandeln > span { grid-column: 1 / -1; font-size: 12px; }
.ex-umwandeln > button { justify-content: center; white-space: nowrap; }
@media (max-width: 480px) {
    .ex-umwandeln { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.ex-umwandeln { display: none; }
#export.ex-umwandeln-an .ex-umwandeln { display: grid; margin-top: 0; }
#export.ex-umwandeln-an .dialog-inhalt > *:not(.ex-zeile):not(.ex-umwandeln):not(.ex-formate-box) { display: none !important; }
#export.ex-umwandeln-an .ex-zeile > *:not(:has(#ex-name)):not(:has(#ex-format)) { display: none !important; }
.probleme li .pr-zeile { user-select: text; cursor: text; }
.probleme li .pr-zeile span { user-select: text; }

/* Export: narrow and as tall as its content. The top edge stays where it is when the format changes;
   only a screen too small for it scrolls, the buttons stay in view. */
#export.dialog { width: min(440px, calc(100vw - 16px)); height: fit-content; max-height: calc(100dvh - 24px); margin: 12px auto auto; overflow: hidden; }
#export[open] { display: flex; flex-direction: column; }
#export .dialog-kopf { flex: none; }
#export .dialog-inhalt { flex: 0 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 12px; padding: 14px 18px 0; overflow: auto; }
#export .dialog-inhalt > * { flex: none; margin-top: 0; margin-bottom: 0; }
#export .dialog-inhalt > .ex-zeile:first-child { grid-template-columns: 1fr; grid-template-rows: auto auto; }
#export label.feld:has(#ex-format) { position: absolute; width: 1px; height: 1px; overflow: hidden; opacity: 0.01; pointer-events: none; }
#export .ex-zeile.vier { grid-template-columns: 1fr 1fr; grid-template-rows: auto auto auto auto; }
#export .nur-pdf .hinweis { margin: 0; }
.ex-formate-titel { font-size: 12.5px; color: var(--leise); font-weight: 500; margin-bottom: 3px; }
.ex-formate { display: grid; gap: 3px; }
.ex-formate.viele { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ex-formate.viele .ex-gruppe { grid-column: 1 / -1; }
.ex-gruppe { font-size: 11px; font-weight: 600; color: var(--leise); margin: 6px 0 0; }
.ex-gruppe:first-child { margin-top: 0; }
.ex-format { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; min-width: 0; border: 1px solid var(--linie); border-radius: 8px; cursor: pointer; font-size: 13px; }
.ex-format:hover { background: var(--flaeche-2); }
.ex-format:has(input:checked) { border-color: var(--marke); background: var(--flaeche-2); font-weight: 600; }
.ex-format input[type=radio] { flex: none; width: 16px !important; height: 16px !important; min-width: 0; margin: 0; padding: 0; border: 0; box-shadow: none; background: none; accent-color: var(--marke); }
.ex-format span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#export .ex-text { flex: 0 1 200px; min-height: 90px; height: auto !important; resize: none; }
#export .ex-umwandeln { grid-template-columns: 1fr; }
#export .ex-umwandeln > button { height: 34px; }
#export.ex-umwandeln-an .dialog-inhalt { padding-bottom: 18px; }
#export .ex-umbruch { display: flex; white-space: normal; margin: 0; }
#export .ex-umbruch[hidden] { display: none; }
#export .dialog-fuss { position: sticky; bottom: 0; display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 4px 0 16px; background: var(--flaeche); z-index: 1; }
#export .dialog-fuss > #ex-info { flex: 1 0 100%; display: block; font-size: 12px; }
#export .dialog-fuss > #ex-info:empty { display: none; }
#export .dialog-fuss > button { flex: 1 1 0; justify-content: center; white-space: nowrap; }
#export .dialog-fuss > .haupt { flex: 1 0 100%; grid-column: auto; }
#export .dialog-fuss > button[hidden] { display: none; }
#export .ex-text[hidden] { display: none; }
@media (min-height: 900px) {
    #export.dialog { margin-top: 3vh; max-height: 94dvh; }
}
@media (max-height: 760px), (max-width: 480px) {
    #export .ex-text { flex-basis: 96px; min-height: 70px; }
    #export .dialog-inhalt { gap: 8px; padding-top: 10px; }
    #export .dialog-kopf { padding: 8px 18px; }
    .ex-format { height: 28px; font-size: 12.5px; }
    .ex-gruppe { margin-top: 3px; }
}
.ex-formate.viele .ex-format { height: 40px; }
.ex-formate.viele .ex-format span { white-space: normal; line-height: 1.2; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
#export:has(.ex-formate.viele) .ex-text { flex-basis: 110px; }
@media (max-width: 480px) {
    .ex-formate.viele { grid-template-columns: 1fr; }
    .ex-formate.viele .ex-format { height: 28px; }
    .ex-formate.viele .ex-format span { display: block; white-space: nowrap; }
}

/* ==========================================================================
   QR editor: the stage with the code, the scan badge, the panel's pickers
   ========================================================================== */

.qr-kopf { gap: 8px 12px; flex-wrap: nowrap; }
.qr-info { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; }
.scan-badge {
    flex: none; display: inline-flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px; max-width: 60%;
    border: 1px solid var(--linie); border-radius: 99px; background: var(--flaeche-2); color: var(--text);
    font: 600 12.5px/1 inherit; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.scan-badge span:last-child { overflow: hidden; text-overflow: ellipsis; }
.scan-badge .punkt { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--leise); }
.scan-badge[data-state="good"] { border-color: var(--ai-an); }
.scan-badge[data-state="good"] .punkt { background: var(--ai-an); }
.scan-badge[data-state="fair"] { border-color: var(--ai-warte); }
.scan-badge[data-state="fair"] .punkt { background: var(--ai-warte); }
.scan-badge[data-state="fail"] { border-color: var(--gefahr); color: var(--gefahr); }
.scan-badge[data-state="fail"] .punkt { background: var(--gefahr); }
.scan-badge[data-state="wait"] .punkt { animation: puls 1s ease-in-out infinite; }
@keyframes puls { 50% { opacity: .3; } }

.qr-buehne {
    display: grid; place-items: center; touch-action: auto; user-select: none;
    background-color: var(--buehne);
    background-image: linear-gradient(45deg, var(--karo-b) 25%, transparent 25%), linear-gradient(-45deg, var(--karo-b) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--karo-b) 75%), linear-gradient(-45deg, transparent 75%, var(--karo-b) 75%);
    background-size: 20px 20px; background-position: 0 0, 0 10px, 10px -10px, -10px 0;
}
.qr-view { position: relative; filter: drop-shadow(0 6px 18px rgba(20, 22, 40, .18)); }
.qr-view svg { display: block; width: 100%; height: 100%; cursor: pointer; }
.qr-view svg text { cursor: text; }
.titel-bearbeiten {
    position: absolute; z-index: 5; padding: 0 8px; border: 2px solid var(--auswahl); border-radius: 6px;
    background: var(--flaeche); color: var(--text); font-weight: 700; text-align: center; outline: none;
}

/* Panel: rows of fields (inputs of a row start at the same height), pickers of equal size */
.inspector-body .form { display: grid; gap: 10px; margin-top: 10px; }
.form-reihe { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto auto; gap: 3px 10px; margin-top: 10px; }
.form .form-reihe { margin-top: 0; }
.form-reihe.eins { grid-template-columns: minmax(0, 1fr); }
.form-reihe > .kasten { grid-row: span 2; align-self: end; min-height: 34px; }
.inspector-body .feld input, .inspector-body .feld select, .inspector-body .feld textarea { width: 100%; }
.inspector-body .feld textarea { resize: vertical; min-height: 60px; }
.feld.aus, .kasten.aus { opacity: .5; }
.feld input.mono, .farbe-zeile input.mono { font-family: var(--mono); font-size: 12.5px; }
.typ-wahl { margin-top: 10px; }
.typ-hinweis { margin: 6px 0 0; font-size: 12px; line-height: 1.4; min-height: 3.4em; }
.inhalt-groesse { margin-top: 12px; font-size: 12px; }
.form-kasten { display: flex; white-space: normal; align-items: flex-start; gap: 7px; margin-top: 10px; line-height: 1.35; }
.form-kasten input { flex: none; width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--marke); }
.farbe-zeile { display: flex; gap: 6px; min-width: 0; }
.farbe-zeile input[type=color] { flex: none; width: 34px; height: 34px; padding: 2px; border: 1px solid var(--linie-stark); border-radius: 7px; background: var(--flaeche); cursor: pointer; }
.farbe-zeile input[type=text] { flex: 1; min-width: 0; }
.regler { margin-top: 10px; grid-template-rows: auto auto; }
.regler > span:first-child { display: flex; justify-content: space-between; gap: 8px; }
.regler output { font-variant-numeric: tabular-nums; color: var(--text); }
.regler input[type=range] { width: 100%; accent-color: var(--marke); }
.unter-titel { margin: 8px 0 4px; font-size: 12px; }
.wahl-raster { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.wahl {
    display: grid; grid-template-rows: 30px 2.5em; place-items: center; gap: 3px; min-width: 0; padding: 6px 3px 4px;
    border: 1px solid var(--linie); border-radius: 8px; background: var(--flaeche); color: var(--text); cursor: pointer; font-size: 11px; line-height: 1.2;
}
.wahl svg, .wahl img { width: 26px; height: 26px; object-fit: contain; }
.wahl span { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; text-align: center; overflow-wrap: normal; word-break: normal; hyphens: auto; align-self: start; max-width: 100%; }
.wahl:hover { background: var(--flaeche-2); }
.wahl[aria-checked="true"] { border-color: var(--marke); background: var(--marke-hell); color: var(--marke); font-weight: 600; }
.swiss-hinweis { padding: 8px 10px; border-radius: 8px; background: var(--flaeche-2); border: 1px solid var(--linie); line-height: 1.4; }
.knopfreihe.eins { display: grid; grid-template-columns: 1fr; margin-top: 16px; }
.ref-knoepfe { margin-top: 12px; }

/* Check tab */
.scan-ergebnis { margin: 0 0 8px; padding: 8px 10px; border-radius: 8px; font-weight: 600; font-size: 13px; background: var(--flaeche-2); border: 1px solid var(--linie); }
.scan-ergebnis[data-state="good"] { border-color: var(--ai-an); }
.scan-ergebnis[data-state="fair"] { border-color: var(--ai-warte); }
.scan-ergebnis[data-state="fail"] { border-color: var(--gefahr); color: var(--gefahr); }
.scan-liste { list-style: none; margin: 0 0 6px; padding: 0; display: grid; gap: 4px; font-size: 13px; }
.scan-liste li { display: flex; gap: 8px; align-items: center; }
.pr-zeichen { flex: none; display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; font-size: 12px; font-weight: 700; background: var(--flaeche-2); }
.pr-zeichen.gut { background: var(--ai-an); color: #fff; }
.pr-zeichen.schlecht { background: var(--gefahr); color: #fff; }
.werte { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 10px; margin: 0; font-size: 13px; }
.werte dt { color: var(--leise); }
.werte dd { margin: 0; overflow-wrap: anywhere; }
.farbmuster { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--linie-stark); vertical-align: -2px; margin-right: 2px; }
.druck-info { font-size: 13px; line-height: 1.5; margin: 8px 0 0; }
.pr-liste { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.pr-knopf { display: flex; gap: 8px; width: 100%; padding: 6px 8px; border: 1px solid var(--linie); border-radius: 7px; background: var(--flaeche); color: var(--text); text-align: left; font-size: 12.5px; line-height: 1.35; cursor: pointer; user-select: text; }
.pr-knopf .art { flex: none; font-weight: 700; }
.pr-liste .err .art { color: var(--gefahr); }
.pr-liste .warn .art { color: #b07a00; }
.hl .farbwert { text-decoration: underline 3px; text-underline-offset: 3px; }

/* My documents: the code as the card's picture */
.datei-bild.qr-bild { display: grid; place-items: center; padding: 10px; background: var(--buehne); }
.datei-bild.qr-bild svg { width: 100%; height: 100%; max-height: 100%; }

/* Export */
#export .ex-groesse[hidden], #export .ex-batch[hidden] { display: none; }
#export .ex-groesse { margin-bottom: 0; }
.ex-mass-info { grid-row: span 2; align-self: end; margin: 0 0 8px; font-size: 12px; }
#export .feld.aus { opacity: .5; }
.ex-batch { display: grid; gap: 8px; }
.ex-batch .ex-zeile { margin-bottom: 0; }
.ex-batch textarea { font: 12px/1.4 var(--mono); resize: vertical; min-height: 80px; }
.ex-batch-knoepfe { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; }
.ex-batch-knoepfe .leise { min-width: 0; flex: 1 1 200px; }

/* Camera */
.scan-dialog { width: min(520px, calc(100vw - 16px)); }
.scan-bild { position: relative; aspect-ratio: 4 / 3; border-radius: 10px; overflow: hidden; background: #000; }
.scan-bild video { width: 100%; height: 100%; object-fit: cover; }
.scan-rahmen { position: absolute; inset: 15% 22%; border: 3px solid rgba(255, 255, 255, .85); border-radius: 14px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .25); }
.scan-status { min-height: 2.6em; }

.betrachter .qr-buehne { display: grid !important; }
@media (max-width: 860px) {
    .qr-kopf { flex-wrap: wrap; }
    .qr-info { flex: 1 0 100%; }
    .scan-badge { max-width: 100%; }
}
@media (max-width: 480px) {
    .wahl-raster { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
.marks mark.warn { background: rgba(214, 158, 46, .2); }
.qr-buehne { min-height: 0; min-width: 0; }
.seite p code, .seite li code { overflow-wrap: anywhere; }
.code-pane > .pane-kopf { flex-wrap: nowrap; }
#code-status { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-pane > .pane-kopf .rechts { flex: none; }
.wahl-raster { grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); }
