:root {
  /* Event-Farben – FIX, niemals aendern (fachliche Vorgabe: identisch fuer alle Familien) */
  --sleep: #3B4A8C;     /* Indigo */
  --cry: #E5694D;       /* Koralle */
  --meal: #F2B400;      /* sattes Gelb/Gold (mit Kommentar getauscht) */
  --stillen: #F2B400;   /* wie Mahlzeit (Unterscheidung über Form: Kreis) */
  --happy: #E0689E;     /* Rosé – HappyNote */
  --comment: #E5694D;
  --accent: #F2C200;    /* Kommentar-Gelb */

  /* Neutrale Flaechen – warmes Papier, leicht indigo-getoentes Ink (Abendhimmel-Anker) */
  --bg: #F7F3EC;
  --card: #FFFDF9;
  --ink: #2B2B3A;
  --muted: #857F8C;
  --line: #EAE2D3;
  --tile-bg: #cdbfae;

  /* Skala */
  --radius: 20px;
  --radius-sm: 12px;
  --radius-lg: 24px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --nav-h: 60px;

  /* dekorative Helfer (additiv) */
  --shadow-card: 0 1px 2px rgba(43,43,58,.04), 0 8px 22px -16px rgba(43,43,58,.35);
  --shadow-tile: 0 10px 26px -14px var(--tile-color, rgba(43,43,58,.4)), 0 2px 6px -3px rgba(43,43,58,.18);
  --shadow-modal: 0 -12px 34px -18px rgba(43,43,58,.4);
  --ring-soft: inset 0 1px 0 rgba(255,255,255,.5);
  --focus-ring: 0 0 0 3px color-mix(in srgb, var(--sleep) 45%, transparent);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex; flex-direction: column; min-height: 100dvh;
}

/* ---------- Quality floor: Fokus, Reduced Motion ---------- */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: 10px;
}
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.tile:focus-visible, .fam-tile:focus-visible, .day-item:focus-visible, a.stat-card:focus-visible {
  box-shadow: var(--focus-ring), var(--shadow-card);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Topbar ---------- */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 18px 12px; gap: 12px; flex: 0 0 auto;
  position: relative;
  /* Signature: hauchdünner Abendhimmel-Verlauf – bewusst zurückhaltend */
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 7%, transparent), transparent 75%);
}
#topbar::after { /* feine Trennkante mit Lichtverlauf */
  content:""; position:absolute; left:18px; right:18px; bottom:0; height:1px;
  background: linear-gradient(90deg, transparent, var(--line) 18%, var(--line) 82%, transparent);
}
#childInfo { text-align: center; line-height: 1.15; position: relative; }
.moon-glyph {
  display: none; position: absolute; top: -3px; right: -22px; width: 14px; height: 14px;
  color: color-mix(in srgb, var(--accent) 70%, #fff); opacity: .85; pointer-events: none;
}
.moon-glyph svg { width: 100%; height: 100%; display: block; }
:root[data-theme="dark"] .moon-glyph { display: block; }
.clock-mini {
  font-size: 19px; font-weight: 600; color: var(--muted);
  font-variant-numeric: tabular-nums; line-height: 1;
  min-width: 44px; text-align: right; letter-spacing: .5px;
}
#childName {
  font-family: "Fraunces", Georgia, serif; font-size: 22px; font-weight: 600;
  letter-spacing: .1px; line-height: 1.1; color: var(--ink);
}
#childAge { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; letter-spacing:.2px; }

/* Kind-Wechsler: Name ist klickbar, kleines Caret daneben */
.child-switch {
  background: none; border: none; padding: 4px 8px; cursor: pointer; color: var(--ink);
  display: inline-flex; align-items: center; gap: 5px; border-radius: 12px;
  font: inherit; line-height: 1.05;
  transition: background .15s ease;
}
.child-switch:active { background: rgba(139,131,118,.14); }
.child-switch .caret { width: 15px; height: 15px; color: var(--muted); flex: 0 0 auto; margin-top: 2px; }
#childInfo { position: relative; }
.child-pop {
  position: absolute; top: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  min-width: 220px; background: var(--card); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: 0 16px 40px -18px rgba(46,42,51,.55);
  padding: 8px; z-index: 60; display: flex; flex-direction: column; gap: 2px;
}
.child-pop[hidden] { display: none; }
.child-opt {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: none; border: none; cursor: pointer; font: inherit; color: var(--ink);
  padding: 11px 12px; border-radius: 11px; text-align: left;
}
.child-opt:active { background: var(--bg); }
.child-opt.active { background: color-mix(in srgb, var(--sleep) 10%, transparent); }
.child-opt .co-name { font-weight: 600; font-size: 15.5px; }
.child-opt.active .co-name { color: var(--sleep); }
.child-opt .co-age { font-size: 12.5px; color: var(--muted); }
.child-opt.child-add { color: var(--muted); font-size: 14px; font-weight: 600; border-top: 1px solid var(--line); border-radius: 0 0 11px 11px; margin-top: 4px; padding-top: 12px; }

