/* ─────────────────────────────────────────────
   Eat, Poop, Love — Warm cream + teal palette
   ───────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&display=swap');

:root {
  --bg:          #F3E6C7;
  --paper:       #FDF7EE;
  --teal:        #3A8CA8;
  --teal-dark:   #2A6B85;
  --teal-light:  #C5E2EE;
  --gold:        #E8A020;
  --gold-light:  #F5D895;
  --ink:         #1E3A4A;
  --ink-light:   #5A7A8A;
  --border:      #2A6B85;
  --radius:      16px;
  --shadow:      4px 4px 0 var(--teal-dark);
  --shadow-sm:   2px 2px 0 var(--teal-dark);
  --font:        'Nunito', sans-serif;
  --nav-h:       64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 18px;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

/* ── App wrapper ─────────────────────────────── */
#app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
  background: var(--bg);
  display: none; /* hidden until auth confirms — JS sets display:flex via .hidden removal */
}
#app:not(.hidden) {
  display: block;
}

/* ── Notebook ruled lines ────────────────────── */
/* Lines live on each screen so they scroll with content */

/* ── Screens ─────────────────────────────────── */
.screen {
  display: none;
  flex-direction: column;
  min-height: calc(100dvh - var(--nav-h));
  padding: 16px 16px 8px;
  padding-bottom: calc(var(--nav-h) + 16px);
  animation: fadeIn 0.15s ease;
  position: relative;
  z-index: 1;
  /* Notebook ruled lines — scroll with content */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 32' preserveAspectRatio='none'%3E%3Cpath d='M0%2C30 Q25%2C29.2 50%2C30 Q75%2C30.8 100%2C30 Q125%2C29.2 150%2C30 Q175%2C30.8 200%2C30 Q225%2C29.2 250%2C30 Q275%2C30.8 300%2C30 Q325%2C29.2 350%2C30 Q375%2C30.8 400%2C30' stroke='%235A7A8A' stroke-width='0.9' fill='none' opacity='0.22'/%3E%3C/svg%3E");
  background-size: 100% 32px;
  background-repeat: repeat-y;
  background-attachment: scroll;
}
.screen.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Top bar ─────────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 41px;
}

.topbar h1 {
  font-size: 24px;
  font-weight: 800;
  line-height: 1;
  color: var(--teal-dark);
}

.topbar-logo {
  height: 42px;
  width: auto;
}

.baby-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gold-light);
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px 4px 8px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
}
.baby-switcher svg { width: 18px; height: 18px; }

/* ── Cards ───────────────────────────────────── */
.card {
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-light);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

/* ── Summary strip ───────────────────────────── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.summary-tile {
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 10px 6px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}
.summary-tile .tile-icon { font-size: 20px; line-height: 1; display:flex; align-items:center; justify-content:center; }
.summary-tile .tile-val  { font-size: 19px; font-weight: 800; line-height: 1; color: var(--teal-dark); }
.summary-tile .tile-lbl  { font-size: 11px; color: var(--ink-light); font-weight: 700; }

/* ── Last-seen strip ─────────────────────────── */
.last-seen {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.last-seen-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--teal-light);
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  box-shadow: var(--shadow-sm);
  font-size: 15px;
}
.last-seen-row .ls-icon  { font-size: 18px; }
.last-seen-row .ls-label { flex: 1; font-weight: 700; }
.last-seen-row .ls-time  { color: var(--ink-light); font-size: 13px; font-weight: 700; }

.ls-edit-btn {
  background: var(--paper);
  border: 1.5px solid var(--border);
  border-radius: 7px;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 13px;
  box-shadow: 1px 1px 0 var(--border);
  flex-shrink: 0;
  margin-left: 6px;
}
.ls-edit-btn:active { background: var(--teal-light); transform: translate(1px,1px); box-shadow: none; }
.ls-edit-placeholder { width: 28px; height: 28px; flex-shrink: 0; margin-left: 6px; }

