:root {
  --bg: #f6f3ee;
  --card: #ffffff;
  --card-2: #efebe4;
  --text: #1f2a2e;
  --muted: #5e6b6f;
  --line: #e2ddd4;
  --accent: #2f7d7a;
  --accent-ink: #ffffff;
  --accent-soft: #dcefed;
  --good: #4f9a62;
  --good-soft: #e1f0e4;
  --warm: #d98b4a;
  --warm-soft: #f8e7d7;
  --sos: #c9573f;
  --sos-soft: #f7e0da;
  --shadow: 0 1px 2px rgba(31, 42, 46, .06), 0 4px 16px rgba(31, 42, 46, .06);
  --radius: 18px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111719;
    --card: #1a2326;
    --card-2: #222d30;
    --text: #e6eded;
    --muted: #9aabad;
    --line: #2b383b;
    --accent: #5cb5af;
    --accent-ink: #0d1a1a;
    --accent-soft: #1d3837;
    --good: #72bb85;
    --good-soft: #1f3526;
    --warm: #e0a068;
    --warm-soft: #3a2a1d;
    --sos: #e27a62;
    --sos-soft: #3c231d;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; text-wrap: balance; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* Kopfzeile & Navigation */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 1.1rem; }
.brand img { border-radius: 8px; }
.sos-mini {
  border: 0; border-radius: 999px; padding: 8px 16px;
  background: var(--sos); color: #fff; font-weight: 700; letter-spacing: .04em;
}
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  border: 0; background: none; padding: 8px 4px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: .72rem; color: var(--muted);
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button[aria-current="page"] { color: var(--accent); font-weight: 600; }

main { max-width: 560px; margin: 0 auto; padding: 4px 16px 24px; outline: none; }

/* Karten */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px; margin-bottom: 14px;
}
.card.soft { background: var(--accent-soft); box-shadow: none; }
.card.warm { background: var(--warm-soft); box-shadow: none; }
.greeting { margin: 12px 0 18px; }
.greeting p { margin: 0; }