.topbar-right { display: flex; align-items: center; gap: 4px; }
.topbar-left { display: flex; align-items: center; min-width: 44px; min-height: 44px; }
/* Familien-App: Kind sitzt links in der Topbar (berater.html laesst es zentriert) */
.topbar-left #childInfo { text-align: left; }
.topbar-left #childInfo .child-pop { left: 0; transform: none; }
.topbar-left .child-switch { padding-left: 0; }
.fb-intro { font-size: 13.5px; color: var(--muted); margin: -6px 0 14px; line-height: 1.45; }
.field textarea {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-size: 16px; background: var(--card); color: var(--ink); resize: vertical;
}
.toast {
  position: fixed; left: 50%; transform: translateX(-50%) translateY(8px);
  bottom: calc(var(--nav-h) + var(--safe-b) + 18px); z-index: 80;
  background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 600;
  padding: 12px 18px; border-radius: 13px; box-shadow: 0 14px 30px -14px rgba(0,0,0,.6);
  opacity: 0; transition: opacity .25s ease, transform .25s ease; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast[hidden] { display: none; }

/* ---------- Berater-Sicht: Familien-Kacheln ---------- */
.fam-head { max-width: 560px; width: 100%; margin: 4px auto 14px; }
.fam-head h2 { margin: 0 0 6px; font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 22px; letter-spacing: .1px; }
.fam-tiles { display: grid; grid-template-columns: 1fr; gap: 13px; max-width: 560px; width: 100%; margin: 0 auto; }
@media (min-width: 620px) { .fam-tiles { grid-template-columns: 1fr 1fr; } }
.fam-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 5px;
  border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer;
  background: var(--card); padding: 18px 18px 16px; text-align: left; font: inherit; color: var(--ink);
  box-shadow: var(--shadow-card);
  transition: transform .1s ease, box-shadow .15s ease, border-color .15s ease;
}
.fam-tile:hover { box-shadow: 0 12px 28px -14px rgba(43,43,58,.4); border-color: #d3c8b0; transform: translateY(-2px); }
.fam-tile:active { transform: scale(.99); }
/* Monogramm-Avatar als echtes Element (der fruehere ::first-letter-Drop-Cap
   schnitt den Buchstaben ab und verschluckte ihn im Namen) */
.fam-tile .ft-head { display: flex; align-items: center; gap: 10px; min-height: 34px; padding-right: 36px; }
.fam-tile .ft-avatar {
  width: 34px; height: 34px; flex: 0 0 auto; border-radius: 50%;
  background: color-mix(in srgb, var(--sleep) 88%, black); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 13.5px; font-weight: 700; letter-spacing: .5px; text-transform: uppercase;
}
.fam-tile .ft-name {
  display: block;
  font-family: "Fraunces", Georgia, serif; font-size: 18.5px; font-weight: 600; color: var(--ink);
  letter-spacing: .1px;
}
.fam-tile .ft-kids { font-size: 14px; font-weight: 600; color: var(--ink); }
.fam-tile .ft-meta { font-size: 12px; color: var(--muted); letter-spacing: .1px; }

/* Berater-Topbar: Familie als Plakette neben dem Kind */
.head-row { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.fam-badge {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer; font: inherit;
  background: color-mix(in srgb, #2a9d8f 14%, transparent);
  color: #1f7d72; border: 1px solid color-mix(in srgb, #2a9d8f 35%, transparent);
  border-radius: 999px; padding: 6px 12px;
  font-size: 15px; font-weight: 700; letter-spacing: .2px; line-height: 1.1;
  transition: background .15s ease;
}
.fam-badge:active { background: color-mix(in srgb, #2a9d8f 24%, transparent); }
.fam-badge .caret { width: 14px; height: 14px; color: currentColor; flex: 0 0 auto; }
:root[data-theme="dark"] .fam-badge { color: #6fd0c4; background: rgba(42,157,143,.18); border-color: rgba(42,157,143,.4); }

/* Stift auf der Familien-Kachel */
.fam-tile { position: relative; }
.fam-tile .ft-edit {
  position: absolute; top: 10px; right: 10px; width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center; border-radius: 10px;
  color: var(--muted); background: transparent; transition: background .15s ease, color .15s ease;
}
.fam-tile .ft-edit:hover { background: var(--bg); color: var(--ink); }
.fam-tile .ft-edit svg { width: 17px; height: 17px; }
.fam-add-wrap { max-width: 560px; width: 100%; margin: 14px auto 0; }
.fam-add-wrap .primary-btn { width: 100%; }

/* Berater-Notizen */
.notes-wrap { max-width: 560px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.note-form { display: flex; flex-direction: column; gap: 10px; }
.note-form textarea {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 12px;
  font: inherit; font-size: 16px; background: var(--card); color: var(--ink); resize: vertical;
}
.note-list { display: flex; flex-direction: column; gap: 10px; }
.note-item {
  background: var(--card); border: 1px solid var(--line); border-radius: 15px;
  padding: 12px 14px; box-shadow: var(--shadow-card);
}
.note-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.note-date { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.note-actions { display: flex; gap: 2px; }
.note-del, .note-edit { width: 30px; height: 30px; border: none; background: transparent; box-shadow: none; font-size: 14px; }
.note-edit svg { width: 15px; height: 15px; }

/* Trennzeile im Familie-verbinden-Modal */
.fm-divider {
  display: flex; align-items: center; gap: 12px; margin: 4px 0 14px;
  color: var(--muted); font-size: 12.5px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase;
}
.fm-divider::before, .fm-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.note-text { font-size: 15px; line-height: 1.5; white-space: pre-wrap; }

/* Select im Einstellungen-Modal (Demo-Familienwechsler) */
.field select {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  font: inherit; font-size: 16px; background: var(--card); color: var(--ink);
}
.icon-btn {
  background: none; border: none; font-size: 22px; color: var(--muted);
  width: 44px; height: 44px; cursor: pointer; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center; line-height: 1; padding: 0;
  transition: background .15s ease, color .15s ease;
}
.icon-btn:active { background: rgba(139,131,118,.14); color: var(--ink); }

/* ---------- Views ---------- */
.view { display: none; flex: 1; padding: 8px 16px 90px; }
.view.active { display: flex; flex-direction: column; }
#view-input.view.active { min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; scrollbar-gutter: stable both-edges; }
#view-input { padding-bottom: calc(var(--nav-h) + var(--safe-b) + 86px); }

/* ---------- Tiles ---------- */
.tiles { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 13px; max-width: 520px; width: 100%; margin: 6px auto 10px; }
.tile {
  position: relative; border: none; padding: 14px; cursor: pointer;
  border-radius: var(--radius); color: #fff; aspect-ratio: 1 / 1; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  background:
    radial-gradient(120% 100% at 50% -20%, rgba(255,255,255,.28), transparent 55%),
    linear-gradient(165deg, color-mix(in srgb, var(--tile-color) 88%, white) 0%, var(--tile-color) 48%, color-mix(in srgb, var(--tile-color) 86%, black) 100%);
  box-shadow: var(--shadow-tile);
  transition: transform .12s ease, box-shadow .25s ease, filter .2s ease;
  isolation: isolate;
}
.tile::after { /* weiches Oberlicht */
  content:""; position:absolute; inset:0; pointer-events:none; z-index:0;
  background: linear-gradient(180deg, rgba(255,255,255,.16), transparent 42%);
  mix-blend-mode: soft-light;
}
.tile:active { transform: scale(.97); filter: brightness(.96); }
@media (hover: hover) {
  .tile:hover { box-shadow: 0 14px 30px -14px var(--tile-color, rgba(43,43,58,.4)), 0 2px 6px -3px rgba(43,43,58,.22); }
}
.tile-sleep   { --tile-color: var(--sleep); }
.tile-cry     { --tile-color: var(--cry); }
.tile-meal    { --tile-color: var(--meal); }
.tile-stillen { --tile-color: var(--stillen); }
.tile-happynote { --tile-color: var(--happy); }

/* Farbmenü in den Einstellungen (höhere Spezifität als .field label) */
.color-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 4px 0 12px; }
.color-grid .color-row { display: flex; align-items: center; gap: 11px; margin: 0; font-size: 14.5px; line-height: 1; color: var(--ink); cursor: pointer; }
.color-grid .color-row span { display: inline; }
.color-row input[type="color"] {
  width: 34px; height: 34px; flex: 0 0 auto; padding: 0; margin: 0; cursor: pointer;
  border: none; border-radius: 9px; background: none;
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
}
.color-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-row input[type="color"]::-webkit-color-swatch { border: none; border-radius: 9px; }
.color-row input[type="color"]::-moz-color-swatch { border: none; border-radius: 9px; }
/* Checkboxen (Diagramme im Druck) teilen sich die .color-row/.color-grid Struktur mit den Farbwaehlern */
.color-row input[type="checkbox"] {
  width: 22px; height: 22px; flex: 0 0 auto; margin: 0; cursor: pointer; accent-color: var(--sleep);
}
.color-row { min-height: 44px; }
.tile-ico {
  position: relative; z-index: 1; width: 72px; height: 72px;
  display: flex; align-items: center; justify-content: center;
}
.tile-ico::before {
  content: ""; position: absolute; inset: 0;
  background: rgba(255,255,255,.17);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35), inset 0 -8px 18px -10px rgba(0,0,0,.25);
}
.tile-ico svg { position: relative; z-index: 1; width: 37px; height: 37px; color: #fff; display: block; filter: drop-shadow(0 2px 4px rgba(0,0,0,.18)); }
.tile-sleep .tile-ico::before { border-radius: 30%; }
.tile-cry .tile-ico::before {
  border-radius: 30%;
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.48) 0 4px, transparent 4px 8px);
}
.tile-meal .tile-ico::before {
  background: rgba(255,255,255,.34);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath d='M45.91 8.02 Q50 0 54.09 8.02 L95.91 89.98 Q100 98 91 98 L9 98 Q0 98 4.09 89.98 Z' fill='%23fff'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath d='M45.91 8.02 Q50 0 54.09 8.02 L95.91 89.98 Q100 98 91 98 L9 98 Q0 98 4.09 89.98 Z' fill='%23fff'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
.tile-meal .tile-ico svg { transform: translateY(7px); }
.tile-stillen .tile-ico::before { border-radius: 50%; }
.tile-happynote .tile-ico::before { border-radius: 50%; }
.tile-label { position: relative; z-index: 1; font-size: 18px; font-weight: 700; letter-spacing: .3px; text-shadow: 0 1px 2px rgba(0,0,0,.12); }
.tile-wide { grid-column: 1 / -1; }

/* HappyNote als runder Knopf in der Mitte, eingebettet zwischen den vier Kacheln */
.tile-happynote {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 30%; height: auto; aspect-ratio: 1 / 1; padding: 0;
  border-radius: 50%; z-index: 3; gap: 4px;
  /* kein sichtbarer Rand: nur eine Luecke in Hintergrundfarbe -> die vier Kacheln wirken ausgeschnitten */
  box-shadow: 0 0 0 6px var(--bg), var(--shadow-tile);
}
.tile-happynote:active { transform: translate(-50%, -50%) scale(.96); }
.tile-happynote .tile-ico { width: 52px; height: 52px; }
.tile-happynote .tile-ico svg { width: 27px; height: 27px; }
.tile-happynote .tile-label { font-size: 13px; }

/* Inhalte der 4 Kacheln zur Aussenecke ruecken, damit der Mittel-Kreis
   auch lange Status-Texte („weint seit 21:33") nicht mehr ueberdeckt */
.tiles > .tile:nth-child(1) { padding: 14px 32px 26px 14px; align-items: flex-start; }
.tiles > .tile:nth-child(2) { padding: 14px 14px 26px 32px; align-items: flex-end; }
.tiles > .tile:nth-child(3) { padding: 26px 32px 14px 14px; align-items: flex-start; }
.tiles > .tile:nth-child(4) { padding: 26px 14px 14px 32px; align-items: flex-end; }
.tiles > .tile:nth-child(1) .tile-state, .tiles > .tile:nth-child(1) .tile-label,
.tiles > .tile:nth-child(3) .tile-state, .tiles > .tile:nth-child(3) .tile-label { text-align: left; justify-content: flex-start; }
.tiles > .tile:nth-child(2) .tile-state, .tiles > .tile:nth-child(2) .tile-label,
.tiles > .tile:nth-child(4) .tile-state, .tiles > .tile:nth-child(4) .tile-label { text-align: right; justify-content: flex-end; }

.tile-state {
  position: relative; z-index: 1; margin-top: 1px; max-width: 100%;
  color: #fff; font-size: 12px; font-weight: 600; text-align: center; line-height: 1.2;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  text-shadow: 0 1px 3px rgba(0,0,0,.22); opacity: .96;
}
.tile-state:empty { display: none; }

/* „läuft gerade“ — klarer aktiver Zustand (weicher Ring + leichte Anhebung), plus ruhiges Atmen statt hartem Blinken */
.tile.running {
  animation: pulse 2.8s ease-in-out infinite;
  transform: translateY(-1px);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tile-color) 55%, transparent), var(--shadow-tile);
}
.tile.running::before {
  content:""; position:absolute; inset:0; z-index:0; border-radius: inherit; pointer-events:none;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.55);
  animation: ringbreath 2.8s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--tile-color) 55%, transparent), var(--shadow-tile); }
  50%     { box-shadow: 0 0 0 6px color-mix(in srgb, var(--tile-color) 30%, transparent), var(--shadow-tile); }
}
@keyframes ringbreath { 0%,100% { opacity:.35; } 50% { opacity:.9; } }

