/* kontor: Designsystem. Alles lokal, keine Schriften oder Bilder von außen (CSP: style-src 'self').
   Farben, Abstände und Radien als Variablen; hell/dunkel nach Systemeinstellung, per Umschalter überschreibbar
   (<html data-theme="hell|dunkel">, gesetzt von static/theme.js). */

:root {
  color-scheme: light dark;
  --text:#1f2328; --leise:#59636e; --rand:#d1d9e0; --rand-stark:#b6c0cb;
  --akzent:#0b5cad; --akzent-hover:#094e93; --akzent-text:#0b5cad; --akzent-hell:#e7f0fb; --auf-akzent:#fff;
  --gefahr:#b42318; --gefahr-hell:#fdecea; --gefahr-knopf:#b42318; --gefahr-knopf-hover:#9a1e14; --auf-gefahr:#fff;
  --ok:#17692f; --ok-hell:#e6f4ea; --warn:#8a5a00; --warn-hell:#fff4d6;
  --flaeche:#fff; --grund:#f3f5f8; --zeile:#f7f9fb; --erhoben:#fff;
  --schatten:0 1px 2px rgba(31,35,40,.06), 0 4px 14px rgba(31,35,40,.05);
  --fokus:#0b5cad;
  --r-s:6px; --r-m:10px; --r-l:14px;
  --a1:.25rem; --a2:.5rem; --a3:.75rem; --a4:1rem; --a5:1.5rem; --a6:2rem;
  --schrift:system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono:ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --nav-hoehe:3.6rem;
}
:root[data-theme=hell] { color-scheme:light; }
:root[data-theme=dunkel] { color-scheme:dark; }

/* Dunkel: nach Systemeinstellung (außer „hell“ ist gewählt) oder gewählt */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme=hell]) {
    --text:#e6edf3; --leise:#9ba5b0; --rand:#2f3640; --rand-stark:#49525e;
    --akzent:#2f6fc0; --akzent-hover:#285fa6; --akzent-text:#6cb0f5; --akzent-hell:#13233a; --auf-akzent:#fff;
    --gefahr:#f47067; --gefahr-hell:#3a1717; --gefahr-knopf:#b83027; --gefahr-knopf-hover:#9e2921; --auf-gefahr:#fff;
    --ok:#62b866; --ok-hell:#132a17; --warn:#e3b341; --warn-hell:#2f2506;
    --flaeche:#161b22; --grund:#0d1117; --zeile:#1c222b; --erhoben:#1c222b;
    --schatten:0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
    --fokus:#6cb0f5;
  }
}
:root[data-theme=dunkel] {
  --text:#e6edf3; --leise:#9ba5b0; --rand:#2f3640; --rand-stark:#49525e;
  --akzent:#2f6fc0; --akzent-hover:#285fa6; --akzent-text:#6cb0f5; --akzent-hell:#13233a; --auf-akzent:#fff;
  --gefahr:#f47067; --gefahr-hell:#3a1717; --gefahr-knopf:#b83027; --gefahr-knopf-hover:#9e2921; --auf-gefahr:#fff;
  --ok:#62b866; --ok-hell:#132a17; --warn:#e3b341; --warn-hell:#2f2506;
  --flaeche:#161b22; --grund:#0d1117; --zeile:#1c222b; --erhoben:#1c222b;
  --schatten:0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.3);
  --fokus:#6cb0f5;
}

*, *::before, *::after { box-sizing:border-box; }
html { -webkit-text-size-adjust:100%; scroll-padding-top:calc(var(--nav-hoehe) + 1rem); }
body { margin:0; font:16px/1.55 var(--schrift); color:var(--text); background:var(--grund); min-height:100vh; }
a { color:var(--akzent-text); text-decoration:none; }
a:hover { text-decoration:underline; text-underline-offset:.15em; }
:focus-visible { outline:3px solid var(--fokus); outline-offset:2px; border-radius:var(--r-s); }
::selection { background:var(--akzent-hell); }
.nur-screenreader { position:absolute; width:1px; height:1px; margin:-1px; padding:0; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap; border:0; }
.sprunglink { position:absolute; left:.5rem; top:-4rem; z-index:100; background:var(--akzent); color:var(--auf-akzent);
              padding:.5rem 1rem; border-radius:var(--r-s); }
