:root {
  --bg: #fff8f5;
  --card: #ffffff;
  --ink: #2b2230;
  --muted: #6e6274;
  --line: #f0e2e0;
  --primary: #d9577a;
  --primary-ink: #ffffff;
  --primary-soft: #fde7ec;
  --teal: #1f8a83;
  --teal-soft: #dff3f1;
  --warn: #b54708;
  --warn-soft: #fff1e0;
  --danger: #c0262d;
  --danger-soft: #fdeaea;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(60, 20, 40, .05), 0 6px 18px rgba(60, 20, 40, .06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b161d;
    --card: #262029;
    --ink: #f6eef4;
    --muted: #b8aabd;
    --line: #3a3140;
    --primary: #f07a9a;
    --primary-ink: #2a0d16;
    --primary-soft: #432634;
    --teal: #5fd0c6;
    --teal-soft: #1d3a38;
    --warn: #ffb066;
    --warn-soft: #3d2a17;
    --danger: #ff7a7f;
    --danger-soft: #45201f;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  min-height: 100dvh;
}

a { color: var(--primary); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .45em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.12rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .7em; }
small, .muted { color: var(--muted); }
.small { font-size: .88rem; }
.pre { white-space: pre-line; margin-top: 4px; }
.m0 { margin: 0 !important; }
.mt { margin-top: 16px; }
.mt-s { margin-top: 10px; }
.mb { margin-bottom: 12px; }
.center { text-align: center; }

/* ---------- Layout ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(10px + var(--safe-top)) calc(16px + var(--safe-right)) 10px calc(16px + var(--safe-left));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 1.15rem; letter-spacing: .01em; }
.brand img { border-radius: 8px; }
.help-btn {
  background: var(--danger); color: #fff; text-decoration: none; font-weight: 700;
  padding: 8px 14px; border-radius: 999px; font-size: .92rem;
}

main {
  max-width: 640px; margin: 0 auto;
  padding: 16px calc(16px + var(--safe-right)) calc(96px + var(--safe-bottom)) calc(16px + var(--safe-left));
  outline: none;
}
body.no-tabs main { padding-bottom: calc(24px + var(--safe-bottom)); }
main.enter > * { animation: enter .28s ease both; }
main.enter > *:nth-child(2) { animation-delay: .03s; }
main.enter > *:nth-child(3) { animation-delay: .06s; }
main.enter > *:nth-child(4) { animation-delay: .09s; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--card) 96%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 0 var(--safe-right) var(--safe-bottom) var(--safe-left);
}
.tabbar a {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 10px; min-height: 58px;
  text-decoration: none; color: var(--muted); font-size: .74rem; font-weight: 600;
  transition: color .2s ease;
}
.tabbar a span { font-size: 1.35rem; line-height: 1; transition: transform .2s ease; }
.tabbar a.active { color: var(--primary); }
.tabbar a.active span { transform: translateY(-1px) scale(1.08); }
.tabbar a.active::before {
  content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px;
  background: var(--primary); border-radius: 0 0 3px 3px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 16px; margin-bottom: 14px;
}
.card.soft { background: var(--primary-soft); border-color: transparent; box-shadow: none; }
.card.teal { background: var(--teal-soft); border-color: transparent; box-shadow: none; }
.card.warn { background: var(--warn-soft); border-color: transparent; box-shadow: none; }
.card.danger { background: var(--danger-soft); border-color: transparent; box-shadow: none; }
.card.warn h3 { color: var(--warn); }
.card.danger h3 { color: var(--danger); }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-title h2, .card-title h3 { margin: 0; }

.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.center-row { justify-content: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 8px; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer; font: inherit; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 18px; border-radius: 14px;
  background: var(--primary); color: var(--primary-ink); text-decoration: none;
  transition: transform .12s ease, opacity .2s ease;
}
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn.quiet { background: var(--primary-soft); color: var(--ink); }
.btn.teal { background: var(--teal); color: #fff; }
.btn.danger { background: var(--danger); color: #fff; }
.btn.ghost-danger { background: transparent; color: var(--danger); border: 2px solid var(--danger); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .88rem; border-radius: 10px; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; }

.icon-btn {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  font-size: 1.05rem; min-width: 40px; min-height: 40px; border-radius: 10px; cursor: pointer;
}

/* ---------- Forms ---------- */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--bg); border: 1.5px solid var(--line); border-radius: 12px;
  padding: 10px 12px; min-height: 48px;
}
input[type="date"], input[type="time"] { min-width: 0; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 1px; border-color: transparent; }
.field { margin-bottom: 12px; }
.hint { font-size: .84rem; color: var(--muted); margin-top: 4px; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--line); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 12px; }
.seg label { position: relative; margin: 0; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; min-height: 0; cursor: pointer; }
.seg span { display: block; text-align: center; padding: 10px 6px; border-radius: 9px; font-weight: 600; font-size: .9rem; color: var(--muted); transition: all .18s ease; }
.seg input:checked + span { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 2px solid var(--primary); }

.logform label { font-size: .8rem; }

.back { display: inline-flex; align-items: center; gap: 4px; text-decoration: none; font-weight: 600; margin-bottom: 10px; }

