/* Pouce — home & baby. Day theme by default, night theme 21:00–07:00. */

:root {
    --bg: #fff7ef;
    --card: #ffffff;
    --card-2: #fff1e4;
    --ink: #2b2330;
    --muted: #8a7d86;
    --line: #f0e2d6;
    --primary: #ff6b5b;
    --primary-ink: #ffffff;
    --mint: #22b28f;
    --butter: #ffc94d;
    --lav: #8c7cf0;
    --sky: #4aa8ff;
    --danger: #e0475b;
    --p1: #ff6b5b;
    --p2: #8c7cf0;
    --shadow: 0 6px 20px rgba(120, 70, 40, .08), 0 1px 3px rgba(120, 70, 40, .06);
    --radius: 22px;
    color-scheme: light;
}

:root[data-theme="night"] {
    --bg: #140f17;
    --card: #211a26;
    --card-2: #2a2130;
    --ink: #eadbc8;
    --muted: #9b8a86;
    --line: #34293a;
    --primary: #e39552;
    --primary-ink: #1b1209;
    --mint: #6fb59a;
    --butter: #d8a948;
    --lav: #a08fe0;
    --sky: #6f9fd0;
    --danger: #d06070;
    --p1: #e39552;
    --p2: #a08fe0;
    --shadow: none;
    color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 16px/1.4 'Nunito', ui-rounded, system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    min-height: 100dvh;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; font-weight: 900; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }

/* ---------- Shell ---------- */

.app { max-width: 560px; margin: 0 auto; padding: 0 16px calc(96px + env(safe-area-inset-bottom)); }

.topbar {
    display: flex; align-items: center; gap: 12px;
    padding: calc(14px + env(safe-area-inset-top)) 0 10px;
}
.topbar .hello { flex: 1; min-width: 0; }
.topbar h1 { font-size: 26px; line-height: 1.1; }
.topbar .sub { color: var(--muted); font-size: 14px; font-weight: 600; }

.avatar {
    width: 40px; height: 40px; border-radius: 50%; border: 0; flex: none;
    display: grid; place-items: center; font-weight: 900; color: #fff; font-size: 16px;
}
.avatar.p1 { background: var(--p1); }
.avatar.p2 { background: var(--p2); }
.avatar.sm { display: inline-grid; vertical-align: -5px; width: 22px; height: 22px; font-size: 11px; margin-right: 2px; }

.pending {
    font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 99px;
    background: var(--butter); color: #3a2a00;
}

.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    display: flex; justify-content: center;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--line);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.tabbar-inner { display: flex; width: 100%; max-width: 560px; }
.tab {
    flex: 1; border: 0; background: none; padding: 6px 0 4px; border-radius: 16px;
    display: flex; flex-direction: column; align-items: center; gap: 1px;
    font-size: 12px; font-weight: 800; color: var(--muted);
}
.tab .ico { font-size: 24px; line-height: 1.1; filter: grayscale(1); opacity: .6; transition: transform .15s; }
.tab[aria-selected="true"] { color: var(--ink); }
.tab[aria-selected="true"] .ico { filter: none; opacity: 1; transform: translateY(-2px) scale(1.08); }

.section-title {
    display: flex; align-items: baseline; justify-content: space-between;
    margin: 22px 2px 10px; font-size: 18px;
}
.section-title .link { border: 0; background: none; color: var(--primary); font-weight: 800; font-size: 14px; padding: 4px; }

.card {
    background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 16px; border: 1px solid var(--line);
}
:root:not([data-theme="night"]) .card { border-color: transparent; }

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

.btn {
    border: 0; border-radius: 16px; padding: 13px 18px; font-weight: 800;
    background: var(--card-2); color: var(--ink);
}
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-danger { background: none; color: var(--danger); }
.btn-block { width: 100%; }
.btn:active, .action:active, .chip:active { transform: scale(.97); }

/* ---------- Baby ---------- */

