html { -webkit-text-size-adjust: 100%; }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
body { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* Layout: Prüfprotokoll zum Abhaken. Klebende Kopfzeile mit Fortschritt, darunter Bereiche A–E als Abschnitte,
   jede Prüffrage als Zeile mit drei Ampel-Kriterien, die selbst die Auswahlknöpfe sind. Am Ende Zeitfresser-Rechnung und Auswertung. */
:root {
  --bg: #eef2f3;
  --surface: #ffffff;
  --sunken: #e4eaec;
  --ink: #13222a;
  --muted: #56676f;
  --line: #d2dbde;
  --accent: #0b6470;
  --accent-ink: #ffffff;
  --accent-soft: #d9ebed;
  --g: #2b8a4b; --g-soft: #e0f1e5;
  --y: #b97f00; --y-soft: #faefd0;
  --r: #bf3e2a; --r-soft: #f7e0db;
  --open: #9aa8ae;
  --font-display: "Archivo", "Arial Narrow", system-ui, sans-serif;
  --font-body: "Source Sans 3", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e171b; --surface: #15222a; --sunken: #1b2b33; --ink: #e4edf0; --muted: #91a3aa; --line: #2a3c44;
    --accent: #4fb2be; --accent-ink: #0b1a1f; --accent-soft: #163a41;
    --g: #58c27c; --g-soft: #163325; --y: #e6b13c; --y-soft: #392d0f; --r: #ee7660; --r-soft: #3c1d18; --open: #5f727a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e171b; --surface: #15222a; --sunken: #1b2b33; --ink: #e4edf0; --muted: #91a3aa; --line: #2a3c44;
  --accent: #4fb2be; --accent-ink: #0b1a1f; --accent-soft: #163a41;
  --g: #58c27c; --g-soft: #163325; --y: #e6b13c; --y-soft: #392d0f; --r: #ee7660; --r-soft: #3c1d18; --open: #5f727a;
  color-scheme: dark;
}

* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.5;
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
.wrap {
  max-width: 1080px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }

/* Kopfzeile */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5;
  background: var(--surface); border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; flex-direction: column; gap: 8px; padding-block: 10px; }
