/* ToddlerTrack -- mobil zuerst. Wird nachts mit einer Hand bedient, also grosse
   Flaechen, ruhige Farben und ein dunkles Schema, das nicht blendet. */

:root {
    color-scheme: light dark;

    --bg: #f6f4f1;
    --surface: #ffffff;
    --surface-2: #ece8e3;
    --text: #1f1c19;
    --text-muted: #6d665e;
    --border: #ddd6cd;

    --accent: #2f7d6d;
    --accent-soft: #d9ece7;
    --accent-text: #ffffff;

    /* Eigene Farbe für Schlaf, damit auf einen Blick klar ist, welche Uhr läuft. */
    --accent-sleep: #4a5da8;

    --danger: #b3261e;
    --danger-soft: #fbe4e2;

    --radius: 14px;
    --radius-sm: 9px;
    --tap: 48px;
    --shadow: 0 1px 2px rgb(0 0 0 / 6%), 0 4px 12px rgb(0 0 0 / 4%);

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14120f;
        --surface: #1e1b18;
        --surface-2: #2a2622;
        --text: #ece7e1;
        --text-muted: #a49b90;
        --border: #38322c;

        --accent: #5cc0a9;
        --accent-soft: #1d3b35;
        --accent-text: #08201b;

        --accent-sleep: #9aa8e8;

        --danger: #f2b8b5;
        --danger-soft: #3d1512;

        --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    }
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    /* Kein Gummiband-Scrollen ueber die feste Kopfzeile hinaus. */
    overscroll-behavior-y: none;
}

h1, h2, h3 {
    margin: 0 0 0.5rem;
    line-height: 1.25;
    font-weight: 650;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.175rem; }
h3 { font-size: 1rem; }

h1:focus, h2:focus {
    outline: none;
}

a {
    color: var(--accent);
}

/* ---------- Grundgeruest ---------- */

