/* Bacon Care Log */
:root {
  /* Headspace-inspired: warm off-white, friendly orange, pastel tiles */
  --bg: #fffaf5;
  --card: #ffffff;
  --ink: #2d2a3e;
  --muted: #75718a;
  --line: #f0e8e0;
  --line-strong: #e6dbd0;
  --input-line: #e2d7cc;
  --soft: #f7f0e9;
  --accent: #f47d31;
  --accent-2: #ff9b54;
  --accent-3: #e8601c;
  --accent-ink: #ffffff;
  --accent-soft: #ffe8d9;
  --t-orange: #ffe3d1;
  --t-yellow: #fff0c4;
  --t-blue: #dde9ff;
  --t-purple: #ece6ff;
  --t-green: #dcf3e7;
  --t-pink: #ffe2ea;
  --hero-1: #ffa462;
  --hero-2: #f47d31;
  --good: #2f9e6a;
  --good-soft: #dcf3e7;
  --warn: #b97500;
  --warn-soft: #fff0c4;
  --bad: #de4049;
  --bad-soft: #ffe2e4;
  --blue: #4a7be8;
  --radius: 24px;
  --shadow: 0 4px 18px rgba(45, 42, 62, .06);
  --shadow-lg: 0 10px 34px rgba(45, 42, 62, .16);
  color-scheme: light;
}
/* Night mode (9pm–6am automatically, or via the 🌙 button): deep indigo, like a sleep screen */
:root.night {
  --bg: #1b1a3a;
  --card: #25244d;
  --ink: #f4f1ff;
  --muted: #aaa6d1;
  --line: #33326a;
  --line-strong: #403f7c;
  --input-line: #4b4a8a;
  --soft: #2d2c5c;
  --accent: #ff9b5c;
  --accent-2: #ffb47e;
  --accent-3: #f47d31;
  --accent-ink: #1b1a3a;
  --accent-soft: #3f3058;
  --t-orange: #3f3058;
  --t-yellow: #3a3654;
  --t-blue: #2b3468;
  --t-purple: #35306c;
  --t-green: #233f4e;
  --t-pink: #3e2c58;
  --hero-1: #4b44a6;
  --hero-2: #2b2768;
  --good: #72d9a4;
  --good-soft: #233f4e;
  --warn: #ffcb62;
  --warn-soft: #3a3654;
  --bad: #ff8088;
  --bad-soft: #4a2a48;
  --blue: #9bb8ff;
  --shadow: none;
  --shadow-lg: 0 10px 34px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.6rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; }
h3 { font-size: 1.1rem; }
.muted { color: var(--muted); }
.small, small { font-size: .82rem; }
.hint { color: var(--muted); font-size: .85rem; margin: .25rem 0 .75rem; }
.wrap { max-width: 980px; margin: 0 auto; padding: 12px 16px 24px; }

/* top + tab bars */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 16px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; text-decoration: none; color: var(--ink); font-size: 1.1rem; }
.topnav { display: none; gap: 4px; flex: 1; }
.topnav a { text-decoration: none; color: var(--muted); padding: 6px 12px; border-radius: 999px; }
.topnav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.who { margin-left: auto; color: var(--muted); font-size: .85rem; }
.reload {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--card);
  color: var(--ink); font-size: 1.25rem; line-height: 1; cursor: pointer; display: grid; place-items: center;
}
.reload.spin { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
/* pull-to-refresh indicator */
.ptr {
  position: fixed; top: calc(8px + env(safe-area-inset-top)); left: 50%; z-index: 40;
  width: 40px; height: 40px; margin-left: -20px; border-radius: 50%;
  background: var(--card); border: 1px solid var(--line); box-shadow: var(--shadow);
  display: grid; place-items: center; font-size: 1.3rem; color: var(--accent);
  transform: translateY(-70px); opacity: 0; pointer-events: none;
}
.ptr.ready { color: var(--accent-ink); background: var(--accent); }
.ptr.spin { transform: translateY(40px); opacity: 1; animation: spin .8s linear infinite; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .72rem; padding: 4px 0;
}
.tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabbar a:last-child svg { fill: currentColor; stroke: none; }
.tabbar a.on { color: var(--accent); font-weight: 600; }
@media (min-width: 820px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  body { padding-bottom: 24px; }
}

/* cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin: 14px 0; box-shadow: var(--shadow);
}
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.flash { background: var(--good-soft); color: var(--good); padding: 10px 14px; border-radius: 12px; margin: 10px 0; font-weight: 500; }
.flash.err { background: var(--bad-soft); color: var(--bad); }

/* forms */
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--bg);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
textarea { resize: vertical; }
label { display: block; font-size: .85rem; color: var(--muted); }
label > input, label > select, label > textarea, label > .row { margin-top: 4px; color: var(--ink); }
.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > input { flex: 1; }
.row.end { justify-content: flex-end; flex-wrap: wrap; }
.row.end .muted { margin-right: auto; }
.w-s { max-width: 90px; }
.center { text-align: center; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-bottom: 12px; }
.fgrid .full { grid-column: 1 / -1; }
@media (min-width: 640px) { .fgrid { grid-template-columns: repeat(3, 1fr); } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer; text-decoration: none; color: var(--ink); font-weight: 600;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: var(--bad-soft); background: transparent; }
.btn:disabled { opacity: .55; }
.link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 4px; font-size: .9rem; text-decoration: none; }