/* ---------- Status-Timer ---------- */
.status-timer {
  position: relative; max-width: 520px; width: 100%; margin: 4px auto 10px; overflow: hidden;
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center;
  padding: 16px 16px 20px; border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
}
.status-timer:empty { display: none; }
.status-timer .st-label {
  font-size: 12px; font-weight: 700; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted);
}
.status-timer .st-time {
  font-family: "Fraunces", Georgia, serif;
  font-size: 40px; font-weight: 600; line-height: 1.22; color: var(--ink);
  font-variant-numeric: tabular-nums; letter-spacing: .5px; padding: 0 4px;
}
.status-timer.is-sleep {
  background: linear-gradient(160deg, #f0f1f8 0%, #e7e9f4 100%);
  border-color: #cdd4ec;
}
.status-timer.is-sleep::before { /* sanfter Mondschein */
  content:""; position:absolute; top:-40%; right:-10%; width:160px; height:160px; border-radius:50%;
  background: radial-gradient(circle, rgba(59,74,140,.14), transparent 70%); pointer-events:none;
}
.status-timer.is-sleep .st-time { color: var(--sleep); }
.status-timer.is-awake { background: linear-gradient(160deg, #eef6ef 0%, #e6f1e8 100%); border-color: #cbe3d2; }
.status-timer.is-awake .st-time { color: var(--meal); }

/* ---------- Permanente Tagesansicht ---------- */
.day-section { max-width: 520px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; }
.day-section .day-add { width: 100%; margin-top: 10px; flex: 0 0 auto; }

/* +Eintrag-Leiste klebt fix am unteren Rand, ueber der Bottom-Nav (nur im Eingabe-Tab sichtbar) */
.day-add-wrap {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b));
  padding: 12px 16px 0;
  background: linear-gradient(180deg, transparent, var(--bg) 30%);
  z-index: 25;
}
.day-add-wrap .day-add { width: 100%; max-width: 520px; margin: 0 auto 12px; display: block; }
.add-pop { position: absolute; left: 16px; right: 16px; bottom: 100%; max-width: 520px; margin: 0 auto 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; z-index: 20; }
.add-pop[hidden] { display: none; }
.add-mini {
  display: flex; align-items: center; gap: 10px; border: none; cursor: pointer; font: inherit;
  border-radius: 16px; padding: 12px 14px; color: #fff;
  background: linear-gradient(160deg, color-mix(in srgb, var(--am-color) 90%, white), var(--am-color));
  box-shadow: 0 12px 26px -14px var(--am-color), var(--ring-soft);
}
.add-mini:active { transform: scale(.97); }
.am-sleep { --am-color: var(--sleep); }
.am-cry { --am-color: var(--cry); }
.am-meal { --am-color: var(--meal); }
.am-stillen { --am-color: var(--stillen); }
.am-happynote { --am-color: var(--happy); }
.am-ico { position: relative; width: 30px; height: 30px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; }
.am-ico::before { content: ""; position: absolute; inset: 0; background: rgba(255,255,255,.2); }
.am-ico svg { position: relative; z-index: 1; width: 17px; height: 17px; color: #fff; display: block; }
.am-sleep .am-ico::before { border-radius: 30%; }
.am-cry .am-ico::before { border-radius: 30%; background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.5) 0 3px, transparent 3px 6px); }
.am-meal .am-ico::before {
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath d='M45.82 13.97 Q50 6 54.18 13.97 L89.82 82.03 Q94 90 85 90 L15 90 Q6 90 10.18 82.03 Z' fill='%23fff'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath d='M45.82 13.97 Q50 6 54.18 13.97 L89.82 82.03 Q94 90 85 90 L15 90 Q6 90 10.18 82.03 Z' fill='%23fff'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
.am-meal .am-ico svg { transform: translateY(2px); }
.am-stillen .am-ico::before { border-radius: 50%; }
.am-happynote .am-ico::before { border-radius: 50%; }
.am-label { font-size: 15px; font-weight: 700; }

/* ---------- Icon-Dock unten: nur Symbole, Indikator-Pill an der Oberkante
   (nach Modern-Mobile-Menu-Vorlage; Hintergrund bewusst opak, kein backdrop-filter) ---------- */
#bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center;
  background: var(--card);
  border-radius: 22px 22px 0 0;
  padding: 7px 10px calc(var(--safe-b) + 7px);
  box-shadow: 0 -10px 26px -16px rgba(46,42,51,.4), 0 -1px 0 var(--line);
}
.nav-btn {
  position: relative; flex: 1; min-height: 46px; border: none; background: none; padding: 0;
  color: var(--muted); cursor: pointer; border-radius: 15px;
  display: flex; align-items: center; justify-content: center;
  transition: color .18s ease;
}
.nav-btn[hidden] { display: none; }
.nav-btn svg { width: 23px; height: 23px; display: block; }
.nav-btn::before { /* Indikator-Pill haengt an der Oberkante des Docks */
  content: ""; position: absolute; top: -7px; left: 50%; transform: translateX(-50%) scaleX(.3);
  width: 26px; height: 3px; border-radius: 0 0 3px 3px; background: var(--sleep);
  opacity: 0; transition: opacity .18s ease, transform .18s ease;
}
.nav-btn.active { color: var(--sleep); }
.nav-btn.active::before { opacity: 1; transform: translateX(-50%) scaleX(1); }
.nav-btn.active svg { animation: navpop .35s ease; }
@keyframes navpop { 0% { transform: scale(1); } 40% { transform: scale(1.16); } 100% { transform: scale(1); } }

