:root {
  --hg: #f5f6f2;
  --karte: #ffffff;
  --text: #1f2a26;
  --leise: #5f6b66;
  --linie: #e1e5df;
  --haupt: #2f6f5e;
  --haupt-text: #ffffff;
  --haupt-hell: #e3f0ea;
  --gefahr: #b3412f;
  --gefahr-hell: #fbeae6;
  --hinweis: #fff6e0;
  --hinweis-linie: #ecd9a6;
  --radius: 14px;
  --leiste-hoehe: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --hg: #131816;
    --karte: #1c2320;
    --text: #e6ece9;
    --leise: #a1ada8;
    --linie: #2d3632;
    --haupt: #6dbb9f;
    --haupt-text: #0f1513;
    --haupt-hell: #22352e;
    --gefahr: #f08a76;
    --gefahr-hell: #3a2420;
    --hinweis: #2d2a1d;
    --hinweis-linie: #5a5032;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--hg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--haupt); }

/* Kopfzeile */
.kopf {
  position: sticky; top: 0; z-index: 10;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: calc(env(safe-area-inset-top) + 6px) 12px 6px;
  min-height: calc(env(safe-area-inset-top) + 56px);
  background: var(--hg);
  border-bottom: 1px solid var(--linie);
}
.kopf h1 { margin: 0; font-size: 19px; font-weight: 650; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kopf-links { justify-self: start; }
.zurueck {
  display: inline-flex; align-items: center; gap: 2px;
  min-height: 44px; padding: 0 8px 0 2px;
  font-size: 17px; text-decoration: none; color: var(--haupt);
}
.info-knopf {
  justify-self: end;
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%;
  font-weight: 700; font-style: italic; font-family: Georgia, serif; font-size: 20px;
  color: var(--haupt); text-decoration: none;
  border: 2px solid var(--haupt);
  transform: scale(.8);
}

/* Inhalt */
main {
  max-width: 640px; margin: 0 auto;
  padding: 16px 16px calc(var(--leiste-hoehe) + env(safe-area-inset-bottom) + 28px);
  outline: none;
}
h2 { font-size: 15px; font-weight: 650; color: var(--leise); text-transform: uppercase; letter-spacing: .04em; margin: 22px 4px 8px; }
h2:first-child { margin-top: 4px; }

.karte {
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.liste { list-style: none; margin: 0; padding: 0; }
.liste li { margin-bottom: 10px; }
.eintrag {
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: 64px;
  padding: 12px 16px;
  background: var(--karte); color: var(--text);
  border: 1px solid var(--linie); border-radius: var(--radius);
  text-decoration: none; text-align: left; font: inherit;
}
.eintrag .haupt { flex: 1; min-width: 0; }
.eintrag .name { font-weight: 600; display: block; overflow-wrap: anywhere; }
.eintrag .details { color: var(--leise); font-size: 15px; display: block; }
.eintrag .pfeil { color: var(--leise); font-size: 22px; }
.eintrag.inaktiv { opacity: .55; }

.marke {
  display: inline-block; font-size: 13px; padding: 2px 8px; border-radius: 99px;
  background: var(--haupt-hell); color: var(--haupt); font-weight: 600; white-space: nowrap;
}
.marke.grau { background: var(--linie); color: var(--leise); }

/* Heute */
.tag-wahl { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.tag-wahl .datum { text-align: center; flex: 1; }
.tag-wahl .datum strong { display: block; font-size: 18px; }
.tag-wahl .datum span { color: var(--leise); font-size: 15px; }
.rund {
  width: 48px; height: 48px; border-radius: 50%;
  border: 1px solid var(--linie); background: var(--karte); color: var(--text);
  font-size: 22px; line-height: 1; cursor: pointer;
}
.fortschritt { height: 8px; background: var(--linie); border-radius: 99px; overflow: hidden; margin: 10px 0 4px; }
.fortschritt div { height: 100%; background: var(--haupt); border-radius: 99px; transition: width .25s; }
.fortschritt-text { color: var(--leise); font-size: 15px; text-align: center; margin: 0 0 4px; }

.abhaken { cursor: pointer; }
.abhaken .kreis {
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  border: 2.5px solid var(--leise);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s;
}
.abhaken .kreis svg { width: 20px; height: 20px; stroke: var(--haupt-text); stroke-width: 3; fill: none; opacity: 0; }
.abhaken[aria-checked="true"] { background: var(--haupt-hell); border-color: transparent; }
.abhaken[aria-checked="true"] .kreis { background: var(--haupt); border-color: var(--haupt); }
.abhaken[aria-checked="true"] .kreis svg { opacity: 1; }
.abhaken[aria-checked="true"] .name { text-decoration: line-through; text-decoration-color: var(--leise); }
.abhaken .zeit { color: var(--leise); font-size: 15px; white-space: nowrap; }

/* Leere Zustände und Hinweise */
.leer { text-align: center; padding: 28px 20px; color: var(--leise); }
.leer .gross { font-size: 19px; color: var(--text); font-weight: 600; margin: 0 0 6px; }
.leer p { margin: 0 0 16px; }
.hinweis-box {
  background: var(--hinweis); border: 1px solid var(--hinweis-linie);
  border-radius: var(--radius); padding: 12px 14px; font-size: 15px; margin: 18px 0 8px;
}
.hinweis-box a { font-weight: 600; }

/* Knöpfe */
.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 0 20px;
  border-radius: 12px; border: 1px solid transparent;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  background: var(--haupt); color: var(--haupt-text);
}
.knopf.breit { width: 100%; }
.knopf.zweit { background: var(--karte); color: var(--haupt); border-color: var(--linie); }
.knopf.gefahr { background: var(--gefahr-hell); color: var(--gefahr); }
.knopf-reihe { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }

/* Formulare */
.feld { margin-bottom: 16px; }
.feld > label, .feld > .label { display: block; font-weight: 600; margin: 0 0 6px 2px; }
.feld .hilfe { color: var(--leise); font-size: 14px; margin: 4px 2px 0; }
input[type=text], input[type=number], input[type=date], input[type=time], select, textarea {
  width: 100%; min-height: 50px;
  padding: 12px 14px;
  font: inherit; font-size: 17px; color: var(--text);
  background: var(--karte);
  border: 1px solid var(--linie); border-radius: 12px;
  -webkit-appearance: none; appearance: none;
}
select {
  background-image: linear-gradient(45deg, transparent 50%, var(--leise) 50%), linear-gradient(135deg, var(--leise) 50%, transparent 50%);
  background-position: calc(100% - 20px) 50%, calc(100% - 14px) 50%;
  background-size: 6px 6px; background-repeat: no-repeat; padding-right: 36px;
}
textarea { min-height: 88px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--haupt); outline-offset: 1px; border-color: transparent; }
.zwei-spalten { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fehler { color: var(--gefahr); font-weight: 600; margin: 0 0 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips label { position: relative; }
.chips input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chips span {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; min-width: 48px; padding: 0 14px;
  border-radius: 99px; border: 1px solid var(--linie); background: var(--karte);
  cursor: pointer; user-select: none; -webkit-user-select: none;
}
.chips input:checked + span { background: var(--haupt); border-color: var(--haupt); color: var(--haupt-text); font-weight: 600; }
.chips input:focus-visible + span { outline: 2px solid var(--haupt); outline-offset: 2px; }

.schalter { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 52px; }
.schalter input {
  -webkit-appearance: none; appearance: none; flex: none;
  width: 52px; height: 32px; border-radius: 99px; background: var(--linie);
  position: relative; cursor: pointer; transition: background .15s; margin: 0;
}
.schalter input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s;
}
.schalter input:checked { background: var(--haupt); }
.schalter input:checked::after { transform: translateX(20px); }

/* Detailansicht */
.detail dt { font-weight: 600; color: var(--leise); font-size: 14px; text-transform: uppercase; letter-spacing: .03em; margin-top: 14px; }
.detail dt:first-child { margin-top: 0; }
.detail dd { margin: 3px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.text p { margin: 0 0 12px; }
.text p:last-child { margin-bottom: 0; }
.klein { font-size: 14px; color: var(--leise); }

/* Untere Leiste */
.leiste {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--leiste-hoehe) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--karte); border-top: 1px solid var(--linie);
}
.leiste a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--leise); text-decoration: none; font-size: 12.5px; font-weight: 500;
}
.leiste svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.leiste a.aktiv { color: var(--haupt); font-weight: 700; }
.leiste a.aktiv svg { stroke-width: 2.3; }

/* Kurzmeldung */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--leiste-hoehe) + env(safe-area-inset-bottom) + 14px);
  transform: translateX(-50%) translateY(10px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--hg);
  padding: 10px 18px; border-radius: 99px; font-size: 15px; max-width: 90vw; text-align: center;
  transition: opacity .2s, transform .2s; z-index: 20;
}
#toast.sichtbar { opacity: 1; transform: translateX(-50%) translateY(0); }
