:root {
  /* COLOR = the direction/state of a VALUE, never a category, never branding,
     never "nice". Attach color only to a delta, a status dot, or an out-of-range
     value — never to chrome (no colored borders, fills, glyphs, or chips). One
     channel per signal. In-range facts get ZERO color. At most one --warn and
     one --good above the fold. --accent is interaction-only (links/focus/active). */
  /* SURFACE SCALE — Radix-dark-gray-style stepping (Linear). Each step is a
     genuinely perceptible jump so cards/rows/sections stay distinct even at
     reduced screen brightness, where near-black grays otherwise collapse. */
  --bg: #0d0f12;       /* page canvas */
  --panel: #131720;    /* cards, nav-active, metric cells — clearly above bg */
  --surface: #1a1f29;  /* elevated: inputs, primary action card, tooltips, drawer */
  --raised: #212736;   /* hover/active states, the one-up nudge */
  --line: #252c38;     /* default border — reads at lower brightness */
  --line-strong: #353e4f; /* section rules / dividers that must pop */
  /* TEXT RAMP — calm AND high-contrast (Linear/Stripe). --faint is STRUCTURE
     ONLY (borders, rings, disabled) and must NEVER set readable text. */
  --text: #f1f3f8;     /* primary near-white ~14:1 — titles, numerals, hero */
  --muted: #9aa3b2;    /* the readable FLOOR ~5.8:1 — body, payoff, meta */
  --label: #aeb4c2;    /* brightest non-primary — small uppercase micro-labels */
  --faint: #6b7587;    /* chrome + faint structure; lifted to read when dimmed */
  --accent: #6cb6f5;   /* interaction only: links, focus, CTAs */
  --good: #4ec291;     /* improving / back-in-range — vivid, full strength */
  --warn: #f0675a;     /* out of range / act now — the loudest, fully saturated */
  --amber: #e0a44a;    /* watch / borderline / recheck-due / stale */

  /* ONE coherent modular type ladder (~1.25). Hierarchy = visual weight, and
     visual weight tracks information importance. Weight (400/600/700) does the
     fine-grain work — no two readable tiers sit within a couple px doing
     different jobs. The big jump (20→32) is spent only on the brief. */
  --t-hero: 32px;    /* THE BRIEF only — the page's dominant element */
  --t-3xl: 26px;     /* vital display numerals only */
  --t-primary: 20px; /* the single #1-action title only */
  --t-xl: 17px;      /* secondary metric values (last-night/screen grids) */
  --t-lg: 16px;      /* lead / feed titles / prose / payoff */
  --t-md: 14px;      /* body, watch rows, demoted alert, meta */
  --t-sm: 12px;      /* labels, eyebrows, pills, deltas, chrome */
  --t-section: 12px; /* (alias — section labels use --t-sm size now) */

  /* spacing — multiples of 4 */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s6: 24px;
  --s7: 28px;

  --ls: .06em;    /* one letter-spacing for all uppercase micro-labels */

  --chat-w: 400px;  /* docked chat sidebar width (drawer + reflow padding) */
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: var(--t-md)/1.45 -apple-system, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  font-variant-numeric: tabular-nums;
}

/* keyboard focus — ONE visible ring for every interactive element. Non-input
   controls reset their background/border, which suppresses the UA default ring
   on dark; this restores a consistent, on-brand focus indicator everywhere.
   (Inputs signal focus via their border-color swap, so they're excluded.) */
a:focus-visible, button:focus-visible, select:focus-visible,
summary:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px;
}

/* one treatment for every uppercase micro-label */
.label, .block .label, .smetric .label, .strip-name, .domain, .lab-table th,
.schart-label, .pattern .ptitle, h2 {
  font-size: var(--t-sm); text-transform: uppercase; letter-spacing: var(--ls);
}

/* ---- sidebar nav ----
   Every section lives in a fixed left rail, grouped by what it's about. The top bar ran out of
   room at 12 sections; a rail scales and keeps the active section visible at all times. */
:root { --sb-w: 212px; }
#sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sb-w); z-index: 60; display: flex; flex-direction: column;
  background: var(--bg); border-right: 1px solid var(--line); padding: var(--s4) var(--s3); gap: var(--s4); }
body { padding-left: var(--sb-w); }
.brand { font-weight: 600; letter-spacing: .02em; padding: 0 var(--s2); }
.sb-top { display: flex; flex-direction: column; gap: var(--s3); }
.sb-search { display: flex; align-items: center; gap: var(--s2); width: 100%; font: inherit; font-size: var(--t-sm);
  color: var(--muted); background: var(--panel); border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; cursor: pointer; }
.sb-search:hover { color: var(--text); border-color: var(--raised); }
.sb-search .ico { width: 14px; height: 14px; }
.sb-search span { flex: 1; text-align: left; }
kbd { font: inherit; font-size: 11px; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 5px; line-height: 16px; }
.sb-nav { display: flex; flex-direction: column; gap: 1px; overflow-y: auto; flex: 1; min-height: 0; }
.sb-group { color: var(--label); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: var(--ls);
  padding: var(--s3) var(--s2) var(--s1); }
.sb-group:first-child { padding-top: 0; }
.sb-nav a { display: flex; align-items: center; gap: 9px; color: var(--muted); text-decoration: none; font-size: var(--t-md);
  padding: 5px var(--s2); border-radius: 6px; border: 1px solid transparent; }
.sb-nav a .ico { width: 15px; height: 15px; color: var(--faint); flex-shrink: 0; }
.sb-nav a:hover { color: var(--text); background: var(--panel); }
.sb-nav a.on { color: var(--text); background: var(--panel); border-color: var(--line); }
.sb-nav a.on .ico { color: var(--text); }
.sb-nav a[hidden] { display: none; }
.sb-foot { display: flex; flex-direction: column; gap: var(--s2); border-top: 1px solid var(--line); padding-top: var(--s3); }
.sb-foot .meta { flex-wrap: wrap; row-gap: 2px; padding: 0 var(--s2); }
.sb-actions { display: grid; grid-template-columns: 1fr; gap: 6px; }
.sb-actions button { justify-content: center; white-space: nowrap; width: 100%; }
.mobile-bar, #sb-scrim { display: none; }
.sb-icon-btn { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 7px; padding: 5px; cursor: pointer; display: inline-flex; }
.sb-icon-btn .ico { width: 16px; height: 16px; }
/* narrow screens: the rail becomes an off-canvas drawer behind a slim top bar */
@media (max-width: 900px) {
  body { padding-left: 0; }
  .mobile-bar { display: flex; align-items: center; gap: var(--s3); position: sticky; top: 0; z-index: 50;
    background: var(--bg); border-bottom: 1px solid var(--line); padding: var(--s2) var(--s4); }
  .mobile-bar .brand { flex: 1; padding: 0; }
  #sidebar { transform: translateX(-100%); transition: transform .18s ease-out; width: min(280px, 82vw); }
  body.sb-open #sidebar { transform: none; }
  #sidebar { z-index: 85; padding-top: calc(var(--s4) + env(safe-area-inset-top)); padding-bottom: calc(var(--s3) + env(safe-area-inset-bottom)); }
  body.sb-open #sb-scrim { display: block; position: fixed; inset: 0; z-index: 80; background: rgba(0,0,0,.55); }
}
@media (prefers-reduced-motion: reduce) { #sidebar { transition: none; } }
.meta { color: var(--muted); font-size: var(--t-sm); display: inline-flex; align-items: center; gap: 5px; transition: color .3s; }
.meta .ico { width: 13px; height: 13px; }
.meta.just-synced { color: var(--good); }
.sync-spin { display: inline-flex; animation: spin 1s linear infinite; }
.sync-spin .ico { width: 13px; height: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }
/* accordion / disclosure content eases in on open. The resting state is fully
   visible, so the reveal only enhances — content never depends on it to show. */
@keyframes reveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
/* content eases in only when a disclosure is actually opened (JS adds .reveal-open
   on the `toggle` event) — a background re-render that recreates an already-open
   <details> won't replay it. Resting state stays fully visible. */
details.reveal-open > summary ~ * { animation: reveal .22s ease-out; }
/* tab switch: a quick opacity fade of the newly shown page. No translate — the
   DOM is already mounted, so a slide would falsely imply content is arriving. */
@keyframes page-in { from { opacity: 0; } to { opacity: 1; } }
.page.page-in { animation: page-in 140ms ease-out; }
@media (prefers-reduced-motion: reduce) {
  details.reveal-open > summary ~ *, .page.page-in { animation: none; }
  .box-collapse > summary::before, .screen-wrap > summary::before, .chat-mcp > summary::before { transition: none; }
}
.sync-err { color: var(--warn); }
/* data-freshness status: a dot + label reflecting DATA recency (newest night),
   kept distinct from "checked Xm ago" (when we last pulled + analyzed). */
.fresh { display: inline-flex; align-items: center; gap: 5px; font-size: var(--t-sm); font-weight: 600; cursor: help; }
.fresh-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); flex-shrink: 0; }
.fresh-current { color: var(--good); } .fresh-current .fresh-dot { background: var(--good); box-shadow: 0 0 0 3px rgba(78,194,145,.18); }
.fresh-behind { color: var(--amber); } .fresh-behind .fresh-dot { background: var(--amber); box-shadow: 0 0 0 3px rgba(224,164,74,.18); }
.fresh-stale { color: var(--warn); } .fresh-stale .fresh-dot { background: var(--warn); box-shadow: 0 0 0 3px rgba(240,103,90,.18); }
.fresh-idle { color: var(--muted); }
.fresh-checked { color: var(--muted); font-size: var(--t-sm); }
.fresh-checked::before { content: "· "; color: var(--faint); }
/* per-module breakdown shown on hover of the status (reuses #tip) */
.fresh-tip-row { display: flex; align-items: baseline; gap: 6px; margin-top: 6px; font-size: var(--t-sm); }
.fresh-tip-row .fresh { font-weight: 400; cursor: default; }
.fresh-tip-row .ico { width: 13px; height: 13px; color: var(--faint); flex-shrink: 0; }
.fresh-tip-name { color: var(--text); font-weight: 600; white-space: nowrap; }
.fresh-tip-rec { color: var(--muted); }
#refresh { background: none; border: 1px solid var(--line); color: var(--muted); font: inherit; font-size: var(--t-sm); font-weight: 550; padding: 4px 10px; border-radius: 7px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
#refresh .ico { width: 13px; height: 13px; }
#refresh:hover:not(:disabled) { color: var(--text); border-color: var(--raised); }
#refresh:disabled { color: var(--muted); cursor: default; }

.page { display: none; }
.page.on { display: block; }

main { max-width: 1180px; margin: 0 auto; padding: var(--s2) 20px 40px; }

/* ---- section headings ---- */
h2 { font-weight: 600; color: var(--muted); }
.h2sub { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); font-size: var(--t-sm); }

/* small tracked uppercase labels need MORE luminance, not less → --label */
.eyebrow, .t-label, .schart-label, #strips .strips-label { color: var(--label); }
.eyebrow { color: var(--label); font-size: var(--t-sm); font-weight: 600; text-transform: uppercase; letter-spacing: var(--ls); }

/* pill / tag — legible category label with a real container edge */
.tag { display: inline-flex; align-items: center; height: 18px; padding: 0 8px; border-radius: 5px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.07); color: var(--label);
  font-size: var(--t-sm); line-height: 1; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }
.tag.warn { background: rgba(240,103,90,.13); border-color: transparent; color: #f3a79e; }

/* staleness caveat — a quiet line, not an emergency box (the fact is in the brief) */
.alert { display: flex; gap: var(--s2); align-items: center; font-size: var(--t-md); color: var(--muted); }
.alert::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); flex-shrink: 0; }
.alert .ico { display: none; }
.alert .a-title { color: var(--muted); font-weight: 400; font-size: var(--t-md); }
.alert .a-cta { color: var(--accent); text-decoration: none; margin-left: 4px; }
.alert .a-cta:hover { text-decoration: underline; }
.alert .a-cta .ico { display: none; }
/* labeled section header — bold tracked title + count + a rule that runs right */
.sec-head { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s4); }
.sec-label { color: var(--text); font-size: var(--t-section); font-weight: 700; text-transform: uppercase; letter-spacing: .09em; white-space: nowrap; }
.sec-sub { color: var(--muted); font-size: var(--t-sm); white-space: nowrap; }
.sec-rule { flex: 1; height: 1px; background: var(--line-strong); }
#alerts:empty, #actionplan:empty { display: none; }
#alerts { margin-top: var(--s3); }   /* tight under the brief — a caveat */
#actionplan, #vitals, #synth, #watch { margin-top: 40px; }
#actionplan .hero-action { margin-top: 0; }
#actionplan .feed { margin-top: var(--s2); }