/* ---------- Buttons: ein System ueber Tokens (primary / ghost / danger),
   Glas-Anmutung nach Glass-Button-Vorlage: leicht transluzente Flaeche,
   heller Randsaum, Licht-Highlight oben. Blur nur punktuell (.day-add) ---------- */
.primary-btn, .ghost-btn, .danger-btn {
  border-radius: 13px; padding: 13px 18px; font-size: 15px; font-weight: 600; cursor: pointer;
  font: inherit; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform .08s ease, box-shadow .2s ease, background .15s ease, border-color .15s ease;
}
.primary-btn:active, .ghost-btn:active, .danger-btn:active { transform: scale(.985); }
.primary-btn {
  background: linear-gradient(160deg, color-mix(in srgb, var(--sleep) 84%, white), color-mix(in srgb, var(--sleep) 94%, transparent));
  color: #fff; border: 1px solid color-mix(in srgb, var(--sleep) 45%, transparent);
  box-shadow: 0 10px 22px -12px var(--sleep), inset 0 1px 0 rgba(255,255,255,.42);
}
.ghost-btn {
  background: color-mix(in srgb, var(--card) 60%, transparent);
  border: 1px solid color-mix(in srgb, var(--line) 85%, transparent);
  color: var(--ink); font-weight: 600;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4), 0 6px 16px -14px rgba(43,43,58,.4);
}
.ghost-btn:active { background: var(--bg); }
.day-add-wrap .day-add { -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.danger-btn {
  background: none; border: 1px solid color-mix(in srgb, var(--comment) 45%, var(--line));
  color: var(--comment); font-weight: 600;
}
.danger-btn:active { background: color-mix(in srgb, var(--comment) 8%, transparent); }
.mini-btn { background: var(--card); border: 1px solid var(--line); border-radius: 11px; width: 44px; height: 44px; font-size: 18px; cursor: pointer; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; padding: 0; line-height: 1; transition: color .15s ease, border-color .15s ease, transform .08s ease, background .15s ease; }
.mini-btn:active { color: var(--ink); border-color: #d6cab2; }
.mini-btn svg { width: 18px; height: 18px; display: block; }

/* Tagesnavigation: runde, klar tappbare Karten */
.day-head .mini-btn { width: 44px; height: 44px; border-radius: 50%; box-shadow: var(--shadow-card); }
.day-head .mini-btn:active { transform: scale(.93); }

/* Listen-Edit: ruhiger Affordance-Stift, kein harter Rahmen */
.day-item .mini-btn { width: 34px; height: 34px; border: none; background: transparent; border-radius: 10px; box-shadow: none; color: color-mix(in srgb, var(--muted) 70%, transparent); }
.day-item .mini-btn svg { width: 17px; height: 17px; }
.day-item:active .mini-btn { color: var(--ink); background: var(--bg); }

/* ---------- Day list ---------- */
.day-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 14px; }
.day-head h2 { margin: 0; font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 22px; letter-spacing:.1px; }
/* Uhr klein unter der Datumszeile (Familien-App; berater.html behaelt .clock-mini in der Topbar) */
.day-title-wrap { display: flex; flex-direction: column; align-items: center; }
.clock-under {
  font-size: 12.5px; font-weight: 600; color: var(--muted); line-height: 1;
  font-variant-numeric: tabular-nums; letter-spacing: .8px; margin-top: 3px;
}
.day-list { display: flex; flex-direction: column; gap: 9px; }
.day-item {
  display: flex; align-items: center; gap: 13px; padding: 13px 14px;
  border: 1px solid var(--line); border-radius: 15px; cursor: pointer; background: var(--card);
  box-shadow: var(--shadow-card); transition: transform .08s ease, border-color .15s ease;
}
.day-item:active { transform: scale(.99); border-color: #d6cab2; }
/* Listen-Marker = kleines Pendant der 2x2-Kachel: geformtes Badge + Icon */
.di-badge {
  position: relative; width: 36px; height: 36px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.di-badge::before {
  content: ""; position: absolute; inset: 0; background: var(--di-color);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 4px 10px -6px var(--di-color);
}
.di-badge svg { position: relative; z-index: 1; width: 18px; height: 18px; display: block; filter: drop-shadow(0 1px 2px rgba(0,0,0,.18)); }
.day-item.t-sleep   { --di-color: var(--sleep); }
.day-item.t-cry     { --di-color: var(--cry); }
.day-item.t-meal    { --di-color: var(--meal); }
.day-item.t-stillen { --di-color: var(--stillen); }
.day-item.t-happynote { --di-color: var(--happy); }
.t-sleep .di-badge::before { border-radius: 30%; }
.t-cry .di-badge::before { border-radius: 30%; background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.45) 0 3px, transparent 3px 6px); }
.t-meal .di-badge::before {
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath d='M45.82 13.97 Q50 6 54.18 13.97 L89.82 82.03 Q94 90 85 90 L15 90 Q6 90 10.18 82.03 Z' fill='%23fff'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100' preserveAspectRatio='none'%3E%3Cpath d='M45.82 13.97 Q50 6 54.18 13.97 L89.82 82.03 Q94 90 85 90 L15 90 Q6 90 10.18 82.03 Z' fill='%23fff'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
.t-meal .di-badge svg { transform: translateY(3px); }
.t-stillen .di-badge::before { border-radius: 50%; }
.t-happynote .di-badge::before { border-radius: 50%; }
.di-main { flex: 1; min-width: 0; }
.di-type { font-weight: 600; font-size: 15px; letter-spacing:.1px; }
.di-time { font-size: 13.5px; color: var(--muted); margin-top: 1px; font-variant-numeric: tabular-nums; letter-spacing: .1px; }
.di-comment { font-size: 13px; color: var(--comment); margin-top: 3px; }
.day-empty { color: var(--muted); text-align: center; padding: 24px; }

/* ---------- Print view (Steuerung, nicht im Design-Fokus) ---------- */
.print-controls { display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; max-width: 520px; }
.pc-row { display: grid; grid-template-columns: 44px 1fr; align-items: center; gap: 10px; }
.pc-row span { font-size: 14px; color: var(--muted); }
.pc-row input { width: 100%; padding: 12px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; min-width: 0; background: var(--card); color: var(--ink); min-height: 44px; }
#btnDoPrint { width: 100%; }
.hint { width: 100%; color: var(--muted); font-size: 13px; margin: 4px 0 0; }
.pc-zoom { display: flex; align-items: center; gap: 10px; }
.pc-zoom > span:first-child { font-size: 14px; color: var(--muted); }
#zoomLabel { font-size: 14px; min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }
.print-scroll { width: 100%; }
.print-scroll.zoomed {
  overflow: auto;
  max-height: calc(100dvh - 210px);
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x pan-y;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.print-area { width: 100%; }
.print-area svg { width: 100%; height: auto; }

/* ---------- Auswertung ---------- */
.stats-controls { display: flex; flex-direction: column; gap: 10px; padding-bottom: 12px; max-width: 520px; width: 100%; }
.stats-controls .pc-row { grid-template-columns: 84px 1fr; }
.stats-body { width: 100%; }
.stats-head { margin: 6px 0 16px; }
.stats-head h2 { font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 22px; margin: 0 0 3px; letter-spacing:.1px; }
.stats-range { font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 11px; }
.stat-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px 14px 12px; text-align: center; box-shadow: var(--shadow-card); }
a.stat-card { display: block; text-decoration: none; color: inherit; cursor: pointer; transition: box-shadow .15s ease, transform .1s ease, border-color .15s ease; }
a.stat-card:hover { box-shadow: 0 10px 26px -14px rgba(46,42,51,.45); border-color: #d3c8b0; transform: translateY(-2px); }
a.stat-card:active { transform: scale(.99); }
.sc-val { font-size: 25px; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; line-height: 1.05; letter-spacing: .2px; }
.sc-label { font-size: 12px; color: var(--muted); margin-top: 5px; line-height: 1.35; }
.sc-sub { font-size: 11px; color: var(--muted); opacity: .8; margin-top: 2px; }
.sc-spark { margin-top: 10px; }
.spark { width: 100%; height: 34px; display: block; }
.spark.donut { width: 46px; height: 46px; margin: 8px auto 0; }
.stats-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }
.stats-chart { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; box-shadow: var(--shadow-card); scroll-margin-top: 16px; }
.stats-chart.full { grid-column: 1 / -1; }
.sc-title { font-size: 13.5px; font-weight: 700; margin-bottom: 8px; color: var(--ink); }
.stats-chart-svg { width: 100%; height: auto; display: block; }
@media (max-width: 560px) { .stats-charts { grid-template-columns: 1fr; } }

/* Nur im Druck sichtbar (z. B. Auswertungs-Seiten im Übersicht-Tab ausgeblendet) */
.print-only { display: none; }

/* Diagramm-Slider (Tage / Woche / Monat) */
.stats-unit { display: flex; align-items: center; gap: 12px; margin: 18px 0 12px; }
.stats-unit .su-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.stats-unit .seg { flex: 1; max-width: 320px; }

/* ---------- Modals ---------- */
.modal-backdrop {
  display: none; position: fixed; inset: 0;
  background: color-mix(in srgb, var(--sleep) 20%, rgba(0,0,0,.42));
  align-items: flex-end; justify-content: center; z-index: 50; padding: 0;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--card); width: 100%; max-width: 520px;
  border-radius: 18px 18px 0 0; padding: 0;
  animation: slideup .2s ease;
  max-height: min(88dvh, 720px);
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow-modal);
}
/* Fester Modal-Kopf (scrollt nicht mit) + eigener Scroll-Body -> nichts rutscht
   mehr unter die Ueberschrift. Ersetzt das fruehere sticky h2. */
