/* Babyfeeder — mobile-first, ein Screen. Farben: dataviz-Referenzpalette. */

:root {
    --page: #f9f9f7;
    --surface: #fcfcfb;
    --ink: #0b0b0b;
    --ink-2: #52514e;
    --muted: #898781;
    --grid: #e1e0d9;
    --baseline: #c3c2b7;
    --border: rgba(11, 11, 11, 0.10);
    --accent: #2a78d6;      /* series-1 blau */
    --series-2: #1baf7a;    /* aqua */
    --series-5: #4a3aa7;    /* violett */
    --danger: #d03b3b;
    --sleep-active: #4a3aa7;
}

@media (prefers-color-scheme: dark) {
    :root {
        --page: #0d0d0d;
        --surface: #1a1a19;
        --ink: #ffffff;
        --ink-2: #c3c2b7;
        --muted: #898781;
        --grid: #2c2c2a;
        --baseline: #383835;
        --border: rgba(255, 255, 255, 0.10);
        --accent: #3987e5;
        --series-2: #199e70;
        --series-5: #9085e9;
        --danger: #d03b3b;
        --sleep-active: #9085e9;
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--page);
    color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

button {
    font-family: inherit;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    color: var(--ink);
    background: none;
}

input {
    font-family: inherit;
    font-size: 1rem;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--page);
    color: var(--ink);
    width: 100%;
}

/* ---------- Login ---------- */

.overlay {
    position: fixed;
    inset: 0;
    background: var(--page);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 24px;
}

.login-card {
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.login-icon { font-size: 3rem; text-align: center; }
.login-card h1 { text-align: center; margin: 0 0 8px; font-size: 1.4rem; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: var(--ink-2); }
.error { color: var(--danger); font-size: 0.9rem; margin: 0; }

.auth-tabs {
    display: flex;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    border-radius: 9px;
    color: var(--muted);
    font-weight: 600;
}

.auth-tab.active { background: var(--accent); color: #fff; }

.label-hint { font-weight: 400; color: var(--muted); font-size: 0.8rem; }

.setup-divider {
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    margin: 4px 0;
}

.link-btn {
    color: var(--muted);
    font-size: 0.85rem;
    text-decoration: underline;
    padding: 8px;
}

.invite-row { display: flex; gap: 8px; align-items: center; }

.invite-row code {
    flex: 1;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 2px;
    text-align: center;
    background: var(--page);
    border: 1px dashed var(--baseline);
    border-radius: 10px;
    padding: 12px 8px;
    user-select: all;
}

/* ---------- Layout ---------- */

#app {
    max-width: 480px;
    margin: 0 auto;
    padding: 0 12px calc(72px + env(safe-area-inset-bottom));
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 4px 10px;
}

.baby-info { display: flex; flex-direction: column; }
#baby-name { font-weight: 700; font-size: 1.15rem; }
.baby-age { color: var(--ink-2); font-size: 0.85rem; }

.stage-badge {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 0.85rem;
    color: var(--ink-2);
    min-height: 40px;
}

main { display: flex; flex-direction: column; gap: 12px; }
.view-title { font-size: 1.1rem; margin: 8px 4px 0; }

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card-title { font-size: 0.85rem; font-weight: 600; color: var(--ink-2); }

/* ---------- Buttons ---------- */

.btn-primary {
    background: var(--accent);
    color: #fff;
    border-radius: 12px;
    padding: 14px;
    font-weight: 600;
    min-height: 48px;
}

.btn-secondary {
    background: var(--page);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    min-height: 48px;
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-radius: 12px;
    padding: 12px 16px;
    min-height: 48px;
}

/* Schlaf */
.sleep-btn {
    background: var(--surface);
    border: 2px solid var(--sleep-active);
    color: var(--sleep-active);
    border-radius: 14px;
    padding: 16px;
    font-size: 1.1rem;
    font-weight: 700;
    min-height: 56px;
}

.sleep-btn.running {
    background: var(--sleep-active);
    color: #fff;
}

.sleep-status { font-size: 0.85rem; color: var(--ink-2); min-height: 1.2em; }

.sleep-btn.alarm {
    background: var(--danger);
    border-color: var(--danger);
    color: #fff;
    animation: alarm-pulse 1s infinite;
}

@keyframes alarm-pulse {
    50% { opacity: 0.65; }
}

.sleep-timer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--ink-2);
}

.sleep-timer-row select {
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--page);
    color: var(--ink);
    font-size: 0.95rem;
    font-family: inherit;
}

/* Medikamente */
.meds-list { display: flex; flex-direction: column; gap: 8px; }

