/* ==========================================================================
   Atemschutzüberwachung – Gestaltung
   Dunkel, kontraststark, große Schrift und Tasten (Bedienung mit Handschuhen).
   ========================================================================== */

:root {
  --hg: #0b0d10;            /* Hintergrund */
  --flaeche: #161a20;       /* Karten, Bereiche */
  --flaeche2: #1f252d;      /* Tasten, Felder */
  --flaeche3: #2a323c;      /* Tasten gedrückt / hervorgehoben */
  --rand: #333c47;
  --text: #f3f5f8;
  --text2: #aab4c2;
  --text3: #7d8796;

  --primaer: #2f6fd6;
  --primaer-hell: #4d8bf0;
  --ok: #1f9d55;
  --warn: #f5b400;
  --warn-text: #1a1400;
  --alarm: #e5262b;
  --alarm-dunkel: #7a0d10;

  --radius: 12px;
  --abstand: 14px;
  --tastenhoehe: 56px;

  --sicher-oben: env(safe-area-inset-top, 0px);
  --sicher-unten: env(safe-area-inset-bottom, 0px);
  --sicher-links: env(safe-area-inset-left, 0px);
  --sicher-rechts: env(safe-area-inset-right, 0px);

  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  font-size: 18px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--hg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.35;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body { overflow: hidden; }

h1, h2, h3 { margin: 0; font-weight: 700; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.05rem; color: var(--text2); text-transform: uppercase; letter-spacing: .04em; }

.zahl { font-variant-numeric: tabular-nums; }

/* ---------- Grundgerüst ---------- */
#app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: var(--sicher-oben) var(--sicher-rechts) 0 var(--sicher-links);
}

.laden { padding: 40px; color: var(--text2); font-size: 1.2rem; text-align: center; }

/* ---------- Tasten ---------- */
button, .taste, .karte, .chip {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}

.taste {
  min-height: var(--tastenhoehe);
  padding: 0 20px;
  border: 2px solid var(--rand);
  border-radius: var(--radius);
  background: var(--flaeche2);
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  line-height: 1.15;
}
.taste:active { background: var(--flaeche3); transform: translateY(1px); }
.taste:focus-visible, .karte:focus-visible, .chip:focus-visible { outline: 3px solid var(--primaer-hell); outline-offset: 2px; }
.taste[disabled] { opacity: .45; cursor: default; }