/* ---------- Today ---------- */
.hero {
  text-align: center; padding: 22px 16px; border: 0;
  background: linear-gradient(160deg, var(--primary-soft), color-mix(in srgb, var(--primary-soft) 40%, var(--card)));
}
.hero .week { font-size: 2.3rem; font-weight: 800; color: var(--primary); line-height: 1.05; margin: 2px 0 4px; }
.hero .sub { color: var(--muted); }
.hero-note { margin: 10px 0 0; font-weight: 700; }
.progress { height: 12px; background: color-mix(in srgb, var(--line) 80%, transparent); border-radius: 999px; overflow: hidden; margin: 14px 0 8px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #f3a35c); border-radius: 999px; transition: width .4s ease; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stat { background: var(--card); border-radius: 12px; padding: 9px 4px; text-align: center; }
.card.soft .stat, .card .stats .stat { border: 1px solid var(--line); }
.stat b { display: block; font-size: 1.12rem; }
.stat small { font-size: .76rem; }

.baby { display: flex; gap: 14px; align-items: center; }
.baby .emoji { font-size: 3.2rem; line-height: 1; width: 70px; height: 70px; display: grid; place-items: center; background: var(--primary-soft); border-radius: 50%; flex: none; }
.fruit { font-size: 1.3rem; font-weight: 800; }
.measures { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--muted); font-size: .9rem; font-weight: 600; margin-top: 2px; }
.tip { background: var(--bg); border-radius: 12px; padding: 10px 12px; margin: 12px 0 6px; font-size: .9rem; }

.milestone { border-left: 4px solid var(--line); padding: 4px 0 4px 12px; margin-bottom: 12px; }
.milestone.now { border-left-color: var(--teal); }
.milestone b { display: block; margin: 4px 0 2px; }
.milestone p { font-size: .92rem; }

/* ---------- Kicks / timer ---------- */
.big-tap {
  display: grid; place-items: center; margin: 8px auto 14px;
  width: min(70vw, 250px); aspect-ratio: 1; border-radius: 50%;
  border: 0; cursor: pointer; font: inherit; color: #fff; text-align: center;
  background: radial-gradient(circle at 30% 30%, #f08aa6, var(--primary));
  box-shadow: 0 10px 30px rgba(217, 87, 122, .35);
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
  transition: transform .1s ease;
}
.big-tap.teal { background: radial-gradient(circle at 30% 30%, #4fc2b9, var(--teal)); box-shadow: 0 10px 30px rgba(31, 138, 131, .35); }
.big-tap.on { background: radial-gradient(circle at 30% 30%, #ff8b8b, var(--danger)); box-shadow: 0 10px 30px rgba(192, 38, 45, .35); animation: pulse 1.6s ease-in-out infinite; }
.big-tap .n { font-size: 3.6rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.big-tap .l { font-size: 1rem; font-weight: 700; opacity: .95; }
.big-tap:active { transform: scale(.95); }
@keyframes pulse { 50% { box-shadow: 0 10px 44px rgba(192, 38, 45, .55); } }
.timer { text-align: center; font-variant-numeric: tabular-nums; font-size: 1.6rem; font-weight: 800; }

.dots { display: flex; justify-content: center; gap: 7px; margin: 10px 0 4px; }
.dots i { width: 20px; height: 20px; border-radius: 50%; background: var(--line); transition: background .2s ease, transform .2s ease; }
.dots i.on { background: var(--primary); transform: scale(1.08); }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 8px 4px; border-bottom: 1px solid var(--line); font-size: .92rem; vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .74rem; text-transform: uppercase; letter-spacing: .03em; }

/* ---------- Lists ---------- */
.list { list-style: none; padding: 0; margin: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.tags { gap: 6px; margin-top: 4px; }

.check { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); cursor: pointer; font-weight: 500; margin: 0; font-size: 1rem; }
.check:last-of-type { border-bottom: 0; }
.check input { width: 24px; height: 24px; min-height: 0; accent-color: var(--primary); flex: none; margin: 0; }
.check span { transition: color .2s ease; }
.check.done span { text-decoration: line-through; color: var(--muted); }
.check .icon-btn { margin-left: auto; }

.menu { padding: 4px 16px; }
.menu a {
  display: flex; align-items: center; gap: 14px; padding: 14px 0; text-decoration: none; color: var(--ink);
  border-bottom: 1px solid var(--line); font-weight: 600;
}
.menu a:last-child { border-bottom: 0; }
.menu a span:first-child { font-size: 1.35rem; width: 32px; text-align: center; }
.menu a::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 1.4rem; }

.profile-card { display: flex; align-items: center; gap: 12px; }
.avatar { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--primary); color: var(--primary-ink); font-weight: 800; font-size: 1.3rem; flex: none; }

.tag { display: inline-block; font-size: .76rem; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: var(--primary-soft); color: var(--ink); white-space: nowrap; }
.tag.teal, .tag.ok { background: var(--teal-soft); color: var(--teal); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.danger { background: var(--danger-soft); color: var(--danger); }

.signs { margin: 0; padding-left: 1.1em; }
.signs li { margin-bottom: 6px; }
.sign-list { list-style: none; margin: 0; padding: 0; }
.sign-list li { display: flex; gap: 12px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid var(--line); font-weight: 500; }
.sign-list li:last-child { border-bottom: 0; }
.sign-list span { font-size: 1.2rem; width: 26px; text-align: center; flex: none; }

.call-grid { display: grid; gap: 10px; }
.call-grid .btn { justify-content: space-between; font-size: 1.02rem; }

.disclaimer { font-size: .8rem; color: var(--muted); text-align: center; margin-top: 18px; }

#toast {
  position: fixed; left: 50%; bottom: calc(80px + var(--safe-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: all .25s ease; z-index: 20; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.setup { padding-top: 6px; }
.setup .logo { display: block; margin: 6px auto 12px; border-radius: 22px; }

@media (max-width: 360px) {
  .grid3 { grid-template-columns: 1fr 1fr; }
  .grid3 > :first-child { grid-column: 1 / -1; }
}

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