:root {
  --akzent: #E2001A;
  --akzent-dunkel: #8E1018;
  --akzent-text: #C80018;
  --grau: #5C6971;
  --bg: #f2f2f7;
  --karte: #ffffff;
  --text: #1c1c1e;
  --text-2: #5C6971;
  --linie: rgba(60, 60, 67, 0.14);
  --material: rgba(242, 242, 247, 0.78);
  --chip: rgba(92, 105, 113, 0.12);
  --warn-bg: rgba(226, 0, 26, 0.08);
  --ok: #1f8a4c;
  --radius: 16px;
  --abstand: 16px;
  --tabs-hoehe: 56px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --akzent-text: #FF5468;
    --bg: #000000;
    --karte: #1c1c1e;
    --text: #f2f2f7;
    --text-2: #9aa5ab;
    --linie: rgba(235, 235, 245, 0.16);
    --material: rgba(18, 18, 20, 0.78);
    --chip: rgba(154, 165, 171, 0.18);
    --warn-bg: rgba(255, 84, 104, 0.14);
    --ok: #4cc380;
  }
}

* { box-sizing: border-box; }
html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  background: var(--bg);
}
body {
  margin: 0;
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button, a, [role="button"], summary, label.zeile { touch-action: manipulation; }
button, .tab, .knopf, .zeile-link, .zurueck, .segment button { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
input, textarea, select { font: inherit; font-size: 16px; color: var(--text); }
img.fluent { display: block; object-fit: contain; flex: none; }
.icon { flex: none; }
h1, h2, h3, p { margin: 0; }

/* ---------- Gerüst ---------- */
.app { min-height: 100dvh; }
.inhalt {
  min-height: 100dvh;
  padding: 0 var(--abstand) calc(var(--tabs-hoehe) + env(safe-area-inset-bottom, 0px) + 24px);
  padding-left: calc(var(--abstand) + env(safe-area-inset-left, 0px));
  padding-right: calc(var(--abstand) + env(safe-area-inset-right, 0px));
  max-width: 640px;
  margin: 0 auto;
  outline: none;
}

.kopf {
  position: sticky; top: 0; z-index: 5;
  margin: 0 calc(var(--abstand) * -1);
  padding: calc(env(safe-area-inset-top, 0px) + 10px) var(--abstand) 8px;
  background: var(--material);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  display: flex; align-items: center; gap: 12px; min-height: 52px;
}
.kopf-logo { width: 34px; height: auto; flex: none; }
.kopf h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.kopf .zurueck + h1 { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.titel-gross {
  font-size: 34px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1;
  padding: 8px 0 16px;
}
.zurueck {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; margin-left: -12px;
  color: var(--akzent-text); background: none; border: 0; border-radius: 22px;
  text-decoration: none; flex: none;
}
.zurueck:active { opacity: 0.45; }

/* ---------- Tab-Leiste ---------- */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(env(safe-area-inset-bottom, 0px) + 2px);
  padding-left: calc(4px + env(safe-area-inset-left, 0px));
  padding-right: calc(4px + env(safe-area-inset-right, 0px));
  background: var(--material);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border-top: 0.5px solid var(--linie);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 4px 0; min-height: 48px;
  font-size: 10.5px; font-weight: 500; letter-spacing: 0.01em;
  color: var(--text-2); text-decoration: none;
}
.tab img { filter: grayscale(1); opacity: 0.55; transition: filter 120ms ease-out, opacity 120ms ease-out, transform 120ms ease-out; }
.tab[aria-current="page"] { color: var(--akzent-text); }
.tab[aria-current="page"] img { filter: none; opacity: 1; }
.tab:active img { transform: scale(0.9); }

/* ---------- Karten ---------- */
.karte {
  background: var(--karte); border-radius: var(--radius);
  padding: var(--abstand); margin-bottom: 12px;
}
.karte-label {
  font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-2); margin-bottom: 6px;
}
.karte-jetzt { border-left: 4px solid var(--akzent); }
.karte-jetzt .karte-label { color: var(--akzent-text); }
.karte-titel { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; }
.karte-text { font-size: 17px; font-weight: 600; letter-spacing: -0.01em; }
.sub { color: var(--text-2); font-size: 15px; margin-top: 2px; }
.klein { color: var(--text-2); font-size: 14px; }
.gross-zahl { font-size: 40px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.karte-warn { background: var(--warn-bg); }
.karte-warn .karte-label { color: var(--akzent-text); }
.hinweis { display: flex; gap: 12px; align-items: flex-start; }
.hinweis + .hinweis { margin-top: 12px; padding-top: 12px; border-top: 0.5px solid var(--linie); }

.abschnitt { font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-2); margin: 24px 4px 8px; }

/* ---------- Listen ---------- */
.liste { background: var(--karte); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.zeile {
  display: flex; align-items: center; flex-wrap: wrap; column-gap: 12px; row-gap: 4px; min-height: 52px;
  padding: 11px var(--abstand); color: inherit; text-decoration: none;
  position: relative; background: none; border: 0; width: 100%; text-align: left; font: inherit;
}
.zeile + .zeile::before {
  content: ""; position: absolute; top: 0; left: var(--abstand); right: 0;
  border-top: 0.5px solid var(--linie);
}
.zeile-link:active, button.zeile:active, label.zeile:active { background: var(--chip); }
.zeile-haupt { flex: 1 1 0; min-width: min-content; }
.zeile-titel { font-weight: 500; overflow-wrap: break-word; }
.zeile-sub { color: var(--text-2); font-size: 14px; margin-top: 1px; overflow-wrap: break-word; }
.zeile-ende { display: flex; align-items: center; gap: 8px; margin-left: auto; max-width: 100%; flex: 0 1 auto; }
.zeile-wert { color: var(--text-2); text-align: right; font-size: 16px; overflow-wrap: break-word; min-width: 0; }
.zeile .icon.weiter { color: var(--text-2); opacity: 0.6; }
.zeit { width: 48px; flex: none; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 15px; }
.zeit small { display: block; font-weight: 400; color: var(--text-2); font-size: 13px; }
.durchgestrichen .zeile-titel, .durchgestrichen .zeit { text-decoration: line-through; color: var(--text-2); }
.durchgestrichen .zeile-sub::after { content: " · fällt aus"; text-decoration: none; display: inline-block; color: var(--akzent-text); }
.aktiv-zeile { background: var(--warn-bg); }

.chip {
  display: inline-block; font-size: 13px; font-weight: 600; padding: 3px 9px;
  border-radius: 999px; background: var(--chip); color: var(--text-2); white-space: nowrap;
}
.chip-akzent { background: var(--warn-bg); color: var(--akzent-text); }
.chip-ok { color: var(--ok); }

/* ---------- Segment ---------- */
.segment { display: flex; background: var(--chip); border-radius: 10px; padding: 2px; margin-bottom: 16px; }
.segment button {
  flex: 1; min-height: 34px; border: 0; background: none; border-radius: 8px;
  font: inherit; font-size: 15px; font-weight: 500; color: var(--text); cursor: pointer;
}
.segment button[aria-pressed="true"] { background: var(--karte); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,0.12); }

/* ---------- Knöpfe, Felder ---------- */
.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border: 0; border-radius: 14px;
  background: var(--akzent); color: #fff; font: inherit; font-weight: 600; cursor: pointer;
  transition: transform 100ms ease-out, opacity 100ms ease-out;
}
.knopf:active { transform: scale(0.97); opacity: 0.85; }
.knopf:disabled { opacity: 0.45; }
.knopf-gross { width: 100%; min-height: 52px; font-size: 17px; }
.knopf-sekundaer { background: var(--chip); color: var(--akzent-text); }
.knopf-text { background: none; color: var(--akzent-text); min-height: 44px; padding: 0 4px; }
.knopf-gefahr { background: var(--warn-bg); color: var(--akzent-text); }
.feld { display: block; margin-bottom: 16px; }
.feld > span { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin: 0 4px 6px; letter-spacing: 0.02em; text-transform: uppercase; }
.feld input, .feld textarea, .feld select {
  width: 100%; min-height: 48px; padding: 11px 14px; border: 1px solid var(--linie);
  border-radius: 12px; background: var(--karte); outline: none;
}
.feld textarea { min-height: 200px; resize: vertical; line-height: 1.4; }
.feld input:focus, .feld textarea:focus, .feld select:focus { border-color: var(--akzent); box-shadow: 0 0 0 3px var(--warn-bg); }
.meldung { min-height: 22px; margin-top: 12px; text-align: center; color: var(--ok); font-size: 15px; }
.meldung.fehler { color: var(--akzent-text); }
.aktionen { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.aktionen-reihe { display: flex; gap: 8px; }
.aktionen-reihe .knopf { flex: 1; min-height: 44px; }

/* Schalter */
.schalter { position: relative; width: 51px; height: 31px; flex: none; }
.schalter input { position: absolute; inset: 0; opacity: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; }
.schalter i { position: absolute; inset: 0; border-radius: 16px; background: var(--chip); transition: background 160ms ease-out; pointer-events: none; }
.schalter i::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,0.25); transition: transform 180ms cubic-bezier(0.3, 0.9, 0.3, 1);
}
.schalter input:checked + i { background: var(--akzent); }
.schalter input:checked + i::after { transform: translateX(20px); }