/* ── Undo bar ────────────────────────────────── */
.undo-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--gold-light);
  border: 2px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 7px 12px;
  margin-bottom: 12px;
  gap: 8px;
}
.undo-bar.hidden { display: none; }
.undo-lbl { font-size: 14px; color: var(--ink-light); flex: 1; font-weight: 700; }
.undo-btn {
  background: var(--gold);
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 4px 14px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 800;
  color: white;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  flex-shrink: 0;
}
.undo-btn:active { transform: translate(1px,1px); box-shadow: none; }

/* ── Quick log buttons ───────────────────────── */
.quick-btns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}

.quick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 16px 8px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-family: var(--font);
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  -webkit-user-select: none;
}
.quick-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--teal-dark);
}
.quick-btn .btn-icon { font-size: 30px; display:flex; align-items:center; justify-content:center; }

.quick-btn.feed   { background: var(--gold-light); }
.quick-btn.poop   { background: #DDD0B8; }
.quick-btn.pee    { background: var(--teal-light); }
.quick-btn.sleep  { background: #C8D4EC; }
.quick-btn.weight { background: #C8E8D0; }

/* Sleep active state */
.quick-btn.sleep.active-sleep {
  background: var(--teal);
  color: white;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: var(--shadow); }
  50%       { box-shadow: 6px 6px 0 var(--teal-dark); }
}

/* ── Bottom nav ──────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 430px;
  height: var(--nav-h);
  background: var(--paper);
  border-top: 2px solid var(--border);
  display: flex;
  align-items: stretch;
  z-index: 100;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 10px;
  font-weight: 700;
  color: var(--ink-light);
  transition: color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
  padding: 0;
}
.nav-btn svg { width: 24px; height: 24px; }
.nav-icon {
  width: 28px;
  height: 28px;
  object-fit: contain;
}
.nav-btn.active {
  color: var(--teal-dark);
  background: var(--teal-light);
}

/* ── Log entry list ──────────────────────────── */
.log-date-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.log-date-nav button {
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  font-family: var(--font);
  font-size: 20px;
  font-weight: 700;
  width: 36px; height: 36px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink);
}
.log-date-nav button:active { transform: translate(1px,1px); box-shadow: 1px 1px 0 var(--border); }
.log-date-nav .date-label { font-size: 17px; font-weight: 800; color: var(--teal-dark); }

.entry-list { display: flex; flex-direction: column; gap: 8px; }

.entry-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  padding: 10px 12px;
}
.entry-item .e-icon { font-size: 22px; width: 34px; display:flex; align-items:center; justify-content:center; flex-shrink:0; }
.entry-item .e-body { flex: 1; }
.entry-item .e-type { font-weight: 800; font-size: 15px; color: var(--teal-dark); }
.entry-item .e-detail { font-size: 13px; color: var(--ink-light); font-weight: 600; }
.entry-item .e-time { font-size: 13px; color: var(--ink-light); white-space: nowrap; font-weight: 700; }

.entry-item .e-actions {
  display: flex;
  gap: 4px;
}
.e-action-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 14px;
}
.e-action-btn:active { background: var(--teal-light); }

