:root {
  --blau: #007aff; --orange: #ff9500; --violett: #8e5bea; --gruen: #30b158; --rot: #ff3b30;
  --grund: #f2f2f7; --karte: #fff; --karte-2: #f2f2f7; --text: #1c1c1e; --leise: #8a8a8e;
  --linie: rgba(60, 60, 67, .14); --glas: rgba(249, 249, 251, .78);
  --akzent: var(--blau); --schatten: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 24px rgba(0, 0, 0, .05);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --blau: #0a84ff; --orange: #ff9f0a; --violett: #a97bff; --gruen: #32d74b; --rot: #ff453a;
    --grund: #000; --karte: #1c1c1e; --karte-2: #2c2c2e; --text: #f5f5f7; --leise: #98989f;
    --linie: rgba(235, 235, 245, .16); --glas: rgba(28, 28, 30, .78); --schatten: none;
  }
}
body[data-tab="heute"] { --akzent: var(--blau); }
body[data-tab="liste"] { --akzent: var(--orange); }
body[data-tab="assistent"] { --akzent: var(--violett); }
body[data-tab="wissen"] { --akzent: var(--gruen); }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--grund); color: var(--text);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: 260px; pointer-events: none; z-index: -1;
  background: linear-gradient(color-mix(in srgb, var(--akzent) 16%, transparent), transparent);
  transition: background .3s;
}
button, input, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; padding: 0; cursor: pointer; }
input, textarea { background: none; border: 0; outline: 0; width: 100%; min-width: 0; }
input::placeholder, textarea::placeholder { color: var(--leise); }
[hidden] { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#seite { max-width: 680px; margin: 0 auto; padding: env(safe-area-inset-top) 16px 190px; }
.kopf { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; padding: 24px 4px 14px; }
.kopf h1 { margin: 0; font-size: 34px; line-height: 1.1; font-weight: 700; letter-spacing: -.4px; }
.datum { margin: 0 0 2px; color: var(--akzent); font-size: 15px; font-weight: 600; }
.ring { width: 52px; height: 52px; transform: rotate(-90deg); flex: none; }
.ring circle { fill: none; stroke-width: 5; }
.ring-grund { stroke: var(--linie); }
.ring-wert { stroke: var(--akzent); stroke-linecap: round; transition: stroke-dasharray .4s; }
.ring text { transform: rotate(90deg); transform-origin: 22px 22px; text-anchor: middle; fill: var(--text); stroke: none; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

.abschnitt { margin: 22px 4px 7px; font-size: 20px; font-weight: 700; letter-spacing: -.2px; }
.abschnitt.rot { color: var(--rot); }
.abschnitt .zahl { color: var(--leise); font-weight: 500; font-size: 15px; margin-left: 4px; }
.gruppe { background: var(--karte); border-radius: 14px; overflow: hidden; box-shadow: var(--schatten); }

.zeile { display: flex; gap: 12px; align-items: flex-start; padding: 11px 14px; position: relative; width: 100%; text-align: left; }
.zeile + .zeile::before, .zeile + .vorschlag + .zeile::before {
  content: ""; position: absolute; top: 0; right: 0; left: 50px; height: .5px; background: var(--linie);
}
.haken {
  flex: none; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--leise); margin-top: -1px;
  display: grid; place-items: center; transition: background .15s, border-color .15s, transform .15s;
  position: relative;
}
.haken::after { content: ""; position: absolute; inset: -10px; }
.haken svg { width: 14px; height: 14px; stroke: #fff; stroke-width: 3; opacity: 0; }
.haken:active { transform: scale(.88); }
.haken[aria-checked="true"] { background: var(--akzent); border-color: var(--akzent); }
.haken[aria-checked="true"] svg { opacity: 1; }
.zeile-inhalt { flex: 1; min-width: 0; cursor: pointer; }
.zeile-titel { overflow-wrap: anywhere; }
.erledigt .zeile-titel { color: var(--leise); text-decoration: line-through; }
.zeile-info { display: flex; flex-wrap: wrap; gap: 3px 10px; color: var(--leise); font-size: 14px; margin-top: 1px; }
.zeile-info .faellig { color: var(--rot); }
.zeile-info .ki { color: var(--violett); font-weight: 600; }

.vorschlag {
  margin: 0 12px 12px 50px; padding: 11px 12px; border-radius: 12px;
  background: color-mix(in srgb, var(--violett) 11%, var(--karte));
}
.chat .vorschlag, .blatt-inhalt .vorschlag { margin: 2px 0 10px; }
.vorschlag-kopf { display: flex; gap: 6px; font-weight: 600; font-size: 15px; color: var(--violett); align-items: center; }
.vorschlag-kopf svg { width: 15px; height: 15px; flex: none; fill: currentColor; stroke: none; }
.vorschlag-titel { font-weight: 600; margin-top: 3px; overflow-wrap: anywhere; }
.vorschlag ul { margin: 5px 0 0; padding-left: 18px; font-size: 15px; }
.vorschlag-knoepfe { display: flex; gap: 8px; margin-top: 10px; }
.knopf { padding: 7px 15px; border-radius: 999px; font-size: 15px; font-weight: 600; }
.knopf.haupt { background: var(--violett); color: #fff; }
.knopf.neben { background: var(--linie); }

.leer { text-align: center; color: var(--leise); padding: 56px 24px; }
.leer strong { display: block; color: var(--text); font-size: 19px; margin-bottom: 4px; }
.fussnote { color: var(--leise); font-size: 14px; margin: 7px 4px 0; }

#schnell {
  position: fixed; z-index: 5; left: 50%; transform: translateX(-50%); width: min(648px, calc(100% - 32px));
  bottom: calc(76px + env(safe-area-inset-bottom));
  background: var(--glas); backdrop-filter: blur(22px) saturate(1.7); -webkit-backdrop-filter: blur(22px) saturate(1.7);
  border-radius: 26px; box-shadow: 0 2px 18px rgba(0, 0, 0, .1); padding: 6px;
}
body[data-tab="wissen"] #schnell, body[data-tab="assistent"] #schnell { display: none; }
.schnell-zeile { display: flex; align-items: center; gap: 4px; }
#schnell-text { padding: 7px 4px; font-size: 17px; }
.glocke { flex: none; width: 36px; height: 36px; border-radius: 50%; color: var(--leise); display: grid; place-items: center; }
.glocke svg { width: 22px; height: 22px; }
.glocke.an { color: var(--akzent); }
.rund {
  flex: none; width: 36px; height: 36px; border-radius: 50%; background: var(--akzent); color: #fff;
  display: grid; place-items: center; transition: transform .15s;
}
.rund svg { width: 20px; height: 20px; stroke-width: 2.6; }
.rund:active { transform: scale(.9); }
.rund:disabled { opacity: .4; }
#schnell-optionen { display: flex; gap: 6px; padding: 4px 4px 8px; overflow-x: auto; scrollbar-width: none; }
.chip {
  flex: none; padding: 6px 12px; border-radius: 999px; background: var(--linie); font-size: 14px; font-weight: 500;
  position: relative; overflow: hidden;
}
.chip.an { background: var(--akzent); color: #fff; }
.chip input { position: absolute; inset: 0; opacity: 0; }

#tabs {
  position: fixed; z-index: 6; left: 0; right: 0; bottom: 0; display: flex; justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--glas); backdrop-filter: blur(22px) saturate(1.7); -webkit-backdrop-filter: blur(22px) saturate(1.7);
  border-top: .5px solid var(--linie);
}
#tabs button {
  flex: 1; max-width: 170px; padding: 7px 0 6px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; font-weight: 500; color: var(--leise);
}
#tabs svg { width: 25px; height: 25px; stroke-width: 1.8; }
#tabs button.aktiv { color: var(--akzent); }

