:root {
  --bg: #F4F6F8; --karte: #FFFFFF; --text: #14202B; --leise: #52606D; --linie: #D5DCE3;
  --akzent: #2F5DA8; --akzent-text: #FFFFFF; --akzent-hell: #E3ECF8;
  --gut: #1E7A3C; --gut-bg: #D7F0DE; --warn: #9A4708; --warn-bg: #FFF0E3; --warn-text: #8A3F07;
  --neutral-bg: #E9EEF4; --neutral-text: #3E4C59;
  --fehler-bg: #FDE8E4; --fehler: #9B2C1C;
  --radius: 14px; --leiste: 64px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10161D; --karte: #18212B; --text: #E8EDF2; --leise: #9AA8B5; --linie: #2E3A47;
    --akzent: #8CB0EE; --akzent-text: #0E1A2E; --akzent-hell: #1E2C42;
    --gut: #7FD39A; --gut-bg: #173523; --warn: #F0A868; --warn-bg: #3A2614; --warn-text: #F0B680;
    --neutral-bg: #222D39; --neutral-text: #B8C4CF;
    --fehler-bg: #3A1A15; --fehler: #F4A898;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 17px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
main {
  max-width: 520px; margin: 0 auto; min-height: 100vh;
  padding: max(20px, env(safe-area-inset-top)) 16px 24px;
}
[hidden] { display: none !important; }
section[data-ansicht] { display: flex; flex-direction: column; gap: 14px; }
.mitte { min-height: 80vh; justify-content: center; text-align: center; }
.reiter { display: flex; flex-direction: column; gap: 14px; padding-bottom: calc(var(--leiste) + 90px + env(safe-area-inset-bottom)); }

h1 { margin: 0; font-size: 30px; line-height: 1.15; }
h2 { margin: 0; font-size: 19px; }
p { margin: 0; }
.leise { color: var(--leise); }
.klein { font-size: 14px; }
.hinweis { color: var(--leise); font-size: 14px; }
.ueberschrift-klein { font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--leise); margin: 6px 4px 0; }

.kauz { width: 104px; height: 104px; align-self: center; }
.kauz.klein { width: 52px; height: 52px; }
.kauz.mittel { width: 72px; height: 72px; }

button { font: inherit; cursor: pointer; border-radius: 12px; min-height: 48px; padding: 0 18px; color: inherit; }
button:disabled { opacity: .6; cursor: progress; }
.haupt { background: var(--akzent); color: var(--akzent-text); border: 0; font-weight: 700; font-size: 18px; min-height: 52px; }
.zweit { background: transparent; color: var(--akzent); border: 1.5px solid var(--akzent); font-weight: 700; }
.breit { width: 100%; }
.text { background: transparent; border: 0; color: var(--leise); text-decoration: underline; }
.text.klein { font-size: 15px; min-height: 44px; padding: 0 6px; }
.text.gefahr { color: var(--fehler); }
button:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--akzent); outline-offset: 2px; }

.feld { display: flex; flex-direction: column; gap: 6px; text-align: left; font-size: 15px; color: var(--leise); }
.feld input, .feld textarea, #neu-text, .titel-eingabe {
  min-height: 48px; padding: 10px 14px; font: inherit; color: var(--text); background: var(--karte);
  border: 1px solid var(--linie); border-radius: 12px; width: 100%;
}
.feld textarea, #neu-text { resize: vertical; }
.feld.schmal { flex: 1; min-width: 0; }
.titel-eingabe { font-size: 20px; font-weight: 700; border-color: transparent; padding-left: 4px; }
.titel-eingabe:focus { border-color: var(--linie); }
.zeile { display: flex; gap: 10px; align-items: flex-end; justify-content: space-between; }
.zeile > .haupt { flex: 1; }
.schalter { display: flex; gap: 10px; align-items: center; font-size: 15px; color: var(--leise); min-height: 44px; }
.schalter input { width: 22px; height: 22px; accent-color: var(--akzent); }

