:root {
  --bg: #fdf3f5;
  --bg-accent: #fff0f3;
  --card: #ffffff;
  --ink: #3a2b31;
  --muted: #9a8790;
  --primary: #e88aa3;
  --primary-dark: #d96f8e;
  --accent: #7cc6a6;
  --accent-dark: #5fb390;
  --feeding: #f4a7bb;
  --poop: #c39a6b;
  --pee: #7fb6e0;
  --border: #f2dbe2;
  --shadow: 0 6px 20px rgba(160, 100, 120, 0.08);
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

.hidden { display: none !important; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: linear-gradient(135deg, #ffd7e0, #ffe9ee);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.app-header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.icon-btn {
  background: rgba(255,255,255,0.6);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: #fff; }

.container {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

/* Notification banner */
.notif-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff6e6;
  border: 1px solid #f5d9a8;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 0.9rem;
}
.notif-banner span { flex: 1; }

/* Next feeding */
.next-feed-card { text-align: center; }
.next-feed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.label {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
}
.link-btn {
  background: none;
  border: none;
  color: var(--primary-dark);
  font-size: 0.8rem;
  cursor: pointer;
  text-decoration: underline;
}
.countdown {
  font-size: 2.8rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin: 6px 0 2px;
  color: var(--ink);
}
.countdown.overdue { color: #d95a6b; }
.next-feed-sub { color: var(--muted); font-size: 0.9rem; }
.progress-track {
  height: 8px;
  background: var(--bg-accent);
  border-radius: 999px;
  margin-top: 14px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 999px;
  transition: width 0.5s linear;
}

/* Quick add */
.quick-add {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}
.quick-btn.feeding, .quick-btn.bottle, .quick-btn.syringe { grid-column: span 2; }
.quick-btn.poop, .quick-btn.pee { grid-column: span 3; }
.quick-btn {
  border: none;
  border-radius: 16px;
  padding: 16px 8px;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow);
  transition: transform 0.06s ease, filter 0.1s ease;
}
.quick-btn:active { transform: scale(0.96); }
.quick-btn:hover { filter: brightness(1.04); }
.quick-btn .emoji { font-size: 1.6rem; }
.quick-btn.feeding { background: var(--feeding); }
.quick-btn.bottle { background: #d99333; }
.quick-btn.syringe { background: #9b8ce0; }
.quick-btn.poop { background: var(--poop); }
.quick-btn.pee { background: var(--pee); }

/* Entry form */
.entry-form h2 { margin: 0 0 14px; font-size: 1.1rem; }
.field-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.field-row label {
  width: 100%;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}
.field-row input[type="text"],
.field-row input[type="number"],
.field-row input[type="datetime-local"],
.field-row select {
  flex: 1;
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 1rem;
  background: #fff;
  color: var(--ink);
}
.field-row input:focus, .field-row select:focus {
  outline: none;
  border-color: var(--primary);
}
.field-row select { width: auto; }
.form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}
.actions-spacer { flex: 1; }

.muted { color: var(--muted); }
.small { font-size: 0.8rem; }

/* Buttons */
.btn {
  border: none;
  border-radius: 12px;
  padding: 11px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-danger { color: #d95a6b; }
.btn-danger:hover { background: #fde3ea; }
.btn-sm { padding: 8px 12px; font-size: 0.82rem; }

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.stat {
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 14px 8px;
  text-align: center;
}
.stat-num { display: block; font-size: 1.6rem; font-weight: 800; }
.stat-label { display: block; color: var(--muted); font-size: 0.75rem; }

/* Stats panel */
.stats-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.stats-card h2 { margin: 0; font-size: 1.05rem; }
.stats-range {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 600;
}
.stats-custom {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
  font-size: 0.82rem;
  color: var(--muted);
}
.stats-custom input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  color: var(--ink);
  background: #fff;
}
.stats-yesterday {
  background: var(--bg-accent);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 14px;
}
.stats-yesterday .label { display: block; margin-bottom: 8px; }
.stats-summary { display: flex; flex-direction: column; gap: 7px; }
.stats-range-label { margin-bottom: 8px; }
.stats-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.92rem;
}
.stats-line .k { color: var(--muted); }
.stats-line .v { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.stats-days {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--bg-accent);
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.stats-day { font-size: 0.85rem; line-height: 1.35; }
.stats-day .d { font-weight: 700; }
.stats-day .m { color: var(--muted); }
.stats-note { color: var(--muted); font-size: 0.78rem; margin: 8px 0 0; }

/* Timeline */
.timeline-card h2 { margin: 0 0 12px; font-size: 1.05rem; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--bg-accent);
}
.timeline li:last-child { border-bottom: none; }
.tl-emoji {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.tl-emoji.feeding { background: #fde3ea; }
.tl-emoji.poop { background: #f3e7d6; }
.tl-emoji.pee { background: #e0effa; }
.tl-main { flex: 1; min-width: 0; }
.tl-title { font-weight: 600; font-size: 0.95rem; }
.tl-note { color: var(--muted); font-size: 0.82rem; }
.tl-time { color: var(--muted); font-size: 0.78rem; white-space: nowrap; }
.tl-delete {
  background: none;
  border: none;
  color: #d0c2c8;
  cursor: pointer;
  font-size: 1rem;
  padding: 6px;
}
.tl-delete:hover { color: #d95a6b; }
.tl-edit {
  background: none;
  border: none;
  color: #d0c2c8;
  cursor: pointer;
  font-size: 0.95rem;
  padding: 6px;
}
.tl-edit:hover { color: var(--ink); }
.empty-state { color: var(--muted); text-align: center; padding: 20px 0; }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(60, 30, 40, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-box { width: 100%; max-width: 420px; }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-head h2 { margin: 0; font-size: 1.1rem; }

/* Edit feeding: side-by-side nursing minutes */
.edit-sides { display: flex; gap: 12px; flex: 1; }
.edit-sides label {
  width: auto;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--muted);
}
.edit-sides input { width: 100%; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #3a2b31;
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  z-index: 100;
}

@media (min-width: 600px) {
  .container, .header-inner { max-width: 600px; }
}

/* Nursing timer */
.nursing-card h2 { margin: 0; font-size: 1.1rem; }
.nursing-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.nurse-timers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.nurse-side {
  text-align: center;
  background: var(--bg-accent);
  border-radius: 14px;
  padding: 14px 8px;
}
.nurse-side-label {
  display: block;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.72rem;
  color: var(--muted);
}
.nurse-elapsed {
  display: block;
  font-size: 2rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin: 8px 0 12px;
  color: var(--ink);
}
.nurse-elapsed.running {
  color: var(--primary-dark);
  animation: nursePulse 1.2s ease-in-out infinite;
}
@keyframes nursePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
.nurse-btn { width: 100%; }
.btn-start { background: var(--feeding); color: #fff; }
.btn-start:hover { filter: brightness(1.05); }
.btn-stop { background: var(--muted); color: #fff; }
.nursing-card .field-row { margin-bottom: 6px; }

/* Looping video player */
.video-modal { background: #000; z-index: 50; }
.video-modal video { width: 100%; height: 100%; object-fit: contain; }
.video-close { position: absolute; top: 12px; right: 12px; z-index: 51; }
.header-inner { gap: 8px; }
.header-inner h1 { flex: 1; }
.video-picker { position: absolute; top: 12px; left: 12px; right: 64px; z-index: 51; display: flex; gap: 8px; flex-wrap: wrap; }
.video-picker button { background: rgba(0,0,0,.6); color: #fff; border: 1px solid #888; border-radius: 16px; padding: 6px 14px; font-size: 14px; }
.video-picker button.active { background: #fff; color: #000; }
