/* ===== Suivi bébé — mobile-first, light/dark following the phone setting ===== */
:root {
    --pico-font-size: 100%;
    --radius: 16px;
    --page: #f7f4ef;
    --surface: #ffffff;
    --surface-2: #f1ede6;
    --border: #e6e0d6;
    --text: #23262b;
    --text-soft: #6b6f76;
    --accent: #1f8a9e;
    --accent-soft: #e2f3f6;
    --good: #2f8f4e; --good-bg: #e6f5ea;
    --bad: #c63d3d;  --bad-bg: #fbe9e9;
    --warn: #a86b00; --warn-bg: #fff3d6;
    --info: #2f6db5; --info-bg: #e7effa;
    --ease: cubic-bezier(.2, .7, .2, 1);
    --shadow: 0 1px 2px rgba(35, 38, 43, .05), 0 2px 8px rgba(35, 38, 43, .05);

    --pico-primary: var(--accent);
    --pico-primary-background: var(--accent);
    --pico-primary-border: var(--accent);
    --pico-primary-hover: #18707f;
    --pico-primary-hover-background: #18707f;
    --pico-primary-hover-border: #18707f;
    --pico-primary-focus: rgba(31, 138, 158, .3);
    --pico-primary-inverse: #fff;
    --pico-background-color: var(--page);
    --pico-card-background-color: var(--surface);
    --pico-color: var(--text);
    --pico-muted-color: var(--text-soft);
    --pico-muted-border-color: var(--border);
    --pico-form-element-background-color: var(--surface);
    --pico-border-radius: 10px;
}
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --page: #0f1419;
        --surface: #182028;
        --surface-2: #212b35;
        --border: #2c3844;
        --text: #e8edf2;
        --text-soft: #9aa7b4;
        --accent: #5cc4d6;
        --accent-soft: rgba(92, 196, 214, .14);
        --good: #57c37a; --good-bg: rgba(87, 195, 122, .14);
        --bad: #f07272;  --bad-bg: rgba(240, 114, 114, .14);
        --warn: #e0a440; --warn-bg: rgba(224, 164, 64, .15);
        --info: #7fb2f0; --info-bg: rgba(127, 178, 240, .14);
        --shadow: none;

        --pico-primary: var(--accent);
        --pico-primary-background: #2a9db1;
        --pico-primary-border: #2a9db1;
        --pico-primary-hover: #7fd3e2;
        --pico-primary-hover-background: #35b0c5;
        --pico-primary-hover-border: #35b0c5;
        --pico-primary-inverse: #fff;
        --pico-background-color: var(--page);
        --pico-card-background-color: var(--surface);
        --pico-color: var(--text);
        --pico-muted-color: var(--text-soft);
        --pico-muted-border-color: var(--border);
        --pico-form-element-background-color: var(--surface-2);
        --pico-code-background-color: var(--surface-2);
    }
}

body { background: var(--page); }
main.container { padding-top: 1rem; padding-bottom: 2.5rem; }
h1 { font-size: 1.5rem; margin-bottom: 1rem; }
h2 { font-size: 1.2rem; }
article { border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); padding: 1.1rem; margin-bottom: 1rem; }
article > header { margin: -1.1rem -1.1rem 1rem; padding: .8rem 1.1rem; border-radius: var(--radius) var(--radius) 0 0; }
.muted { color: var(--text-soft); }
.small { font-size: .875rem; }
.good { color: var(--good); }
.bad { color: var(--bad); }
.warn { color: var(--warn); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .16s; }
@media (prefers-reduced-motion: reduce) {
    *, ::view-transition-old(root), ::view-transition-new(root) { animation: none !important; transition: none !important; }
}