.modal-head {
  flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 18px 12px; border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; position: static; padding: 0; }
.modal-x {
  width: 36px; height: 36px; flex: 0 0 auto; border: none; background: none; cursor: pointer;
  color: var(--muted); font-size: 17px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center; padding: 0;
  transition: background .15s ease, color .15s ease;
}
.modal-x:active { background: var(--bg); color: var(--ink); }
.modal-body {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 16px 18px calc(20px + var(--safe-b));
}
@media (min-width: 620px) { .modal-body { padding-bottom: 20px; } }
.modal-wide { max-width: 640px; }
@keyframes slideup { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (min-width: 620px) {
  .modal-backdrop { align-items: center; }
  .modal { border-radius: 18px; max-height: min(85dvh, 720px); }
}
.modal h2 {
  margin: 0 0 16px; font-size: 20px; font-family: "Fraunces", Georgia, serif; font-weight: 600;
  letter-spacing: .1px;
}

/* ---------- Einstellungen: aufklappbare Gruppen (native <details>) ---------- */
.set-group { border-bottom: 1px solid var(--line); }
.set-group:last-of-type { border-bottom: none; }
.set-group > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  padding: 14px 2px; user-select: none; -webkit-user-select: none;
}
.set-group > summary::-webkit-details-marker { display: none; }
.set-group > summary .sg-title {
  flex: 1; font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 16.5px;
  color: var(--ink); letter-spacing: .1px;
}
.set-group > summary .sg-chev {
  width: 18px; height: 18px; flex: 0 0 auto; color: var(--muted);
  transition: transform .18s ease;
}
.set-group[open] > summary .sg-chev { transform: rotate(180deg); }
.set-group > .sg-body { padding: 2px 2px 14px; }
.set-group .field:last-child { margin-bottom: 0; }

