@font-face{
  font-family:'DM Sans';
  font-style:normal;
  font-weight:300 600;
  font-display:swap;
  src:url('/fonts/dm-sans-variable.woff2') format('woff2');
}
@font-face{
  font-family:'JetBrains Mono';
  font-style:normal;
  font-weight:400 500;
  font-display:swap;
  src:url('/fonts/jetbrains-mono-variable.woff2') format('woff2');
}

:root{
  /* DoingWell brand: Deep Field background, Tide structural gradient, one fixed Signal accent */
  --deep-1:#064E3B; --deep-2:#0B1120;
  --tide-1:#22D3EE; --tide-2:#34D399;
  --tide-border:linear-gradient(45deg, var(--tide-1) 0%, var(--tide-2) 100%);
  --tide-border-muted:linear-gradient(45deg, rgba(34,211,238,.5) 0%, rgba(52,211,153,.5) 100%);
  --structure:var(--tide-1);   /* nav/selection chrome — always Tide */
  --link:var(--tide-1);        /* interactive text (Back, edit pencils): Tide cyan on dark */
  --focus-ring:var(--tide-1);  /* keyboard focus ring — see :focus-visible below */
  --surface:#101B2D; --surface2:#0a1420;
  --hairline:rgba(255,255,255,.07);
  --track:rgba(255,255,255,.08);

  --page:var(--deep-2); --card:var(--surface); --card2:var(--surface2);
  --border:rgba(255,255,255,.12); --border2:rgba(255,255,255,.12);
  --text:#e8eaef; --muted:#8b93a1; --faint:#6b7480;
  --accent:#FBBF24;             /* Signal — fixed, no user picker */
  --green:#22c55e; --pink:#f472b6; --purple:#a78bfa; --blue:#38bdf8; --danger:#ef4444;
  --mono:'JetBrains Mono',ui-monospace,SFMono-Regular,Menlo,monospace; --radius:12px;
  --btn-text-on-accent:#241a05;  /* dark text on the gold accent — same in both themes */
}

/* Light theme — background/surface/text flip to a light neutral palette (per the
   original brand exploration's "black text on white" typography variant); the
   header/hero stays on the dark Deep Field gradient in both themes, since it's
   the one full-intensity brand moment and the gradient wordmark needs a dark
   backdrop to read — only the page body's tokens change. */
:root[data-theme="light"]{
  --page:#F5F5F4; --surface:#FFFFFF; --surface2:#F0EFED;
  --border:rgba(0,0,0,.12); --border2:rgba(0,0,0,.12);
  --hairline:rgba(0,0,0,.07); --track:rgba(0,0,0,.08);
  --text:#16181c; --muted:#5b6472; --faint:#8891a0;
  /* Tide cyan is too pale on white (~1.7:1); use a darker teal for interactive
     text + focus ring so links/back/pencils clear the 3:1 UI-contrast minimum.
     --structure stays bright Tide — it's only ever used on the dark hero. */
  --link:#0E7490; --focus-ring:#0E7490;
}

*{box-sizing:border-box}
body{margin:0;background:var(--page);color:var(--text);
  font-family:'DM Sans',system-ui,-apple-system,"Segoe UI",sans-serif;font-weight:400;-webkit-tap-highlight-color:transparent}

/* header — the persistent hero: Deep Field fill, full-strength Tide border, gradient wordmark + live stat line */
header{position:sticky;top:0;z-index:10;
  background:linear-gradient(135deg, var(--deep-1) 0%, var(--deep-2) 100%);
  display:flex;flex-direction:column;gap:4px;
  padding:14px 16px 12px;
}
header::after{content:"";position:absolute;left:0;right:0;bottom:0;height:1.5px;background:var(--tide-border)}
.hero-top{display:flex;align-items:center;justify-content:space-between}
header h1{font-size:25.13px;font-weight:300;margin:0;display:flex;align-items:flex-start;gap:9px}
#home-link{cursor:pointer;-webkit-tap-highlight-color:transparent;user-select:none}
#home-link:active{opacity:.7}
/* Wordmark: "Doing" reads quiet (regular weight, plain white) so "Well" — bold,
   the Tide gradient — carries the visual weight instead, a deliberate nod to
   this being a WELLNESS app. A gold bullet (•, not a middle-dot — DM Sans's
   middle-dot glyph sits low and reads as a stray period) separates the two,
   nudged down 4px and scaled down from its native size to read as a small
   considered mark rather than an oversized bullet point. */
