:root {
  color-scheme: light;
  --bg: #f5f6fa; --card: #fff; --glass: #ffffffe0; --text: #202435; --muted: #596177;
  --line: #e6e8ef; --soft: #f1f2f7; --brand: #5347a9; --brand-bg: #efecff; --on-brand: #fff;
  --rose: #9d453e; --rose-bg: #f9eae8; --sage: #3d6752; --sage-bg: #e9f2ea;
  --danger: #a13536; --danger-bg: #f9e9e8; --shadow: 0 12px 35px #24243a0b;
  font: 16px/1.52 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei UI", sans-serif;
  background: var(--bg); color: var(--text);
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #151620; --card: #20222e; --glass: #20222ee8; --text: #f1f1f7; --muted: #b4bbcf;
  --line: #373a4b; --soft: #2a2e3e; --brand: #bcb3ff; --brand-bg: #34304f; --on-brand: #18152b;
  --rose: #f2b0a7; --rose-bg: #472e30; --sage: #afd7bb; --sage-bg: #293b33;
  --danger: #ffc0ba; --danger-bg: #4a2c2e; --shadow: 0 10px 30px #0002;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 0; }
[hidden] { display: none !important; }
h1,h2,h3,p,ul { margin: 0; }
h1 { font-size: clamp(1.85rem,4.25vw,2.65rem); letter-spacing: -.055em; line-height: 1.16; }
h2 { font-size: 1.12rem; }
h3 { font-size: 1rem; }
p { overflow-wrap: anywhere; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button[disabled] { cursor: default; opacity: .55; }
:focus-visible { outline: 3px solid var(--brand); outline-offset: 3px; }
:where(button,a):active { filter: brightness(.91); }
svg { flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.75; }
.skip { position: fixed; z-index: 8; top: 9px; left: 9px; padding: 12px; background: var(--card); transform: translateY(-150%); }
.skip:focus { transform: none; }
.muted { color: var(--muted); }
.caption { font-size: .84rem; color: var(--muted); }
.tabular { font-variant-numeric: tabular-nums; }
.header { position: sticky; top: 0; z-index: 3; min-height: 69px; border-bottom: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(18px) saturate(145%); }
.top { max-width: 1190px; margin: auto; padding: 10px 24px; min-height: inherit; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand { display: inline-flex; align-items: center; flex: none; gap: 10px; font-weight: 750; letter-spacing: .02em; }
.brand img { width: 35px; height: 35px; border-radius: 11px; }
.nav { display: flex; gap: 5px; padding: 4px; background: var(--soft); border-radius: 20px; }
.nav a { display: flex; align-items: center; justify-content: center; gap: 7px; padding: 0 13px; min-width: 81px; min-height: 42px; border-radius: 15px; font-size: .87rem; color: var(--muted); white-space: nowrap; }
.nav a svg { width: 17px; height: 17px; }
.nav a[aria-current="page"] { background: var(--card); box-shadow: 0 2px 6px #18132915; color: var(--brand); font-weight: 750; }
.top-actions,.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.top-actions { gap: 4px; }
.button { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 13px; padding: 0 13px; font-size: .88rem; font-weight: 670; background: var(--soft); }
.button:hover:not(:disabled) { filter: brightness(.96); }
.button svg { width: 17px; height: 17px; }
.button.primary { background: var(--brand); color: var(--on-brand); }
.button.flat { color: var(--brand); background: transparent; }
.button.clear { background: none; border-color: var(--line); }
.button.icon { width: 44px; padding: 0; }
.button.icon svg { width: 19px; height: 19px; }
.button.danger { color: var(--danger); background: var(--danger-bg); }
.button.tone { background: var(--baby-tint); color: var(--baby-ink); }
.button[aria-pressed="true"] { background: var(--brand-bg); color: var(--brand); }
.actor { max-width: 118px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: .83rem; color: var(--muted); }
main { max-width: 1190px; margin: auto; padding: 32px 24px 64px; }
.page-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: 22px; gap: 15px; flex-wrap: wrap; }
.page-head p { margin-top: 5px; color: var(--muted); font-size: .92rem; }
.segment { display: inline-flex; flex-wrap: wrap; padding: 3px; gap: 3px; background: var(--soft); border: 1px solid var(--line); border-radius: 16px; }
.segment .button { min-height: 44px; background: transparent; padding-inline: 12px; }
.segment .button[aria-pressed="true"] { background: var(--card); color: var(--brand); box-shadow: 0 2px 6px #18132916; }
.babies { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 15px; }
.card { border: 1px solid var(--line); border-radius: 22px; background: var(--card); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.baby-card { --baby-ink: var(--rose); --baby-tint: var(--rose-bg); position: relative; overflow: hidden; }
.baby-card.sage { --baby-ink: var(--sage); --baby-tint: var(--sage-bg); }
.baby-head,.panel-head,.slot,.item-row,.baby-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-width: 0; }
.baby-title { justify-content: start; }
.baby-title img { width: 47px; height: 47px; object-fit: cover; border-radius: 15px; background: var(--baby-tint); }
.baby-title h2 { font-size: 1.35rem; overflow-wrap: anywhere; }
.baby-title .caption { color: var(--baby-ink); }
.status-tag { display: inline-flex; flex: none; align-items: center; gap: 6px; color: var(--baby-ink); background: var(--baby-tint); font-size: .76rem; border-radius: 20px; padding: 5px 9px; }
.status-tag svg { width: 14px; height: 14px; }
.meals { display: grid; grid-template-columns: 1.18fr 1fr 1fr; gap: 10px; margin: 15px 0; }
.metric { min-width: 0; }
.metric + .metric { padding-left: 12px; border-left: 1px solid var(--line); }
.metric strong { display: block; font-size: clamp(1.35rem,4vw,2.12rem); letter-spacing: -.055em; line-height: 1.2; font-variant-numeric: tabular-nums; }
.metric strong small { font-size: .74rem; font-weight: 650; color: var(--muted); letter-spacing: 0; white-space: nowrap; }
.metric span { display: block; color: var(--muted); font-size: .79rem; overflow-wrap: anywhere; }
.slot { border-top: 1px solid var(--line); padding: 6px 0; min-height: 48px; font-size: .85rem; }
.slot svg { width: 17px; height: 17px; }
.slot strong { overflow-wrap: anywhere; }
.slot-info { display: flex; align-items: center; gap: 6px; color: var(--muted); flex: none; }
.next-info { flex: 1; }
.slot .button { flex: none; min-height: 44px; background: transparent; color: var(--baby-ink); }
.care-summary { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 6px; border-top: 1px solid var(--line); padding: 8px 0 3px; font-size: .82rem; }
.care-summary > div { min-width: 0; overflow-wrap: anywhere; }
.care-summary strong { display: block; margin-top: 2px; }
.care-summary svg { width: 15px; height: 15px; }
.other-actions summary { min-height: 44px; display: list-item; padding-top: 10px; padding-bottom: 7px; }
.baby-actions { display: grid; grid-template-columns: 1.28fr .85fr 1fr; gap: 7px; margin-top: 7px; }
.baby-actions .button { padding-inline: 4px; }
.section-grid { display: grid; grid-template-columns: 1.45fr 1fr; gap: 15px; margin-top: 15px; align-items: start; }
.stack { display: grid; gap: 14px; }
.panel-head { min-height: 40px; margin-bottom: 6px; }
.panel-head h2 { display: flex; align-items: center; gap: 8px; }
.panel-head h2 svg { width: 19px; height: 19px; color: var(--brand); }
.list { padding: 0; list-style: none; }
.item-row { min-height: 60px; padding: 6px 0; }
.item-row + .item-row { border-top: 1px solid var(--line); }
.item-row time { width: 44px; flex: none; font-size: .83rem; font-variant-numeric: tabular-nums; font-weight: 750; }
.item-icon { width: 34px; height: 34px; display: grid; place-items: center; flex: none; border-radius: 11px; background: var(--rose-bg); color: var(--rose); }
.item-icon.sage { background: var(--sage-bg); color: var(--sage); }
.item-icon svg { height: 17px; width: 17px; }
.item-main { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: .91rem; }
.item-main .caption { font-size: .78rem; }
.item-main .feed-age { margin-top: 2px; color: var(--brand); font-variant-numeric: tabular-nums; }
.item-row .button.icon { flex: none; }
.empty { padding: 25px 8px; text-align: center; color: var(--muted); font-size: .88rem; }
.status { display: flex; justify-content: space-between; gap: 7px; align-items: start; padding: 12px; border-radius: 13px; background: var(--brand-bg); color: var(--brand); margin: 8px 0; overflow-wrap: anywhere; }
.status.alert { color: var(--danger); background: var(--danger-bg); }
.status p { font-size: .86rem; }
.status .button { flex: none; }
.sheet-stack,.form-stack { display: grid; gap: 13px; }
.narrow { max-width: 760px; }
.choices { display: flex; flex-wrap: wrap; gap: 6px; }
.choice { position: relative; }
.choice input { position: absolute; inset: 0; opacity: 0; width: 100%; margin: 0; }
.choice span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 12px; font-size: .87rem; color: var(--muted); }
.choice input:checked + span { color: var(--brand); background: var(--brand-bg); border-color: var(--brand); }
.choice input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
label,.field-label,legend { font-weight: 650; font-size: .87rem; }
label { display: block; min-width: 0; }
fieldset { padding: 0; margin: 0; border: 0; min-width: 0; }
legend { margin-bottom: 6px; }
input:not([type=checkbox],[type=radio]),select,textarea { display: block; width: 100%; min-height: 45px; min-width: 0; border: 1px solid var(--line); border-radius: 12px; margin-top: 4px; padding: 8px 10px; background: var(--bg); font-size: 1rem; }
input[type=file] { font-size: .82rem; }
textarea { resize: vertical; }
.inline { display: flex; align-items: center; gap: 7px; min-height: 44px; }
.inline input { width: 19px; height: 19px; }
.form-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 9px; }
.filter-bar { display: flex; justify-content: space-between; gap: 10px; align-items: end; flex-wrap: wrap; margin-bottom: 12px; }
.filter-bar label { min-width: 132px; }
.filter-bar .actions { align-items: end; }
.notice { padding: 8px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--soft); color: var(--muted); font-size: .83rem; }
.error { color: var(--danger); font-size: .9rem; }
.chart { display: grid; gap: 8px; margin: 10px 0 2px; }
.chart-row { display: grid; grid-template-columns: 46px 1fr; align-items: center; gap: 8px; font-size: .83rem; }
.bar-line { display: flex; align-items: center; gap: 5px; min-height: 16px; white-space: nowrap; }
.bar { display: inline-block; height: 7px; width: var(--w); border-radius: 6px; background: var(--rose); }
.bar.sage { background: var(--sage); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .84rem; }
td,th { border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; padding: 9px 8px; }
th { color: var(--muted); }
details summary { cursor: pointer; color: var(--brand); padding-block: 8px; width: fit-content; font-size: .88rem; }
.picture { display: block; max-width: 100%; max-height: 255px; border-radius: 13px; object-fit: contain; margin: 6px auto; }
.ai-page { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; align-items: start; }
.catalog-list .item-row { min-height: 48px; }
.report-title { display: flex; justify-content: space-between; align-items: start; flex-wrap: wrap; gap: 7px; }
.settings-grid { display: grid; gap: 14px; grid-template-columns: repeat(2,minmax(0,1fr)); align-items: start; }
.login-stage { min-height: 100dvh; display: grid; place-items: center; padding: 22px; background: radial-gradient(ellipse at 50% 15%,var(--brand-bg),transparent 58%); }
.login-card { max-width: 430px; width: 100%; padding: 26px; }
.login-card .brand { margin-bottom: 10px; }
.login-card h1 { font-size: 2rem; margin-bottom: 6px; }
.login-card .button.primary { width: 100%; }
dialog { color: var(--text); background: var(--card); padding: 20px; border: 1px solid var(--line); border-radius: 24px; width: min(560px,calc(100% - 22px)); max-height: calc(100% - 22px); box-shadow: 0 19px 90px #10102340; }
dialog::backdrop { background: #1515287a; backdrop-filter: blur(5px); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sheet-head h2 { font-size: 1.25rem; overflow-wrap: anywhere; }
.sheet-actions { display: flex; justify-content: end; gap: 8px; flex-wrap: wrap; }
.sheet-actions .primary { margin-left: auto; }
#toast { position: fixed; z-index: 6; bottom: 16px; right: 16px; max-width: min(430px,calc(100% - 32px)); background: var(--text); color: var(--card); border-radius: 13px; min-height: 43px; padding: 9px 12px; display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: .88rem; box-shadow: var(--shadow); }
#toast:empty { display: none; }
#toast button { border: 1px solid currentColor; border-radius: 10px; color: inherit; background: none; font-size: inherit; min-height: 44px; padding: 0 8px; }
@media (max-width: 780px) {
  .header { min-height: 59px; }
  .top { padding-inline: 15px; }
  .nav { position: fixed; z-index: 4; bottom: calc(8px + env(safe-area-inset-bottom)); left: max(10px,calc((100vw - 540px)/2)); right: max(10px,calc((100vw - 540px)/2)); display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); background: var(--glass); backdrop-filter: blur(20px) saturate(150%); border: 1px solid var(--line); box-shadow: var(--shadow); }
  .nav a { min-width: 0; padding: 5px 1px; gap: 3px; display: grid; justify-items: center; font-size: .74rem; min-height: 48px; }
  .header { position: relative; backdrop-filter: none; }
  main { padding: 22px 14px calc(86px + env(safe-area-inset-bottom)); }
  .meals { gap: 5px; }
  .metric + .metric { padding-left: 8px; }
  #toast { bottom: calc(73px + env(safe-area-inset-bottom)); }
}
@media (max-width: 620px) {
  .babies,.section-grid,.ai-page,.settings-grid { grid-template-columns: 1fr; gap: 10px; }
  .card { padding: 13px; border-radius: 19px; }
  .login-card { padding: 20px; }
  .page-head { margin-bottom: 12px; }
  .section-grid { margin-top: 10px; }
  .item-row { gap: 6px; }
  dialog { width: 100%; margin: auto 0 0; border-radius: 23px 23px 0 0; padding: 15px 14px calc(15px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-transparency: reduce) { .header,.nav { background: var(--card); backdrop-filter: none; } }
@media print {
  :root { color-scheme: light; --bg: white; --card: white; --text: black; --muted: #333; --line: #ccc; }
  .header,.page-head,.no-print,#toast,.skip { display: none !important; }
  main { max-width: none; padding: 0; }
  .card { border: 0; padding: 0; box-shadow: none; }
  .report-title h2 { font-size: 1.4rem; }
}
