/* Pooltagebuch – mobile-first, einhändig bedienbar. Wasser-Cyan-Identität wie das Dashboard. */
:root {
  --bg: #e6eff3; --surface: #ffffff; --surface-2: #f2f8fa; --surface-3: #e8f1f5;
  --ink: #0f2430; --muted: #5c7482; --faint: #93a8b4;
  --line: #d3e0e7; --line-strong: #bcd2db;
  --accent: #0c8fac; --accent-ink: #ffffff; --accent-soft: #d4edf3;
  --gruen: #0f9e86; --gruen-soft: #d6f0ea;
  --gelb: #d97a1e; --gelb-soft: #f8e7d2;
  --rot: #d63d4a; --rot-soft: #f8dcde;
  --shadow-sm: 0 1px 2px rgba(15,36,48,.07);
  --shadow: 0 2px 8px rgba(15,36,48,.08), 0 12px 30px rgba(15,36,48,.07);
  --radius: 18px; --radius-sm: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tap: 60px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #071219; --surface: #0f232f; --surface-2: #0c1d27; --surface-3: #122b38;
    --ink: #e7f1f5; --muted: #90a9b6; --faint: #5f7885;
    --line: #1d3846; --line-strong: #28495a;
    --accent: #2bb6d3; --accent-ink: #04222c; --accent-soft: #12384492;
    --gruen: #24bfa2; --gruen-soft: #0e332e;
    --gelb: #e69445; --gelb-soft: #33230f;
    --rot: #ec5f6b; --rot-soft: #331419;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.3);
    --shadow: 0 2px 8px rgba(0,0,0,.35), 0 14px 34px rgba(0,0,0,.4);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
/* touch-action: manipulation unterbindet den Doppel-Tipp-Zoom beim schnellen Tippen (Stepper). */
html { -webkit-text-size-adjust: 100%; touch-action: manipulation; }
button, input, textarea, label, .stepper, .mini-row, .wasser-row, .seg-mini, .segment,
.hist-item, .akt-item, .add-chip, .taet-chip, .s-value { touch-action: manipulation; }
body {
  font-family: var(--font); color: var(--ink); background: var(--bg);
  min-height: 100dvh; line-height: 1.45; -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
h1, h2, h3 { line-height: 1.15; letter-spacing: -.02em; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

/* ------------------------------------------------------------------ App-Shell */
.app {
  max-width: 520px; margin: 0 auto; min-height: 100dvh;
  display: flex; flex-direction: column;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 17px; }
.topbar .brand svg { color: var(--accent); }
.topbar .spacer { flex: 1; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  color: var(--muted); background: var(--surface); border: 1px solid var(--line);
}
.icon-btn:active { transform: scale(.94); }

/* Segment control (Eingeben / Verlauf) */
.segment {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 14px 16px 4px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 4px;
}
.segment button {
  padding: 10px; border-radius: 10px; font-weight: 600; font-size: 15px; color: var(--muted);
  transition: background .15s, color .15s;
}
.segment button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

main { flex: 1; padding: 8px 16px 0; }
.view { animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ Stepper */
.date-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 6px 2px 14px; color: var(--muted); font-size: 14px;
}
.date-row input[type="date"] {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 10px; color: var(--ink);
}

.stepper {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 16px; margin-bottom: 14px;
  border-left: 5px solid var(--line);
  transition: border-color .2s, background .2s;
}
.stepper.s-gruen { border-left-color: var(--gruen); }
.stepper.s-gelb { border-left-color: var(--gelb); }
.stepper.s-rot { border-left-color: var(--rot); }
.stepper .s-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.stepper .s-label { font-weight: 650; font-size: 16px; }
.stepper .s-pill {
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted);
}
.stepper.s-gruen .s-pill { background: var(--gruen-soft); color: var(--gruen); }
.stepper.s-gelb .s-pill { background: var(--gelb-soft); color: var(--gelb); }
.stepper.s-rot .s-pill { background: var(--rot-soft); color: var(--rot); }

.s-controls { display: grid; grid-template-columns: var(--tap) 1fr var(--tap); align-items: center; gap: 12px; }
.s-btn {
  width: var(--tap); height: var(--tap); border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--accent);
  display: grid; place-items: center; font-size: 30px; font-weight: 400;
  transition: transform .08s, background .12s;
  user-select: none;
}
.s-btn:active { transform: scale(.9); background: var(--accent-soft); }
.s-btn svg { width: 26px; height: 26px; }
.s-value { text-align: center; }
.s-value .v { font-size: 46px; font-weight: 750; letter-spacing: -.03em; line-height: 1; }
.s-value .u { font-size: 13px; color: var(--muted); margin-top: 4px; font-weight: 600; }
.s-value .v.empty { color: var(--faint); font-weight: 600; font-size: 30px; }

/* ------------------------------------------------------------------ Weitere Werte (aufklappbar) */
.more {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 14px;
}
.more > summary {
  list-style: none; cursor: pointer; padding: 16px; display: flex; align-items: center; gap: 10px;
  font-weight: 600; color: var(--ink);
}
.more > summary::-webkit-details-marker { display: none; }
.more > summary .chev { margin-left: auto; color: var(--muted); transition: transform .2s; }
.more[open] > summary .chev { transform: rotate(180deg); }
.more[open] > summary { border-bottom: 1px solid var(--line); }
.more .more-body { padding: 6px 16px 16px; display: flex; flex-direction: column; gap: 4px; }
.mini-row {
  display: grid; grid-template-columns: 1fr auto auto auto; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.mini-row:last-child { border-bottom: none; }
.mini-row .m-label { font-size: 15px; }
.mini-row .m-label small { display: block; color: var(--faint); font-size: 11.5px; font-weight: 500; }
.mini-btn {
  width: 40px; height: 40px; border-radius: 10px; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--accent); display: grid; place-items: center; font-size: 22px;
}
.mini-btn:active { transform: scale(.9); }
.mini-val { min-width: 56px; text-align: center; font-weight: 700; font-size: 17px; }
.mini-val.empty { color: var(--faint); font-weight: 500; }
.note-field {
  width: 100%; margin-top: 12px; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px; background: var(--surface-2); color: var(--ink); resize: none; min-height: 70px;
}

/* ------------------------------------------------------------------ Bottom-Aktion */
.bottombar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 62%, transparent);
  display: flex; justify-content: center;
}
.bottombar .inner { width: 100%; max-width: 520px; }
.btn-primary {
  width: 100%; min-height: 58px; border-radius: 16px; background: var(--accent); color: var(--accent-ink);
  font-size: 18px; font-weight: 700; box-shadow: var(--shadow); display: flex; align-items: center;
  justify-content: center; gap: 10px; transition: transform .1s, opacity .2s;
}
.btn-primary:active { transform: scale(.985); }
.btn-primary:disabled { opacity: .5; }
.btn-ghost {
  width: 100%; min-height: 52px; border-radius: 14px; background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); font-weight: 600; font-size: 16px;
}
.btn-danger {
  width: 100%; min-height: 54px; border-radius: 14px; background: var(--rot); color: #fff;
  font-weight: 700; font-size: 16px; box-shadow: var(--shadow);
}
.btn-danger:active { transform: scale(.985); }