.entry-item.feed   { border-left: 4px solid var(--gold); }
.entry-item.poop   { border-left: 4px solid #A0855A; }
.entry-item.pee    { border-left: 4px solid var(--teal); }
.entry-item.sleep  { border-left: 4px solid #7090C8; }
.entry-item.weight { border-left: 4px solid #4CAF50; }

.empty-state {
  text-align: center;
  color: var(--ink-light);
  font-size: 17px;
  font-weight: 700;
  padding: 40px 0;
}

/* ── Calendar ────────────────────────────────── */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.cal-header button {
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  font-family: var(--font);
  font-size: 20px;
  font-weight: 700;
  width: 36px; height: 36px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--ink);
}
.cal-header .cal-title { font-size: 18px; font-weight: 800; color: var(--teal-dark); }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 14px;
}
.cal-day-name {
  text-align: center;
  font-size: 12px;
  color: var(--ink-light);
  font-weight: 800;
  padding: 4px 0;
}
.cal-cell {
  aspect-ratio: 1;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  position: relative;
}
.cal-cell.has-data { background: var(--gold-light); border-color: var(--border); box-shadow: 1px 1px 0 var(--border); }
.cal-cell.today { font-weight: 800; border-color: var(--teal) !important; border-width: 2px !important; }
.cal-cell.selected { background: var(--teal-light) !important; border-color: var(--border) !important; box-shadow: var(--shadow-sm) !important; }
.cal-cell.other-month { color: #B8CAD4; }
.cal-cell .dot-row { display: flex; gap: 2px; position: absolute; bottom: 3px; }
.cal-cell .dot { width: 4px; height: 4px; border-radius: 50%; }
.dot.feed  { background: var(--gold); }
.dot.poop  { background: #A0855A; }
.dot.pee   { background: var(--teal); }
.dot.sleep { background: #7090C8; }

.cal-day-log { margin-top: 4px; }

/* ── Charts ──────────────────────────────────── */
.chart-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}
.chart-tab {
  flex: 1;
  padding: 8px;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--paper);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  color: var(--ink);
}
.chart-tab.active {
  background: var(--teal-light);
  color: var(--teal-dark);
}

.chart-metric-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.chart-metric-tab {
  padding: 5px 12px;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--paper);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 1px 1px 0 var(--border);
  color: var(--ink);
}
.chart-metric-tab.active { background: var(--gold-light); color: var(--teal-dark); }

.chart-wrapper {
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  margin-bottom: 14px;
}

/* ── Settings / Baby profiles ────────────────── */
.section-title {
  font-size: 21px;
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--teal-dark);
}

.baby-card {
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.baby-card .baby-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  background: var(--gold-light);
  flex-shrink: 0;
}
.baby-card .baby-info { flex: 1; }
.baby-card .baby-name { font-size: 18px; font-weight: 800; color: var(--teal-dark); }
.baby-card .baby-meta { font-size: 13px; color: var(--ink-light); font-weight: 600; }
.baby-card .baby-actions { display: flex; gap: 6px; }
.baby-card .baby-actions button {
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: 8px;
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 16px;
  box-shadow: 1px 1px 0 var(--border);
}

/* ── Forms / Modals ──────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30,58,74,0.42);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.modal-overlay.hidden { display: none; }

.modal-sheet {
  background: var(--paper);
  border: 2px solid var(--border);
  border-bottom: none;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 430px;
  padding: 20px 20px 32px;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: 0 -4px 0 var(--teal-dark);
}

.modal-handle {
  width: 48px; height: 5px;
  background: var(--teal-dark);
  border-radius: 3px;
  margin: 0 auto 16px;
  opacity: 0.25;
}

.modal-title {
  font-size: 23px;
  font-weight: 800;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--teal-dark);
}

/* ── Form elements ───────────────────────────── */
.form-group {
  margin-bottom: 16px;
}
.form-label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-light);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: white;
  font-family: var(--font);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  outline: none;
  box-shadow: var(--shadow-sm);
}
.form-input:focus { border-color: var(--teal); background: var(--teal-light); }

/* ── Slider ──────────────────────────────────── */
.slider-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.slider-val {
  font-size: 32px;
  font-weight: 800;
  text-align: center;
  line-height: 1;
  color: var(--teal-dark);
}
.slider-unit { font-size: 16px; font-weight: 600; color: var(--ink-light); }

input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--teal-light);
  border: 1.5px solid var(--border);
  outline: none;
  cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--gold);
  border: 2.5px solid var(--border);
  box-shadow: var(--shadow-sm);
  cursor: grab;
}
input[type=range]:active::-webkit-slider-thumb { cursor: grabbing; transform: scale(1.15); }

/* ── Method selector ─────────────────────────── */
.method-selector {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.method-btn {
  flex: 1;
  min-width: 70px;
  padding: 8px 4px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--paper);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  transition: background 0.1s;
}
.method-btn.selected { background: var(--gold-light); }

/* ── Consistency selector ────────────────────── */
.consistency-selector {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.consistency-btn {
  padding: 10px 4px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--paper);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  box-shadow: var(--shadow-sm);
  color: var(--ink);
}
.consistency-btn.selected { background: var(--gold-light); }

/* ── Sleep timer display ─────────────────────── */
.sleep-timer-display {
  font-size: 48px;
  font-weight: 800;
  text-align: center;
  padding: 12px 0;
  letter-spacing: 2px;
  color: var(--teal-dark);
}