/* ----- top bar + menu ----- */
.topbar {
    position: sticky; top: 0; z-index: 30;
    background: color-mix(in srgb, var(--page) 85%, transparent);
    backdrop-filter: saturate(160%) blur(12px); -webkit-backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid var(--border);
    padding-top: env(safe-area-inset-top);
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-height: 3.6rem; padding-top: 0; padding-bottom: 0; }
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--text); min-width: 0; }
.brand:hover { color: var(--text); }
.brand-emoji { font-size: 1.7rem; line-height: 1; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-text small { color: var(--text-soft); font-size: .78rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu { position: static; margin: 0; }
.menu > summary {
    list-style: none; display: flex; align-items: center; justify-content: center;
    width: 2.75rem; height: 2.75rem; padding: 0; border-radius: 12px; line-height: 1;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { display: none !important; }
.menu[open] > summary { border-color: var(--accent); color: var(--accent); }
.menu-panel {
    position: absolute; left: .75rem; right: .75rem; top: calc(100% + .4rem);
    display: grid; grid-template-columns: 1fr 1fr; gap: .35rem; padding: .5rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 16px 40px rgba(0, 0, 0, .18);
    max-height: calc(100vh - 6rem); overflow-y: auto;
}
.menu[open] .menu-panel { animation: drop .16s var(--ease); }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
.menu-panel a {
    display: flex; align-items: center; gap: .6rem; padding: .7rem .75rem; border-radius: 12px;
    color: var(--text); text-decoration: none; font-weight: 500; font-size: .95rem;
    -webkit-tap-highlight-color: transparent;
}
.menu-panel a:hover, .menu-panel a:active { background: var(--surface-2); }
.menu-panel a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }
.menu-emoji { font-size: 1.25rem; width: 1.6rem; text-align: center; }
.menu-panel .menu-logout { grid-column: 1 / -1; border-top: 1px solid var(--border); border-radius: 0 0 12px 12px; color: var(--text-soft); margin-top: .2rem; }
@media (min-width: 769px) {
    .topbar-inner { position: relative; }
    .menu-panel { left: auto; right: 0; width: 26rem; }
}

/* ----- flashes, forms ----- */
.flash { padding: .75rem 1rem; border-radius: 12px; background: var(--info-bg); border-left: 4px solid var(--info); animation: rise .25s var(--ease); }
.flash-success { background: var(--good-bg); border-color: var(--good); }
.flash-error { background: var(--bad-bg); border-color: var(--bad); }
.flash-warning { background: var(--warn-bg); border-color: var(--warn); }
.field-error { display: block; color: var(--bad); margin-top: -.6rem; margin-bottom: .8rem; }
form button[type="submit"] { width: 100%; }
@media (min-width: 769px) { form button[type="submit"] { width: auto; min-width: 12rem; } }

/* ----- login ----- */
.login { max-width: 420px; margin: 2.5rem auto; padding: 1.5rem; }
.login-head { text-align: center; margin-bottom: 1rem; }
.login-emoji { font-size: 3rem; }
.login-head h1 { margin: .25rem 0 0; }

/* ----- dashboard ----- */
.hero { text-align: center; padding: 1.5rem 1rem 1rem; }
.hero-label { margin: 0; color: var(--text-soft); }
.hero-age { font-size: 1.9rem; font-weight: 800; line-height: 1.2; margin: .2rem 0 .4rem; letter-spacing: -.01em; }

/* ----- disclaimer ----- */
.disclaimer { padding-bottom: calc(1.5rem + env(safe-area-inset-bottom)); }
.disclaimer small { display: block; color: var(--text-soft); background: var(--surface-2); border-radius: 12px; padding: .75rem 1rem; line-height: 1.5; }

/* ----- page structure ----- */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .75rem; }
.page-head h1 { margin: 0; }
[role="button"].btn-small, button.btn-small { padding: .45rem .9rem; font-size: .9rem; width: auto; margin: 0; }
.back { display: inline-block; margin-bottom: .5rem; text-decoration: none; font-size: .95rem; }
h2 { margin-top: 1.5rem; margin-bottom: .6rem; }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); }
@media (max-width: 768px) { .grid { grid-template-columns: 1fr; gap: 0; } .grid.grid-3 { grid-template-columns: 1fr 1fr 1fr; gap: .5rem; } }
.delete-form { margin-top: 1rem; }
.delete-form button { width: 100%; color: var(--bad); border-color: var(--bad); }
@media (min-width: 769px) { .delete-form button { width: auto; } }
.radios { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; }