.wordmark{display:inline-flex;align-items:baseline}
.wordmark-doing{color:#fff;font-weight:400}
.wordmark-dot{color:var(--accent);font-weight:400;margin:0 3px;font-size:.719em;position:relative;top:1px}
.wordmark-well{background:var(--tide-border);-webkit-background-clip:text;background-clip:text;
  -webkit-text-fill-color:transparent;color:transparent;font-weight:700}
main{max-width:600px;margin:0 auto;padding:14px 16px 96px}
.hidden{display:none!important}
.muted{color:var(--muted)}
.app-version{text-align:center;color:var(--faint);font-size:11px;font-family:var(--mono,monospace);margin:18px 0 8px;letter-spacing:.02em}

/* hero mini progress bars — replace the old text stat line */
.hero-stats{display:flex;gap:16px;margin-top:2px}
.hero-metric{display:flex;align-items:center;gap:7px;flex:1;min-width:0}
.hero-metric-label{font-family:var(--mono);font-size:10px;font-weight:500;color:rgba(255,255,255,.55);text-transform:uppercase;letter-spacing:.04em;flex-shrink:0}
.hero-metric-track{flex:1;height:4px;background:rgba(255,255,255,.15);border-radius:2px;overflow:hidden}
.hero-metric-fill{height:100%;border-radius:2px;width:0;background:var(--accent)}

/* header actions: date-picker trigger, settings gear */
.header-actions{display:flex;align-items:center;gap:8px}
.icon-btn{background:none;border:0;padding:4px 6px;color:rgba(255,255,255,.85);font-size:15px;cursor:pointer;font-family:'DM Sans',sans-serif}
#date-input{position:absolute;opacity:0;pointer-events:none;width:0;height:0}

/* Bordered surfaces (feed cards, cards, nutrient groups, the Today summary) use a
   nested-div gradient frame — an outer element painted with the Tide gradient as
   a plain `background` plus 1.5px padding, and an inner element with the solid
   surface colour on top. This is deliberately NOT the background-clip or mask
   pseudo-element tricks (both tried and both rendered as a flat solid colour on
   some mobile browsers) — two plain nested elements with ordinary backgrounds is
   the one technique with zero exotic-feature dependency, so it's guaranteed to
   render the same everywhere. */
.feed-card,.card,.ngroup,.summary{
  background:var(--tide-border-muted);
  border-radius:var(--radius);
  padding:1.5px;
}
.feed-card-inner,.card-inner,.ngroup-inner,.summary-inner{
  background:var(--surface);
  border-radius:calc(var(--radius) - 1.5px);
  padding:14px 16px;
  height:100%;
}
.card,.ngroup{margin-bottom:12px}
.card h3,.ngroup h3{font-size:14px;font-weight:600;margin:0 0 10px}
.sec{color:var(--faint);font-size:12px;letter-spacing:.6px;text-transform:uppercase;margin:0 0 8px}

/* AI insights (roadmap item 9a): the model's own written summary, rendered
   from a small markdown subset (see insights.js renderMarkdown) — headings
   subordinate to the card's own h3, since they start at h4. */
.insights-content{font-size:13px;line-height:1.6;color:var(--fg)}
.insights-content h4,.insights-content h5{margin:14px 0 6px;font-weight:600}
.insights-content h4:first-child,.insights-content h5:first-child{margin-top:0}
.insights-content p{margin:0 0 8px}
.insights-content ul{margin:0 0 8px;padding-left:20px}
.insights-content li{margin-bottom:4px}

/* feed cards: compact tap-through summaries, grouped into sections */
#view-feed{display:flex;flex-direction:column;gap:18px}
.feed-section{display:flex;flex-direction:column;gap:10px}
/* Section header: a small Tide-cyan eyebrow + optional meta ("live now", the
   selected date) + a hairline rule filling the row. */
.feed-section-head{display:flex;align-items:center;gap:10px}
.feed-section-title{font-size:11px;font-weight:700;letter-spacing:.08em;text-transform:uppercase;color:var(--structure);font-family:var(--mono)}
.feed-section-meta{font-size:10px;color:var(--faint);font-family:var(--mono);white-space:nowrap}
.feed-section-line{flex:1;height:1px;background:var(--border)}
/* Date-scope note under the Today header when a past day is selected. */
.feed-section-note{font-size:11px;color:var(--faint);background:color-mix(in srgb,var(--structure) 8%,transparent);
  border-radius:8px;padding:6px 10px}
/* Device/Records card header: label on the left, status pill(s) (live/low-stock/
   rest-mode) pushed to the right edge — separates "what this card is" from "its
   current status" instead of competing inline after the label text. */
.feed-card-head{display:flex;align-items:center;justify-content:space-between;gap:8px;margin-bottom:6px}
.feed-card-head .feed-card-label{margin-bottom:0}
/* Right-side status pills (Rest Mode, battery, live) as a single tight cluster
   — without this wrapper, space-between spreads each pill independently across
   the header instead of grouping them flush against the right edge. */
.feed-card-head-right{display:flex;align-items:center;gap:6px}
/* "live" tag on a Devices card label — this data is current, not date-scoped.
   line-height:1 (not vertical-align:middle, which aligns to the line box and
   read as sitting low next to the label's uppercase cap-height) keeps the pill
   optically centred against the label text it sits beside. */
.feed-live{display:inline-flex;align-items:center;font-size:9px;font-weight:700;line-height:1;
  text-transform:uppercase;letter-spacing:.03em;
  color:var(--tide-2);background:color-mix(in srgb,var(--tide-2) 15%,transparent);border-radius:6px;padding:3px 6px}
/* Marks a user-added micronutrient in the detail list (vs. the built-in ~35)
   -- same type treatment as .feed-live (size/weight/uppercase/spacing) but
   deliberately no pill background: it's a quiet label, not a status signal. */
.custom-tag{font-size:9px;font-weight:700;line-height:1;text-transform:uppercase;
  letter-spacing:.03em;color:var(--tide-2);margin-left:6px}
.feed-card{display:block;width:100%;text-align:left;cursor:pointer;border:0}
/* Live-update flash (SSE): the card whose value just changed gets a soft
   tide-cyan glow that fades, so the eye lands on what's new. Self-removes on
   animationend (see flashIfChanged in util.js). The inner surface carries the
   ring so it hugs the card's rounded edge. */
.feed-card.just-updated .feed-card-inner{animation:card-flash 1.6s ease-out}
@keyframes card-flash{
  0%   {box-shadow:0 0 0 0 color-mix(in srgb,var(--structure) 70%,transparent);
        background:color-mix(in srgb,var(--structure) 10%,var(--surface))}
  100% {box-shadow:0 0 0 6px transparent;background:var(--surface)}
}
@media (prefers-reduced-motion: reduce){
  /* No motion: a brief static tint instead of the pulsing ring. */
  .feed-card.just-updated .feed-card-inner{animation:card-flash-static 1.6s ease-out}
  @keyframes card-flash-static{0%{background:color-mix(in srgb,var(--structure) 12%,var(--surface))}100%{background:var(--surface)}}
}
.feed-card-label{font-size:12px;font-weight:500;letter-spacing:.04em;text-transform:uppercase;color:var(--muted);margin-bottom:6px}
.feed-card-stat{font-family:var(--mono);font-weight:600;font-size:20px;color:var(--text)}
.feed-card-stat.over-threshold{color:var(--accent)}
.feed-card-stat.goal-met{color:var(--tide-2)}
.feed-card-sub{font-size:12px;color:var(--muted);margin-top:2px}

/* Condensed empty-state card: a domain card with nothing logged today shrinks
   to a single row — label left, status right, immediately beside it — instead
   of the full-height stat block. Toggled by JS adding/removing .condensed on
   .feed-card-inner (see cards.js condenseCard()); the full stat/sub spans stay
   in the DOM but hidden, so re-expanding on new data needs no re-render. */
.feed-card-inner.condensed{padding:12px 16px;display:flex;align-items:center;justify-content:space-between;gap:10px}
.feed-card-inner.condensed .feed-card-label{margin-bottom:0}
.feed-card-inner.condensed .feed-card-condensed-stat{font-size:13px;font-weight:600;color:var(--accent);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.feed-card-condensed-stat{display:none}
.feed-card-inner.condensed .feed-card-stat,.feed-card-inner.condensed .feed-card-sub,.feed-card-inner.condensed .feed-card-bars{display:none}
.feed-card-inner.condensed .feed-card-condensed-stat{display:block}

/* test-results feed card. Right-aligned in the card header (.feed-card-head) —
   line-height:1 keeps it optically centred against the label instead of the
   line-box middle (which read as sitting low next to the label's cap-height). */
/* Matches the CGM "Low stock" pill's look (K3 — one danger-pill language):
   gradient-muted Tide border + a solid darkened-danger fill, not a flat
   danger background. */
.tests-flag{display:inline-flex;align-items:center;gap:4px;font-size:10px;font-weight:700;line-height:1;color:#fff;
  border:1px solid transparent;background:color-mix(in srgb,var(--danger) 75%,#000);
  border-radius:8px;padding:3px 8px;letter-spacing:0;text-transform:none;
  background:linear-gradient(color-mix(in srgb,var(--danger) 75%,#000) 0 0) padding-box,
             var(--tide-border-muted) border-box}
/* Unread-count pill: informational, NOT an error — use a flat accent fill, not
   the danger-red gradient-bordered look the "flagged results" pill uses (P2).
   Resets border/background fully since .tests-flag now sets a two-layer
   gradient-border background this pill must NOT inherit. */
.unread-flag{color:var(--btn-text-on-accent);background:var(--accent);border:1px solid transparent}
.tests-recent{display:flex;flex-direction:column;gap:5px;margin-top:8px}
.tests-recent-row{display:flex;justify-content:space-between;align-items:center;gap:10px;font-size:13px}
.tests-recent-name{color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tests-recent-val{flex-shrink:0;font-family:var(--mono);font-size:13px}
/* Status marker: a small colour chip that also carries a glyph (↑ ↓ ! ✓) so
   status isn't colour-only (WCAG 1.4.1). Sized to fit the glyph legibly. */
.tests-dot{display:inline-flex;align-items:center;justify-content:center;min-width:15px;height:15px;
  padding:0 3px;border-radius:8px;margin-right:6px;vertical-align:middle;
  font-size:10px;font-weight:800;line-height:1;color:#0b1120;font-family:var(--mono)}
.tests-dot:empty{width:8px;min-width:8px;height:8px;padding:0;border-radius:50%}
.tests-dot.flag{box-shadow:0 0 0 2px color-mix(in srgb,var(--danger) 22%,transparent)}
.tests-val{font-weight:600;color:var(--text)}
.tests-unit{color:var(--muted);font-size:11px}

/* test-results detail list */
.tests-toolbar{display:flex;gap:10px;align-items:center;flex-wrap:wrap}
.tests-search{flex:1;min-width:140px;padding:8px 10px;border-radius:8px;border:1px solid var(--track);background:var(--surface2);color:var(--text)}
.tests-filter{font-size:12px;color:var(--muted);display:flex;align-items:center;gap:5px;white-space:nowrap}
.tests-group{margin-top:14px}
/* Shared grouped-detail primitives. A section header + tappable list rows,
   used identically by the device detail pages (Withings/Oura/Nightscout, the
   .wg-* aliases) and the PKB record pages (.tests-* aliases). One rule so the
   two families can't drift apart — see .detail-group-head / .detail-row. */
.detail-group-head,.tests-group-head,.wg-group-head{font-size:11px;font-weight:600;letter-spacing:.04em;text-transform:uppercase;color:var(--muted);margin-bottom:4px}
.detail-row,.tests-row,.wg-row{display:grid;grid-template-columns:1fr auto auto;gap:10px;align-items:center;width:100%;min-height:44px;text-align:left;border:0;background:transparent;color:var(--text);padding:9px 4px;border-bottom:1px solid var(--track);cursor:pointer}
.detail-row:hover,.tests-row:hover,.wg-row:hover{background:color-mix(in srgb,var(--accent) 7%,transparent)}
.tests-row-name{font-size:14px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.tests-row-val{font-family:var(--mono);font-size:13px;white-space:nowrap}
.tests-range{color:var(--muted);font-size:11px;margin-left:6px}
.tests-row-when{color:var(--muted);font-size:11px;white-space:nowrap}
/* "Sensitive category" marker — a short word, not a lone colour dot (A4). */
.tests-sensitive{color:var(--purple);font-weight:700;font-size:10px;text-transform:uppercase;letter-spacing:.03em;
  background:color-mix(in srgb,var(--purple) 16%,transparent);border-radius:6px;padding:1px 6px}

/* trend page */
.trend-latest{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:12px}
.trend-latest-val{display:flex;align-items:baseline;gap:6px}
.trend-big{font-family:var(--mono);font-weight:700;font-size:28px;color:var(--text)}
.trend-unit{color:var(--muted);font-size:13px}
.trend-star{font-size:13px;padding:6px 12px;flex-shrink:0}
.trend-chart{margin:6px 0 14px}
.spark{width:100%;height:auto;display:block}
.trend-readings{display:flex;flex-direction:column;gap:2px}
.trend-reading{display:flex;justify-content:space-between;font-size:13px;color:var(--muted);padding:5px 2px;border-bottom:1px solid var(--track);font-family:var(--mono)}

/* Withings feed card: three compact labelled stats (Weight / Sleep / BP).
   The three boxes are distributed left / centre / right across the card
   (space-between), but each box shrinks to its content and stays LEFT-aligned
   INSIDE — so every label sits flush above the first digit of its value, not
   over the value+unit's centre/right edge. */
.wh-stats{display:flex;justify-content:space-between;gap:12px;margin-top:2px}
.wh-stat{min-width:0;text-align:left}
.wh-stat-label{font-size:10px;font-weight:600;letter-spacing:.05em;text-transform:uppercase;color:var(--muted)}
.wh-stat-val{font-family:var(--mono);font-weight:600;font-size:18px;color:var(--text);white-space:nowrap;margin-top:1px}
.wh-stat-unit{font-family:inherit;font-size:11px;font-weight:500;color:var(--muted);margin-left:3px}
/* a stale headline value (e.g. an old glucose reading shown as "23m ago") reads muted */
.wh-stat-stale{color:var(--muted)}
/* shared small muted caption (replaces scattered inline font-size:12px) */
.caption{font-size:12px;color:var(--muted);line-height:1.4}
.source-note{margin:-4px 0 12px}   /* attribution line under a device detail header */
/* Oura battery pill: same shape/position as .feed-live, in the card header row
   (not absolute — that escaped the card on long content). Neutral (tide accent,
   like "live") once ring_battery_level gives a real %; red (.oura-batt-low)
   at/below 20% or (fallback, no % synced yet) the old low_battery_alert
   boolean fires. Icon is an inline SVG (solid, single colour via currentColor)
   rather than the 🔋 emoji, which renders inconsistently across platforms. */
.oura-batt{display:inline-flex;align-items:center;gap:3px;font-size:9px;font-weight:700;
  line-height:1;letter-spacing:.03em;border-radius:6px;padding:3px 6px;
  color:var(--tide-2);background:color-mix(in srgb,var(--tide-2) 15%,transparent)}
.oura-batt svg{width:11px;height:11px;flex:0 0 auto;fill:currentColor}
.oura-batt.oura-batt-low{color:#fff;background:color-mix(in srgb,var(--danger) 75%,#000)}
/* Reading age ("15h ago"): muted grey, not the pill's accent colour — the %
   is the live-status claim, the age is a caveat on it, so it reads distinctly
   quieter rather than implying the whole pill is equally "current". */
.oura-batt-age{color:var(--muted);font-weight:500}
/* Rest Mode badge: a STATUS (not an alert), so it uses the tide-gradient border
   + a neutral dark fill rather than the battery pill's red. Right-aligned in
   the card header (.feed-card-head), before the "live" pill; shown only while
   a rest-mode period is active. */
.oura-rest{display:inline-flex;align-items:center;gap:4px;line-height:1;
  font-size:10px;font-weight:700;letter-spacing:0;text-transform:none;color:var(--text);
  border:1px solid transparent;border-radius:8px;padding:3px 8px;
  background:linear-gradient(var(--surface2) 0 0) padding-box,
             var(--tide-border-muted) border-box}
/* Oura tag rows in the detail page */
.oura-tag{display:flex;justify-content:space-between;align-items:baseline;gap:10px;
  padding:7px 0;border-bottom:1px solid var(--border)}
.oura-tag:last-child{border-bottom:0}
.oura-tag-main{min-width:0}
.oura-tag-label{font-weight:600;color:var(--text)}
.oura-tag-comment{font-size:12px;color:var(--muted);margin-top:2px;line-height:1.4}
.oura-tag-when{font-size:11px;color:var(--faint);font-family:var(--mono);
  text-align:right;flex:0 0 auto;max-width:42%}
/* Custom-tag name button (Oura exposes no custom-tag name — user sets it here) */
.oura-tag-name-btn{display:inline-flex;align-items:center;gap:6px;padding:0;border:0;
  background:none;cursor:pointer;font-weight:600;color:var(--accent);
  font-family:inherit;font-size:inherit;text-align:left}
.oura-tag-edit{font-size:11px;color:var(--muted)}

/* Withings grouped detail: sections (Body/Blood Pressure/Sleep/Activity) each a
   list of tappable metric rows -> trend. */
.wg-group{margin-bottom:16px}
/* .wg-group-head / .wg-row / .wg-row:hover are defined with .detail-* above */
.wg-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.wg-val{font-family:var(--mono);font-weight:600;color:var(--text)}
.wg-when{color:var(--muted);font-size:11px;white-space:nowrap}
/* Nightscout glucose sub-stats line under the glucose row */
.ns-substat{font-size:12px;color:var(--muted);line-height:1.5;padding:8px 4px 0}
.ns-substat strong{color:var(--text);font-weight:600}
/* CGM sensor tracking */
/* Low-stock pill: right-aligned in the card header (.feed-card-head) — NOT
   absolute (reusing the absolute .oura-batt made it escape the card to the
   viewport edge). */
.cgm-lowpill{display:inline-flex;align-items:center;gap:4px;line-height:1;
  font-size:10px;font-weight:700;letter-spacing:0;text-transform:none;color:#fff;
  background:color-mix(in srgb,var(--danger) 75%,#000);border:1px solid transparent;
  border-radius:8px;padding:3px 8px;
  background:linear-gradient(color-mix(in srgb,var(--danger) 75%,#000) 0 0) padding-box,
             var(--tide-border-muted) border-box}
.cgm-forecast{font-size:13px;color:var(--muted);line-height:1.5;margin-bottom:12px}
.cgm-forecast strong{color:var(--text);font-weight:600}
.cgm-low,.cgm-forecast .cgm-low{color:var(--danger);font-weight:600}
.cgm-section{margin-top:14px}
.cgm-item{display:flex;align-items:flex-start;gap:10px;padding:10px 4px;border-bottom:1px solid var(--track)}
.cgm-item:last-child{border-bottom:0}
.cgm-item.past{opacity:.8}
.cgm-main{flex:1;min-width:0}
.cgm-main .name{font-weight:600;color:var(--text)}
.cgm-main .sub{font-size:12px;color:var(--muted);margin-top:2px;line-height:1.4}
.cgm-main .mono{font-family:var(--mono)}
.cgm-thumb{width:44px;height:44px;object-fit:cover;border-radius:8px;flex:0 0 auto;cursor:pointer}
.cgm-actions{display:flex;flex-direction:column;gap:6px;align-items:flex-end;flex:0 0 auto}
.cgm-actions button{font-size:12px;padding:0 12px;min-height:40px;border-radius:8px;border:1px solid var(--border);
  background:transparent;color:var(--text);cursor:pointer;white-space:nowrap}
.cgm-actions button.go{background:var(--accent);color:var(--btn-text-on-accent);border-color:transparent;font-weight:600}
.cgm-actions button.del{border-color:transparent}
.cgm-badge{display:inline-block;font-size:10px;font-weight:600;border-radius:8px;padding:1px 7px;
  margin-left:6px;background:var(--track);color:var(--muted);vertical-align:middle}
.cgm-badge.faulty{background:color-mix(in srgb,var(--danger) 22%,transparent);color:var(--danger)}

/* appointments feed card */
.appts-next{margin-top:6px}
.appts-next-when{font-family:var(--mono);font-size:15px;font-weight:600;color:var(--text)}
.appts-next-spec{font-size:13px;color:var(--muted);margin-top:2px}

/* appointments detail */
.appts-group{margin-top:14px}
.appt-row{border-bottom:1px solid var(--track)}
.appt-head{display:flex;justify-content:space-between;align-items:center;gap:10px;width:100%;text-align:left;border:0;background:transparent;color:var(--text);padding:11px 4px;cursor:pointer}
.appt-main{min-width:0}
.appt-when{font-family:var(--mono);font-size:13px;color:var(--text)}
.appt-spec{font-size:13px;color:var(--muted);margin-top:2px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.appt-meta{display:flex;align-items:center;gap:8px;flex-shrink:0}
.appt-status{font-size:11px;padding:2px 8px;border-radius:8px;background:var(--track);color:var(--muted);white-space:nowrap}
/* "Upcoming" is the primary, most-common appointment state — a SOLID accent
   fill with dark on-accent text so it reads at full contrast in both themes
   (a 22%-gold tint under gold text was near-invisible, esp. on light). */
.appt-status.booked{background:var(--accent);color:var(--btn-text-on-accent);font-weight:600}
.appt-status.done{background:color-mix(in srgb,var(--green) 20%,transparent);color:var(--green)}
.appt-status.cancelled{background:color-mix(in srgb,var(--danger) 18%,transparent);color:var(--danger)}
.appt-chev{color:var(--muted);transition:transform .15s}
.appt-row.open .appt-chev{transform:rotate(90deg)}
.appt-body{padding:2px 4px 12px}
.appt-field{display:flex;gap:10px;padding:4px 0;font-size:13px;border-top:1px solid color-mix(in srgb,var(--track) 60%,transparent)}
.appt-field-k{color:var(--muted);width:90px;flex-shrink:0}
.appt-field-v{color:var(--text)}
.msg-unread .appt-spec{font-weight:600}
.msg-unread .appt-spec::first-letter{color:var(--accent)}
.msg-attach{font-size:12px;opacity:.8}

/* micronutrients feed card: grouped mini progress bars */
.feed-card-bars{display:flex;flex-direction:column;gap:6px;margin-top:2px}
.fc-micro-row{display:flex;align-items:center;gap:8px}
.fc-micro-label{font-size:11px;color:var(--muted);width:112px;flex-shrink:0;display:flex;align-items:center;gap:5px;min-width:0}
.fc-micro-name{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;min-width:0}
/* Over-limit pill on a micronutrient group (K6): colour + the word "over" so
   it doesn't rely on colour alone, matching the red bar. */
.fc-micro-over{flex-shrink:0;font-size:9px;font-weight:700;text-transform:uppercase;letter-spacing:.03em;
  color:var(--danger);background:color-mix(in srgb,var(--danger) 18%,transparent);
  border-radius:6px;padding:0 5px;line-height:1.5}
.fc-micro-track{flex:1;height:4px;background:var(--track);border-radius:2px;overflow:hidden}
.fc-micro-fill{height:100%;border-radius:2px}

/* detail pages: small back-arrow header */
.detail-header{display:flex;align-items:center;gap:10px;margin-bottom:14px}
.detail-header h2{font-size:17px;font-weight:600;margin:0;flex:1}
.back-btn{background:none;border:0;color:var(--link);font-size:15px;padding:4px 6px;cursor:pointer;font-family:'DM Sans',sans-serif}

/* FAB: the one deliberate action, always reachable */
.fab{position:fixed;right:20px;bottom:24px;width:58px;height:58px;border-radius:50%;
  background:var(--accent);color:var(--btn-text-on-accent);font-size:28px;font-weight:400;line-height:1;
  border:0;box-shadow:0 6px 20px rgba(0,0,0,.35);cursor:pointer;z-index:40;
  display:flex;align-items:center;justify-content:center;padding:0}

/* Bottom sheets: FAB type-picker + generic quick-log */
.sheet-backdrop{position:fixed;inset:0;background:rgba(0,0,0,.55);z-index:44}
.sheet{position:fixed;left:0;right:0;bottom:0;max-width:600px;margin:0 auto;
  background:var(--surface);border-radius:18px 18px 0 0;
  padding:18px 16px calc(18px + env(safe-area-inset-bottom));z-index:45;
  max-height:80vh;overflow-y:auto;
}
.sheet::before{content:"";position:absolute;left:0;right:0;top:0;height:1.5px;background:var(--tide-border)}
#sheet-picker{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}
#sheet-picker button{display:flex;flex-direction:column;align-items:center;gap:6px;padding:16px 8px;font-size:22px;
  border:1.5px solid var(--track);transition:border-color .15s,background .15s}
#sheet-picker button span{font-size:12px;color:var(--muted)}
/* Gradient-on-hover, same language as .tile.outline (K3 — one hover treatment
   across quick-log entry points: this FAB picker, the toilet/med/supp tiles). */
#sheet-picker button:hover{border-color:transparent;
  background:linear-gradient(var(--surface2) 0 0) padding-box,
             var(--tide-border) border-box;
  border:1.5px solid transparent;
}

/* summary: donut + macro bars (Today's primary card) */
.summary-inner{display:flex;align-items:center;gap:18px}
.donut{width:96px;height:96px;border-radius:50%;flex-shrink:0;
  background:conic-gradient(var(--tide-1), var(--tide-2) 0%, var(--track) 0% 100%);
  display:flex;align-items:center;justify-content:center}
.donut .in{width:74px;height:74px;border-radius:50%;background:var(--surface);
  display:flex;flex-direction:column;align-items:center;justify-content:center}
.donut .n{font-size:22px;font-weight:600;font-family:var(--mono);color:var(--accent)}
.donut .u{font-size:10px;color:var(--muted)}
.macrobars{flex:1;display:flex;flex-direction:column;gap:9px;min-width:0}
.bar .lab{display:flex;justify-content:space-between;font-size:12px;color:var(--muted);margin-bottom:4px}
.bar .lab b{color:var(--text);font-weight:500;font-family:var(--mono)}
.track{height:5px;background:var(--track);border-radius:3px;overflow:hidden}
.track .fill{height:100%;border-radius:3px}

/* entries */
.entries-hdr{display:flex;justify-content:space-between;color:var(--faint);font-size:11px;
  text-transform:uppercase;letter-spacing:.8px;margin:0 2px 6px}
.row{display:flex;align-items:center;gap:10px;padding:9px 10px;border-radius:8px}
.row:nth-child(even){background:var(--surface2)}
.row .tm{font-family:var(--mono);color:var(--faint);font-size:12px;width:40px;flex-shrink:0}
.row .nm{color:var(--text);font-size:14px;flex:1;min-width:0}
.row .sub{color:var(--muted);font-size:11px;margin-top:1px}
.row .kc{font-family:var(--mono);color:var(--text);font-size:13px}
.row .actions{display:flex;gap:2px}
.row-swatch{width:14px;height:14px;border-radius:50%;flex-shrink:0;border:1px solid rgba(255,255,255,.15)}
.chip{font-size:10px;padding:1px 7px;border-radius:4px;background:var(--track);color:var(--muted);margin-left:6px}

/* controls */
button{font:inherit;border:1.5px solid rgba(255,255,255,.12);border-radius:10px;padding:11px 14px;
  background:var(--surface2);color:var(--text);cursor:pointer;font-family:'DM Sans',system-ui,sans-serif}
button:active{transform:scale(.98)}
button.primary,button.go{border:0;font-weight:600}
/* In-flight / disabled control (double-submit guard, see guarded() in util.js). */
button:disabled{opacity:.55;cursor:default;pointer-events:none}
button.primary{background:var(--accent);color:var(--btn-text-on-accent)}
button.go{background:var(--accent);color:var(--btn-text-on-accent)}
/* Destructive confirm button (confirmModal danger=true): red fill, white text. */
button.go.danger{background:var(--danger);color:#fff}
/* An <a class="go"> (e.g. the photo-lightbox Download link) needs the same
   button chrome as button.go — links don't inherit any of the button{} rules. */
a.go{font:inherit;border:0;border-radius:10px;padding:11px 14px;font-weight:600;
  background:var(--accent);color:var(--btn-text-on-accent);cursor:pointer;
  font-family:'DM Sans',system-ui,sans-serif;text-decoration:none;
  display:inline-flex;align-items:center;justify-content:center}
a.go:active{transform:scale(.98)}
input,select{font:inherit;width:100%;padding:11px 12px;border-radius:10px;
  border:1.5px solid rgba(255,255,255,.12);background:var(--surface2);color:var(--text)}
input::placeholder{color:var(--faint)}
input:focus,select:focus{outline:none;border-color:color-mix(in srgb,var(--structure) 60%,transparent)}
/* Shared keyboard-focus ring (A11y / WCAG 2.4.7). :focus-visible only, so mouse
   taps don't draw it — but every tappable thing (buttons, the whole feed-card
   feed, drill-down metric rows, back button, chips, links) gets a clear ring
   for keyboard/switch users. One token drives the colour in both themes. */
:where(button,a,[role="button"],.feed-card,.detail-row,.tests-row,.wg-row,.stack-chip,.tile,.swatch,.preset-chip,input,select):focus-visible{
  outline:2px solid var(--focus-ring);outline-offset:2px;border-radius:6px}
.row-controls,.row{}
.tiles{display:grid;grid-template-columns:repeat(2,1fr);gap:10px}
.tile{padding:16px;text-align:center;font-size:15px}
/* Quick-log tile buttons (supplement/medication catalogue items) restyled to
   match the toilet quick-log's light outline + gradient-on-hover language
   (K3 — one control language across quick-log forms) instead of the plain
   filled .tile look. */
.tile.outline{
  background:transparent;color:var(--text);
  border:1.5px solid var(--track);
  transition:border-color .15s,background .15s;
}
.tile.outline:hover{border-color:transparent;
  background:linear-gradient(var(--surface2) 0 0) padding-box,
             var(--tide-border) border-box;
  border:1.5px solid transparent;
}
/* Low-supply state still needs to read at a glance — a red border override,
   same semantics as before, just layered on top of the outline style. */
.tile.outline.low-supply{border-color:var(--danger)}
.tile.outline.low-supply:hover{
  background:linear-gradient(var(--surface2) 0 0) padding-box,
             linear-gradient(45deg, var(--danger), var(--danger)) border-box;
}

/* One row of evenly-sized "Log … Stack" buttons (Morning/Afternoon/Evening) —
   replaces the old stacked full-width blocks so all periods are visible at a
   glance without scrolling (used by both Supplements and Medications
   quick-log forms). */
.stack-log-row{display:flex;gap:8px;margin-top:10px}
.stack-log-row button{flex:1;min-width:0;padding:11px 4px;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.list-item{display:flex;justify-content:space-between;align-items:center;gap:10px;
  padding:11px 12px;border-radius:10px;background:var(--surface2);margin-bottom:8px}
.list-item .name{font-weight:500;font-size:14px}
.list-item .sub{font-size:12px;color:var(--muted)}
/* Records hub rows: a .list-item that's a <button>, not a <div> (so it's real
   tap target with hover/focus/active states) — reset the global button chrome
   this app applies by default (border, own background, centred text). */
.records-hub-row{width:100%;text-align:left;border:1px solid transparent;background:var(--surface2)}
.records-hub-row:active{background:var(--surface2)}
.bristol{display:grid;grid-template-columns:repeat(7,1fr);gap:6px}
.bristol button{padding:14px 0;font-family:var(--mono)}
.del{background:none;border:0;color:var(--danger);font-size:17px;padding:5px 9px;cursor:pointer}

/* nav + flex helpers (reuse old .row layout for forms) */
.formrow{display:flex;gap:10px}.formrow>*{flex:1}

/* badges + modal + toast */
.badge{font-size:11px;padding:2px 9px;border-radius:999px;background:var(--track);color:var(--muted)}
.badge.offline{background:var(--danger);color:#fff}
.modal{position:fixed;inset:0;background:rgba(0,0,0,.6);display:flex;align-items:center;justify-content:center;padding:20px;z-index:50}
.modal-card{background:var(--surface);border:1px solid var(--border);border-radius:16px;padding:20px;width:100%;max-width:360px}
.modal-card label{display:block;font-size:13px;color:var(--muted);margin-bottom:4px}
/* photo lightbox (tap a CGM box-label thumbnail) — wider than the standard
   360px modal-card so the full-size image is actually viewable, capped to the
   viewport so it never overflows on a small phone. */
.photo-modal-card{max-width:min(560px,92vw)}
.photo-modal-card img{display:block;width:100%;max-height:75vh;object-fit:contain;border-radius:10px;background:var(--surface2)}
/* blocking alert modal (util.js alertModal) — red-accented refusal notice */
.alert-card.danger{border-color:var(--danger);box-shadow:0 0 0 1px var(--danger)}
.alert-card.danger h3{color:var(--danger)}
.alert-card .am-body{color:var(--text);font-size:14px;line-height:1.45;margin:8px 0 0}
/* low-supply / running-out feed banner (cards.js updateSupplyBanner) */
/* offline notice screen (app.js showOffline) — replaces header + feed.
   Anchored near the top (icon high on the screen) rather than vertically
   centred, with a narrowed text column and the Retry button dropped well
   below the copy. */
body.offline-mode header{display:none}
#view-offline{min-height:100vh;display:flex;flex-direction:column;align-items:center;padding:18vh 24px 24px}
/* +20% type scale for this screen; width sized so the copy wraps as
   "DoingWell needs a connection to" / "sync your day" — recheck this wrap
   point on-device after the Ebbwell->DoingWell rename since the new word is
   longer by 2 characters. */
.offline-card{text-align:center;max-width:300px;font-size:1.2em}
.offline-card .offline-icon{display:flex;justify-content:center;margin-bottom:16px}
.offline-card .offline-icon .logo{width:77px;height:77px;border-radius:19px}
.offline-card h2{margin:0 0 10px;font-weight:400;font-size:1.7em}
.offline-card p{margin:0;line-height:1.5}
/* first sentence has an explicit <br> so it always reads
   "DoingWell needs a connection" / "to sync your day." regardless of font metrics;
   the second sentence sits below with a clear gap between the two. */
.offline-card .offline-line2{margin-top:16px}
.offline-card #btn-offline-retry{margin-top:25vh;font-size:1em}
.supply-banner{display:flex;align-items:center;gap:10px;margin-bottom:12px;padding:10px 14px;
  border-radius:12px;background:rgba(239,68,68,.12);border:1px solid var(--danger);color:var(--text);font-size:13px;line-height:1.4}
.supply-banner span{flex:1}
.supply-banner-link{flex:1;background:none;border:none;color:inherit;font:inherit;text-align:left;cursor:pointer;padding:0}
.supply-banner button{background:none;border:none;color:var(--muted);font-size:15px;cursor:pointer;padding:2px 4px}
/* Consistency heatmap (detail-consistency). A plain CSS grid, columns = weeks,
   rows = weekdays (Mon-Sun), oldest week first -- same convention as a GitHub
   contributions graph. Level 0-4 shades from the empty track colour up to the
   full tide gradient, so it reads consistently with the rest of the palette
   rather than introducing a new colour scale. */
.consistency-summary{display:flex;gap:18px;margin-bottom:14px;flex-wrap:wrap}
.consistency-summary .stat{display:flex;flex-direction:column}
.consistency-summary .stat .num{font-size:22px;font-weight:600;font-variant-numeric:tabular-nums}
.consistency-summary .stat .lab{font-size:12px;color:var(--muted)}
.consistency-legend{display:flex;align-items:center;gap:4px;font-size:11px;color:var(--muted);margin-bottom:8px}
.consistency-grid{display:grid;grid-auto-flow:column;grid-template-rows:repeat(7,1fr);gap:3px;overflow-x:auto;padding-bottom:4px}
.consistency-cell{width:11px;height:11px;border-radius:2px;background:var(--track);flex-shrink:0}
.consistency-cell[data-level="0"]{background:var(--track)}
.consistency-cell[data-level="1"]{background:var(--tide-1);opacity:.25}
.consistency-cell[data-level="2"]{background:var(--tide-1);opacity:.5}
.consistency-cell[data-level="3"]{background:var(--tide-2);opacity:.75}
.consistency-cell[data-level="4"]{background:var(--tide-2);opacity:1}
.consistency-pad{background:transparent}
.consistency-legend .consistency-cell{width:10px;height:10px}

/* PKB medicines review rows (pkb.js renderMedReview) */
.pkb-med{border:1px solid var(--border);border-radius:12px;padding:12px;margin-top:10px}
.pkb-med-head{display:flex;justify-content:flex-end}
.pkb-med-status{font-size:11px;text-transform:uppercase;letter-spacing:.04em;font-weight:600}
.pkb-med-name{font-weight:500;font-size:15px}
.pkb-med-orig{font-size:12px;line-height:1.4;margin-top:4px}
.pkb-med input{width:100%}
.toast{position:fixed;bottom:84px;left:50%;transform:translateX(-50%);
  background:var(--surface);border:1px solid var(--border);color:var(--text);
  padding:10px 18px;border-radius:999px;font-weight:500;opacity:0;transition:opacity .2s;pointer-events:none;z-index:60}
.toast.show{opacity:1}
/* Undo toast: same pill, but interactive (an "Undo" affordance) so a deleted
   logged entry can be restored. pointer-events on only while shown. */
.toast.has-action{pointer-events:auto;display:inline-flex;align-items:center;gap:14px}
.toast-undo{background:none;border:0;color:var(--link);font-weight:700;font-size:14px;
  padding:2px 4px;cursor:pointer;font-family:inherit;white-space:nowrap}

/* segmented controls */
.seg{display:flex;gap:6px;margin-top:4px}
.seg.bristol7{display:grid;grid-template-columns:repeat(7,1fr)}
.seg.mood5{display:grid;grid-template-columns:repeat(5,1fr)}
.seg.mood5 button{font-size:20px;padding:8px 0}
.seg button{flex:1;padding:11px 0;border:1.5px solid rgba(255,255,255,.12);border-radius:10px;
  background:var(--surface2);color:var(--muted);font-family:var(--mono)}
.seg button.active{background:rgba(34,211,238,.16);color:var(--text);border-color:rgba(34,211,238,.5);font-weight:600}
.lab2{display:block;color:var(--muted);font-size:13px;margin:14px 0 0}

/* colour swatches (toilet colour picker) */
.swatches{display:flex;flex-wrap:wrap;gap:10px;margin-top:6px}
.swatch{width:34px;height:34px;border-radius:50%;border:2px solid transparent;cursor:pointer}
.swatch.active{border-color:var(--text)}

/* hue slider — fine colour dial below the quick swatches, confined to a
   clinically-realistic gradient (set inline per visit type in JS, not a
   generic rainbow — real stool/urine colour range only, see
   POOP_GRADIENT/PEE_GRADIENT in cards.js). The live preview dot shows the
   CURRENT selected colour (+ clarity/alpha for pee), since the slider
   thumb itself can't carry a colour. */
.hue-row{display:flex;align-items:center;gap:10px}
.hue-slider{flex:1;-webkit-appearance:none;appearance:none;height:10px;border-radius:999px}
.hue-slider::-webkit-slider-thumb{-webkit-appearance:none;width:20px;height:20px;border-radius:50%;
  background:var(--text);border:2px solid var(--page);cursor:pointer}
.hue-slider::-moz-range-thumb{width:20px;height:20px;border-radius:50%;
  background:var(--text);border:2px solid var(--page);cursor:pointer}

/* toilet-log duration stopwatch: tap-to-start/stop timer + a manual mm:ss
   override field that's always the value actually submitted, whether it was
   populated by the stopwatch or hand-typed */
.stopwatch-row{display:flex;align-items:center;gap:10px;margin-top:4px}
.stopwatch-row .go{flex:0 0 auto;padding:9px 16px}
.stopwatch-display{font-family:var(--mono);font-size:16px;color:var(--text);min-width:52px}
.stopwatch-manual{width:80px;flex:0 0 auto;text-align:center;font-family:var(--mono)}
.hue-preview{width:28px;height:28px;border-radius:50%;flex-shrink:0;border:2px solid rgba(255,255,255,.25)}

/* options rows */
/* Options group header (Preferences / Connections) — same eyebrow language as
   the feed sections, so both screens read as grouped, not flat stacks (IA4). */
.opt-group-head{display:flex;align-items:center;gap:10px;margin:6px 2px 10px}
.opt-group-head.spaced{margin-top:22px}
.opt-row{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:7px 0}
.opt-row label,.opt-row .muted{font-size:14px}
.opt-row input{max-width:130px}
.chk{display:flex;align-items:center;gap:8px;color:var(--muted);font-size:13px}
.chk input{width:auto}

/* Stack-period picker — three multi-select toggle chips. Unselected chips wear
   the Tide gradient as text fill (same technique as .wordmark); a selected chip
   flips to the Signal gold fill used by the FAB / primary buttons. */
.stack-picker-label{font-size:11px;font-weight:600;letter-spacing:.06em;
  text-transform:uppercase;color:var(--muted);margin-bottom:8px}
.stack-chips{display:flex;gap:8px}
.stack-chip{flex:1;padding:10px 6px;border-radius:10px;font-size:14px;font-weight:600;
  cursor:pointer;background:transparent;border:1px solid var(--track);
  transition:border-color .15s,background .15s;
  /* Tide gradient text fill when unselected */
  background-image:var(--tide-border);-webkit-background-clip:text;background-clip:text;
  -webkit-text-fill-color:transparent;color:transparent}
.stack-chip:hover{border-color:color-mix(in srgb,var(--tide-1) 55%,var(--track))}
.stack-chip[aria-pressed="true"]{border-color:var(--accent);background:var(--accent);
  /* undo the gradient text-clip so the dark on-accent text shows */
  -webkit-text-fill-color:var(--btn-text-on-accent);color:var(--btn-text-on-accent)}

/* preset edit chips */
.preset-chip{display:inline-flex;align-items:center;gap:6px;background:var(--surface2);
  border:1px solid rgba(255,255,255,.12);border-radius:999px;padding:5px 6px 5px 12px;margin:0 6px 6px 0;font-size:13px}
.preset-chip button{padding:2px 7px;border:0;background:none;color:var(--danger);font-size:14px}

/* meal group headers (Today) */
.meal-hdr{display:flex;justify-content:space-between;align-items:baseline;margin:14px 2px 5px;color:var(--text);font-size:13px;font-weight:600}
.meal-hdr span:last-child{color:var(--muted);font-weight:400;font-family:var(--mono);font-size:12px}

.logo{width:34px;height:34px;border-radius:9px;display:block}

/* nutrient groups */
.nrow{margin-bottom:10px;cursor:pointer;border-radius:8px;padding:4px;margin:-4px -4px 6px -4px}
.nrow:active{background:var(--surface2)}
.nrow .lab{display:flex;justify-content:space-between;font-size:13px;color:var(--muted);margin-bottom:4px}
.nrow .lab b{color:var(--text);font-weight:500;font-family:var(--mono)}
.nrow .track{height:5px;background:var(--track);border-radius:3px;overflow:hidden}
.nrow .fill{height:100%;border-radius:3px}
/* supplement nutrient entry grid */
.sngrid{display:grid;grid-template-columns:1fr 78px;gap:6px 10px;align-items:center}
.sngrid label{font-size:12px;color:var(--muted)}
.sngrid input{padding:7px 8px}
