* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #eff6ff;
  color: #1e293b;
  padding-bottom: env(safe-area-inset-bottom);
}
button { font: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  background: #eff6ff;
  padding: 12px 12px 10px;
  border-bottom: 1px solid #bfdbfe;
}
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
h1 { font-size: 22px; margin: 0; }
.sync-pill { font-size: 12px; padding: 4px 8px; border-radius: 999px; background: #dbeafe; color: #1d4ed8; white-space: nowrap; }
.sync-pill.warn { background: #fef3c7; color: #92400e; }
.sync-pill.hidden { display: none; }

.daynav { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.nav-btn {
  width: 48px; height: 44px; border-radius: 12px; border: 1px solid #93c5fd;
  background: #fff; font-size: 16px; color: #1d4ed8;
}
.nav-btn:disabled { opacity: .35; }
.day-label { font-size: 18px; font-weight: 700; text-align: center; }
.day-label small { display: block; font-size: 12px; font-weight: 400; color: #64748b; }

.totals { display: flex; gap: 8px; margin-top: 10px; }
.total {
  flex: 1; background: #fff; border: 1px solid #bfdbfe; border-radius: 14px;
  padding: 8px 4px; text-align: center;
}
.total-icon { font-size: 18px; }
.total-num { display: block; font-size: 26px; font-weight: 800; line-height: 1.1; }
.total-unit { font-size: 12px; color: #64748b; }
.total-eq { display: block; font-size: 12px; color: #64748b; min-height: 14px; }
.cell-unit { font-size: 12px; font-weight: 600; }
.cell-eq { font-size: 11px; color: #64748b; min-height: 13px; }
.sheet-oz-eq { text-align: center; font-size: 16px; color: #64748b; min-height: 20px; }
.cell-times { font-size: 10px; color: #64748b; min-height: 12px; text-align: center; line-height: 1.3; }

/* Event list + type-in add row (exact times) */
.event-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; max-height: 190px; overflow-y: auto; }
.event-empty { color: #64748b; font-size: 14px; margin: 4px 0; }
.event-row { display: flex; align-items: center; gap: 8px; background: #eff6ff; border-radius: 10px; padding: 8px 10px; font-size: 15px; }
.event-time { font-weight: 700; white-space: nowrap; }
.event-amt { flex: 1; min-width: 0; }
.event-by { color: #64748b; font-size: 13px; white-space: nowrap; }
.event-del { border: none; background: #fff; color: #dc2626; border-radius: 999px; width: 32px; height: 32px; font-size: 20px; line-height: 1; flex: none; }
.add-row { display: flex; gap: 8px; align-items: flex-end; margin: 10px 0 4px; }
.add-field { flex: 1; font-size: 13px; font-weight: 600; color: #475569; min-width: 0; }
.add-field input { display: block; width: 100%; margin-top: 4px; padding: 12px 10px; font-size: 18px; border: 1px solid #93c5fd; border-radius: 12px; background: #fff; color: #1e293b; }

.last-feed { margin-top: 8px; font-size: 14px; color: #334155; text-align: center; min-height: 18px; }

.actions { display: flex; gap: 8px; margin-top: 8px; }
.btn {
  border: 1px solid #93c5fd; background: #fff; color: #1d4ed8;
  border-radius: 12px; padding: 11px 10px; font-size: 15px; font-weight: 600;
}
.btn-primary { background: #2563eb; border-color: #2563eb; color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: #64748b; }
.btn-big { padding: 13px 18px; font-size: 16px; }
.btn-small { padding: 9px 12px; font-size: 14px; }
.actions .btn { flex: 1; }
.btn:disabled { opacity: .5; }

.grid { padding: 10px 12px 20px; display: flex; flex-direction: column; gap: 8px; }
.hour-row {
  display: flex; gap: 8px; align-items: stretch;
  background: #fff; border: 1px solid #dbeafe; border-radius: 14px; padding: 8px;
}
.hour-row.now { border: 2px solid #2563eb; background: #dbeafe; }
.hour-row.flash { animation: flash 1.2s ease; }
@keyframes flash { 0%, 100% { background: #fff; } 25% { background: #bfdbfe; } 60% { background: #bfdbfe; } }
.hour-label { width: 56px; flex: none; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; }
.cell { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.cell-icon { font-size: 15px; line-height: 1; }
.cell-value {
  border: none; background: #eff6ff; border-radius: 10px;
  font-size: 20px; font-weight: 800; padding: 4px 0; width: 100%; color: #1e293b;
}
.cell-value.has { background: #dbeafe; color: #1e40af; }
.cell-by { font-size: 10px; color: #94a3b8; min-height: 12px; white-space: nowrap; overflow: hidden; max-width: 100%; text-overflow: ellipsis; }
.cell-steps { display: flex; gap: 6px; width: 100%; }
.step {
  flex: 1; height: 44px; border-radius: 10px; border: 1px solid #93c5fd;
  background: #fff; font-size: 22px; font-weight: 700; color: #1d4ed8; line-height: 1;
}

.past-view { padding: 14px 12px 20px; }
.past-view h2 { margin: 4px 0; font-size: 20px; }
.past-note { color: #64748b; font-size: 14px; margin: 0 0 12px; }
.past-row {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: #fff; border: 1px solid #bfdbfe; border-radius: 14px; padding: 14px 12px;
  margin-bottom: 8px; text-align: left; font-size: 15px;
}
.past-row b { font-size: 16px; }
.past-row .past-totals { color: #475569; font-size: 14px; white-space: nowrap; }
.past-empty { color: #64748b; }
.back-today { width: 100%; margin-top: 6px; }
.foot { text-align: center; color: #94a3b8; font-size: 12px; padding: 8px 12px 20px; }

/* Sheets */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-wrap[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, .45); }
.sheet {
  position: relative; width: 100%; max-width: 520px; background: #fff;
  border-radius: 20px 20px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
  box-shadow: 0 -8px 30px rgba(15, 23, 42, .25);
}
.sheet h2 { margin: 0 0 4px; font-size: 20px; }
.sheet-by { color: #64748b; font-size: 14px; min-height: 18px; margin-bottom: 8px; }
.sheet-value-row { display: flex; align-items: center; gap: 12px; justify-content: center; margin: 8px 0; }
.step-big {
  width: 72px; height: 72px; border-radius: 50%; border: 2px solid #2563eb;
  background: #eff6ff; color: #1d4ed8; font-size: 36px; font-weight: 700; line-height: 1;
}
.sheet-value { font-size: 44px; font-weight: 800; min-width: 120px; text-align: center; }
.half-row { display: flex; gap: 8px; justify-content: center; margin-bottom: 8px; }
.half-row[hidden] { display: none; }
.chips { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 6px 0 10px; }
.chips[hidden] { display: none; }
.chip { border: 1px solid #93c5fd; background: #eff6ff; color: #1d4ed8; border-radius: 999px; padding: 10px 16px; font-size: 16px; font-weight: 700; }
.quick-diaper { display: flex; gap: 8px; margin: 6px 0 10px; }
.quick-diaper[hidden] { display: none; }
.quick-diaper .btn { flex: 1; }
.sheet-actions { display: flex; gap: 8px; margin-top: 10px; }
.sheet-actions .btn-big { flex: 1; }
.sync-note { color: #64748b; font-size: 14px; margin: 0 0 12px; }
.name-field { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 4px; }
.name-field input {
  display: block; width: 100%; margin-top: 6px; padding: 12px; font-size: 16px;
  border: 1px solid #93c5fd; border-radius: 12px;
}
.code-big {
  font-size: 30px; font-weight: 800; letter-spacing: 2px; text-align: center;
  background: #eff6ff; border: 1px dashed #93c5fd; border-radius: 14px; padding: 14px; margin: 8px 0;
}
.code-row { display: flex; gap: 8px; margin: 8px 0; }
.code-row input {
  flex: 1; padding: 12px; font-size: 18px; text-transform: uppercase; letter-spacing: 1px;
  border: 1px solid #93c5fd; border-radius: 12px; min-width: 0;
}
.name-pick { display: flex; gap: 8px; margin: 12px 0 4px; }
.name-pick .btn { flex: 1; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; z-index: 80;
  background: #1e293b; color: #fff; padding: 11px 16px; border-radius: 999px;
  font-size: 14px; max-width: 92vw; text-align: center;
}
.toast[hidden] { display: none; }
