:root {
    color-scheme: light;
    --bg: #fff7fb;
    --surface: #ffffff;
    --surface-strong: #fff0f5;
    --soft: #f7efe8;
    --text: #261b18;
    --muted: #806f68;
    --brand: #ff7a90;
    --brand-dark: #d94d6a;
    --teal: #3aa7a3;
    --blue: #5d83c4;
    --mint: #8bd8bd;
    --sun: #ffd166;
    --lavender: #b79ced;
    --line: #f2dce5;
    --shadow: 0 12px 26px rgba(122, 52, 78, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(255, 209, 102, 0.22), transparent 30vw),
        radial-gradient(circle at top right, rgba(139, 216, 189, 0.22), transparent 28vw),
        var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.hidden {
    display: none !important;
}

.app-shell {
    width: min(100%, 560px);
    min-height: 100vh;
    margin: 0 auto;
    padding: 18px 16px 96px;
}

.topbar,
.panel,
.baby-card,
.summary-card,
.sweetspot-card,
.stats-list article,
.timeline-item,
.live-strip {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px;
    margin-bottom: 14px;
    background: linear-gradient(135deg, #fff, #fff2f6);
}

.eyebrow,
.muted,
.message,
.hint {
    margin: 0 0 4px;
    color: var(--muted);
    font-size: 13px;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 0;
    font-size: 27px;
    letter-spacing: 0;
}

h2 {
    margin-bottom: 8px;
    font-size: 21px;
    letter-spacing: 0;
}

h3 {
    margin-bottom: 10px;
    font-size: 17px;
    letter-spacing: 0;
}

.locale-switch,
.auth-tabs,
.filter-tabs {
    display: inline-flex;
    padding: 3px;
    background: var(--surface-strong);
    border-radius: 8px;
}

.locale-switch a,
.auth-tabs button,
.filter-tabs button {
    min-width: 42px;
    padding: 8px 10px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    text-align: center;
    text-decoration: none;
}

.locale-switch a.active,
.auth-tabs button.active,
.filter-tabs button.active {
    background: var(--brand);
    color: #fff;
}

.auth-screen {
    display: grid;
    gap: 14px;
}

.auth-hero {
    padding: 20px 6px 4px;
    text-align: center;
}

.app-mark,
.baby-photo {
    display: grid;
    place-items: center;
    background: linear-gradient(140deg, var(--brand), var(--sun));
    color: #fff;
    font-weight: 900;
}

.app-mark {
    width: 84px;
    height: 84px;
    margin: 0 auto 12px;
    border-radius: 8px;
    font-size: 42px;
}

.auth-tabs {
    width: 100%;
}

.auth-tabs button {
    flex: 1;
}

.form-stack {
    display: grid;
    gap: 12px;
}

.panel,
.summary-card,
.sweetspot-card {
    padding: 16px;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    min-height: 46px;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
}

textarea {
    resize: vertical;
}

.primary-btn,
.ghost-btn,
.small-btn,
.icon-btn {
    border: 0;
    border-radius: 8px;
    font-weight: 900;
}

.primary-btn {
    min-height: 50px;
    background: var(--brand-dark);
    color: #fff;
}

.ghost-btn,
.small-btn,
.icon-btn {
    background: var(--surface-strong);
    color: var(--brand-dark);
}

.ghost-btn {
    min-height: 50px;
}

.full-width {
    width: 100%;
}

.small-btn {
    min-height: 38px;
    padding: 9px 12px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    font-size: 24px;
}

.icon-btn.mini {
    width: 32px;
    height: 32px;
    font-size: 18px;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.baby-card {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 14px;
    align-items: center;
    padding: 16px;
    background: linear-gradient(135deg, #fff, #f3fffb);
}

.baby-photo {
    position: relative;
    width: 72px;
    height: 72px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    font-size: 34px;
    overflow: hidden;
}

.baby-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.baby-photo small {
    position: absolute;
    right: 4px;
    bottom: 4px;
    padding: 2px 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    color: var(--brand-dark);
    font-size: 10px;
    font-weight: 900;
}

#profileSelect {
    grid-column: 1 / -1;
}

.live-strip {
    position: sticky;
    top: 8px;
    z-index: 5;
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    align-items: center;
    margin-top: 14px;
    padding: 12px;
}

.live-strip strong {
    font-size: 20px;
}

.live-strip button {
    min-height: 40px;
    padding: 0 12px;
    border: 0;
    border-radius: 8px;
    background: var(--brand-dark);
    color: #fff;
    font-weight: 900;
}

.view {
    display: none;
    margin-top: 14px;
}

.view.active {
    display: block;
}

.sweetspot-card {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin-bottom: 14px;
    border-color: #d8f2ec;
    background: linear-gradient(135deg, #fff, #effdf9);
}

.sweetspot-card h2 {
    margin-bottom: 2px;
    color: var(--teal);
    font-size: 34px;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.quick-actions button {
    display: grid;
    min-height: 98px;
    place-items: center;
    gap: 7px;
    padding: 12px 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: linear-gradient(180deg, #fff, #fff8fb);
    box-shadow: 0 8px 18px rgba(70, 35, 25, 0.06);
    color: var(--text);
    transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.quick-actions button:active {
    transform: scale(0.98);
}

.action-icon {
    display: grid;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 14px;
    background: var(--surface-strong);
    color: var(--brand-dark);
    font-size: 25px;
    line-height: 1;
}

.action-feeding .action-icon { background: #fff0f5; }
.action-diaper .action-icon { background: #eef9ff; }
.action-sleep .action-icon { background: #f2efff; }
.action-growth .action-icon { background: #effdf5; }
.action-health .action-icon { background: #fff4df; }
.action-journal .action-icon { background: #fff8c9; }

.action-feeding { border-color: #ffd5df !important; }
.action-diaper { border-color: #cfeeff !important; }
.action-sleep { border-color: #ded5ff !important; }
.action-growth { border-color: #c9f3dd !important; }
.action-health { border-color: #ffe2a3 !important; }
.action-journal { border-color: #ffef99 !important; }

.quick-actions b {
    font-size: 14px;
    text-align: center;
}

.section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.section-title h2 {
    margin-bottom: 0;
}

.section-title span,
.timeline-item time {
    color: var(--muted);
    font-size: 13px;
}

.summary-grid,
.stats-list,
.insight-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.summary-grid article,
.insight-grid article {
    min-height: 84px;
    padding: 13px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--surface-strong), #fff);
}

.summary-grid strong,
.summary-grid span,
.stats-list span,
.stats-list strong,
.insight-grid span,
.insight-grid strong {
    display: block;
}

.summary-grid strong,
.stats-list strong,
.insight-grid strong {
    margin-bottom: 4px;
    font-size: 21px;
}

.summary-grid span,
.stats-list span,
.insight-grid span {
    color: var(--muted);
    font-size: 13px;
}

.filter-tabs {
    width: 100%;
    margin-bottom: 12px;
    overflow-x: auto;
    gap: 4px;
    flex-wrap: nowrap;
    justify-content: flex-start;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.filter-tabs::-webkit-scrollbar {
    display: none;
}

.filter-tabs button {
    flex: 0 0 auto;
    min-width: max-content;
    scroll-snap-align: start;
}

.timeline,
.care-list {
    display: grid;
    gap: 12px;
}

.timeline-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
    padding: 15px;
    background: linear-gradient(135deg, #fff, #fffafd);
}

.timeline-item strong {
    display: block;
    margin-bottom: 6px;
    font-size: 16px;
}

.trash-item {
    border-style: dashed;
    opacity: 0.94;
}

.trash-item small {
    color: var(--muted);
}

.timeline-item p {
    margin-bottom: 0;
    color: var(--muted);
    line-height: 1.45;
    word-break: break-word;
}

.timeline-side {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.empty-state {
    padding: 18px;
    border: 1px dashed var(--line);
    border-radius: 8px;
    color: var(--muted);
    text-align: center;
}

.chart-panel,
.insight-grid,
.care-list,
.sleep-plan {
    margin-top: 14px;
}

.weekly-chart {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
    align-items: end;
    min-height: 168px;
}

.chart-day {
    display: grid;
    gap: 8px;
    justify-items: center;
}

.bars {
    display: flex;
    align-items: end;
    gap: 3px;
    height: 128px;
}

.bar {
    width: 7px;
    min-height: 6px;
    border-radius: 8px 8px 0 0;
}

.bar.sleep {
    background: var(--blue);
}

.bar.milk {
    background: var(--brand);
}

.bar.diaper {
    background: var(--teal);
}

.care-list article {
    display: grid;
    gap: 4px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.care-list span {
    color: var(--muted);
    font-size: 13px;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.advanced-fields {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface-strong);
}

.advanced-fields summary {
    color: var(--brand-dark);
    font-weight: 900;
}

.advanced-fields label {
    margin-top: 10px;
}

.bottom-nav {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    width: min(100%, 560px);
    margin: 0 auto;
    padding: 9px 8px calc(9px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.94);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(16px);
}

.bottom-nav button {
    min-height: 42px;
    padding: 8px 3px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--muted);
    font-size: 11px;
    font-weight: 900;
    text-align: center;
}

.bottom-nav button.active {
    background: linear-gradient(135deg, #fff0f5, #fff8c9);
    color: var(--brand-dark);
}

.log-dialog {
    width: min(calc(100% - 28px), 560px);
    max-height: min(86vh, 760px);
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text);
    overflow: auto;
}

.report-dialog {
    max-width: min(calc(100% - 20px), 720px);
}

.report-content {
    display: grid;
    gap: 12px;
    margin-bottom: 14px;
}

.report-table {
    max-height: 52vh;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.report-table table {
    width: 100%;
    border-collapse: collapse;
    min-width: 520px;
}

.report-table th,
.report-table td {
    padding: 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
    font-size: 13px;
}

@media print {
    body > *:not(.report-dialog) {
        display: none !important;
    }

    .report-dialog {
        position: static;
        display: block !important;
        width: auto;
        max-width: none;
        max-height: none;
        border: 0;
        box-shadow: none;
    }

    .report-dialog .section-title,
    #printReportBtn {
        display: none !important;
    }

    .report-table {
        max-height: none;
        overflow: visible;
    }
}

.log-dialog::backdrop {
    background: rgba(38, 27, 24, 0.36);
}

.undo-toast {
    position: fixed;
    right: 16px;
    bottom: 88px;
    left: 16px;
    z-index: 10;
    display: flex;
    width: min(calc(100% - 32px), 520px);
    margin: 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 13px 14px;
    border-radius: 8px;
    background: #261b18;
    color: #fff;
    box-shadow: var(--shadow);
}

.undo-toast button {
    border: 0;
    background: transparent;
    color: #ffd166;
    font-weight: 900;
}

@media (min-width: 860px) {
    .app-shell {
        width: min(100%, 1080px);
    }

    .baby-card {
        grid-template-columns: 72px 1fr 240px;
    }

    #profileSelect {
        grid-column: auto;
    }

    .quick-actions {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .bottom-nav {
        width: min(100%, 1080px);
    }
}

@media (max-width: 420px) {
    .app-shell {
        padding-right: 12px;
        padding-left: 12px;
    }

    .summary-grid,
    .stats-list,
    .insight-grid {
        grid-template-columns: 1fr;
    }

    .timeline-item,
    .sweetspot-card,
    .live-strip {
        grid-template-columns: 1fr;
    }

    .timeline-side {
        align-items: flex-start;
    }

    .section-title {
        align-items: flex-start;
        flex-direction: column;
    }

    .button-row {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
    }

    .button-row .small-btn {
        width: 100%;
        min-width: 0;
        padding-right: 8px;
        padding-left: 8px;
        font-size: 12px;
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        color-scheme: dark;
        --bg: #171214;
        --surface: #211917;
        --surface-strong: #352029;
        --soft: #2b2220;
        --text: #fff7f3;
        --muted: #c6aaa2;
        --line: #3d2b27;
        --shadow: none;
    }

    .bottom-nav {
        background: rgba(33, 25, 23, 0.94);
    }

    .sweetspot-card,
    .topbar,
    .baby-card,
    .timeline-item,
    .quick-actions button {
        background: var(--surface);
    }
}
