:root {
  --bg: #14110f;
  --bg-2: #1e1a17;
  --card: #26211d;
  --card-2: #2f2925;
  --line: #3a332e;
  --txt: #f4ede6;
  --txt-dim: #b7aca2;
  --txt-faint: #8a7f75;
  --accent: #e8a87c;      /* warm peach */
  --accent-2: #f4c9a3;
  --feed: #7fb2a8;        /* soft teal */
  --sleep: #8f9ad6;       /* soft indigo */
  --diaper: #d69a8f;      /* soft clay */
  --more: #b8a98f;        /* warm taupe */
  --good: #8fca9a;
  --warn: #e6b566;
  --danger: #e08a8a;
  --radius: 20px;
  --tap: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--txt);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.4;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}

#app { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
#screen {
  flex: 1;
  padding: calc(var(--safe-t) + 12px) 16px 96px;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

/* Headings */
h1 { font-size: 28px; font-weight: 700; margin: 8px 0 2px; letter-spacing: -0.02em; }
h2 { font-size: 20px; font-weight: 650; margin: 22px 0 10px; letter-spacing: -0.01em; }
.sub { color: var(--txt-dim); font-size: 15px; margin: 0 0 12px; }

/* Home hero buttons */
.big-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.big-btn {
  min-height: 120px;
  border: none;
  border-radius: var(--radius);
  color: #14110f;
  font-size: 22px;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px;
  cursor: pointer;
  text-align: left;
  transition: transform .08s ease, filter .08s ease;
}
.big-btn:active { transform: scale(0.97); filter: brightness(1.05); }
.big-btn .ico { font-size: 30px; }
.big-btn .hint { font-size: 13px; font-weight: 500; opacity: .8; }
.big-btn.feed { background: linear-gradient(155deg, var(--feed), #9ac6bd); }
.big-btn.sleep { background: linear-gradient(155deg, var(--sleep), #aab3e0); }
.big-btn.diaper { background: linear-gradient(155deg, var(--diaper), #e4b1a6); }
.big-btn.more { background: linear-gradient(155deg, var(--more), #cdc0a8); }

/* Status strip */
.status-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-top: 18px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 12px; text-align: center;
}
.stat .n { font-size: 22px; font-weight: 700; }
.stat .l { font-size: 12px; color: var(--txt-faint); text-transform: uppercase; letter-spacing: .04em; }
.stat .since { font-size: 13px; color: var(--accent); font-weight: 600; }

/* Cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }

/* Sleep timer banner */
.timer-banner {
  background: linear-gradient(155deg, #2b3363, #384088);
  border: 1px solid #4a54a8; border-radius: var(--radius);
  padding: 16px; margin-top: 16px; display: flex; align-items: center; justify-content: space-between;
}
.timer-banner .t { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer-banner .lbl { font-size: 13px; color: var(--txt-dim); }

/* Buttons */
button { font-family: inherit; }
.btn {
  min-height: var(--tap); border-radius: 14px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--txt); font-size: 17px; font-weight: 600;
  padding: 0 18px; cursor: pointer; width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s ease, filter .08s;
}
.btn:active { transform: scale(0.98); }
.btn.primary { background: var(--accent); color: #14110f; border-color: transparent; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn.sm { min-height: 44px; font-size: 15px; padding: 0 12px; width: auto; }

/* Chip / option selectors */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 4px; }
.chip {
  min-height: 48px; padding: 0 16px; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--card-2); color: var(--txt); font-size: 16px; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center;
}
.chip[aria-pressed="true"] { background: var(--accent); color: #14110f; border-color: var(--accent); }

/* Stepper (oz, etc.) */
.stepper { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.stepper button {
  width: var(--tap); height: var(--tap); border-radius: 14px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--txt); font-size: 28px; font-weight: 700; cursor: pointer;
}
.stepper .val { flex: 1; text-align: center; font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stepper .unit { font-size: 15px; color: var(--txt-dim); }

label.field { display: block; margin: 12px 0 4px; font-size: 14px; color: var(--txt-dim); font-weight: 600; }
input, select, textarea {
  width: 100%; min-height: var(--tap); background: var(--bg-2); color: var(--txt);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 17px; font-family: inherit;
}
textarea { min-height: 80px; resize: vertical; }
input[type="datetime-local"], input[type="date"] { min-height: var(--tap); }

/* Sheet / modal */
#sheet-host { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; }
#sheet-host[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.sheet {
  position: relative; z-index: 1; width: 100%; max-width: 640px; margin: 0 auto;
  background: var(--bg-2); border-top-left-radius: 24px; border-top-right-radius: 24px;
  border: 1px solid var(--line); border-bottom: none;
  padding: 10px 18px calc(24px + var(--safe-b)); max-height: 92vh; overflow-y: auto;
  animation: slideup .22s ease;
}
@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-grab { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 6px auto 10px; }
.sheet h2 { margin-top: 6px; }

/* inline spinner (sync key derivation) */
.spinner {
  display: inline-block; width: 14px; height: 14px; vertical-align: -2px;
  border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Timeline / list rows */
.day-head { display: flex; justify-content: space-between; align-items: baseline; margin: 18px 0 8px; }
.day-head .d { font-size: 16px; font-weight: 700; }
.day-head .c { font-size: 13px; color: var(--txt-faint); }
.entry {
  display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line);
}
.entry:last-child { border-bottom: none; }
.entry .dot { width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 19px; flex: 0 0 auto; }
.entry .dot.feed { background: rgba(127,178,168,.22); }
.entry .dot.sleep { background: rgba(143,154,214,.22); }
.entry .dot.diaper { background: rgba(214,154,143,.22); }
.entry .dot.growth { background: rgba(232,168,124,.22); }
.entry .dot.health { background: rgba(224,138,138,.22); }
.entry .body { flex: 1; min-width: 0; }
.entry .title { font-size: 16px; font-weight: 600; }
.entry .meta { font-size: 13px; color: var(--txt-faint); }
.entry .time { font-size: 14px; color: var(--txt-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
.entry .x { color: var(--txt-faint); background: none; border: none; font-size: 20px; padding: 6px; cursor: pointer; }

.empty { text-align: center; color: var(--txt-faint); padding: 40px 20px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* Growth chart */
.growth-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.growth-tabs .chip { min-height: 42px; font-size: 14px; }
svg.chart { width: 100%; height: auto; display: block; background: var(--bg-2); border-radius: 14px; }
.pctile-badge { font-size: 15px; color: var(--txt-dim); margin-top: 8px; }
.pctile-badge b { color: var(--accent); font-size: 18px; }

/* Guidance */
.guide-stage { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; -webkit-overflow-scrolling: touch; }
.guide-entry { border-left: 3px solid var(--accent); padding-left: 12px; margin: 14px 0; }
.guide-entry h3 { margin: 0 0 4px; font-size: 17px; }
.guide-entry .src { font-size: 13px; }
.guide-entry .src a { color: var(--accent); }
.redflag { border-left-color: var(--danger); }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: calc(84px + var(--safe-b)); transform: translateX(-50%);
  background: var(--card-2); color: var(--txt); border: 1px solid var(--line);
  padding: 12px 20px; border-radius: 999px; font-size: 15px; font-weight: 600;
  z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.4); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }

/* Tab bar */
#tabbar {
  position: sticky; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(20,17,15,.92); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b); z-index: 40;
}
.tab {
  min-height: 60px; background: none; border: none; color: var(--txt-faint);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11px; cursor: pointer; padding: 6px 0;
}
.tab .tab-ico { font-size: 21px; filter: grayscale(.4) opacity(.75); }
.tab[aria-current="true"] { color: var(--accent); }
.tab[aria-current="true"] .tab-ico { filter: none; }

.muted { color: var(--txt-faint); font-size: 13px; }
.row-split { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
hr.soft { border: none; border-top: 1px solid var(--line); margin: 16px 0; }

/* Print — pediatrician daily summary */
@media print {
  #tabbar, #sheet-host, #toast { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  #screen { padding: 0; max-width: 100%; }
  .card { border: 1px solid #999; break-inside: avoid; }
  .print-only { display: block !important; }
  .no-print { display: none !important; }
  h1, h2 { color: #000; }
}
.print-only { display: none; }