.taste.primaer { background: var(--primaer); border-color: var(--primaer); color: #fff; }
.taste.primaer:active { background: #2559ad; }
.taste.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.taste.gefahr { background: var(--alarm); border-color: var(--alarm); color: #fff; }
.taste.gefahr:active { background: #b81d21; }
.taste.umriss-gefahr { border-color: var(--alarm); color: #ff8a8d; background: transparent; }
.taste.gross { min-height: 72px; font-size: 1.2rem; }
.taste.riesig { min-height: 88px; font-size: 1.45rem; width: 100%; }
.taste.symbol { padding: 0 14px; min-width: var(--tastenhoehe); }
.taste svg { flex: none; }

/* ---------- Kopfzeile ---------- */
.kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 10px var(--abstand);
  background: var(--flaeche);
  border-bottom: 1px solid var(--rand);
}
.kopf-einsatz { display: flex; align-items: center; gap: 16px; min-width: 0; }
.kopf-uhr {
  font-size: 2.3rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: .01em;
  line-height: 1;
}
.kopf-info { display: flex; flex-direction: column; min-width: 0; }
.kopf-label { color: var(--text2); font-size: .85rem; }
.kopf-ort {
  font-size: 1.05rem; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 38vw;
}
.kopf-tasten { display: flex; gap: 10px; flex-wrap: wrap; }
.kopf-tasten .taste.aus { color: var(--warn); border-color: var(--warn); }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px var(--abstand);
  background: #242a33;
  border-bottom: 1px solid var(--rand);
  font-weight: 600;
}

/* ---------- Stand 2: Ergänzungen (Zettel-Ablauf) ---------- */
.kopf-titel { font-size: .8rem; font-weight: 700; color: var(--text2); text-transform: uppercase; letter-spacing: .05em; }
.taste.klein { min-height: 48px; padding: 0 14px; font-size: .95rem; }
.taste.warn-umriss { border-color: var(--warn); color: var(--warn); background: transparent; }
.taste.wecker-taste { flex-direction: column; gap: 0; min-width: 96px; font-size: 1.15rem; }
.taste.wecker-taste small { font-size: .72rem; font-weight: 600; color: var(--warn); text-transform: uppercase; letter-spacing: .03em; }
.taste.wecker-taste.gewaehlt { background: var(--primaer); border-color: var(--primaer-hell); color: #fff; }
.taste.wecker-taste.gewaehlt small { color: #fff; }
.wecker-wahl { display: flex; flex-wrap: wrap; gap: 10px; }
.feld > span svg { vertical-align: -5px; margin-right: 4px; }

.badge-sicherung {
  align-self: flex-start;
  display: inline-block;
  margin-top: 2px;
  padding: 3px 10px;
  border-radius: 6px;
  background: #2b2a12;
  border: 2px solid var(--warn);
  color: var(--warn);
  font-size: .78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.karte.notfall .badge-sicherung { color: #fff; border-color: #fff; background: transparent; }
.karte-rueckzug { font-size: .95rem; color: var(--text2); }
.karte-rueckzug b { color: var(--text); font-variant-numeric: tabular-nums; }
.karte.notfall .karte-rueckzug, .karte.notfall .karte-rueckzug b { color: #fff; }
.karte-ort { overflow-wrap: anywhere; }

.detail-uhr-zeile { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.detail-druck { font-size: 3rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; margin-bottom: 4px; }
.detail-druck small { font-size: 1rem; color: var(--text2); font-weight: 600; margin-left: 6px; }
.detail-druck.niedrig { color: #ff7a7e; }

.abschnitt-kopf { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.angaben { display: grid; gap: 0; margin-bottom: 10px; }
.angabe {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--rand);
  min-height: 48px;
}
.angabe-titel { color: var(--text2); font-size: .9rem; }
.angabe-wert { font-size: 1.05rem; font-weight: 600; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.geprueft { color: #43d17f; font-weight: 700; margin-left: 6px; white-space: nowrap; }
.nicht-geprueft { color: var(--warn); font-weight: 700; margin-left: 6px; white-space: nowrap; }
.mitglied { grid-template-columns: auto minmax(0, 1fr); }
.rueckzugsdruck .rz-zeile { flex-basis: 100%; color: var(--text2); font-size: .95rem; }
.hinweis-warn { color: var(--warn); font-weight: 600; margin: 0; }

/* Schalter Sicherungstrupp + Haken Funkgruppe geprüft */
.td-oben { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; align-items: end; }
@media (max-width: 640px) { .td-oben { grid-template-columns: minmax(0, 1fr); } }
.schalter, .haken {
  display: inline-flex; align-items: center; gap: 12px;
  min-height: var(--tastenhoehe); padding: 0 16px;
  border: 2px solid var(--rand); border-radius: var(--radius);
  background: var(--flaeche2); color: var(--text);
  font-size: 1.05rem; font-weight: 600; text-align: left;
  touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
.schalter-knopf { position: relative; flex: none; width: 52px; height: 30px; border-radius: 999px; background: var(--flaeche3); border: 2px solid var(--rand); }
.schalter-knopf::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--text2); transition: left .15s; }
.schalter.an { border-color: var(--warn); }
.schalter.an .schalter-knopf { background: var(--warn); border-color: var(--warn); }
.schalter.an .schalter-knopf::after { left: 25px; background: #1a1400; }
.haken { width: 100%; }
.haken-kasten {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px; border: 3px solid var(--text2);
  font-size: 1.3rem; font-weight: 900;
}
.haken.an { border-color: #1f9d55; }
.haken.an .haken-kasten { background: var(--ok); border-color: var(--ok); color: #fff; }
@media (prefers-reduced-motion: reduce) { .schalter-knopf::after { transition: none; } }

.td-mitglied { grid-template-columns: auto minmax(0, 1.3fr) minmax(0, 1fr) auto; }
@media (max-width: 640px) {
  .td-mitglied { grid-template-columns: auto minmax(0, 1fr) auto; }
  .td-mitglied .td-m-ff { grid-column: 2 / 3; }
}

/* Druckeingabe: ein Wert */
.dz-feld.dz-einzel { grid-template-areas: "name wert" "letzt wert"; grid-template-columns: minmax(0, 1fr) auto; min-height: 110px; }
.dz-feld.dz-einzel .dz-wert { font-size: 3.4rem; }
.vorschau {
  padding: 12px 16px; border-radius: 12px;
  border: 2px solid var(--primaer-hell); background: #142034;
  font-size: 1.15rem; display: grid; gap: 4px;
}
.vorschau b { font-variant-numeric: tabular-nums; }
.vorschau.sofort { border-color: var(--alarm); background: #2a1214; color: #ffb3b5; }
.vorschau.leer { border-style: dashed; border-color: var(--rand); background: transparent; color: var(--text2); font-size: 1rem; }

/* Graue Tabelle */
.tabelle-rahmen { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.grau-tabelle { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; background: #2a2f36; }
table.grau-tabelle th, table.grau-tabelle td { border: 1px solid #4a525c; padding: 10px 8px; text-align: center; font-size: 1.1rem; }
table.grau-tabelle tr:first-child th { background: #3a414a; }
table.grau-tabelle th.kopfspalte { text-align: left; white-space: nowrap; font-size: .95rem; color: var(--text2); background: #23282e; }
.zettel-regeln { margin: 0; padding-left: 1.2em; color: var(--text2); display: grid; gap: 4px; }

/* ---------- Hauptbereich: Karten + Detail ---------- */
.haupt {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: var(--abstand);
  padding: var(--abstand) var(--abstand) 0;
  min-height: 0;
  overflow: hidden;
}

.karten {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--abstand);
  align-content: start;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 4px calc(var(--abstand) + var(--sicher-unten));
  min-height: 0;
}

.detail {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 18px 18px calc(24px + var(--sicher-unten));
}

/* Hochformat: Karten oben, Detail darunter, alles scrollt gemeinsam */
@media (orientation: portrait) {
  .haupt {
    display: block;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(var(--abstand) + var(--sicher-unten));
  }
  .karten { overflow: visible; padding-bottom: var(--abstand); }
  .detail { overflow: visible; border-radius: var(--radius); }
}
@media (orientation: portrait) and (min-width: 900px) {
  .karten { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .karten { grid-template-columns: minmax(0, 1fr); }
  .kopf-uhr { font-size: 1.8rem; }
}

/* ---------- Trupp-Karte ---------- */
.karte {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 190px;
  padding: 14px 16px;
  background: var(--flaeche);
  border: 3px solid var(--rand);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
}
.karte:active { background: var(--flaeche2); }
.karte.gewaehlt { box-shadow: 0 0 0 3px var(--primaer-hell); }
.karte-kopf { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.karte-name { font-size: 1.15rem; font-weight: 700; line-height: 1.2; min-width: 0; overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; }
.karte-uhr {
  font-size: 3.2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: .01em;
  margin: 4px 0 2px;
}
.karte-werte { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 1rem; color: var(--text2); }
.karte-werte b { color: var(--text); font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.karte-kontrolle { font-size: .95rem; color: var(--text2); font-variant-numeric: tabular-nums; }
.karte-kontrolle.faellig { color: var(--warn); font-weight: 700; }
.karte-warnung { font-weight: 700; font-size: 1rem; min-height: 0; }
.karte-warnung:empty { display: none; }
.karte-mitglieder { margin-top: auto; color: var(--text3); font-size: .9rem; overflow-wrap: anywhere; }

.karte.status-bereit .karte-uhr { color: var(--text3); }
.karte.status-beendet { opacity: .6; }
.karte.status-beendet .karte-uhr { color: var(--text2); }

.karte.neu {
  align-items: center; justify-content: center;
  border-style: dashed; color: var(--text2);
  font-size: 1.2rem; font-weight: 600;
  min-height: 190px;
}
.karte.neu .plus { font-size: 2.6rem; line-height: 1; }

/* Warnstufen */
.karte.stufe-warn { border-color: var(--warn); }
.karte.stufe-warn .karte-warnung { color: var(--warn); }
.karte.stufe-alarm { border-color: var(--alarm); background: #2a1214; }
.karte.stufe-alarm .karte-warnung { color: #ff7a7e; }
.karte.notfall { background: var(--alarm); border-color: #fff; color: #fff; }
.karte.notfall .karte-werte, .karte.notfall .karte-kontrolle,
.karte.notfall .karte-mitglieder, .karte.notfall .karte-warnung,
.karte.notfall .karte-werte b { color: #fff; }

@keyframes alarm-rahmen {
  0%, 49% { border-color: var(--alarm); box-shadow: 0 0 0 3px rgba(229, 38, 43, .55); }
  50%, 100% { border-color: #5a1416; box-shadow: none; }
}
@keyframes notfall-flaeche {
  0%, 49% { background: var(--alarm); }
  50%, 100% { background: var(--alarm-dunkel); }
}
.karte.stufe-alarm:not(.notfall) { animation: alarm-rahmen 1s steps(1) infinite; }
.karte.notfall { animation: notfall-flaeche 1s steps(1) infinite; }

@media (prefers-reduced-motion: reduce) {
  .karte.stufe-alarm:not(.notfall), .karte.notfall, .warnliste li.alarm { animation: none !important; }
  .karte.stufe-alarm:not(.notfall) { border-width: 5px; box-shadow: 0 0 0 3px rgba(229, 38, 43, .55); }
}

/* Status-Kennzeichen */
.status-chip {
  flex: none;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .03em;
  text-transform: uppercase;
  border: 2px solid currentColor;
  white-space: nowrap;
}
.status-chip.bereit { color: #9aa5b4; }
.status-chip.anmarsch { color: #6fa8ff; }
.status-chip.ziel { color: #43d17f; }
.status-chip.rueckzug { color: #d6a2ff; }
.status-chip.beendet { color: #7d8796; }
.karte.notfall .status-chip { color: #fff; }

/* ---------- Detailbereich ---------- */
.detail-leer { text-align: center; padding: 40px 10px; color: var(--text2); }
.detail-leer p { font-size: 1.15rem; }

.detail-kopf { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.detail-name { font-size: 1.6rem; font-weight: 700; overflow-wrap: anywhere; }
.detail-auftrag { color: var(--text2); margin-top: 2px; overflow-wrap: anywhere; }
.detail-uhr {
  font-size: 4.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  margin: 14px 0 4px;
}
.detail-unterzeile { color: var(--text2); font-variant-numeric: tabular-nums; }
.detail-unterzeile.faellig { color: var(--warn); font-weight: 700; }

.notfall-banner {
  margin: 14px 0 0;
  padding: 14px 16px;
  background: var(--alarm);
  color: #fff;
  border-radius: var(--radius);
  font-size: 1.3rem;
  font-weight: 800;
  text-align: center;
  letter-spacing: .03em;
}

.warnliste { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.warnliste:empty { display: none; }
.warnliste li {
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1.05rem;
}
.warnliste li.warn { background: var(--warn); color: var(--warn-text); }
.warnliste li.alarm { background: var(--alarm); color: #fff; }

.abschnitt { margin-top: 20px; }
.abschnitt > h3 { margin-bottom: 8px; }

.mitglieder { display: grid; gap: 8px; }
.mitglied {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--flaeche2);
  border-radius: 10px;
}
.rolle {
  display: inline-block;
  min-width: 44px;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--flaeche3);
  font-weight: 800;
  font-size: .9rem;
  text-align: center;
}
.m-name { font-size: 1.15rem; font-weight: 600; overflow-wrap: anywhere; }
.m-name small { display: block; color: var(--text3); font-weight: 400; font-size: .85rem; }
.m-druck { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; line-height: 1; }
.m-druck small { font-size: .9rem; color: var(--text2); font-weight: 600; }
.m-druck.niedrig { color: #ff7a7e; }

.rueckzugsdruck {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  margin-top: 10px; padding: 12px 14px;
  border: 2px solid var(--rand); border-radius: 10px;
}
.rueckzugsdruck b { font-size: 1.8rem; font-variant-numeric: tabular-nums; }
.rueckzugsdruck.offen { color: var(--text2); border-style: dashed; }

/* Fortschrittsbalken Einsatzzeit */
.balken-rahmen { margin-top: 6px; }
.balken {
  position: relative;
  height: 26px;
  background: var(--flaeche2);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--rand);
}
.balken-fuell { height: 100%; width: 0; background: var(--primaer); transition: width .8s linear; }
.balken-fuell.warn { background: var(--warn); }
.balken-fuell.alarm { background: var(--alarm); }
.balken .marke { position: absolute; top: 0; bottom: 0; width: 3px; margin-left: -1.5px; background: var(--text); opacity: .85; }
.balken .marke.klein { width: 1px; margin-left: -.5px; opacity: .35; }
.balken-skala { position: relative; height: 22px; margin-top: 4px; color: var(--text2); font-size: .85rem; font-variant-numeric: tabular-nums; }
.balken-skala span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.balken-skala span.links { transform: none; left: 0; }
.balken-skala span.rechts { transform: none; right: 0; }
@media (prefers-reduced-motion: reduce) { .balken-fuell { transition: none; } }

.aktionen { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 18px; }
.aktionen .taste { width: 100%; }
.aktionen .breit { grid-column: 1 / -1; }

.zeiten { display: flex; flex-wrap: wrap; gap: 4px 18px; color: var(--text2); font-size: .95rem; font-variant-numeric: tabular-nums; }
.zeiten b { color: var(--text); }

table.verlauf { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.verlauf th, table.verlauf td { padding: 8px 6px; text-align: left; border-bottom: 1px solid var(--rand); }
table.verlauf th { color: var(--text2); font-size: .85rem; font-weight: 600; }
table.verlauf td.r, table.verlauf th.r { text-align: right; }
.leer-hinweis { color: var(--text3); }

/* ---------- Startbildschirm ---------- */
.start {
  grid-row: 1 / -1;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + var(--sicher-unten));
}
.start-karte {
  width: 100%;
  max-width: 560px;
  display: grid;
  gap: 16px;
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 18px;
  padding: 28px;
  grid-template-columns: minmax(0, 1fr);   /* lange Wörter dürfen die Karte nicht sprengen */
}
.start-kopf { display: flex; align-items: center; gap: 16px; }
.start-kopf > * { min-width: 0; }
.start-kopf h1 { font-size: 1.8rem; overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; }
@media (max-width: 480px) { .start-karte { padding: 18px; } .start-kopf h1 { font-size: 1.3rem; } }
.start-kopf p { margin: 2px 0 0; color: var(--text2); }
.start-symbol { flex: none; color: var(--alarm); }
.start-unten { display: flex; gap: 10px; flex-wrap: wrap; }
.start-unten .taste { flex: 1 1 140px; }

.hinweis { color: var(--text3); font-size: .9rem; margin: 0; }

/* ---------- Formularfelder ---------- */
.feld { display: grid; gap: 6px; }
.feld > span { color: var(--text2); font-size: .95rem; font-weight: 600; }
input[type="text"], input[type="number"], input:not([type]), textarea {
  font: inherit;
  font-size: 1.15rem;
  color: var(--text);
  background: var(--flaeche2);
  border: 2px solid var(--rand);
  border-radius: 10px;
  min-height: var(--tastenhoehe);
  padding: 10px 14px;
  width: 100%;
}
textarea { min-height: 140px; resize: vertical; }
input:focus, textarea:focus { outline: none; border-color: var(--primaer-hell); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: var(--tastenhoehe);
  padding: 0 16px;
  border-radius: 999px;
  border: 2px solid var(--rand);
  background: var(--flaeche2);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
}
.chip:active { background: var(--flaeche3); }
.chip.gewaehlt { border-color: var(--primaer-hell); background: #1b2c48; }
.chip .weg { margin-left: 8px; color: var(--text3); }

.fehler { color: #ff8a8d; font-weight: 700; margin: 0; min-height: 1.35em; white-space: pre-line; }
.fehler:empty { min-height: 0; }

/* ---------- Dialoge ---------- */
.ebene {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, .72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(12px + var(--sicher-oben)) calc(12px + var(--sicher-rechts)) calc(12px + var(--sicher-unten)) calc(12px + var(--sicher-links));
}
.ebene[hidden] { display: none; }
#bestaetigung { z-index: 60; }

.dlg {
  width: 100%;
  max-width: 640px;
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--flaeche);
  border: 2px solid var(--rand);
  border-radius: 16px;
  padding: 22px;
  display: grid;
  gap: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}
.dlg.breit { max-width: 860px; }
.dlg.klein { max-width: 520px; }
.dlg.gefahr { border-color: var(--alarm); }
.dlg p { margin: 0; }
.dlg .text { font-size: 1.1rem; white-space: pre-line; }
.dlg-tasten { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; margin-top: 4px; }
.dlg-tasten .taste { flex: 1 1 160px; }

/* Trupp-Dialog */
.td-mitglied {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 2px solid transparent;
  border-radius: 12px;
}
.td-mitglied.aktiv { border-color: var(--primaer-hell); background: #142034; }
.td-druck { display: flex; align-items: center; gap: 6px; }
.td-druck input { width: 96px; text-align: center; font-variant-numeric: tabular-nums; padding: 10px 6px; }
.td-druck span { color: var(--text2); }
@media (max-width: 640px) {
  .td-mitglied { grid-template-columns: auto minmax(0, 1fr); }
  .td-druck { grid-column: 1 / -1; }
}

/* Druckeingabe */
.dz-raster { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: 18px; }
@media (max-width: 760px) { .dz-raster { grid-template-columns: minmax(0, 1fr); } }
.dz-felder { display: grid; gap: 10px; align-content: start; }
.dz-feld {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "rolle name wert" "rolle letzt wert";
  align-items: center;
  column-gap: 12px;
  padding: 12px 14px;
  min-height: 84px;
  background: var(--flaeche2);
  border: 3px solid var(--rand);
  border-radius: 12px;
  text-align: left;
}
.dz-feld.aktiv { border-color: var(--primaer-hell); background: #142034; }
.dz-feld .rolle { grid-area: rolle; }
.dz-name { grid-area: name; font-size: 1.15rem; font-weight: 700; overflow-wrap: anywhere; }
.dz-letzt { grid-area: letzt; color: var(--text2); font-size: .9rem; }
.dz-wert { grid-area: wert; font-size: 2.6rem; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 3.2ch; text-align: right; line-height: 1; }
.dz-wert small { font-size: .9rem; color: var(--text2); font-weight: 600; margin-left: 4px; }
.dz-wert.leer { color: var(--text3); }
.dz-schnell-titel { color: var(--text2); font-size: .9rem; font-weight: 600; margin-top: 4px; }
.dz-schnell { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.dz-schnell .taste { padding: 0 4px; font-variant-numeric: tabular-nums; font-size: 1.15rem; }
.dz-tastatur { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; align-content: start; }
.dz-tastatur .taste { min-height: 76px; font-size: 1.9rem; font-weight: 700; padding: 0; }
.dz-tastatur .taste.klein-text { font-size: 1.1rem; }

/* Einstellungen */
.es-raster { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 640px) { .es-raster { grid-template-columns: minmax(0, 1fr); } }
.stepper { display: grid; grid-template-columns: var(--tastenhoehe) minmax(0, 1fr) var(--tastenhoehe); gap: 6px; }
.stepper input { text-align: center; font-variant-numeric: tabular-nums; padding: 10px 4px; }
.stepper .taste { padding: 0; font-size: 1.5rem; }
.zeile { display: flex; gap: 10px; }
.zeile > input { flex: 1; }
.rahmen-hinweis {
  padding: 12px 14px;
  border-left: 4px solid var(--warn);
  background: #221d0d;
  border-radius: 8px;
  color: #f1e3b8;
}

/* ---------- Protokoll-Ansicht ---------- */
#protokollleiste {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 40;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  padding: calc(10px + var(--sicher-oben)) calc(var(--abstand) + var(--sicher-rechts)) 10px calc(var(--abstand) + var(--sicher-links));
  background: var(--flaeche);
  border-bottom: 1px solid var(--rand);
}
#protokollleiste[hidden] { display: none; }
#protokollleiste .titel { font-size: 1.3rem; font-weight: 700; margin-right: auto; }

#druckbereich { display: none; }
body.protokoll-offen #druckbereich {
  display: block;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  top: var(--leistenhoehe, 90px);
  z-index: 30;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #fff;
  color: #111;
  padding: 24px calc(24px + var(--sicher-rechts)) calc(40px + var(--sicher-unten)) calc(24px + var(--sicher-links));
  -webkit-user-select: text;
  user-select: text;
}
#druckbereich table { border-collapse: collapse; width: 100%; margin: 8px 0 16px; }
#druckbereich th, #druckbereich td { border: 1px solid #999; padding: 4px 6px; text-align: left; vertical-align: top; }
#druckbereich h1, #druckbereich h2, #druckbereich h3 { color: #000; text-transform: none; letter-spacing: 0; }

/* ---------- Meldung (Toast) ---------- */
#meldung {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--sicher-unten));
  transform: translateX(-50%) translateY(20px);
  z-index: 70;
  max-width: min(90vw, 640px);
  padding: 14px 22px;
  border-radius: 12px;
  background: #e8ecf2;
  color: #10141a;
  font-weight: 700;
  font-size: 1.05rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
#meldung.sichtbar { opacity: 1; transform: translateX(-50%) translateY(0); }
#meldung.fehler-meldung { background: var(--alarm); color: #fff; }

/* ---------- Druck: nur das Protokoll, schwarz auf weiß ---------- */
@media print {
  @page { margin: 14mm; }
  html, body { height: auto; overflow: visible; background: #fff !important; color: #000 !important; font-size: 11pt; }
  body > *:not(#druckbereich) { display: none !important; }
  #druckbereich, body.protokoll-offen #druckbereich {
    display: block !important;
    position: static !important;
    overflow: visible !important;
    padding: 0 !important;
    background: #fff !important;
    color: #000 !important;
  }
  #druckbereich * { color: #000 !important; background: transparent !important; box-shadow: none !important; }
  #druckbereich table { page-break-inside: auto; }
  #druckbereich tr { page-break-inside: avoid; }
  #druckbereich th, #druckbereich td { border: 1px solid #000 !important; }
}
