:root {
  --bg: #12182a;
  --bg-elevated: #1b2338;
  --bg-card: #1e2740;
  --border: #2b3552;
  --text: #f4f1ea;
  --text-dim: #9aa3bd;
  --accent: #f5b942;
  --accent-strong: #f2a51c;
  --danger: #e0654f;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

h1, h2 { font-family: "Playfair Display", Georgia, serif; margin: 0; }

.hidden { display: none !important; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea {
  font-family: inherit;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 16px; /* prevents iOS zoom-on-focus */
  width: 100%;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---------------------------------------------------------------- LOGIN */
.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  max-width: 360px;
  width: 100%;
  text-align: center;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 28px;
}
.login-card .brand { font-size: 2rem; margin-bottom: 8px; }
.login-sub { color: var(--text-dim); margin: 0 0 24px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 15px;
  width: 100%;
}
.btn-signin { background: var(--accent); color: #23180a; }
.btn-signin:active { transform: scale(0.98); }
.login-error {
  margin-top: 16px;
  color: var(--danger);
  font-size: 14px;
}
.btn-danger-outline {
  border: 1px solid var(--danger);
  color: var(--danger);
  border-radius: 10px;
  padding: 10px;
  width: 100%;
  margin-top: 8px;
}

/* ----------------------------------------------------------------- APP */
.app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
}

.app-header {
  padding: 18px 20px 14px;
  background: linear-gradient(180deg, var(--bg-elevated), var(--bg));
  border-bottom: 1px solid var(--border);
}
.header-top { display: flex; align-items: center; gap: 14px; }
.header-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--bg-card); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0;
}
.baby-name { font-size: 1.6rem; }
.header-date { color: var(--text-dim); font-size: 14px; margin-top: 2px; }
.header-signout { margin-left: auto; font-size: 20px; color: var(--text-dim); }

.views { flex: 1; overflow-y: auto; padding: 16px 16px calc(90px + var(--safe-bottom)); }
.view { max-width: 640px; margin: 0 auto; }

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--accent);
}
.card-header h2 { color: #23180a; font-size: 1.3rem; }
.feed-card-header { background: var(--accent); }

.fab {
  width: 34px; height: 34px; border-radius: 50%;
  background: #23180a; color: var(--accent);
  font-size: 20px; line-height: 1; display: flex; align-items: center; justify-content: center;
}

/* --------------------------------------------------------- LAST FEED */
.last-feed {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.last-feed-icon { font-size: 26px; }
.last-feed-meta { flex: 1; min-width: 0; }
.last-feed-label { font-size: 15px; font-weight: 600; }
.last-feed-sub { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.last-feed-amount { font-family: "Playfair Display", serif; font-size: 2rem; }

/* ------------------------------------------------------------ FEED LIST */
.feed-list { list-style: none; margin: 0; padding: 0; max-height: 55vh; overflow-y: auto; }
.feed-list li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}
.feed-list li:last-child { border-bottom: none; }
.feed-time { width: 76px; flex-shrink: 0; font-size: 14px; color: var(--text-dim); }
.feed-bar-wrap { flex: 1; }
.feed-bar { height: 8px; border-radius: 4px; background: var(--accent); }
.feed-brand { font-size: 13px; color: var(--text-dim); margin-top: 4px; }
.feed-note { font-size: 12px; color: var(--text-dim); font-style: italic; margin-top: 2px; }
.feed-amount { font-weight: 700; min-width: 56px; text-align: right; }
.show-more { width: 100%; padding: 14px; color: var(--accent); font-weight: 600; border-top: 1px solid var(--border); }

/* -------------------------------------------------------------- HISTORY */
.week-nav { display: flex; align-items: center; gap: 6px; color: #23180a; font-weight: 600; font-size: 13px; }
.history-grid-wrap { overflow-x: auto; padding: 8px; }
.history-grid {
  display: grid;
  grid-template-columns: 40px repeat(7, minmax(34px, 1fr));
  min-width: 320px;
  font-size: 11px;
}
.history-cell {
  position: relative;
  height: 16px;
  border-bottom: 1px dashed rgba(255,255,255,0.05);
}
.history-hour-label {
  color: var(--text-dim);
  text-align: right;
  padding-right: 6px;
  font-size: 10px;
  transform: translateY(-6px);
}
.history-day-header {
  text-align: center;
  color: var(--text-dim);
  font-weight: 600;
  padding-bottom: 6px;
}
.history-bar {
  position: absolute;
  left: 3px; right: 3px;
  height: 6px;
  border-radius: 3px;
  background: var(--accent);
  top: 5px;
}

/* --------------------------------------------------------------- TRENDS */
.range-toggle { display: flex; gap: 4px; background: rgba(0,0,0,0.15); border-radius: 999px; padding: 3px; }
.range-btn { padding: 5px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; color: #23180a; }
.range-btn.active { background: #23180a; color: var(--accent); }
.stat-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border);
}
.stat-tile { background: var(--bg-card); padding: 16px 18px; }
.stat-label { color: var(--text-dim); font-size: 13px; }
.stat-value { font-family: "Playfair Display", serif; font-size: 1.8rem; margin-top: 4px; }
.stat-unit { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.chart-wrap { padding: 18px; }
.chart-caption { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; }

/* ---------------------------------------------------------------- NAV */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  padding: 8px 0 calc(8px + var(--safe-bottom));
}
.nav-btn {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 0;
}
.nav-btn.active { color: var(--accent); }
.nav-icon { font-size: 20px; }

/* ------------------------------------------------------------- ICON BTN */
.icon-btn { font-size: 18px; color: var(--text-dim); padding: 4px 8px; }

/* ------------------------------------------------------------------ SHEET */
.sheet-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: flex-end;
  z-index: 50;
}
.sheet {
  width: 100%;
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  padding-bottom: calc(24px + var(--safe-bottom));
}
.sheet-header {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--accent);
  color: #23180a;
  padding: 16px 16px;
  position: sticky; top: 0;
  border-radius: 20px 20px 0 0;
}
.sheet-header h2 { font-size: 1.5rem; }
.sheet-save { font-weight: 700; color: #23180a; font-size: 15px; }
.sheet-header .icon-btn { color: #23180a; }
.sheet-body { padding: 18px 18px 0; display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; color: var(--text-dim); }
.chip {
  align-self: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 13px;
  color: var(--accent);
  margin-top: -10px;
}

/* ------------------------------------------------------------------ TOAST */
.toast {
  position: fixed;
  bottom: calc(96px + var(--safe-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: #23180a;
  color: var(--accent);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  z-index: 60;
}

@media (min-width: 640px) {
  .views { padding-left: 24px; padding-right: 24px; }
}
