:root {
  --bg: #f3efe4;
  --card: #fbf9f3;
  --ink: #2c3020;
  --muted: #736d5a;
  --line: #e3dccb;
  --olive: #5f6f2e;
  --olive-d: #44511f;
  --olive-l: #e2e6cc;
  --brown: #7a5634;
  --brown-l: #efe3d1;
  --warn: #b0502a;
  --warn-l: #f7e1d4;
  --on-olive: #fbf9f3;
  --shadow: 0 1px 2px rgba(60, 50, 20, .06), 0 4px 14px rgba(60, 50, 20, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1b14;
    --card: #24261c;
    --ink: #ece8da;
    --muted: #a5a08b;
    --line: #353729;
    --olive: #a4b56b;
    --olive-d: #c4d38d;
    --olive-l: #323920;
    --brown: #cc9f72;
    --brown-l: #3a2f22;
    --warn: #e78c62;
    --warn-l: #40271c;
    --on-olive: #1a1b14;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  margin: 0 auto;
  max-width: 560px;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  padding: env(safe-area-inset-top) 16px calc(84px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
h1, h2, h3, .serif { font-family: "Fraunces", Georgia, serif; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 28px; margin: 0; }
h2 { font-size: 20px; margin: 26px 2px 10px; }
h3 { font-size: 16px; margin: 0; }
.muted { color: var(--muted); }
p { margin: 0; }
button { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* header */
.top { display: flex; align-items: center; justify-content: space-between; padding: 16px 2px 8px; }
.top p { font-size: 14px; margin-top: 2px; }
.sync { width: 10px; height: 10px; border-radius: 50%; background: var(--olive); opacity: .7; }
.sync.off { background: var(--warn); opacity: 1; }
.offline-note { font-size: 13px; color: var(--warn); background: var(--warn-l); border-radius: 12px; padding: 8px 12px; margin-bottom: 12px; }

/* cards */
.card { background: var(--card); border-radius: 22px; padding: 18px; box-shadow: var(--shadow); border: 1px solid var(--line); margin-bottom: 12px; }

/* feed hero */
.feed { display: grid; grid-template-columns: 108px 1fr; gap: 18px; align-items: center; }
.ring { position: relative; width: 108px; height: 108px; }
.ring svg { width: 108px; height: 108px; transform: rotate(-90deg); stroke-width: 9; }
.ring .track { stroke: var(--olive-l); }
.ring .prog { stroke: var(--olive); transition: stroke-dashoffset .6s; }
.ring.late .prog { stroke: var(--warn); }
.ring.brown .track { stroke: var(--brown-l); }
.ring.brown .prog { stroke: var(--brown); }
.ring.brown .ico { color: var(--brown); }
.ring.asleep .prog { animation: breathe 3.5s ease-in-out infinite; }
@keyframes breathe { 50% { opacity: .45; } }
.btn.brown-solid { background: var(--brown); color: var(--on-olive); }
.sleep .ico.olive { background: var(--olive-l); color: var(--olive-d); }
.ring .ico { position: absolute; inset: 0; display: grid; place-items: center; color: var(--olive); }
.ring.late .ico { color: var(--warn); }
.ring .ico svg { width: 34px; height: 34px; transform: none; stroke-width: 1.7; }
.feed .label { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.feed .big { font-family: "Fraunces", Georgia, serif; font-size: 32px; white-space: nowrap; line-height: 1.1; font-weight: 600; margin: 2px 0; }
.feed .big.late { color: var(--warn); }
.feed .sub { font-size: 14px; color: var(--muted); }
.upcoming { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; align-items: center; }
.upcoming span { font-size: 13px; }
.pill { background: var(--olive-l); color: var(--olive-d); border-radius: 999px; padding: 4px 10px; font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; border: 0; border-radius: 16px; padding: 15px 16px; font-weight: 600; font-size: 17px; background: var(--olive); color: var(--on-olive); cursor: pointer; }
.btn:active { transform: scale(.98); }
.btn.ghost { background: var(--olive-l); color: var(--olive-d); }
.btn.brown { background: var(--brown-l); color: var(--brown); }
.btn.danger { background: var(--warn-l); color: var(--warn); }
.btn.small { padding: 10px 14px; font-size: 15px; width: auto; border-radius: 12px; }
.feed-btn { margin-top: 14px; }

/* sleep */
.sleep { display: flex; align-items: center; gap: 14px; }
.sleep .ico { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--brown-l); color: var(--brown); }
.sleep .txt { flex: 1; min-width: 0; }
.sleep .txt b { display: block; font-size: 17px; }
.sleep .txt span { font-size: 14px; color: var(--muted); }

/* quick grid */
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 4px 11px; border-radius: 18px; border: 1px solid var(--line); background: var(--card); font-size: 12.5px; font-weight: 600; color: var(--ink); cursor: pointer; box-shadow: var(--shadow); }
.quick:active { transform: scale(.96); }
.quick .i { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--olive-l); color: var(--olive-d); }
.quick.b .i { background: var(--brown-l); color: var(--brown); }

/* stats */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 12px 14px; box-shadow: var(--shadow); }
.stat small { display: block; font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat b { font-family: "Fraunces", Georgia, serif; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat span { font-size: 13px; color: var(--muted); }
.stat.warn b { color: var(--warn); }

/* event list */
.list { background: var(--card); border: 1px solid var(--line); border-radius: 20px; overflow: hidden; box-shadow: var(--shadow); }
.ev { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; }
.ev:last-child { border-bottom: 0; }
.ev:active { background: var(--olive-l); }
.ev .i { width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; background: var(--olive-l); color: var(--olive-d); flex: none; }
.ev .i.b { background: var(--brown-l); color: var(--brown); }
.ev .i.w { background: var(--warn-l); color: var(--warn); }
.ev .i svg { width: 19px; height: 19px; }
.ev .m { flex: 1; min-width: 0; }
.ev .m b { display: block; font-weight: 600; }
.ev .m span { font-size: 13px; color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev time { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--muted); font-size: 15px; }
.empty { padding: 22px; text-align: center; color: var(--muted); font-size: 15px; }
.dayhead { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 4px 8px; gap: 10px; }
.dayhead h3 { font-size: 17px; }
.dayhead span { font-size: 13px; color: var(--muted); text-align: right; }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 999px; padding: 8px 14px; font-size: 15px; font-weight: 500; cursor: pointer; }
.chip.on { background: var(--olive); border-color: var(--olive); color: var(--on-olive); font-weight: 600; }
.filter { overflow-x: auto; flex-wrap: nowrap; margin: 4px -16px 0; padding: 4px 16px; scrollbar-width: none; }
.filter::-webkit-scrollbar { display: none; }
.filter .chip { flex: none; }

/* sheet */
.sheet-wrap { position: fixed; inset: 0; z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet-wrap[hidden] { display: none; }
.scrim { position: absolute; inset: 0; background: rgba(20, 18, 10, .45); animation: fade .2s; }
.sheet { position: relative; width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; background: var(--bg); border-radius: 26px 26px 0 0; padding: 10px 16px calc(18px + env(safe-area-inset-bottom)); animation: up .25s cubic-bezier(.2, .9, .3, 1); }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet .head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.sheet .head .i { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: var(--olive-l); color: var(--olive-d); }
.sheet .head h2 { margin: 0; flex: 1; }
.x { border: 0; background: var(--card); width: 36px; height: 36px; border-radius: 50%; font-size: 20px; color: var(--muted); cursor: pointer; }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 0 2px 6px; text-transform: uppercase; letter-spacing: .05em; }
input, textarea, select { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; width: 100%; font-size: 17px; }
input:focus, textarea:focus { outline: 2px solid var(--olive); outline-offset: -1px; }
textarea { min-height: 70px; resize: vertical; }
.numrow { display: flex; align-items: center; gap: 8px; }
.numrow input { text-align: center; font-family: "Fraunces", Georgia, serif; font-size: 28px; font-weight: 600; padding: 8px; flex: 1; min-width: 0; }
.numrow em { font-style: normal; color: var(--muted); font-weight: 600; width: 58px; }
.step { width: 54px; height: 54px; border-radius: 16px; border: 0; background: var(--olive-l); color: var(--olive-d); font-size: 26px; font-weight: 600; cursor: pointer; flex: none; }
.timequick { margin-top: 8px; }
.only-amning, .only-poo { display: none; }
.sheet[data-kind="amning"] .only-amning { display: block; }
.sheet[data-kind="amning"] .no-amning { display: none; }
.sheet[data-poo="1"] .only-poo { display: block; }
.row2 { display: flex; gap: 8px; margin-top: 6px; }
.row2 .btn { flex: 1; }

/* charts */
.chart svg { width: 100%; height: auto; stroke-width: 1; }
.chart .ln { stroke: var(--olive); stroke-width: 2.2; fill: none; }
.chart .dot { fill: var(--olive); stroke: var(--card); stroke-width: 1.5; }
.chart .dot.w { fill: var(--warn); }
.chart .band { fill: var(--olive-l); stroke: none; opacity: .7; }
.chart .lim { stroke: var(--warn); stroke-dasharray: 4 4; stroke-width: 1.2; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart text { fill: var(--muted); stroke: none; font-size: 10.5px; font-family: -apple-system, system-ui, sans-serif; }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.chart-head b { font-family: "Fraunces", Georgia, serif; font-size: 26px; }
.chart-head b.w { color: var(--warn); }

/* settings */
.set-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.linkbox { font-size: 13px; word-break: break-all; background: var(--olive-l); color: var(--olive-d); padding: 10px 12px; border-radius: 12px; margin: 8px 0 10px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }

/* tabs */
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: flex; justify-content: center; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
.tabs a { flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); text-decoration: none; padding: 4px 0; }
.tabs a.on { color: var(--olive-d); }

/* toast */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 30; background: var(--ink); color: var(--bg); padding: 10px 10px 10px 16px; border-radius: 14px; display: flex; gap: 14px; align-items: center; font-size: 15px; box-shadow: 0 6px 24px rgba(0,0,0,.2); animation: up .2s; white-space: nowrap; }
.toast[hidden] { display: none; }
.toast button { border: 0; background: transparent; color: var(--olive-l); font-weight: 700; padding: 4px 8px; cursor: pointer; }

.lock { text-align: center; padding: 60px 10px; }
.lock p { margin: 10px 0 20px; }

@keyframes up { from { transform: translateY(30px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
@media (max-width: 370px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
  .feed { grid-template-columns: 88px 1fr; }
  .ring, .ring svg { width: 88px; height: 88px; }
  .feed .big { font-size: 28px; }
}

/* iOS Safari gives date inputs an intrinsic width and centred text — tame it */
input[type="datetime-local"] { -webkit-appearance: none; appearance: none; display: block; min-width: 0; max-width: 100%; min-height: 50px; text-align: left; }
input[type="datetime-local"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
.pill.b { background: var(--brown-l); color: var(--brown); }

.weigh { border-top: 1px solid var(--line); padding-top: 14px; margin-bottom: 4px; }
.weigh-title { font-family: "Fraunces", Georgia, serif; font-weight: 600; font-size: 17px; margin: 0 2px 12px; }
.weigh-title .muted { font-family: -apple-system, system-ui, sans-serif; font-weight: 400; font-size: 14px; }
.weigh-diff { font-size: 14px; color: var(--muted); background: var(--olive-l); border-radius: 12px; padding: 10px 12px; margin: -4px 0 16px; }
.weigh-diff.has { color: var(--olive-d); font-size: 16px; }
.weigh-diff b { font-family: "Fraunces", Georgia, serif; font-size: 22px; }