/* Aufklappbar */
details.klapp { background: var(--karte); border-radius: var(--radius); margin-bottom: 12px; }
details.klapp > summary {
  list-style: none; display: flex; align-items: center; justify-content: space-between;
  min-height: 52px; padding: 0 var(--abstand); font-weight: 600; cursor: pointer;
}
details.klapp > summary::-webkit-details-marker { display: none; }
details.klapp > summary::after {
  content: ""; width: 8px; height: 8px; border-right: 2px solid var(--text-2); border-bottom: 2px solid var(--text-2);
  transform: rotate(45deg); transition: transform 160ms ease-out; margin-right: 4px;
}
details.klapp[open] > summary::after { transform: rotate(-135deg); }
.klapp-inhalt { padding: 0 var(--abstand) var(--abstand); white-space: pre-line; overflow-wrap: anywhere; }
.klapp-inhalt ul { margin: 0; padding-left: 20px; white-space: normal; }
.klapp-inhalt li { margin-bottom: 4px; }

/* ---------- Leer / Laden ---------- */
.leer { text-align: center; padding: 56px 24px; }
.leer h2 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin: 16px 0 6px; }
.leer p { color: var(--text-2); }
.leer img { margin: 0 auto; }
.laden { text-align: center; color: var(--text-2); padding: 48px 0; }
.fehlerkarte { background: var(--warn-bg); color: var(--akzent-text); border-radius: var(--radius); padding: var(--abstand); margin: 16px 0; }