.topline { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.brand { font-family: var(--font-display); font-weight: 800; font-stretch: 112%; font-size: 15px; letter-spacing: .01em; }
.brand span { color: var(--accent); }
.client { color: var(--muted); font-size: 15px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 160px; }
.progress { font-family: var(--font-mono); font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.progress .bar { width: 90px; height: 6px; border-radius: 3px; background: var(--sunken); overflow: hidden; }
.progress .bar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }
.nav { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.nav::-webkit-scrollbar { display: none; }
.nav button {
  flex: none; border: 1px solid var(--line); background: var(--bg); border-radius: 999px;
  padding: 5px 12px 5px 10px; font-size: 13px; cursor: pointer; display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
.nav button:hover { border-color: var(--accent); }
.lamp { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--open); display: inline-block; }
.lamp.g { background: var(--g); } .lamp.y { background: var(--y); } .lamp.r { background: var(--r); }
.lamp.none { background: transparent; border: 1.5px solid var(--line); }

/* Hinweisband Beispiel */
.example-band { background: var(--y-soft); border-bottom: 1px solid var(--line); }
.example-band .wrap { padding-block: 10px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; font-size: 15px; }
.example-band p { margin: 0; flex: 1 1 280px; }

main { padding-block: 28px 64px; display: flex; flex-direction: column; gap: 40px; }

/* Kopf der Seite */
.intro { display: grid; gap: 10px; max-width: 70ch; }
.eyebrow { font-family: var(--font-mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.intro h1 { font-size: clamp(28px, 5vw, 42px); font-weight: 800; font-stretch: 108%; line-height: 1.08; }
.intro p { margin: 0; color: var(--muted); }
.legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* Abschnitte */
section.block { display: grid; gap: 14px; scroll-margin-top: 110px; }
.block-head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; border-bottom: 2px solid var(--ink); padding-bottom: 8px; }
.block-head h2 { font-size: clamp(20px, 3vw, 26px); font-weight: 750; font-stretch: 106%; flex: 1 1 260px; }
.block-head h2 .letter { color: var(--accent); margin-right: 8px; }
.block-head .stat { font-family: var(--font-mono); font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.block-intro { margin: 0; color: var(--muted); max-width: 72ch; }

/* Stammdaten */
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 16px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select, textarea, .tf input {
  width: 100%; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px;
}
.field input:focus, .field select:focus, textarea:focus, .tf input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.privacy-note { font-size: 13px; color: var(--muted); margin: 0; }

/* Prüfpunkte */
.items { display: grid; gap: 12px; }
.item {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; display: grid; gap: 10px; border-left: 5px solid var(--line);
}
.item[data-rating="g"] { border-left-color: var(--g); }
.item[data-rating="y"] { border-left-color: var(--y); }
.item[data-rating="r"] { border-left-color: var(--r); }
.item[data-rating="na"] { opacity: .62; }
.item-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.qid { font-family: var(--font-mono); font-size: 13px; color: var(--accent); font-weight: 500; }
.item-head h3 { font-size: 18px; font-weight: 650; flex: 1 1 240px; }
.tag { font-family: var(--font-mono); font-size: 11px; letter-spacing: .05em; text-transform: uppercase; border: 1px solid var(--line); border-radius: 4px; padding: 3px 8px; color: var(--muted); }
.hint { margin: 0; color: var(--muted); font-size: 15px; max-width: 80ch; }
.choices { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.choice {
  text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px 10px;
  cursor: pointer; display: grid; gap: 4px; align-content: start; font-size: 14.5px; line-height: 1.4;
}
.choice .lbl { display: flex; align-items: center; gap: 7px; font-family: var(--font-mono); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.choice .dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid currentColor; }
.choice.g .dot { color: var(--g); } .choice.y .dot { color: var(--y); } .choice.r .dot { color: var(--r); }
.choice:hover { border-color: var(--muted); }
.choice[aria-checked="true"].g { background: var(--g-soft); border-color: var(--g); }
.choice[aria-checked="true"].y { background: var(--y-soft); border-color: var(--y); }
.choice[aria-checked="true"].r { background: var(--r-soft); border-color: var(--r); }
.choice[aria-checked="true"] .dot { background: currentColor; }
.choice[aria-checked="true"] .lbl { color: var(--ink); font-weight: 500; }
.item-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toggle {
  border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 6px 14px; font-size: 13px; cursor: pointer; color: var(--muted);
}
.toggle[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.toggle.qw[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.leistung { margin-left: auto; font-size: 13px; color: var(--accent); font-weight: 600; text-align: right; }
.leistung::before { content: "→ "; }
textarea { resize: vertical; min-height: 40px; font-size: 15px; }

/* Zeitfresser */
.tf-settings { display: flex; gap: 16px; flex-wrap: wrap; }
.tf-settings .field { width: 180px; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table.tf { width: 100%; border-collapse: collapse; min-width: 640px; }
.tf th, .tf td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
.tf th { font-family: var(--font-mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 500; background: var(--sunken); }
.tf td.out, .tf th.out { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tf input[type="number"] { width: 90px; text-align: right; font-variant-numeric: tabular-nums; }
.tf tfoot td { font-weight: 700; border-bottom: 0; background: var(--sunken); }
.icon-btn { border: 1px solid transparent; background: transparent; cursor: pointer; color: var(--muted); border-radius: 6px; padding: 4px 8px; }
.icon-btn:hover { border-color: var(--line); color: var(--r); }

.btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 8px 14px; cursor: pointer; font-weight: 600; font-size: 15px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger[data-armed="true"] { background: var(--r); color: #fff; border-color: var(--r); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Auswertung */
.summary { display: grid; gap: 20px; }
.sum-top { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 760px) { .sum-top { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; align-content: start; min-width: 0; }
.panel h3 { font-size: 16px; font-weight: 700; font-stretch: 104%; }
.area-row { display: grid; grid-template-columns: 14px minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.area-row .name { min-width: 0; }
.area-row .counts { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.stack { grid-column: 2 / 4; height: 6px; display: flex; border-radius: 3px; overflow: hidden; background: var(--sunken); }
.stack i { display: block; height: 100%; }
.stack .r { background: var(--r); } .stack .y { background: var(--y); } .stack .g { background: var(--g); }
.big { font-family: var(--font-display); font-weight: 800; font-stretch: 110%; font-size: clamp(30px, 5vw, 40px); line-height: 1; font-variant-numeric: tabular-nums; }
.sub { color: var(--muted); font-size: 14px; margin: 0; }
.offer-list { display: grid; gap: 12px; }
.offer { border-top: 1px solid var(--line); padding-top: 10px; display: grid; gap: 6px; }
.offer:first-child { border-top: 0; padding-top: 0; }
.offer-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.offer-head strong { font-family: var(--font-display); font-size: 17px; font-stretch: 104%; }
.offer ul, .qw-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.offer li, .qw-list li { display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 8px; align-items: baseline; font-size: 15px; }
.offer li .lamp, .qw-list li .lamp { transform: translateY(1px); }
.offer li small, .qw-list li small { color: var(--muted); display: block; }
.callout { background: var(--r-soft); border: 1px solid var(--r); border-radius: var(--radius); padding: 10px 14px; font-size: 15px; }
.empty { color: var(--muted); font-size: 15px; margin: 0; }
.status { font-size: 14px; color: var(--muted); min-height: 1.5em; margin: 0; }
.status.err { color: var(--r); }
.copy-fallback { width: 100%; min-height: 160px; font-family: var(--font-mono); font-size: 13px; }
.rules { font-size: 13.5px; color: var(--muted); margin: 0; max-width: 80ch; }

@media (max-width: 640px) {
  .choices { grid-template-columns: 1fr; }
  .leistung { margin-left: 0; text-align: left; flex-basis: 100%; }
  .item { padding: 12px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