.chat-ansicht .kopf { padding-bottom: 8px; }
.text-knopf { color: var(--akzent); font-size: 17px; }
.chat { display: flex; flex-direction: column; }
.chat-verlauf { display: flex; flex-direction: column; gap: 10px; padding: 8px 0 14px; }
.blase { max-width: 88%; overflow-wrap: anywhere; }
.blase.user {
  align-self: flex-end; background: var(--violett); color: #fff; padding: 8px 13px; border-radius: 19px 19px 5px 19px; white-space: pre-wrap;
}
.blase.assistant { align-self: stretch; max-width: 100%; }
.blase.assistant :first-child { margin-top: 0; }
.blase.assistant :last-child { margin-bottom: 0; }
.blase p { margin: 0 0 9px; }
.blase h3, .blase h4 { margin: 14px 0 4px; font-size: 17px; }
.blase ul, .blase ol { margin: 0 0 9px; padding-left: 22px; }
.blase li { margin-bottom: 3px; }
.blase.fehler { color: var(--rot); }
.tippt { display: inline-flex; gap: 4px; padding: 6px 0; }
.tippt i { width: 7px; height: 7px; border-radius: 50%; background: var(--violett); animation: tippt 1s infinite; }
.tippt i:nth-child(2) { animation-delay: .15s; }
.tippt i:nth-child(3) { animation-delay: .3s; }
@keyframes tippt { 50% { transform: translateY(-4px); opacity: .5; } }
.beispiele { display: flex; flex-direction: column; gap: 8px; padding: 6px 0; }
.beispiel { text-align: left; padding: 11px 14px; border-radius: 14px; background: var(--karte); box-shadow: var(--schatten); }
.chat-form {
  display: flex; gap: 6px; align-items: flex-end; padding: 6px 6px 6px 16px; border-radius: 24px;
  background: var(--karte); box-shadow: var(--schatten);
}
.chat-ansicht .chat-form {
  position: fixed; z-index: 5; left: 50%; transform: translateX(-50%); width: min(648px, calc(100% - 32px));
  bottom: calc(76px + env(safe-area-inset-bottom));
}
.chat-form textarea { resize: none; padding: 6px 0; max-height: 130px; font-size: 17px; line-height: 1.3; }
.chat .rund { background: var(--violett); }