/* ---------- Avatare: runde Kreise, gestapelt (nach Avatar-Circles-Vorlage) ---------- */
.avatar-circle {
  width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto; overflow: hidden;
  border: 2px solid var(--card); background: var(--sleep); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; letter-spacing: .3px; box-sizing: content-box;
}
.avatar-circle img { width: 100%; height: 100%; display: block; object-fit: cover; }
.avatar-stack { display: inline-flex; align-items: center; }
.avatar-stack .avatar-circle:not(:first-child) { margin-left: -10px; }
.avatar-stack .avatar-more { background: var(--ink); font-size: 11.5px; }
#userBtn {
  border: none; background: none; padding: 3px; cursor: pointer; border-radius: 999px;
  display: inline-flex; align-items: center;
  transition: background .15s ease;
}
#userBtn:active { background: rgba(139,131,118,.14); }

/* User-Popover (Angemeldet als … + Abmelden), Struktur nach Popover-Vorlage */
.user-pop {
  position: absolute; top: calc(100% + 6px); right: 10px; z-index: 70;
  width: min(300px, calc(100vw - 24px));
  background: var(--card); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 16px 40px -18px rgba(46,42,51,.55);
  animation: popfade .16s ease;
}
.user-pop[hidden] { display: none; }
@keyframes popfade { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.user-pop .up-head {
  display: flex; align-items: center; gap: 12px; padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line);
}
.user-pop .up-head .avatar-circle { width: 40px; height: 40px; font-size: 16px; }
.user-pop .up-name { font-weight: 700; font-size: 15.5px; color: var(--ink); line-height: 1.2; }
.user-pop .up-role { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.user-pop .up-body { padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
.user-pop .up-body:empty { display: none; }
.user-pop .up-member { display: flex; align-items: center; gap: 10px; }
.user-pop .up-member .avatar-circle { width: 28px; height: 28px; font-size: 11.5px; border-color: transparent; }
.user-pop .up-member .um-name { font-size: 13.5px; color: var(--ink); font-weight: 600; }
.user-pop .up-member .um-sub { font-size: 11.5px; color: var(--muted); margin-left: auto; }
.user-pop .up-foot { padding: 10px 14px 12px; border-top: 1px solid var(--line); }
.user-pop .up-foot .ghost-btn { width: 100%; }

/* Avatar-Auswahl in den Einstellungen */
.avatar-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; }
.avatar-grid button {
  border: none; background: none; padding: 2px; cursor: pointer; border-radius: 50%; line-height: 0;
}
.avatar-grid .avatar-circle { width: 44px; height: 44px; border-color: transparent; }
.avatar-grid button.active { box-shadow: 0 0 0 3px var(--sleep); }
.avatar-grid button:active { transform: scale(.94); }

/* Profil-Karte der Beraterin */
.bp-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.bp-head .avatar-circle { width: 56px; height: 56px; font-size: 20px; border-color: transparent; }
.bp-name { font-family: "Fraunces", Georgia, serif; font-size: 19px; font-weight: 600; color: var(--ink); }
.bp-text { font-size: 14px; color: var(--muted); line-height: 1.5; margin: 2px 0 12px; }
.bp-rows { display: flex; flex-direction: column; gap: 8px; }
.bp-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 13px; background: var(--bg);
  color: var(--ink); text-decoration: none; font-size: 14.5px; font-weight: 600;
  transition: border-color .15s ease, background .15s ease;
}
a.bp-row:active { background: color-mix(in srgb, var(--sleep) 8%, var(--bg)); border-color: var(--sleep); }
.bp-row .bp-ico {
  width: 34px; height: 34px; flex: 0 0 auto; border-radius: 10px;
  background: color-mix(in srgb, var(--sleep) 12%, transparent); color: var(--sleep);
  display: inline-flex; align-items: center; justify-content: center;
}
.bp-row .bp-ico svg { width: 17px; height: 17px; }
.bp-row .bp-val { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bp-row .bp-sub { display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; letter-spacing: .4px; text-transform: uppercase; margin-bottom: 1px; }
.bp-empty { color: var(--muted); font-size: 14px; text-align: center; padding: 12px 0 4px; }
.bp-switch { display: flex; gap: 6px; margin-bottom: 14px; }
.bp-switch button { flex: 1; }

/* ---------- Zahnrad + Berater-Avatar im Dock (kein View-Tab, oeffnen Modals) ---------- */
.nav-btn.nav-settings svg { width: 22px; height: 22px; }
.nav-btn.nav-settings:active { color: var(--ink); }
.nav-btn.nav-berater .avatar-circle { width: 27px; height: 27px; font-size: 11.5px; border-color: transparent; }
.nav-btn.nav-berater:active .avatar-circle { transform: scale(.94); }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
.field .opt { font-size: 12px; }
.field input[type=text] { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 16px; background: var(--card); color: var(--ink); }
.dt-row { display: flex; gap: 8px; align-items: center; }
.dt-row input { flex: 1; padding: 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 16px; min-width: 0; background: var(--card); color: var(--ink); }
.dt-hint { width: 100%; color: var(--muted); font-size: 12px; line-height: 1.5; margin: 6px 0 0; }
.dt-hint b { color: var(--ink); font-weight: 600; }
/* Verbindungscode (Familie <-> Beraterin) */
.connect-code {
  display: block; width: 100%; margin-top: 8px; padding: 14px 16px; text-align: center;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 26px; font-weight: 700; letter-spacing: 6px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); cursor: pointer;
}
.connect-code:active { background: color-mix(in srgb, var(--sleep) 8%, var(--bg)); }
.connect-error { width: 100%; color: var(--comment); font-size: 12.5px; line-height: 1.45; margin: 6px 0 0; }