.sos-card {
  display: block; width: 100%; text-align: left; border: 0;
  background: linear-gradient(135deg, var(--sos), color-mix(in srgb, var(--sos) 70%, #7a2d6a));
  color: #fff; border-radius: 22px; padding: 22px 20px; margin-bottom: 16px;
  box-shadow: 0 6px 20px color-mix(in srgb, var(--sos) 30%, transparent);
}
.sos-card strong { display: block; font-size: 1.35rem; margin-bottom: 4px; }
.sos-card span { opacity: .92; }

.quick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.quick button {
  border: 0; border-radius: 16px; background: var(--card); box-shadow: var(--shadow);
  padding: 14px; text-align: left; display: flex; flex-direction: column; gap: 2px; min-height: 76px;
}
.quick .ico { font-size: 1.3rem; line-height: 1; }
.quick b { font-weight: 600; }
.quick small { color: var(--muted); font-size: .78rem; }

.banner {
  display: flex; gap: 12px; align-items: center; justify-content: space-between;
  background: var(--accent-soft); border-radius: 16px; padding: 14px 16px; margin-bottom: 16px;
}
.banner p { margin: 0; }

/* Wochenpunkte */
.days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; margin: 10px 0 6px; }
.day { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: .72rem; color: var(--muted); }
.dot { width: 30px; height: 30px; border-radius: 50%; background: var(--card-2); display: grid; place-items: center; font-size: .8rem; color: var(--text); }
.dot.good { background: var(--good); color: #fff; }
.dot.binge { background: var(--warm); color: #fff; }
.dot.open { background: transparent; border: 2px dashed var(--line); }
.day.today .dot { outline: 2px solid var(--accent); outline-offset: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: .78rem; color: var(--muted); margin-top: 8px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.stat { background: var(--card-2); border-radius: 14px; padding: 12px; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: .8rem; color: var(--muted); }

/* Einträge */
.entries { list-style: none; margin: 0; padding: 0; }
.entry { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.entry:first-child { border-top: 0; }
.entry .tag { flex: 0 0 auto; width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--card-2); font-size: 1.05rem; }
.entry .body { flex: 1; min-width: 0; }
.entry .body b { font-weight: 600; }
.entry .meta { font-size: .82rem; color: var(--muted); overflow-wrap: anywhere; }
.entry .del { border: 0; background: none; color: var(--muted); padding: 6px; border-radius: 8px; font-size: 1.1rem; line-height: 1; }
.dayhead { font-size: .8rem; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: 16px 0 4px; }

/* Balken */
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: 8.5em 1fr 2em; gap: 8px; align-items: center; font-size: .88rem; }
.bar .track { height: 10px; background: var(--card-2); border-radius: 99px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--accent); border-radius: 99px; }
.bar .n { text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }
.insight { padding: 12px 14px; background: var(--accent-soft); border-radius: 14px; margin-top: 10px; font-size: .93rem; }

/* Buttons */
.btn {
  border: 0; border-radius: 14px; padding: 13px 18px; font-weight: 600;
  background: var(--accent); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-decoration: none; min-height: 48px;
}
.btn.block { width: 100%; }
.btn.ghost { background: var(--card-2); color: var(--text); }
.btn.line { background: transparent; border: 1.5px solid var(--line); color: var(--text); }
.btn.sos { background: var(--sos); color: #fff; }
.btn.small { padding: 8px 14px; min-height: 38px; font-size: .9rem; border-radius: 12px; }
.btn.danger { background: transparent; color: var(--sos); border: 1.5px solid var(--sos); }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > .btn { flex: 1 1 140px; }
.stack { display: grid; gap: 10px; }

/* Formular */
.field { margin-bottom: 18px; }
.field > label, .field > .label { display: block; font-weight: 600; margin-bottom: 8px; }
.field .hint { font-size: .82rem; color: var(--muted); margin: -4px 0 8px; }
input[type="text"], input[type="tel"], input[type="date"], input[type="time"], textarea {
  width: 100%; border: 1.5px solid var(--line); background: var(--card); border-radius: 12px; padding: 11px 12px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 13px; font-size: .9rem;
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 6px; }
.seg .chip { border-radius: 12px; padding: 10px 4px; text-align: center; }
.scale-labels { display: flex; justify-content: space-between; font-size: .75rem; color: var(--muted); margin-top: 4px; }
input[type="range"] { width: 100%; accent-color: var(--accent); height: 32px; }
.range-val { font-weight: 700; color: var(--accent); }

/* Bottom Sheet */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 20; background: rgba(10, 18, 20, .45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-backdrop[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); border-radius: 22px 22px 0 0; padding: 10px 16px calc(20px + env(safe-area-inset-bottom));
  animation: up .22s ease-out;
}
.sheet .grab { width: 40px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 12px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.sheet-head h2 { margin: 0; }
.x { border: 0; background: var(--card-2); width: 36px; height: 36px; border-radius: 50%; font-size: 1.2rem; line-height: 1; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Vollbild (SOS, Onboarding) */
.fullscreen {
  position: fixed; inset: 0; z-index: 30; overflow-y: auto; background: var(--bg);
  padding: calc(16px + env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}
.fullscreen[hidden] { display: none; }
.fs-inner { max-width: 520px; margin: 0 auto; }
.fs-top { display: flex; justify-content: flex-end; }

.sos-timer { text-align: center; margin: 4px 0 8px; }
.sos-timer .time { font-size: 3rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .02em; line-height: 1.1; }
.wave-svg { width: 100%; height: auto; display: block; margin: 6px 0 2px; }
.wave-svg .base { fill: none; stroke: var(--line); stroke-width: 3; }
.wave-svg .done { fill: none; stroke: var(--sos); stroke-width: 4; stroke-linecap: round; }
.wave-svg .ball { fill: var(--sos); }
.wave-svg text { fill: var(--muted); font-size: 11px; }

.breath { display: grid; place-items: center; margin: 18px 0; }
.breath .circle {
  width: 150px; height: 150px; border-radius: 50%; display: grid; place-items: center; text-align: center;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--accent) 45%, var(--card)), var(--accent-soft));
  color: var(--text); font-weight: 600; transform: scale(.72); transition: transform 4s ease-in-out;
}
.breath .circle.in { transform: scale(1); transition-duration: 4s; }
.breath .circle.out { transform: scale(.72); transition-duration: 6s; }

.quote {
  font-size: 1.15rem; font-weight: 500; text-align: center; padding: 18px; border-radius: 18px;
  background: var(--card); box-shadow: var(--shadow); margin-bottom: 14px; text-wrap: pretty;
}
.alt-list { display: grid; gap: 8px; }
.alt-list .chip { text-align: left; border-radius: 14px; padding: 12px 14px; font-size: .95rem; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 40;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: .92rem;
  transition: .25s; max-width: calc(100% - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.note-from {
  border-left: 4px solid var(--accent); background: var(--card); border-radius: 0 14px 14px 0;
  padding: 14px 16px; margin: 14px 0; white-space: pre-line; box-shadow: var(--shadow);
}
.help-list { padding-left: 1.2em; margin: 0 0 .75rem; }
.help-list li { margin-bottom: .35rem; }
.phone { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 0; border-top: 1px solid var(--line); }
.phone:first-of-type { border-top: 0; }
.phone div { min-width: 0; }
.empty { text-align: center; color: var(--muted); padding: 10px 0; }

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