.sleep-controls {
  display: flex;
  gap: 8px;
}

/* ── Action buttons ──────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 20px;
  border: 2px solid var(--border);
  border-radius: 999px;
  font-family: var(--font);
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.1s, box-shadow 0.1s;
  color: var(--ink);
}
.btn:active { transform: translate(2px, 2px); box-shadow: var(--shadow-sm); }
.btn-primary { background: var(--gold); color: white; }
.btn-secondary { background: var(--paper); color: var(--ink); }
.btn-danger { background: #FFB3B3; color: var(--ink); }
.btn-full { width: 100%; }
.btn-blue { background: var(--teal-light); color: var(--ink); }
.btn-green { background: #C8E8D0; color: var(--ink); }

/* ── Nursing timer ───────────────────────────── */
.nursing-panel {
  display: none;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  margin-bottom: 4px;
}
.nursing-panel.visible { display: flex; }

/* Mode toggle */
.nursing-mode-toggle {
  display: flex;
  gap: 6px;
}
.ns-mode-btn {
  flex: 1;
  padding: 7px 8px;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--paper);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  box-shadow: 1px 1px 0 var(--border);
  color: var(--ink-light);
}
.ns-mode-btn.active {
  background: var(--teal-light);
  color: var(--teal-dark);
}

/* Timer view */
.ns-timer-view {
  display: flex;
  gap: 8px;
}
.nursing-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.nursing-side.active { background: var(--teal-light); }
.nursing-side .ns-label { font-size: 13px; font-weight: 700; color: var(--ink-light); }
.nursing-side .ns-time  { font-size: 22px; font-weight: 800; color: var(--teal-dark); }

/* Manual input view */
.ns-manual-view {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ns-manual-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.ns-manual-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-light);
  white-space: nowrap;
  width: 86px;
  flex-shrink: 0;
}
.ns-manual-input {
  flex: 1 !important;
  width: auto !important;
  font-size: 16px !important;
  padding: 8px 12px !important;
}

/* ── Time input ──────────────────────────────── */
.time-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.time-row label { font-size: 14px; font-weight: 700; color: var(--ink-light); white-space: nowrap; }

/* ── Note field ──────────────────────────────── */
textarea.form-input {
  resize: vertical;
  min-height: 60px;
}

/* ── Growth chart card ───────────────────────── */
.growth-mini {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 40px;
  margin-top: 6px;
}
.growth-bar {
  flex: 1;
  background: var(--teal-light);
  border: 1.5px solid var(--border);
  border-radius: 3px 3px 0 0;
  min-height: 4px;
}

/* ── No baby state ───────────────────────────── */
.no-baby {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 60vh;
  text-align: center;
}
.no-baby .nb-emoji { font-size: 64px; }
.no-baby h2 { font-size: 25px; font-weight: 800; color: var(--teal-dark); }
.no-baby p  { font-size: 16px; color: var(--ink-light); font-weight: 600; max-width: 280px; }