/* segmented + chips */
.seg { display: inline-flex; flex-wrap: wrap; background: var(--soft); border-radius: 12px; padding: 3px; gap: 2px; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 8px 12px; border-radius: 9px; color: var(--muted); cursor: pointer; font-size: .88rem; }
.seg input:checked + span { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.seg.small span { padding: 5px 14px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { margin: 0; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: .85rem; color: var(--ink); cursor: pointer; }
.chip input:checked + span { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip input:focus-visible + span { outline: 2px solid var(--accent); }
.chipbtn { padding: 10px 16px; min-width: 52px; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); cursor: pointer; font-weight: 600; }
.chipbtn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chips.big { gap: 8px; }

/* day header + stats */
.dayhead { display: flex; align-items: center; gap: 10px; margin: 6px 0 10px; }
.daytitle { flex: 1; text-align: center; }
.navbtn {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: var(--card); border: 1px solid var(--line); text-decoration: none; color: var(--ink); font-size: 1.5rem;
}
.navbtn.ghost { visibility: hidden; }
.datepick { position: relative; display: inline-block; overflow: hidden; color: var(--muted); font-size: .9rem; cursor: pointer; }
/* iPhone gives date inputs a minimum width, so the invisible picker could spill over the › button; keep it inside the label */
.datepick input { position: absolute; inset: 0; opacity: 0; width: 100%; min-width: 0; max-width: 100%; -webkit-appearance: none; appearance: none; cursor: pointer; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 640px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; }
.stat .k { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: .8rem; font-weight: 500; color: var(--muted); margin-left: 2px; }
.stat .s { font-size: .78rem; color: var(--muted); }

.pcvstat { gap: 2px; }
.wchg.down { color: var(--bad); font-weight: 600; }
.wchg.up { color: var(--good); font-weight: 600; }
.qhead { font-size: .9rem; margin: 16px 0 8px; }
.qhead.rare { color: var(--warn); }
.qhead.severe { color: var(--bad); }
.minis { display: flex; flex-wrap: wrap; gap: 6px; }
.mini {
  position: relative; padding: 7px 12px; min-height: 36px; border-radius: 999px; cursor: pointer;
  font-size: .82rem; font-weight: 600; background: var(--bg); border: 1px solid var(--line); color: var(--ink);
  touch-action: manipulation; -webkit-user-select: none; user-select: none;
}
.minis.rare .mini { border-color: color-mix(in srgb, var(--warn) 45%, var(--line)); }
.minis.severe .mini { border-color: color-mix(in srgb, var(--bad) 55%, var(--line)); color: var(--bad); }
.mini .qc {
  margin-left: 6px; display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-size: .7rem;
}
.mini .qc:empty { display: none; }
.minis.severe .mini .qc { background: var(--bad); color: #fff; }
.alertcard { border-width: 2px; }
.alertcard.severe { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.alertcard.rare { border-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.pcvrow { display: grid; grid-template-columns: 1fr auto 44px; gap: 6px; align-items: baseline; font-size: .85rem; }
.pcvrow b { font-variant-numeric: tabular-nums; font-size: 1rem; }
.pcvrow small { color: var(--muted); text-align: right; font-size: .72rem; }
.plans { background: var(--warn-soft); border-color: transparent; }

/* daily quote */
.quote {
  position: relative; margin: 14px 0; padding: 16px 18px 16px 52px;
  background: linear-gradient(135deg, var(--accent-soft), var(--card));
  border: 1px solid var(--line); border-radius: var(--radius);
}
.quote .q-mark {
  position: absolute; left: 14px; top: 2px; font-size: 3.4rem; line-height: 1;
  color: var(--accent); font-family: Georgia, "Times New Roman", serif; opacity: .7;
}
.quote blockquote { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: 1.05rem; font-style: italic; line-height: 1.45; }
.plans ul { margin: 6px 0 0; padding-left: 20px; }

/* quick log */
.timechip { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: .9rem; }
.timechip.set { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); font-weight: 600; }
.qgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (min-width: 560px) { .qgrid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 820px) { .qgrid { grid-template-columns: repeat(6, 1fr); } }
.qbtn {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 82px; padding: 10px 6px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--bg); cursor: pointer; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: manipulation; transition: transform .12s;
}
.qbtn:active, .qbtn.pop { transform: scale(.94); }
.qbtn .qi { font-size: 1.6rem; line-height: 1; }
.qbtn .ql { font-size: .82rem; font-weight: 600; text-align: center; }
.qbtn .qs { font-size: .72rem; color: var(--muted); }
.qbtn .qc {
  position: absolute; top: 6px; right: 6px; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: .75rem; font-weight: 700;
  display: grid; place-items: center;
}
.qbtn .qc:empty { display: none; }
.qbtn.concern { border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.qbtn.special { background: var(--soft); }
.qbtn.asleep { background: var(--accent-soft); border-color: var(--accent); }

/* meds */
.medlist { list-style: none; margin: 0; padding: 0; }
.medlist li { padding: 10px 0; border-top: 1px solid var(--line); }
.medlist li:first-child { border-top: 0; padding-top: 0; }
.med-name { margin-bottom: 6px; }
.slots { display: flex; flex-wrap: wrap; gap: 6px; }
.slot {
  display: inline-flex; flex-direction: column; align-items: center; line-height: 1.1;
  min-height: 40px; min-width: 70px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); cursor: pointer; font-size: .85rem; font-weight: 600;
}
.slot small { font-weight: 400; font-size: .7rem; opacity: .8; }
.slot.done { background: var(--good-soft); color: var(--good); border-color: transparent; }
.slot.due { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }
.slot.missed { border-color: var(--bad); color: var(--bad); }
.slot.later { color: var(--muted); }
.slot.add { border-style: dashed; color: var(--muted); font-weight: 500; }

/* symptom grid */
.gridwrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.grid { width: 100%; border-collapse: collapse; font-size: .85rem; min-width: 520px; }
.grid th, .grid td { border-bottom: 1px solid var(--line); padding: 6px 6px; text-align: left; vertical-align: top; }
.grid thead th { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; font-weight: 600; }
.grid tbody th { white-space: nowrap; font-weight: 600; }
.grid .ic { display: inline-block; width: 1.4em; }
.grid tr.zero th { color: var(--muted); font-weight: 500; }
.grid .tally { font-weight: 700; letter-spacing: 2px; color: var(--accent); display: block; }
.grid td small { color: var(--muted); display: block; line-height: 1.25; }
.grid .tot { font-weight: 700; text-align: center; }
.grid tr.concern:not(.zero) th { color: var(--bad); }

/* timeline */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 62px 26px 1fr auto; gap: 6px; align-items: start; padding: 9px 0; border-top: 1px solid var(--line); }
.timeline li:first-child { border-top: 0; }
.timeline time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; padding-top: 1px; }
.tl-ic { text-align: center; }
.tl-body { min-width: 0; overflow-wrap: anywhere; }
.tl-note { color: var(--muted); font-size: .88rem; margin-top: 2px; }
.by { display: inline-block; font-size: .72rem; color: var(--muted); background: var(--soft); border-radius: 6px; padding: 0 6px; margin-top: 3px; }
.timeline .x { border: 0; background: none; color: var(--muted); font-size: 1.3rem; width: 36px; height: 32px; cursor: pointer; border-radius: 8px; }
.timeline .x:hover { background: var(--bad-soft); color: var(--bad); }
.timeline li.note-concern .tl-text { color: var(--bad); font-weight: 600; }
.timeline li.note-plan .tl-text { color: var(--warn); font-weight: 600; }
.timeline li.visit { background: var(--accent-soft); border-radius: 10px; padding-left: 6px; padding-right: 6px; border-top-color: transparent; }
.timeline li.visit a { font-weight: 600; color: var(--ink); }
.empty { padding: 10px 0; }
.tl-actions { display: flex; align-items: start; }
.edit-meal { border: 0; background: none; color: var(--muted); font-size: 1.05rem; width: 36px; height: 32px; cursor: pointer; border-radius: 8px; }
.edit-meal:hover { background: var(--soft); color: var(--accent); }
.meallist { list-style: none; margin: 0 0 4px; padding: 0; }
.meallist li { display: grid; grid-template-columns: 62px 1fr auto 36px; gap: 6px; align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); }
.meallist time { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.ml-food small { display: block; font-size: .8rem; }
.ml-meds { display: block; font-size: .8rem; color: var(--good); }
.ml-g { font-weight: 600; font-variant-numeric: tabular-nums; }

.redflags summary { cursor: pointer; list-style: none; }
.redflags summary::-webkit-details-marker { display: none; }
.redflags summary h2 { display: inline; }
.redflags .prose { margin-top: 10px; }

/* dialogs */
dialog.sheet {
  border: 0; border-radius: 20px; padding: 20px; width: min(520px, calc(100vw - 24px));
  background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(20, 14, 8, .45); }
@media (max-width: 560px) {
  dialog.sheet { margin: auto auto 0; width: 100%; max-width: 100%; border-radius: 20px 20px 0 0; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
}
.rr-tap {
  width: 100%; min-height: 160px; border-radius: 20px; border: 0; background: var(--accent); color: var(--accent-ink);
  font-size: 1.6rem; font-weight: 700; cursor: pointer; touch-action: manipulation; margin: 8px 0;
}
.rr-tap:active { transform: scale(.98); }
.rr-tap:disabled { background: var(--good); }
.rr-read { font-variant-numeric: tabular-nums; color: var(--muted); }
.rr-result { font-size: 1.4rem; margin: 8px 0; }
.rr-result b { font-size: 2.4rem; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(86px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 12px; display: flex; gap: 12px; align-items: center;
  opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: calc(100vw - 32px); font-size: .92rem;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast.err { background: var(--bad); color: #fff; }
.toast button { background: none; border: 0; color: var(--accent); font-weight: 700; cursor: pointer; padding: 4px; }

/* generic lists / tables */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 12px 0; border-top: 1px solid var(--line); }
.list > li:first-child { border-top: 0; }
.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th, .tbl td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl th { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.tbl td.num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll-x { overflow-x: auto; }
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--soft); color: var(--muted); }
.badge.tap { background: var(--accent); color: var(--accent-ink); }
.badge.bill { background: var(--warn-soft); color: var(--warn); }
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0 4px; flex-wrap: wrap; }

/* visits */
.visit-card h3 { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.fluids { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.fluid { background: var(--soft); border-radius: 10px; padding: 6px 10px; font-size: .85rem; }
.fluid b { font-size: 1.05rem; }
.sitegrid { display: grid; grid-template-columns: max-content 1fr 1fr; gap: 6px 10px; align-items: center; max-width: 520px; }
.prose { white-space: normal; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }

/* files */
.fgallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.fgroup { grid-column: 1 / -1; margin: 10px 0 0; font-size: 1rem; }
.fitem { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; text-decoration: none; color: var(--ink); }
.fthumb { aspect-ratio: 4 / 3; background: var(--soft); display: grid; place-items: center; font-size: 2.2rem; overflow: hidden; }
.fthumb img { width: 100%; height: 100%; object-fit: cover; }
.fmeta { padding: 8px 10px; font-size: .82rem; }
.fmeta b { display: block; font-size: .88rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* file viewer */
.viewer-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 6px 0 10px; }
.viewer-nav { display: flex; gap: 8px; }
.viewer { background: #111; border-radius: var(--radius); overflow: hidden; display: grid; place-items: center; min-height: 200px; }
.viewer img, .viewer video { display: block; max-width: 100%; max-height: 75vh; height: auto; }
.viewer .pdfpages { width: 100%; background: var(--soft); padding: 8px; }
.viewer .pdfpages canvas { display: block; margin: 0 auto 8px; background: #fff; box-shadow: var(--shadow); }
.viewer .card { margin: 16px; }

/* trends */
.chartbox { position: relative; height: 240px; }
.chartgrid { display: grid; gap: 14px; }
@media (min-width: 900px) { .chartgrid { grid-template-columns: 1fr 1fr; } }
.chartgrid .card { margin: 0; }

/* more page */
.menu { list-style: none; margin: 0; padding: 0; }
.menu a { display: flex; align-items: center; gap: 12px; padding: 14px 4px; border-top: 1px solid var(--line); text-decoration: none; color: var(--ink); font-weight: 500; }
.menu li:first-child a { border-top: 0; }
.menu .mi { font-size: 1.3rem; width: 30px; text-align: center; }
.menu small { display: block; color: var(--muted); font-weight: 400; }

/* login */
.login { max-width: 380px; margin: 12vh auto 0; }
.login h1 { text-align: center; margin-bottom: 14px; }

/* ================================================================
   Headspace-inspired theme (layered over the base styles above)
   ================================================================ */
body { font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; background: var(--bg); transition: background .3s; }
h1 { font-size: 1.85rem; font-weight: 900; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 800; }
h3 { font-weight: 800; }
b, strong { font-weight: 800; }
a { color: var(--accent); }
.link { color: var(--accent); font-weight: 800; text-decoration: none; }
.hint { color: var(--muted); }
.wrap { padding: 4px 18px 32px; }

/* header */
.topbar { background: color-mix(in srgb, var(--bg) 90%, transparent); border-bottom: 0; padding-top: calc(10px + env(safe-area-inset-top)); gap: 10px; }
.brand { color: var(--ink); font-weight: 900; font-size: 1.25rem; }
.topnav a { color: var(--muted); font-weight: 700; border-radius: 999px; padding: 8px 14px; }
.topnav a.on { background: var(--accent-soft); color: var(--accent); }
.who { font-weight: 700; }
.reload { border: 0; background: var(--soft); width: 40px; height: 40px; font-size: 1.1rem; }

/* bottom tabs: active icon sits in a soft pill */
.tabbar { background: var(--card); border-top: 0; box-shadow: 0 -6px 24px rgba(45, 42, 62, .06); padding-top: 8px; }
.tabbar a { font-weight: 700; font-size: .7rem; color: var(--muted); }
.tabbar svg { width: 24px; height: 24px; padding: 4px 16px; box-sizing: content-box; border-radius: 999px; stroke-width: 2.1; transition: background .2s; }
.tabbar a.on { color: var(--accent); }
.tabbar a.on svg { background: var(--accent-soft); }

/* cards: no borders, rounder, softer */
.card { border: 0; border-radius: var(--radius); padding: 20px; margin: 14px 0; box-shadow: var(--shadow); background: var(--card); }
.flash { border-radius: 18px; font-weight: 700; }

/* buttons: big friendly pills */
.btn { border-radius: 999px; border: 0; background: var(--soft); color: var(--ink); font-weight: 800; padding: 12px 22px; min-height: 48px; transition: transform .12s, filter .2s; }
.btn:hover { filter: brightness(.97); }
.btn:active { transform: scale(.96); }
.btn.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.ghost { background: transparent; color: var(--accent); }
.btn.danger { background: var(--bad-soft); color: var(--bad); }

/* inputs: soft filled fields */
input:not([type=checkbox]):not([type=radio]), select, textarea { border: 2px solid transparent; background: var(--soft); border-radius: 16px; min-height: 50px; padding: 12px 16px; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); background: var(--card); box-shadow: none; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .8; }
label { color: var(--ink); font-weight: 700; font-size: .85rem; }
label small { color: var(--muted); font-weight: 600; }

/* pills */
.chip span { border: 0; background: var(--soft); padding: 9px 15px; font-weight: 700; color: var(--ink); }
.chip input:checked + span { background: var(--accent); color: var(--accent-ink); box-shadow: none; }
.chipbtn { border: 0; background: var(--soft); font-weight: 800; padding: 11px 18px; }
.chipbtn.on { background: var(--accent); color: var(--accent-ink); }
.seg { background: var(--soft); border-radius: 999px; padding: 4px; }
.seg span { border-radius: 999px; font-weight: 700; }
.seg input:checked + span { background: var(--card); color: var(--accent); box-shadow: 0 2px 8px rgba(45, 42, 62, .1); }
.badge { background: var(--soft); color: var(--ink); font-weight: 800; border-radius: 999px; padding: 3px 10px; }
.badge.tap { background: var(--accent); color: var(--accent-ink); }
.by { background: var(--soft); border-radius: 999px; padding: 1px 9px; font-weight: 700; }

/* ---------- Today: greeting, hero check-in, progress ---------- */
.greet { margin: 10px 2px 12px; }
.hello { margin: 0 0 4px; color: var(--muted); font-weight: 800; font-size: .95rem; }
.daynav { display: flex; align-items: center; gap: 10px; }
.daynav .navbtn { position: relative; z-index: 2; flex: none; width: 36px; height: 36px; font-size: 1.2rem; border: 0; background: var(--soft); }
.datepick { color: var(--ink); font-weight: 900; font-size: 1.35rem; text-decoration: none; }
.hero {
  position: relative; overflow: hidden; border-radius: 32px; padding: 22px 20px 18px;
  background: radial-gradient(120% 140% at 100% 0%, var(--hero-1) 0%, var(--hero-2) 70%);
  color: #fff; box-shadow: 0 12px 30px color-mix(in srgb, var(--hero-2) 35%, transparent);
}
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; background: rgba(255, 255, 255, .12); }
.hero::before { width: 180px; height: 180px; right: -50px; bottom: -70px; }
.hero::after { width: 90px; height: 90px; left: -30px; top: -35px; }
.hero h1 { position: relative; z-index: 1; color: #fff; font-size: 1.55rem; max-width: 70%; line-height: 1.15; margin: 4px 0 16px; }
.hero-art { position: absolute; z-index: 1; right: 14px; top: 14px; width: 82px; height: 82px; border-radius: 24px; transform: rotate(6deg); box-shadow: 0 8px 20px rgba(0, 0, 0, .18); }
.moods { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.mood {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0 6px; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, .16); border-radius: 18px; color: #fff; transition: transform .15s, background .2s;
  touch-action: manipulation; font-family: inherit;
}
.mood .me { font-size: 1.7rem; line-height: 1; }
.mood .ml { font-size: .7rem; font-weight: 800; }
.mood:active { transform: scale(.92); }
.mood.on { background: #fff; color: var(--hero-2); transform: translateY(-2px); box-shadow: 0 6px 14px rgba(0, 0, 0, .15); }
.hero-quote { position: relative; z-index: 1; margin: 16px 0 0; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, .25); font-weight: 700; font-size: .95rem; line-height: 1.45; opacity: .96; }

.progress { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
.ptile { border-radius: 22px; padding: 12px; display: flex; align-items: center; gap: 10px; min-height: 72px; }
.ptile b { display: block; font-size: 1.35rem; font-weight: 900; line-height: 1.1; color: var(--ink); }
.ptile b small { font-size: .85rem; color: var(--muted); font-weight: 800; }
.ptile span { font-size: .72rem; font-weight: 700; color: var(--muted); line-height: 1.2; }
.ptile .pi { font-size: 1.5rem; }
.ring { width: 44px; height: 44px; flex: none; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 7; }
.ring-bg { stroke: rgba(45, 42, 62, .1); }
:root.night .ring-bg { stroke: rgba(255, 255, 255, .12); }
.ring-fg { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .6s ease; }
@media (max-width: 380px) { .ptile { flex-direction: column; align-items: flex-start; gap: 4px; } }

.t-orange { background: var(--t-orange); }
.t-yellow { background: var(--t-yellow); }
.t-blue { background: var(--t-blue); }
.t-purple { background: var(--t-purple); }
.t-green { background: var(--t-green); }
.t-pink { background: var(--t-pink); }

/* stat tiles in pastel colours */
.stats.tiles { gap: 10px; margin: 14px 0; }
.stats.tiles .stat { border: 0; border-radius: 22px; padding: 14px; box-shadow: none; }
.stats.tiles .stat:nth-child(5n+1) { background: var(--t-purple); }
.stats.tiles .stat:nth-child(5n+2) { background: var(--t-green); }
.stats.tiles .stat:nth-child(5n+3) { background: var(--t-blue); }
.stats.tiles .stat:nth-child(5n+4) { background: var(--t-pink); }
.stats.tiles .stat:nth-child(5n+5) { background: var(--t-yellow); }
.stat .k { text-transform: none; letter-spacing: 0; font-weight: 800; font-size: .78rem; color: var(--muted); }
.stat .v { font-weight: 900; font-size: 1.45rem; }
.stat .s { font-weight: 600; }
.plans { background: var(--t-yellow); box-shadow: none; }

/* quick log: pastel tiles with round icon badges */
.timechip { border: 0; background: var(--soft); font-weight: 800; padding: 8px 14px; }
.timechip.set { background: var(--warn-soft); color: var(--warn); }
.qgrid { gap: 10px; }
.qbtn { border: 0; border-radius: 22px; min-height: 96px; gap: 6px; background: var(--soft); font-family: inherit; color: var(--ink); }
.qgrid .qbtn:nth-child(6n+1) { background: var(--t-blue); }
.qgrid .qbtn:nth-child(6n+2) { background: var(--t-yellow); }
.qgrid .qbtn:nth-child(6n+3) { background: var(--t-orange); }
.qgrid .qbtn:nth-child(6n+4) { background: var(--t-green); }
.qgrid .qbtn:nth-child(6n+5) { background: var(--t-purple); }
.qgrid .qbtn:nth-child(6n+6) { background: var(--t-pink); }
.qbtn .qi { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .75); font-size: 1.5rem; }
:root.night .qbtn .qi { background: rgba(255, 255, 255, .08); }
.qbtn .ql { font-weight: 800; font-size: .8rem; }
.qbtn .qc { background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 0 3px var(--card); top: 8px; right: 8px; }
.qbtn.asleep { outline: 3px solid var(--accent); }
.qhead { font-weight: 900; font-size: 1rem; margin: 22px 0 10px; }
.qhead.rare { color: var(--warn); }
.qhead.severe { color: var(--bad); }
.mini { border: 0; border-radius: 999px; background: var(--soft); font-weight: 700; padding: 6px 12px; min-height: 32px; font-size: .78rem; font-family: inherit; }
.minis.rare .mini { background: var(--warn-soft); color: var(--warn); border: 0; }
.minis.severe .mini { background: var(--bad-soft); color: var(--bad); border: 0; }

/* meds */
.medlist li { border-top: 2px solid var(--soft); padding: 14px 0; }
.med-name b { font-weight: 900; }
.slot { border: 0; border-radius: 999px; background: var(--soft); min-height: 44px; min-width: 80px; padding: 7px 14px; font-weight: 800; font-family: inherit; color: var(--ink); }
.slot.done { background: var(--good-soft); color: var(--good); }
.slot.due { background: var(--warn-soft); color: var(--warn); box-shadow: inset 0 0 0 2px var(--warn); }
.slot.missed { background: var(--bad-soft); color: var(--bad); box-shadow: inset 0 0 0 2px var(--bad); }
.slot.later { color: var(--muted); }
.slot.add { background: transparent; box-shadow: inset 0 0 0 2px var(--line-strong); color: var(--muted); }
/* every slot: two centred lines, same height */
.slot { justify-content: center; gap: 1px; min-height: 52px; min-width: 92px; line-height: 1.15; }
.slot .st { font-weight: 800; white-space: nowrap; }
.slot small { font-size: .72rem; font-weight: 700; opacity: .85; white-space: nowrap; }
.slot.add small, .slot.later small { font-weight: 600; }

/* food */
.meallist li { border-bottom: 2px solid var(--soft); }
.ml-g { font-weight: 900; }

/* fold-away sections */
details.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary h2 { flex: none; }
details.fold > summary .fold-sum { color: var(--muted); font-weight: 700; font-size: .85rem; margin-left: auto; }
details.fold > summary::after {
  content: "›"; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: var(--soft); color: var(--muted); font-weight: 900; transition: transform .2s; flex: none;
}
details.fold[open] > summary::after { transform: rotate(90deg); }
details.fold[open] > summary { margin-bottom: 14px; }

/* tables + timeline */
.grid thead th, .tbl th { text-transform: none; letter-spacing: 0; font-weight: 800; }
.grid th, .grid td, .tbl th, .tbl td { border-bottom-color: var(--soft); border-bottom-width: 2px; }
.grid .tally { color: var(--accent); }
.timeline li { border-top: 2px solid var(--soft); }
.timeline li.visit { background: var(--t-orange); border-radius: 18px; padding: 12px; }
.timeline li.visit a { color: var(--ink); text-decoration: none; }
.fluid { background: var(--soft); border-radius: 999px; padding: 6px 12px; }

/* files, more, sheets, toast */
.fitem { border: 0; border-radius: 22px; box-shadow: var(--shadow); }
.fthumb { border-radius: 22px 22px 0 0; }
.menu a { border-top: 2px solid var(--soft); font-weight: 700; }
.menu a::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 1.4rem; }
.menu .mi { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; background: var(--soft); font-size: 1.2rem; }
dialog.sheet { border-radius: 30px; padding: 24px; background: var(--card); color: var(--ink); box-shadow: var(--shadow-lg); }
dialog::backdrop { background: rgba(27, 26, 58, .55); }
@media (max-width: 560px) {
  dialog.sheet { border-radius: 30px 30px 0 0; padding-top: 30px; }
  dialog.sheet::before { content: ""; position: absolute; top: 10px; left: 50%; width: 44px; height: 5px; margin-left: -22px; border-radius: 3px; background: var(--line-strong); }
}
.rr-tap { border-radius: 28px; background: radial-gradient(120% 140% at 100% 0%, var(--hero-1), var(--hero-2)); color: #fff; }
.toast { border-radius: 999px; padding: 12px 18px; background: var(--ink); color: var(--bg); font-weight: 700; box-shadow: var(--shadow-lg); }
.toast button { color: var(--accent); }
:root.night .toast { background: #f4f1ff; color: #1b1a3a; }
.login { border-radius: 30px; box-shadow: var(--shadow-lg); padding: 28px; }
.quote { background: var(--t-yellow); border: 0; }
.alertcard.severe { background: var(--bad-soft); color: var(--bad); box-shadow: inset 0 0 0 2px var(--bad); }
.alertcard.rare { background: var(--warn-soft); color: var(--warn); box-shadow: inset 0 0 0 2px var(--warn); }
@media (max-width: 560px) { .wrap { padding-left: 16px; padding-right: 16px; } .card { padding: 18px 16px; } }

/* bloodwork */
.labcard { padding: 0; overflow: hidden; }
.labwrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.labtbl { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .88rem; }
.labtbl th, .labtbl td { padding: 9px 10px; border-bottom: 2px solid var(--soft); text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.labtbl thead th { font-weight: 800; font-size: .8rem; vertical-align: bottom; }
.labtbl thead th a { color: var(--ink); text-decoration: none; }
.labtbl thead th small { display: block; color: var(--muted); font-weight: 600; font-size: .68rem; max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.labtbl thead .sheet { font-size: .9rem; }
.labtbl .sticky { position: sticky; left: 0; z-index: 1; background: var(--card); text-align: left; min-width: 150px; max-width: 190px; white-space: normal; box-shadow: 2px 0 0 var(--soft); }
.labtbl tbody th.sticky { font-weight: 700; }
.labtbl tbody th small { display: block; color: var(--muted); font-weight: 600; font-size: .7rem; }
.labtbl tr.grp th { background: var(--soft); font-weight: 900; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); text-align: left; }
.labtbl tbody tr:not(.grp) { cursor: pointer; }
.labtbl tbody tr:not(.grp):hover td, .labtbl tbody tr:not(.grp):hover th { background: var(--accent-soft); }
.lv { font-weight: 800; }
.lv.fH { color: var(--bad); }
.lv.fL { color: var(--blue); }
.chg { margin-left: 4px; color: var(--muted); font-size: .7rem; }
.keydot { color: var(--accent); font-size: .6rem; vertical-align: middle; }
.labgroup { border-top: 2px solid var(--soft); padding: 10px 0; }
.labgroup summary { cursor: pointer; }
.labform { display: grid; grid-template-columns: minmax(110px, 1.5fr) repeat(4, minmax(56px, 1fr)); gap: 6px; align-items: center; margin-top: 10px; }
.labform.five { grid-template-columns: minmax(110px, 1.5fr) repeat(4, minmax(56px, 1fr)); }
.labform input { min-height: 40px !important; padding: 8px 10px !important; font-size: .9rem; border-radius: 10px !important; }
.lf-name { font-size: .82rem; font-weight: 700; }

.aibox { background: var(--t-purple); box-shadow: none; }
.aibox code { background: rgba(255,255,255,.6); padding: 1px 6px; border-radius: 6px; }
input.aifilled { background: var(--t-yellow) !important; box-shadow: inset 0 0 0 2px var(--warn) !important; }

.sheetday { padding: 12px 0; border-top: 2px solid var(--soft); }
.sheetday:first-of-type { border-top: 0; }
.sheetthumbs { display: flex; gap: 8px; overflow-x: auto; margin-top: 8px; }
.sheetthumbs a { flex: none; width: 96px; text-decoration: none; color: var(--muted); }
.sheetthumbs img, .sheetthumbs span { display: grid; place-items: center; width: 96px; height: 120px; object-fit: cover; border-radius: 14px; background: var(--soft); font-size: 2rem; }
.sheetthumbs small { display: block; font-size: .68rem; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* print / report */
.report h1 { font-size: 1.5rem; }
.report .day { break-inside: avoid; page-break-inside: avoid; }
.report .day h2 { border-bottom: 2px solid var(--ink); padding-bottom: 4px; margin: 18px 0 8px; }
.report .grid { min-width: 0; font-size: .78rem; }
.report .timeline li { padding: 4px 0; grid-template-columns: 62px 22px 1fr; }
@media print {
  :root { --bg: #fff; --card: #fff; --ink: #000; --muted: #555; --line: #ccc; --soft: #f3f3f3; --accent: #000; --accent-2: #000; --accent-3: #000; --accent-soft: #f3f3f3; }
  body { padding: 0; font-size: 11pt; }
  .no-print, .tabbar, .topbar, .toast { display: none !important; }
  .card { box-shadow: none; border: 0; padding: 0; margin: 10px 0; }
  .wrap { max-width: none; padding: 0; }
  a { color: inherit; text-decoration: none; }
  .gridwrap { overflow: visible; margin: 0; padding: 0; }
}

/* ---------- Today: photo of the day ---------- */
.daypic { position: relative; margin: 0 0 14px; border-radius: 28px; overflow: hidden; background: var(--card, #fff); box-shadow: 0 10px 26px rgba(0, 0, 0, .10); }
.daypic-img { display: block; }
/* Give the photo its own layer so iPhone doesn't repaint it when a scroll ends (that showed as a flicker) */
.daypic, .daypic-img img { -webkit-transform: translateZ(0); transform: translateZ(0); -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.daypic-img img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: color-mix(in srgb, var(--hero-1) 25%, transparent); }
.daypic-tag { position: absolute; left: 12px; top: 12px; padding: 5px 12px; border-radius: 999px; background: rgba(0, 0, 0, .5); color: #fff; font-weight: 800; font-size: .85rem; pointer-events: none; }
.daypic-form { position: absolute; right: 12px; bottom: 12px; margin: 0; }
.daypic-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px; background: rgba(255, 255, 255, .92); color: #333; font-weight: 800; font-size: .85rem; cursor: pointer; box-shadow: 0 4px 12px rgba(0, 0, 0, .18); }
.daypic-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.daypic-btn.busy { opacity: .6; pointer-events: none; }
.daypic-btn.busy span::after { content: " …uploading"; }
.daypic.empty { box-shadow: none; background: transparent; border: 2px dashed color-mix(in srgb, var(--hero-2) 45%, transparent); }
.daypic.empty .daypic-form { position: static; }
.daypic.empty .daypic-btn { display: flex; justify-content: center; padding: 22px 14px; border-radius: 0; background: transparent; color: var(--hero-2); box-shadow: none; font-size: 1rem; }

/* Guinness: small rounded-square photo in the bottom-left corner of the photo card */
.pal { position: absolute; left: 12px; bottom: 12px; z-index: 2; width: 88px; height: 88px; }
.pal-img img { display: block; width: 88px; height: 88px; border-radius: 22px; object-fit: cover; border: 3px solid #fff; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); background: #ddd; }
.pal form { margin: 0; }
.pal-btn { cursor: pointer; }
.pal-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.pal:not(.none) .pal-btn { position: absolute; right: -6px; top: -6px; width: 28px; height: 28px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: .8rem; box-shadow: 0 2px 8px rgba(0, 0, 0, .2); }
.pal.none .pal-btn { display: grid; place-items: center; width: 88px; height: 88px; border-radius: 22px; border: 2px dashed rgba(255, 255, 255, .9); background: rgba(0, 0, 0, .35); color: #fff; font-weight: 800; font-size: .72rem; text-align: center; line-height: 1.1; padding: 6px; }
.pal-name { position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); padding: 1px 8px; border-radius: 999px; background: #fff; color: #333; font-weight: 800; font-size: .68rem; white-space: nowrap; box-shadow: 0 2px 6px rgba(0, 0, 0, .15); pointer-events: none; }
.pal.busy { opacity: .55; pointer-events: none; }
.daypic.empty { display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.daypic.empty .daypic-form { flex: 1; }
.daypic.empty .pal { position: relative; left: auto; bottom: auto; order: -1; }
.daypic.empty .pal.none .pal-btn { border-color: color-mix(in srgb, var(--hero-2) 55%, transparent); background: transparent; color: var(--hero-2); }

/* Mobile scrolling: never let the tab bar or Safari's toolbar hide the last bit of a page or sheet */
@media (max-width: 819px) {
  body { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
}
dialog.sheet { max-height: 90vh; max-height: 90dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

/* Back to top (appears near the bottom of long pages) */
.totop {
  position: fixed; right: 16px; bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 25;
  width: 46px; height: 46px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--accent); color: var(--accent-ink, #fff); font-size: 1.35rem; font-weight: 900; line-height: 1;
  box-shadow: 0 8px 20px rgba(0, 0, 0, .2);
  opacity: 0; transform: translateY(12px) scale(.9); pointer-events: none; transition: opacity .2s, transform .2s;
}
.totop.show { opacity: 1; transform: none; pointer-events: auto; }
@media (min-width: 820px) { .totop { bottom: 24px; } }

/* Never let anything make the page wider than the phone (on iPhone that also pushes the tab bar off screen) */
html { overflow-x: hidden; }
@supports (overflow: clip) { body { overflow-x: clip; } }
.daynav { flex-wrap: wrap; row-gap: 6px; min-width: 0; }
.datepick { min-width: 0; max-width: 100%; }

/* Swipe between days: label that slides in from the edge */
.daypeek {
  position: fixed; top: 50%; z-index: 30; padding: 10px 16px; border-radius: 999px;
  background: var(--card); color: var(--ink); font-weight: 900; font-size: .95rem; white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18); opacity: 0; pointer-events: none;
  transition: opacity .15s, transform .15s, background .15s, color .15s;
}
.daypeek.left { left: 12px; transform: translate(-20px, -50%); }
.daypeek.right { right: 12px; transform: translate(20px, -50%); }
.daypeek.show { opacity: 1; transform: translate(0, -50%); }
.daypeek.ready { background: var(--accent); color: var(--accent-ink, #fff); }

/* Login box: centred (the later .card margin rule was overriding "margin: auto") */
.card.login { margin: 12vh auto 0; width: 100%; max-width: 380px; }

/* Today: Quick log header row inside the fold */
.quick-h { align-items: center; gap: 10px; margin-bottom: 10px; }
.quick-h .hint { margin: 0; flex: 1; }

/* Treatment course card (e.g. Palladia) */
.course + .course { margin-top: 14px; padding-top: 14px; border-top: 2px solid var(--soft); }
.course-top { display: flex; align-items: center; gap: 10px; }
.course-top b { font-size: 1.05rem; }
.course-day { margin-left: auto; padding: 4px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 900; font-size: .85rem; }
.course-status { margin: 0 0 12px; font-weight: 700; }
.course-top + .course-status { margin-top: 8px; }
.course-total .s small { font-weight: 600; }
.course-status.ok { color: var(--good, #2f9e6a); }
.course-status.due { color: var(--accent); }
.course-total { display: flex; align-items: baseline; gap: 10px; padding: 12px 16px; border-radius: 18px; background: var(--soft); }
.course-total .v { font-size: 2rem; font-weight: 900; line-height: 1; }
.course-total .s { color: var(--muted); font-weight: 700; font-size: .88rem; }

/* Nutrition estimates on the Food card */
.ml-nut { margin-top: 3px; font-size: .82rem; color: var(--muted); }
.ml-nut > summary { list-style: none; cursor: pointer; display: inline; }
.ml-nut > summary::-webkit-details-marker { display: none; }
.ml-nut > summary b { color: var(--ink); }
.ml-nut > summary::after { content: " ›"; }
.ml-nut[open] > summary::after { content: " ⌄"; }
.ml-nutd { display: flex; flex-direction: column; gap: 2px; margin: 6px 0 2px; padding: 8px 10px; border-radius: 12px; background: var(--soft); }
.ml-nut-wait { display: block; margin-top: 3px; font-size: .8rem; }
.nutday { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 4px 0 8px; }
.nutday div { padding: 10px 8px; border-radius: 16px; background: var(--soft); text-align: center; }
.nutday b { display: block; font-size: 1.2rem; font-weight: 900; }
.nutday span { display: block; font-size: .72rem; font-weight: 700; color: var(--muted); }
.nutday div:first-child { background: var(--good-soft, #dcf3e7); }
.nutnote { margin: 0 0 12px; line-height: 1.45; }