/* Ein-/Ausblenden der Seiten */
.seite { animation: ein 220ms ease-out; }
@keyframes ein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .seite { animation: none; }
  .schalter i, .schalter i::after, .knopf, .tab img, details.klapp > summary::after { transition: none; }
}
@media (prefers-reduced-transparency: reduce) {
  .kopf, .tabs { background: var(--bg); -webkit-backdrop-filter: none; backdrop-filter: none; }
}
@media (hover: hover) and (pointer: fine) {
  .zeile-link:hover, button.zeile:hover { background: var(--chip); }
  .knopf:hover { opacity: 0.9; }
}

/* ---------- Anmeldung ---------- */
.login-seite { min-height: 100dvh; }
.login {
  max-width: 420px; margin: 0 auto; text-align: center;
  padding: calc(env(safe-area-inset-top, 0px) + 12vh) 24px calc(env(safe-area-inset-bottom, 0px) + 32px);
}
.login h1 { font-size: 30px; font-weight: 700; letter-spacing: -0.03em; margin-top: 20px; }
.login .unter { color: var(--text-2); margin: 6px 0 36px; }
.erststart { margin-top: 36px; text-align: left; }
.erststart summary { cursor: pointer; color: var(--akzent-text); text-align: center; min-height: 44px; display: flex; align-items: center; justify-content: center; }
.erststart form { margin-top: 12px; }
.erststart .klein { margin-bottom: 16px; text-align: center; }

.login [hidden] { display: none !important; }
.login-block { text-align: left; }
.login-block h2 { font-size: 22px; font-weight: 700; margin-bottom: 6px; text-align: center; }
.login-block .klein { margin: 12px 0 16px; text-align: center; }
