/* 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-line: rgba(0, 0, 0, .14);
  /* Kapselfarben (Medikinet retard laut Fachinformation; Lila wie vom Nutzer gewünscht) */
  --k-weiss: #fbfbf9;
  --k-hellgrau: #cfcdd3;
  --k-grau: #8f8c95;
  --k-lila: #9b7fd0;
  --k-violett: #7a55c6;
  --k-dunkelviolett: #4b2c86;
  --font: ui-sans-serif, -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
/* Dunkel: nach System, außer unter Einstellungen → Darstellung fest gewählt (data-theme) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1f1f1e;
    --ink: #ecebe7;
    --muted: #8f8e89;
    --rule: #2f2f2d;
    --card: #2c2c2a;
    --card-line: #3a3a37;
    --pill: #3a3a37;
    --accent: #c9603f;
    --k-weiss: #f2f1ed;
    --k-dunkelviolett: #6a47ad;  /* etwas heller, sonst auf dunklem Grund kaum sichtbar */
    --cap-line: rgba(255, 255, 255, .08);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1f1f1e;
  --ink: #ecebe7;
  --muted: #8f8e89;
  --rule: #2f2f2d;
  --card: #2c2c2a;
  --card-line: #3a3a37;
  --pill: #3a3a37;
  --accent: #c9603f;
  --k-weiss: #f2f1ed;
  --k-dunkelviolett: #6a47ad;  /* etwas heller, sonst auf dunklem Grund kaum sichtbar */
  --cap-line: rgba(255, 255, 255, .08);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; overflow: hidden; }
html { touch-action: manipulation; } /* kein Zoomen durch Doppeltippen (z. B. schnell auf + tippen) */
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;
}
/* Chrome „Desktop-Website“ (boot.js): App in Handybreite, dann vergrößert auf die volle Breite */
html.scaled .app { width: calc(100vw / var(--zoom)); max-width: none; margin: 0; transform: scale(var(--zoom)); transform-origin: 0 0; }

/* Prognose oben */
.forecast { padding: 40px 0 16px; border-bottom: 1px solid var(--rule); } /* Abstand zum Unschärfe-Verlauf von iOS oben (wie Fieldnotes) */
.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); }
.forecast .sub.tap { cursor: pointer; }
/* Sprechzeiten unter der Prognose (Tipp auf den Rezept-Termin) */
.forecast .hours { margin-top: 10px; background: var(--card); border: 1px solid var(--card-line); border-radius: 16px; padding: 6px 14px; font-size: 15px; animation: up .15s ease-out; }
.forecast .hours div { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; font-variant-numeric: tabular-nums; }
.forecast .hours div + div { border-top: 1px solid var(--card-line); }
.forecast .hours .off { color: var(--muted); }
.forecast .hours .hl { color: var(--accent); font-weight: 600; }

.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 { background: linear-gradient(90deg, var(--a, var(--k-weiss)) 50%, var(--b, var(--k-weiss)) 50%); }
.cap.big { width: 40px; height: 17px; border-radius: 9px; margin-right: 8px; vertical-align: -2px; }
/* Stärken in den Einstellungen */
.row-line .str-name { display: flex; align-items: center; gap: 8px; }
.row-line.off .str-name { color: var(--muted); }
.row-line.off .cap { opacity: .45; }
.sheet .cnt.col { flex-direction: column; align-items: flex-start; gap: 8px; }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 32px; height: 32px; border-radius: 50%; background: var(--k); box-shadow: inset 0 0 0 1px var(--cap-line), 0 0 0 1px var(--card-line); }
.swatch.sel { box-shadow: inset 0 0 0 1px var(--cap-line), 0 0 0 2px var(--card), 0 0 0 4px var(--accent); }
.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); }
/* Pausentag */
.day-row { display: flex; align-items: center; gap: 8px; }
.day-row .pause-count { font-weight: 400; }
.pill.small { font-size: 13px; padding: 3px 12px; font-weight: 400; color: var(--ink); }
.pill.small.acc { color: var(--accent-ink); }
.dose.paused { opacity: .4; cursor: default; }
.dose .right { display: flex; align-items: center; gap: 10px; }
/* Uhrzeit je Einnahme: antippen öffnet die Zeitauswahl (unsichtbares Feld darüber) */
.tpill { position: relative; display: inline-flex; background: var(--pill); border-radius: 999px; padding: 6px 12px; font-size: 15px; font-variant-numeric: tabular-nums; min-width: 66px; justify-content: center; }
.tpill.empty { color: var(--muted); }
.tpill.suggest { color: var(--muted); background: none; box-shadow: inset 0 0 0 1.5px var(--pill); } /* nur errechnet: beim Abhaken gilt jetzt */
.tpill input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; font-size: 16px; }
.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; }
.row-line .btns { display: inline-flex; gap: 8px; }
#push-state .pill { cursor: pointer; }

/* 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 16px; 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) { :root:not([data-theme="light"]) .tabs button.on { background: var(--pill); } }
:root[data-theme="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 h3 .sum { font-weight: 400; }
.sheet h3.head { display: flex; align-items: baseline; gap: 6px; }
.sheet h3.head .link { margin-left: auto; font-weight: 400; padding: 0 4px; }
.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 .notes { padding: 6px 0 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; }

/* Kalender für Zeiträume: erster und letzter Tag in einem Kalender */
.cal-head { display: flex; align-items: center; gap: 6px; margin: 6px 0 4px; }
.cal-head #cal-month { font-size: 16px; font-weight: 600; }
.cal-head .r { width: 36px; height: 36px; border-radius: 50%; background: var(--pill); display: grid; place-items: center; }
.cal-head .r svg { width: 18px; height: 18px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); row-gap: 2px; }
.cal .wd { font-size: 12px; font-weight: 600; color: var(--muted); text-align: center; padding: 4px 0 6px; }
.cal .day-c { height: 42px; display: grid; place-items: center; font-size: 16px; font-variant-numeric: tabular-nums; }
.cal .day-c span { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; }
.cal .day-c.past { color: var(--muted); }
.cal .day-c.now span { box-shadow: inset 0 0 0 1.5px var(--muted); }
.cal .day-c.in { background: color-mix(in srgb, var(--accent) 16%, transparent); }
.cal .day-c.lo { border-radius: 21px 0 0 21px; }
.cal .day-c.hi { border-radius: 0 21px 21px 0; }
.cal .day-c.lo.hi { border-radius: 21px; background: none; }
.cal .day-c.lo span, .cal .day-c.hi span { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.cal-sum { font-size: 15px; padding: 10px 2px 4px; min-height: 20px; }
.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;
}