/* ----- lists of items (appointments, measures, doses) ----- */
.list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: 1rem; }
.item {
    display: flex; align-items: center; gap: .8rem; padding: .8rem .95rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    text-decoration: none; color: var(--text); box-shadow: var(--shadow);
    -webkit-tap-highlight-color: transparent; transition: border-color .15s var(--ease), transform .08s var(--ease);
}
.item:hover { border-color: var(--accent); color: var(--text); }
.item:active { transform: scale(.99); }
.item-optional { opacity: .78; }
.item-icon { font-size: 1.5rem; width: 2rem; text-align: center; flex-shrink: 0; }
.item-body { display: flex; flex-direction: column; gap: .15rem; flex: 1; min-width: 0; }
.measures { display: flex; flex-wrap: wrap; gap: .25rem .9rem; font-size: .95rem; }
.badge { font-size: .72rem; font-weight: 600; padding: .15rem .55rem; border-radius: 999px; white-space: nowrap; }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-good { background: var(--good-bg); color: var(--good); }
.tag { font-size: .72rem; font-weight: 600; padding: .05rem .45rem; border-radius: 6px; }
.tag-obligatoire { background: var(--info-bg); color: var(--info); }
.tag-recommande { background: var(--good-bg); color: var(--good); }
.tag-situation { background: var(--surface-2); color: var(--text-soft); }
.pct { font-size: .75rem; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: .05rem .4rem; border-radius: 6px; }
details.history { margin: 1rem 0; }
details.history > summary { font-weight: 600; }

