/* Gestaltung wie Fieldnotes: gleiche Farben, Systemschrift, Akzent --accent */
:root {
  --bg: #ffffff;
  --ink: #1f1f1e;
  --muted: #8d8d8a;
  --rule: #ececea;
  --card: #f5f5f3;
  --card-line: #e4e4e1;
  --pill: #e9e9e6;
  --accent: #d4593a;
  --accent-ink: #ffffff;
  --cap-white: #fbfbf9;
  --cap-line: rgba(0, 0, 0, .14);
  --cap-lila: #7d5bbf;
  --cap-lila-light: #9b7fd0;
  --font: ui-sans-serif, -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f1f1e;
    --ink: #ecebe7;
    --muted: #8f8e89;
    --rule: #2f2f2d;
    --card: #2c2c2a;
    --card-line: #3a3a37;
    --pill: #3a3a37;
    --accent: #c9603f;
    --cap-white: #f2f1ed;
    --cap-line: transparent;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; }
body {
  background: var(--bg); color: var(--ink);
  font: 400 17px/1.45 var(--font);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.app {
  height: var(--app-h, 100dvh);
  display: flex; flex-direction: column;
  max-width: 680px; margin: 0 auto;
  padding: env(safe-area-inset-top) 20px 0;
  position: relative;
}

/* Prognose oben */
.forecast { padding: 14px 0 16px; border-bottom: 1px solid var(--rule); }
.forecast .lbl { font-size: 13px; font-weight: 600; color: var(--muted); }
.forecast .big { font-size: 28px; font-weight: 600; letter-spacing: -.01em; line-height: 1.2; margin-top: 2px; }
.forecast .big .slot { color: var(--muted); font-weight: 400; }
.forecast .sub { font-size: 15px; color: var(--muted); margin-top: 4px; }
.forecast .sub b { color: var(--accent); font-weight: 600; }
.forecast.warn .big { color: var(--accent); }

.main { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding-bottom: 12px; }
.day { font-size: 13px; font-weight: 600; color: var(--muted); padding: 18px 0 4px; }

/* Kapseln: 5 mg weiß, 10 mg weiß/lila, 20 mg lila */
.cap { display: inline-block; width: 30px; height: 13px; border-radius: 7px; box-shadow: inset 0 0 0 1px var(--cap-line); vertical-align: -1px; flex: none; }
.cap.c5 { background: var(--cap-white); }
.cap.c10 { background: linear-gradient(90deg, var(--cap-white) 50%, var(--cap-lila-light) 50%); }
.cap.c20 { background: var(--cap-lila); }
.caps { display: inline-flex; align-items: center; gap: 3px; vertical-align: middle; }

/* Einnahmen heute */
.dose { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--rule); cursor: pointer; }
.dose:last-child { border-bottom: 0; }
.dose .d { font-size: 14px; color: var(--muted); font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 8px; margin-top: 4px; min-height: 20px; }
.dose.done .n, .dose.skip .n { color: var(--muted); }
.dev { color: var(--accent); }
.chk { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: var(--pill); color: var(--muted); }
.chk.on { background: var(--accent); color: var(--accent-ink); }
.chk.next { box-shadow: inset 0 0 0 2px var(--accent); background: none; color: var(--accent); }
.chk:disabled { opacity: .5; }