/* ── Scrollable areas ────────────────────────── */
.scroll-area {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* ── Misc ────────────────────────────────────── */
.divider {
  height: 2px;
  background: var(--teal-light);
  margin: 12px 0;
}

.text-center { text-align: center; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mb-8  { margin-bottom: 8px; }
.flex  { display: flex; }
.flex-1 { flex: 1; }
.gap-8 { gap: 8px; }
.hidden { display: none !important; }

/* ── Baby face animation ─────────────────────── */
.baby-anim {
  position: relative;
  display: inline-block;
  width: 1.6em;
  height: 1.6em;
  vertical-align: middle;
  flex-shrink: 0;
}
.baby-anim img {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  opacity: 0;
}
.baby-anim img:nth-child(1) { animation: baby-f1 2.4s steps(1) infinite; }
.baby-anim img:nth-child(2) { animation: baby-f2 2.4s steps(1) infinite; }
.baby-anim img:nth-child(3) { animation: baby-f3 2.4s steps(1) infinite; }

@keyframes baby-f1 {
  0%, 32%   { opacity: 1; }
  33%, 100% { opacity: 0; }
}
@keyframes baby-f2 {
  0%, 32%   { opacity: 0; }
  33%, 65%  { opacity: 1; }
  66%, 100% { opacity: 0; }
}
@keyframes baby-f3 {
  0%, 65%   { opacity: 0; }
  66%, 100% { opacity: 1; }
}

/* ── Desktop layout ─────────────────────────── */
@media (min-width: 431px) {
  /* Squiggly lines fill the full screen */
  body {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 32' preserveAspectRatio='none'%3E%3Cpath d='M0%2C30 Q25%2C29.2 50%2C30 Q75%2C30.8 100%2C30 Q125%2C29.2 150%2C30 Q175%2C30.8 200%2C30 Q225%2C29.2 250%2C30 Q275%2C30.8 300%2C30 Q325%2C29.2 350%2C30 Q375%2C30.8 400%2C30' stroke='%235A7A8A' stroke-width='0.9' fill='none' opacity='0.22'/%3E%3C/svg%3E");
    background-size: 100% 32px;
    background-repeat: repeat-y;
  }

  /* Nav bar extends full screen width; padding keeps buttons centred over the 430px content */
  .bottom-nav {
    max-width: 100%;
    padding: 0 calc(50% - 215px);
  }

  /* Buttons must not stretch across the full bar */
  .nav-btn {
    flex: 0 0 calc(430px / 6);
  }
}

/* ── Safe area support ───────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .bottom-nav {
    height: calc(var(--nav-h) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
  }
  .screen {
    padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  }
}

/* ── Time scroll picker ──────────────────────── */
.tsp-wrap {
  display: flex;
  align-items: center;
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: 12px;
  padding: 0 10px;
  position: relative;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.tsp-highlight {
  position: absolute;
  left: 6px; right: 6px;
  top: 50%; transform: translateY(-50%);
  height: 44px;
  background: var(--teal-light);
  border-radius: 8px;
  border: 1.5px solid var(--teal-dark);
  pointer-events: none;
  z-index: 0;
}
.tsp-col {
  flex: 1;
  height: 132px;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: relative;
  z-index: 1;
  overscroll-behavior: contain;
  -webkit-mask-image: linear-gradient(to bottom, transparent, black 28%, black 72%, transparent);
  mask-image: linear-gradient(to bottom, transparent, black 28%, black 72%, transparent);
}
.tsp-col::-webkit-scrollbar { display: none; }
.tsp-item {
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 21px;
  font-weight: 700;
  color: var(--ink);
  cursor: default;
  user-select: none;
}
.tsp-col .tsp-item:not(.tsp-pad) { scroll-snap-align: center; }
.tsp-pad { visibility: hidden; pointer-events: none; }
.tsp-sep {
  font-size: 26px;
  font-weight: 900;
  color: var(--teal-dark);
  flex-shrink: 0;
  padding: 0 4px;
  z-index: 1;
}
.tsp-col.tsp-ap { flex: 0 0 60px; }

/* ── Camera overlay ──────────────────────────── */
.camera-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 300;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: env(safe-area-inset-top, 0px);
}
.camera-video-wrap {
  position: relative;
  width: 100%;
  max-width: 430px;
  aspect-ratio: 1;
  background: #111;
  flex-shrink: 0;
}
.camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
  display: block;
}
.camera-guide {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.camera-guide-oval {
  width: 56%;
  height: 74%;
  border: 2.5px dashed rgba(255,255,255,0.8);
  border-radius: 50%;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.22);
}
.camera-crosshair {
  position: absolute;
  inset: 0;
}
.camera-crosshair::before {
  content: '';
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: 1px;
  background: rgba(255,255,255,0.18);
}
.camera-crosshair::after {
  content: '';
  position: absolute;
  top: 50%; left: 0; right: 0;
  height: 1px;
  background: rgba(255,255,255,0.18);
}
.camera-hint {
  color: rgba(255,255,255,0.65);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  padding: 10px 20px 0;
  width: 100%;
  max-width: 430px;
}
.camera-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 20px;
  width: 100%;
  max-width: 430px;
  flex: 1;
}
.camera-shutter {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: white;
  border: 4px solid rgba(255,255,255,0.5);
  cursor: pointer;
  box-shadow: 0 0 0 5px rgba(255,255,255,0.2);
  flex-shrink: 0;
  transition: transform 0.1s;
}
.camera-shutter:active { transform: scale(0.9); }
.camera-side-btn {
  width: 80px;
  flex-shrink: 0;
  background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.35);
  border-radius: 999px;
  color: white;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  padding: 10px 8px;
  cursor: pointer;
  text-align: center;
}
.camera-preview-wrap {
  width: 100%;
  max-width: 430px;
  flex-shrink: 0;
}
#camera-canvas {
  width: 100%;
  display: block;
  aspect-ratio: 1;
}
.camera-preview-controls {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  width: 100%;
  max-width: 430px;
}

