/* Dark by default: most feeds happen at night. Light theme follows the phone. */
:root {
  --bg: #151a26;
  --surface: #1f2636;
  --surface-2: #283044;
  --text: #eef0f5;
  --muted: #a3abbd;
  --line: #343c52;
  --left: #f2a07b;
  --right: #6fc3b2;
  --accent: #f2a07b;
  --accent-ink: #2a1a12;
  --danger: #ff8a80;
  --radius: 18px;
  --gap: 16px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f4f1;
    --surface: #ffffff;
    --surface-2: #efebe6;
    --text: #1d2230;
    --muted: #5d6475;
    --line: #e1dcd5;
    --left: #d9774d;
    --right: #2f9682;
    --accent: #d9774d;
    --accent-ink: #ffffff;
    --danger: #c62828;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 0 calc(72px + env(safe-area-inset-bottom));
}

body.sheet-open { overflow: hidden; }

button, input, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px var(--gap) 4px;
}

.topbar h1 { font-size: 1.25rem; margin: 0; letter-spacing: 0.01em; }

.sync-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.6;
}
.sync-dot.ok { background: var(--right); opacity: 1; }
.sync-dot.syncing { background: var(--right); opacity: 0.5; }
.sync-dot.pending, .sync-dot.offline { background: #f2c94c; opacity: 1; }
.sync-dot.auth, .sync-dot.error { background: var(--danger); opacity: 1; }

.notice {
  margin: 8px var(--gap) 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border-left: 4px solid #f2c94c;
  font-size: 0.9rem;
}
.notice[hidden] { display: none; }

.view { padding: 8px var(--gap) var(--gap); max-width: 560px; margin: 0 auto; }

.view-title { font-size: 1rem; color: var(--muted); font-weight: 600; margin: 20px 0 10px; }

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: var(--gap);
}

.card h2, .card h3 { margin: 0 0 8px; }

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.hero { text-align: center; }

.next { font-size: 3rem; font-weight: 700; margin: 4px 0 8px; line-height: 1.1; }
.next.side-L, .txt-L { color: var(--left); }
.next.side-R, .txt-R { color: var(--right); }

.meta { color: var(--muted); margin: 4px 0; }
.meta strong { color: var(--text); }

.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  vertical-align: middle;
  font-weight: 600;
}
.badge.live { background: var(--accent); color: var(--accent-ink); }

.side-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: var(--gap); }

.side-btn {
  border: 2px solid transparent;
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px 8px;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.side-btn span { color: var(--muted); font-size: 0.85rem; }
.side-btn strong { font-size: 1.6rem; }
.side-btn em { font-style: normal; font-variant-numeric: tabular-nums; font-size: 1.1rem; color: var(--muted); }
.side-btn.side-L strong { color: var(--left); }
.side-btn.side-R strong { color: var(--right); }
.side-btn.suggested.side-L, .side-btn.running.side-L { border-color: var(--left); }
.side-btn.suggested.side-R, .side-btn.running.side-R { border-color: var(--right); }
.side-btn.running { background: var(--surface-2); }
.side-btn.running em { color: var(--text); }
.side-btn:active { transform: scale(0.98); }

.active-card { text-align: center; }
.active-card .side-row { margin: 12px 0; }
.active-card .side-btn { background: var(--bg); }
.active-card .side-btn.running { background: var(--surface-2); }

.clock {
  font-size: 3.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin: 4px 0;
}

.btn-row { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; }

.btn {
  border: 0;
  border-radius: 14px;
  padding: 14px 16px;
  background: var(--surface-2);
  font-weight: 600;
  min-height: 48px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.wide { width: 100%; margin-top: 8px; }
.btn.ghost-danger { background: transparent; color: var(--danger); }

.link {
  background: none;
  border: 0;
  margin-top: 14px;
  padding: 6px;
  color: var(--muted);
  text-decoration: underline;
}
.link.danger { color: var(--danger); }

.quick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 8px; }

.quick-btn {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 14px;
  padding: 12px 4px;
  font-weight: 600;
  font-size: 0.9rem;
}

.day-head { font-size: 0.9rem; color: var(--muted); margin: 18px 0 6px; }

.entries { list-style: none; margin: 0; padding: 0; }

.entry {
  width: 100%;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  text-align: left;
  border: 0;
  background: var(--surface);
  padding: 12px 14px;
  border-radius: 14px;
  margin-bottom: 6px;
}
.entry:disabled { opacity: 1; cursor: default; }

.entry-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.entry-main small { color: var(--muted); }
.entry-main .note { font-style: italic; overflow-wrap: anywhere; }

.dot { width: 12px; height: 12px; border-radius: 50%; margin-top: 5px; flex: none; background: var(--muted); }
.dot.breast.side-L { background: var(--left); }
.dot.breast.side-R { background: var(--right); }
.dot.bottle { background: transparent; border: 3px solid var(--text); }
.dot.pump { background: var(--muted); border-radius: 3px; }

.empty { color: var(--muted); text-align: center; margin: 24px 0; }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }

.tile {
  background: var(--surface);
  border-radius: 14px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.tile span { color: var(--muted); font-size: 0.8rem; }
.tile strong { font-size: 1.2rem; font-variant-numeric: tabular-nums; }
.tile small { color: var(--muted); font-size: 0.7rem; }

.stats { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin: 8px 0; }
.stats th, .stats td { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.stats thead th { color: var(--muted); font-weight: 600; }
.stats .num { text-align: right; font-variant-numeric: tabular-nums; }
.stats tbody th { font-weight: 500; white-space: nowrap; }
.bar-cell { width: 40%; }
.bar { display: flex; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.bar i { display: block; height: 100%; }
.bar i.side-L { background: var(--left); }
.bar i.side-R { background: var(--right); }
.bar-cell small { color: var(--muted); }

.stack { display: flex; flex-direction: column; gap: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; border: 0; margin: 0; padding: 0; min-width: 0; }
.field > span, .field legend { color: var(--muted); font-size: 0.85rem; padding: 0; }

.field input, .field textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  font-size: 16px; /* stops iOS zooming on focus */
  min-height: 48px;
}

.with-suffix { position: relative; display: block; }
.with-suffix em { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-style: normal; pointer-events: none; }
.with-suffix input { padding-right: 48px; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.segmented { display: flex; background: var(--bg); border-radius: 12px; padding: 4px; gap: 4px; }
.segmented label { flex: 1; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; text-align: center; padding: 10px 4px; border-radius: 9px; font-weight: 600; color: var(--muted); }
.segmented input:checked + span { background: var(--surface-2); color: var(--text); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }

.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 5;
}
.tabs button { border: 0; background: none; padding: 14px 4px; color: var(--muted); font-weight: 600; }
.tabs button.on { color: var(--accent); }

.sheet { position: fixed; inset: 0; z-index: 10; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgb(0 0 0 / 0.5); }
.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: 22px 22px 0 0;
  padding: 8px var(--gap) calc(var(--gap) + env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.sheet-head h2 { font-size: 1.15rem; margin: 10px 0; }
.icon-btn { border: 0; background: var(--surface-2); width: 36px; height: 36px; border-radius: 50%; font-size: 1.3rem; line-height: 1; }
.sheet-body { display: flex; flex-direction: column; gap: 14px; padding: 4px 0 8px; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 12px; padding-top: 8px; }
.sheet-foot .primary { flex: 1; }
.form-error { color: var(--danger); margin: 4px 0; }

.setup { margin-top: 24px; }