/* Mitglieder-/Verbindungsliste (Settings-Modal, Familie + Beraterin) */
.member-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.member-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
}
.member-info { flex: 1; min-width: 0; }
.member-name { font-size: 14px; font-weight: 600; color: var(--ink); }
.member-name .owner-tag { font-weight: 600; color: var(--sleep); font-size: 12px; margin-left: 6px; }
.member-user { font-size: 12.5px; color: var(--muted); }
.member-actions { display: flex; gap: 6px; flex: 0 0 auto; }
.member-actions .ghost-btn, .member-actions .danger-btn { padding: 8px 12px; font-size: 13px; }
.member-reset-box { margin-top: 8px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 12px; }
.modal-actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.spacer { flex: 1; }

.add-types { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.add-type { padding: 16px; font-size: 17px; border: 1px solid var(--line); background: var(--bg); border-radius: 12px; cursor: pointer; text-align: left; }

/* ---------- Kommentar-Anhang (Bildschirm-Vorschau) ---------- */
.cmt-page { font-family: system-ui, sans-serif; color: var(--ink); padding: 4px 2px; }
.cmt-page h2 { color: var(--sleep); font-family: "Fraunces", Georgia, serif; font-size: 18px; margin: 0 0 12px; }
.cmt-day { font-weight: 700; font-size: 15px; margin: 14px 0 4px; border-bottom: 1px solid var(--line); padding-bottom: 3px; }
.cmt-row { display: grid; grid-template-columns: 52px 82px 1fr; gap: 10px; font-size: 14px; margin: 3px 0; align-items: baseline; }
.cmt-time { color: var(--muted); }
.cmt-type { font-weight: 600; }
.cmt-text { color: #1f1b24; }
.cmt-empty { color: var(--muted); }

/* ============================================================
   DARK MODE — gesteuert über data-theme am <html>. JS setzt
   'dark'/'light' (System wird per matchMedia aufgelöst).
   Druck bleibt immer hell (siehe @media print). Markerfarben
   und Logo-Indigo bleiben; nur Flächen/Text drehen.
   ============================================================ */
:root[data-theme="dark"] {
  /* Echter Nachtmodus: tiefes Nacht-Indigo statt neutralem Dunkelgrau */
  --bg: #12142A; --card: #1B1E38; --ink: #EAE4F2; --muted: #9490B0;
  --line: #2B2E4E; --comment: #F0876F;
  --shadow-card: 0 1px 2px rgba(0,0,0,.35), 0 10px 26px -16px rgba(0,0,0,.75);
  --shadow-modal: 0 -12px 34px -18px rgba(0,0,0,.75);
  --focus-ring: 0 0 0 3px color-mix(in srgb, #9aa6d4 55%, transparent);
}
:root[data-theme="dark"] #topbar {
  background: linear-gradient(180deg, color-mix(in srgb, var(--sleep) 26%, transparent), transparent 78%);
}
:root[data-theme="dark"] .modal-backdrop { background: color-mix(in srgb, var(--sleep) 30%, rgba(4,5,14,.7)); }
:root[data-theme="dark"] .status-timer.is-sleep { background: linear-gradient(160deg, #20233a, #1b1d30); border-color: #383f63; }
:root[data-theme="dark"] .status-timer.is-sleep .st-time { color: #9aa6d4; }
:root[data-theme="dark"] .status-timer.is-sleep::before { background: radial-gradient(circle, rgba(154,166,212,.18), transparent 70%); }
:root[data-theme="dark"] .status-timer.is-awake { background: linear-gradient(160deg, #1d2620, #18211b); border-color: #2f4636; }
:root[data-theme="dark"] .status-timer.is-awake .st-time { color: #6fc285; }
:root[data-theme="dark"] .tile::after { background: linear-gradient(180deg, rgba(255,255,255,.10), transparent 42%); }
:root[data-theme="dark"] .tile { box-shadow: 0 12px 30px -16px #000, 0 2px 6px -3px #000; }
/* Mittel-Button: auch im Dunkelmodus nur die Hintergrund-Luecke (kein sichtbarer Rand) */
:root[data-theme="dark"] .tile-happynote { box-shadow: 0 0 0 6px var(--bg), 0 12px 30px -16px #000, 0 2px 6px -3px #000; }
:root[data-theme="dark"] .nav-btn.active { color: #9aa6d4; }
:root[data-theme="dark"] .nav-btn.active::before { background: #9aa6d4; }
:root[data-theme="dark"] .ghost-btn { box-shadow: inset 0 1px 0 rgba(255,255,255,.07), 0 6px 16px -14px rgba(0,0,0,.6); }
:root[data-theme="dark"] .primary-btn { border-color: color-mix(in srgb, var(--sleep) 65%, transparent); }
:root[data-theme="dark"] .cmt-text { color: var(--ink); }

/* Segmented control (Darstellung: System / Hell / Dunkel) */
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; min-height: 44px; padding: 10px 6px; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 10px; font-size: 14px; font-weight: 600; cursor: pointer; transition: background .15s ease, color .15s ease, border-color .15s ease; }
.seg button.active { background: var(--sleep); color: #fff; border-color: var(--sleep); }

/* ---------- Print ---------- */
@media print {
  @page { size: A4 landscape; margin: 0; }
  /* Druck immer hell, egal welches Theme aktiv ist */
  :root[data-theme="dark"], :root { --bg: #fff; --card: #fff; --ink: #2E2A33; --muted: #5a5560; --line: #e0cdda; --comment: #E5694D; }
  body { background: #fff; color: #2E2A33; }
  #topbar, #bottomnav, .no-print, .view:not(#view-print) { display: none !important; }
  #view-print { display: block !important; padding: 0; }
  .print-only { display: block !important; }
  /* Bildschirm-Zoom darf den Druck nie beeinflussen */
  .print-scroll { overflow: visible !important; max-height: none !important; border: 0 !important; }
  .print-area { display: block; width: 100% !important; }
  /* Jede Seite ein exakter A4-quer-Container mit overflow:hidden -> nie eine Leerseite */
  .print-page {
    width: 297mm; height: 210mm; padding: 7mm; box-sizing: border-box;
    overflow: hidden; page-break-after: always; break-after: page;
  }
  .print-page:last-child { page-break-after: auto; break-after: auto; }
  .print-area svg { width: 100%; height: 100%; display: block; }
  .cmt-page { padding: 0; }
  .cmt-page h2 { font-size: 18pt; margin: 0 0 6mm; }
  .cmt-day { font-size: 12pt; margin: 4mm 0 1.5mm; }
  .cmt-row { grid-template-columns: 16mm 26mm 1fr; font-size: 11pt; }
  /* Auswertungs-Seite im Druck: A4 quer, nichts gequetscht */
  .stats-print .stats-head h2 { font-size: 17pt; margin: 0 0 1.5mm; }
  .stats-print .stats-range { font-size: 10.5pt; color: #5a5560; margin-bottom: 4mm; }
  .stats-print .stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3.5mm; }
  .stats-print .stat-card { border: 1px solid #e0cdda; border-radius: 3mm; padding: 3mm 2.5mm; text-align: center; box-shadow: none; }
  .stats-print .sc-val { font-size: 15pt; font-weight: 800; }
  .stats-print .sc-label { font-size: 8.5pt; margin-top: 1mm; }
  .stats-print .sc-sub { font-size: 7.5pt; }
  .stats-print svg { height: auto !important; }
  .stats-print .sc-spark { margin-top: 1.5mm; }
  .stats-print .spark { height: 7mm !important; }
  .stats-print .spark.donut { width: 11mm !important; height: 11mm !important; margin: 1mm auto 0; }
  .stats-print .stats-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 4mm; margin-top: 4mm; }
  .stats-print .stats-chart.full { grid-column: 1 / -1; }
  .stats-print .stats-chart { border: 1px solid #e0cdda; border-radius: 3mm; padding: 2.5mm 3mm; box-shadow: none; }
  .stats-print .sc-title { font-size: 10.5pt; margin-bottom: 1.5mm; }
  .stats-print .stats-chart-svg { width: 100% !important; height: auto !important; max-height: 60mm; }
}