/* ----- tabs ----- */
.tabs { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .4rem; margin-bottom: .75rem; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { flex-shrink: 0; padding: .4rem .85rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); text-decoration: none; color: var(--text); font-size: .9rem; }
.tabs a[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ----- dashboard cards ----- */
.cards { display: grid; grid-template-columns: 1fr; gap: .75rem; }
@media (min-width: 700px) { .cards { grid-template-columns: 1fr 1fr; } }
.card {
    display: flex; flex-direction: column; gap: .3rem; padding: 1rem 1.1rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    text-decoration: none; color: var(--text); box-shadow: var(--shadow);
    transition: border-color .15s var(--ease), transform .08s var(--ease);
}
.card:hover { border-color: var(--accent); color: var(--text); }
.card:active { transform: scale(.99); }
.card-title { font-size: .85rem; font-weight: 700; color: var(--text-soft); text-transform: uppercase; letter-spacing: .03em; }
.card .badge { align-self: flex-start; }

/* ----- growth chart ----- */
.chart-card { padding: .9rem .6rem .5rem; }
.chart-card > header { margin: -.9rem -.6rem .5rem; }
svg.growth-chart { width: 100%; height: auto; display: block; font-family: inherit; }
.growth-chart .g { stroke: var(--border); stroke-width: 1; }
.growth-chart .ax { fill: var(--text-soft); font-size: 12px; }
.growth-chart .b97 { fill: var(--accent); opacity: .10; }
.growth-chart .b85 { fill: var(--accent); opacity: .16; }
.growth-chart .pc { fill: none; stroke: var(--accent); stroke-width: 1; opacity: .45; }
.growth-chart .p50 { fill: none; stroke: var(--accent); stroke-width: 2; opacity: .8; }
.growth-chart .pl { fill: var(--text-soft); font-size: 10px; }
.growth-chart .today { stroke: var(--warn); stroke-width: 1.5; stroke-dasharray: 4 4; }
.growth-chart .child { fill: none; stroke: #e0607e; stroke-width: 2.5; stroke-linejoin: round; }
.growth-chart .pt { fill: #e0607e; stroke: var(--surface); stroke-width: 2; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem .5rem; margin: .4rem .4rem 0; color: var(--text-soft); }
.lg { display: inline-block; width: 1.1rem; height: .7rem; border-radius: 3px; margin-left: .4rem; }
.lg-97 { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.lg-85 { background: color-mix(in srgb, var(--accent) 26%, transparent); }
.lg-50 { height: 3px; background: var(--accent); }
.lg-child { height: 3px; background: #e0607e; }
.lg-today { height: 0; border-top: 2px dashed var(--warn); }

/* ----- milestones ----- */
.milestone { padding: .9rem 1rem; }
.milestone-head { display: flex; gap: .75rem; align-items: flex-start; }
.milestone-head > div { display: flex; flex-direction: column; }
.domain { font-size: 1.5rem; line-height: 1.2; }
.milestone p { margin: .5rem 0; }
.milestone-now { border-left: 4px solid var(--accent); }
.milestone-past { border-left: 4px solid var(--warn); }
.milestone-achieved { border-left: 4px solid var(--good); }
.milestone-later, .milestone-next { opacity: .9; }
details.activities { margin: .25rem 0 .6rem; }
details.activities summary { font-size: .9rem; }
details.activities ul { font-size: .9rem; margin-bottom: 0; }

/* ----- daily log ----- */
.quick { margin-bottom: 1rem; }
.status-line { margin-bottom: .6rem; }
.tap-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.tap-grid form, .tap-row form, .quick > form { margin: 0; }
.big-tap {
    width: 100%; min-height: 4.2rem; margin: 0; padding: .6rem; font-size: 1.15rem; font-weight: 700;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem;
    border-radius: 16px; border: 0; color: var(--text); background: var(--surface); box-shadow: var(--shadow);
    border: 1px solid var(--border); -webkit-tap-highlight-color: transparent; transition: transform .08s var(--ease);
}
.big-tap:active, .tap-ml:active { transform: scale(.96); }
.big-tap small { font-size: .78rem; font-weight: 500; color: var(--text-soft); }
.tap-feed { background: color-mix(in srgb, #e0607e 12%, var(--surface)); }
.tap-sleep { background: color-mix(in srgb, #6c63d9 14%, var(--surface)); }
.tap-diaper { background: color-mix(in srgb, #d9a441 14%, var(--surface)); }
.tap-wake { background: color-mix(in srgb, #f2b33d 25%, var(--surface)); margin-bottom: .5rem; }
.tap-label { margin: .9rem 0 .35rem; font-weight: 600; }
.tap-row { display: grid; grid-template-columns: repeat(6, 1fr); gap: .35rem; }
@media (max-width: 420px) { .tap-row { grid-template-columns: repeat(3, 1fr); } }
.tap-ml {
    width: 100%; margin: 0; padding: .55rem 0; font-size: 1.05rem; font-weight: 700; line-height: 1.1;
    display: flex; flex-direction: column; align-items: center;
    border-radius: 12px; background: color-mix(in srgb, var(--accent) 12%, var(--surface)); color: var(--text); border: 1px solid var(--border);
}
.tap-ml small { font-size: .7rem; font-weight: 500; color: var(--text-soft); }
.undo-bar { display: flex; align-items: center; gap: .5rem; margin: -.4rem 0 .6rem; }
.link-button { background: none; border: 0; padding: 0; margin: 0; width: auto; color: var(--accent); text-decoration: underline; font-size: .9rem; }
.day-nav { display: flex; align-items: center; justify-content: space-between; margin: 1rem 0 .5rem; }
.day-nav a { font-size: 1.6rem; text-decoration: none; padding: 0 .75rem; }
.totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: .5rem; margin-bottom: .75rem; }
.totals div { display: flex; flex-direction: column; align-items: center; padding: .6rem .3rem; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.totals strong { font-size: 1.15rem; }
.totals span { font-size: .78rem; color: var(--text-soft); text-align: center; }
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; align-items: baseline; gap: .6rem; padding: .6rem .3rem; border-bottom: 1px solid var(--border); text-decoration: none; color: var(--text); }
.tl-item:hover { color: var(--text); background: var(--surface-2); }
.tl-time { font-variant-numeric: tabular-nums; font-weight: 600; width: 3rem; flex-shrink: 0; }
.tl-emoji { width: 1.5rem; text-align: center; }
.tl-body { flex: 1; min-width: 0; }
.tl-who { flex-shrink: 0; }

/* ----- health ----- */
.emergency { border-left: 4px solid var(--bad); }
.emergency-numbers { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; margin: .6rem 0 .4rem; }
.emergency-numbers a { margin: 0; padding: .55rem .2rem; font-size: .9rem; font-weight: 700; }
.emergency-numbers a:first-child { background: var(--bad); border-color: var(--bad); }
.item-link { text-decoration: none; color: var(--text); }
.item-link:hover { color: var(--text); }
.call { font-size: 1.4rem; text-decoration: none; padding: .3rem .5rem; border-radius: 12px; background: var(--good-bg); }

/* ----- food ----- */
.allergen-grid { display: flex; flex-wrap: wrap; gap: .35rem; margin: .6rem 0; }
.allergen { font-size: .82rem; padding: .2rem .55rem; border-radius: 999px; background: var(--surface-2); color: var(--text-soft); }
.allergen-done { background: var(--good-bg); color: var(--good); font-weight: 600; }

/* ----- teeth ----- */
.mouth { text-align: center; padding: 1rem .5rem; }
.jaw { display: grid; grid-template-columns: repeat(10, 1fr); gap: 2px; max-width: 34rem; margin: 0 auto; }
.jaw-upper { align-items: end; margin-bottom: .5rem; }
.jaw-lower { align-items: start; }
.jaw-lower .tooth { flex-direction: column-reverse; }
.jaw-label { margin: .2rem 0; }
.tooth { display: flex; flex-direction: column; align-items: center; gap: .2rem; text-decoration: none; color: var(--text-soft); -webkit-tap-highlight-color: transparent; }
.tooth-shape { display: block; width: 78%; aspect-ratio: 3 / 4; border-radius: 40% 40% 45% 45%; border: 2px solid var(--border); background: var(--surface-2); transition: transform .1s var(--ease); }
.tooth:active .tooth-shape { transform: scale(.9); }
.tooth-t4 .tooth-shape, .tooth-t5 .tooth-shape { aspect-ratio: 1 / 1; border-radius: 35%; }
.tooth-t3 .tooth-shape { border-radius: 50% 50% 40% 40%; }
.tooth-out .tooth-shape { background: #fffdf6; border-color: #e4d8b8; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .06); }
.tooth-soon .tooth-shape { border-style: dashed; border-color: var(--accent); }
.tooth-label { font-size: .6rem; line-height: 1; white-space: nowrap; }
.tooth-dot { display: inline-block; width: .8rem; height: .8rem; border-radius: 4px; margin-left: .5rem; border: 2px solid var(--border); vertical-align: middle; }
.tooth-dot.out { background: #fffdf6; border-color: #e4d8b8; }
.tooth-dot.soon { border-style: dashed; border-color: var(--accent); }
.tooth-dot.later { background: var(--surface-2); }
.center { text-align: center; }

/* ----- journal ----- */
.journal { display: grid; grid-template-columns: 1fr; gap: .75rem; }
@media (min-width: 640px) { .journal { grid-template-columns: 1fr 1fr; } }
.memory { display: flex; flex-direction: column; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); text-decoration: none; color: var(--text); box-shadow: var(--shadow); }
.memory:hover { color: var(--text); border-color: var(--accent); }
.memory img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--surface-2); }
.memory-body { display: flex; flex-direction: column; gap: .2rem; padding: .8rem 1rem; }
.photo-large { width: 100%; border-radius: var(--radius); margin-bottom: 1rem; }