.kopf { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.karte { background: var(--karte); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.plan { border: 2px solid var(--akzent); }
.tipps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 15px; color: var(--leise); }
.pfeil { display: inline-block; width: 22px; font-weight: 700; }
.pfeil.gut { color: var(--gut); } .pfeil.warn { color: var(--warn); }

.fortschritt { display: flex; flex-direction: column; gap: 6px; }
.balken { height: 8px; border-radius: 4px; background: var(--neutral-bg); overflow: hidden; }
#fortschritt-balken { height: 100%; width: 0; background: var(--gut); border-radius: 4px; transition: width .3s ease; }

/* Als Nächstes */
.streifen { display: flex; gap: 10px; overflow-x: auto; padding: 2px 0 4px; scroll-snap-type: x mandatory; }
.termin { flex: 0 0 auto; min-width: 150px; max-width: 220px; background: var(--karte); border-radius: 12px; padding: 10px 12px;
  border: 0; text-align: left; display: flex; flex-direction: column; gap: 2px; scroll-snap-align: start; min-height: auto; }
.termin .zeit { font-weight: 700; color: var(--akzent); font-size: 15px; }
.termin .was { font-size: 15px; }
.termin .bald { font-size: 13px; color: var(--warn-text); font-weight: 700; }

/* Aufgabenliste */
.aufgaben { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.wisch { position: relative; border-radius: 12px; overflow: hidden; background: var(--karte); }
.wisch.rechts { background: var(--gut); }
.wisch.links { background: var(--warn); }
.wisch .hinter { position: absolute; inset: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 18px;
  color: #fff; font-weight: 700; font-size: 15px; }
.wisch:not(.rechts) .hinter .l, .wisch:not(.links) .hinter .r { visibility: hidden; }
.karte-aufgabe { position: relative; display: flex; align-items: center; gap: 10px; padding: 12px 14px 12px 16px; min-height: 60px;
  background: var(--karte); border-radius: 12px; touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: pointer;
  transition: transform .18s ease; }
.karte-aufgabe.zieht { transition: none; }
.karte-aufgabe .inhalt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.karte-aufgabe .titel { font-size: 17px; overflow-wrap: anywhere; }
.karte-aufgabe .meta { font-size: 13px; color: var(--leise); }
.grund { align-self: flex-start; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 10px; background: var(--neutral-bg); color: var(--neutral-text); }
.grund.warn { background: var(--warn-bg); color: var(--warn-text); }
.uhr { font-weight: 700; color: var(--akzent); font-size: 15px; white-space: nowrap; }

.aufgaben.erledigt li { display: flex; align-items: center; gap: 12px; padding: 8px 14px; min-height: 52px; background: var(--gut-bg); border-radius: 12px; }
.aufgaben.erledigt .titel { flex: 1; text-decoration: line-through; color: var(--leise); overflow-wrap: anywhere; }
.haken { width: 36px; height: 36px; min-height: 36px; padding: 0; border-radius: 50%; border: 0; background: var(--gut); color: #fff; font-weight: 700; flex: 0 0 auto; }

.leer { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 28px 8px; }

/* Alle */
.gruppe { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.gruppe h2 { font-size: 15px; color: var(--leise); margin: 8px 4px 0; }
.gruppe.ueberfaellig h2 { color: var(--warn-text); }
.zeile-aufgabe { display: flex; align-items: center; gap: 10px; padding: 12px 14px; min-height: 52px; background: var(--karte);
  border-radius: 12px; border: 0; width: 100%; text-align: left; font-size: 17px; }
.zeile-aufgabe .titel { flex: 1; overflow-wrap: anywhere; }
.marke-termin { font-size: 12px; font-weight: 700; color: var(--akzent); background: var(--akzent-hell); border-radius: 10px; padding: 2px 8px; }

/* Listen (Passkeys, Irgendwann) */
.liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.liste li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--linie); }
.liste li:last-child { border-bottom: 0; }
.liste .info { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.liste .info small { color: var(--leise); font-size: 13px; }
.liste button { min-height: 44px; padding: 0 12px; background: transparent; border: 1px solid var(--linie); font-size: 14px; }
.liste button.plus { border-color: var(--akzent); color: var(--akzent); font-weight: 700; }
.marke { font-size: 12px; font-weight: 700; color: var(--gut); background: var(--gut-bg); border-radius: 10px; padding: 2px 8px; align-self: flex-start; }

.einladungslink { display: flex; flex-direction: column; gap: 10px; align-items: center; text-align: center; padding-top: 6px; }
.einladungslink img { width: 220px; height: 220px; background: #fff; border-radius: 10px; }
.einladungslink code { font-size: 13px; word-break: break-all; color: var(--leise); }

/* Chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 20px; border: 1px solid var(--linie); background: var(--karte); font-size: 15px; }
.chip[aria-pressed="true"] { background: var(--akzent); border-color: var(--akzent); color: var(--akzent-text); font-weight: 700; }

.aktionen { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.aktion { min-height: 56px; border: 0; font-weight: 700; font-size: 17px; }
.aktion.gut { background: var(--gut-bg); color: var(--gut); }
.aktion.warn { background: var(--warn-bg); color: var(--warn-text); }

/* Plus-Knopf und Leiste */
.fab { position: fixed; right: max(16px, calc(50% - 244px)); bottom: calc(var(--leiste) + 18px + env(safe-area-inset-bottom));
  width: 62px; height: 62px; border-radius: 50%; border: 0; padding: 0; background: var(--akzent); color: var(--akzent-text);
  font-size: 34px; line-height: 1; box-shadow: 0 6px 18px rgba(0,0,0,.22); z-index: 5; }
.leiste { position: fixed; left: 0; right: 0; bottom: 0; z-index: 4; display: flex; justify-content: center;
  background: var(--karte); border-top: 1px solid var(--linie); padding-bottom: env(safe-area-inset-bottom); }
.leiste button { flex: 1; max-width: 130px; height: var(--leiste); border: 0; background: transparent; border-radius: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 13px; color: var(--leise); padding: 0; }
.leiste .symbol { font-size: 20px; line-height: 1; }
.leiste button[aria-current="page"] { color: var(--akzent); font-weight: 700; }

/* Blätter */
.schleier { position: fixed; inset: 0; background: rgba(10, 16, 24, .45); z-index: 10; }
.blatt { position: fixed; left: 0; right: 0; bottom: 0; z-index: 11; max-width: 520px; margin: 0 auto; max-height: 92vh; overflow-y: auto;
  background: var(--bg); border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px; box-shadow: 0 -6px 24px rgba(0,0,0,.2); }

#meldung {
  position: fixed; left: 16px; right: 16px; z-index: 20; bottom: calc(var(--leiste) + 16px + env(safe-area-inset-bottom));
  max-width: 488px; margin: 0 auto; padding: 8px 8px 8px 16px; min-height: 52px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-size: 15px; box-shadow: 0 4px 16px rgba(0,0,0,.25);
  display: flex; align-items: center; gap: 12px;
}
#meldung-text { flex: 1; }
#meldung.fehler { background: var(--fehler-bg); color: var(--fehler); }
#meldung-rueckgaengig { min-height: 40px; border: 0; background: transparent; color: var(--bg); font-weight: 700; text-decoration: underline; padding: 0 10px; }
body:not(.in-app) #meldung { bottom: max(16px, env(safe-area-inset-bottom)); }

/* ---------- Schritt 4: Erfassen ---------- */
.unsichtbar { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.kopf-knoepfe { display: flex; align-items: center; gap: 6px; }
.rund { width: 48px; height: 48px; min-height: 48px; padding: 0; border-radius: 50%; border: 1px solid var(--linie);
  background: var(--karte); font-size: 22px; line-height: 1; color: var(--akzent); }

.hinweis-karte { flex-direction: row; align-items: center; gap: 14px; border: 2px solid var(--akzent); text-align: left;
  font: inherit; color: var(--text); cursor: pointer; width: 100%; }
.hk-symbol { font-size: 26px; color: var(--akzent); }
.hk-text { display: flex; flex-direction: column; gap: 2px; }
.in-arbeit { display: flex; align-items: center; gap: 8px; margin: -4px 4px 0; }
.punkt { width: 10px; height: 10px; border-radius: 50%; background: var(--akzent); display: inline-block; flex: 0 0 auto;
  animation: pulsieren 1.2s ease-in-out infinite; }
@keyframes pulsieren { 50% { opacity: .25; } }

.mikro-zeile { align-items: center; justify-content: flex-start; }
.mikro { white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; border: 1.5px solid var(--akzent); color: var(--akzent);
  background: transparent; font-weight: 700; user-select: none; -webkit-user-select: none; touch-action: none; }
.mikro-symbol { color: var(--fehler); font-size: 14px; }
.mikro.nimmt-auf { background: var(--fehler); border-color: var(--fehler); color: #fff; }
.mikro.nimmt-auf .mikro-symbol { color: #fff; animation: pulsieren 1s ease-in-out infinite; }

/* Vorschläge */
.vor-liste { display: flex; flex-direction: column; gap: 14px; }
.vor-box { background: var(--karte); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.vor-quelle { font-size: 14px; color: var(--leise); border-left: 3px solid var(--linie); padding-left: 10px;
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 7.5em; overflow: hidden; }
.vor-quelle.offen { max-height: none; }
.vor-mehr { align-self: flex-start; min-height: 36px; padding: 0 4px; font-size: 14px; }
.vor-aufgabe { display: grid; grid-template-columns: 28px 1fr; gap: 6px 10px; align-items: center; }
.vor-aufgabe input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--akzent); }
.vor-aufgabe .titel-feld { resize: none; line-height: 1.35; min-height: 44px; padding: 8px 12px; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--linie); border-radius: 10px; width: 100%; }
.vor-unter { grid-column: 2; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 14px; color: var(--leise); }
.vor-unter input[type=date] { min-height: 40px; padding: 4px 8px; font: inherit; font-size: 14px; color: var(--text);
  background: var(--bg); border: 1px solid var(--linie); border-radius: 10px; }
.vor-hinweis-warn { color: var(--warn-text); font-size: 14px; }
.vor-knoepfe { display: flex; gap: 10px; justify-content: space-between; align-items: center; }
.vor-knoepfe .haupt { flex: 1; }

/* Nachtnotiz – dunkel und ruhig, egal welches Farbschema */
.nacht { position: fixed; inset: 0; z-index: 30; background: #0B1016; color: #C9D2DB; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 18px; padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  text-align: center; }
.nacht-zeit { font-size: 15px; color: #6E7C8A; margin: 0; }
.nacht h2 { color: #DDE4EA; font-size: 22px; font-weight: 600; }
.nacht-eingabe, .nacht-fertig { display: flex; flex-direction: column; align-items: center; gap: 18px; width: 100%; max-width: 420px; }
.nacht-mikro { width: 180px; height: 180px; border-radius: 50%; border: 2px solid #34506E; background: #13202E; color: #C9D2DB;
  font-size: 17px; padding: 20px; user-select: none; -webkit-user-select: none; touch-action: none; }
.nacht-mikro.nimmt-auf { background: #5A1E1E; border-color: #C0504D; color: #fff; box-shadow: 0 0 0 10px rgba(192, 80, 77, .18); }
.nacht-leise { color: #7D8B98; font-size: 15px; line-height: 1.5; margin: 0; }
.nacht-feld { width: 100%; }
.nacht-feld textarea { width: 100%; min-height: 52px; padding: 12px 14px; font: inherit; color: #DDE4EA; background: #121A23;
  border: 1px solid #26333F; border-radius: 12px; resize: none; }
.nacht-knopf { width: 100%; background: #26446A; color: #E6EDF3; border: 0; font-weight: 700; min-height: 52px; }
.nacht-gross { font-size: 26px; color: #DDE4EA; margin: 0; }
.nacht-schliessen { background: transparent; border: 0; color: #6E7C8A; text-decoration: underline; }
.nacht button:focus-visible, .nacht textarea:focus-visible { outline: 3px solid #5C86C0; outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .punkt, .mikro.nimmt-auf .mikro-symbol { animation: none; }
  .karte-aufgabe { transition: none; }
}

/* ---------- Schritt 5: Tagesabschluss & Benachrichtigungen ---------- */
.feld select, .einst-zeile select, .einst-zeile input[type=time] {
  min-height: 44px; padding: 6px 10px; font: inherit; color: var(--text); background: var(--karte);
  border: 1px solid var(--linie); border-radius: 10px; }
.zeile.links { justify-content: flex-start; flex-wrap: wrap; align-items: center; }
.einstellungen { display: flex; flex-direction: column; gap: 4px; border-top: 1px solid var(--linie); padding-top: 8px; }
.einst-zeile { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.einst-zeile .schalter { flex: 1; color: var(--text); }
.einst-zeile input[type=time], .einst-zeile select { flex: 0 0 auto; width: 124px; }
.einstellungen.aus { opacity: .55; }

.abschluss-text { font-size: 18px; }
.abschluss-liste { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.abschluss-karte { background: var(--karte); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.abschluss-karte .titel { font-size: 18px; font-weight: 700; overflow-wrap: anywhere; }
.abschluss-knoepfe { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.abschluss-knoepfe button { min-height: 48px; border: 1px solid var(--linie); background: var(--bg); font-weight: 700; font-size: 15px; }
.abschluss-knoepfe .gut { background: var(--gut-bg); color: var(--gut); border-color: transparent; }
.abschluss-knoepfe .warn { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }
.abschluss-knoepfe input[type=date] { grid-column: 1 / -1; min-height: 48px; padding: 6px 10px; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--akzent); border-radius: 12px; }
.abschluss-karte.entschieden { flex-direction: row; align-items: center; justify-content: space-between; padding: 10px 14px; min-height: 56px; }
.abschluss-karte.entschieden .titel { font-size: 16px; font-weight: 400; }
.abschluss-karte.entschieden .ergebnis { font-size: 13px; color: var(--leise); }
.abschluss-karte.entschieden.erledigt { background: var(--gut-bg); }
.abschluss-karte.entschieden button { min-height: 40px; padding: 0 8px; background: transparent; border: 0; color: var(--leise);
  text-decoration: underline; font-size: 14px; }
.morgen-vorschau .zeile-termin { display: flex; gap: 10px; align-items: baseline; }
.morgen-vorschau .zeit { font-weight: 700; color: var(--akzent); }
