@import url('https://fonts.googleapis.com/css2?family=Pacifico&display=swap');

:root {
  color-scheme: light;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --bg:      #f0f8ff;
  --card:    #ffffff;
  --border:  rgba(2,132,199,0.14);
  --text:    #0f2035;
  --muted:   #5a7a96;
  --primary: #0284c7;
  --amber:   #e8a020;
  --sky:     #0ea5e9;
  --teal:    #0d9488;
}

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

body {
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: 1rem;
  padding-top: max(env(safe-area-inset-top), 1.25rem);
  padding-bottom: max(calc(env(safe-area-inset-bottom) + 72px), 80px);
}

.hidden { display: none !important; }

/* ── Login: profile select ───────────────────────── */

#screen-profiles {
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - 2.25rem);
}

.login-header {
  text-align: center;
  padding: 2rem 0 0.5rem;
}

.login-header h1 {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #38bdf8, #0284c7);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--muted);
  margin-top: 0.35rem;
  font-size: 0.95rem;
}

.profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-top: 2rem;
}

.profile-cell {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 1.5rem 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
  cursor: pointer;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  transition: transform 0.15s, border-color 0.15s;
  width: 100%;
  box-shadow: 0 2px 12px rgba(2,132,199,0.08);
}

.profile-cell:active { transform: scale(0.94); border-color: rgba(124,111,255,0.4); }

.avatar-wrap {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(2,132,199,0.18);
}

.avatar-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ── Login: PIN ──────────────────────────────────── */

#screen-pin {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 0.5rem;
  min-height: calc(100dvh - 2.25rem);
}

.back-btn {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.95rem;
  cursor: pointer;
  padding: 0.35rem 0;
  margin-bottom: 1.5rem;
  width: auto;
}

.pin-avatar {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  overflow: hidden;
  box-shadow: 0 12px 36px rgba(2,132,199,0.2);
  margin-bottom: 1rem;
}

.pin-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.pin-greeting {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  letter-spacing: -0.01em;
}

.pin-dots {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.pin-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.18);
  background: transparent;
  transition: background 0.12s, border-color 0.12s;
}

.pin-dot.filled {
  background: #0284c7;
  border-color: #0284c7;
}

.pin-error {
  color: #e05252;
  font-size: 0.88rem;
  min-height: 1.1rem;
  margin-bottom: 0.5rem;
  text-align: center;
}

.numpad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  width: 100%;
  max-width: 280px;
  margin-top: 0.5rem;
}

.nk {
  background: rgba(0,0,0,0.04);
  border: 1px solid rgba(0,0,0,0.07);
  border-radius: 18px;
  color: var(--text);
  font-size: 1.4rem;
  font-weight: 500;
  height: 64px;
  cursor: pointer;
  transition: background 0.1s;
  width: 100%;
}

.nk:active { background: rgba(0,0,0,0.1); }
.nk-del    { color: var(--muted); font-size: 1.1rem; }
.nk-ok     { background: rgba(2,132,199,0.15); border-color: rgba(2,132,199,0.35); color: var(--primary); }
.nk-ok:active { background: rgba(2,132,199,0.28); }

/* ── Shared card ─────────────────────────────────── */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 1rem 1.1rem;
  margin-bottom: 0.75rem;
  box-shadow: 0 2px 12px rgba(2,132,199,0.06);
}

/* ── Home: top bar ───────────────────────────────── */

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.micro-label { color: var(--muted); font-size: 0.75rem; }

.user-greeting {
  font-family: 'Pacifico', cursive;
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--primary);
  letter-spacing: 0.01em;
}

.btn-logout {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.15rem;
  padding: 0.4rem 0.5rem;
  cursor: pointer;
  width: auto;
  line-height: 1;
  transition: color 0.15s;
}

.btn-logout:hover { color: var(--text); }

/* ── Sleep banner ────────────────────────────────── */

.sleep-banner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(2,132,199,0.08);
  border: 1px solid rgba(2,132,199,0.3);
  border-radius: 18px;
  padding: 0.8rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  color: var(--primary);
  animation: pulse-border 3s ease-in-out infinite;
}

@keyframes pulse-border {
  0%, 100% { border-color: rgba(2,132,199,0.25); }
  50%       { border-color: rgba(2,132,199,0.55); }
}

.banner-zzz {
  font-size: 1.2rem;
  animation: float 2s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-3px); }
}

/* ── Day nav ─────────────────────────────────────── */

.day-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
}

.day-nav h2 {
  flex: 1;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
}

.nav-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: rgba(0,0,0,0.04);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  width: auto;
  padding: 0 0.75rem;
  height: 36px;
}

.nav-btn:disabled { opacity: 0.22; cursor: default; }

/* ── Stats grid ──────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.stat-cell {
  background: rgba(2,132,199,0.05);
  border-radius: 16px;
  padding: 0.75rem 0.9rem;
}

.stat-label { color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; display: block; }
.stat-value { font-size: 1.2rem; font-weight: 700; display: block; margin-top: 0.15rem; }

/* ── Events ──────────────────────────────────────── */

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.section-head h3 { font-size: 0.9rem; font-weight: 600; }

