:root {
  --bg: #FBF6EF;
  --bg2: #F4ECE1;
  --card: #FFFFFF;
  --ink: #2A2733;
  --muted: #8A8494;
  --line: #EDE5DA;
  --shadow: 0 1px 2px rgba(60, 40, 20, .05), 0 8px 24px rgba(60, 40, 20, .06);
  --c-bottle: #4F9CF0;
  --c-breast: #EE6F9C;
  --c-sleep: #7B6CF0;
  --c-diaper: #2EBF95;
  --c-weight: #F0A13A;
  --c-pump: #D46BD9;
  --accent: #FF7A59;
  --ok: #2EBF95;
  --warn: #F0A13A;
  --bad: #E5534B;
  --r: 22px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #12111A;
  --bg2: #1A1824;
  --card: #1E1C2A;
  --ink: #ECE8F4;
  --muted: #8C87A0;
  --line: #2C2939;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .25);
  --c-bottle: #6AADF5;
  --c-breast: #F284AB;
  --c-sleep: #9A8EF7;
  --c-diaper: #4FCFA8;
  --c-weight: #F4B45D;
  --c-pump: #DD86E1;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body {
  font-family: 'Rubik', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  font-size: 16px; line-height: 1.4;
  min-height: 100dvh;
  padding-bottom: calc(84px + env(safe-area-inset-bottom));
  transition: background .3s, color .3s;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
[hidden] { display: none !important; }

.wrap { max-width: 560px; margin: 0 auto; padding: 0 16px; }

/* Header */
.top {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  padding: calc(10px + env(safe-area-inset-top)) 0 10px;
}
.top .wrap { display: flex; align-items: center; gap: 12px; }
.baby-avatar {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center; font-size: 26px;
  background: linear-gradient(135deg, #FFD9C7, #FFC1D6);
  flex: none;
}
:root[data-theme="dark"] .baby-avatar { background: linear-gradient(135deg, #4B3A5E, #5E3A4E); }
.baby-name { font-weight: 800; font-size: 21px; letter-spacing: -.3px; }
.baby-age { color: var(--muted); font-size: 13px; }
.top .grow { flex: 1; min-width: 0; }
.sync {
  display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted);
  padding: 6px 10px; border-radius: 99px; background: var(--card); box-shadow: var(--shadow);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.dot.pending { background: var(--warn); }
.dot.offline { background: var(--bad); }
.me-chip {
  width: 38px; height: 38px; border-radius: 50%; color: #fff; font-weight: 700;
  display: grid; place-items: center; font-size: 16px; flex: none;
}

/* Cards */
.card {
  background: var(--card); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 18px; margin: 14px 0;
}
.section-title {
  font-size: 13px; font-weight: 600; color: var(--muted);
  margin: 22px 4px 8px; letter-spacing: .2px;
}

/* Hero */
.hero { position: relative; overflow: hidden; padding: 22px 20px; }
.hero::after {
  content: ''; position: absolute; inset-inline-end: -40px; top: -40px;
  width: 160px; height: 160px; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--c-bottle) 22%, transparent), transparent 70%);
  pointer-events: none;
}
.hero-label { color: var(--muted); font-size: 14px; font-weight: 500; }
.hero-time { font-size: 54px; font-weight: 800; letter-spacing: -2px; line-height: 1.05; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.hero-time small { font-size: 18px; font-weight: 600; letter-spacing: 0; color: var(--muted); margin-inline-start: 6px; }
.hero-detail { font-size: 14px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.hero-detail b { color: var(--ink); font-weight: 600; }
.hint {
  margin-top: 12px; font-size: 13px; padding: 8px 12px; border-radius: 12px;
  background: var(--bg2); display: inline-flex; gap: 6px; align-items: center;
}

/* Active timers */
.timer {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px;
  border-radius: var(--r); margin: 14px 0; color: #fff;
  box-shadow: var(--shadow);
}
.timer.sleep { background: linear-gradient(135deg, #6D5FE8, #9A7CF2); }
.timer.breast { background: linear-gradient(135deg, #E95B8E, #F48FB0); }
.timer .t-ico { font-size: 30px; }
.timer .t-body { flex: 1; min-width: 0; }
.timer .t-title { font-size: 14px; opacity: .9; }
.timer .t-time { font-size: 32px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -1px; }
.timer .t-btn {
  background: rgba(255, 255, 255, .95); color: #2A2733; font-weight: 700;
  padding: 12px 18px; border-radius: 16px; font-size: 16px;
}
.timer .t-x { color: #fff; opacity: .8; font-size: 13px; padding: 6px; }
.pulse { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #fff; margin-inline-end: 6px; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1 } 50% { opacity: .25 } }

/* Quick actions */
.quick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin: 14px 0; }
.qbtn {
  background: var(--card); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 16px; display: flex; align-items: center; gap: 12px; text-align: start;
  min-height: 84px; transition: transform .12s;
}
.qbtn:active { transform: scale(.96); }
.qbtn .q-ico {
  width: 50px; height: 50px; border-radius: 16px; display: grid; place-items: center; font-size: 26px; flex: none;
  background: color-mix(in srgb, var(--c) 16%, transparent);
}
.qbtn .q-label { font-weight: 700; font-size: 17px; }
.qbtn .q-sub { font-size: 12px; color: var(--muted); }
.qmini { display: flex; gap: 10px; margin-top: -2px; }
.qmini button {
  flex: 1; background: var(--card); box-shadow: var(--shadow); border-radius: 16px;
  padding: 10px; font-size: 14px; font-weight: 500; display: flex; gap: 6px; justify-content: center; align-items: center;
}

/* Stats chips */
.chips-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stat { background: var(--bg2); border-radius: 16px; padding: 10px 6px; text-align: center; }
.stat b { display: block; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat span { font-size: 11px; color: var(--muted); }

/* Leader */
.lead-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.lead-row .nm { width: 64px; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-bar { flex: 1; height: 26px; border-radius: 10px; background: var(--bg2); overflow: hidden; }
.lead-bar i { display: block; height: 100%; border-radius: 10px; transition: width .5s; min-width: 4px; }
.lead-row .vl { font-size: 13px; color: var(--muted); min-width: 64px; text-align: end; font-variant-numeric: tabular-nums; }

/* Event list */
.ev-list { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.ev {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; width: 100%; text-align: start;
  border-bottom: 1px solid var(--line);
}
.ev:last-child { border-bottom: 0; }
.ev:active { background: var(--bg2); }
.ev .e-ico {
  width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; font-size: 20px; flex: none;
  background: color-mix(in srgb, var(--c) 16%, transparent);
}
.ev .e-body { flex: 1; min-width: 0; }
.ev .e-title { font-weight: 600; font-size: 15px; }
.ev .e-sub { font-size: 12.5px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.ev .e-time { font-weight: 600; font-variant-numeric: tabular-nums; font-size: 15px; }
.who { display: inline-flex; align-items: center; gap: 4px; }
.who i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.day-head { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 4px 8px; }
.day-head b { font-size: 16px; }
.day-head span { font-size: 12px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; font-size: 14px; }

/* Filter chips */
.filters { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 2px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }
.fchip {
  flex: none; padding: 8px 14px; border-radius: 99px; background: var(--card); box-shadow: var(--shadow);
  font-size: 14px; font-weight: 500;
}
.fchip.on { background: var(--ink); color: var(--bg); }

/* Charts */
.chart-title { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.chart-title b { font-size: 16px; }
.chart-title span { font-size: 12px; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 8px; height: 150px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar-col .bv { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar-col .b { width: 100%; max-width: 34px; border-radius: 10px 10px 6px 6px; min-height: 4px; transition: height .5s; }
.bar-col .bl { font-size: 12px; color: var(--muted); }
.bar-col.today .bl { color: var(--ink); font-weight: 700; }
.fun-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.fun { background: var(--card); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; }
.fun .f-ico { font-size: 24px; }
.fun .f-val { font-size: 22px; font-weight: 800; margin-top: 4px; font-variant-numeric: tabular-nums; }
.fun .f-lbl { font-size: 12px; color: var(--muted); }

/* Bottom nav */
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav .wrap { display: flex; }
.nav button {
  flex: 1; padding: 10px 0 12px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 12px; color: var(--muted); font-weight: 500;
}
.nav button .n-ico { font-size: 22px; filter: grayscale(1); opacity: .6; transition: .2s; }
.nav button.on { color: var(--ink); font-weight: 700; }
.nav button.on .n-ico { filter: none; opacity: 1; transform: translateY(-1px); }

/* Sheet */
.backdrop { position: fixed; inset: 0; background: rgba(20, 15, 30, .45); z-index: 20; animation: fade .2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  max-width: 560px; margin: 0 auto;
  background: var(--card); border-radius: 28px 28px 0 0;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 92dvh; overflow-y: auto;
  animation: up .25s cubic-bezier(.2, .8, .2, 1);
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { margin: 0 0 14px; font-size: 22px; display: flex; align-items: center; gap: 10px; }
@keyframes up { from { transform: translateY(100%) } }
@keyframes fade { from { opacity: 0 } }

.field { margin: 14px 0; }
.field > label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
.inp {
  width: 100%; padding: 13px 14px; border-radius: 14px; border: 1.5px solid var(--line);
  background: var(--bg); font-size: 16px; outline: none;
}
.inp:focus { border-color: var(--accent); }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg button {
  flex: 1; min-width: 70px; padding: 12px 10px; border-radius: 14px; background: var(--bg2);
  font-weight: 600; font-size: 15px; border: 2px solid transparent;
}
.seg button.on { background: color-mix(in srgb, var(--c, var(--accent)) 14%, var(--card)); border-color: var(--c, var(--accent)); }
.amount { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 6px 0 10px; }
.amount .step {
  width: 60px; height: 60px; border-radius: 50%; background: var(--bg2); font-size: 30px; font-weight: 500;
  display: grid; place-items: center;
}
.amount .step:active { transform: scale(.92); }
.amount .val { text-align: center; min-width: 120px; }
.amount .val input {
  width: 130px; text-align: center; font-size: 56px; font-weight: 800; border: 0; background: transparent; outline: none;
  letter-spacing: -2px; font-variant-numeric: tabular-nums; padding: 0;
}
.amount .val small { display: block; color: var(--muted); font-size: 14px; margin-top: -4px; }
.presets { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.presets button { padding: 8px 14px; border-radius: 99px; background: var(--bg2); font-weight: 600; font-size: 14px; }
.btn {
  width: 100%; padding: 16px; border-radius: 18px; font-weight: 700; font-size: 17px;
  background: var(--accent); color: #fff; margin-top: 10px;
}
.btn.c { background: var(--c); }
.btn.ghost { background: var(--bg2); color: var(--ink); }
.btn.danger { background: transparent; color: var(--bad); font-weight: 600; }
.btn:active { transform: scale(.98); }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.big-opts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.big-opts button {
  padding: 18px 8px; border-radius: 20px; background: var(--bg2); display: flex; flex-direction: column;
  align-items: center; gap: 6px; font-weight: 600;
}
.big-opts button span { font-size: 30px; }
.big-opts button:active { transform: scale(.95); }
.who-pick { display: flex; gap: 8px; flex-wrap: wrap; }
.who-pick button {
  display: flex; align-items: center; gap: 8px; padding: 8px 14px 8px 10px; border-radius: 99px;
  background: var(--bg2); font-weight: 600; border: 2px solid transparent;
}
.who-pick button .av { width: 26px; height: 26px; font-size: 12px; }
.who-pick button.on { border-color: var(--ink); background: var(--card); }
.av { border-radius: 50%; color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.or { text-align: center; color: var(--muted); font-size: 13px; margin: 14px 0 0; }
.link { color: var(--accent); font-weight: 600; font-size: 14px; padding: 6px; }

/* Login */
.login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login .box { width: 100%; max-width: 380px; text-align: center; }
.login .logo { font-size: 72px; margin-bottom: 8px; }
.login h1 { margin: 0 0 6px; font-size: 28px; }
.login p { color: var(--muted); margin: 0 0 24px; }
.login .inp { text-align: center; font-size: 22px; letter-spacing: 4px; }
.user-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.user-list button {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 18px;
  background: var(--card); box-shadow: var(--shadow); font-size: 18px; font-weight: 600;
}
.user-list .av { width: 42px; height: 42px; font-size: 18px; }
.err { color: var(--bad); font-size: 14px; min-height: 20px; margin-top: 8px; }

/* Settings */
.set-row { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row .grow { flex: 1; }
.set-row .sub { font-size: 12px; color: var(--muted); }
.colors { display: flex; gap: 8px; flex-wrap: wrap; }
.colors button { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; }
.colors button.on { border-color: var(--ink); }

.toast {
  position: fixed; bottom: calc(96px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 16px; font-weight: 600; z-index: 30;
  box-shadow: var(--shadow); display: flex; gap: 12px; align-items: center; max-width: calc(100% - 32px);
  animation: fade .2s;
}
.toast button { color: var(--accent); font-weight: 700; }

@media (max-width: 360px) {
  .hero-time { font-size: 44px; }
  .chips-row { grid-template-columns: repeat(2, 1fr); }
  .qbtn { padding: 12px; gap: 8px; }
  .qbtn .q-ico { width: 42px; height: 42px; font-size: 22px; }
}