/* inline SVG icon — one stroke weight across the whole set */
.ico { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.5; fill: none;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
/* vendored brand marks are filled single-path logos, not line glyphs */
.ico-brand { stroke: none; fill: currentColor; }
/* brand marks carry their brand color — a deliberate exception to the otherwise
   monochrome system; near-black brands (Apple, Peloton) are lightened so they
   stay legible on the dark canvas. Services without a real mark stay grey. */
.ico-b-peloton { color: #e01a2b; }
.ico-b-strava { color: #fc4c02; }
.ico-b-garmin { color: #1a9fe0; }
.ico-b-fitbit { color: #00b0b9; }
.ico-b-apple_health { color: #e2e5ec; }
.ico-b-google_health { color: #4285f4; }
.ico-b-headspace { color: #f47d31; }
.ico-b-anthropic { color: #d97757; }
.ico-b-openai { color: #74aa9c; }
.eyebrow .ico, .good .ico, .warn .ico, .muted .ico, .t-arrow .ico, .stale-note .ico { width: 13px; height: 13px; vertical-align: -2px; }

/* ---- THE BRIEF — the page's dominant element (visual weight = importance) ---- */
#briefing { margin-top: 40px; margin-bottom: 8px; }
.brief-date { color: var(--muted); font-size: var(--t-sm); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; margin-bottom: 12px; }
.brief-body { font-size: var(--t-hero); font-weight: 600; line-height: 1.3; color: var(--text); max-width: 700px; letter-spacing: -.01em; }
.brief-body strong { font-weight: 700; }   /* risk terms carry inline emphasis */
/* DAY RANKS — F · C · B · A · S. The one place the page is allowed to be playful: a game-rank
   stamp. Colors are still state (S gold > A green > B blue > C amber > F red), never decoration. */
:root { --rk-S: #f2c14e; --rk-A: #4ec291; --rk-B: #7aa7ff; --rk-C: #e0a44a; --rk-F: #f0675a; }
.rchip { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 5px; font-size: 13px; font-weight: 900;
  font-style: italic; letter-spacing: -.02em; line-height: 1; border: 1.5px solid currentColor; transform: skewX(-8deg); flex: 0 0 auto; }
.rchip.prov { border-style: dashed; }
.rchip.rk-none { color: var(--faint); border-color: var(--line-strong); font-style: normal; }
.rk-S { color: var(--rk-S); background: rgba(242,193,78,.12); }
.rk-A { color: var(--rk-A); background: rgba(78,194,145,.12); }
.rk-B { color: var(--rk-B); background: rgba(122,167,255,.12); }
.rk-C { color: var(--rk-C); background: rgba(224,164,74,.12); }
.rk-F { color: var(--rk-F); background: rgba(240,103,90,.12); }
.today-top { display: flex; align-items: center; gap: var(--s6); }
.today-main { min-width: 0; }
.today-top .today-why { margin-left: 0; }
.rstamp { position: relative; flex: 0 0 auto; width: 104px; height: 104px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 3px solid currentColor; border-radius: 14px; transform: rotate(-6deg); overflow: hidden; }
.rstamp-l { font-size: 64px; font-weight: 900; font-style: italic; line-height: .9; letter-spacing: -.04em; }
.rstamp-c { font-size: 10px; font-weight: 800; letter-spacing: .24em; text-transform: uppercase; margin-top: 2px; }
.rstamp-q { position: absolute; left: 50%; bottom: -26px; transform: translateX(-50%) rotate(6deg); white-space: nowrap; font-size: var(--t-sm); color: var(--muted); display: none; }
@keyframes rk-pop { 0% { transform: rotate(-6deg) scale(.6); opacity: 0; } 70% { transform: rotate(-6deg) scale(1.08); opacity: 1; } 100% { transform: rotate(-6deg) scale(1); } }
.rstamp { animation: rk-pop .45s cubic-bezier(.23,1,.32,1) both; }
/* S IS SUPER — the only tier that gets juice: gradient (gold → amber → pink → violet), a breathing
   glow, a one-time pop, a periodic shimmer and, on the big stamp, twinkling sparkles. A gets a faint
   static glow; everything else stays flat. The contrast is the effect. */
:root { --rk-S-grad: linear-gradient(135deg, #ffe07a 0%, #f2c14e 22%, #ff9a3c 45%, #ff5fa2 72%, #a77bff 100%); }
.rstamp.rk-S { overflow: visible; border-color: transparent; color: #ffe07a;
  background: linear-gradient(135deg, rgba(242,193,78,.14), rgba(255,95,162,.10) 60%, rgba(167,123,255,.14)) padding-box,
    linear-gradient(var(--panel), var(--panel)) padding-box, var(--rk-S-grad) border-box;
  animation: rk-pop-S .6s cubic-bezier(.34,1.56,.64,1) both; }
.rstamp.rk-S .rstamp-l { background: var(--rk-S-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 1px 0 rgba(0,0,0,.45)); padding-right: .08em; }
.rstamp.rk-S .rstamp-c { background: var(--rk-S-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.rstamp.rk-S::before { content: ""; position: absolute; inset: -3px; border-radius: inherit; z-index: -1; pointer-events: none;
  box-shadow: 0 0 22px 2px rgba(242,193,78,.55), 0 0 44px 8px rgba(255,95,162,.30), 0 0 70px 14px rgba(167,123,255,.20);
  animation: rk-breathe 3.2s ease-in-out infinite; }
.rk-fx { position: absolute; inset: 0; border-radius: inherit; overflow: hidden; pointer-events: none; }
.rk-fx::after { content: ""; position: absolute; top: -20%; bottom: -20%; left: 0; width: 60%;
  background: linear-gradient(100deg, transparent 20%, rgba(255,255,255,.55) 50%, transparent 80%); mix-blend-mode: overlay;
  transform: translateX(-160%) skewX(-12deg); animation: rk-sweep 4.5s ease-in-out 1s infinite; }
.rk-spark { position: absolute; width: 12px; height: 12px; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, #fff 0 20%, #ffe07a 45%, transparent 70%);
  clip-path: polygon(50% 0, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0 50%, 40% 40%);
  animation: rk-twinkle 2.6s ease-in-out infinite; }
.rk-spark.s1 { top: -8px; right: -6px; animation-delay: .7s; }
.rk-spark.s2 { bottom: 10px; left: -9px; width: 9px; height: 9px; animation-delay: 1.6s; background: radial-gradient(circle, #fff 0 20%, #ff9fcb 45%, transparent 70%); }
.rk-spark.s3 { top: 20px; left: -4px; width: 7px; height: 7px; animation-delay: 2.3s; background: radial-gradient(circle, #fff 0 20%, #c9b0ff 45%, transparent 70%); }
.rk-spark.s4 { bottom: -7px; right: 18px; width: 8px; height: 8px; animation-delay: 1.1s; }
.rchip.rk-S { position: relative; overflow: hidden; color: #1d1204; background: var(--rk-S-grad); border-color: rgba(255,224,122,.9);
  text-shadow: 0 1px 0 rgba(255,255,255,.35);
  box-shadow: 0 0 8px rgba(242,193,78,.55), 0 0 16px rgba(255,95,162,.30);
  animation: rk-chip-pop .5s cubic-bezier(.34,1.56,.64,1) both; }
.rchip.rk-S::after { content: ""; position: absolute; inset: -2px -60%; pointer-events: none;
  background: linear-gradient(100deg, transparent 38%, rgba(255,255,255,.75) 50%, transparent 62%);
  transform: translateX(-70%); animation: rk-chip-sweep 5s ease-in-out 1.2s infinite; }
.rchip.cal-rank.rk-S { position: absolute; }
.rchip.rk-A { box-shadow: 0 0 6px rgba(78,194,145,.22); }
.tcell-q.rq-S { background: var(--rk-S-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
@keyframes rk-pop-S { 0% { transform: rotate(-6deg) scale(.5); opacity: 0; } 60% { transform: rotate(-6deg) scale(1.12); opacity: 1; }
  80% { transform: rotate(-6deg) scale(.97); } 100% { transform: rotate(-6deg) scale(1); } }
@keyframes rk-chip-pop { 0% { transform: skewX(-8deg) scale(.5); opacity: 0; } 70% { transform: skewX(-8deg) scale(1.15); opacity: 1; } 100% { transform: skewX(-8deg) scale(1); } }
@keyframes rk-breathe { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
@keyframes rk-sweep { 0%, 18% { transform: translateX(-160%) skewX(-12deg); } 100% { transform: translateX(260%) skewX(-12deg); } }
@keyframes rk-chip-sweep { 0%, 16% { transform: translateX(-70%); } 32%, 100% { transform: translateX(70%); } }
@keyframes rk-twinkle { 0%, 100% { opacity: 0; transform: scale(.3) rotate(0deg); } 45% { opacity: 1; transform: scale(1) rotate(45deg); } 70% { opacity: 0; transform: scale(.5) rotate(90deg); } }
.tcell-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.tcell-q { font-size: var(--t-sm); font-weight: 600; font-style: italic; margin-top: 2px; color: var(--muted); }
.tcell-q.rq-S { color: var(--rk-S); } .tcell-q.rq-A { color: var(--rk-A); } .tcell-q.rq-B { color: var(--rk-B); }
.tcell-q.rq-C { color: var(--rk-C); } .tcell-q.rq-F { color: var(--rk-F); }
.rstrip { display: flex; align-items: center; gap: var(--s4); margin-top: var(--s4); flex-wrap: wrap; }
.rs-days { display: flex; gap: 6px; }
.rs-day { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.rs-day .rs-w { font-size: 10px; color: var(--muted); font-weight: 600; }
.rs-day.today .rs-w { color: var(--text); }
.rs-day.today .rchip { outline: 2px solid var(--line-strong); outline-offset: 2px; }
.rs-brag { font-size: var(--t-sm); color: var(--muted); }
.cal-rank { position: absolute; top: 4px; right: 4px; width: 18px; height: 18px; font-size: 11px; }
@media (prefers-reduced-motion: reduce) { .rstamp, .rstamp.rk-S, .rchip.rk-S { animation: none; }
  .rstamp.rk-S::before { animation: none; opacity: .8; } .rk-fx, .rchip.rk-S::after, .rk-spark { display: none; } }
@media (max-width: 760px) {
  .today-top { gap: var(--s4); align-items: flex-start; }
  .rstamp { width: 72px; height: 72px; border-width: 2.5px; border-radius: 10px; }
  .rstamp-l { font-size: 42px; }
  .rstamp-c { font-size: 8px; }
  .rs-days { gap: 4px; }
  .rs-day .rchip { width: 18px; height: 18px; font-size: 11px; }
}
/* HEALTH CALENDAR (Calendar page) */
#cal-health { margin-bottom: var(--s7); }
.calh-connect { max-width: 760px; }
.calh-lead { color: var(--text); font-size: var(--t-lg); line-height: 1.5; margin-bottom: var(--s3); }
.calh-lead strong { font-weight: 650; }
.calh-steps { color: var(--muted); font-size: var(--t-md); line-height: 1.6; padding-left: 20px; margin: 0 0 var(--s3); }
.calh-steps a { color: var(--accent); }
.calh-steps em { color: var(--text); font-style: normal; }
.calh-form { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; margin: var(--s2) 0; }
.calh-form input, .calh-form select { font: inherit; font-size: var(--t-md); color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.calh-form input { flex: 1; min-width: 220px; }
.calh-form input:focus, .calh-form select:focus { outline: none; border-color: var(--accent); }
.calh-note { color: var(--muted); font-size: var(--t-sm); line-height: 1.5; margin: var(--s2) 0; }
.calh-note a { color: var(--accent); }
.calh-top { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s4); flex-wrap: wrap; margin-bottom: var(--s4); }
.calh-counts { display: flex; align-items: baseline; gap: var(--s4); flex-wrap: wrap; }
.calh-count { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--t-md); }
.calh-count strong { color: var(--text); font-size: var(--t-xl); font-weight: 650; font-variant-numeric: tabular-nums; }
.calh-count .ico, .calh-next .ico { width: 15px; height: 15px; color: var(--faint); align-self: center; }
.calh-sub { color: var(--muted); font-size: var(--t-sm); }
.calh-next { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--t-md); }
.calh-next strong { color: var(--text); font-weight: 600; }
.calh-list { list-style: none; margin: var(--s2) 0 0; padding: 0; border-top: 1px solid var(--line); }
.calh-ev { display: grid; grid-template-columns: 24px 170px minmax(0, 1fr) auto; gap: var(--s3); align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.calh-ico .ico { width: 15px; height: 15px; color: var(--faint); display: block; }
.calh-when { color: var(--muted); font-size: var(--t-sm); font-variant-numeric: tabular-nums; }
.calh-title { color: var(--text); font-size: var(--t-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.calh-cat { color: var(--muted); font-size: var(--t-sm); }
.calh-rules { margin-top: var(--s4); }
.calh-rules > summary { cursor: pointer; color: var(--muted); font-size: var(--t-sm); }
.calh-rules > summary:hover { color: var(--text); }
.calh-chips { display: flex; flex-wrap: wrap; gap: var(--s2); margin: var(--s2) 0; }
.calh-rule { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-sm); color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 3px 4px 3px 8px; }
.calh-rule.ign { color: var(--muted); }
.calh-rule button { background: none; border: 0; padding: 2px; cursor: pointer; color: var(--faint); display: inline-flex; }
.calh-rule button:hover { color: var(--warn); }
.calh-rule .ico { width: 11px; height: 11px; }
.cal-ev { display: inline-flex; color: var(--accent); }
.cal-ev .ico { width: 13px; height: 13px; }
.titem.is-cal.done .titem-ico { color: var(--good); }
@media (max-width: 760px) {
  .calh-ev { grid-template-columns: 22px minmax(0, 1fr); row-gap: 2px; }
  .calh-ev .calh-title { grid-column: 2; white-space: normal; }
  .calh-ev .calh-cat { display: none; }
  .calh-when { grid-column: 2; }
}
/* TODAY — verdict, why, four cells, the short list */
.today-head { display: flex; align-items: baseline; gap: 14px; }
.today-dot { flex: 0 0 auto; width: 12px; height: 12px; border-radius: 50%; background: var(--faint); transform: translateY(-4px); }
.today-dot.good { background: var(--good); box-shadow: 0 0 0 4px rgba(78,194,145,.16); }
.today-dot.ok { background: var(--muted); }
.today-dot.watch { background: var(--amber); box-shadow: 0 0 0 4px rgba(224,164,74,.16); }
.today-dot.low { background: var(--warn); box-shadow: 0 0 0 4px rgba(240,103,90,.16); }
.today-why { color: var(--muted); font-size: var(--t-lg); line-height: 1.5; margin: var(--s2) 0 0 26px; max-width: 760px; font-variant-numeric: tabular-nums; }
.tcells { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin-top: var(--s6);
  background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.tcell { display: flex; flex-direction: column; gap: 2px; padding: var(--s3) var(--s4); background: var(--bg); text-decoration: none; color: inherit; min-width: 0; }
.tcell:hover { background: var(--panel); }
.tcell-l { font-size: var(--t-sm); color: var(--label); font-weight: 600; text-transform: uppercase; letter-spacing: var(--ls); }
.tcell-v { font-size: var(--t-3xl); font-weight: 650; color: var(--text); font-variant-numeric: tabular-nums; line-height: 1.2; }
.tcell-v.good { color: var(--good); }
.tcell-v.amber { color: var(--amber); }
.tcell-v.warn { color: var(--warn); }
.tcell-n { font-size: var(--t-sm); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tlist-h { display: flex; align-items: baseline; gap: var(--s2); margin: var(--s6) 0 var(--s2); }
.tlist-c { font-size: var(--t-sm); color: var(--muted); }
.tlist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); max-width: 900px; }
.titem { display: flex; align-items: center; gap: var(--s3); min-height: 44px; padding: 8px 12px; font: inherit; text-align: left;
  color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; cursor: pointer; text-decoration: none; min-width: 0; }
.titem:hover:not(:disabled) { border-color: var(--line-strong); background: var(--surface); }
.titem:disabled { cursor: default; }
.titem-box { flex: 0 0 auto; width: 18px; height: 18px; border-radius: 5px; border: 1.5px solid var(--line-strong); display: grid; place-items: center; }
.titem-box .ico { width: 12px; height: 12px; color: var(--bg); }
.titem.done .titem-box { background: var(--good); border-color: var(--good); }
.titem.done .titem-t { color: var(--muted); }
.titem-ico { flex: 0 0 auto; width: 18px; display: grid; place-items: center; color: var(--faint); }
.titem-ico .ico { width: 15px; height: 15px; }
.titem-t { font-size: var(--t-md); font-weight: 500; white-space: nowrap; }
.titem-n { font-size: var(--t-sm); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.stand-lead { color: var(--text); font-size: var(--t-lg); line-height: 1.5; max-width: 760px; margin-bottom: var(--s4); }
.stand-lead strong { font-weight: 650; }
/* labs: how old each result is */
.lab-when { white-space: nowrap; color: var(--muted); font-size: var(--t-sm); text-align: right; }
.lab-table th.lab-when-h { text-align: right; }
.lab-prev { color: var(--muted); }
.lab-ages { color: var(--muted); font-size: var(--t-sm); margin: 0 0 var(--s2); line-height: 1.6; }
.lab-ages .stale { color: var(--amber); }
@media (max-width: 760px) {
  .tcells { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tlist { grid-template-columns: 1fr; }
  .today-why { margin-left: 0; font-size: var(--t-md); }
  .tcell-v { font-size: var(--t-xl); }
  .tcell-n { white-space: normal; }
}
.stale-note { color: var(--amber); font-size: var(--t-sm); margin-top: var(--s2); }
.stale-note a { color: var(--accent); text-decoration: none; }


/* ---- vitals: boxed 3-up, big values, color only on the arrow ---- */
#vitals { margin-top: var(--s6); }
/* flat hairline grid — the NUMBERS carry the weight, not a box */
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; background: none; border: 0; }
.tile { background: none; padding: 0 24px; border-left: 1px solid var(--line); }
.tile:first-child { padding-left: 0; border-left: 0; }
.t-label { color: var(--label); font-size: var(--t-sm); font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }
.t-value { font-size: var(--t-3xl); font-weight: 650; color: var(--text); margin-top: var(--s1); display: flex; align-items: center; gap: 6px; }
.t-arrow .ico { width: 18px; height: 18px; }
.t-arrow { display: inline-flex; }
.t-arrow.good, .good { color: var(--good); }
.t-arrow.warn { color: var(--warn); }
.t-arrow.amber { color: var(--amber); }
.t-value.v-amber { color: var(--amber); }
.t-sub { color: var(--muted); font-size: var(--t-sm); margin-top: 2px; }
.vitals-foot { color: var(--muted); font-size: var(--t-sm); margin-top: var(--s3); }
.vitals-foot .good { color: var(--good); }
.vitals-foot .muted { color: var(--muted); }

/* ---- cardiovascular synthesis: prose, no rail, no box ---- */
#synth:empty { display: none; }
#synth { margin-top: var(--s6); }
.synth-b { color: var(--muted); margin-top: var(--s2); line-height: 1.55; max-width: 640px; font-size: var(--t-lg); }
.synth-claims { margin-top: var(--s2); color: var(--muted); font-size: var(--t-sm); }
.synth-claims .mid { color: var(--muted); margin: 0 7px; }
.claim { color: var(--muted); }

/* ---- watchlist ---- */
#watch:empty { display: none; }
#watch { margin-top: var(--s6); }
#watch .eyebrow { margin-bottom: var(--s1); }
.watch-row { display: flex; gap: var(--s3); padding: 4px 0; border-bottom: 1px solid var(--line); font-size: var(--t-md); }
.watch-what { flex: 1; color: var(--text); }
.watch-when { color: var(--muted); }
.watch-cost { color: var(--muted); min-width: 90px; text-align: right; }
@media (max-width: 760px) { .tiles { grid-template-columns: 1fr; gap: var(--s3); } .tile { border-left: 0; padding-left: 0; } }

/* ---- banner (sleep page only now) ---- */
#banner:empty, #verdict:empty { display: none; }
.banner { margin-top: var(--s4); padding: var(--s3); border-left: 3px solid var(--warn); background: #1c1416; }
.banner.info { border-left-color: var(--amber); background: var(--panel); }
.banner .btitle { font-weight: 600; }
.banner .baction { color: var(--muted); font-size: var(--t-sm); margin-top: var(--s1); }
.verdict { margin-top: var(--s3); font-size: var(--t-lg); line-height: 1.5; color: var(--text); }

/* ---- actions / insights: flat hairline rows ---- */
#actions, #insights { margin-top: 0; }
.insight {
  display: grid; grid-template-columns: 12px 1fr auto; gap: var(--s3);
  padding: 16px 0; border-bottom: 1px solid var(--line); background: none;
  align-items: start;
}
.dot { width: 9px; height: 9px; border-radius: 50%; margin-top: 6px; }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px rgba(240,103,90,.18); }
.dot.good { background: var(--good); box-shadow: 0 0 0 3px rgba(78,194,145,.18); }
.dot.quiet { background: none; box-shadow: inset 0 0 0 1.5px #6b7283; }
.insight .body .title { color: var(--text); font-weight: 600; font-size: var(--t-lg); }
.payoff { color: var(--muted); font-size: var(--t-md); margin-top: 4px; line-height: 1.5; }
.insight .side { align-self: start; margin-top: 4px; }
.insight .side svg { display: block; }
.delta { color: var(--muted); font-size: var(--t-sm); }

/* the #1 action earns primacy through elevation + position + CTA — NOT a bigger
   title. Same title size as the feed; the surface lift + CTA carry the emphasis. */
.insight.is-primary { background: var(--surface); border: 1px solid var(--line); border-radius: 8px;
  padding: 18px 20px; margin-bottom: var(--s3); }
.insight.is-primary .payoff { margin-top: 5px; }

/* the why explanation — a full-width block under the row, toggled inline */
.more-body { color: var(--muted); font-size: var(--t-md); line-height: 1.55; max-width: 720px;
  margin-top: 10px; }
.more-body[hidden] { display: none; }

/* footer controls — Why this + Mark done sit together, always same place */
.row-foot { display: flex; align-items: center; gap: var(--s4); margin-top: 12px; }
/* Age of the evidence behind an alert. Pushed to the far end so it reads as provenance, not as
   another control; goes semantic-warn once the data is old enough to distrust the conclusion. */
.asof { margin-left: auto; display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--t-sm); color: var(--faint); white-space: nowrap; }
.asof .ico { width: 12px; height: 12px; }
.asof.stale { color: var(--warn); }
.why-btn { display: inline-flex; align-items: center; gap: 4px; background: none; border: 0; padding: 0;
  font: inherit; font-size: var(--t-sm); font-weight: 600; color: var(--accent); cursor: pointer; }
.why-btn:hover { text-decoration: underline; }
.why-btn .ico { width: 13px; height: 13px; transition: transform .12s; }
.why-btn.open .ico { transform: rotate(180deg); }
.row-cta { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-sm); font-weight: 650;
  color: #0e1014; background: var(--accent); border: 0; border-radius: 8px; padding: 7px 13px; text-decoration: none; }
.row-cta:hover { filter: brightness(1.08); }
.row-cta .ico { width: 14px; height: 14px; }

/* domain badge = legible pill with a leading domain icon (beaker, moon, …) */
.domain { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px 0 6px; border-radius: 6px;
  background: #21262f; color: var(--label);
  font-size: var(--t-sm); line-height: 1; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; }
.domain .ico { width: 13px; height: 13px; color: var(--muted); }
.insight .title { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
#inbox-suggest { margin-top: var(--s4); }

/* tooltip / learn-as-you-go — underline only on hover, so values don't read
   as spell-check errors; the affordance appears when you reach for it */
[data-tip] { cursor: help; text-decoration: none; }
[data-tip]:hover { text-decoration: underline dotted var(--faint); text-underline-offset: 3px; }
#tip {
  position: fixed; display: none; z-index: 50; max-width: 320px;
  background: #181b22; border: 1px solid var(--faint); padding: var(--s2) var(--s3);
  font-size: var(--t-sm); line-height: 1.45; box-shadow: 0 4px 16px rgba(0,0,0,.5);
  pointer-events: none;
}
#tip .tip-t { font-weight: 600; color: var(--text); }
#tip .tip-d { color: var(--muted); margin-top: 3px; }
#tip .tip-m { color: var(--muted); margin-top: var(--s1); }
#tip .tip-stale { color: var(--amber); margin-top: var(--s1); }
.done-btn { background: none; border: 1px solid var(--line); color: var(--muted); font: inherit; font-size: var(--t-sm); font-weight: 550; padding: 5px 11px; border-radius: 7px; cursor: pointer; white-space: nowrap; }
.done-btn:hover { color: var(--text); border-color: var(--raised); }
.is-primary .done-btn { position: static; }
.insight.is-done .title { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--faint); }
.insight.is-done .payoff { color: var(--muted); }

/* chips: text tokens, no borders — color only on true flags */
.chip { display: inline-block; font-size: var(--t-sm); margin-left: 7px; color: var(--muted); vertical-align: 1px; }
.chip.improved { color: var(--good); }
.chip.regressed, .chip.flag { color: var(--warn); }
.chip.recheck { color: var(--amber); }
.chip.new, .chip.stale { color: var(--label); }
/* stale actions stay fully legible (the data, not the advice, is old — the
   NEEDS-ATTENTION alert already flags that). Only DONE gets a strikethrough. */

/* ---- jump-to: a near-invisible footer index ---- */
#strips { margin-top: var(--s7); border-top: 1px solid var(--line-strong); padding-top: var(--s4); }
#strips .strips-label { color: var(--muted); margin-bottom: var(--s2); display: block; font-size: var(--t-sm); text-transform: uppercase; letter-spacing: var(--ls); }
.strip { display: inline-flex; gap: var(--s2); align-items: baseline; margin-right: var(--s6); text-decoration: none; color: var(--muted); font-size: var(--t-md); }
.strip:hover { color: var(--text); }
.strip-name { display: inline-flex; align-items: center; height: 18px; padding: 0 8px; border-radius: 5px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.07); color: var(--label);
  font-weight: 600; text-transform: uppercase; letter-spacing: .04em; font-size: var(--t-sm); }
.strip-body { color: var(--muted); }
.strip-go { color: var(--muted); display: inline-flex; }
.warn-txt { color: var(--warn); }
.empty { color: var(--muted); margin-top: var(--s4); }

/* ---- metric grid (shared: last-night, screens, labs status) ---- */
.metrics { display: grid; gap: 1px; background: var(--line); border: 1px solid var(--line); margin-top: var(--s2); }
.metrics.c8 { grid-template-columns: repeat(8, 1fr); }
.metrics.c7 { grid-template-columns: repeat(7, 1fr); }
.metrics.c3 { grid-template-columns: repeat(3, 1fr); }
.metric { background: var(--panel); padding: var(--s2) 10px; }
.metric .label { color: var(--muted); }
.metric .value { font-size: var(--t-xl); font-weight: 600; margin-top: 2px; }
.metric .value.f-mid { color: var(--amber); }
.metric .bdelta, .metric .snote { font-size: var(--t-sm); margin-top: 2px; }
.bdelta.up { color: var(--good); }
.bdelta.down { color: var(--warn); }
.bdelta.flat { color: var(--muted); }
.metric .snote { color: var(--muted); }
.metric svg { margin-top: var(--s1); }
#lastnight, #labs-status { margin-top: var(--s4); }
#lastnight h2 { margin-bottom: var(--s1); }

/* traffic lights */
.tl { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin: 0 6px 2px 0; }
.tl-ok { background: var(--good); }
.tl-mid { background: var(--amber); }
.tl-high { background: var(--warn); }

/* ---- pattern ---- */
#pattern:empty { display: none; }
.pattern { margin-top: var(--s4); padding: var(--s2) var(--s3); border: 1px solid var(--amber); background: var(--panel); }
.pattern .ptitle { color: var(--amber); }
.pattern .pbody { margin-top: var(--s1); }
.pattern .pdays { color: var(--muted); font-size: var(--t-sm); margin-top: var(--s1); }

/* ---- collapsibles (one disclosure treatment) ---- */
details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }
/* "Why this" — reads as an interactive link, accent + chevron */
details.more { margin-top: 10px; }
details.more > summary { color: var(--accent); font-size: var(--t-sm); font-weight: 600;
  display: inline-flex; align-items: center; gap: 4px; }
details.more > summary:hover { text-decoration: underline; }
details.more > summary .ico { width: 13px; height: 13px; transition: transform .12s; }
details.more[open] > summary .ico { transform: rotate(180deg); }
.more-body { color: var(--muted); font-size: var(--t-md); line-height: 1.5; margin-top: 6px; max-width: 720px; }

/* "Show N more" / "Acted on" — a real bordered button control */
details.more-insights { margin-top: var(--s3); }
details.more-insights > summary { display: inline-block; }
.more-btn { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-sm); font-weight: 550;
  color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 7px 13px; }
.more-btn:hover { color: var(--text); border-color: var(--raised); }
.more-btn .ico { width: 13px; height: 13px; transition: transform .12s; }
details.more-insights[open] .more-btn .ico { transform: rotate(180deg); }

/* boxed collapsible (charts, screens, labs table) */
.box-collapse { margin-top: var(--s4); border: 1px solid var(--line); background: var(--panel); padding: var(--s2) var(--s3); }
.box-collapse > summary { display: flex; align-items: baseline; gap: var(--s3); }
.box-collapse > summary h2 { display: inline; }
.box-collapse > summary::before { content: "›"; display: inline-block; margin-right: var(--s2); color: var(--muted); font-size: 17px; line-height: 1; font-weight: 600; transition: transform .2s ease; }
.box-collapse[open] > summary::before { transform: rotate(90deg); }

/* ---- screens ---- */
#screens:empty { display: none; }
.screen-wrap { margin-top: var(--s4); border: 1px solid var(--line); background: var(--panel); padding: var(--s2) var(--s3); }
.screen-wrap > summary::before { content: "›"; display: inline-block; margin-right: var(--s2); color: var(--muted); font-size: 17px; line-height: 1; font-weight: 600; transition: transform .2s ease; }
.screen-wrap[open] > summary::before { transform: rotate(90deg); }
.screen-wrap > summary h2 { display: inline; }
.screen-wrap h2 .dot { display: inline-block; }
.sverdict-inline { display: block; color: var(--muted); margin: var(--s1) 0 0 14px; }
.screen { margin-top: var(--s2); }
.sverdict { color: var(--text); }
.saction { color: var(--muted); }
.schart-label { color: var(--muted); margin-top: var(--s3); display: block; }
.sevidence { list-style: none; padding: var(--s1) 0 0; color: var(--muted); font-size: var(--t-sm); }
.sevidence li { margin-top: var(--s1); padding-left: 10px; border-left: 2px solid var(--line); }

/* ---- charts ---- */
.range { display: inline-flex; }
.range button { background: none; border: 1px solid var(--line); color: var(--muted); font: inherit; font-size: var(--t-sm); padding: 2px 8px; cursor: pointer; }
.range button + button { border-left: none; }
.range button.on { color: var(--text); background: var(--panel); }
.charts { margin-top: var(--s1); }
.chart-block { margin-top: var(--s4); }
.chart { height: 240px; margin-top: var(--s1); }
.chart.short { height: 180px; }
#notes { list-style: none; padding: var(--s1) 0 0; color: var(--muted); font-size: var(--t-sm); }
#notes li { margin-top: 2px; }

/* ---- tables (labs markers + retest) ---- */
.lab-table { width: 100%; border-collapse: collapse; margin-top: var(--s2); }
.lab-table th { text-align: left; color: var(--muted); padding: var(--s1) var(--s2) var(--s1) 0; border-bottom: 1px solid var(--line); }
.lab-table td { padding: var(--s1) var(--s2) var(--s1) 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
.lab-table .num { white-space: nowrap; }
.lab-table .muted { color: var(--muted); font-size: var(--t-sm); }

#labs-retest { margin-top: var(--s4); }
.rt-v { font-size: var(--t-sm); text-transform: uppercase; letter-spacing: var(--ls); white-space: nowrap; width: 1%; color: var(--muted); }
.rt-skip-v { color: var(--muted); }
.rt-policy { color: var(--muted); font-size: var(--t-sm); margin-top: 2px; }

/* draw-event cards */
.draw-card { border: 1px solid var(--line); background: var(--panel); padding: var(--s3); margin-top: var(--s2); }
.draw-card.urgent { border-left: 3px solid var(--warn); }
.draw-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); }
.draw-title { font-weight: 600; }
.draw-cost { color: var(--good); font-size: var(--t-sm); white-space: nowrap; }
.draw-when { margin-top: var(--s1); }
.draw-status { color: var(--muted); font-size: var(--t-sm); margin-top: 2px; }
.draw-covers { list-style: none; margin-top: var(--s2); columns: 2; column-gap: var(--s6); }
.draw-covers li { color: var(--muted); font-size: var(--t-sm); padding-left: 10px; border-left: 2px solid var(--line); margin-bottom: 2px; break-inside: avoid; }
.draw-cta { display: inline-block; margin-top: var(--s2); color: var(--accent); text-decoration: none; border: 1px solid var(--accent); padding: 3px 10px; font-size: var(--t-sm); }
.draw-cta:hover { background: rgba(90, 169, 230, .08); }
.draw-total { margin-top: var(--s2); padding: var(--s2) var(--s3); border: 1px solid var(--line); color: var(--text); font-weight: 600; }
.gen-rec { margin-top: var(--s2); padding-top: var(--s2); border-top: 1px solid var(--line); }
#gen-tests, #mri-findings, #vax-recs, #vax-history { margin-top: var(--s4); }
.rt-do .rt-v { color: var(--warn); }

/* inbox */
#dropzone { margin-top: var(--s4); border: 1px dashed var(--faint); padding: var(--s7) var(--s4); text-align: center; cursor: pointer; }
#dropzone.over { border-color: var(--accent); background: var(--panel); }
.drop-title { font-size: var(--t-lg); font-weight: 600; }
.drop-sub { color: var(--muted); font-size: var(--t-sm); margin-top: var(--s1); }
.drop-sub.faint { color: var(--muted); }
.drop-sub code { color: var(--muted); }
#inbox-files { margin-top: var(--s4); }

/* ---- supplements: daytime / nighttime regimen ---- */
.supp-block { margin-top: var(--s6); }
.supp-when { display: flex; align-items: center; gap: 6px; margin-bottom: var(--s2); }
.supp-when .ico { color: var(--muted); }
.supp-pills { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; margin-left: 4px; }
.supp-row { display: grid; grid-template-columns: 96px 1fr auto; gap: var(--s3); padding: 14px 0; border-bottom: 1px solid var(--line); align-items: center; }
.supp-pill { display: flex; align-items: center; gap: var(--s2); }
.pill { width: 32px; height: 32px; flex-shrink: 0; }
.supp-amt { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; font-size: var(--t-sm); }
.supp-main { min-width: 0; }
.supp-name { font-weight: 600; color: var(--text); }
.supp-dose { font-weight: 400; color: var(--muted); font-size: var(--t-sm); margin-left: 8px; }
.supp-meta { font-size: var(--t-md); color: var(--muted); margin-top: 3px; line-height: 1.5; }
.supp-change { color: var(--amber); font-size: var(--t-sm); margin-top: var(--s1); }
.supp-markers { margin-top: var(--s2); display: flex; flex-wrap: wrap; gap: 4px var(--s4); }
.supp-marker { font-size: var(--t-sm); color: var(--muted); }
.supp-side { flex-shrink: 0; }
.supp-buy { color: var(--accent); font-size: var(--t-sm); text-decoration: none; white-space: nowrap; display: inline-flex; align-items: center; gap: 2px; }
.supp-buy:hover { text-decoration: underline; }
.supp-buy .ico { width: 13px; height: 13px; }

footer {
  max-width: 1180px; margin: 0 auto; padding: var(--s3) 20px var(--s7);
  color: var(--muted); font-size: var(--t-sm); border-top: 1px solid var(--line-strong);
}
footer .warnico { color: var(--amber); }

@media (max-width: 900px) { .metrics.c8, .metrics.c7 { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 760px) { .supp-grid { grid-template-columns: 1fr; } }

/* profile strip */
#profile:empty { display: none; }
/* profile: a quiet passport stamp, not content */
.profile { margin-top: var(--s3); color: var(--muted); font-size: var(--t-sm); }
.pbit { color: var(--muted); }
.pbit.faint { color: var(--muted); }
.psep { color: var(--faint); margin: 0 6px; }
.pf-more { display: inline-block; margin-left: 10px; }
.pf-detail { color: var(--muted); margin-top: var(--s1); max-width: 900px; }

/* -------------------------------------------- ask (floating chat drawer) */
/* The FAB is the one place the accent becomes a solid surface — the single
   bold gesture. Everything inside the drawer stays as quiet as the rest of
   the app. */
#chat-fab { position: fixed; right: 22px; bottom: 22px; z-index: 60;
  width: 48px; height: 48px; border-radius: 12px; border: none; cursor: pointer;
  background: var(--accent); color: var(--bg);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s ease, opacity .15s ease; }
#chat-fab .ico { width: 22px; height: 22px; }
#chat-fab:hover { transform: translateY(-2px); }
#chat-fab:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
#chat-fab.hidden { opacity: 0; transform: scale(.6); pointer-events: none; }

#chat-drawer { position: fixed; top: 0; right: 0; z-index: 61; height: 100vh;
  width: var(--chat-w); display: flex; flex-direction: column;
  background: var(--panel); border-left: 1px solid var(--line);
  transform: translateX(100%); transition: transform .2s ease; }
#chat-drawer.on { transform: translateX(0); }
/* dock, don't cover: when open, shrink the app into the space beside the drawer */
body { transition: padding-right .2s ease; }
body.chat-on { padding-right: var(--chat-w); }
@media (max-width: 760px) {
  #chat-drawer { width: 100vw; }
  body.chat-on { padding-right: 0; }  /* too narrow to dock — overlay on mobile */
}

.chat-head { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between;
  padding: var(--s3) 16px; border-bottom: 1px solid var(--line); }
.chat-title { font-size: var(--t-xl); font-weight: 650; color: var(--text); }
.chat-ctx { color: var(--muted); font-weight: 400; font-size: var(--t-sm); }
.chat-ctx:not(:empty)::before { content: "· "; color: var(--faint); }
.chat-actions { display: flex; align-items: center; gap: 2px; }
.chat-x { background: none; border: none; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 6px; display: flex; }
.chat-x .ico { width: 18px; height: 18px; }
.chat-x:hover { color: var(--text); background: var(--surface); }

/* history mode: hide the live chat chrome, show the saved-session list */
#chat-drawer.show-history .chat-controls,
#chat-drawer.show-history .chat-compose,
#chat-drawer.show-history .chat-foot { display: none; }
#chat-drawer.show-history #chat-history { color: var(--accent); }
#chat-drawer.show-history .chat-log { gap: var(--s2); }
.chat-empty { color: var(--muted); font-size: var(--t-sm); }
.chat-hrow { display: flex; align-items: center; justify-content: space-between; gap: var(--s2);
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 7px; cursor: pointer; }
.chat-hrow:hover { border-color: var(--raised); background: var(--surface); }
.chat-hrow.on { border-color: var(--accent); }
.chat-hmeta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.chat-htitle { color: var(--text); font-size: var(--t-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-hago { color: var(--muted); font-size: var(--t-sm); }
.chat-hdel { flex: 0 0 auto; background: none; border: none; color: var(--faint); cursor: pointer; padding: 4px; display: flex; }
.chat-hdel .ico { width: 15px; height: 15px; }
.chat-hdel:hover { color: var(--warn); }

.chat-controls { flex: 0 0 auto; padding: var(--s3) 16px; border-bottom: 1px solid var(--line); }
.chat-pickers { display: flex; gap: var(--s2); align-items: center; }
#chat-provider, #chat-model { font: inherit; font-size: var(--t-sm); color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 5px 8px; }
#chat-provider { flex: 1; min-width: 0; }
#chat-model { flex: 1; min-width: 0; }
#chat-model:disabled { opacity: .45; }
#chat-provider:focus, #chat-model:focus, #chat-text:focus { outline: none; border-color: var(--accent); }
.chat-ghost { font: inherit; font-size: var(--t-sm); color: var(--muted); background: none;
  border: 1px solid var(--line); border-radius: 7px; padding: 4px 9px; cursor: pointer; }
.chat-ghost:hover { color: var(--text); border-color: var(--raised); }
.chat-alert { display: flex; margin-top: var(--s2); padding: 8px 10px;
  border: 1px solid var(--line); border-left: 3px solid var(--amber); border-radius: 0 6px 6px 0;
  background: var(--surface); color: var(--muted); font-size: var(--t-sm); line-height: 1.45; }
.chat-alert code { background: var(--panel); border: 1px solid var(--line); border-radius: 4px; padding: 1px 4px; font-size: 11.5px; }
.chat-alert a { color: var(--accent); text-decoration: none; }
.chat-alert a:hover { text-decoration: underline; }

.chat-log { flex: 1 1 auto; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: var(--s4); }
.chat-hello { color: var(--muted); font-size: var(--t-md); line-height: 1.55; display: flex; flex-direction: column; gap: var(--s2); }
.chat-hello p { margin-bottom: var(--s1); }
.chat-eg { text-align: left; font: inherit; font-size: var(--t-sm); color: var(--muted);
  background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 8px 11px; cursor: pointer; }
.chat-eg:hover { color: var(--text); border-color: var(--raised); }
.chat-msg { display: flex; }
.chat-msg.user { justify-content: flex-end; }
.chat-msg.asst { flex-direction: column; align-items: flex-start; }
.chat-bubble { font-size: var(--t-md); line-height: 1.6; }
.chat-msg.user .chat-bubble { background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px 12px 3px 12px; padding: 8px 12px; color: var(--text); max-width: 88%; }
.chat-msg.asst .chat-bubble { color: var(--text); max-width: 100%; }
.chat-bubble code { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-size: 12.5px; }
.chat-thinking { color: var(--faint); font-size: var(--t-sm); margin-bottom: 5px; }
.chat-thinking summary { cursor: pointer; text-transform: uppercase; letter-spacing: var(--ls); font-weight: 600; }
.chat-thinking[open] { color: var(--muted); line-height: 1.5; }
.chat-dots { color: var(--muted); font-style: italic; }

/* rendered markdown (assistant replies) — kept within the design system */
.chat-md > :first-child { margin-top: 0; }
.chat-md > :last-child { margin-bottom: 0; }
.chat-md p { margin: 0 0 var(--s2); line-height: 1.6; }
.chat-md ul, .chat-md ol { margin: 0 0 var(--s2); padding-left: 20px; }
.chat-md li { margin: 2px 0; }
.chat-md li::marker { color: var(--faint); }
.chat-md h1, .chat-md h2, .chat-md h3, .chat-md h4 { color: var(--text); font-weight: 650; line-height: 1.3; margin: var(--s3) 0 var(--s1); }
.chat-md h1, .chat-md h2 { font-size: var(--t-lg); }
.chat-md h3, .chat-md h4 { font-size: var(--t-md); }
.chat-md strong { color: var(--text); font-weight: 650; }
.chat-md a { color: var(--accent); text-decoration: none; }
.chat-md a:hover { text-decoration: underline; }
.chat-md code { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-size: 12.5px; }
.chat-md pre { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 10px 12px; overflow-x: auto; margin: 0 0 var(--s2); }
.chat-md pre code { background: none; border: none; padding: 0; font-size: 12.5px; line-height: 1.5; }
.chat-md blockquote { border-left: 3px solid var(--line); margin: 0 0 var(--s2); padding: 2px 0 2px 12px; color: var(--muted); }
.chat-md img { max-width: 100%; height: auto; border-radius: 7px; margin: var(--s1) 0; }
.chat-md hr { border: none; border-top: 1px solid var(--line); margin: var(--s3) 0; }
.chat-md table { border-collapse: collapse; width: 100%; margin: 0 0 var(--s2); font-size: var(--t-sm); }
.chat-md th, .chat-md td { border: 1px solid var(--line); padding: 5px 8px; text-align: left; }
.chat-md th { color: var(--label); font-weight: 600; background: var(--surface); }

.chat-compose { flex: 0 0 auto; padding: 12px 16px; border-top: 1px solid var(--line); }
.chat-input { display: flex; gap: var(--s2); align-items: flex-end; }
#chat-text { flex: 1; font: inherit; font-size: var(--t-md); color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 7px; padding: 9px 11px; resize: none; max-height: 140px; line-height: 1.45; }
#chat-text:disabled { opacity: .5; }
.chat-send { flex: 0 0 auto; width: 38px; height: 38px; border: none; border-radius: 7px; cursor: pointer;
  background: var(--accent); color: var(--bg); display: flex; align-items: center; justify-content: center; }
.chat-send .ico { width: 18px; height: 18px; }
.chat-send:disabled { background: var(--line); color: var(--faint); cursor: default; }
.chat-hint { color: var(--muted); font-size: var(--t-sm); margin-top: 6px; }

.chat-foot { flex: 0 0 auto; padding: 10px 16px 14px; border-top: 1px solid var(--line); }
.chat-mcp > summary { cursor: pointer; list-style: none; color: var(--faint); font-size: var(--t-sm);
  text-transform: uppercase; letter-spacing: var(--ls); font-weight: 600; }
.chat-mcp > summary::-webkit-details-marker { display: none; }
.chat-mcp > summary::before { content: "›"; display: inline-block; margin-right: 6px; color: var(--muted); font-size: 14px; line-height: 1; font-weight: 600; transition: transform .2s ease; }
.chat-mcp[open] > summary::before { transform: rotate(90deg); }
.chat-mcp p { color: var(--muted); font-size: var(--t-sm); line-height: 1.5; margin: var(--s2) 0; }
.chat-mcp code { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-size: 11.5px; }
.chat-code { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  overflow-x: auto; font-size: 11.5px; line-height: 1.5; color: var(--muted); margin-bottom: var(--s2); }

/* ---- agent replies: action steps, approvals, working state -------------------------------
   Patterns adapted from Beautiful UI (beautifului.dev) — Copyright (c) Turbo, MIT License —
   mapped onto this design system's tokens: 1px borders instead of ring shadows, 6px chips. */
@keyframes pd-fade-up { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pd-pop-in { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
@keyframes pd-shimmer { 0% { background-position: 150% center; } 100% { background-position: -50% center; } }
@keyframes pd-spin { to { transform: rotate(1turn); } }
.chat-bubble > * + * { margin-top: var(--s2); }
.ai-steps { display: flex; flex-direction: column; gap: 2px; }
.ai-step { display: flex; align-items: center; gap: var(--s2); min-height: 28px; font-size: var(--t-sm);
  animation: pd-fade-up .3s cubic-bezier(.23,1,.32,1) both; min-width: 0; }
.ai-step > .ico, .ai-spin { flex: 0 0 auto; width: 14px; height: 14px; color: var(--faint); }
.ai-step.is-done.is-write > .ico { color: var(--good); }
.ai-step.is-error > .ico { color: var(--warn); }
.ai-spin { display: inline-block; border-radius: 50%; border: 1.5px solid var(--line-strong); border-top-color: var(--muted);
  animation: pd-spin .7s linear infinite; box-sizing: border-box; }
.ai-step-title { flex: 0 0 auto; color: var(--text); font-weight: 500; }
.ai-step:not(.is-write) .ai-step-title { color: var(--muted); }
.ai-step-detail { min-width: 0; flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  height: 22px; line-height: 20px; padding: 0 6px; border-radius: 6px; background: var(--surface); border: 1px solid var(--line);
  color: var(--muted); font-variant-numeric: tabular-nums; }
.ai-step.is-error .ai-step-detail { color: var(--warn); }
.ai-step.is-write { flex-wrap: wrap; row-gap: 0; padding: 2px 0; }
.ai-step.is-write .ai-step-detail { flex-basis: 100%; margin-left: 22px; white-space: normal; height: auto; line-height: 1.45;
  border: 0; background: none; padding: 0; color: var(--muted); }
.ai-group > summary { list-style: none; cursor: pointer; border-radius: 6px; }
.ai-group > summary::-webkit-details-marker { display: none; }
.ai-group > summary:hover { background: var(--surface); }
.ai-group > .ai-step { margin-left: 7px; padding-left: 14px; border-left: 1px solid var(--line); }
.ai-working { display: flex; align-items: center; gap: var(--s2); font-size: var(--t-sm); font-weight: 500;
  background: linear-gradient(90deg, var(--muted) 35%, var(--text) 50%, var(--muted) 65%); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: pd-shimmer 1.4s linear infinite; }
.ai-pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; animation: pd-pop-in .9s ease-in-out infinite alternate; }
.ai-error { display: flex; gap: var(--s2); align-items: flex-start; color: var(--warn); font-size: var(--t-sm); line-height: 1.5; }
.ai-error .ico { width: 14px; height: 14px; flex: 0 0 auto; margin-top: 2px; }
.ai-approve { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap;
  padding: var(--s3); background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  animation: pd-fade-up .38s cubic-bezier(.23,1,.32,1) both; }
.ai-approve-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ai-approve-title { color: var(--text); font-size: var(--t-md); font-weight: 500; }
.ai-approve-detail { color: var(--muted); font-size: var(--t-sm); overflow: hidden; text-overflow: ellipsis; }
.ai-approve-acts { display: flex; gap: var(--s2); }
.ai-btn { font: inherit; font-size: var(--t-sm); font-weight: 500; height: 28px; padding: 0 12px; border-radius: 6px; cursor: pointer;
  background: var(--raised); color: var(--text); border: 1px solid var(--line); transition: background .1s, transform .2s; }
.ai-btn:hover { background: var(--line-strong); }
.ai-btn:active { transform: scale(.96); }
.ai-btn-danger { background: none; border-color: var(--warn); color: var(--warn); }
.ai-btn-danger:hover { background: rgba(240,103,90,.12); }
.ai-approve.is-decided { padding: var(--s2) var(--s3); }
.ai-approve-done { display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-sm); font-weight: 500; color: var(--good);
  animation: pd-pop-in .26s ease both; }
.ai-approve-done.is-kept { color: var(--muted); }
.ai-approve-done .ico { width: 13px; height: 13px; }
.chat-privacy { color: var(--muted); font-size: var(--t-sm); line-height: 1.45; }
@media (prefers-reduced-motion: reduce) {
  .ai-step, .ai-approve, .ai-approve-done, .ai-pulse, .ai-working { animation: none; }
  .ai-spin { animation-duration: 2s; }
}

@media (prefers-reduced-motion: reduce) { #chat-drawer, #chat-fab { transition: none; } }

/* ------------------------------------------------------------ settings */
#settings-integrations { margin-top: 40px; }
.set-note { color: var(--muted); font-size: var(--t-md); max-width: 680px; margin-top: calc(-1 * var(--s2)); margin-bottom: var(--s4); line-height: 1.55; }

/* privacy panel — the local-only / device-encryption assurance */
/* flat 2-col fact list, not a 4-tile card grid — these are read-once assurances,
   not dashboard widgets. Icons are inert chrome (faint), never accent. */
.privacy-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--s4) var(--s6); margin-top: var(--s4); }
.privacy-item { background: none; border: 0; border-radius: 0; padding: 0; }
.privacy-h { display: flex; align-items: center; gap: var(--s2); color: var(--text); font-weight: 600; font-size: var(--t-md); margin-bottom: 6px; }
.privacy-h .ico { width: 15px; height: 15px; color: var(--faint); }
.privacy-item p { color: var(--muted); font-size: var(--t-sm); line-height: 1.55; }
.privacy-item code { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-size: 11.5px; }
@media (max-width: 760px) { .privacy-grid { grid-template-columns: 1fr; } }

/* every source is ONE flat row — icon · name · brings · status+action (no cards).
   Connected sources and catalogue entries share this component. */
.intg-live { margin-top: var(--s2); }
.intg-list { margin-top: var(--s1); }
.intg-row { display: grid; grid-template-columns: minmax(190px, 1.1fr) 2fr auto; gap: var(--s4);
  align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.intg-row-head { display: flex; align-items: center; gap: 7px; min-width: 0; }
.intg-row-head .ico { width: 15px; height: 15px; flex-shrink: 0; }
.intg-row-head .ico:not(.ico-brand) { color: var(--faint); }  /* line glyphs stay grey; brand marks keep their color */
.intg-row-name { color: var(--text); font-weight: 600; }
.intg-row-brings { color: var(--muted); font-size: var(--t-sm); min-width: 0; }
/* freshness sits under what the source brings — provenance, not a status badge */
.intg-sync { display: flex; align-items: center; gap: 4px; margin-top: 2px; color: var(--faint); }
.intg-sync .ico { width: 12px; height: 12px; }
.intg-sync.warn { color: var(--warn); }
.intg-row-status { justify-self: end; display: flex; align-items: center; gap: var(--s3); white-space: nowrap; }
/* the catalogue disclosure: everything not yet wired up, tucked away by default */
/* a plain disclosure, NOT a bordered panel — its flat rows must align
   edge-to-edge with the connected strip above (no inset, no box, no fill) */
.intg-catalogue { margin-top: var(--s4); border: 0; background: none; padding: 0; }
.intg-catalogue > summary { margin-bottom: var(--s2); }
.intg-catalogue .set-note { margin-top: var(--s1); }
.intg-catalogue .intg-cat:first-of-type { margin-top: var(--s3); }
@media (max-width: 760px) {
  .intg-row { grid-template-columns: 1fr auto; }
  .intg-row-brings { display: none; }
}

/* integration cards */
.intg-cat { margin-top: var(--s6); }
.intg-cat .eyebrow { display: block; margin-bottom: var(--s3); }
.intg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: var(--s3); }
.intg-card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: var(--s4); display: flex; flex-direction: column; }
.intg-top { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.intg-name { color: var(--text); font-weight: 600; font-size: var(--t-lg); }
.intg-badge { font-size: var(--t-sm); font-weight: 600; color: var(--muted); white-space: nowrap; display: inline-flex; align-items: center; gap: 5px; }
.intg-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--faint); }
.intg-badge.ok { color: var(--good); }
.intg-badge.ok::before { background: var(--good); }
/* works/connectable now — brighter than a "Planned" (base muted) badge */
.intg-badge.live { color: var(--label); }
.intg-badge.live::before { background: var(--muted); }
.intg-brings { color: var(--muted); font-size: var(--t-sm); line-height: 1.5; margin-top: var(--s1); }
.intg-form { margin-top: var(--s3); display: flex; flex-direction: column; gap: var(--s2); }
.intg-field { display: flex; flex-direction: column; gap: 4px; font-size: var(--t-sm); color: var(--label); }
.intg-field input { font: inherit; font-size: var(--t-md); color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; }
.intg-field input:focus { outline: none; border-color: var(--accent); }
.intg-hint { color: var(--muted); font-size: var(--t-sm); line-height: 1.5; }
.intg-actions { display: flex; gap: var(--s2); align-items: center; margin-top: 2px; }
.intg-btn { font: inherit; font-size: var(--t-sm); font-weight: 600; color: var(--bg); background: var(--accent);
  border: none; border-radius: 7px; padding: 6px 14px; cursor: pointer; }
.intg-btn:disabled { background: var(--line); color: var(--faint); cursor: default; }
/* planned sources: a receding ghost, so full-saturation accent is reserved for
   buttons that actually connect something (Blue-Means-Clickable) */
.intg-btn-ghost { background: none; color: var(--muted); border: 1px solid var(--line); }
.intg-btn-ghost:hover { color: var(--text); border-color: var(--raised); }
.intg-ghost { font: inherit; font-size: var(--t-sm); color: var(--muted); background: none; border: 1px solid var(--line);
  border-radius: 7px; padding: 6px 12px; cursor: pointer; }
.intg-ghost:hover { color: var(--warn); border-color: var(--raised); }
.intg-link { color: var(--accent); text-decoration: none; font-size: var(--t-sm); font-weight: 600; margin-top: var(--s3); }
.intg-link:hover { text-decoration: underline; }
.intg-docs { color: var(--faint); text-decoration: none; font-size: var(--t-sm); }
.intg-docs:hover { color: var(--muted); }
.intg-foot { margin-top: var(--s3); display: flex; }
.intg-help { color: var(--muted); font-size: var(--t-sm); line-height: 1.45; }

/* connection dialog (modal) */
.modal { position: fixed; inset: 0; z-index: 80; display: none; }
.modal.on { display: block; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .55); }
.modal-card { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(460px, 92vw); max-height: 86vh; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3);
  padding: var(--s4) var(--s4) var(--s3); border-bottom: 1px solid var(--line); }
.modal-title { color: var(--text); font-size: var(--t-lg); font-weight: 650; }
.modal-sub { color: var(--muted); font-size: var(--t-sm); margin-top: 3px; line-height: 1.5; }
.modal-body { padding: var(--s4); display: flex; flex-direction: column; gap: var(--s3); }

/* ------------------------------------------------------------ calendar (habits) */
#page-calendar { margin-top: var(--s6); }
/* summary: one flat card per habit — streak + 30-day count */
.cal-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: var(--line);
  border: 1px solid var(--line); margin-top: var(--s2); }
.cal-card { background: var(--panel); padding: var(--s3) var(--s4); }
.cal-card-h { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--t-sm);
  font-weight: 600; }
.cal-card-h .ico { width: 14px; height: 14px; color: var(--faint); }
.cal-card.active .cal-card-h .ico { color: var(--good); }
.cal-card-streak { color: var(--text); font-size: var(--t-3xl); font-weight: 650; margin-top: 4px;
  display: flex; align-items: baseline; gap: 6px; }
.cal-card-unit { color: var(--muted); font-size: var(--t-sm); font-weight: 400; }
.cal-card-sub { color: var(--muted); font-size: var(--t-sm); margin-top: 2px; }

/* month navigator */
.cal-nav { display: flex; align-items: center; justify-content: center; gap: var(--s4); margin: var(--s6) 0 var(--s3); }
.cal-month { color: var(--text); font-weight: 600; font-size: var(--t-lg); min-width: 160px; text-align: center; }
.cal-page { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px;
  background: none; border: 1px solid var(--line); border-radius: 7px; color: var(--muted); cursor: pointer; }
.cal-page:hover:not(:disabled) { color: var(--text); border-color: var(--raised); }
.cal-page:disabled { opacity: .35; cursor: default; }
.cal-page .ico { width: 16px; height: 16px; }
.cal-page.prev .ico { transform: rotate(180deg); }

/* grid */
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--s2); margin-bottom: 6px; }
.cal-weekdays span { text-align: center; color: var(--faint); font-size: var(--t-sm); font-weight: 600;
  text-transform: uppercase; letter-spacing: var(--ls); }
.cal-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--s2); }
.cal-cell { position: relative; min-height: 74px; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 8px; cursor: pointer;
  display: flex; flex-direction: column; align-items: flex-start; gap: var(--s2);
  transition: background-color .12s ease, border-color .12s ease; }
.cal-cell:hover:not(:disabled):not(.blank) { background: var(--surface); border-color: var(--raised); }
.cal-cell.blank { background: none; border: 0; cursor: default; }
.cal-cell.future { opacity: .4; cursor: default; }
.cal-cell.today { border-color: var(--accent); }
.cal-cell.perfect { background: rgba(78, 194, 145, .1); }
.cal-num { color: var(--muted); font-size: var(--t-sm); font-weight: 600; font-variant-numeric: tabular-nums; }
.cal-cell.today .cal-num { color: var(--accent); }
.cal-marks { display: flex; flex-wrap: wrap; gap: 3px; align-self: flex-start; }
.cal-mark { display: inline-flex; }
.cal-mark .ico { width: 13px; height: 13px; color: var(--text); }
.cal-cell.perfect .cal-mark .ico { color: var(--good); }

/* legend */
.cal-legends { display: flex; flex-wrap: wrap; gap: var(--s4); margin-top: var(--s4); }
.cal-leg { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: var(--t-sm); }
.cal-leg .cal-mark .ico { width: 14px; height: 14px; color: var(--faint); }
.cal-leg-src { color: var(--faint); font-size: var(--t-sm); }
.cal-note { margin-top: var(--s2); margin-bottom: 0; }

/* day editor rows (in the modal) — big tap targets */
.day-rows { padding: var(--s3) var(--s4) var(--s4); gap: var(--s2); }
.day-row { display: flex; align-items: center; gap: var(--s3); width: 100%; text-align: left;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; cursor: pointer;
  color: var(--text); font: inherit; transition: background-color .12s ease, border-color .12s ease; }
.day-row:hover:not(:disabled) { background: var(--surface); border-color: var(--raised); }
.day-row:disabled { cursor: default; }
.day-row-ico { display: inline-flex; }
.day-row-ico .ico { width: 18px; height: 18px; color: var(--faint); }
.day-row.done .day-row-ico .ico { color: var(--good); }
.day-row-main { flex: 1; display: flex; flex-direction: column; font-weight: 600; }
.day-row-sub { color: var(--muted); font-size: var(--t-sm); font-weight: 400; margin-top: 1px; }
.day-row-check { display: inline-flex; color: var(--good); }
.day-row-check .ico { width: 18px; height: 18px; }

@media (max-width: 760px) {
  .cal-cards { grid-template-columns: 1fr; }
  .cal-cell { min-height: 42px; padding: 4px; }
  .cal-mark .ico { width: 11px; height: 11px; }
}

/* ------------------------------------------------------------ connect AI */
/* header entry point — same quiet chrome as refresh; it's setup, not a daily action */
/* the one filled button in the rail: AI access is the app's doorway to everything else */
#connect-ai { background: var(--accent); border: 1px solid var(--accent); color: #0b1220; font: inherit; font-size: var(--t-sm);
  font-weight: 650; padding: 6px 10px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  box-shadow: 0 0 0 3px rgba(108,182,245,.14); }
#connect-ai .ico { width: 14px; height: 14px; }
#connect-ai:hover { filter: brightness(1.08); }
#connect-ai:focus-visible { outline-offset: 3px; }
.ai-card { width: min(560px, 94vw); }
.ai-body { gap: var(--s4); }
.ai-rows { display: flex; flex-direction: column; }
.ai-row { display: flex; gap: var(--s3); align-items: flex-start; padding: var(--s3) 0; border-top: 1px solid var(--line); }
.ai-row:first-child { border-top: 0; padding-top: 0; }
.ai-row-main { flex: 1; min-width: 0; }
.ai-row-name { color: var(--text); font-weight: 600; font-size: var(--t-md); display: flex; align-items: center; gap: var(--s2); }
.ai-row-blurb { color: var(--muted); font-size: var(--t-sm); line-height: 1.5; margin-top: 2px; }
.ai-steps { color: var(--muted); font-size: var(--t-sm); line-height: 1.5; margin: var(--s1) 0 0 18px; }
.ai-row-note { color: var(--label); font-size: var(--t-sm); line-height: 1.5; margin-top: var(--s1); }
.ai-row .intg-btn { flex-shrink: 0; display: inline-flex; align-items: center; gap: 4px; }
.ai-row .intg-btn .ico { width: 12px; height: 12px; }
.ai-copy { margin-top: var(--s2); }
.ai-copy-l { color: var(--label); font-size: var(--t-sm); margin-bottom: 2px; }
.ai-copy-row { display: flex; gap: var(--s2); align-items: center; }
.ai-copy-row code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; font-size: 11.5px; color: var(--text); }
.ai-copy-btn { flex-shrink: 0; }
.ai-link { background: none; border: 0; color: var(--accent); font: inherit; font-size: var(--t-sm); cursor: pointer; padding: 0; margin-top: var(--s2); }
.ai-link:hover { text-decoration: underline; }
.ai-err { color: var(--warn); font-size: var(--t-sm); margin-top: var(--s1); }
.ai-conn { display: flex; flex-direction: column; gap: var(--s1); }
.ai-conn-row { display: flex; justify-content: space-between; align-items: center; gap: var(--s3); font-size: var(--t-md); color: var(--text); }
.ai-conn-meta { color: var(--muted); font-size: var(--t-sm); }
.ai-share-list { display: flex; flex-direction: column; gap: 6px; margin-top: var(--s1); }
.ai-share { display: flex; gap: var(--s2); align-items: baseline; color: var(--text); font-size: var(--t-sm); cursor: pointer; }
.ai-share input { accent-color: var(--accent); }
.ai-share-note { color: var(--muted); }

/* ------------------------------------------------------------ nutrition + training */
#page-nutrition, #page-training { margin-top: var(--s6); }
.n-read { color: var(--text); font-size: var(--t-lg); line-height: 1.5; max-width: 760px; margin-bottom: var(--s4); }
.n-read strong { font-weight: 650; }
.n-h2 { margin-top: var(--s6); }
.metric .unit { font-size: var(--t-sm); color: var(--muted); font-weight: 400; margin-left: 2px; }
.n-charts { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s4); margin-top: var(--s4); }
.chart.ch-small { height: 160px; }
.n-day { margin-top: var(--s3); }
.log-list { margin-top: var(--s2); border-top: 1px solid var(--line); }
.log-row { display: grid; grid-template-columns: 52px 1fr auto; gap: var(--s3); align-items: baseline;
  padding: var(--s2) 0; border-bottom: 1px solid var(--line); }
.log-time { color: var(--muted); font-size: var(--t-sm); }
.log-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.log-title { color: var(--text); font-size: var(--t-md); }
.log-meta { color: var(--muted); font-size: var(--t-sm); }
@media (max-width: 760px) { .n-charts { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------ spotlight search */
.spot { position: fixed; inset: 0; z-index: 90; display: none; }
.spot.on { display: block; }
.spot-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.spot-card { position: absolute; top: 12vh; left: 50%; transform: translateX(-50%); width: min(640px, 94vw);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 12px; overflow: hidden; }
.spot-in { display: flex; align-items: center; gap: var(--s3); padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
.spot-in .ico { width: 18px; height: 18px; color: var(--muted); }
.spot-in input { flex: 1; background: none; border: 0; outline: none; color: var(--text); font: inherit; font-size: var(--t-lg); }
.spot-list { max-height: min(60vh, 520px); overflow-y: auto; padding: var(--s1); }
.spot-row { display: flex; align-items: center; gap: var(--s3); padding: 7px var(--s3); border-radius: 7px; cursor: pointer; }
.spot-row.on { background: var(--raised); }
.spot-ico .ico { width: 15px; height: 15px; color: var(--faint); display: block; }
.spot-row.on .spot-ico .ico { color: var(--text); }
.spot-main { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: var(--s2); }
.spot-title { color: var(--text); font-size: var(--t-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 1; }
.spot-title mark { background: none; color: var(--accent); }
.spot-sub { color: var(--muted); font-size: var(--t-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
.spot-type { color: var(--label); font-size: 11px; text-transform: uppercase; letter-spacing: var(--ls); flex-shrink: 0; }
.spot-empty { color: var(--muted); padding: var(--s4); }
@keyframes flash { from { background: rgba(108,182,245,.18); } to { background: transparent; } }
.flash { animation: flash 1.6s ease-out; border-radius: 6px; }
@media (prefers-reduced-motion: reduce) { .flash { animation: none; outline: 1px solid var(--accent); } }

/* ------------------------------------------------------------ quick add + toast */
.qa { margin: 0 0 var(--s4); }
.qa-row { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s2); }
.qa-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 320px; font: inherit; font-size: var(--t-sm);
  color: var(--text); background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px 5px 9px; cursor: pointer; }
.qa-chip:hover { border-color: var(--accent); }
.qa-chip .ico { width: 13px; height: 13px; color: var(--accent); flex-shrink: 0; }
.qa-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.qa-p { color: var(--muted); flex-shrink: 0; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 12px); z-index: 95; opacity: 0; pointer-events: none;
  background: var(--raised); border: 1px solid var(--line-strong); color: var(--text); border-radius: 10px; padding: 9px 14px;
  font-size: var(--t-md); transition: opacity .15s, transform .15s; max-width: min(560px, 92vw); }
#toast.on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast-btn { margin-left: var(--s2); background: none; border: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
.ai-code { font: 600 28px/1.2 ui-monospace, Menlo, monospace; letter-spacing: .14em; color: var(--text); text-align: center;
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: 10px; padding: 14px; margin: var(--s2) 0; }

/* ------------------------------------------------------------ page heads + small controls */
.page-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.page-title { font-size: var(--t-primary); font-weight: 650; color: var(--text); text-transform: none; letter-spacing: 0; }
.page-head .intg-btn { display: inline-flex; align-items: center; gap: 6px; }
.page-head .intg-btn .ico { width: 14px; height: 14px; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-align: left; }
.link-btn:hover { text-decoration: underline; }
.icon-btn { background: none; border: 1px solid transparent; color: var(--faint); border-radius: 6px; padding: 4px; cursor: pointer; display: inline-flex; }
.icon-btn:hover { color: var(--warn); border-color: var(--line); }
.icon-btn .ico { width: 14px; height: 14px; }
.log-side { display: inline-flex; align-items: center; gap: var(--s2); }

/* ------------------------------------------------------------ nutrition dashboard
   Lead sentence → targets → trend → the week's meals by day → coverage. Numbers are tabular and
   right-aligned in fixed columns so a day's totals line up with its meals. Unknown is "–". */
.n-head { flex-wrap: wrap; justify-content: flex-start; gap: var(--s3) var(--s4); }
.n-head .page-title { margin-right: auto; }
.n-nav { display: inline-flex; align-items: center; gap: var(--s1); }
.n-step { width: 28px; height: 28px; display: inline-grid; place-items: center; background: none; border: 1px solid var(--line);
  border-radius: 6px; color: var(--muted); cursor: pointer; }
.n-step .ico { width: 14px; height: 14px; transform: rotate(90deg); }
.n-step.next .ico { transform: rotate(-90deg); }
.n-step:hover:not(:disabled) { color: var(--text); background: var(--panel); }
.n-step:disabled { opacity: .35; cursor: default; }
.n-when { min-width: 104px; text-align: center; font-size: var(--t-md); font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.n-today { font-size: var(--t-sm); margin-left: var(--s1); }
.seg { display: inline-flex; gap: 2px; padding: 2px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; }
.seg-b { font: inherit; font-size: var(--t-sm); color: var(--muted); background: none; border: 0; border-radius: 6px; padding: 4px 10px; cursor: pointer; transition: background .15s, color .15s; }
.seg-b:hover { color: var(--text); }
.seg-b.on { background: var(--raised); color: var(--text); font-weight: 500; }
.seg-s { display: none; }
.n-add { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: var(--t-sm); font-weight: 500; color: var(--text);
  background: none; border: 1px solid var(--line-strong); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
.n-add .ico { width: 14px; height: 14px; color: var(--accent); }
.n-add:hover { background: var(--panel); }

.n-lead { margin-bottom: var(--s4); max-width: 820px; }
.n-lead .n-read { margin-bottom: var(--s1); }
.n-read strong { color: var(--text); font-weight: 650; font-variant-numeric: tabular-nums; }
.n-pct { color: var(--muted); font-size: var(--t-md); }
.n-pct.good { color: var(--good); }
.n-fix { color: var(--muted); font-size: var(--t-md); line-height: 1.6; }
.n-fix .link-btn { display: inline-flex; align-items: center; gap: 4px; }
.n-fix .link-btn .ico, .n-coverage .link-btn .ico { width: 13px; height: 13px; }
.n-sep { display: inline-block; width: 1px; height: 12px; background: var(--line-strong); margin: 0 var(--s3); vertical-align: -1px; }
.n-or { color: var(--muted); }

.nmeters { max-width: 700px; margin-bottom: var(--s6); }
.nmeters-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: var(--s2); }
.nmeters-by { color: var(--muted); font-size: var(--t-sm); }
.nmeter { display: grid; grid-template-columns: 116px 1fr 96px 124px; gap: var(--s3); align-items: center; min-height: 32px; }
.nmeter-l { font: inherit; font-size: var(--t-md); color: var(--text); background: none; border: 0; padding: 0; text-align: left; cursor: pointer; }
.nmeter-l:hover { color: var(--accent); }
.nmeter-track { position: relative; height: 6px; background: var(--line); border-radius: 3px; }
.nmeter-fill { position: absolute; inset: 0 auto 0 0; background: var(--muted); border-radius: 3px; }
.nmeter.hit .nmeter-fill { background: var(--good); }
.nmeter.over .nmeter-fill { background: var(--amber); }
.nmeter.over .nmeter-n { color: var(--amber); }
.nmeter-dir { color: var(--faint); font-size: var(--t-sm); margin-left: 4px; }
.n-goalhist { margin-top: var(--s3); font-size: var(--t-sm); color: var(--muted); }
.n-goalhist > summary { cursor: pointer; color: var(--muted); }
.n-goalhist > summary:hover { color: var(--text); }
.n-goalhist ul { list-style: none; margin: var(--s2) 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.n-goalhist li { display: grid; grid-template-columns: 96px 88px minmax(0, 1fr); gap: var(--s2); line-height: 1.45; }
.gh-when { font-variant-numeric: tabular-nums; }
.gh-by { color: var(--text); }
.gh-what strong { color: var(--text); font-weight: 600; }
.gh-why { font-style: italic; }
.tgt-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2) var(--s4); flex-basis: 100%; }
.tgt-grid label { display: flex; flex-direction: column; gap: 4px; color: var(--text); font-size: var(--t-sm); }
.tgt-grid label em { color: var(--muted); font-style: normal; }
.tgt-in { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.tgt-reason { flex-basis: 100%; display: flex; align-items: center; gap: var(--s2); color: var(--text); }
.tgt-reason input { flex: 1; width: auto !important; }
.tgt-acts { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; flex-basis: 100%; }
@media (max-width: 760px) {
  .tgt-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .n-goalhist li { grid-template-columns: 1fr; gap: 0; }
}
.nmeter-tick { position: absolute; left: 80%; top: -4px; bottom: -4px; width: 2px; background: var(--text); border-radius: 1px; }
.nmeter-v { text-align: right; font-size: var(--t-md); font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.nmeter-v .u { color: var(--muted); font-weight: 400; }
.nmeter-n { font-size: var(--t-sm); color: var(--muted); font-variant-numeric: tabular-nums; display: inline-flex; align-items: center; gap: 3px; }
.nmeter.hit .nmeter-n { color: var(--good); }
.nmeter-n .ico { width: 12px; height: 12px; }
.nmeter-edit { margin: var(--s2) 0 var(--s4); }
.tgt-form { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2) var(--s4); font-size: var(--t-sm); color: var(--muted);
  padding: var(--s3); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; max-width: 640px; }
.tgt-form label { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }
.tgt-form input { width: 64px; font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; }
.tgt-form input:focus { outline: none; border-color: var(--accent); }
.tgt-hint { font-size: var(--t-sm); color: var(--muted); }

.n-trend { margin-bottom: var(--s6); }
.n-trend-h { display: flex; gap: var(--s2); align-items: baseline; margin-bottom: var(--s1); }
.n-trend-sub { color: var(--muted); font-size: var(--t-sm); }
.n-mult { display: grid; grid-template-columns: 64px 1fr; align-items: center; }
.n-mult-l { font-size: var(--t-sm); color: var(--muted); }
.chart.ch-mult { height: 96px; }
#ch-protein.ch-mult { height: 80px; }
.n-trend-note { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; color: var(--muted); font-size: var(--t-md);
  padding: var(--s3) 0; margin-bottom: var(--s4); border-top: 1px solid var(--line); }
.n-trend-note .ico { width: 14px; height: 14px; color: var(--faint); }

.ndays { border-top: 1px solid var(--line-strong); margin-bottom: var(--s6); }
.ncols-h, .nday-h, .nrow { display: grid; grid-template-columns: minmax(0, 1fr) repeat(var(--nc, 3), 60px) 24px; gap: var(--s3); align-items: center; }
.ncols-h { padding: 6px 0; font-size: var(--t-sm); color: var(--label); border-bottom: 1px solid var(--line); }
.ncol { text-align: right; font-variant-numeric: tabular-nums; }
.ncol.na { color: var(--faint); }
.nday { border-bottom: 1px solid var(--line); }
.nday-h { width: 100%; font: inherit; text-align: left; background: none; border: 0; color: var(--text); cursor: pointer; padding: 10px 0; }
.nday-h:hover { background: var(--panel); }
.nday-name { font-size: var(--t-md); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nday-h { grid-template-columns: auto minmax(0, 1fr) repeat(var(--nc, 3), 60px) 24px; }
.nday-meta { font-size: var(--t-sm); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nday-h .ncol { font-size: var(--t-md); font-weight: 600; }
.nday-chev { display: inline-grid; place-items: center; color: var(--faint); }
.nday-chev .ico { width: 14px; height: 14px; transform: rotate(-90deg); transition: transform .2s; }
.nday.open .nday-chev .ico { transform: none; }
.nday-body { padding-bottom: var(--s2); }
.nrow { grid-template-columns: 44px minmax(0, 1fr) repeat(var(--nc, 3), 60px) 24px; min-height: 32px; padding: 4px 0; font-size: var(--t-md); color: var(--text);
  cursor: pointer; border-radius: 6px; }
.nrow:hover, .nrow:focus-visible { background: var(--panel); outline: none; }
.nrow-t { color: var(--muted); font-size: var(--t-sm); font-variant-numeric: tabular-nums; padding-left: 2px; }
.nrow-d { min-width: 0; display: flex; gap: var(--s2); align-items: baseline; }
.nrow-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nrow-src { flex-shrink: 0; color: var(--muted); font-size: var(--t-sm); }
.nrow .ncol { color: var(--muted); }
.nrow .ncol.na { color: var(--faint); }
.nday-gap { padding: 8px 0; font-size: var(--t-sm); color: var(--muted); border-bottom: 1px solid var(--line); }
.nday-empty { color: var(--muted); font-size: var(--t-md); padding: 4px 0 4px 56px; line-height: 1.6; }
.nday-add { display: inline-flex; align-items: center; gap: 6px; margin: 4px 0 0 56px; font: inherit; font-size: var(--t-sm);
  color: var(--muted); background: none; border: 0; padding: 4px 0; cursor: pointer; }
.nday-add .ico { width: 13px; height: 13px; }
.nday-add:hover { color: var(--accent); }

.n-coverage { margin-bottom: var(--s6); color: var(--muted); font-size: var(--t-md); }
.n-coverage > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px; font-size: var(--t-sm); color: var(--muted); }
.n-coverage > summary::-webkit-details-marker { display: none; }
.n-coverage > summary .ico { width: 14px; height: 14px; color: var(--faint); }
.n-coverage > summary:hover { color: var(--text); }
.n-coverage ul { list-style: none; margin: var(--s2) 0 0; padding: 0 0 0 20px; display: flex; flex-direction: column; gap: 4px; line-height: 1.5; }
.n-coverage strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.n-empty { max-width: 620px; }
.n-empty .intg-actions { gap: var(--s3); flex-wrap: wrap; }
.meal-acts { display: flex; align-items: center; gap: var(--s4); flex-wrap: wrap; }
.meal-acts .link-btn { display: inline-flex; align-items: center; gap: 4px; font-size: var(--t-sm); }
.meal-acts .link-btn .ico { width: 13px; height: 13px; }
.meal-del { color: var(--warn); margin-left: auto; }

/* add sheet form */
.meal-form { display: flex; flex-direction: column; gap: var(--s2); }
.meal-form input[name=description] { font: inherit; font-size: var(--t-lg); color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.meal-form input:focus { outline: none; border-color: var(--accent); }
.meal-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.meal-grid label { display: flex; flex-direction: column; gap: 4px; font-size: var(--t-sm); color: var(--label); min-width: 0; }
.meal-grid input { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; width: 100%; }
.modal-card { overflow-x: hidden; }
.meal-more > summary { cursor: pointer; color: var(--muted); font-size: var(--t-sm); margin: 2px 0 var(--s2); }
.meal-est { display: flex; gap: 6px; align-items: center; font-size: var(--t-sm); color: var(--muted); margin-top: var(--s2); }
.meal-submit { padding: 10px; font-size: var(--t-md); }

/* ------------------------------------------------------------ mobile (phones) */
#tabbar { display: none; }
@media (max-width: 760px) {
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  main { padding: var(--s3) var(--s4) var(--s6); }
  .mobile-bar { padding-top: calc(var(--s2) + env(safe-area-inset-top)); }
  .mobile-bar .brand { font-size: var(--t-lg); }
  #tabbar { display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
    background: rgba(13,15,18,.94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); }
  #tabbar a, #tabbar button { display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 48px; justify-content: center;
    color: var(--muted); text-decoration: none; font: inherit; font-size: 11px; background: none; border: 0; border-radius: 10px; cursor: pointer; }
  #tabbar .ico { width: 20px; height: 20px; }
  #tabbar .on { color: var(--text); background: var(--panel); }
  #chat-fab { bottom: calc(76px + env(safe-area-inset-bottom)) !important; }
  #toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
  :root { --t-hero: 23px; --t-3xl: 22px; }
  #briefing { margin-top: var(--s4); }

  /* every dialog becomes a bottom sheet */
  .modal-card { top: auto; bottom: 0; left: 0; transform: none; width: 100%; max-height: 90vh; border-radius: 16px 16px 0 0;
    padding-bottom: env(safe-area-inset-bottom); border-left: 0; border-right: 0; border-bottom: 0; }
  .modal-card::before { content: ""; display: block; width: 36px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 8px auto 0; }
  .ai-card { width: 100%; }
  .ai-row { flex-wrap: wrap; }
  .ai-row .intg-btn { width: 100%; justify-content: center; min-height: 44px; }

  /* spotlight: full screen */
  .spot-card { top: 0; left: 0; transform: none; width: 100%; height: 100%; border-radius: 0; border: 0; padding-top: env(safe-area-inset-top); }
  .spot-list { max-height: none; height: calc(100% - 60px); }
  .spot-sub { display: none; }

  /* layout: one column, 2-up metrics, nothing wider than the screen */
  .metrics.c3, .metrics.c7, .metrics.c8 { grid-template-columns: repeat(2, 1fr); }
  .cal-cards { grid-template-columns: 1fr; }
  table { display: block; overflow-x: auto; }
  .chart { height: 200px; }
  .chart.ch-small { height: 150px; }
  .page-title { font-size: var(--t-xl); }
  .log-row { grid-template-columns: 40px minmax(0, 1fr) auto; gap: var(--s2); }
  .log-side .tag { font-size: 10px; padding: 0 5px; }
  .intg-row { grid-template-columns: 1fr; gap: var(--s2); }

  /* nutrition: nav + range on one line, the add action as an icon; rows keep P / F / kcal */
  .n-head { gap: var(--s2); }
  .n-head .n-nav { order: 1; }
  .n-head .seg { order: 2; margin-left: auto; }
  .n-head .n-add { order: 3; padding: 6px 8px; }
  .n-head .n-add span { display: none; }
  .n-when { min-width: 88px; font-size: var(--t-sm); }
  .seg-b { padding: 4px 8px; }
  .seg-l { display: none; }
  .seg-s { display: inline; }
  .n-read { font-size: var(--t-md); }
  .n-fix .link-btn, .nday-empty .link-btn, .n-coverage .link-btn, .n-today, .nmeter-l, .nday-add, .seg-b, .n-step { min-height: 0; }
  .n-sep { display: block; width: 0; height: 4px; margin: 0; background: none; }
  .nmeter { grid-template-columns: 60px 1fr 76px; }
  .nmeter-n { display: none; }
  .n-mult { grid-template-columns: 48px 1fr; }
  .ncols-h, .nday-h, .nrow { grid-template-columns: minmax(0, 1fr) repeat(var(--nc, 3), 40px) 16px; gap: var(--s2); }
  .nday-h { grid-template-columns: minmax(0, 1fr) repeat(var(--nc, 3), 40px) 16px; }
  .nday-meta { display: none; }
  .nrow { grid-template-columns: 36px minmax(0, 1fr) repeat(var(--nc, 3), 40px); }
  .nrow-name { white-space: normal; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
  .ncols-h { grid-template-columns: minmax(0, 1fr) repeat(var(--nc, 3), 40px); }
  .ncols-h > span:last-child { display: none; }
  .nday-h { grid-template-columns: minmax(0, 1fr) 40px 36px 48px 16px; }
  footer, #foot { padding-right: 68px; }
  .nday-empty, .nday-add { padding-left: 0; margin-left: 0; }
  .meal-grid { grid-template-columns: repeat(3, 1fr); }
  .meal-form input { font-size: 16px; } /* no iOS zoom-on-focus */
  .insight .side { display: none; }   /* action sparklines: decoration on a phone, and they overflow */
  .page-head .page-title { display: none; }   /* the top bar already names the section */
  .page-head { justify-content: flex-end; margin-bottom: var(--s3); }
  .qa-row { flex-wrap: nowrap; overflow-x: auto; margin-left: calc(-1 * var(--s4)); margin-right: calc(-1 * var(--s4));
    padding: 0 var(--s4) 4px; scrollbar-width: none; }
  .qa-row::-webkit-scrollbar { display: none; }
  .qa-chip { flex-shrink: 0; max-width: 78vw; }
  #chat-fab { width: 44px !important; height: 44px !important; right: 14px !important; }
  button, .intg-btn, .intg-ghost { min-height: 36px; }
}

/* ------------------------------------------------------------ recent activity (home) */
#activity { margin-top: var(--s7); }
.act-list { border-top: 1px solid var(--line); }
.act-row { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: var(--s3); align-items: center;
  padding: 9px 2px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.act-row:hover { background: var(--panel); }
.act-ico .ico { width: 15px; height: 15px; color: var(--faint); display: block; }
.act-main { display: flex; flex-direction: column; min-width: 0; }
.act-title { color: var(--text); font-size: var(--t-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.act-detail { color: var(--muted); font-size: var(--t-sm); }
.act-meta { display: inline-flex; align-items: center; gap: var(--s2); color: var(--muted); font-size: var(--t-sm); white-space: nowrap; }
.act-more { margin-top: var(--s2); font-size: var(--t-sm); }
.act-offer { display: flex; align-items: center; gap: var(--s3); background: var(--panel); border: 1px solid var(--accent);
  border-radius: 10px; padding: var(--s3) var(--s4); margin-bottom: var(--s3); color: var(--text); font-size: var(--t-md); }
.act-offer > .ico { width: 16px; height: 16px; color: var(--accent); flex-shrink: 0; }
.act-offer span { flex: 1; }
@media (max-width: 760px) {
  .act-row { grid-template-columns: 20px minmax(0, 1fr); }
  .act-meta { grid-column: 2; }
  .act-offer { flex-wrap: wrap; }
  .act-offer .intg-btn { width: 100%; justify-content: center; }
}
.link-banner { display: flex; align-items: center; gap: var(--s4); background: var(--panel); border: 1px solid var(--accent);
  border-radius: 12px; padding: var(--s4); margin: var(--s4) 0; }
.link-banner > .ico { width: 20px; height: 20px; color: var(--accent); flex-shrink: 0; }
.link-banner div { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.link-banner strong { color: var(--text); font-size: var(--t-lg); font-weight: 650; }
.link-banner span { color: var(--muted); font-size: var(--t-md); }
.link-banner .intg-btn { padding: 10px 16px; font-size: var(--t-md); white-space: nowrap; }
#home-link:empty, #nutrition-link:empty { display: none; }
@media (max-width: 760px) { .link-banner { flex-wrap: wrap; } .link-banner .intg-btn { width: 100%; justify-content: center; } }

/* Data check (Settings) */
.cc-row { display: flex; gap: var(--s3); align-items: baseline; padding: var(--s2) 0; border-bottom: 1px solid var(--line); font-size: var(--t-md); }
.cc-row .muted { font-size: var(--t-sm); }
.cc-detail { margin-top: var(--s1); font-size: var(--t-sm); color: var(--muted); }
.tl-none { background: var(--line-strong); }
