:root {
  color-scheme: dark;
  --bg: #14110e;
  --bg-2: #1c1814;
  --card: #262019;
  --card-2: #312920;
  --line: rgba(246, 236, 220, 0.1);
  --text: #f6efe6;
  --muted: #b7aa9c;
  --faint: #8d8072;
  --amber: #f0a35a;
  --amber-2: #ffd7a8;
  --ink: #2a1c0e;
  --rose: #e57b6b;
  --sage: #8fbfa0;
  --lilac: #c0b0e4;
  --sky: #9ec0db;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --serif: "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --nav: calc(64px + env(safe-area-inset-bottom));
  --dock: 76px;
}
[data-theme="light"] {
  color-scheme: light;
  --bg: #f4efe8;
  --bg-2: #fffaf4;
  --card: #fffdf9;
  --card-2: #f3ebe1;
  --line: rgba(42, 33, 24, 0.08);
  --text: #2a2118;
  --muted: #6e6258;
  --faint: #8d8074;
  --amber: #d9842d;
  --amber-2: #fff1dc;
  --ink: #2a1c0e;
  --shadow: 0 12px 30px rgba(70, 42, 12, 0.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { touch-action: manipulation; }
body {
  min-height: 100dvh;
  background:
    radial-gradient(1200px 500px at 50% -10%, rgba(240, 163, 90, 0.16), transparent 55%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.4;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }
.booting, .gate, .shell { width: min(480px, 100%); margin: 0 auto; }
.booting { padding: 30vh 24px; text-align: center; color: var(--muted); }
.gate { min-height: 100dvh; padding: calc(28px + env(safe-area-inset-top)) 20px 32px; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.brand h1, .age-num { font-family: var(--serif); font-weight: 560; letter-spacing: -0.03em; margin: 0; }
.brand h1 { font-size: 46px; line-height: 0.95; }
.lede { margin: 0; color: var(--muted); font-size: 17px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg-2);
  border-radius: 14px;
  padding: 14px 14px;
  font-size: 16px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--amber); border-color: transparent; }
.btn, .choice, .qbtn, .nav button, .mic, .send {
  border: 0;
  border-radius: 16px;
  min-height: 52px;
}
.btn { padding: 14px 16px; background: var(--card-2); }
.btn.primary { background: var(--amber); color: var(--ink); font-weight: 700; }
.btn.danger { background: transparent; color: var(--rose); }
.btn.full { width: 100%; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.seg { display: flex; gap: 8px; }
.seg button, .choice { background: var(--card); border: 1px solid var(--line); }
.seg button[aria-pressed="true"], .choice[aria-pressed="true"] { background: var(--amber); color: var(--ink); border-color: transparent; font-weight: 700; }
.linkish { background: none; border: 0; color: var(--amber); padding: 8px 0; min-height: 44px; }
.error { color: var(--rose); margin: 0; }
.shell { min-height: 100dvh; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.top { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; padding: 12px 16px 0; gap: 8px 12px; }
.top-titles { min-width: 0; flex: 1; }
.babies { display: flex; gap: 8px; width: 100%; overflow-x: auto; padding: 4px 0 2px; }
.babies button {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 4px 12px 4px 4px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font-weight: 700;
}
.babies button[aria-selected="true"] { border-color: var(--amber); background: var(--amber-2); color: var(--ink); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px;
}
.scope { display: flex; gap: 8px; margin: 0 0 8px; }
.scope button {
  min-height: 44px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; color: var(--muted); font-weight: 700;
}
.scope button[aria-pressed="true"] { background: var(--amber); color: var(--ink); border-color: transparent; }
.scope-note { margin: 0 0 8px; color: var(--faint); font-size: 13px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.plan-band { padding: 10px 0; border-top: 1px solid var(--line); }
.plan-band .row { align-items: end; }
.plan-band input, #feeding-plan textarea { width: 100%; }
.warn { color: var(--amber); margin: 0; }
#feeding-plan textarea { min-height: 72px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); color: var(--text); padding: 10px 12px; }
.eyebrow { margin: 0; color: var(--amber); font-size: 13px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.top h2 { margin: 0; font-size: 22px; }
.view { flex: 1; padding: 8px 16px calc(var(--nav) + var(--dock) + 12px); }
.view.chat, .view.plain { padding-bottom: calc(var(--nav) + 88px); }
.card, .status, .guide, .statgrid div, .bubble, .confirm, .ios-hint {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 22px;
}
.age { padding: 8px 0 12px; }
.age-num { font-size: 40px; line-height: 0.95; }
.age p { margin: 6px 0 0; color: var(--muted); }
.note-chip { display: inline-block; margin-top: 8px; color: var(--faint); font-size: 14px; }
.status { padding: 12px 14px; margin-bottom: 8px; }
.status.soon { background: color-mix(in srgb, var(--amber) 22%, var(--card)); }
.status.due { background: color-mix(in srgb, var(--rose) 24%, var(--card)); }
.status .k { color: var(--muted); font-size: 13px; margin: 0 0 4px; }
.status strong { display: block; font-size: 24px; line-height: 1.1; }
.status .sub { margin: 6px 0 0; color: var(--muted); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0; }
.statgrid div { padding: 8px 10px; }
.statgrid b { display: block; font-size: 18px; }
.statgrid span { color: var(--muted); font-size: 12px; }
.guide { padding: 12px 14px; }
.guide-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.guide-table td { padding: 8px 4px; border-bottom: 1px solid var(--line); }
.guide-table tr.current td { color: var(--amber); font-weight: 700; }
.disclaimer, .sources { color: var(--muted); font-size: 13px; }
.sources a { color: var(--amber); }
.seg.wrap { flex-wrap: wrap; }
.wizard h1 { font-family: var(--serif); font-size: 34px; line-height: 1.05; margin: 0; }
.guide h3, .section h3 { margin: 0 0 6px; font-size: 16px; }
.guide p, .section p { margin: 0; color: var(--muted); }
.remind { margin-top: 8px !important; }
.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 4px 0 12px; }
.quick button {
  min-height: 64px; min-width: 44px;
  border: 0; border-radius: 16px;
  background: var(--card-2); color: var(--text);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 8px 4px; font-size: 13px; font-weight: 700;
}
.quick button .glyph { color: var(--amber); }
.sheet .quick { margin-top: 0; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.qbtn { background: var(--card-2); text-align: left; padding: 12px; min-height: 64px; font-size: 17px; font-weight: 700; }
.qbtn small { display: block; font-weight: 500; color: var(--muted); font-size: 13px; }
.banner { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px; margin-bottom: 10px; background: var(--amber-2); color: var(--ink); border-radius: 18px; }
.banner button { background: var(--ink); color: var(--amber-2); }
.nav {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(480px, 100%);
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  z-index: 5;
}
.nav button { background: transparent; color: var(--faint); min-height: 48px; border-radius: 12px; }
.nav button[aria-current="page"] { color: var(--text); font-weight: 700; }
.dock {
  position: fixed; left: 50%; transform: translateX(-50%);
  width: min(480px, 100%);
  bottom: var(--nav);
  display: flex; gap: 8px; padding: 8px 12px;
  z-index: 6;
}
.dock input { flex: 1; min-height: 56px; border-radius: 18px; background: var(--card); }
.mic, .send {
  width: 56px; min-width: 56px; height: 56px; min-height: 44px;
  border-radius: 18px;
  background: var(--amber); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
}
.glyph { display: flex; pointer-events: none; }
.mic.hot { background: var(--rose); color: #fff; }
.sheet-back { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  width: min(480px, 100%);
  max-height: min(92dvh, 820px);
  overflow: auto;
  background: var(--bg-2);
  border-radius: 24px 24px 0 0;
  padding: 8px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
}
.grab { width: 42px; height: 5px; border-radius: 99px; background: var(--line); margin: 6px auto 10px; }
.sheet-head, .day-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.sheet h2, .day-head h3 { margin: 0; }
.text-btn { background: none; border: 0; color: var(--amber); min-height: 44px; }
.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.side { padding: 18px 12px; text-align: center; border-radius: 22px; background: var(--card); border: 1px solid var(--line); }
.side.on { border-color: var(--amber); box-shadow: inset 0 0 0 2px var(--amber); }
.side b { display: block; font-variant-numeric: tabular-nums; font-size: 36px; margin-top: 4px; }
.timeline { display: flex; flex-direction: column; gap: 8px; }
.entry {
  width: 100%; text-align: left; background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 12px 14px; min-height: 64px;
}
.entry b { display: block; }
.entry span { color: var(--muted); font-size: 14px; }
.day { margin: 16px 0 8px; color: var(--muted); font-size: 13px; }
.charts { display: flex; flex-direction: column; gap: 12px; }
.chart-card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 14px; }
.chart-card svg { width: 100%; height: auto; display: block; }
.ranges { display: flex; gap: 8px; margin-bottom: 12px; }
.chat-log { display: flex; flex-direction: column; gap: 10px; }
.bubble { padding: 12px 14px; max-width: 92%; }
.bubble.user { align-self: flex-end; background: var(--amber); color: var(--ink); }
.bubble .who { display: block; font-size: 12px; opacity: 0.7; margin-bottom: 4px; }
.confirm { margin-top: 8px; padding: 10px; background: var(--bg); color: var(--text); }
.confirm b { display: block; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chips button { background: var(--card-2); border: 0; border-radius: 999px; padding: 10px 14px; min-height: 44px; }
.composer { display: flex; gap: 8px; margin-top: 12px; }
.ios-hint, #toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  width: min(440px, calc(100% - 24px));
  z-index: 30;
}
.ios-hint { bottom: calc(16px + env(safe-area-inset-bottom)); padding: 16px; }
#toast {
  bottom: calc(var(--nav) + 16px);
  background: var(--text); color: var(--bg); padding: 12px 14px; border-radius: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
#toast.show { opacity: 1; pointer-events: auto; }
#toast { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
#toast button { background: none; border: 0; color: var(--amber); font-weight: 700; min-height: 44px; min-width: 44px; }
.offline { margin: 8px 16px 0; padding: 10px 12px; border-radius: 12px; background: var(--card-2); color: var(--muted); }
.settings section { margin: 0 0 18px; }
.member, .invite { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