.status { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px; }
.stat { padding: 14px 16px; }
.stat .label { font-size: 13px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .big { font-size: 30px; font-weight: 900; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .big small { font-size: 16px; font-weight: 800; }
.stat .meta { font-size: 13px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.stat.wide { grid-column: span 2; display: flex; align-items: center; gap: 14px; }
.stat.wide .grow { flex: 1; }
.stat.sleeping { background: linear-gradient(135deg, #5b4fd6, #8c7cf0); color: #fff; border: 0; }
.stat.sleeping .label, .stat.sleeping .meta { color: rgba(255, 255, 255, .8); }
:root[data-theme="night"] .stat.sleeping { background: linear-gradient(135deg, #2c2550, #43386f); }

.actions { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.action {
    position: relative; border: 0; border-radius: var(--radius); padding: 18px 12px 16px;
    min-height: 112px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
    color: #fff; font-weight: 900; font-size: 18px; box-shadow: var(--shadow);
    user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
    transition: transform .1s;
}
.action .emoji { font-size: 38px; line-height: 1; }
.action .hint { font-size: 12px; font-weight: 700; opacity: .85; }
.action.bottle { background: var(--sky); }
.action.nappy { background: var(--mint); }
.action.sleep { background: var(--lav); }
.action.bath { background: var(--butter); color: #3a2a00; }
.action.wake { background: #5b4fd6; }
:root[data-theme="night"] .action { filter: saturate(.7) brightness(.8); }
.action.pressing { transform: scale(.95); }

.today-strip { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.pill {
    background: var(--card); border: 1px solid var(--line); border-radius: 99px;
    padding: 6px 12px; font-size: 13px; font-weight: 800;
}

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
    display: flex; align-items: center; gap: 12px; padding: 12px 4px;
    border-bottom: 1px solid var(--line);
}
.timeline li:last-child { border-bottom: 0; }
.timeline .t-emoji { font-size: 24px; width: 32px; text-align: center; }
.timeline .t-main { flex: 1; min-width: 0; }
.timeline .t-title { font-weight: 800; }
.timeline .t-sub { font-size: 13px; color: var(--muted); font-weight: 600; }
.timeline .t-time { font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.timeline .t-pts { font-size: 12px; color: var(--mint); font-weight: 900; }
.timeline button.row { all: unset; display: contents; cursor: pointer; }
.empty { text-align: center; padding: 22px 10px; color: var(--muted); font-weight: 600; }

.baby-hero { display: flex; align-items: center; gap: 12px; padding: 16px; margin-top: 6px; }
.baby-hero .emoji { font-size: 40px; }

/* ---------- Home (chores) ---------- */

.chores { display: grid; gap: 10px; }
.chore { display: flex; align-items: center; gap: 12px; padding: 12px 12px 12px 16px; }
.chore .c-main { flex: 1; min-width: 0; }
.chore .c-title { font-weight: 800; }
.chore .c-sub { font-size: 13px; color: var(--muted); font-weight: 600; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.chore .bar { height: 6px; border-radius: 99px; background: var(--card-2); margin-top: 8px; overflow: hidden; }
.chore .bar span { display: block; height: 100%; border-radius: 99px; background: var(--mint); }
.chore.due .bar span { background: var(--butter); }
.chore.late .bar span { background: var(--primary); }
.chore .tag { font-size: 11px; font-weight: 900; padding: 2px 8px; border-radius: 99px; background: var(--card-2); color: var(--muted); }
.chore.late .tag.state { background: var(--primary); color: var(--primary-ink); }
.chore.due .tag.state { background: var(--butter); color: #3a2a00; }
.check {
    width: 52px; height: 52px; border-radius: 16px; border: 2px solid var(--line); background: var(--card-2);
    font-size: 24px; flex: none; display: grid; place-items: center;
}
.chore.late .check { border-color: var(--primary); }
.chore .edit { border: 0; background: none; color: var(--muted); font-size: 20px; padding: 6px; }
.room-filter { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.room-filter::-webkit-scrollbar { display: none; }
.chip {
    border: 1px solid var(--line); background: var(--card); border-radius: 99px;
    padding: 8px 14px; font-weight: 800; font-size: 14px; white-space: nowrap;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- Game ---------- */

.challenge { background: linear-gradient(135deg, #ff8a5b, #ff5b7a); color: #fff; border: 0; }
:root[data-theme="night"] .challenge { background: linear-gradient(135deg, #5a3622, #5a2433); }
.challenge .kicker { font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; opacity: .85; }
.challenge h2 { font-size: 24px; margin: 4px 0 2px; }
.challenge p { margin: 0 0 12px; font-weight: 600; opacity: .92; }
.progress { height: 12px; border-radius: 99px; background: rgba(255, 255, 255, .3); overflow: hidden; }
.progress span { display: block; height: 100%; background: #fff; border-radius: 99px; transition: width .4s; }
.challenge .foot { display: flex; justify-content: space-between; margin-top: 8px; font-weight: 800; font-size: 14px; }

.duel .names { display: flex; justify-content: space-between; font-weight: 900; margin-bottom: 8px; }
.duel .names .pts { font-size: 28px; display: block; line-height: 1; }
.duel .names .right { text-align: right; }
.duel .meter { display: flex; height: 16px; border-radius: 99px; overflow: hidden; background: var(--card-2); }
.duel .meter span { transition: flex-grow .4s; }
.duel .meter .a { background: var(--p1); }
.duel .meter .b { background: var(--p2); }
.duel .streaks { display: flex; justify-content: space-between; margin-top: 10px; font-size: 13px; font-weight: 800; color: var(--muted); }

.titles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.title-card { padding: 12px 14px; display: flex; gap: 10px; align-items: center; }
.title-card .emoji { font-size: 28px; }
.title-card .name { font-weight: 900; font-size: 14px; }
.title-card .who { font-size: 13px; color: var(--muted); font-weight: 700; }

.level .row { display: flex; justify-content: space-between; align-items: baseline; }
.level .lv { font-size: 13px; font-weight: 900; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.level .name { font-size: 22px; font-weight: 900; }
.level .xpbar { height: 10px; border-radius: 99px; background: var(--card-2); overflow: hidden; margin: 10px 0 6px; }
.level .xpbar span { display: block; height: 100%; background: linear-gradient(90deg, var(--butter), var(--primary)); }

.badges { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.badge { text-align: center; padding: 10px 4px; }
.badge .emoji { font-size: 28px; display: block; }
.badge .n { font-size: 12px; font-weight: 900; color: var(--muted); }
.badge.locked .emoji { filter: grayscale(1); opacity: .35; }

.recap .crown { font-size: 34px; }
.forfeits { margin: 8px 0 0; padding-left: 20px; font-weight: 700; }
.forfeits li { margin: 4px 0; }

/* ---------- Sheet (bottom modal) ---------- */

.scrim {
    position: fixed; inset: 0; z-index: 40; background: rgba(20, 10, 20, .45);
    display: flex; align-items: flex-end; justify-content: center;
    animation: fade .15s ease-out;
}
.sheet {
    width: 100%; max-width: 560px; max-height: 88dvh; overflow-y: auto;
    background: var(--bg); border-radius: 26px 26px 0 0;
    padding: 10px 16px calc(18px + env(safe-area-inset-bottom));
    animation: up .2s ease-out;
}
.sheet .grabber { width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { font-size: 22px; margin-bottom: 14px; }
.sheet .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.sheet .grid.two { grid-template-columns: 1fr 1fr; }
.choice {
    border: 0; border-radius: 18px; padding: 18px 8px; background: var(--card);
    box-shadow: var(--shadow); font-weight: 900; font-size: 20px;
    display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.choice .emoji { font-size: 30px; }
.choice small { font-size: 12px; color: var(--muted); font-weight: 700; }
.choice[aria-pressed="true"] { outline: 3px solid var(--primary); }
.sheet .stack { display: grid; gap: 12px; margin-top: 16px; }
.sheet .actions-row { display: flex; gap: 10px; margin-top: 18px; }
.sheet .actions-row .btn { flex: 1; }

label { display: grid; gap: 6px; font-weight: 800; font-size: 14px; }
input, select {
    width: 100%; border: 2px solid var(--line); background: var(--card); border-radius: 14px;
    padding: 12px 14px; font-size: 16px; font-weight: 600; min-height: 48px;
}
input:focus, select:focus { outline: none; border-color: var(--primary); }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg button {
    flex: 1; border: 2px solid var(--line); background: var(--card); border-radius: 14px;
    padding: 10px 8px; font-weight: 800; min-width: 70px;
}
.seg button[aria-pressed="true"] { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 14%, var(--card)); }

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

.toast {
    position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 50;
    transform: translateX(-50%); width: calc(100% - 32px); max-width: 528px;
    display: flex; align-items: center; gap: 12px;
    background: var(--ink); color: var(--bg); border-radius: 18px; padding: 12px 12px 12px 18px;
    font-weight: 800; box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
    animation: up .2s ease-out;
}
.toast .msg { flex: 1; }
.toast .pts { color: var(--butter); }
.toast button { border: 0; background: rgba(255, 255, 255, .16); color: inherit; border-radius: 12px; padding: 8px 14px; font-weight: 900; }
:root[data-theme="night"] .toast button { background: rgba(0, 0, 0, .12); }
.toast.error { background: var(--danger); color: #fff; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.confetti i { position: absolute; top: -20px; font-style: normal; font-size: 24px; animation: drop 1.4s ease-in forwards; }

@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
.toast { animation-name: toast-up; }
@keyframes toast-up { from { transform: translate(-50%, 24px); opacity: 0; } }
@keyframes drop { to { transform: translateY(110vh) rotate(540deg); opacity: .8; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

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

body.login { display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; text-align: center; }
.login-logo { font-size: 64px; }
.login-card h1 { font-size: 36px; }
.login-card form { display: grid; gap: 14px; text-align: left; margin: 24px 0 14px; }
.error { background: color-mix(in srgb, var(--danger) 14%, var(--card)); color: var(--danger); padding: 10px 14px; border-radius: 14px; font-weight: 800; }

/* ---------- History ---------- */
.week-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; text-align: center; }
.week-nav > div { flex: 1; }
.week-nav .btn { width: 48px; padding-left: 0; padding-right: 0; font-size: 22px; }
.week-nav .btn:disabled { opacity: .35; }
.chart-card { margin-bottom: 12px; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.chart { display: block; width: 100%; height: auto; margin: 4px 0; }
.chart line { stroke: var(--line); stroke-width: 2; }
.chart text { font: 800 11px system-ui, sans-serif; text-anchor: middle; fill: var(--muted); }
.chart text.v { fill: var(--ink); }
.chart text.now { fill: var(--primary); }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin: 0 3px 0 6px; vertical-align: -1px; }
.days { display: grid; gap: 10px; }
.day { padding: 0 14px; }
.day-head { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 10px; width: 100%; padding: 14px 0; cursor: pointer; }
.day-head .grow { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.day-head .chev { color: var(--muted); font-size: 18px; }
.day.open .day-head { border-bottom: 2px solid var(--line); }
.day .timeline .t-time { white-space: nowrap; }
.day .tag { font-size: 11px; font-weight: 900; padding: 2px 8px; border-radius: 99px; }
.tag.late { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