.app-shell {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: calc(var(--safe-top) + 0.75rem) 1rem 0.75rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.app-header__title {
    margin: 0;
    font-size: 1.075rem;
    font-weight: 650;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.app-main {
    flex: 1;
    width: 100%;
    max-width: 640px;
    margin-inline: auto;
    padding: 1rem 1rem 1.5rem;
}

/* Untere Navigation liegt im Daumenbereich. */
.app-nav {
    position: sticky;
    bottom: 0;
    z-index: 10;
    display: flex;
    background: var(--surface);
    border-top: 1px solid var(--border);
    padding-bottom: var(--safe-bottom);
}

.app-nav a {
    flex: 1;
    min-height: var(--tap);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.4rem 0.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
}

.app-nav a.active {
    color: var(--accent);
    font-weight: 600;
}

.app-nav__icon {
    font-size: 1.25rem;
    line-height: 1;
}

/* ---------- Karten und Listen ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow);
}

.stack > * + * {
    margin-top: 0.875rem;
}

.muted {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.list > li + li {
    border-top: 1px solid var(--border);
}

.list-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0;
    min-height: var(--tap);
}

.list-row__main {
    flex: 1;
    min-width: 0;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.75rem;
    font-weight: 600;
}

/* ---------- Formulare ---------- */

.field {
    display: block;
    margin-bottom: 1rem;
}

.field__label {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.field__hint {
    display: block;
    margin-top: 0.3rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Blazors InputText rendert <input> ohne type-Attribut -- das :not deckt es mit ab. */
input:not([type]),
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
select,
textarea {
    width: 100%;
    min-height: var(--tap);
    padding: 0.6rem 0.75rem;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font: inherit;
    /* Unter 16px zoomt iOS beim Fokussieren in das Feld hinein. */
    font-size: 16px;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible,
button:focus-visible,
a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.code-input {
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 1.35rem;
    letter-spacing: 0.18em;
    text-align: center;
    text-transform: uppercase;
}

/* ---------- Schaltflaechen ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    min-height: var(--tap);
    padding: 0.6rem 1.1rem;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.btn--primary {
    background: var(--accent);
    color: var(--accent-text);
}

.btn--ghost {
    background: transparent;
    border-color: var(--border);
}

.btn--danger {
    background: transparent;
    border-color: var(--border);
    color: var(--danger);
}

.btn--block {
    display: flex;
    width: 100%;
}

/* Nur Symbol: gibt in Listenzeilen rund 90px an den Eintragstext zurueck. */
.btn--icon {
    flex: none;
    width: 42px;
    min-height: 42px;
    padding: 0;
    font-size: 1rem;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-row {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

/* ---------- Meldungen ---------- */

.alert {
    padding: 0.75rem 0.9rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.925rem;
}

.alert--error {
    background: var(--danger-soft);
    color: var(--danger);
}

.alert--info {
    background: var(--accent-soft);
    color: var(--accent);
}

.validation-message {
    display: block;
    margin-top: 0.3rem;
    color: var(--danger);
    font-size: 0.85rem;
}

.invalid {
    border-color: var(--danger);
}

/* ---------- Anmelde- und Einrichtungsseiten, ohne Navigation ---------- */

.plain-shell {
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(var(--safe-top) + 1.5rem) 1rem calc(var(--safe-bottom) + 1.5rem);
}

.plain-shell__inner {
    width: 100%;
    max-width: 420px;
}

.brand {
    text-align: center;
    margin-bottom: 1.5rem;
}

.brand__mark {
    font-size: 2.5rem;
    line-height: 1;
}

.brand__name {
    margin: 0.4rem 0 0;
    font-size: 1.5rem;
}

/* ---------- Blazor-Fehlerleiste ---------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    padding: 0.9rem 1rem calc(0.9rem + var(--safe-bottom));
    background: #b3261e;
    color: #fff;
    box-shadow: 0 -2px 12px rgb(0 0 0 / 25%);
}

#blazor-error-ui .dismiss {
    position: absolute;
    top: 0.5rem;
    right: 0.9rem;
    cursor: pointer;
}

#blazor-error-ui .reload {
    color: #fff;
}

.blazor-error-boundary {
    padding: 1rem;
    border-radius: var(--radius-sm);
    background: var(--danger-soft);
    color: var(--danger);
}

.blazor-error-boundary::after {
    content: "Da ist etwas schiefgelaufen.";
}
.child-head {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.child-head h2 {
    margin: 0;
}

.last-line {
    margin: 0 0 0.9rem;
}

/* Der laufende Timer ist das, was man nachts um drei aus zwei Metern Entfernung sieht. */
.running {
    text-align: center;
    padding: 0.75rem 0 1rem;
}

.running__side {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
}

.running__clock {
    font-size: 3.25rem;
    font-weight: 300;
    line-height: 1.1;
    /* Gleich breite Ziffern, damit die Uhr beim Zaehlen nicht zappelt. */
    font-variant-numeric: tabular-nums;
}

.btn-row--split > .btn {
    flex: 1;
}

.btn--small {
    min-height: 38px;
    padding: 0.35rem 0.7rem;
    font-size: 0.85rem;
    font-weight: 500;
}

.today {
    margin-top: 1.1rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--border);
}

.today__summary {
    display: flex;
    gap: 1.25rem;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.today .btn--block {
    margin-top: 0.75rem;
}

/* Die Bemerkung sitzt unter ihrem Eintrag und ist selbst die Schaltflaeche zum Bearbeiten. */
.note {
    display: block;
    width: 100%;
    margin: -0.35rem 0 0.6rem;
    padding: 0.45rem 0.6rem;
    border: 0;
    border-left: 3px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
}

.note--empty {
    border-left-color: transparent;
    background: transparent;
    padding-left: 0;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.note-edit {
    margin: -0.2rem 0 0.75rem;
}

.note-edit textarea {
    margin-bottom: 0.5rem;
}

.running--sleep .running__side {
    color: var(--accent-sleep);
}

/* ---------- Kind-Auswahl ---------- */

.child-picker {
    display: flex;
    gap: 0.35rem;
    margin-bottom: 0.875rem;
    padding: 0.25rem;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
}

.child-picker__item {
    flex: 1;
    min-height: 40px;
    border: 0;
    border-radius: calc(var(--radius-sm) - 2px);
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.child-picker__item.is-active {
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow);
}

/* ---------- Tagesnavigation im Verlauf ---------- */

.daynav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.daynav__arrow {
    width: var(--tap);
    height: var(--tap);
    flex: none;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.daynav__arrow:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.daynav__label {
    flex: 1;
    text-align: center;
    font-weight: 650;
}

.daynav__label .muted {
    font-weight: 400;
    font-size: 0.85rem;
}

.daystats {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--border);
}

.daystats__item {
    flex: 1;
    text-align: center;
    min-width: 0;
}

.daystats__value {
    font-size: 1.15rem;
    font-weight: 650;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.daystats__label {
    color: var(--text-muted);
    font-size: 0.775rem;
}

/* ---------- Timeline ---------- */

.timeline__icon {
    flex: none;
    width: 1.75rem;
    font-size: 1.1rem;
    text-align: center;
}

.timeline__note {
    margin-top: 0.2rem;
    font-size: 0.85rem;
}

/* ---------- Balken der Statistik ---------- */

.bars {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.75rem;
}

.bar-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.bar-row__day {
    flex: none;
    width: 3.25rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.bar-row__value {
    flex: none;
    width: 4rem;
    text-align: right;
    font-size: 0.8rem;
    font-variant-numeric: tabular-nums;
}

.bar-track {
    flex: 1;
    height: 1.35rem;
    min-width: 0;
    background: var(--surface-2);
    border-radius: 4px;
    overflow: hidden;
}

.bar {
    height: 100%;
    border-radius: 4px;
    /* Auch der kleinste Wert bleibt sichtbar. */
    min-width: 2px;
}

.bar--feeding {
    background: var(--accent);
}

.bar--sleep {
    background: var(--accent-sleep);
}

.bar--diaper {
    background: var(--text-muted);
}

/* ---------- Zahlenfeld mit Einheit ---------- */

.input-unit {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-unit input {
    flex: 1;
    min-width: 0;
}

.input-unit__suffix {
    flex: none;
    color: var(--text-muted);
    font-size: 0.9rem;
}
