:root {
  --paper: #FDF9F4; --card: #FFFFFF; --ink: #26446B; --ink-2: #4A6283; --muted: #6E7E93; --line: #ECE5DA;
  --primary: #26446B; --on-primary: #FFFFFF; --danger: #B5432F;
  --feed: #FFD24D; --feed-soft: #FFF3C7;
  --sleep: #A9CFEE; --sleep-soft: #E6F1FB;
  --diaper: #B8DDA2; --diaper-soft: #EAF5E2;
  --health: #CFCFF5; --health-soft: #EEEEFC;
  --growth: #F6C3A0; --growth-soft: #FDEBDF;
  --track: #EFE8DC;
  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Figtree", -apple-system, "Segoe UI", system-ui, sans-serif;
  --radius: 20px;
  color-scheme: light;
}
:root[data-theme="night"] {
  --paper: #0F1522; --card: #161F31; --ink: #F1DDB8; --ink-2: #D9C6A2; --muted: #9C8F78; --line: #253047;
  --primary: #E2A64B; --on-primary: #1A1408; --danger: #E2836E;
  --feed: #E2A64B; --feed-soft: #2A2618;
  --sleep: #6F9CCB; --sleep-soft: #1B2840;
  --diaper: #7FAF6A; --diaper-soft: #1C2A22;
  --health: #9C9CE0; --health-soft: #22233D;
  --growth: #D99A72; --growth-soft: #2E2320;
  --track: #253047;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.45; }
body { min-height: 100dvh; overscroll-behavior-y: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 2px solid var(--feed); outline-offset: 2px; border-radius: 6px; }
input, select { font: inherit; color: var(--ink); background: transparent; }
/* Nada de zoom al tocar: iOS agranda si un campo tiene letra de menos de 16px o con doble toque. */
html { touch-action: manipulation; -webkit-text-size-adjust: 100%; }
input, select, textarea { font-size: max(16px, 1em); }
.num { font-variant-numeric: tabular-nums; }

.app { max-width: 560px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 14px) 16px calc(env(safe-area-inset-bottom) + 92px); }
.content { display: flex; flex-direction: column; gap: 14px; }
.loading { height: 100dvh; }
.offline { background: var(--danger); color: #fff; font-size: 13px; padding: 6px 12px; border-radius: 10px; margin-bottom: 10px; text-align: center; }

/* encabezado */
.top { margin-bottom: 16px; }
.kid { display: flex; align-items: center; gap: 12px; text-align: left; }
.kid-text { display: flex; flex-direction: column; }
.kid-name { font-family: var(--serif); font-size: 32px; line-height: 1.05; display: flex; align-items: center; gap: 4px; }
.caret { color: var(--muted); display: inline-flex; }
.kid-sub { font-size: 13px; color: var(--muted); }
.page-title { font-family: var(--serif); font-weight: 400; font-size: 32px; margin: 6px 0 0; }
.avatar { border-radius: 50%; background: var(--feed); overflow: hidden; display: inline-grid; place-items: center; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar .initial { font-family: var(--serif); color: var(--primary); }
.avatar.person { background: var(--health-soft); }
.avatar.person .initial { font-size: 20px; color: var(--ink); }

/* el círculo de la última toma */
.hero { background: var(--card); border-radius: var(--radius); padding: 22px 18px 16px; display: flex; flex-direction: column; align-items: center; gap: 10px; box-shadow: 0 1px 0 var(--line); }
.ring { position: relative; width: 210px; height: 210px; max-width: 100%; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 12; }
.ring .track { stroke: var(--track); }
.ring .fill { stroke: var(--feed); stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
.ring-mid { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; gap: 2px; padding: 0 24px; }
.ring-mid .big { font-family: var(--serif); font-size: 46px; line-height: 1; }
.ring-mid .big small { font-size: 18px; margin-left: 1px; color: var(--ink-2); }
.ring-mid .sub { font-size: 13px; color: var(--muted); }
.ring-mid .sub.strong { color: var(--ink-2); font-weight: 500; }

.primary { background: var(--primary); color: var(--on-primary); border-radius: 18px; padding: 16px 18px; font-size: 17px; font-weight: 600; width: 100%; }
.primary.small { width: auto; padding: 10px 16px; font-size: 15px; border-radius: 14px; }
.secondary { border: 1.5px solid var(--ink); border-radius: 14px; padding: 10px 16px; font-weight: 600; font-size: 15px; }
.link { font-size: 14px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; color: var(--ink-2); padding: 6px; }
.danger { color: var(--danger); font-weight: 600; padding: 10px 0; }
.danger.armed { background: var(--danger); color: #fff; border-radius: 12px; padding: 10px 14px; width: 100%; }

/* tarjetas de cada cosa */
.card, .banner { background: var(--card); border-radius: var(--radius); padding: 12px 12px 12px 14px; display: flex; align-items: center; gap: 10px; box-shadow: 0 1px 0 var(--line); flex-wrap: wrap; }
.card-main { flex: 1 1 200px; display: flex; align-items: center; gap: 12px; text-align: left; min-width: 0; }
.badge { width: 42px; height: 42px; border-radius: 14px; display: grid; place-items: center; flex: none; color: var(--ink); }
.badge.sm { width: 30px; height: 30px; border-radius: 10px; }
.c-feed .badge, .c-feed .dot { background: var(--feed-soft); }
.c-sleep .badge, .c-sleep .dot { background: var(--sleep-soft); }
.c-diaper .badge, .c-diaper .dot { background: var(--diaper-soft); }
.c-health .badge, .c-health .dot { background: var(--health-soft); }
.c-growth .badge, .c-growth .dot { background: var(--growth-soft); }
.card-text { display: flex; flex-direction: column; min-width: 0; }
.card-title { font-family: var(--serif); font-size: 21px; line-height: 1.15; }
.card-sub { font-size: 13px; color: var(--muted); }
.count { font-family: var(--serif); font-size: 22px; margin-left: auto; padding-right: 4px; }
.card-actions { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.chip { border: 1.5px solid var(--line); border-radius: 999px; padding: 7px 12px; font-size: 14px; font-weight: 600; white-space: nowrap; }
.chip.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.add { width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: var(--on-primary); display: grid; place-items: center; flex: none; }
.banner { background: var(--sleep-soft); }
.banner > div { flex: 1; min-width: 0; }
.banner-title { font-family: var(--serif); font-size: 20px; }

/* listas de anotaciones */
.section-title { font-family: var(--serif); font-weight: 400; font-size: 22px; margin: 8px 0 6px; }
.list-block { margin-top: 6px; }
.rows { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 0 var(--line); }
.rows li + li { border-top: 1px solid var(--line); }
.row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 14px; text-align: left; }
.dot { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.row-time { font-size: 14px; color: var(--muted); min-width: 52px; }
.row-text { flex: 1; font-size: 15px; min-width: 0; }
.row-note { color: var(--muted); }
.who { width: 24px; height: 24px; border-radius: 50%; background: var(--line); font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; color: var(--ink-2); }
.empty { color: var(--muted); font-size: 14px; margin: 4px 2px; }
.help { color: var(--muted); font-size: 13px; margin: 4px 0; }
.center { text-align: center; }
.pad { padding: 8px 0; }

/* historial */
.daynav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.daynav h2 { font-family: var(--serif); font-weight: 400; font-size: 24px; margin: 0; text-align: center; flex: 1; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--ink); }
.strip { position: relative; height: 54px; background: var(--card); border-radius: 14px; margin: 4px 0 6px; box-shadow: 0 1px 0 var(--line); overflow: hidden; }
.strip .tick { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line); }
.strip .tick i { position: absolute; bottom: 3px; left: 3px; font-size: 10px; font-style: normal; color: var(--muted); }
.strip .tick:last-of-type i { left: auto; right: 3px; }
.strip .bar { position: absolute; top: 10px; height: 16px; border-radius: 6px; background: var(--sleep); }
.strip .mark { position: absolute; top: 8px; width: 4px; height: 20px; border-radius: 2px; transform: translateX(-2px); }
.strip .mark.c-feed { background: var(--feed); }
.strip .mark.c-diaper { background: var(--diaper); top: 26px; height: 10px; }
.strip .mark.c-health { background: var(--health); }
.strip .mark.c-growth { background: var(--growth); }
.strip .nowline { position: absolute; top: 0; bottom: 0; border-left: 2px solid var(--danger); }

/* resumen */
.panel { background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: 0 1px 0 var(--line); }
.panel h3 { font-family: var(--serif); font-weight: 400; font-size: 22px; margin: 0 0 4px; display: flex; align-items: center; gap: 10px; }
.stat { margin: 4px 0 10px; color: var(--ink-2); font-weight: 500; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; }
.bar-col { flex: 1; display: grid; grid-template-rows: auto 1fr auto; justify-items: center; height: 100%; gap: 4px; min-width: 0; }
.bar-area { width: 100%; display: flex; align-items: flex-end; justify-content: center; min-height: 0; }
.bar-fill { width: 100%; max-width: 30px; border-radius: 6px 6px 3px 3px; min-height: 2px; }
.c-feed .bar-fill { background: var(--feed); } .c-sleep .bar-fill { background: var(--sleep); } .c-diaper .bar-fill { background: var(--diaper); }
.bar-val { font-size: 11px; color: var(--muted); }
.bar-lbl { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: clip; max-width: 100%; }
.plain { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; font-size: 14px; }
.plain .num { color: var(--muted); margin-right: 6px; }

/* familia */
.group { display: flex; flex-direction: column; gap: 4px; }
.list { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 0 var(--line); }
.list li + li { border-top: 1px solid var(--line); }
.list button, .list-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 14px; text-align: left; }
.list-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.list-text b { font-family: var(--serif); font-weight: 400; font-size: 19px; }
.list-text small { color: var(--muted); font-size: 13px; }
.list-add { color: var(--ink-2); font-weight: 600; }
.mods { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.mods li { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 10px 12px; }
.mod-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.mod-text small { color: var(--muted); font-size: 12px; }
.mods .icon-btn { width: 32px; height: 32px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.photo-pick { display: inline-flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; }
.linkbox input { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px; font-size: 16px; margin: 6px 0 10px; }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; }

/* campos */
.field { border-top: 1px solid var(--line); padding: 10px 0; }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.label { font-family: var(--serif); font-size: 19px; }
.control { display: flex; justify-content: flex-end; flex: 1 1 160px; min-width: 0; }
.control input[type=text], .control input[type=date], .control input[type=datetime-local], .control select { border: 1px solid var(--line); border-radius: 12px; padding: 9px 10px; font-size: 16px; width: 100%; max-width: 260px; background: var(--card); }
.control input.short { max-width: 110px; text-align: right; }
.inline { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.unit { color: var(--muted); font-size: 14px; }
.seg { display: flex; border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; width: 100%; }
.seg button { flex: 1; padding: 9px 10px; font-size: 15px; font-weight: 600; }
.seg button.on { background: var(--ink); color: var(--paper); }
.field .seg { max-width: 320px; }
.units-row { display: flex; gap: 12px; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button { width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--ink); font-size: 22px; line-height: 1; }
.stepper input { width: 70px; text-align: center; font-family: var(--serif); font-size: 28px; border: 0; padding: 0; }
.switch { position: relative; width: 52px; height: 32px; flex: none; display: inline-block; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background .2s; pointer-events: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--feed); outline-offset: 2px; }
.error { color: var(--danger); font-size: 14px; }

/* hojas que suben */
.scrim { position: fixed; inset: 0; background: rgba(10, 14, 22, .45); z-index: 20; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: calc(100dvh - env(safe-area-inset-top) - 30px); background: var(--card); border-radius: 24px 24px 0 0; z-index: 21; display: flex; flex-direction: column; max-width: 560px; margin: 0 auto; }
.sheet-head { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; padding: 10px 12px; border-radius: 24px 24px 0 0; background: var(--line); min-height: 60px; }
.sheet.c-feed .sheet-head { background: var(--feed); } .sheet.c-sleep .sheet-head { background: var(--sleep); }
.sheet.c-diaper .sheet-head { background: var(--diaper); } .sheet.c-health .sheet-head { background: var(--health); }
.sheet.c-growth .sheet-head { background: var(--growth); }
:root[data-theme="night"] .sheet-head { color: #1A1408; }
:root[data-theme="night"] .sheet.c-plain .sheet-head { color: var(--ink); }
.sheet-head h2 { margin: 0; text-align: center; font-family: var(--serif); font-weight: 400; font-size: 26px; }
.sheet-head .icon-btn { color: inherit; }
.sheet-save { font-weight: 700; padding: 8px 10px; }
.sheet-body { overflow-y: auto; padding: 6px 18px calc(env(safe-area-inset-bottom) + 20px); }
@media (prefers-reduced-motion: no-preference) { .sheet { animation: subir .22s ease-out; } @keyframes subir { from { transform: translateY(40px); opacity: .6; } } }

/* barra de abajo */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; background: var(--paper); border-top: 1px solid var(--line); display: flex; justify-content: center; padding: 6px 8px calc(env(safe-area-inset-bottom) + 6px); z-index: 10; }
.tabs button { flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--muted); padding: 4px 0; }
.tabs button.on { color: var(--ink); font-weight: 700; }

.toast { position: fixed; left: 12px; right: 12px; bottom: calc(env(safe-area-inset-bottom) + 76px); max-width: 536px; margin: 0 auto; background: var(--primary); color: var(--on-primary); border-radius: 16px; padding: 13px 16px; display: flex; justify-content: space-between; gap: 12px; align-items: center; z-index: 15; box-shadow: 0 12px 28px -12px rgba(0,0,0,.5); font-size: 15px; }
.toast button { font-weight: 700; text-decoration: underline; color: inherit; }

/* entrar */
.join { max-width: 420px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 60px) 20px 40px; text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: stretch; }
.join .logo { border-radius: 22px; align-self: center; }
.join h1 { font-family: var(--serif); font-weight: 400; font-size: 34px; margin: 6px 0 0; }
.join p { color: var(--ink-2); margin: 0; }
.join .field { text-align: left; }

.list .list-row button.link { width: auto; padding: 6px; flex: none; }