/* ── Photos screen ───────────────────────────── */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}
.photo-thumb {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  position: relative;
}
.photo-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.photo-thumb .pt-date {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,0.52);
  color: white;
  font-family: var(--font);
  font-size: 9px;
  font-weight: 700;
  text-align: center;
  padding: 2px;
}
.photo-thumb .pt-del {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(0,0,0,0.5);
  border: none;
  border-radius: 50%;
  color: white;
  width: 22px; height: 22px;
  font-size: 11px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font);
}

/* ── Timelapse player ────────────────────────── */
.timelapse-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  background: #111;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
  border: 2px solid var(--border);
  box-shadow: var(--shadow);
  flex-shrink: 0;
}
.timelapse-img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.timelapse-counter {
  position: absolute;
  top: 10px; right: 12px;
  background: rgba(0,0,0,0.5);
  color: white;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
}
.timelapse-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
  flex-shrink: 0;
}
.tl-speed {
  flex: 1;
  display: flex;
  gap: 4px;
}
.tl-speed-btn {
  flex: 1;
  padding: 8px 4px;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--paper);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  color: var(--ink-light);
  box-shadow: 1px 1px 0 var(--border);
}
.tl-speed-btn.active { background: var(--gold-light); color: var(--teal-dark); }

/* ── Illustration icons ──────────────────────── */
.epl-icon {
  height: 1.5em;
  width: auto;
  display: inline-block;
  vertical-align: middle;
  object-fit: contain;
  flex-shrink: 0;
}
.epl-icon-lg {
  height: 2.2em;
  width: auto;
  display: inline-block;
  vertical-align: middle;
  object-fit: contain;
  flex-shrink: 0;
}

/* ── Auth screen ─────────────────────────────── */
#auth-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 500;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 400 32' preserveAspectRatio='none'%3E%3Cpath d='M0%2C30 Q25%2C29.2 50%2C30 Q75%2C30.8 100%2C30 Q125%2C29.2 150%2C30 Q175%2C30.8 200%2C30 Q225%2C29.2 250%2C30 Q275%2C30.8 300%2C30 Q325%2C29.2 350%2C30 Q375%2C30.8 400%2C30' stroke='%235A7A8A' stroke-width='0.9' fill='none' opacity='0.22'/%3E%3C/svg%3E");
  background-size: 100% 32px;
  background-repeat: repeat-y;
}
#auth-screen.hidden { display: none; }

.auth-card {
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px 24px;
  width: 100%;
  max-width: 380px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 8px;
}
.auth-logo img {
  height: 40px;
  width: auto;
}

.auth-tagline {
  text-align: center;
  color: var(--ink-light);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 24px;
}

.auth-error {
  background: #FFE5E5;
  border: 1.5px solid #F08080;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  color: #C0392B;
  margin-bottom: 12px;
}
.auth-error.hidden { display: none; }

.auth-toggle {
  text-align: center;
  margin-top: 16px;
  font-size: 14px;
  color: var(--ink-light);
  font-weight: 600;
}

.auth-toggle-btn {
  background: none;
  border: none;
  color: var(--teal);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  padding: 0 4px;
}

#auth-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-remember {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
}

.auth-remember-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-light);
  cursor: pointer;
  user-select: none;
}

.auth-remember-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
  cursor: pointer;
}