.eingabe-karte {
  display: flex; align-items: center; gap: 6px; margin-top: 10px; padding: 6px 6px 6px 14px;
  background: var(--karte); border-radius: 14px; box-shadow: var(--schatten);
}
.wissen-zeile, .einstellung { display: flex; align-items: center; gap: 10px; padding: 11px 14px; position: relative; }
.wissen-zeile + .wissen-zeile::before, .einstellung + .einstellung::before {
  content: ""; position: absolute; top: 0; right: 0; left: 14px; height: .5px; background: var(--linie);
}
.wissen-zeile span, .einstellung span { flex: 1; overflow-wrap: anywhere; }
.entfernen { color: var(--leise); width: 28px; height: 28px; display: grid; place-items: center; flex: none; }
.entfernen svg { width: 16px; height: 16px; }
.schalter { appearance: none; -webkit-appearance: none; flex: none; width: 51px; height: 31px; border-radius: 999px; background: var(--linie); position: relative; transition: background .2s; cursor: pointer; }
.schalter::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0, 0, 0, .25); transition: transform .2s; }
.schalter:checked { background: var(--gruen); }
.schalter:checked::after { transform: translateX(20px); }
.einstellung input[type="time"] { width: auto; color: var(--leise); text-align: right; }
.einstellung button { color: var(--akzent); font-weight: 500; }

#blatt-hinter { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 9; animation: ein .2s; }
#blatt {
  position: fixed; z-index: 10; left: 50%; bottom: 0; transform: translateX(-50%); width: min(680px, 100%);
  height: min(92dvh, 860px); background: var(--grund); border-radius: 14px 14px 0 0;
  display: flex; flex-direction: column; animation: hoch .28s cubic-bezier(.2, .8, .2, 1);
}
@keyframes ein { from { opacity: 0; } }
@keyframes hoch { from { transform: translate(-50%, 100%); } }
.blatt-kopf { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px 10px; }
.blatt-kopf strong { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.blatt-inhalt { flex: 1; overflow-y: auto; padding: 0 16px calc(20px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
.blatt-inhalt .chat { height: 100%; }
.blatt-inhalt .chat-verlauf { flex: 1; overflow-y: auto; }
.feld-titel { font-size: 22px; font-weight: 700; padding: 13px 14px; display: block; }
.feld-notiz { display: block; padding: 11px 14px; min-height: 64px; resize: none; border-top: .5px solid var(--linie); }
.feld { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 9px 14px; min-height: 44px; }
.feld + .feld { border-top: .5px solid var(--linie); }
.feld input { width: auto; flex: 0 1 auto; color: var(--leise); text-align: right; }
.feld .leeren { color: var(--leise); font-size: 14px; }
.punkt { display: flex; gap: 12px; align-items: center; padding: 9px 8px 9px 14px; }
.punkt + .punkt { border-top: .5px solid var(--linie); }
.punkt span { flex: 1; overflow-wrap: anywhere; }
.punkt.erledigt span { color: var(--leise); text-decoration: line-through; }
.punkt .haken { width: 22px; height: 22px; }
.punkt .haken[aria-checked="true"] { background: var(--blau); border-color: var(--blau); }
.punkt-neu { padding: 11px 14px; border-top: .5px solid var(--linie); }
.ki-knopf {
  display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%; margin-top: 18px; padding: 13px;
  border-radius: 14px; background: var(--violett); color: #fff; font-weight: 600;
}
.ki-knopf svg { width: 18px; height: 18px; fill: currentColor; stroke: none; }
.loeschen { display: block; width: 100%; padding: 13px; margin-top: 12px; border-radius: 14px; background: var(--karte); color: var(--rot); }

#anmeldung {
  position: fixed; inset: 0; z-index: 20; background: var(--grund); display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px; padding: 24px;
}
#anmeldung img { border-radius: 19px; }
#anmeldung h1 { margin: 4px 0 14px; font-size: 28px; }
#anmeldung input { max-width: 320px; padding: 13px 14px; border-radius: 14px; background: var(--karte); box-shadow: var(--schatten); }
#anmeldung .ki-knopf { max-width: 320px; margin-top: 0; background: var(--blau); }
#anmeldung #face-id-anmelden + input { margin-top: 12px; }
#anmelde-fehler { margin: 0; min-height: 20px; color: var(--rot); font-size: 15px; }

@media (min-width: 720px) {
  #blatt { bottom: 4dvh; border-radius: 14px; height: min(88dvh, 780px); }
  @keyframes hoch { from { transform: translate(-50%, 24px); opacity: 0; } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