.med-row {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--page);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    min-height: 52px;
    text-align: left;
}

.med-check {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 2px solid var(--baseline);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.med-row.done .med-check { background: var(--series-2); border-color: var(--series-2); }
.med-row.done .med-name { color: var(--muted); text-decoration: line-through; }
.med-name { flex: 1; font-weight: 600; }
.med-time { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }

/* Fütterung */
.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(76px, 1fr));
    gap: 8px;
}

.preset-btn {
    background: var(--page);
    border: 2px solid var(--accent);
    color: var(--accent);
    border-radius: 12px;
    padding: 12px 4px;
    font-weight: 700;
    font-size: 1.05rem;
    min-height: 56px;
}

.preset-btn.custom { border-style: dashed; font-weight: 500; font-size: 0.9rem; }

/* Windel */
.diaper-row { display: flex; gap: 8px; }

.diaper-btn {
    flex: 1;
    background: var(--page);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 1.2rem;
    min-height: 60px;
}

.diaper-btn span { font-size: 0.75rem; color: var(--ink-2); }
.diaper-btn.selected { border: 2px solid var(--accent); }

/* ---------- Summen ---------- */

.summary-strip { display: flex; gap: 8px; }

.stat-tile {
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: center;
}

.stat-label { font-size: 0.7rem; color: var(--muted); }
.stat-value { font-size: 1.05rem; font-weight: 700; }

/* ---------- Log ---------- */

.log-section { display: flex; flex-direction: column; gap: 6px; }

.date-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 2px 4px;
}

.date-nav span { font-weight: 600; font-size: 0.95rem; }

.date-arrow {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    font-size: 1.3rem;
    color: var(--ink-2);
}

.date-arrow:disabled { opacity: 0.3; }

.log-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }

.log-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 10px 14px;
    width: 100%;
    text-align: left;
    min-height: 52px;
}

.log-icon { font-size: 1.2rem; }
.log-main { flex: 1; display: flex; flex-direction: column; }
.log-value { font-weight: 600; font-size: 0.95rem; }
.log-detail { font-size: 0.78rem; color: var(--muted); }
.log-time { font-size: 0.85rem; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.log-empty { color: var(--muted); text-align: center; padding: 16px 0; }

/* ---------- Charts ---------- */

.chart { width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }

.chart-legend { display: flex; gap: 14px; font-size: 0.8rem; color: var(--ink-2); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch-klein { background: var(--accent); }
.swatch-gross { background: var(--series-2); }

/* ---------- Einstellungen ---------- */

.field { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: var(--ink-2); }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--page);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 8px 8px 8px 14px;
    font-weight: 600;
}

.chip button {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--border);
    font-size: 0.9rem;
    line-height: 1;
}

.chip-add-row { display: flex; gap: 8px; }
.chip-add-row input { flex: 1; }
.chip-add-row button { flex-shrink: 0; }

.user-card { flex-direction: row; align-items: center; justify-content: space-between; }
#current-user { color: var(--ink-2); font-size: 0.9rem; }

/* ---------- Bottom-Nav ---------- */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-around;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
    z-index: 50;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 1.2rem;
    color: var(--muted);
    padding: 6px 18px;
    border-radius: 12px;
    min-width: 64px;
}

.nav-btn span { font-size: 0.7rem; }
.nav-btn.active { color: var(--accent); }

/* ---------- Sheets ---------- */

.sheet-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 90;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.sheet {
    background: var(--surface);
    border-radius: 20px 20px 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sheet-handle {
    width: 40px;
    height: 4px;
    border-radius: 2px;
    background: var(--baseline);
    margin: 4px auto 6px;
    flex-shrink: 0;
}

.sheet h2 { margin: 0; font-size: 1.15rem; }
.sheet h3 { margin: 8px 0 0; font-size: 0.9rem; color: var(--ink-2); }
.sheet ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; }
.stage-sub { margin: 0; color: var(--muted); font-size: 0.85rem; }
.disclaimer { font-size: 0.75rem; color: var(--muted); margin: 8px 0 0; }

#edit-form { display: flex; flex-direction: column; gap: 12px; }
.edit-actions { display: flex; gap: 10px; }
.edit-actions .btn-primary { flex: 1; }

/* ---------- Toast ---------- */

.toast {
    position: fixed;
    bottom: calc(84px + env(safe-area-inset-bottom));
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: var(--page);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    z-index: 95;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    max-width: calc(100% - 32px);
}

#toast-undo {
    color: var(--accent);
    font-weight: 700;
    padding: 4px 8px;
}
