:root {
    color-scheme: light;
    --bg: #fffaf6;
    --surface: #ffffff;
    --surface-strong: #fff2ea;
    --soft: #f4eee5;
    --text: #292523;
    --muted: #827872;
    --brand: #ffad86;
    --brand-dark: #c87554;
    --sage: #9fb79e;
    --sage-soft: #dfe8dc;
    --rose: #d99aa3;
    --oat: #ead7b7;
    --teal: #82aaa0;
    --blue: #7894b7;
    --mint: #cddccc;
    --sun: #e6bd7a;
    --lavender: #dccfe8;
    --line: #eee6de;
    --shadow: 0 16px 34px rgba(88, 70, 58, 0.09);
}

html {
    color-scheme: light;
    background: var(--bg);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(180deg, #fffdf9 0%, var(--bg) 54%, #fff7f1 100%);
    color: var(--text);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select,
textarea {
    font: inherit;
    color-scheme: light;
}

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: 22px 18px 102px;
}

.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: 18px;
    margin-bottom: 16px;
    background: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(14px);
}

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

.message {
    margin: 0;
    padding: 13px 14px;
    border: 1px solid #f4d8c8;
    border-left: 5px solid var(--brand);
    border-radius: 8px;
    background: #fff4ec;
    color: #5f4032;
    font-size: 15px;
    font-weight: 800;
    line-height: 1.45;
    box-shadow: 0 10px 22px rgba(199, 117, 84, 0.1);
}

.message:empty {
    display: none;
}

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

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

h2 {
    margin-bottom: 8px;
    font-size: 24px;
    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: #f7f1ea;
    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: #fff;
    color: var(--brand-dark);
    box-shadow: 0 8px 18px rgba(91, 70, 55, 0.08);
}

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

.auth-hero {
    padding: 24px 6px 8px;
    text-align: left;
}

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

.app-mark {
    position: relative;
    width: 84px;
    height: 84px;
    margin: 0 0 14px;
    border-radius: 28px;
    font-size: 0;
    box-shadow: 0 18px 32px rgba(200, 117, 84, 0.18);
}

.logo-face {
    position: relative;
    width: 48px;
    height: 48px;
    border: 4px solid #fff;
    border-radius: 50%;
}

.logo-face::before,
.logo-face::after {
    content: "";
    position: absolute;
    top: 17px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
}

.logo-face::before {
    left: 11px;
}

.logo-face::after {
    right: 11px;
}

.app-mark::before {
    content: "";
    position: absolute;
    top: 17px;
    right: 18px;
    width: 13px;
    height: 13px;
    border-top: 4px solid #fff;
    border-right: 4px solid #fff;
    border-radius: 50%;
    transform: rotate(-30deg);
}

.app-mark::after {
    content: "";
    position: absolute;
    bottom: 22px;
    left: 34px;
    width: 16px;
    height: 8px;
    border-bottom: 4px solid #fff;
    border-radius: 0 0 18px 18px;
}

.auth-tabs {
    width: 100%;
}

.auth-tabs button {
    flex: 1;
}

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

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

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

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

textarea {
    resize: vertical;
}

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

.primary-btn {
    min-height: 52px;
    background: linear-gradient(135deg, var(--brand), var(--brand-dark));
    color: #fff;
    box-shadow: 0 10px 20px rgba(200, 117, 84, 0.2);
}

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

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

.link-btn {
    min-height: 38px;
    background: transparent;
    color: var(--brand-dark);
    text-align: center;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.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: 18px;
    background: linear-gradient(135deg, #ffffff, #f4f8f0);
}

.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: #dce8d7;
    background: linear-gradient(135deg, #ffffff, #eef6eb);
}

.sweetspot-card h2 {
    margin-bottom: 2px;
    color: #6d9277;
    font-size: 34px;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    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, #fffaf6);
    box-shadow: 0 12px 24px rgba(70, 45, 25, 0.07);
    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: #ffe2d3; }
.action-diaper .action-icon { background: #dfe8dc; }
.action-sleep .action-icon { background: #eadde0; }
.action-growth .action-icon { background: #e7d8bb; }
.action-health .action-icon { background: #f8d0b3; }
.action-journal .action-icon { background: #eee3f3; }

.action-feeding { border-color: #ffd7c4 !important; background: #fff4ec !important; }
.action-diaper { border-color: #d5e2d2 !important; background: #f5faf2 !important; }
.action-sleep { border-color: #ead1d7 !important; background: #fff4f6 !important; }
.action-growth { border-color: #e8d6b5 !important; background: #fff8ea !important; }
.action-health { border-color: #ffd6b7 !important; background: #fff0e2 !important; }
.action-journal { border-color: #e4d5ed !important; background: #fbf3ff !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, #fff4ec, #fff);
}

.summary-grid article:nth-child(2),
.insight-grid article:nth-child(2) {
    background: linear-gradient(135deg, #eef6eb, #fff);
}

.summary-grid article:nth-child(3),
.insight-grid article:nth-child(3) {
    background: linear-gradient(135deg, #f7ead1, #fff);
}

.summary-grid article:nth-child(4),
.insight-grid article:nth-child(4) {
    background: linear-gradient(135deg, #f5e9f9, #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, #fffaf6);
}

.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: 10px 10px calc(10px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.9);
    border-top: 1px solid var(--line);
    backdrop-filter: blur(16px);
}

.bottom-nav button {
    display: grid;
    min-height: 54px;
    place-items: center;
    gap: 4px;
    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::before {
    display: block;
    color: currentColor;
    font-size: 20px;
    line-height: 1;
}

.bottom-nav [data-view="dashboardView"]::before { content: "⌂"; }
.bottom-nav [data-view="historyView"]::before { content: "□"; }
.bottom-nav [data-view="statsView"]::before { content: "▱"; }
.bottom-nav [data-view="settingsView"]::before { content: "⚙"; }

.bottom-nav button.active {
    background: #fff1e8;
    color: var(--brand-dark);
    box-shadow: 0 8px 18px rgba(199, 117, 84, 0.12);
}

.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;
    }
}
