/* Cradle Clock — dark-first, calm night palette. Light mode overrides under [data-theme="light"]. */
:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1f242d;
  --surface-3: #262c37;
  --text: #e7ecf3;
  --muted: #9aa4b2;
  --border: #2a3038;
  --accent: #8aa1ff;        /* periwinkle */
  --accent-text: #0f1115;
  --link: #8aa1ff;
  --good: #6fcf97;          /* on schedule */
  --warn: #f2c14e;          /* in window */
  --bad: #eb6f6f;           /* overdue */
  --danger: #eb6f6f;
  --radius: 14px;
  --radius-lg: 22px;
}
:root[data-theme="light"] {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #eef0f7;
  --surface-3: #e4e7f1;
  --text: #1c2230;
  --muted: #5b6473;
  --border: #d9dce6;
  --accent: #5566e6;
  --accent-text: #ffffff;
  --link: #3f51d6;
  --good: #2f9e63;
  --warn: #c98a14;
  --bad: #cf4b4b;
  --danger: #cf4b4b;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}
.boot { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }

/* Screen-flash when a feeding is due (respects reduced-motion). */
@keyframes cc-flash { 0%,100% { background: var(--bg); } 50% { background: color-mix(in srgb, var(--warn) 28%, var(--bg)); } }
body.cc-flash { animation: cc-flash 0.9s ease-in-out 4; }
@media (prefers-reduced-motion: reduce) { body.cc-flash { animation: none; } }

/* Layout shell */
.app-shell { display: flex; flex-direction: column; min-height: 100vh; }
.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.app-header .baby { display: flex; align-items: center; gap: 8px; min-width: 0; }
.app-header h1 { font-size: 1.05rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.app-header .baby select { max-width: 46vw; }
main { flex: 1; width: 100%; max-width: 640px; margin: 0 auto; padding: 16px 16px 96px; }

/* Bottom tab nav — one-handed */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  background: none; border: 0; color: var(--muted); padding: 10px 4px 12px;
  font-size: 0.72rem; display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 56px;
}
.tabbar button .ico { font-size: 1.25rem; line-height: 1; }
.tabbar button.active { color: var(--accent); }

/* Buttons */
button { font: inherit; cursor: pointer; }
.btn {
  border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); padding: 12px 16px; min-height: 48px; width: 100%;
}
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 700; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); background: transparent; }
.btn.sm { min-height: 40px; padding: 8px 12px; width: auto; font-size: 0.9rem; }
.btn:disabled { opacity: 0.5; cursor: default; }
.icon-btn { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); border-radius: 10px; min-height: 40px; min-width: 40px; padding: 6px 10px; font-size: 1.1rem; line-height: 1; }
.row { display: flex; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* Inputs */
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
textarea { min-height: 64px; resize: vertical; }
label.field { display: block; }
label.field > span { display: block; font-size: 0.82rem; color: var(--muted); margin: 0 0 4px 2px; }

/* Home — hero feeding button + countdown */
.hero { text-align: center; padding: 8px 0 4px; }
.bigbtn {
  width: 220px; height: 220px; max-width: 64vw; max-height: 64vw; aspect-ratio: 1;
  border-radius: 50%; border: 0; margin: 8px auto; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text); box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}
.bigbtn .lbl { font-size: 1.35rem; font-weight: 800; letter-spacing: 0.3px; }
.bigbtn .sub { font-size: 0.85rem; opacity: 0.8; margin-top: 4px; }
.bigbtn.feeding { background: var(--good); }
.bigbtn.sleeping { background: var(--surface-2); color: var(--text); border: 2px solid var(--border); }

.stopwatch { font-variant-numeric: tabular-nums; font-size: 3rem; font-weight: 800; letter-spacing: 1px; }
.stopwatch.paused { color: var(--warn); }

/* Countdown card */
.count {
  margin: 14px 0; padding: 16px; border-radius: var(--radius-lg); border: 1px solid var(--border);
  background: var(--surface); text-align: center;
}
.count .due { font-size: 1.05rem; }
.count .big { font-size: 2.1rem; font-weight: 800; font-variant-numeric: tabular-nums; margin: 2px 0; }
.count.early .big { color: var(--text); }
.count.window .big { color: var(--warn); }
.count.overdue .big { color: var(--bad); }
.count .win { font-size: 0.85rem; color: var(--muted); }

/* Warning banner */
.warnbar {
  position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 15;
  background: color-mix(in srgb, var(--warn) 22%, var(--surface)); border: 1px solid var(--warn);
  border-radius: 12px; padding: 12px; margin: 0 0 12px; display: flex; align-items: center; gap: 10px;
}
.warnbar .msg { flex: 1; font-weight: 600; }

/* Cards / timeline */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.timeline { display: flex; flex-direction: column; gap: 10px; }
.tl-card { display: flex; gap: 12px; align-items: flex-start; }
.tl-card .when { width: 64px; flex: none; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; padding-top: 2px; }
.tl-card .body { flex: 1; min-width: 0; }
.tl-card .head { display: flex; align-items: center; gap: 8px; }
.tl-card .title { font-weight: 700; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.good { background: var(--good); } .dot.bad { background: var(--bad); } .dot.none { background: var(--muted); }
.kind-feeding { border-left: 3px solid var(--accent); }
.kind-sleep { border-left: 3px solid #b08bd8; }
.kind-note { border-left: 3px solid var(--muted); }
.detailline { color: var(--muted); font-size: 0.9rem; margin-top: 2px; }
.cardactions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.tag { display: inline-block; font-size: 0.72rem; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }

/* Side toggle + steppers */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { background: var(--surface-2); border: 0; color: var(--text); padding: 8px 14px; min-height: 40px; }
.seg button.on { background: var(--accent); color: var(--accent-text); font-weight: 700; }
.stepper { display: inline-flex; align-items: center; gap: 8px; }
.stepper button { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 1.2rem; }
.stepper .val { min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; font-weight: 700; }

/* Day header */
.dayhead { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.dayhead .date { font-weight: 700; }

/* Summary card */
.summary { margin-top: 16px; border: 1px dashed var(--border); }
.summary .metrics { color: var(--muted); font-size: 0.9rem; margin-bottom: 8px; }
.summary .final { font-size: 1.02rem; }

/* History */
.hist-day { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.hist-day .d { font-weight: 700; }
.hist-day .s { color: var(--muted); font-size: 0.9rem; }

/* Sheet / modal */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--surface); border: 1px solid var(--border); border-bottom: 0; border-radius: 18px 18px 0 0; width: 100%; max-width: 640px; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.sheet h3 { margin: 0 0 12px; }
@media (min-width: 560px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 18px; border-bottom: 1px solid var(--border); } }

/* Disclaimer */
.disclaimer { font-size: 0.82rem; color: var(--muted); line-height: 1.5; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 78px; background: var(--surface-3); color: var(--text); border: 1px solid var(--border); border-radius: 999px; padding: 8px 16px; z-index: 50; box-shadow: 0 6px 20px rgba(0,0,0,0.3); }
.pending { font-size: 0.78rem; color: var(--warn); }
.app-footer { text-align: center; color: var(--muted); font-size: 0.78rem; padding: 8px 0 2px; }
h2.screen-title { font-size: 1.2rem; margin: 4px 0 14px; }
