:root {
  --bg: #eef6fd;
  --bg2: #dcecfa;
  --card: #ffffff;
  --ink: #23405e;
  --muted: #6f87a0;
  --line: #d6e6f4;
  --primary: #5fa3db;
  --primary-ink: #ffffff;
  --primary-soft: #cfe6f9;
  --mm: #f2a7b8;      /* morsmelk – rosa */
  --mm-soft: #fde8ee;
  --mme: #6fb1e6;     /* erstatning – blå */
  --mme-soft: #e1f0fc;
  --pee: #f0c94d;
  --pee-soft: #fdf5d9;
  --poop: #b88a5e;
  --poop-soft: #f4ebe1;
  --pump: #a596e0;
  --pump-soft: #eeeafb;
  --warn: #e98a6b;
  --warn-soft: #fde9e1;
  --ok: #6cbf9a;
  --shadow: 0 6px 18px rgba(60, 110, 160, .10);
  --radius: 20px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101c2d;
    --bg2: #14243a;
    --card: #1a2d46;
    --ink: #e3eefa;
    --muted: #8fa7c1;
    --line: #263f5e;
    --primary: #6eb1e8;
    --primary-ink: #0f1b2b;
    --primary-soft: #21405f;
    --mm-soft: #3a2632;
    --mme-soft: #1f3a55;
    --pee-soft: #3a3420;
    --poop-soft: #352a22;
    --pump-soft: #2c2847;
    --warn-soft: #43271f;
    --shadow: 0 6px 18px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(180deg, var(--bg2) 0, var(--bg) 260px) no-repeat, var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.4;
  min-height: 100vh;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--warn); min-height: 1.2em; margin: 8px 0 0; }
h1 { font-size: 24px; margin: 0; letter-spacing: -.01em; }

button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea {
  font: inherit; color: var(--ink);
  background: var(--bg); border: 2px solid var(--line); border-radius: 14px;
  padding: 12px 14px; width: 100%; outline: none;
}
input:focus, textarea:focus { border-color: var(--primary); }

.btn {
  border: 0; border-radius: 16px; padding: 14px 18px; font-weight: 700;
  background: var(--primary-soft); color: var(--ink);
}
.btn.primary { background: var(--primary); color: var(--primary-ink); }
.btn.danger { background: var(--warn-soft); color: var(--warn); }
.btn.wide { width: 100%; }
.icon-btn {
  border: 0; background: var(--card); width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; box-shadow: var(--shadow); font-size: 26px; line-height: 1;
  color: var(--primary); flex: none;
}

/* ---------- login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  background: var(--card); border-radius: 28px; padding: 32px 26px; width: 100%; max-width: 360px;
  box-shadow: var(--shadow); text-align: center; display: grid; gap: 14px;
}
.login-icon { width: 84px; height: 84px; margin: 0 auto; }
.login-card p { margin: 0; }

/* ---------- layout ---------- */
main {
  max-width: 640px; margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 16px 0;
}
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 2px 14px; }
.top p { margin: 2px 0 0; }

.next-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.next-card {
  background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.next-card::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 6px; background: var(--mme);
}
.next-card.pump::before { background: var(--pump); }
.next-card .lbl { font-size: 13px; color: var(--muted); font-weight: 600; }
.next-card .big { font-size: 24px; font-weight: 800; margin: 2px 0; letter-spacing: -.01em; }
.next-card .sub { font-size: 13px; color: var(--muted); }
.next-card.due { background: var(--warn-soft); }
.next-card.due .big { color: var(--warn); }
.next-card.soon .big { color: var(--primary); }
.goal-pill {
  display: inline-block; margin-top: 6px; padding: 3px 10px; border-radius: 99px;
  background: var(--mme-soft); font-size: 12px; font-weight: 700;
}

.day-nav { display: flex; align-items: center; gap: 12px; margin: 22px 0 12px; }
.day-label { flex: 1; position: relative; text-align: center; font-weight: 800; font-size: 19px; cursor: pointer; }
.day-label input {
  position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; padding: 0; border: 0;
}
.day-label input::-webkit-calendar-picker-indicator { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }

.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat {
  background: var(--card); border-radius: 18px; padding: 12px 12px 10px; box-shadow: var(--shadow); min-width: 0;
}
.stat .n { font-size: 22px; font-weight: 800; letter-spacing: -.01em; }
.stat .n small { font-size: 13px; font-weight: 700; color: var(--muted); }
.stat .t { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat.span2 { grid-column: span 2; }
.stat.span3 { grid-column: span 3; }
.milkbar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--line); margin: 8px 0 6px; }
.milkbar .a { background: var(--mm); }
.milkbar .b { background: var(--mme); }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 12px; color: var(--muted); font-weight: 600; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: 0; }
.dot.mm { background: var(--mm); } .dot.mme { background: var(--mme); }
.dot.pee { background: var(--pee); } .dot.poop { background: var(--poop); } .dot.pump { background: var(--pump); }

.strip-wrap { background: var(--card); border-radius: 18px; padding: 12px 14px 8px; margin-top: 10px; box-shadow: var(--shadow); }
.strip { position: relative; height: 54px; border-radius: 10px;
  background: repeating-linear-gradient(90deg, transparent 0, transparent calc(25% - 1px), var(--line) calc(25% - 1px), var(--line) 25%);
}
.strip .row { position: absolute; left: 0; right: 0; height: 14px; }
.strip .row.r0 { top: 2px; } .strip .row.r1 { top: 20px; } .strip .row.r2 { top: 38px; }
.strip .mark { position: absolute; top: 1px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; border: 2px solid var(--card); }
.strip .now { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--warn); border-radius: 2px; }
.strip-axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; font-weight: 600; }