/* Verlauf */
.hist { display: grid; grid-template-columns: 46px 1fr; gap: 0 10px; padding: 8px 0; border-bottom: 1px solid var(--rule); font-size: 15px; cursor: pointer; }
.hist:has(+ .day), .hist:last-child { border-bottom: 0; }
.hist time { font-size: 13px; color: var(--muted); padding-top: 1px; font-variant-numeric: tabular-nums; }
.hist .t { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.muted { color: var(--muted); }

/* Vorrat */
.stock { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.stock .n { display: flex; align-items: center; gap: 8px; }
.stock .d { font-size: 14px; color: var(--muted); }
.stock .d.low { color: var(--accent); }
.step { display: flex; align-items: center; gap: 6px; }
.step .r { width: 36px; height: 36px; border-radius: 50%; background: var(--pill); display: grid; place-items: center; }
.step .r svg { width: 18px; height: 18px; }
.step .v { min-width: 44px; text-align: center; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.pills { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px 0 4px; }
.pill { background: var(--pill); border-radius: 999px; padding: 6px 14px; font-size: 15px; font-variant-numeric: tabular-nums; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; }
.pill.acc { background: var(--accent); color: var(--accent-ink); }
.row-line { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--rule); font-size: 16px; cursor: pointer; min-height: 46px; }
.row-line .x { color: var(--muted); font-size: 15px; text-align: right; }
.row-line.static { cursor: default; padding: 6px 0; }

/* Leiste unten */
.tabs { display: flex; gap: 4px; padding: 5px; background: var(--card); border: 1px solid var(--card-line); border-radius: 999px; margin: 8px auto max(12px, env(safe-area-inset-bottom)); width: max-content; flex: none; }
.tabs button { padding: 8px 22px; border-radius: 999px; font-size: 15px; color: var(--muted); }
.tabs button.on { background: var(--bg); color: var(--ink); box-shadow: 0 1px 2px #0001; }
@media (prefers-color-scheme: dark) { .tabs button.on { background: var(--pill); } }

/* Fenster unten (Abweichung, Plan, Zeitraum, Bestand) */
.sheet-wrap { position: absolute; inset: 0; z-index: 10; }
.dim { position: absolute; inset: 0; background: color-mix(in srgb, var(--bg) 70%, transparent); }
.sheet { position: absolute; left: 12px; right: 12px; bottom: max(12px, env(safe-area-inset-bottom)); background: var(--card); border: 1px solid var(--card-line); border-radius: 26px; padding: 18px 16px 12px; max-height: calc(100% - 24px); overflow-y: auto; animation: up .18s ease-out; }
body.kb .sheet { bottom: 8px; }
@keyframes up { from { transform: translateY(12px); opacity: 0; } }
.sheet h3 { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.sheet .cnt { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--card-line); }
.sheet .cnt:last-of-type { border-bottom: 0; }
.sheet .cnt > span { display: flex; align-items: center; gap: 8px; }
.sheet .row { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.sheet .sum { font-size: 15px; color: var(--muted); }
.sheet .sum.dev { color: var(--accent); }
.sheet input[type=number], .sheet input[type=text], .sheet input[type=date] {
  font: inherit; font-size: 17px; color: inherit; background: var(--bg); border: 1px solid var(--card-line); border-radius: 12px; padding: 7px 10px; outline: none;
}
.sheet input[type=number] { width: 90px; text-align: right; font-variant-numeric: tabular-nums; }
.sheet input[type=date] { min-width: 150px; }
.sheet input[type=text] { width: 100%; }
.sheet input:focus { border-color: var(--accent); }
.sheet .field { padding: 6px 0; }
.sheet .pack { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 12px 4px; border-bottom: 1px solid var(--card-line); font-size: 17px; }
.sheet .pack:last-of-type { border-bottom: 0; }
.sheet .pack > span { display: flex; align-items: center; gap: 8px; }
.sheet .pack b { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
.grow { flex: 1; }
.link { color: var(--muted); font-size: 15px; padding: 6px 4px; }

/* Uhrzeit-Pill wie in Fieldnotes: antippen öffnet die Zeitauswahl */
.pill-wrap { position: relative; display: inline-flex; }
.pill-wrap input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; }

.round {
  width: 42px; height: 42px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--pill); color: var(--ink); cursor: pointer; padding: 0; flex: none;
}
.send { background: var(--accent); color: var(--accent-ink); }
.send:disabled { opacity: .45; cursor: default; }

.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0%, 30% { background: color-mix(in srgb, var(--accent) 22%, transparent); } 100% { background: transparent; } }
.err-note { color: var(--accent); font-size: 14px; padding: 8px 0; }

/* Login: gleiche Eingabekarte unten wie Fieldnotes */
.login-page .app { justify-content: flex-end; padding-left: 12px; padding-right: 12px; }
.composer { background: var(--card); border: 1px solid var(--card-line); border-radius: 26px; padding: 14px 12px 10px 16px; margin-bottom: max(10px, env(safe-area-inset-bottom)); }
.composer .row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.composer .pill { margin-left: -4px; }
.pill.err { color: var(--accent); }
.login input {
  display: block; width: 100%; border: 0; outline: none; background: none;
  font: inherit; font-size: 18px; color: inherit; caret-color: var(--accent); height: 28px;
}