/* ------------------------------------------------------------------ Ergebnis */
.result { text-align: center; padding-top: 8px; }
.result .badge {
  width: 108px; height: 108px; border-radius: 50%; margin: 8px auto 16px; display: grid; place-items: center;
  animation: pop .4s cubic-bezier(.2,1.2,.4,1);
}
@keyframes pop { from { transform: scale(.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.result .badge svg { width: 56px; height: 56px; color: #fff; }
.result.gruen .badge { background: var(--gruen); }
.result.gelb .badge { background: var(--gelb); }
.result.rot .badge { background: var(--rot); }
.result h2 { font-size: 24px; margin-bottom: 6px; }
.result .r-sub { color: var(--muted); margin-bottom: 20px; padding: 0 10px; }

.recs { display: flex; flex-direction: column; gap: 12px; text-align: left; }
.rec {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 15px 16px; display: grid;
  grid-template-columns: 34px 1fr; gap: 13px; align-items: start; border-left: 5px solid var(--line);
}
.rec.a-zugeben { border-left-color: var(--gruen); } .rec.a-vermeiden { border-left-color: var(--rot); } .rec.a-hinweis { border-left-color: var(--accent); }
.rec .r-dot { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; }
.rec.a-zugeben .r-dot { background: var(--gruen-soft); color: var(--gruen); }
.rec.a-vermeiden .r-dot { background: var(--rot-soft); color: var(--rot); }
.rec.a-hinweis .r-dot { background: var(--accent-soft); color: var(--accent); }
.rec .r-dot svg { width: 19px; height: 19px; }
.rec .r-label { font-weight: 700; font-size: 14px; margin-bottom: 3px; }
.rec .r-text { font-size: 14.5px; color: var(--ink); }
.rec .r-text b { color: var(--accent); }
.result .disclaimer { color: var(--faint); font-size: 12px; margin-top: 18px; padding: 0 8px; }

/* ------------------------------------------------------------------ Verlauf */
.hist { display: flex; flex-direction: column; gap: 10px; padding-top: 4px; }
.hist-empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.hist-item {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm); padding: 13px 14px; display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  border-left: 4px solid var(--line);
}
.hist-item.a-gruen { border-left-color: var(--gruen); } .hist-item.a-gelb { border-left-color: var(--gelb); } .hist-item.a-rot { border-left-color: var(--rot); }
.hist-date { text-align: center; min-width: 44px; }
.hist-date .d { font-size: 20px; font-weight: 750; line-height: 1; }
.hist-date .m { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.hist-vals { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 8px; background: var(--surface-2); color: var(--muted); }
.chip b { color: var(--ink); font-weight: 700; }
.hist-note { font-size: 12.5px; color: var(--faint); margin-top: 4px; flex-basis: 100%; }
.hist-item .del { color: var(--faint); width: 34px; height: 34px; display: grid; place-items: center; border-radius: 9px; }
.hist-item .del:active { background: var(--rot-soft); color: var(--rot); }

/* ------------------------------------------------------------------ Sheet / Modal */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(8,20,28,.45); z-index: 40; display: flex; align-items: flex-end;
  animation: fade .2s ease;
}
.sheet {
  width: 100%; max-width: 520px; margin: 0 auto; background: var(--surface);
  border-radius: 22px 22px 0 0; padding: 20px 20px calc(24px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow); animation: up .28s cubic-bezier(.2,.9,.3,1);
}
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
.sheet h3 { font-size: 19px; margin-bottom: 4px; }
.sheet p { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.sheet .field { margin-bottom: 16px; }
.grip { width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 0 auto 14px; }
.sheet-sep { height: 1px; background: var(--line); margin: 20px 0 16px; }
.sheet-hint { color: var(--faint); font-size: 12.5px; margin-top: 8px; text-align: center; }

/* ------------------------------------------------------------------ Felder / Login */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input {
  border: 1px solid var(--line-strong); border-radius: 12px; padding: 14px; background: var(--surface-2);
  color: var(--ink); font-size: 16px;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

.login-body { display: grid; place-items: center; min-height: 100dvh; padding: 24px; background: radial-gradient(120% 90% at 50% -10%, var(--surface-3), var(--bg) 60%); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); padding: 32px 26px; text-align: center; }
.login-logo { color: var(--accent); margin-bottom: 12px; }
.login-card h1 { font-size: 26px; }
.login-sub { color: var(--muted); margin-bottom: 24px; font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 16px; text-align: left; }
.login-form .btn-primary { margin-top: 6px; }
.login-fehler { color: var(--rot); font-size: 14px; margin-top: 14px; font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: calc(104px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--surface); padding: 11px 18px; border-radius: 12px; font-size: 14px;
  font-weight: 600; z-index: 50; box-shadow: var(--shadow); animation: fade .2s ease;
}
:root[data-theme] .toast, .toast { color: #fff; }

/* ------------------------------------------------------------------ Wasserbild (prominent) */
.wasser-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.wasser-choice button {
  min-height: 54px; border-radius: 12px; border: 1.5px solid var(--line-strong);
  background: var(--surface-2); color: var(--muted); font-size: 16px; font-weight: 650;
  transition: background .15s, border-color .15s, color .15s;
}
.wasser-choice button:active { transform: scale(.97); }
.wasser-choice button[aria-pressed="true"][data-w="klar"] { background: var(--gruen-soft); border-color: var(--gruen); color: var(--gruen); }
.wasser-choice button[aria-pressed="true"][data-w="trueb"] { background: var(--gelb-soft); border-color: var(--gelb); color: var(--gelb); }
.s-pill.s-empty { background: transparent; color: var(--faint); font-weight: 500; font-style: italic; }

/* ------------------------------------------------------------------ Warnungen (Ergebnis) */
.warnungen { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; text-align: left; }
.warnbox {
  display: grid; grid-template-columns: 22px 1fr; gap: 11px; align-items: start;
  background: var(--gelb-soft); border: 1px solid var(--gelb); border-radius: 12px;
  padding: 12px 14px; font-size: 13.5px; line-height: 1.4; color: var(--ink);
}
.warnbox .wb-icon { color: var(--gelb); display: grid; place-items: center; margin-top: 1px; }
.warnbox .wb-icon svg { width: 20px; height: 20px; }
.warnbox b { color: var(--gelb); }

/* ------------------------------------------------------------------ Maßnahmen erfassen */
.aktionen { text-align: left; margin-top: 24px; border-top: 1px solid var(--line); padding-top: 20px; }
.akt-title { font-size: 18px; font-weight: 700; }
.akt-sub { color: var(--muted); font-size: 13.5px; margin: 4px 0 14px; }
.akt-active { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.akt-item {
  display: grid; grid-template-columns: 32px 1fr auto auto auto; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; padding: 8px 10px 8px 6px;
}
.akt-item .akt-x { width: 30px; height: 30px; border-radius: 8px; color: var(--faint); display: grid; place-items: center; }
.akt-item .akt-x:active { background: var(--rot-soft); color: var(--rot); }
.akt-item .akt-x svg { width: 16px; height: 16px; }
.akt-name { font-weight: 650; font-size: 15px; }
.akt-menge { min-width: 62px; text-align: center; font-weight: 700; font-size: 15px; }
.akt-add { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.add-chip { border: 1px dashed var(--line-strong); color: var(--muted); background: var(--surface); border-radius: 999px; padding: 8px 13px; font-size: 13.5px; font-weight: 600; }
.add-chip:active { transform: scale(.95); border-color: var(--accent); color: var(--accent); }
.akt-taet { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; }
.taet-chip { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); border-radius: 999px; padding: 9px 14px; font-size: 13.5px; font-weight: 600; }
.taet-chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.taet-chip:active { transform: scale(.96); }
.aktionen .note-field { margin-top: 12px; }

/* ------------------------------------------------------------------ Verlauf: Wasser & Maßnahmen */
.wtag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 3px 9px; border-radius: 8px; }
.wtag svg { width: 12px; height: 12px; }
.wtag.klar { background: var(--gruen-soft); color: var(--gruen); }
.wtag.trueb { background: var(--gelb-soft); color: var(--gelb); }
.hist-massn { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; flex-basis: 100%; }
.mtag { font-size: 11.5px; font-weight: 600; color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); border-radius: 7px; padding: 2px 7px; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