.list { margin-top: 16px; display: grid; gap: 8px; }
.entry {
  display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: 16px;
  padding: 10px 14px; box-shadow: var(--shadow); border: 0; text-align: left; width: 100%;
}
.entry .time { font-weight: 800; font-variant-numeric: tabular-nums; width: 46px; flex: none; }
.entry .ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-size: 19px; flex: none; }
.entry.feed .ico { background: var(--mme-soft); }
.entry.diaper .ico { background: var(--pee-soft); }
.entry.diaper.poop .ico { background: var(--poop-soft); }
.entry.pump .ico { background: var(--pump-soft); }
.entry .what { flex: 1; min-width: 0; }
.entry .main { font-weight: 700; }
.entry .note { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 13px; font-weight: 700; margin-right: 4px; }
.tag.mm { background: var(--mm-soft); }
.tag.mme { background: var(--mme-soft); }
.tag.pee { background: var(--pee-soft); }
.tag.poop { background: var(--poop-soft); }
.tag.pump { background: var(--pump-soft); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.bottom-space { height: calc(110px + env(safe-area-inset-bottom)); }

/* ---------- hurtigknapper ---------- */
.action-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
@media (min-width: 700px) {
  .action-bar { left: 50%; transform: translateX(-50%); max-width: 640px; border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0; }
}
.act {
  border: 0; border-radius: 18px; padding: 10px 6px; font-weight: 800; font-size: 15px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: var(--shadow);
  color: var(--ink);
}
.act .emo { font-size: 24px; }
.act.feed { background: var(--mme-soft); }
.act.diaper { background: var(--pee-soft); }
.act.pump { background: var(--pump-soft); }
.act:active { transform: scale(.97); }

/* ---------- ark (skjema) ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(20, 40, 70, .35); z-index: 20; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 21;
  background: var(--card); border-radius: 26px 26px 0 0;
  padding: 10px 18px calc(18px + env(safe-area-inset-bottom));
  max-height: 92vh; overflow-y: auto; box-shadow: 0 -10px 30px rgba(0,0,0,.15);
  animation: up .18s ease-out;
}
@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: 480px; border-radius: 26px; animation: none; }
}
@keyframes up { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
.grip { width: 44px; height: 5px; border-radius: 9px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { margin: 0 0 14px; font-size: 21px; }
.field { margin-bottom: 14px; }
.field > label, .field > .lab { display: block; font-size: 13px; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.timechips { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.chip {
  border: 0; background: var(--bg); border-radius: 99px; padding: 7px 12px; font-size: 14px; font-weight: 700;
}
.chip.on { background: var(--primary); color: var(--primary-ink); }
.amount { display: flex; align-items: center; gap: 8px; }
.amount input { text-align: center; font-size: 22px; font-weight: 800; padding: 10px 6px; }
.amount .step { flex: none; width: 50px; height: 50px; border-radius: 14px; border: 0; background: var(--bg); font-size: 24px; font-weight: 800; color: var(--primary); }
.amount .unit { font-weight: 700; color: var(--muted); }
.mlchips { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; padding-bottom: 2px; }
.mlchips .chip { flex: none; }
.milk-block { border-radius: 18px; padding: 12px; margin-bottom: 12px; }
.milk-block.mm { background: var(--mm-soft); }
.milk-block.mme { background: var(--mme-soft); }
.milk-block .lab { font-weight: 800; margin-bottom: 8px; display: block; }
.milk-block input, .milk-block .step, .milk-block .chip { background: var(--card); }
.toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.toggle {
  border: 3px solid transparent; border-radius: 18px; padding: 16px 8px; font-weight: 800; font-size: 17px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; background: var(--bg);
}
.toggle .emo { font-size: 30px; }
.toggle.pee.on { background: var(--pee-soft); border-color: var(--pee); }
.toggle.poop.on { background: var(--poop-soft); border-color: var(--poop); }
.sheet-actions { display: grid; grid-template-columns: 1fr 2fr; gap: 10px; margin-top: 6px; }
.sheet-actions.three { grid-template-columns: 1fr 1fr 2fr; }
.total-line { font-size: 14px; font-weight: 700; color: var(--muted); margin: -4px 0 12px; }
.total-line b { color: var(--ink); }
.goal-row { display: grid; grid-template-columns: 1fr 100px 44px; gap: 8px; margin-bottom: 8px; align-items: center; }
.goal-row button { height: 44px; border: 0; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-weight: 800; }
.sect { font-weight: 800; margin: 18px 0 8px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 99px; font-weight: 700;
  opacity: 0; transition: .2s; pointer-events: none; z-index: 30; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 380px) {
  .next-card .big { font-size: 20px; }
  .stat .n { font-size: 19px; }
}

/* ---------- kvarter-velger ---------- */
.timesel { display: flex; align-items: center; gap: 4px; }
.timesel select {
  appearance: none; -webkit-appearance: none; text-align: center; text-align-last: center;
  font-size: 20px; font-weight: 800; padding: 10px 4px; min-width: 0;
}
.timesel .colon { font-weight: 800; font-size: 20px; color: var(--muted); }
.row2.timerow { grid-template-columns: 1.1fr 1fr; }

/* ---------- toppknapper og vekt ---------- */
.top-btns { display: flex; gap: 8px; align-items: center; }
.icon-btn.pill { width: auto; padding: 0 14px; border-radius: 99px; font-size: 16px; font-weight: 800; gap: 6px; display: flex; color: var(--ink); }
.nav-spacer { width: 44px; flex: none; }
.chart-card { background: var(--card); border-radius: 18px; padding: 14px 14px 8px; margin-top: 10px; box-shadow: var(--shadow); }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 6px; }
#weightChart svg { width: 100%; height: auto; display: block; overflow: visible; }
#weightChart .grid { stroke: var(--line); stroke-width: 1; }
#weightChart .axis { fill: var(--muted); font-size: 11px; font-weight: 600; font-family: inherit; }
#weightChart .line { fill: none; stroke: var(--primary); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
#weightChart .area { fill: var(--primary-soft); opacity: .55; }
#weightChart .pt { fill: var(--primary); stroke: var(--card); stroke-width: 2; }
#weightChart .pt.sel { fill: var(--ink); }
#weightChart .hit { fill: transparent; cursor: pointer; }
#weightChart .lbl { fill: var(--ink); font-size: 12px; font-weight: 800; font-family: inherit; }
.add-weight { margin-top: 12px; }
.entry.weight .ico { background: var(--primary-soft); }
.tag.weight { background: var(--primary-soft); }
.delta-up { color: var(--ok); } .delta-down { color: var(--warn); }
.small-space { height: 30px; }
