/* Baby-Tracker – dunkles Design für nächtliche Nutzung */

:root {
  --bg: #0e1116;
  --surface: #161b22;
  --surface-2: #1f262f;
  --line: #2b333d;
  --text: #e6ebf0;
  --muted: #8b97a3;
  --primary: #5b8def;
  --danger: #e5534b;
  --ok: #3fb950;
  --feed: #f0a35e;
  --diaper: #5fb4d0;
  --sleep: #a18df0;
  --measure: #72c49a;
  --med: #e07a98;
  --note: #b5bec7;
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding-top: env(safe-area-inset-top);
}
#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px calc(92px + env(safe-area-inset-bottom));
}

h1 { font-size: 1.4rem; margin: 0; }
h2 { font-size: 1.1rem; margin: 0; }
p { margin: 0; }
code { background: var(--surface-2); padding: 2px 6px; border-radius: 6px; }
small { color: var(--muted); font-weight: 400; }
.muted { color: var(--muted); font-size: .9rem; }
.center { text-align: center; }
.loading { color: var(--muted); text-align: center; margin-top: 40vh; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
}
button:disabled { cursor: default; }

/* Kategorie-Farben */
.c-feed { --accent: var(--feed); }
.c-diaper { --accent: var(--diaper); }
.c-sleep { --accent: var(--sleep); }
.c-measure { --accent: var(--measure); }
.c-med { --accent: var(--med); }
.c-note { --accent: var(--note); }
.c-today { --accent: var(--primary); }

/* Kopfzeile */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 14px; }
.live { flex: none; width: 12px; height: 12px; border-radius: 50%; background: #4a525c; }
.live.on { background: var(--ok); box-shadow: 0 0 8px rgba(63, 185, 80, .6); }
.banner {
  margin-bottom: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: #5a3a12;
  color: #ffd8a8;
  font-size: .9rem;
  text-align: center;
}

/* Status-Karten */
.cards { display: grid; gap: 10px; margin-bottom: 16px; }
.card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
}
.card.running { background: color-mix(in srgb, var(--accent) 16%, var(--surface)); }
.card-text { min-width: 0; }
.card-label { font-weight: 600; }
.card-sub { color: var(--muted); font-size: .88rem; }
.card-value {
  font-size: 1.25rem;
  font-weight: 700;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.c-today { flex-direction: column; align-items: stretch; gap: 6px; }
.c-today .card-sub { text-align: center; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); text-align: center; }
.stat b { display: block; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .8rem; }

/* Schnellaktionen */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.action {
  min-height: 60px;
  padding: 8px 14px;
  text-align: left;
  font-size: 1.02rem;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 14px;
}
.action:active { transform: scale(.98); background: color-mix(in srgb, var(--accent) 20%, var(--surface-2)); }
.action:disabled { opacity: .5; }
body.busy .action,
body.busy .big,
body.busy [type="submit"] { opacity: .6; pointer-events: none; }

/* Eintragsliste */
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 4px 0 10px; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-bottom: 8px;
  padding: 10px 12px;
  text-align: left;
  background: var(--surface);
  border-left: 4px solid var(--accent);
  border-radius: 12px;
}
.row-icon { flex: none; font-size: 1.3rem; }
.row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row-title { font-weight: 600; }
.row-sub { color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-who {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .8rem;
  font-weight: 700;
}

/* Verlauf */
.day-nav { text-align: center; }
.day-title { flex: 1; }
.icon-btn { flex: none; width: 48px; height: 48px; border-radius: 12px; background: var(--surface-2); font-size: 1.6rem; }
.icon-btn:disabled { opacity: .3; }

/* Mehr */
.panel { display: grid; gap: 10px; margin-bottom: 12px; padding: 14px; background: var(--surface); border-radius: var(--radius); }
.row-buttons { display: flex; flex-wrap: wrap; gap: 10px; }

/* Buttons */
.btn {
  min-height: 48px;
  padding: 0 18px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.danger { color: #ffb4ae; border-color: #5c2b28; }
.link { padding: 6px 0; color: var(--primary); font-weight: 600; }

/* Tab-Leiste */
.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 10;
  display: flex;
  justify-content: center;
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(14, 17, 22, .96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
}
.tab {
  flex: 1;
  max-width: 186px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 10px;
  color: var(--muted);
  font-size: .78rem;
}
.tab-icon { font-size: 1.3rem; }
.tab.active { color: var(--text); }

/* Bottom-Sheet */
#sheet-backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .6); }
#sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  max-width: 560px;
  max-height: 90vh;
  margin: 0 auto;
  overflow-y: auto;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 30px rgba(0, 0, 0, .4);
}
.stack { display: grid; gap: 12px; }
.sheet-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 4px; }
.sheet-actions .danger { margin-right: auto; }

/* Formulare */
.field { display: grid; gap: 6px; }
.field > span { font-size: .9rem; font-weight: 600; }
input, textarea, select {
  width: 100%;
  padding: 12px;
  font: inherit;
  font-size: 16px; /* verhindert Zoom auf dem iPhone */
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
}
input:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: transparent; }
textarea { resize: vertical; }

.chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.chips-label { margin-right: 2px; color: var(--muted); font-size: .85rem; }
.chip { padding: 8px 12px; font-size: .92rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; }
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

.seg, .toggles { display: flex; gap: 8px; }
.seg label, .toggle { position: relative; flex: 1; }
.seg input, .toggle input { position: absolute; opacity: 0; pointer-events: none; }
.seg span, .toggle span {
  display: block;
  padding: 12px;
  text-align: center;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
}
.seg input:checked + span,
.toggle input:checked + span { background: var(--primary); border-color: var(--primary); color: #fff; }

.big-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.big {
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 1.9rem;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.big span { font-size: 1rem; font-weight: 600; }
.big:active { background: color-mix(in srgb, var(--diaper) 25%, var(--surface-2)); }

/* Hinweis unten */
#toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 30;
  max-width: 528px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: #2b3440;
  border-radius: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .4);
}
.toast-action { color: #9ec1ff; font-weight: 700; white-space: nowrap; }

/* Anmeldung & Meldungen */
.center-screen { min-height: 80vh; display: grid; align-content: center; gap: 16px; text-align: center; }
.center-screen form { text-align: left; }
.logo { font-size: 3rem; }
.error { color: #ffb4ae; }