.badge {
  background: rgba(0,0,0,0.06);
  border-radius: 20px;
  padding: 0.15rem 0.55rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.events-list { display: grid; gap: 0.5rem; }

.empty-msg { color: var(--muted); text-align: center; padding: 1.5rem 0; font-size: 0.88rem; }

.event-item {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.8rem 0.9rem;
  border-radius: 18px;
  background: rgba(2,132,199,0.03);
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
}

.ev-sleep   { border-left-color: var(--primary); }
.ev-formula { border-left-color: var(--sky); }
.ev-breast  { border-left-color: var(--teal); }

.ev-icon { font-size: 1.25rem; flex-shrink: 0; padding-top: 0.05rem; }

.ev-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.ev-title { font-weight: 600; font-size: 0.88rem; }
.ev-sub   { color: #4a6a84; font-size: 0.8rem; }
.ev-meta  { color: var(--muted); font-size: 0.75rem; margin-top: 0.1rem; }
.ev-note  { color: #4a6a84; font-size: 0.78rem; font-style: italic; }

.ev-del {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: center;
  padding: 0;
}

.ev-del:active { background: rgba(220,60,60,0.12); color: #c04040; }

/* ── Modal ───────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(80,60,160,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
  backdrop-filter: blur(4px);
}

.modal-sheet {
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: 1.5rem 1.25rem;
  position: relative;
  box-shadow: 0 8px 40px rgba(2,132,199,0.18);
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: rgba(0,0,0,0.06);
  border: none;
  color: var(--muted);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

#modal-body h2 { font-size: 1.15rem; margin-bottom: 1.25rem; }

.fg {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.fl {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.fi, .fs {
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  border: 1px solid rgba(0,0,0,0.1);
  background: rgba(0,0,0,0.03);
  color: var(--text);
  font-size: 1rem;
}

.fi:focus, .fs:focus {
  outline: none;
  border-color: #0284c7;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.chip {
  position: relative;
  cursor: pointer;
}

.chip input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.chip span {
  display: block;
  padding: 0.55rem 0.9rem;
  border-radius: 20px;
  border: 1px solid rgba(0,0,0,0.1);
  background: rgba(0,0,0,0.03);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  user-select: none;
}

.chip input[type="radio"]:checked + span {
  background: rgba(2,132,199,0.12);
  border-color: rgba(2,132,199,0.45);
  color: var(--primary);
}

.chip span:active {
  background: rgba(2,132,199,0.08);
}

.amount-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.amount-display {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--sky);
  letter-spacing: -0.01em;
}

.ml-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(
    to right,
    var(--sky) 0%,
    var(--sky) calc((var(--pct, 33.33%) )),
    rgba(0,0,0,0.1) calc((var(--pct, 33.33%)))
  );
  outline: none;
  cursor: pointer;
  margin: 0.5rem 0 0.3rem;
}

.ml-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  cursor: grab;
}

.ml-slider::-moz-range-thumb {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  border: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  cursor: grab;
}

.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: rgba(0,0,0,0.3);
  padding: 0 1px;
  margin-bottom: 0.25rem;
}

.btn-save {
  width: 100%;
  padding: 1rem;
  background: #4f7bff;
  border: none;
  border-radius: 16px;
  color: white;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 0.5rem;
}

.btn-save:active { opacity: 0.85; }
.btn-save:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Bottom bar ──────────────────────────────────── */

.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: rgba(255,255,255,0.97);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(16px);
  display: flex;
  padding-bottom: max(env(safe-area-inset-bottom), 0px);
  z-index: 100;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.22rem;
  padding: 0.65rem 0 0.5rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s;
  letter-spacing: 0.01em;
}

.nav-icon { font-size: 1.4rem; line-height: 1; }
.nav-label { line-height: 1; }

.nav-item-home,
.nav-item-sleep,
.nav-item-wake,
.nav-item-milk  { color: var(--muted); }
.nav-item-active { color: var(--primary) !important; }

.nav-item:active { opacity: 0.65; }

/* ── Stats screen ────────────────────────────────── */

#screen-stats {
  min-height: 100dvh;
}

.stats-heading {
  font-size: 1.1rem;
  font-weight: 700;
}

.period-tabs {
  display: flex;
  gap: 0.45rem;
  margin-bottom: 1rem;
}

.ptab {
  flex: 1;
  padding: 0.5rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,0.03);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  width: auto;
}

.ptab.active {
  background: rgba(2,132,199,0.1);
  border-color: rgba(2,132,199,0.4);
  color: var(--primary);
}

.stats-page-content {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

/* ── Summary stat strip ──────────────────────────── */

.sstat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.sstat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 0.75rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  box-shadow: 0 2px 8px rgba(2,132,199,0.06);
}

.sstat-v { font-size: 1.15rem; font-weight: 700; }
.sstat-l { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* ── Chart cards ─────────────────────────────────── */

.chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 1rem 1rem 0.75rem;
  box-shadow: 0 2px 8px rgba(2,132,199,0.06);
}

.chart-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.6rem;
}

.leg-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