.sprunglink:focus { top:.5rem; text-decoration:none; }

/* Symbole (inline-SVG aus templates/_icons.html) */
.ic { width:1.25em; height:1.25em; flex:none; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round; vertical-align:-.2em; }
.ic-gefuellt { fill:currentColor; }

/* Kopfleiste und Navigation */
.kopfleiste { position:sticky; top:0; z-index:20; background:var(--flaeche); border-bottom:1px solid var(--rand); }
.kopfleiste-innen { display:flex; align-items:center; gap:var(--a4); max-width:60rem; margin:0 auto; padding:.55rem 1.25rem; min-height:var(--nav-hoehe); }
.marke { display:inline-flex; align-items:center; gap:.5rem; font-weight:700; font-size:1.15rem; color:var(--text); letter-spacing:.01em; }
.marke:hover { text-decoration:none; }
.marke .ic { color:var(--akzent-text); width:1.4em; height:1.4em; }
nav.haupt { display:flex; gap:.25rem; margin-left:var(--a3); }
nav.haupt a { white-space:nowrap; display:inline-flex; align-items:center; gap:.45rem; color:var(--leise); padding:.4rem .7rem; border-radius:var(--r-s); font-weight:500; }
nav.haupt a:hover { background:var(--zeile); color:var(--text); text-decoration:none; }
nav.haupt a[aria-current=page] { color:var(--akzent-text); background:var(--akzent-hell); }
.nutzer { margin-left:auto; display:flex; align-items:center; gap:.5rem; }
.wer { color:var(--leise); display:inline-flex; align-items:center; gap:.4rem; max-width:14rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.wer .avatar { width:1.9rem; height:1.9rem; border-radius:50%; background:var(--akzent-hell); color:var(--akzent-text); display:inline-grid; place-items:center; font-weight:700; font-size:.9rem; flex:none; }
.symbolknopf { display:inline-grid; place-items:center; width:2.4rem; height:2.4rem; padding:0; border-radius:var(--r-s); border:1px solid transparent;
               background:transparent; color:var(--leise); cursor:pointer; }
.symbolknopf:hover { background:var(--zeile); color:var(--text); }
.theme-knopf { display:none; }
html.js .theme-knopf { display:inline-grid; }
.theme-knopf .ic { display:none; }
html:not([data-theme]) .theme-knopf .ic-auto, html[data-theme=hell] .theme-knopf .ic-hell, html[data-theme=dunkel] .theme-knopf .ic-dunkel { display:inline; }
form.inline { display:inline; margin:0; }

main { max-width:54rem; margin:0 auto; padding:var(--a4) 1.25rem 4rem; }
.seitenkopf { margin:var(--a4) 0 var(--a2); }
.seitenkopf h1 { margin:0; }
.fuss { max-width:54rem; margin:0 auto; padding:0 1.25rem 2rem; color:var(--leise); font-size:.85rem; }

/* Inhalt */
.karte { background:var(--flaeche); border:1px solid var(--rand); border-radius:var(--r-m); padding:1.1rem 1.4rem; margin:var(--a4) 0; box-shadow:var(--schatten); }
.karte.schmal { max-width:28rem; margin:var(--a6) auto; }
.kopf { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:.5rem 1rem; }
.kopf h2, .kopf h1 { margin:0; }
.kopf .knopf { white-space:nowrap; }
h1, h2, h3 { line-height:1.25; margin:.1rem 0 .5rem; }
h1 { font-size:1.4rem; } h2 { font-size:1.15rem; } h3 { font-size:1rem; }
p { margin:.5rem 0; }
.hinweis { color:var(--leise); font-size:.9rem; margin:.2rem 0 .8rem; }
.leer { color:var(--leise); }
.leerzustand { text-align:center; padding:1.5rem 1rem; color:var(--leise); border:1px dashed var(--rand-stark); border-radius:var(--r-m); background:var(--zeile); }
.leerzustand .ic { width:2.2rem; height:2.2rem; color:var(--leise); opacity:.8; display:block; margin:0 auto .4rem; }
.leerzustand p { margin:.2rem 0; }
.zurueck { margin:.5rem 0 0; }

table.liste { width:100%; border-collapse:separate; border-spacing:0; border:1px solid var(--rand); border-radius:var(--r-m); overflow:hidden; }
table.liste th { text-align:left; font-size:.78rem; text-transform:uppercase; letter-spacing:.05em; color:var(--leise);
                 background:var(--zeile); padding:.55rem .8rem; border-bottom:1px solid var(--rand); font-weight:600; }
table.liste td { padding:.65rem .8rem; border-bottom:1px solid var(--rand); vertical-align:middle; overflow-wrap:anywhere; }
table.liste tbody tr:last-child td { border-bottom:none; }
table.liste tr.klickbar:hover td { background:var(--akzent-hell); }
td.pfeil { width:2rem; text-align:right; }
td.pfeil a { display:inline-grid; place-items:center; color:var(--leise); }
.zeilenlink { font-weight:600; }
.pille, .marke-pille { display:inline-block; font-size:.76rem; padding:.05rem .55rem; border-radius:999px; border:1px solid var(--rand-stark); color:var(--leise); white-space:nowrap; margin:.1rem .15rem .1rem 0; }
.marke-pille { background:var(--akzent-hell); border-color:transparent; color:var(--akzent-text); }
.pille.warn { background:var(--warn-hell); border-color:transparent; color:var(--warn); }
.pille.gefahr { background:var(--gefahr-hell); border-color:transparent; color:var(--gefahr); }
.ziel { display:inline-block; margin:.1rem .35rem .1rem 0; padding:.05rem .5rem; border-radius:var(--r-s); background:var(--zeile); border:1px solid var(--rand); font-size:.9rem; }
.ja { color:var(--ok); font-weight:500; }

/* Formulare */
label { display:block; margin:.7rem 0 .25rem; font-weight:500; }
label.haken { display:flex; gap:.5rem; align-items:center; font-weight:normal; margin-top:.8rem; }
input, select, textarea { font:inherit; padding:.5rem .65rem; border:1px solid var(--rand-stark); border-radius:var(--r-s); width:100%; background:var(--flaeche); color:inherit; min-height:2.5rem; }
input::placeholder { color:var(--leise); opacity:.8; }
input:focus-visible, select:focus-visible { outline:3px solid var(--fokus); outline-offset:1px; }
input[type=checkbox] { width:1.15rem; height:1.15rem; min-height:0; accent-color:var(--akzent); }
fieldset { border:none; padding:0; margin:.6rem 0; }
legend { font-weight:500; margin-bottom:.25rem; padding:0; }
fieldset input { margin:.25rem 0; }
.adresse { display:flex; align-items:center; gap:.4rem; }
.adresse input { flex:1 1 auto; min-width:0; }
.adresse select { flex:0 1 auto; width:auto; }

/* Knöpfe */
button, .knopf { display:inline-flex; align-items:center; justify-content:center; gap:.45rem; font:inherit; font-weight:600; padding:.5rem 1.05rem; min-height:2.5rem;
                 border-radius:var(--r-s); border:1px solid var(--akzent); background:var(--akzent); color:var(--auf-akzent); cursor:pointer; text-decoration:none;
                 transition:background .12s, border-color .12s; }
/* Hover dunkelt mit festen Farben ab statt per filter: brightness() aufzuhellen, damit die Schrift in beiden
   Schemata bei mindestens 4,5:1 bleibt (tests/test_oberflaeche.py rechnet nach). :where() hält die Spezifität
   niedrig, damit eigene Knöpfe (.symbolknopf, .meldung-zu) ihr :hover behalten. */
button:hover, .knopf:hover { text-decoration:none; }
:where(button:not(.leise, .zweit, .gefahr, .gefahr-voll, [disabled]),
       .knopf:not(.leise, .zweit, .gefahr, [aria-disabled=true])):hover { background:var(--akzent-hover); border-color:var(--akzent-hover); }
button[disabled], .knopf[aria-disabled=true] { opacity:.55; cursor:not-allowed; }
button.leise, .knopf.leise { background:transparent; color:var(--akzent-text); border-color:transparent; }
button.leise:hover, .knopf.leise:hover { background:var(--akzent-hell); }
.knopf.zweit, button.zweit { background:var(--flaeche); color:var(--text); border-color:var(--rand-stark); }
.knopf.zweit:hover, button.zweit:hover { background:var(--zeile); }
.knopf.gefahr, button.gefahr { background:transparent; color:var(--gefahr); border-color:var(--gefahr); }
button.gefahr-voll { background:var(--gefahr-knopf); border-color:var(--gefahr-knopf); color:var(--auf-gefahr); }
.knopf.gefahr:hover, button.gefahr:hover { background:var(--gefahr-hell); }
button.gefahr-voll:not([disabled]):hover { background:var(--gefahr-knopf-hover); border-color:var(--gefahr-knopf-hover); }
button.leise.gefahr { border-color:transparent; }
.aktionen { display:flex; flex-wrap:wrap; gap:.75rem 1rem; align-items:center; margin-top:var(--a4); }
.gefahrzone { border-color:var(--gefahr); }
.gefahrzone h2, .gefahrzone h1 { color:var(--gefahr); }

/* Meldungen */
.meldungen { display:grid; gap:.5rem; margin:var(--a3) 0 0; }
.meldung { display:flex; gap:.6rem; align-items:flex-start; padding:.7rem .95rem; border-radius:var(--r-m); border:1px solid currentColor; margin:var(--a3) 0 0; }
.meldungen .meldung { margin:0; }
.meldung > .ic { margin-top:.2em; }
.meldung > span, .meldung > div { flex:1; min-width:0; }
.meldung p { margin:0; }
.meldung.ok { color:var(--ok); background:var(--ok-hell); }
.meldung.fehler { color:var(--gefahr); background:var(--gefahr-hell); }
.meldung.info { color:var(--akzent-text); background:var(--akzent-hell); }
.meldung.warn { color:var(--warn); background:var(--warn-hell); }
.meldung > span, .meldung > div, .meldung a { color:var(--text); }
.meldung a { text-decoration:underline; }

.qr { width:12rem; height:12rem; display:block; margin:.6rem 0; background:#fff; padding:.4rem; border-radius:var(--r-s); }
.geheim { font-family:var(--mono); font-size:1.05rem; letter-spacing:.04em; background:var(--zeile); border:1px solid var(--rand); border-radius:var(--r-s);
          padding:.5rem .7rem; overflow-wrap:anywhere; user-select:all; }
ol.codes { columns:2; column-gap:1.5rem; font-family:var(--mono); padding-left:1.8rem; }
ol.codes li { padding:.1rem 0; white-space:nowrap; }
.webauthn-status:empty { display:none; }
.webauthn-status { color:var(--gefahr); }
details { margin-top:var(--a4); }
summary { cursor:pointer; color:var(--akzent-text); }

@media (max-width: 72rem) { .wer .name { display:none; } }


/* Mit Skript (ui.js): Passwortfeld, Stärke, Toasts, Dialog, Fehlertexte */
[hidden] { display:none !important; }
.js-nur { display:none; }   /* erst sichtbar, wenn ui.js vollständig gestartet ist (html.ui) */
html.ui .js-nur { display:revert; }
html.ui .aktionen.js-nur { display:flex; }
html.ui p.js-nur button { display:inline-flex; }
.pwfeld { position:relative; }
.pwfeld input { padding-right:2.9rem; }
.pwfeld .pw-zeigen { position:absolute; right:.15rem; top:50%; transform:translateY(-50%); width:2.2rem; height:2.2rem; }
.staerke { margin:.35rem 0 .2rem; }
.staerke-balken { display:grid; grid-template-columns:repeat(4, 1fr); gap:.3rem; }
.staerke-balken span { height:.35rem; border-radius:999px; background:var(--rand); transition:background .2s; }
.staerke[data-stufe="1"] .staerke-balken span:nth-child(-n+1) { background:var(--gefahr); }
.staerke[data-stufe="2"] .staerke-balken span:nth-child(-n+2) { background:var(--warn); }
.staerke[data-stufe="3"] .staerke-balken span:nth-child(-n+3) { background:var(--ok); }
.staerke[data-stufe="4"] .staerke-balken span { background:var(--ok); }
.staerke-text, .gleich-text { margin:.25rem 0 0; min-height:1.3em; }
.vorschlag { padding-left:0; padding-right:0; min-height:0; font-weight:500; }
.fehlertext { color:var(--gefahr); font-size:.88rem; margin:.25rem 0 0; }
input[aria-invalid=true], select[aria-invalid=true] { border-color:var(--gefahr); box-shadow:0 0 0 1px var(--gefahr); }
input.filter { margin:.4rem 0 .8rem; }
a[aria-disabled=true] { opacity:.55; cursor:not-allowed; }
.codes + .aktionen { margin-top:var(--a2); }

.toasts { position:fixed; z-index:50; top:calc(var(--nav-hoehe) + .6rem); right:1rem; width:min(26rem, calc(100vw - 2rem)); margin:0; pointer-events:none; }
.toasts .meldung { pointer-events:auto; background:var(--erhoben); box-shadow:0 6px 24px rgba(0,0,0,.18); border-color:currentColor; animation:toast-ein .2s ease-out; transition:opacity .35s; }
.toasts .meldung.ok { background:var(--ok-hell); }
.toasts .meldung.fehler { background:var(--gefahr-hell); }
.toasts .meldung.info { background:var(--akzent-hell); }
.toasts .meldung.weg { opacity:0; }
.meldung-zu { width:1.9rem; height:1.9rem; min-height:0; padding:0; margin:-.2rem -.3rem -.2rem 0; border-radius:var(--r-s); border:none; background:transparent; color:var(--text); flex:none; }
.meldung-zu:hover { background:rgba(127,127,127,.2); filter:none; }
.meldung-zu .ic { width:1.1em; height:1.1em; }
@keyframes toast-ein { from { opacity:0; transform:translateY(-.5rem); } to { opacity:1; transform:none; } }

dialog.bestaetigung { border:1px solid var(--gefahr); border-radius:var(--r-m); padding:1.2rem 1.4rem; background:var(--flaeche); color:var(--text); width:min(26rem, calc(100vw - 2rem)); box-shadow:0 12px 40px rgba(0,0,0,.35); }
dialog.bestaetigung::backdrop { background:rgba(10,14,20,.55); backdrop-filter:blur(2px); }
dialog.bestaetigung h2 { color:var(--gefahr); margin-top:0; }
dialog.bestaetigung .aktionen { justify-content:flex-end; }

/* Fehlerseiten, Anmeldung */
.fehlerseite { text-align:center; }
.fehlerseite .ic.gross { width:3rem; height:3rem; color:var(--warn); }
.fehlerseite .aktionen { justify-content:center; }
.fehlercode { color:var(--leise); font-size:.85rem; letter-spacing:.06em; text-transform:uppercase; margin:.3rem 0 0; }
tr.klickbar { cursor:pointer; }

/* Handy: Navigation als untere Leiste, Kopfleiste schlank */
@media (max-width: 44rem) {
  :root { --nav-hoehe:3.1rem; }
  body { padding-bottom:4.4rem; }
  .kopfleiste-innen { padding:.4rem .9rem; gap:var(--a2); }
  nav.haupt { position:fixed; left:0; right:0; bottom:0; margin:0; gap:0; justify-content:space-around; z-index:30;
              background:var(--flaeche); border-top:1px solid var(--rand); padding:.3rem .25rem calc(.3rem + env(safe-area-inset-bottom)); }
  nav.haupt a { flex-direction:column; gap:.1rem; font-size:.7rem; padding:.3rem .2rem; flex:1; justify-content:center; text-align:center; min-width:0; border-radius:var(--r-m); }
  nav.haupt a .ic { width:1.45rem; height:1.45rem; }
  .wer .name { display:none; }
  main { padding:.25rem .75rem 2rem; }
  .karte { padding:1rem; }
  .karte.schmal, .karte.mittel { margin:var(--a4) auto; }
  table.liste .breit { display:none; }
  table.liste td, table.liste th { padding:.6rem .6rem; }
  ol.codes { columns:1; }
  .aktionen > button, .aktionen > .knopf { flex:1 1 auto; }
  .toasts { top:auto; bottom:calc(4.6rem + env(safe-area-inset-bottom)); right:.75rem; left:.75rem; width:auto; }
}
@media (max-width: 24rem) { nav.haupt a span { font-size:.64rem; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration:.01ms !important; animation-duration:.01ms !important; scroll-behavior:auto !important; }
}
@media (forced-colors: active) {
  .karte, table.liste, input, select, button, .knopf { border:1px solid CanvasText; }
  nav.haupt a[aria-current=page] { outline:2px solid Highlight; }
}
@media print {
  .kopfleiste, nav.haupt, .aktionen, .sprunglink, .fuss { display:none; }
  body { background:#fff; color:#000; padding:0; }
  .karte { box-shadow:none; border-color:#999; }
}
