/* Since Nov 26 the working pages use the calmer, light version at the end of this file ("Calm look"); the
   sign-in pages keep the full desert scene. The original notes:
   Sonoran dusk: the clinic portal's visual language, built from the Interlude mark (dusk indigo to plum, a banded
   desert sun, a sand horizon).
   A desert-night sky runs from the top bar into each page header; the banded sun, plum mesas and saguaros live in a
   text-free horizon band below the title, and a sand dune melts into a sand-colored page. Text always sits on solid
   colors (night sky, sand, warm-white cards). Terracotta = actions, saguaro green = good, turquoise = info,
   sun gold = accents on the night sky. Display type + Work Sans UI, self-hosted (no third-party requests).
   Every text/background pair meets WCAG AA in light and dark mode. Chart, meter, sleep-stage and macro colors are
   the validated data-viz palette: change them only after re-running the palette validator. */

@font-face { font-family: "Raleway"; src: url("fonts/raleway-latin.e401cae7a129.woff2") format("woff2");
  font-weight: 500 800; font-style: normal; font-display: swap; }
@font-face { font-family: "Work Sans"; src: url("fonts/worksans-latin.97b33529e13b.woff2") format("woff2");
  font-weight: 400 700; font-style: normal; font-display: swap; }
/* Inter (variable, with a display optical size) for the big Apple-style wordmark. Apple devices use their own
   SF Pro via -apple-system first; everyone else gets Inter. Only downloaded on pages that use it. */
@font-face { font-family: "Inter"; src: url("fonts/inter-latin.36d46dbbf193.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap; }

:root {
  color-scheme: light;
  --font-ui: "Work Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  /* Headings, page titles and big numbers: the sign-in wordmark's stack (SF Pro on Apple devices, self-hosted Inter elsewhere). */
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", system-ui, sans-serif;

  /* Sky (top bar + page headers), from the mark's dusk tile. Text only ever sits on --night. */
  --night: #1d1838;
  --night-raised: #2d2948;     /* solid chips and buttons on the night sky */
  --night-line: #6e6a82;       /* their outline (3:1 on --night) */
  --on-night: #ffffff;
  --on-night-2: #d8cfe6;
  --gold: #ffd98f;             /* the mark's sun: eyebrows, hero buttons, focus on the night sky */
  --gold-hover: #ffe5b0;
  --gold-soft: #ffe9c4;
  --sun: linear-gradient(180deg, #ffd98f, #f0883f);
  --sand: #f6dcb4;             /* the mark's horizon */
  --sky-1: #33224b; --sky-2: #4d2a4e; --sky-3: #6a3550; --sky-4: #b4584a; --sky-5: #e88d4a; --sky-6: #f3b25e; /* sign-in sky */
  --art-filter: none;

  /* Ground */
  --page: #faf7f2;             /* light sand */
  --surface: #ffffff;          /* white cards */
  --surface-2: #f4efe8;
  --ink: #231c30;
  --ink-2: #4f4558;
  --muted: #6b6070;
  --line: #ece5da;
  --line-2: #ddd3c4;
  --field: #8f7f6c;            /* form-field borders (3:1 on cards) */

  /* Accents */
  --accent: #9c5641;           /* soft clay: primary buttons (5.5:1 with white text) */
  --accent-hover: #864834;
  --on-accent: #ffffff;
  --accent-ink: #8f4a33;       /* links */
  --accent-tint: #f6ebe5;
  --terra: #c8613b;            /* decorative */
  --green: #3f8a5c;            /* saguaro: "good" stripes */
  --green-ink: #2d6a45;
  --green-tint: #edf5ee;
  --teal: #1a8f97;             /* turquoise: decorative borders */
  --teal-ink: #11706f;
  --teal-tint: #e8f3f1;
  --amber: #b86e00;            /* "warning" stripes */
  --amber-ink: #8a5300;
  --amber-tint: #fcf4e3;
  --red: #b3243a;              /* "critical" */
  --red-tint: #fcefef;
  --navy-tint: #f0edf7;        /* dusk violet tint */
  --dusk-ink: #4d3f8f;
  --focus: #4b3fa0;

  --series-1: #1d98ba;         /* validated: chart bars & meters */
  --wash: rgba(156, 86, 65, 0.04);
  --shadow: 0 1px 2px rgba(60, 40, 20, 0.04), 0 4px 14px rgba(60, 40, 20, 0.04);
  --shadow-lg: 0 1px 3px rgba(60, 40, 20, 0.05), 0 8px 22px rgba(60, 40, 20, 0.06);
  --radius: 18px;
  --sunset: linear-gradient(90deg, #41284f, #7a3b4b 24%, #f0883f 58%, #ffd98f 82%, #f6dcb4);

  --band: 170px;               /* horizon art below the page title */
  --lift: 48px;                /* how far the page's first cards rise into the horizon */
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --night: #110e22;
    --night-raised: #232034;
    --night-line: #66637a;
    --sky-1: #241b3c; --sky-2: #37203f; --sky-3: #532c45; --sky-4: #934a40; --sky-5: #c2733f; --sky-6: #d6974f;
    --art-filter: brightness(0.82) saturate(0.9);
    --page: #131126;
    --surface: #1c1934;
    --surface-2: #262143;
    --ink: #f3ede4;
    --ink-2: #d2c9d9;
    --muted: #aa9fba;
    --line: #342d55;
    --line-2: #463d6e;
    --field: #7d7399;
    --accent: #ee9a74;
    --accent-hover: #f5b394;
    --on-accent: #1d1838;
    --accent-ink: #f3a582;
    --accent-tint: rgba(238, 154, 116, 0.16);
    --terra: #e07a52;
    --green: #5fbf80;
    --green-ink: #8fd3a4;
    --green-tint: rgba(95, 191, 128, 0.16);
    --teal: #3fbab5;
    --teal-ink: #72d4cf;
    --teal-tint: rgba(63, 186, 181, 0.16);
    --amber: #f2b84b;
    --amber-ink: #f2c26b;
    --amber-tint: rgba(242, 184, 75, 0.15);
    --red: #ff9a9a;
    --red-tint: rgba(255, 138, 138, 0.15);
    --navy-tint: rgba(169, 156, 240, 0.16);
    --dusk-ink: #bcb0f2;
    --focus: #ffd98f;
    --series-1: #2a9fc4;
    --wash: rgba(238, 154, 116, 0.08);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 8px 24px rgba(0, 0, 0, 0.28);
    --shadow-lg: 0 2px 4px rgba(0, 0, 0, 0.35), 0 18px 40px rgba(0, 0, 0, 0.45);
  }
}

/* --- Base ------------------------------------------------------------------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* hidden always wins over component display rules */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 400 15px/1.55 var(--font-ui); }
a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { font-family: var(--font-display); color: var(--ink); margin: 0; font-variant-numeric: lining-nums;
  font-optical-sizing: auto; }
h1 { font-size: 2rem; font-weight: 700; letter-spacing: -0.025em; line-height: 1.12; }
h2 { font-size: 1.1rem; font-weight: 650; letter-spacing: -0.012em; margin-bottom: 0.95rem; display: flex; align-items: center;
  gap: 0.6rem; flex-wrap: wrap; }
h3 { font-size: 0.95rem; font-weight: 700; margin: 1.25rem 0 0.5rem; }
h2 .muted, h3 .muted { font-family: var(--font-ui); font-weight: 400; font-size: 0.82rem; }
/* Section icons sit in a small sun-warmed tile. */
.card h2 > .icon { color: var(--accent-ink); width: 30px; height: 30px; padding: 6px; border-radius: 9px;
  background: var(--accent-tint); vertical-align: middle; }
p { margin: 0.4rem 0; }
code { font-size: 0.9em; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; display: block; }
td.small { display: table-cell; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.icon { flex: none; vertical-align: -4px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.topbar, .hero, .auth-pitch { --focus: var(--gold); }
::selection { background: color-mix(in srgb, var(--gold) 45%, transparent); }

/* --- Top bar: the top of the night sky ---------------------------------------- */
.topbar { position: relative; display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: 0 2rem; height: 64px; background: var(--night); color: var(--on-night); }
.topbar::after { /* a thin sunset line, only where no page header continues the sky */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--sunset); }
.topbar:has(~ .hero)::after, .topbar:has(~ .auth)::after { display: none; }
.topbar:has(~ .auth .desert-scene) { background: #110d24; } /* meet the sign-in sky without a seam */
/* Lockup: the Interlude mark (its dusk tile melts into the sky, the banded sun glows), wordmark, clinic name. */
.brand { display: flex; align-items: center; gap: 0.7rem; text-decoration: none; color: var(--on-night); min-width: 0; }
.brand-mark { display: block; width: 36px; height: 36px; border-radius: 10px; flex: none;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.14), 0 0 22px rgba(240, 136, 63, 0.3); }
.brand-name { font: 700 1.2rem/1 var(--font-display); letter-spacing: 0.01em; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; color: var(--on-night); }
.brand-sub { color: var(--on-night-2); font-size: 0.85rem; white-space: nowrap; padding-left: 0.7rem; min-width: 0;
  border-left: 1px solid var(--night-line); overflow: hidden; text-overflow: ellipsis; }
.topnav { display: flex; gap: 0.25rem; align-items: center; flex: none; white-space: nowrap; }
.topnav form { margin: 0; }
.topnav a, .topnav .linklike { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.45rem 0.85rem;
  border-radius: 999px; color: var(--on-night-2); text-decoration: none; font-weight: 500; font-size: 0.93rem; }
.topnav a:hover, .topnav .linklike:hover { background: var(--night-raised); color: var(--on-night); }
.topnav a[aria-current="page"] { color: var(--gold-soft); background: #3f3443; font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255, 217, 143, 0.35); }
.linklike { background: none; border: 0; cursor: pointer; font: inherit; }
.topbar .tag.good { background: var(--night-raised); color: var(--gold-soft); box-shadow: inset 0 0 0 1px var(--night-line);
  white-space: nowrap; flex: none; margin: 0; padding: 0.25rem 0.7rem; }

.viewonly-bar { display: flex; align-items: center; justify-content: center; gap: 0.45rem; padding: 0.45rem 1rem;
  background: var(--amber-tint); color: var(--ink); font-size: 0.85rem; font-weight: 500; text-align: center; }
@media (prefers-color-scheme: dark) { .viewonly-bar { background: #3c3137; } }

/* --- Page header: night sky above, glowing horizon band below ---------------------- */
.hero, .auth-pitch { --art: var(--band); position: relative; overflow: hidden; color: var(--on-night);
  --glow: linear-gradient(180deg, var(--night) 0%, var(--sky-1) 26%, var(--sky-2) 42%, var(--sky-3) 57%, var(--sky-4) 70%,
      var(--sky-5) 84%, var(--sky-6) 100%) left bottom / 100% var(--art) no-repeat;
  background: var(--glow), var(--night); }
.hero { padding: 2rem 2rem var(--band); }
.hero.compact { --band: 150px; }
.hero::before, .auth-pitch::before { /* mesas, saguaros, first stars (original SVG) */
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: var(--art); pointer-events: none;
  background: url("art/horizon.29e1999e57a7.svg") 72% 100% / cover no-repeat; filter: var(--art-filter); }
.hero::after, .auth-pitch::after { /* the dune in the page's own color: the desert floor becomes the page */
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 30px; pointer-events: none;
  background: var(--page);
  -webkit-mask: url("art/dune.ab542ac4e9ce.svg") 0 100% / 100% 100% no-repeat; mask: url("art/dune.ab542ac4e9ce.svg") 0 100% / 100% 100% no-repeat; }
.hero > *, .auth-pitch > * { position: relative; z-index: 1; }
.hero-inner { max-width: 1320px; margin: 0 auto; display: flex; justify-content: space-between; align-items: flex-end;
  gap: 1.5rem; position: relative; flex-wrap: wrap; }
.hero h1 { color: var(--on-night); font-size: 2.75rem; font-weight: 700; letter-spacing: -0.035em; line-height: 1.06; }
/* Page titles wear the sign-in wordmark's warm light (white to apricot), always on the solid night sky. */
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .hero h1 { background: linear-gradient(180deg, #ffffff 30%, #fff1dc 62%, #ffc98c 100%); -webkit-background-clip: text;
    background-clip: text; color: transparent; padding-bottom: 0.06em; }
}
.hero .eyebrow, .auth-pitch .eyebrow { color: #f6c27a; font-weight: 600; font-size: 0.8rem; letter-spacing: 0.12em;
  text-transform: uppercase; margin-bottom: 0.45rem; display: flex; align-items: baseline; gap: 0.55rem; }
.hero .eyebrow::before, .auth-pitch .eyebrow::before { /* a tiny banded sun, as in the mark */
  content: ""; width: 16px; height: 9px; border-radius: 16px 16px 0 0; flex: none;
  background: linear-gradient(180deg, #ffd98f 0 58%, transparent 58% 72%, #f4a254 72%); }
.hero .sub { color: var(--on-night-2); margin-top: 0.5rem; font-size: 1rem; display: flex; align-items: center; gap: 0.5rem;
  flex-wrap: wrap; }
.hero .sub a { color: var(--on-night); text-decoration: none; display: inline-grid; place-items: center; width: 32px; height: 32px;
  border-radius: 50%; background: var(--night-raised); box-shadow: inset 0 0 0 1px var(--night-line); }
.hero .sub a:hover { background: #3a3656; }
.hero .back { color: var(--on-night-2); }
.hero .back:hover { color: var(--on-night); }
.hero-person { display: flex; align-items: center; gap: 1rem; }
.hero-stats { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }
.hero-stat { background: var(--night-raised); box-shadow: inset 0 0 0 1px #3d3a56; color: #efe8f6;
  border-radius: 999px; padding: 0.32rem 0.85rem; font-size: 0.85rem; display: inline-flex; gap: 0.4rem; align-items: center; }
.hero-stat .icon { color: var(--gold); width: 17px; height: 17px; }
.hero-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.hero .lead { color: var(--on-night-2); margin-bottom: 0; max-width: 60ch; }

/* Narrow pages (patient pages, short forms): keep the header in the same column as the cards. */
.patient .hero-inner, body:has(main.narrow) .hero-inner { max-width: 696px; }
.patient .topbar { padding-inline: max(2rem, calc((100% - 696px) / 2)); }

/* --- Layout ------------------------------------------------------------------ */
.page { max-width: 1320px; margin: 0 auto; padding: 1.75rem 2rem 3rem; }
.page.lifted { margin-top: calc(-1 * var(--lift)); position: relative; padding-top: 0; }
.page.narrow { max-width: 760px; }
.back { display: inline-flex; align-items: center; gap: 0.35rem; text-decoration: none; font-weight: 500;
  font-size: 0.9rem; margin-bottom: 0.9rem; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.25rem; }
.sub { margin: 0.25rem 0 0; color: var(--ink-2); }

/* --- Buttons ------------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--ink); border-radius: 999px; padding: 0.6rem 1.15rem; font: 600 0.93rem var(--font-ui);
  cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 28%, transparent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 45%, transparent); }
.btn.danger:hover { background: var(--red-tint); }
/* On the night sky: sunlight-gold primary, solid raised secondary. */
.hero .btn.primary, .topbar .btn.primary, .auth-pitch .btn.primary { background: var(--gold); border-color: var(--gold);
  color: #1d1838; box-shadow: 0 6px 22px rgba(240, 136, 63, 0.3); }
.hero .btn.primary:hover, .topbar .btn.primary:hover { background: var(--gold-hover); border-color: var(--gold-hover); }
.btn.on-dark { background: var(--night-raised); border-color: var(--night-line); color: var(--on-night); }
.btn.on-dark:hover { background: #3a3656; }
.btn.small-btn, .small-btn { padding: 0.35rem 0.85rem; font-size: 0.85rem; }
.btn.block { width: 100%; }
.actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.done-badge { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--on-night); font-weight: 600;
  background: var(--night-raised); box-shadow: inset 0 0 0 1px var(--night-line); padding: 0.55rem 1rem; border-radius: 999px; }
.done-badge .icon { color: #a8e6b8; }
@media (prefers-reduced-motion: no-preference) {
  .btn { transition: background-color .15s, border-color .15s, box-shadow .15s, transform .05s; }
  .topnav a, .topnav .linklike, table.review tbody tr { transition: background-color .12s, color .12s; }
}

/* --- Cards, tiles ----------------------------------------------------------------- */
.card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.4rem 1.5rem; margin-bottom: 1.1rem; box-shadow: var(--shadow); }
.card.accent, .composer { overflow: hidden; }
.card.accent::before, .composer::before { /* a sliver of sunset across the top */
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--sunset); }
.card.warn { border-color: color-mix(in srgb, var(--amber) 50%, transparent); background:
  linear-gradient(0deg, var(--amber-tint), var(--amber-tint)), var(--surface); }
.card.warn h2 > .icon { color: var(--amber-ink); background: var(--surface); }
.narrowcard { max-width: 640px; margin-left: auto; margin-right: auto; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem;
  display: flex; align-items: center; gap: 1rem; box-shadow: var(--shadow-lg); }
.tile-icon { display: grid; place-items: center; width: 46px; height: 46px; border-radius: 14px; flex: none; }
.tile-label { color: var(--ink-2); font-size: 0.88rem; display: block; }
.tile-value { font: 700 2.05rem/1.05 var(--font-display); font-optical-sizing: auto; font-variant-numeric: lining-nums tabular-nums; display: block;
  color: var(--ink); letter-spacing: -0.01em; }
.tile-value small { font: 500 1rem var(--font-ui); color: var(--muted); }
.t-teal { background: var(--teal-tint); color: var(--teal-ink); }
.t-green { background: var(--green-tint); color: var(--green-ink); }
.t-amber { background: var(--amber-tint); color: var(--amber-ink); }
.t-navy { background: var(--navy-tint); color: var(--dusk-ink); }
.t-red { background: var(--red-tint); color: var(--red); }

/* --- Avatars ---------------------------------------------------------------------- */
.avatar { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; flex: none;
  font: 700 0.85rem var(--font-ui); letter-spacing: 0.02em; }
.avatar.lg { width: 64px; height: 64px; font: 800 1.35rem var(--font-display); }
.avatar.teal { background: var(--teal-tint); color: var(--teal-ink); }
.avatar.green { background: var(--green-tint); color: var(--green-ink); }
.avatar.navy { background: var(--navy-tint); color: var(--dusk-ink); }
.avatar.amber { background: var(--amber-tint); color: var(--amber-ink); }
.hero .avatar.navy { background: var(--night-raised); color: var(--on-night);
  box-shadow: 0 0 0 2px var(--gold), 0 0 22px rgba(240, 136, 63, 0.35); }
.who { display: flex; align-items: center; gap: 0.75rem; min-width: 11rem; }
.who-name { font-weight: 600; color: var(--ink); text-decoration: none; display: block; white-space: nowrap; }
a.who-name:hover { color: var(--accent-ink); }
.who .muted { font-size: 0.82rem; }

/* --- Tables --------------------------------------------------------------------- */
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 0.85rem 0.7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 1.15rem; }
th:last-child, td:last-child { padding-right: 1.15rem; }
th { font-size: 0.72rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em;
  white-space: nowrap; background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.review tbody tr { position: relative; }
table.review tbody tr:hover { background: var(--wash); }
table.review td:first-child { box-shadow: inset 4px 0 0 transparent; }
table.review tr.sev-critical td:first-child { box-shadow: inset 4px 0 0 var(--red); }
table.review tr.sev-warning td:first-child { box-shadow: inset 4px 0 0 var(--amber); }
table.review tr.sev-good td:first-child { box-shadow: inset 4px 0 0 var(--green); }
/* Long headings ("Calories vs daily target") wrap so the whole review fits a laptop screen without scrolling. */
table.review th { white-space: normal; line-height: 1.35; vertical-align: bottom; }
table.review .who { min-width: 9.5rem; }
table.review .who-name { white-space: normal; }
.rowlink::after { content: ""; position: absolute; inset: 0; } /* whole row is clickable */
/* Done rows: the marks fade, the text keeps full contrast (WCAG 1.4.3). */
tr.is-done .meter, tr.is-done .dots { opacity: 0.55; }
.empty { text-align: center; padding: 2.5rem; color: var(--ink-2); }
.footnote { color: var(--muted); font-size: 0.82rem; margin-top: 0.75rem; }
.actions-cell { white-space: nowrap; text-align: right; }
.actions-cell a { font-weight: 600; text-decoration: none; }
.actions-cell a:hover { text-decoration: underline; }
.actions-cell a + a { margin-left: 1rem; }

/* --- Metrics & meters ---------------------------------------------------------------- */
.metric { min-width: 6rem; font-variant-numeric: tabular-nums; }
.metric-value { font-weight: 600; }
.metric-target { color: var(--muted); font-size: 0.85rem; }
.meter { display: block; position: relative; height: 6px; margin-top: 0.4rem; border-radius: 3px; background: var(--line); }
.meter .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--series-1); }
.meter .goal { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); border-radius: 1px; opacity: 0.7; }

/* --- Chips, tags, statuses: color is never alone, each carries an icon and a label ------- */
.flags { min-width: 13rem; max-width: 16.5rem; }
.chip { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; font-weight: 500; padding: 0.22rem 0.65rem;
  border-radius: 999px; margin: 0 0.3rem 0.3rem 0; white-space: nowrap; color: var(--ink); background: var(--surface-2); }
.chip .ico { font-size: 0.68rem; }
.chip.critical { background: var(--red-tint); }
.chip.critical .ico { color: var(--red); }
.chip.warning { background: var(--amber-tint); }
.chip.warning .ico { color: var(--amber-ink); }
.chip.good { background: var(--green-tint); }
.chip.good .ico { color: var(--green-ink); }
.tag { display: inline-flex; align-items: center; gap: 0.3rem; font: 600 0.75rem var(--font-ui); padding: 0.15rem 0.6rem;
  border-radius: 999px; background: var(--teal-tint); color: var(--teal-ink); margin-bottom: 0.2rem; }
.tag .icon { width: 14px; height: 14px; }
.tag.good { background: var(--green-tint); color: var(--green-ink); }
.tag.navy { background: var(--navy-tint); color: var(--ink-2); }
.tag.warn { background: var(--amber-tint); color: var(--ink); }
.status, .pstatus { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.8rem; font-weight: 600;
  padding: 0.22rem 0.7rem; border-radius: 999px; white-space: nowrap; }
.status.todo { background: var(--surface-2); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line-2); }
.status.draft { background: var(--teal-tint); color: var(--teal-ink); }
.status.sent, .pstatus.active { background: var(--green-tint); color: var(--green-ink); }
.status.skipped, .pstatus.withdrawn, .pstatus.archived { background: var(--surface-2); color: var(--muted); }
.pstatus.invited { background: var(--teal-tint); color: var(--teal-ink); }
/* Status icons, drawn in the label's own color (decorative; the label carries the meaning). */
.status::before, .pstatus::before, table.caldays .tag::before {
  content: ""; width: 0.9em; height: 0.9em; flex: none; background: currentColor;
  -webkit-mask: var(--status-icon) center / contain no-repeat; mask: var(--status-icon) center / contain no-repeat; }
.status.todo { --status-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='5.5' fill='none' stroke='%23000' stroke-width='2' stroke-dasharray='3 2.2'/%3E%3C/svg%3E"); }
.status.draft { --status-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 13h3l7-7-3-3-7 7z' fill='none' stroke='%23000' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.status.sent, .pstatus.active, table.caldays .tag.good { --status-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m3 8.5 3.2 3L13 4.5' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.status.skipped, .pstatus.withdrawn, .pstatus.archived { --status-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 10a5 5 0 0 1 9-3M12.5 3v4h-4' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.pstatus.invited { --status-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M14 2 2 7l5 2 2 5z' fill='none' stroke='%23000' stroke-width='1.8' stroke-linejoin='round'/%3E%3C/svg%3E"); }
table.caldays .tag.warn { --status-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='4.5'/%3E%3C/svg%3E"); }
table.caldays .tag.warn::before { background: var(--amber-ink); }

/* --- Patient detail --------------------------------------------------------------------- */
.detail { display: grid; grid-template-columns: minmax(0, 1fr) 390px; gap: 1.25rem; align-items: start; }
.detail-side { position: sticky; top: 1rem; }
.flaglist { list-style: none; margin: 0 0 0.4rem; padding: 0; display: flex; flex-wrap: wrap; }
.charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.4rem 1.6rem; }
figure { margin: 0; }
figcaption { font-size: 0.88rem; font-weight: 600; margin-bottom: 0.35rem; }
figcaption .muted { font-weight: 400; font-size: 0.8rem; }
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--series-1); }
.chart .hit { fill: transparent; }
.chart .col:hover .hit { fill: var(--wash); }
.chart .missing { fill: var(--muted); }
.chart .axis { stroke: var(--line-2); stroke-width: 1; }
.chart .target { stroke: var(--ink); stroke-width: 1; stroke-dasharray: 4 3; opacity: 0.6; }
.chart text { font-size: 11px; fill: var(--muted); font-family: var(--font-ui); }
.daytable { margin-top: 1rem; }
.daytable summary, .manual summary { cursor: pointer; color: var(--accent-ink); font-weight: 600; }
.daytable td, .daytable th { padding: 0.45rem 0.7rem; font-size: 0.85rem; }

.composer textarea { width: 100%; font: 400 0.95rem/1.6 var(--font-ui); padding: 0.85rem; border-radius: 12px;
  border: 1px solid var(--field); background: var(--surface-2); color: var(--ink); resize: vertical; }
.composer .actions { margin: 0.75rem 0; }
.notes p { margin: 0; color: var(--ink-2); }

table.micros td { padding: 0.5rem 0.6rem; vertical-align: middle; }
table.micros tr:last-child td { border-bottom: 0; }
table.micros .microbar { width: 38%; }
.micro-target { display: block; margin-top: 0.1rem; font-size: 0.75rem; color: var(--ink-2); }
table.micros .meter { margin-top: 0; }
.mealday { display: flex; align-items: center; gap: 0.5rem; margin-top: 1.25rem; flex-wrap: wrap; }
.small-inline { font: 400 0.82rem var(--font-ui); }
.meals { list-style: none; padding: 0; margin: 0; }
.meals li { display: grid; grid-template-columns: 4.8rem 1fr auto; gap: 0.75rem; padding: 0.6rem 0; font-size: 0.92rem;
  border-bottom: 1px solid var(--line); align-items: start; }
.meals li:last-child { border-bottom: 0; }
.meal-time { padding-top: 0.1rem; }
.meal-main { display: flex; flex-direction: column; gap: 0.25rem; min-width: 0; }
.mealname { font-weight: 500; }
.meal-macros { display: flex; gap: 0.9rem; flex-wrap: wrap; font-size: 0.85rem; color: var(--ink-2); }
.meal-macros strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.meal-extras { font-size: 0.8rem; color: var(--muted); }
.meal-kcal { white-space: nowrap; }
/* Calorie split per entry: validated categorical slots 1-3 (all-pairs safe in both modes). */
:root { --macro-protein: #2a78d6; --macro-carbs: #eb6834; --macro-fat: #1baf7a; }
@media (prefers-color-scheme: dark) { :root { --macro-protein: #3987e5; --macro-carbs: #d95926; --macro-fat: #199e70; } }
.macro-protein { background: var(--macro-protein); }
.macro-carbs { background: var(--macro-carbs); }
.macro-fat { background: var(--macro-fat); }
.macrobar { display: flex; gap: 2px; height: 6px; max-width: 220px; border-radius: 3px; overflow: hidden; }
.macrobar span { display: block; height: 100%; min-width: 2px; }

/* --- Forms ------------------------------------------------------------------------------ */
.formcard { display: flex; flex-direction: column; gap: 1rem; }
.formcard > div, .formgrid > div, .consent > div { display: flex; flex-direction: column; gap: 0.35rem; }
.formcard > div.actions { flex-direction: row; gap: 0.5rem; }
.formgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; }
.formgrid > div:has(textarea) { grid-column: 1 / -1; }
.formcard label, .consent label, .login label { font-size: 0.88rem; font-weight: 600; color: var(--ink); }
input[type=text], input[type=email], input[type=password], input[type=number], select, .formcard textarea, .consent textarea {
  font: 400 0.95rem var(--font-ui); padding: 0.65rem 0.85rem; border-radius: 12px; border: 1px solid var(--field);
  background: var(--surface); color: var(--ink); width: 100%; }
input:hover, select:hover, textarea:hover { border-color: var(--ink-2); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px;
  border-color: var(--focus); border-radius: 12px; }
input[type=checkbox] { width: 1.15rem; height: 1.15rem; accent-color: var(--accent); }
input[type=checkbox]:focus-visible { border-radius: 4px; }
.consent input[type=checkbox] { width: 1.35rem; height: 1.35rem; align-self: flex-start; }
/* Owner page: radio choices and short lists with an action on the right */
.choices { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.choices label { display: flex; gap: 0.6rem; align-items: flex-start; font-weight: 600; cursor: pointer; }
.choices input[type=radio] { width: 1.15rem; height: 1.15rem; margin-top: 0.15rem; flex: none; accent-color: var(--accent); }
.choices .small { font-weight: 400; margin-top: 0.15rem; }
.owner-list { list-style: none; padding: 0; margin: 0; }
.owner-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.7rem 0;
  border-top: 1px solid var(--line); }
.owner-list li:first-child { border-top: 0; }
.owner-list li > div { min-width: 0; }
.owner-list .small { overflow-wrap: anywhere; }
.section-title { margin-top: 1.6rem; }
.formcard .helptext, .formcard [id$="_helptext"] { font-size: 0.8rem; color: var(--muted); font-weight: 400; }
ul.errorlist { color: var(--red); margin: 0; padding-left: 1rem; font-size: 0.85rem; }
.formcard div[id^="id_helps_with"] { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.35rem 1rem; }
.formcard div[id^="id_helps_with"] label { font-weight: 400; display: flex; gap: 0.45rem; align-items: center; }
input[type=file] { font: inherit; color: var(--ink-2); max-width: 100%; }
input[type=file]::file-selector-button { font: 600 0.88rem var(--font-ui); border: 1px solid var(--line-2); background: var(--surface);
  color: var(--ink); border-radius: 999px; padding: 0.45rem 0.9rem; margin-right: 0.7rem; cursor: pointer; }
textarea[readonly] { width: 100%; font: 400 0.92rem var(--font-ui); padding: 0.75rem 0.85rem; border-radius: 12px;
  border: 1px dashed var(--teal); background: var(--teal-tint); color: var(--ink); margin: 0.5rem 0; resize: none; }
.upload { display: flex; flex-wrap: wrap; gap: 0.7rem; align-items: center; margin: 0.8rem 0; }

/* --- Toasts ---------------------------------------------------------------------- */
.toasts { list-style: none; padding: 0; margin: 0 0 1.1rem; display: grid; gap: 0.5rem; }
.toast { padding: 0.75rem 1rem; border-radius: 12px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--shadow); border-left: 4px solid var(--teal); }
.toast.success { border-left-color: var(--green); }
.toast.warning { border-left-color: var(--amber); }
.toast.error { border-left-color: var(--red); }

/* --- Sign in & sign up: a tall desert evening beside the form ----------------------------- */
.auth { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: calc(100vh - 64px); }
/* Text sits in the solid night above --band; below it, stars over the horizon art (--art tall). */
.auth-pitch { --band: max(300px, 44vh); padding: 4rem 3.5rem var(--band); display: flex; flex-direction: column;
  justify-content: center; }
.auth-pitch, .auth-pitch::before { --art: 230px; }
.auth-pitch { background:
    url("art/stars.8cebdd25e3cd.svg") left 0 bottom var(--art) / 100% calc(var(--band) - var(--art)) no-repeat, var(--glow), var(--night); }
.auth-pitch::before { background-position: 62% 100%; }
.auth-pitch h1 { color: var(--on-night); font-size: 2.7rem; max-width: 16ch; }
.auth-pitch .lead { color: var(--on-night-2); max-width: 46ch; font-size: 1.08rem; margin: 1rem 0 1.5rem; }
.checks { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.7rem; }
.checks li { display: flex; gap: 0.65rem; align-items: center; color: #efe8f6; }
.checks .dot { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--night-raised);
  box-shadow: inset 0 0 0 1px rgba(255, 217, 143, 0.45); color: var(--gold); flex: none; font-size: 0.8rem; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 3rem 2rem; }
.auth-form .card { width: 100%; max-width: 440px; box-shadow: var(--shadow-lg); padding: 2.1rem; overflow: hidden; }
.auth-form .card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 4px; background: var(--sunset); }
.auth-form h2 { font-size: 1.55rem; margin-bottom: 0.25rem; }
.login { display: flex; flex-direction: column; gap: 1rem; }
.login label { display: flex; flex-direction: column; gap: 0.35rem; }

/* --- Patient-facing pages ------------------------------------------------------------ */
.patient .hero h1 { font-size: 2.05rem; }
.lead { font-size: 1.05rem; color: var(--ink-2); margin: 0.4rem 0 1rem; }
.plain { margin: 0; padding-left: 1.1rem; }
.plain li { margin: 0.35rem 0; }
.share-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.85rem; }
.share-list li { display: flex; gap: 0.8rem; align-items: flex-start; }
.share-list .tile-icon { width: 40px; height: 40px; border-radius: 12px; }
.share-list strong { display: block; }
.checklist { list-style: none; padding: 0; margin: 0.4rem 0; display: grid; gap: 0.5rem; }
.checklist li { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.6rem 0.75rem; border-radius: 12px;
  background: var(--surface-2); }
.checklist li::before { content: "✓"; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--green-tint); color: var(--green-ink); font-weight: 700; font-size: 0.8rem; flex: none; margin-top: 1px; }
ol.steps { list-style: none; counter-reset: step; padding: 0; margin: 0.6rem 0; display: grid; gap: 0.6rem; }
ol.steps li { counter-increment: step; display: flex; gap: 0.7rem; align-items: flex-start; }
ol.steps li::before { content: counter(step); display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 0.82rem; flex: none; }
.option { border: 1px solid var(--line); border-radius: 14px; padding: 1.1rem 1.2rem; margin-top: 1rem; }
.option.recommended { border: 2px solid var(--green); background: color-mix(in srgb, var(--green-tint) 40%, var(--surface)); }
.option-head { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.option-head h3 { margin: 0; display: flex; align-items: center; gap: 0.5rem; }
.manual { margin-top: 1rem; }
.manual[open] summary { margin-bottom: 0.5rem; }
.connectors { list-style: none; padding: 0; margin: 0.5rem 0 0; }
.connectors li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: 0.75rem 0;
  border-top: 1px solid var(--line); }
.connectors li > div { display: flex; gap: 0.75rem; align-items: center; }
.connectors form { margin: 0; }
.consent { display: flex; flex-direction: column; gap: 1rem; }
.agree { display: flex !important; flex-direction: row !important; gap: 0.7rem; align-items: flex-start; }

/* --- At a glance (doctor) & what's connected (patient) ----------------------------------- */
.glance { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.glance-group { background: var(--surface-2); border-radius: 14px; padding: 0.95rem 1rem; min-width: 0; }
.glance-group h3 { margin: 0 0 0.65rem; display: flex; align-items: center; gap: 0.55rem; font-size: 0.92rem; }
.glance-group .tile-icon { width: 32px; height: 32px; border-radius: 10px; }
.glance-group .tile-icon .icon { width: 17px; height: 17px; }
.glance-group dl { margin: 0; display: grid; gap: 0.4rem; }
.glance-row { display: flex; justify-content: space-between; align-items: baseline; gap: 0.75rem; font-size: 0.9rem; }
.glance-row dt { color: var(--ink-2); flex: 1 1 0; min-width: 0; }
.glance-row dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; flex: 0 1 auto; max-width: 64%;
  overflow-wrap: break-word; }
.hae-btn { margin-top: 0.5rem; }
.hae-buttons { display: flex; flex-direction: column; gap: 0.5rem; margin: 0.6rem 0 0.4rem; }
.hae-buttons .btn { justify-content: flex-start; }
.conn { list-style: none; padding: 0; margin: 0; }
.conn li { display: flex; align-items: center; gap: 0.8rem; padding: 0.75rem 0; border-top: 1px solid var(--line); }
.conn li:first-child { border-top: 0; padding-top: 0.2rem; }
.conn .tile-icon { width: 38px; height: 38px; border-radius: 12px; }
.conn-main { flex: 1; min-width: 0; }
.conn-main strong { display: block; }
.conn-hint { display: block; font-size: 0.8rem; color: var(--amber-ink); margin-top: 0.2rem; }

/* --- Sleep stages & workouts ------------------------------------------------------------ */
:root { --stage-deep: #2a78d6; --stage-core: #1baf7a; --stage-rem: #6250d6; --stage-awake: #eb6834; --stage-asleep: #6b8290; }
@media (prefers-color-scheme: dark) {
  :root { --stage-deep: #3987e5; --stage-core: #199e70; --stage-rem: #9085e9; --stage-awake: #d95926; --stage-asleep: #8aa1ab; }
}
.stage-deep { background: var(--stage-deep); }
.stage-core { background: var(--stage-core); }
.stage-rem { background: var(--stage-rem); }
.stage-awake { background: var(--stage-awake); }
.stage-asleep { background: var(--stage-asleep); }
.sleep-summary { display: flex; flex-wrap: wrap; gap: 0.4rem 1.25rem; align-items: baseline; margin-bottom: 0.6rem; }
.sleep-summary strong { font-variant-numeric: tabular-nums; }
.stage-legend { list-style: none; padding: 0; margin: 0 0 0.5rem; display: flex; gap: 1rem; flex-wrap: wrap;
  font-size: 0.82rem; color: var(--ink-2); }
.stage-legend li { display: inline-flex; align-items: center; gap: 0.35rem; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
table.sleep-table td { padding: 0.6rem 0.5rem; vertical-align: middle; }
table.sleep-table tr:last-child td { border-bottom: 0; }
.sleep-night { white-space: nowrap; }
.stagebar-cell { width: 55%; }
.stagebar { display: flex; gap: 2px; height: 14px; border-radius: 4px; overflow: hidden; background: var(--line); margin-bottom: 0.25rem; }
.stagebar span { display: block; height: 100%; min-width: 2px; }
.tablewrap.flat { box-shadow: none; }
table.workouts td .small { display: block; }

/* --- Legal & footer ------------------------------------------------------------------ */
.sitefoot { max-width: 1320px; margin: 0 auto; padding: 1.5rem 2rem 2.5rem; display: flex; justify-content: space-between;
  align-items: center; gap: 1rem; flex-wrap: wrap; color: var(--muted); font-size: 0.85rem; border-top: 1px solid var(--line); }
.sitefoot > span { display: inline-flex; align-items: center; gap: 0.5rem; font-family: var(--font-display); font-weight: 700;
  color: var(--ink-2); letter-spacing: 0.02em; }
.sitefoot > span::before { /* the mark, small */
  content: ""; width: 20px; height: 20px; border-radius: 6px; background: url("icons/interlude-mark.b9ad636e27d3.svg") center / contain no-repeat; }
.sitefoot nav { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.sitefoot a { color: var(--ink-2); text-decoration: none; }
.sitefoot a:hover { color: var(--accent-ink); text-decoration: underline; }
.patient .sitefoot { max-width: 760px; }
.legal { line-height: 1.7; }
.legal h3 { margin-top: 1.6rem; }
.legal h3:first-child { margin-top: 0; }
.legal ol.plain, .legal ul.plain { padding-left: 1.3rem; }
.legal li { margin: 0.45rem 0; }
fieldset.agreements { border: 1px solid var(--line); border-radius: 14px; padding: 0.9rem 1rem; margin: 0.25rem 0 0;
  display: grid; gap: 0.7rem; }
fieldset.agreements legend { font: 600 0.88rem var(--font-ui); padding: 0 0.35rem; color: var(--ink); }
.agree span { font-weight: 400; color: var(--ink); line-height: 1.45; }
.agree input[type=checkbox] { flex: none; width: 1.3rem; height: 1.3rem; margin: 0.1rem 0 0; }

/* --- Responsive ------------------------------------------------------------------- */
@media (max-width: 1000px) {
  .detail, .auth { grid-template-columns: 1fr; }
  .detail-side { position: static; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .charts, .formgrid, .glance { grid-template-columns: 1fr; }
  .auth-pitch { --band: 260px; padding: 2.5rem 1.5rem var(--band); }
  .auth-pitch, .auth-pitch::before { --art: 200px; }
}
@media (max-width: 640px) {
  .topbar { padding: 0 1rem; gap: 0.5rem; }
  .topnav a, .topnav .linklike { padding: 0.45rem 0.6rem; }
  .topnav .btn.small-btn { padding: 0.35rem 0.75rem; }
  .brand-sub { display: none; }
  /* Icon-only on phones; the label stays for screen readers (WCAG 2.4.4). */
  .topnav a span.label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; }
  .hero { padding: 1.6rem 1.1rem var(--band); }
  .hero h1 { font-size: 1.8rem; }
  .page { padding: 1.25rem 1rem 2.5rem; }
  .card { padding: 1.15rem; }
  .kpis { gap: 0.6rem; }
  .tile { padding: 0.8rem; gap: 0.6rem; }
  .tile-icon { width: 38px; height: 38px; }
  .tile-value { font-size: 1.6rem; }
}

/* --- Phones: the doctor portal ------------------------------------------------------------ */
@media (max-width: 700px) {
  :root { --band: 130px; --lift: 40px; }
  .hero.compact { --band: 120px; }
  .patient .topbar { padding-inline: 1rem; }

  /* Tables become cards: one card per row, each value labelled. */
  table.review thead, table.cards thead { display: none; }
  table.review, table.review tbody, table.cards, table.cards tbody { display: block; }
  table.review tr, table.cards tr { display: grid; grid-template-columns: 1fr 1fr; gap: 0.7rem 1rem;
    padding: 1rem 1rem 1rem 1.1rem; border-bottom: 1px solid var(--line); }
  table.review tbody tr:last-child, table.cards tbody tr:last-child { border-bottom: 0; }
  table.review td, table.cards td { display: block; padding: 0; border: 0; min-width: 0; text-align: left; }
  table.review td:first-child, table.cards td:first-child { grid-column: 1 / -1; padding-left: 0; box-shadow: none; }
  table.review td:last-child, table.cards td:last-child { padding-right: 0; }
  table.review tr[class] td:first-child { box-shadow: none; }
  table.review tr.sev-critical { box-shadow: inset 4px 0 0 var(--red); }
  table.review tr.sev-warning { box-shadow: inset 4px 0 0 var(--amber); }
  table.review tr.sev-good { box-shadow: inset 4px 0 0 var(--green); }
  table.review td[data-label]::before, table.cards td[data-label]::before {
    content: attr(data-label); display: block; font-size: 0.68rem; font-weight: 600; letter-spacing: 0.08em;
    text-transform: uppercase; color: var(--muted); margin-bottom: 0.2rem; }
  table.review td.flags, table.cards td.muted { grid-column: 1 / -1; max-width: none; min-width: 0; }
  table.review td.status-cell { grid-column: 1 / -1; }
  table.review .metric { min-width: 0; }
  table.review .chip, .flaglist .chip { white-space: normal; }
  table.cards td.actions-cell { grid-column: 1 / -1; text-align: left; }
  table.cards td.actions-cell a { display: inline-block; padding: 0.35rem 0; }
  table.cards.workouts tr { grid-template-columns: 1fr 1fr; }
  .who { min-width: 0; }
  td:empty { display: none !important; }

  /* Patient page: lead with this week's flags and the message, then the details. */
  .detail { display: flex; flex-direction: column; gap: 0; }
  .detail-main, .detail-side { display: contents; }
  .detail-main > *, .detail-side > * { order: 5; }
  .detail-main > .thisweek { order: 1; }
  .detail-side > .composer { order: 2; }
  .composer textarea { min-height: 15rem; font-size: 16px; } /* 16px stops iPhone zooming in */
  .composer .actions .btn { flex: 1 1 auto; }

  /* Sleep rows: night, hours and awakenings on top, the stage bar full width below. */
  table.sleep-table, table.sleep-table tbody { display: block; }
  table.sleep-table tr { display: grid; grid-template-columns: 1fr auto auto; gap: 0.35rem 0.75rem; align-items: start;
    padding: 0.7rem 0; border-bottom: 1px solid var(--line); }
  table.sleep-table td { padding: 0; border: 0; }
  table.sleep-table td.stagebar-cell { grid-row: 2; grid-column: 1 / -1; width: auto; }
  table.sleep-table td:last-child { grid-row: 1; grid-column: 3; }

  /* Micronutrients: keep name, amount, % and status; drop the bar and day count. */
  table.micros td.microbar, table.micros td.small { display: none; }

  /* Hero & headers */
  .hero-inner { align-items: stretch; }
  .hero-actions, .hero-actions .btn { width: 100%; }
  .hero-stat { font-size: 0.8rem; }
  .sleep-summary { gap: 0.3rem 0.9rem; font-size: 0.9rem; }
  .meals li { grid-template-columns: 4.2rem 1fr; }
  .meals li .meal-kcal { grid-column: 2; }
  .auth-form { order: -1; padding: 1.5rem 1rem; }
  .auth-pitch { --band: 220px; }
  .auth-pitch, .auth-pitch::before { --art: 170px; }
  .auth-pitch h1 { font-size: 1.9rem; }
  input[type=text], input[type=email], input[type=password], input[type=number], select, textarea { font-size: 16px; }
}

/* --- Desktop app: shortcuts, previous/next, install page ------------------------------------ */
kbd { display: inline-block; min-width: 1.6em; padding: 0.05rem 0.4rem; border: 1px solid var(--line-2);
  border-bottom-width: 2px; border-radius: 6px; background: var(--surface-2); font: 600 0.8rem var(--font-ui);
  text-align: center; color: var(--ink); }
.shortcuts { border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem 1.6rem; max-width: 380px;
  width: calc(100% - 2rem); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); }
.shortcuts::backdrop { background: rgba(15, 13, 31, 0.55); }
.shortcuts h2 { margin-bottom: 1rem; }
.shortcuts dl { margin: 0 0 1rem; display: grid; gap: 0.55rem; }
.shortcuts dl div { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.shortcuts dd { margin: 0; color: var(--ink-2); }
.prevnext { display: inline-flex; align-items: center; gap: 0.4rem; }
.prevnext .btn { padding: 0.55rem 0.75rem; }
.prevnext-pos { color: var(--on-night-2); font-size: 0.85rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.install-btn { color: var(--gold) !important; font-weight: 600 !important; }
.install-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 0.5rem; }
.install-head img { border-radius: 16px; box-shadow: var(--shadow); }
.install-head h2 { margin: 0; }
@media (hover: none) { .hide-touch { display: none; } }
.only-touch { display: none; }
@media (hover: none) { .only-touch { display: inline-flex; } span.only-touch { display: block; } }
@media (display-mode: standalone) { .install-btn { display: none !important; } }
@media (max-width: 700px) { .prevnext { width: 100%; justify-content: space-between; } }
.sample-tag { font-size: 0.66rem; padding: 0.05rem 0.45rem; margin-left: 0.3rem; vertical-align: 1px; }
.pin { display: inline-flex; color: var(--accent-ink); margin-right: 0.3rem; vertical-align: -2px; }
.pin .icon { width: 15px; height: 15px; }
.formgrid > div:has(input[type=checkbox]) { flex-direction: row-reverse; justify-content: flex-end; align-items: center; gap: 0.6rem; }
.chart .day-target { stroke: var(--ink); stroke-width: 2; opacity: 0.55; }

/* --- Sign-in desert scene ---------------------------------------------------------------- */
.desert-scene { justify-content: flex-end; padding: 3.5rem 3.5rem calc(46% + 1.5rem);
  background:
    radial-gradient(1.6px 1.6px at 9% 12%, rgba(255, 255, 255, 0.9), transparent 70%),
    radial-gradient(1px 1px at 18% 30%, rgba(255, 255, 255, 0.7), transparent 70%),
    radial-gradient(1.2px 1.2px at 27% 8%, rgba(255, 255, 255, 0.8), transparent 70%),
    radial-gradient(1px 1px at 36% 22%, rgba(255, 255, 255, 0.55), transparent 70%),
    radial-gradient(1.6px 1.6px at 47% 6%, rgba(255, 255, 255, 0.85), transparent 70%),
    radial-gradient(1px 1px at 56% 27%, rgba(255, 255, 255, 0.6), transparent 70%),
    radial-gradient(1.3px 1.3px at 64% 14%, rgba(255, 255, 255, 0.8), transparent 70%),
    radial-gradient(1px 1px at 73% 34%, rgba(255, 255, 255, 0.5), transparent 70%),
    radial-gradient(1.6px 1.6px at 82% 9%, rgba(255, 255, 255, 0.9), transparent 70%),
    radial-gradient(1px 1px at 90% 24%, rgba(255, 255, 255, 0.65), transparent 70%),
    radial-gradient(1.2px 1.2px at 95% 4%, rgba(255, 255, 255, 0.75), transparent 70%),
    radial-gradient(1px 1px at 5% 38%, rgba(255, 255, 255, 0.5), transparent 70%),
    linear-gradient(180deg, #110d24 0%, #1d1838 26%, #33224b 46%, #6a3550 64%, #b4584a 80%, #e88d4a 91%, #f3b25e 100%); }
.desert-scene::before, .desert-scene::after { content: none; }
.desert-scene .eyebrow { color: #f6c27a; }
.desert-scene .lead { color: #ece5f4; max-width: 40ch; margin-bottom: 0; }
.desert-scene > .scene { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: auto; z-index: 0;
  display: block; }
.ds-wordmark { font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", system-ui, sans-serif;
  font-size: 170px; font-weight: 700; letter-spacing: -0.045em; font-optical-sizing: auto;
  filter: drop-shadow(0 8px 26px rgba(255, 168, 90, 0.35)); }
@media (prefers-reduced-motion: no-preference) {
  .desert-scene .ds-sun { animation: ds-settle 2.4s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
  .desert-scene .ds-wordmark { animation: ds-reveal 1.4s 0.25s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
}
@keyframes ds-settle { from { transform: translateY(-26px); opacity: 0.5; } to { transform: none; opacity: 1; } }
@keyframes ds-reveal { from { transform: translateY(18px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (max-width: 1000px) { .auth:has(.desert-scene) { min-height: 0; } .desert-scene { padding: 2.5rem 1.5rem calc(46% + 1rem); } }

/* --- iPhone app pairing: the one-time code and QR on the connect page and /app/pair/ -------------- */
/* The code reads like a ticket stub: a warm dashed edge (3:1 on the card), large tabular characters. */
.pair-code { display: inline-block; margin: 0.35rem 0; padding: 0.4rem 0.85rem; border: 1.5px dashed var(--accent);
  border-radius: 12px; background: var(--surface-2); color: var(--ink); letter-spacing: 0.14em; user-select: all;
  font: 700 1.35rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-variant-numeric: tabular-nums; }
.pair-qr { display: block; margin-top: 0.6rem; }
/* Always dark modules on a white tile (with extra quiet zone), so it scans in dark mode too. */
.pair-qr svg { width: 176px; height: 176px; padding: 8px; border-radius: 14px; background: #ffffff;
  box-shadow: 0 0 0 1px var(--line), var(--shadow); }
#iphone-app .option-head h3 > .icon { color: var(--accent-ink); }

/* --- Sign-in & security: two-factor codes ------------------------------------------------------------------- */
.code-input { font: 600 1.15rem/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important;
  letter-spacing: 0.12em; font-variant-numeric: tabular-nums; }
.formcard .code-input { max-width: 18rem; }
.secret-key { display: inline-block; margin-top: 0.3rem; padding: 0.35rem 0.7rem; border-radius: 10px; user-select: all;
  background: var(--surface-2); color: var(--ink); border: 1px dashed var(--field); letter-spacing: 0.08em;
  font: 600 0.95rem/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; overflow-wrap: anywhere; }
ol.steps li > div { display: flex; flex-direction: column; gap: 0.3rem; min-width: 0; flex: 1; }
.codes { list-style: none; padding: 0; margin: 0.9rem 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem; }
.codes code { display: block; padding: 0.45rem 0.7rem; border-radius: 10px; background: var(--surface-2);
  border: 1px dashed var(--accent); color: var(--ink); text-align: center; letter-spacing: 0.1em;
  font: 600 0.98rem/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.inline-form { margin-top: 0.75rem; }
@media (max-width: 480px) { .codes { grid-template-columns: 1fr; } }

/* --- Friday review: week-over-week change, review progress, data freshness ------------------ */
.table-legend { margin: 0 0 0.5rem 0.25rem; font-size: 0.8rem; color: var(--muted); }
.tile-main { flex: 1; min-width: 0; }
.meter.progress { margin-top: 0.55rem; height: 5px; }
.meter.progress .fill { background: var(--green); }
.hero-stat.warn { color: var(--gold-soft); box-shadow: inset 0 0 0 1px var(--gold); font-weight: 600; }
.hero-stat.warn .icon { color: var(--gold); }

/* --- Pre-visit brief: a one-page document, on screen and on paper ---------------------------- */
.page.brief-page { max-width: 1000px; }
.brief { padding: 1.8rem 2rem; }
.brief-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem 2rem; flex-wrap: wrap;
  border-bottom: 2px solid var(--line); padding-bottom: 1rem; margin-bottom: 0.9rem; }
.brief-kicker { margin: 0; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--muted); }
.brief-head h2 { font-size: 1.65rem; margin: 0.2rem 0 0.1rem; }
.brief-sub { margin: 0; color: var(--ink-2); }
.brief-meta { margin: 0; display: grid; gap: 0.2rem; font-size: 0.85rem; }
.brief-meta div { display: flex; gap: 0.75rem; }
.brief-meta dt { color: var(--muted); min-width: 4.2rem; }
.brief-meta dd { margin: 0; color: var(--ink); }
.brief-alert { display: inline-flex; align-items: center; gap: 0.3rem; color: var(--amber-ink); font-weight: 600; }
.brief-alert .icon { width: 16px; height: 16px; }
.brief-targets { display: flex; flex-wrap: wrap; gap: 0.35rem 1.6rem; font-size: 0.9rem; }
.brief-targets strong { color: var(--muted); font-weight: 600; margin-right: 0.3rem; }
.brief h3 { margin: 1.3rem 0 0.55rem; }
.brief-table th, .brief-table td { padding: 0.45rem 0.7rem; font-size: 0.88rem; }
.brief-table tbody th { text-transform: none; letter-spacing: 0; font-size: 0.88rem; font-weight: 500; color: var(--ink);
  background: none; white-space: normal; }
.brief-table tbody tr:last-child th { border-bottom: 0; }
.brief-table tbody th { min-width: 12rem; }
.brief-table td.wrap { white-space: normal; min-width: 6.5rem; font-size: 0.82rem; }
.brief-table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.brief-table .status { font-size: 0.75rem; padding: 0.1rem 0.55rem; }
.brief-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 2rem; }
.brief-patterns { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.25rem; }
.brief-patterns .chip { margin-bottom: 0; }
.brief-message { margin: 0.35rem 0 0; padding: 0.7rem 0.95rem; border-left: 3px solid var(--line-2);
  background: var(--surface-2); border-radius: 0 12px 12px 0; color: var(--ink-2); font-size: 0.9rem; }
.visit-notes .lines span { display: block; height: 2rem; border-bottom: 1px solid var(--line-2); }
@media (max-width: 700px) {
  .brief { padding: 1.15rem; }
  .brief-cols { grid-template-columns: 1fr; }
  .brief-head h2 { font-size: 1.35rem; }
  /* The table scrolls sideways on a phone; keep each row's label in view. */
  .brief-table tbody th { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 8.5rem; }
  .brief-table tbody tr:nth-child(even) th { background: color-mix(in srgb, var(--surface-2) 55%, var(--surface)); }
}

/* Paper: always light, no app chrome, one Letter/A4 page for a typical patient. */
@media print {
  :root { color-scheme: light; --page: #ffffff; --surface: #ffffff; --surface-2: #f3efe8; --ink: #111111;
    --ink-2: #2b2b2b; --muted: #555555; --line: #d8d0c2; --line-2: #a99f8f; --amber-ink: #7a4800;
    --green-ink: #1f5a36; --red: #a01c30; --accent-ink: #8a3a20; --teal-ink: #0d5c5b; --dusk-ink: #3b3175;
    --red-tint: #fcefef; --amber-tint: #fbeed3; --green-tint: #e6f0e6; --teal-tint: #dff0ee; --navy-tint: #ebe7f5; }
  @page { size: auto; margin: 0.45in; }
  body { background: #ffffff; color: var(--ink); font-size: 10pt; }
  .topbar, .sitefoot, .viewonly-bar, .no-print, .toasts, .shortcuts { display: none !important; }
  .page, .page.lifted { max-width: none; margin: 0; padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; margin: 0; }
  .tablewrap { box-shadow: none; overflow: visible; border-radius: 6px; }
  .brief-head { padding-bottom: 0.5rem; margin-bottom: 0.5rem; }
  .brief h3 { margin: 0.65rem 0 0.3rem; font-size: 10.5pt; }
  .brief-table thead th, .brief-table tbody th, .brief-table td { padding: 0.14rem 0.5rem; font-size: 9pt; }
  .brief-head h2 { font-size: 16pt; }
  .brief-targets, .brief-meta, .brief p, .brief-message { font-size: 9.5pt; }
  .brief .footnote { margin-top: 0.3rem; font-size: 8pt; }
  .chip, .status { box-shadow: inset 0 0 0 1px var(--line-2); }
  .brief section, .brief-table tr { break-inside: avoid; }
  .visit-notes .lines span { height: 1.5rem; }
}

/* --- Glucose, blood pressure, body composition ---------------------------------------------- */
/* The practitioner's range is a soft saguaro wash behind the data; readings use the validated series color. */
:root { --range-wash: color-mix(in srgb, var(--green) 15%, transparent); }
.chart .band { fill: var(--range-wash); }
.chart .series { fill: none; stroke: var(--series-1); stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.chart .baseline { fill: none; stroke: var(--series-1); stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.chart .dot { fill: var(--series-1); }
.chart .dot.faint { fill: var(--ink-2); opacity: 0.5; }
.chart .context { fill: var(--navy-tint); }
.chart .hour { stroke: var(--line); stroke-width: 1; }
.chart .meal line { stroke: var(--accent-ink); stroke-width: 1; stroke-dasharray: 2 2; opacity: 0.75; }
.chart .meal circle { fill: var(--accent); }
.chart .meal text { fill: var(--on-accent); font: 700 9px var(--font-ui); }
.chart.bp .reading line { stroke: var(--ink-2); stroke-width: 1.5; }
.chart.bp .sys { fill: var(--macro-carbs); }
.chart.bp .dia { fill: var(--surface); stroke: var(--macro-protein); stroke-width: 1.8; }
.stat-row { display: flex; flex-wrap: wrap; gap: 0.75rem 2.2rem; align-items: flex-end; margin-bottom: 0.75rem; }
.stat { display: flex; flex-direction: column; min-width: 0; }
.stat-value { font: 700 1.6rem/1.1 var(--font-display); font-variant-numeric: lining-nums tabular-nums; color: var(--ink); }
.stat-value small { font: 500 0.9rem var(--font-ui); color: var(--muted); }
.stat-label { color: var(--ink-2); font-size: 0.85rem; }
.tirbar { display: flex; gap: 2px; height: 12px; border-radius: 6px; overflow: hidden; background: var(--line); margin: 0.2rem 0 0.5rem; }
.tirbar span { display: block; height: 100%; }
.tir-below { background: var(--red); }
.tir-in { background: var(--green); }
.tir-above { background: var(--amber); }
.sufficiency, .hypothesis { display: flex; gap: 0.6rem; align-items: flex-start; padding: 0.7rem 0.9rem; border-radius: 12px;
  color: var(--ink); font-size: 0.9rem; }
.sufficiency { background: var(--amber-tint); }
.sufficiency .icon { color: var(--amber-ink); flex: none; margin-top: 1px; width: 18px; height: 18px; }
.hypothesis { background: var(--navy-tint); margin-top: 0.9rem; font-size: 0.85rem; }
.hypothesis .icon { color: var(--dusk-ink); flex: none; margin-top: 1px; width: 18px; height: 18px; }
.gdays { display: grid; gap: 4px; margin: 0.9rem 0 0.4rem; }
.gday { display: grid; grid-template-columns: 10rem minmax(0, 1fr); gap: 0.75rem; align-items: center; }
.gday-label { display: flex; flex-direction: column; line-height: 1.25; font-size: 0.85rem; min-width: 0; }
.gday .chart { border-radius: 6px; background: var(--surface-2); }
.gday-axis .chart { background: none; }
.band-swatch { background: color-mix(in srgb, var(--green) 30%, var(--surface)); box-shadow: inset 0 0 0 1px var(--green); }
.meal-key { display: inline-grid; place-items: center; min-width: 1.3rem; height: 1.3rem; padding: 0 0.2rem; border-radius: 999px;
  background: var(--accent); color: var(--on-accent); font: 700 0.72rem var(--font-ui); }
.stage-legend .meal-key { margin-right: 0.1rem; }
.rankings { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.5rem; }
.rankings h4 { margin: 0 0 0.4rem; font-size: 0.9rem; display: flex; gap: 0.4rem; align-items: center; }
.rankings h4 .icon { width: 17px; height: 17px; color: var(--accent-ink); }
.ranklist { margin: 0; padding-left: 1.3rem; display: grid; gap: 0.35rem; font-size: 0.9rem; }
.ranklist li span { display: block; }
.ranklist li span.muted { font-size: 0.8rem; }
.readings { list-style: none; padding: 0; margin: 0.75rem 0 0; }
.readings li { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(7rem, auto); gap: 0.75rem; padding: 0.45rem 0;
  border-top: 1px solid var(--line); font-size: 0.9rem; align-items: baseline; font-variant-numeric: tabular-nums; }
.charts.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.body-split { margin-top: 0.8rem; }
.context-tag { align-self: flex-start; margin-top: 0.15rem; }
table.meal-glucose td { padding-top: 0.55rem; padding-bottom: 0.55rem; }
@media (max-width: 1000px) { .charts.three { grid-template-columns: 1fr; } }
.chart-narrow { display: none; }
@media (max-width: 700px) { .chart-wide { display: none; } .chart-narrow { display: block; } }
@media (max-width: 700px) {
  .gday { grid-template-columns: 1fr; gap: 0.15rem; }
  .gday-label { flex-direction: row; flex-wrap: wrap; gap: 0.2rem 0.6rem; align-items: baseline; }
  .gday-axis .gday-label { display: none; }
  .rankings { grid-template-columns: 1fr; }
  .readings li { grid-template-columns: minmax(0, 1fr) auto; }
  .readings li > :last-child { grid-column: 1 / -1; }
  table.meal-glucose tr { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.4rem 0.75rem; padding: 0.7rem 0.9rem; }
  table.meal-glucose td[colspan] { grid-column: 1 / -1; }
}
.meal-cell { display: flex; gap: 0.6rem; align-items: flex-start; }
.meal-cell .meal-key { margin-top: 0.1rem; flex: none; }

/* --- Targets: the edit form's sections, program templates, this week's scorecard ------------------------------ */
fieldset.formsection { border: 0; border-top: 1px solid var(--line); margin: 0; padding: 1.1rem 0 0.2rem;
  display: flex; flex-direction: column; gap: 0.6rem; min-width: 0; }
fieldset.formsection:first-of-type { border-top: 0; padding-top: 0.2rem; }
fieldset.formsection legend { font: 650 1rem var(--font-display); color: var(--ink); padding: 0; float: left; width: 100%;
  margin-bottom: 0.2rem; }
fieldset.formsection legend + * { clear: both; }
.program-box { background: var(--surface-2); border-radius: 14px; padding: 1rem 1.1rem 0.8rem !important; border: 0 !important; }
.template-apply { display: flex; flex-direction: column; gap: 0.35rem; justify-content: flex-end; align-items: flex-start; }
.template-list { margin: 0.3rem 0 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem 1rem;
  font-size: 0.82rem; }
.template-list dt { font-weight: 600; color: var(--ink); }
.template-list dd { margin: 0.1rem 0 0; color: var(--ink-2); }
table.scorecard td { padding-top: 0.55rem; padding-bottom: 0.55rem; }
table.scorecard td .small { display: block; }
.tag.met::before { content: ""; width: 0.85em; height: 0.85em; flex: none; background: currentColor;
  -webkit-mask: var(--status-icon) center / contain no-repeat; mask: var(--status-icon) center / contain no-repeat; }
.tag.good.met { --status-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='m3 8.5 3.2 3L13 4.5' fill='none' stroke='%23000' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.tag.warn.met { --status-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='4.5'/%3E%3C/svg%3E"); }
.tag.warn.met::before { background: var(--amber-ink); }
.tag.nodata { --status-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8h8' fill='none' stroke='%23000' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.protocol .checklist li { font-size: 0.92rem; }
@media (max-width: 1000px) { .template-list { grid-template-columns: 1fr; } }

/* --- Athlete view: fueling by day type, training load, recovery, event --------------------------------------- */
.daytype { display: inline-flex; align-items: center; gap: 0.3rem; font-weight: 600; font-size: 0.85rem; white-space: nowrap; }
.daytype span[aria-hidden] { color: var(--dusk-ink); font-size: 0.95rem; }
.daytype.high span[aria-hidden], .daytype.medium span[aria-hidden] { color: var(--accent-ink); }
table.fuel td { padding-top: 0.55rem; padding-bottom: 0.55rem; vertical-align: top; }
table.fuel td .small { display: block; }
table.fuel .tag.met { margin-top: 0.2rem; }
.athlete .stat-label .chip { margin: 0.25rem 0 0; }
@media (max-width: 700px) {
  table.fuel tr { grid-template-columns: 1fr 1fr; }
}

/* --- Friday triage: groups, day dots, why lines, one-click approval, focus, marked days ----------------------- */
.triage { margin-bottom: 1.4rem; }
.group-head { margin: 0 0 0.6rem 0.2rem; font-size: 1.05rem; }
.group-head .tile-icon { width: 30px; height: 30px; border-radius: 9px; }
.group-head .tile-icon .icon { width: 16px; height: 16px; }
.dots { list-style: none; margin: 0; padding: 0; display: flex; gap: 3px; }
.dot { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; font: 700 0.62rem/1 var(--font-ui);
  box-shadow: inset 0 0 0 1px var(--line-2); background: var(--surface-2); color: var(--ink-2); flex: none; }
.dot.on { background: var(--green-tint); color: var(--green-ink); box-shadow: inset 0 0 0 1px var(--green); }
.dot.under, .dot.over { background: var(--amber-tint); color: var(--amber-ink); box-shadow: inset 0 0 0 1px var(--amber); }
.dot.missing { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line-2); }
.dot.context { background: var(--navy-tint); color: var(--dusk-ink); box-shadow: inset 0 0 0 1px var(--dusk-ink); }
.table-legend .dot { width: 15px; height: 15px; font-size: 0.55rem; vertical-align: -2px; margin: 0 0.1rem; }
.thisweek .dots { margin: 0.2rem 0 0.6rem; }
.thisweek .dot { width: 24px; height: 24px; font-size: 0.75rem; }
.dots-sub { display: block; margin-top: 0.35rem; font-size: 0.8rem; color: var(--ink-2); white-space: nowrap; }
.why { margin: 0.25rem 0 0.2rem; font-size: 0.8rem; color: var(--ink-2); line-height: 1.4; white-space: normal; }
table.review .chip { white-space: normal; border-radius: 10px; }
.why-label { font-weight: 600; color: var(--ink); }
.flags { max-width: 19rem; }
.focus-line { display: flex; gap: 0.45rem; align-items: flex-start; margin: 0 0 0.45rem; font-size: 0.85rem; color: var(--ink); }
.focus-line .icon { width: 16px; height: 16px; color: var(--dusk-ink); margin-top: 2px; flex: none; }
.thisweek .focus-line { font-size: 0.92rem; padding: 0.6rem 0.8rem; border-radius: 12px; background: var(--navy-tint); }
.approve { position: relative; z-index: 2; margin: 0; } /* above the row-wide link */
.approve-btn { white-space: normal; text-align: left; line-height: 1.25; max-width: 8.5rem; padding: 0.4rem 0.8rem;
  border-radius: 14px; }
.approve-btn .icon { width: 16px; height: 16px; color: var(--green-ink); }
.focus-pick { display: flex; flex-direction: column; gap: 0.4rem; margin: 0.4rem 0 0.2rem; }
.focus-pick label { font-size: 0.88rem; font-weight: 600; }
.marks { list-style: none; padding: 0; margin: 0 0 0.75rem; }
.marks li { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; padding: 0.4rem 0;
  border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.marks form { margin: 0; }
.markform { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; align-items: end; }
.markform label { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.82rem; font-weight: 600; }
.markform .wide, .markform .btn { grid-column: 1 / -1; }
@media (max-width: 700px) {
  table.review td.status-cell .approve-btn { width: 100%; }
}

/* --- "Your week" on the patient's page, and its switches on the edit form ------------------------------------ */
/* Read-only and calm: neutral tags (a tick for Met, an open ring for Not yet), no red, the clinic's words. */
.yourweek .week-part { border-top: 1px solid var(--line); padding-top: 1rem; margin-top: 1rem; }
.yourweek h2 + .week-part { border-top: 0; padding-top: 0; margin-top: 0; }
.yourweek h3 { margin: 0 0 0.6rem; display: flex; align-items: center; gap: 0.45rem; }
.yourweek h3 .icon { width: 18px; height: 18px; color: var(--accent-ink); }
.checkin-message { padding: 0.8rem 1rem; border-left: 3px solid var(--accent); background: var(--surface-2);
  border-radius: 0 12px 12px 0; color: var(--ink); overflow-wrap: anywhere; }
.checkin-message p { margin: 0 0 0.55rem; }
.checkin-message p:last-child { margin-bottom: 0; }
.reviewed { display: flex; gap: 0.4rem; align-items: flex-start; margin: 0.55rem 0 0; font-size: 0.85rem; color: var(--ink-2); }
.reviewed .icon { width: 16px; height: 16px; color: var(--green-ink); margin-top: 2px; }
.yourweek .focus-line { font-size: 0.95rem; padding: 0.65rem 0.85rem; border-radius: 12px; background: var(--navy-tint);
  margin-bottom: 0.6rem; }
.yourweek .focus-line .small { margin-top: 0.15rem; }
.checklist.plainmark li::before { content: ""; width: 8px; height: 8px; margin: 0.5rem 0.35rem 0 0.3rem;
  background: var(--dusk-ink); }
.tag.notyet { --status-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='5' fill='none' stroke='%23000' stroke-width='2'/%3E%3C/svg%3E"); }
table.week-targets td { padding-top: 0.6rem; padding-bottom: 0.6rem; }
table.week-targets td .small { display: block; margin-top: 0.1rem; }
table.week-targets td:nth-child(2) { font-variant-numeric: tabular-nums; }
table.week-targets .tag { white-space: nowrap; }
.week-vitals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.5rem; align-items: start;
  margin-bottom: 0; }
.week-vitals .stat { gap: 0.15rem; }
.week-vitals .stat-label strong { color: var(--ink); }
.tir-meter { height: 8px; border-radius: 4px; margin-top: 0.45rem; max-width: 18rem; }
.tir-meter .fill { border-radius: 4px; }
.week-note { display: flex; gap: 0.45rem; align-items: flex-start; margin: 1.1rem 0 0; padding-top: 0.9rem;
  border-top: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; }
.week-note .icon { width: 16px; height: 16px; margin-top: 2px; }
.switches { display: grid; gap: 0.8rem; }
.switch { display: flex; gap: 0.7rem; align-items: flex-start; }
.switch input[type=checkbox] { flex: none; width: 1.25rem; height: 1.25rem; margin: 0.1rem 0 0; }
.switch label { font-weight: 600; cursor: pointer; }
.switch .small { margin-top: 0.1rem; line-height: 1.45; }
@media (max-width: 700px) {
  .week-vitals { grid-template-columns: 1fr; }
  /* Phones: the target and its result on one line, this week's value underneath. */
  table.cards.week-targets tr { grid-template-columns: minmax(0, 1fr) auto; gap: 0.3rem 0.75rem; padding: 0.75rem 0.9rem; }
  table.cards.week-targets td { padding: 0; }
  table.cards.week-targets td:first-child { grid-column: 1; grid-row: 1; }
  table.cards.week-targets td:last-child { grid-column: 2; grid-row: 1; align-self: start; }
  table.cards.week-targets td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  table.cards.week-targets td:last-child[data-label]::before { display: none; }
  table.cards.week-targets td:nth-child(2)[data-label]::before { display: inline; content: attr(data-label) ": ";
    text-transform: none; letter-spacing: 0; font-size: inherit; font-weight: 400; margin: 0; }
}

/* --- Accessibility preferences ------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .btn:active { transform: none; }
}
@media (forced-colors: active) {
  .hero::before, .hero::after, .auth-pitch::before, .auth-pitch::after, .card.accent::before, .composer::before { display: none; }
  .status::before, .pstatus::before, table.caldays .tag::before { background: CanvasText; }
  .hero h1 { background: none; color: CanvasText; }
}

/* --- Calm look (Nov 26) ------------------------------------------------------------------------------------------
   Working pages: a light top bar and a plain page header (no night sky, horizon art or sunset lines), quieter section
   icons and stripes, and folded detail sections. The sign-in and sign-up pages (.auth) keep the desert scene. */
body:not(:has(.auth)) .topbar { background: var(--surface); color: var(--ink); border-bottom: 1px solid var(--line);
  height: 60px; }
body:not(:has(.auth)) :is(.topbar, .hero) { --focus: inherit; }
body:not(:has(.auth)) .topbar::after { display: none; }
body:not(:has(.auth)) :is(.brand, .brand-name) { color: var(--ink); }
body:not(:has(.auth)) .brand-mark { width: 32px; height: 32px; box-shadow: none; }
body:not(:has(.auth)) .brand-sub { color: var(--muted); border-left-color: var(--line-2); }
body:not(:has(.auth)) .topnav :is(a, .linklike) { color: var(--ink-2); }
body:not(:has(.auth)) .topnav :is(a, .linklike):hover { background: var(--surface-2); color: var(--ink); }
body:not(:has(.auth)) .topnav a[aria-current="page"] { background: var(--accent-tint); color: var(--accent-ink);
  box-shadow: none; }
body:not(:has(.auth)) .install-btn { color: var(--accent-ink) !important; }
body:not(:has(.auth)) .topbar .tag.good { background: var(--green-tint); color: var(--green-ink); box-shadow: none; }

body:not(:has(.auth)) .hero { background: none; color: var(--ink); padding: 1.9rem 2rem 1.5rem; overflow: visible; }
body:not(:has(.auth)) .hero::before, body:not(:has(.auth)) .hero::after { display: none; }
body:not(:has(.auth)) .hero h1 { background: none; -webkit-background-clip: border-box; background-clip: border-box;
  color: var(--ink); font-size: 2.1rem; padding-bottom: 0; }
body:not(:has(.auth)) .hero .eyebrow { color: var(--muted); font-size: 0.75rem; letter-spacing: 0.1em; }
body:not(:has(.auth)) .hero .eyebrow::before { display: none; }
body:not(:has(.auth)) .hero :is(.sub, .lead, .back) { color: var(--ink-2); }
body:not(:has(.auth)) .hero .back:hover { color: var(--ink); }
body:not(:has(.auth)) .hero .sub a { background: var(--surface); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line-2); }
body:not(:has(.auth)) .hero .sub a:hover { background: var(--surface-2); }
body:not(:has(.auth)) .hero-stat { background: var(--surface); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line); }
body:not(:has(.auth)) .hero-stat .icon { color: var(--muted); }
body:not(:has(.auth)) .hero-stat.warn { background: var(--amber-tint); color: var(--ink); font-weight: 600;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--amber) 45%, transparent); }
body:not(:has(.auth)) .hero-stat.warn .icon { color: var(--amber-ink); }
body:not(:has(.auth)) .hero .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent);
  box-shadow: none; }
body:not(:has(.auth)) .hero .btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
body:not(:has(.auth)) .btn.on-dark { background: var(--surface); border-color: var(--line-2); color: var(--ink); }
body:not(:has(.auth)) .btn.on-dark:hover { background: var(--surface-2); border-color: var(--muted); }
body:not(:has(.auth)) .done-badge { background: var(--green-tint); color: var(--green-ink); box-shadow: none; }
body:not(:has(.auth)) .done-badge .icon { color: var(--green-ink); }
body:not(:has(.auth)) .prevnext-pos { color: var(--muted); }
body:not(:has(.auth)) .hero .avatar.navy { background: var(--navy-tint); color: var(--dusk-ink); box-shadow: none; }
body:not(:has(.auth)) .page.lifted { margin-top: 0; padding-top: 0.25rem; }
/* Line the title up with the cards below it (the page column is 1320px wide with 2rem padding). */
body:not(:has(.auth)):not(.patient):not(:has(main.narrow)) .hero-inner { max-width: calc(1320px - 4rem); }
@media (max-width: 700px) {
  body:not(:has(.auth)) .hero { padding: 1.3rem 1.1rem 1.1rem; }
  body:not(:has(.auth)) .hero h1 { font-size: 1.7rem; }
}

/* Quieter cards: no sunset sliver, neutral section icons, lighter tiles, thinner row stripes. */
body:not(:has(.auth)) :is(.card.accent, .composer)::before { display: none; }
body:not(:has(.auth)) .card h2 > .icon { color: var(--ink-2); background: var(--surface-2); }
body:not(:has(.auth)) .tile { box-shadow: var(--shadow); }
body:not(:has(.auth)) table.review tr.sev-critical td:first-child {
  box-shadow: inset 3px 0 0 color-mix(in srgb, var(--red) 55%, var(--surface)); }
body:not(:has(.auth)) table.review tr.sev-warning td:first-child {
  box-shadow: inset 3px 0 0 color-mix(in srgb, var(--amber) 55%, var(--surface)); }
body:not(:has(.auth)) table.review tr.sev-good td:first-child {
  box-shadow: inset 3px 0 0 color-mix(in srgb, var(--green) 55%, var(--surface)); }

/* Folded detail sections (patient page): the heading row opens and closes it; a chevron shows which way. */
details.card.fold:not([open]) { padding-block: 1rem; }
details.card.fold > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 1rem;
  justify-content: space-between; border-radius: 10px; }
details.card.fold > summary::-webkit-details-marker { display: none; }
details.card.fold > summary h2 { margin: 0; }
details.card.fold[open] > summary { margin-bottom: 0.95rem; }
details.card.fold > summary::after { content: ""; flex: none; width: 9px; height: 9px; margin: 0 0.4rem 0.3rem;
  border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(45deg); }
details.card.fold[open] > summary::after { transform: rotate(-135deg); margin-bottom: -0.2rem; }
details.card.fold > summary:hover h2 { color: var(--accent-ink); }

/* Friday review: "Why" folds into the row, the key and the fine print into one "How to read this page". */
details.why { margin: 0.3rem 0 0.15rem; }
details.why > summary, details.howto > summary { list-style: none; cursor: pointer; display: inline-flex;
  align-items: center; gap: 0.35rem; font-weight: 600; color: var(--accent-ink); }
details.why > summary::-webkit-details-marker, details.howto > summary::-webkit-details-marker { display: none; }
details.why > summary::after, details.howto > summary::after { content: ""; width: 6px; height: 6px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg) translateY(-2px); }
details.why[open] > summary::after, details.howto[open] > summary::after { transform: rotate(-135deg) translate(-1px, -1px); }
details.why > p { margin: 0.2rem 0 0; }
details.howto { margin-top: 1.1rem; font-size: 0.82rem; color: var(--muted); }
details.howto > p { margin: 0.55rem 0 0; max-width: 120ch; }
details.howto .table-legend { margin: 0.55rem 0 0; }

/* Check-ins: when the last one went out under each chip, the Snooze menu and the folded Snoozed group. */
.checkin-when { display: block; margin-top: 0.35rem; font-size: 0.76rem; color: var(--muted); white-space: nowrap; }
.status.snoozed { background: var(--navy-tint); color: var(--dusk-ink); --status-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M12.5 9.5A5.5 5.5 0 0 1 6.5 3.5a5.5 5.5 0 1 0 6 6z' fill='none' stroke='%23000' stroke-width='2' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.snooze-menu { position: relative; }
.snooze-menu > summary { list-style: none; }
.snooze-menu > summary::-webkit-details-marker { display: none; }
.snooze-pop { position: absolute; right: 0; top: calc(100% + 0.4rem); z-index: 5; width: 15.5rem; display: grid;
  gap: 0.45rem; padding: 0.85rem; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow-lg); }
.snooze-pop p { margin: 0 0 0.15rem; }
.snooze-pop .btn { justify-content: flex-start; }
@media (max-width: 700px) {
  .hero-actions :is(.snooze-menu, form), .hero-actions form .btn { width: 100%; }
  .snooze-pop { left: 0; right: auto; width: 100%; }
}
details.snoozed-group { margin-top: 1.25rem; }
details.snoozed-group > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 0.5rem; }
details.snoozed-group > summary::-webkit-details-marker { display: none; }
details.snoozed-group > summary::after { content: ""; width: 7px; height: 7px; margin-bottom: 0.55rem;
  border-right: 2px solid var(--ink-2); border-bottom: 2px solid var(--ink-2); transform: rotate(45deg); }
details.snoozed-group[open] > summary::after { transform: rotate(-135deg); margin-bottom: 0.2rem; }
details.snoozed-group[open] > summary { margin-bottom: 0.1rem; }
table.snoozed-table td { vertical-align: middle; }
table.snoozed-table .status-cell { text-align: right; }

/* Team page: a role picker and its button side by side. */
.inline-form { display: flex; gap: 0.4rem; align-items: center; margin: 0; }
.inline-form select { width: auto; padding-block: 0.4rem; }

/* Check-ins: whose patients to show (everyone, mine, each practitioner, unassigned). */
.who-filter { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 1rem; }
.who-filter a { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0.85rem; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink-2); text-decoration: none; font-weight: 500;
  font-size: 0.88rem; }
.who-filter a:hover { background: var(--surface-2); color: var(--ink); }
.who-filter a[aria-current="page"] { background: var(--accent-tint); border-color: transparent; color: var(--accent-ink);
  font-weight: 600; }
.who-count { font-size: 0.78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.who-filter a[aria-current="page"] .who-count { color: var(--accent-ink); }

/* Device & app guide (device_guide.py): the guide, "What I use" ticks, the practitioner's card, suggestions */
.guide { display: grid; gap: 1.4rem; }
.guide-kind h3 { display: flex; align-items: center; gap: 0.6rem; margin: 0 0 0.4rem; }
.guide-kind .tile-icon { width: 34px; height: 34px; border-radius: 11px; }
.guide-sees { margin: 0 0 0.3rem; font-size: 0.9rem; }
.guide-note { margin: 0 0 0.5rem; }
.guide-items { list-style: none; padding: 0; margin: 0.6rem 0 0; display: grid; gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.guide-item { border: 1px solid var(--line); border-radius: 14px; padding: 0.85rem 1rem; display: flex;
  flex-direction: column; gap: 0.35rem; background: var(--surface); }
.guide-item.owned { border-color: var(--green); }
.guide-item-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.guide-price { margin: 0; font-size: 0.9rem; }
.guide-facts { margin: 0; display: grid; gap: 0.35rem; font-size: 0.84rem; }
.guide-facts dt { font: 600 0.72rem var(--font-ui); text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.guide-facts dd { margin: 0.05rem 0 0; color: var(--ink-2); }
.guide-link { margin: auto 0 0; padding-top: 0.3rem; font-size: 0.88rem; display: flex; gap: 0.5rem; align-items: center;
  flex-wrap: wrap; }
.guide-fold { margin-top: 1.25rem; }
.device-picks { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); margin: 0.6rem 0 1rem; }
.device-picks fieldset { border: 1px solid var(--line); border-radius: 14px; padding: 0.6rem 0.85rem 0.75rem; margin: 0;
  display: grid; gap: 0.45rem; align-content: start; }
.device-picks legend { font: 600 0.85rem var(--font-ui); padding: 0 0.3rem; color: var(--ink); }
.pick { display: flex; align-items: center; gap: 0.55rem; font-size: 0.9rem; cursor: pointer; min-height: 28px; }
.pick input[type=checkbox] { flex: none; }
.detail-side .device-picks { grid-template-columns: 1fr; }
.device-line { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin: 0.3rem 0; }
.device-line > strong { margin-right: 0.2rem; }
.device-gaps { list-style: none; padding: 0; margin: 0.3rem 0 0.6rem; }
.device-gaps li { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.55rem 0;
  border-top: 1px solid var(--line); }
.device-gaps li:first-child { border-top: 0; }
.device-gaps li > div { display: grid; gap: 0.1rem; }
.device-gaps form { margin: 0; flex: none; }
.suggest-other { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.suggest-other label { width: 100%; }
.device-edit { margin: 0.75rem 0 0.4rem; }
.device-edit > summary { cursor: pointer; font: 600 0.88rem var(--font-ui); color: var(--accent-ink); }
.suggestion { border-radius: 12px; background: var(--surface-2); padding: 0.7rem 0.85rem; margin: 0.2rem 0 0.75rem; }
.suggestion p { margin: 0; }
.suggestion p + p { margin-top: 0.35rem; }
/* The guide's "at a glance" grid and the "working together" grid */
.guide-glance h3, .coverage-wrap h3 { margin: 0 0 0.5rem; }
.guide-grid, .coverage { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.guide-grid th, .guide-grid td, .coverage th, .coverage td { padding: 0.45rem 0.55rem; border-bottom: 1px solid var(--line);
  text-align: left; vertical-align: middle; }
.guide-grid thead th { font: 600 0.74rem var(--font-ui); color: var(--muted); text-align: center; white-space: nowrap; }
.guide-grid thead th:first-child { text-align: left; }
.guide-grid td { text-align: center; }
.guide-grid tbody th { font-weight: 600; white-space: nowrap; position: sticky; left: 0; background: var(--surface); }
.guide-grid tbody th .tag { margin-left: 0.3rem; }
.guide-grid .grid-kind th { position: static; background: var(--surface-2); font: 650 0.78rem var(--font-ui);
  color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; }
.guide-grid tr.owned th, .guide-grid tr.owned td { background: color-mix(in srgb, var(--green-tint) 55%, var(--surface)); }
.mark { font-weight: 700; display: inline-block; min-width: 1em; text-align: center; }
.mark.yes { color: var(--green-ink); }
.mark.some { color: var(--amber-ink); }
.mark.no { color: var(--muted); font-weight: 400; }
.grid-key { margin-top: 0.4rem; }
.coverage-wrap { margin: 0.75rem 0 0.9rem; }
.coverage thead th { font: 600 0.74rem var(--font-ui); color: var(--muted); }
.coverage tbody th { font-weight: 600; white-space: nowrap; }
.coverage tr.cov-gap th, .coverage tr.cov-gap td { background: color-mix(in srgb, var(--amber-tint) 60%, var(--surface)); }
.cov-gap-label { color: var(--amber-ink); }
.guide-offer { margin: 0; font-size: 0.86rem; display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; }
.guide-grid tbody th, .coverage tbody th { text-transform: none; letter-spacing: normal; font: 600 0.84rem var(--font-ui);
  color: var(--ink); }
.guide-grid tbody th a { font-weight: 600; }
.coverage .cov-why { display: block; font: 400 0.76rem var(--font-ui); color: var(--muted); white-space: normal; }
.coverage td.cov-mark { text-align: center; width: 4.5rem; }
.coverage thead th:nth-child(2) { text-align: center; }
/* The guide is a grid: keep the wide table scrolling inside its box instead of widening the page on phones */
.guide { grid-template-columns: minmax(0, 1fr); }
.guide-glance, .coverage-wrap { min-width: 0; max-width: 100%; }
/* Screen-reader-only labels in the cells are positioned: keep them inside the scrolling box */
.guide-glance .tablewrap, .coverage-wrap .tablewrap { position: relative; }

/* Owner page: clinic requests from the business page, and its stories (monitoring/owner.py) */
.requests { list-style: none; padding: 0; margin: 0.6rem 0 0; display: grid; gap: 0.75rem; }
.request { border: 1px solid var(--line); border-radius: 14px; padding: 0.9rem 1rem; display: grid; gap: 0.55rem; }
.request-head { display: flex; flex-wrap: wrap; gap: 0.2rem 0.6rem; align-items: baseline; }
.request-head strong { font-size: 1rem; }
.request-facts { margin: 0; display: grid; gap: 0.25rem; font-size: 0.9rem; }
.request-facts div { display: flex; gap: 0.75rem; }
.request-facts dt { color: var(--muted); min-width: 4.5rem; }
.request-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.request-note { margin: 0; padding: 0.6rem 0.85rem; border-left: 3px solid var(--line-2); background: var(--surface-2);
  border-radius: 0 12px 12px 0; color: var(--ink-2); font-size: 0.9rem; overflow-wrap: anywhere; }
.request .actions form, .owner-list .actions form { margin: 0; }
details.handled-requests { margin-top: 1rem; }
details.handled-requests > summary { cursor: pointer; font-weight: 600; color: var(--accent-ink); }
details.handled-requests[open] > summary { margin-bottom: 0.4rem; }
.story-rules { background: var(--amber-tint); border-radius: 14px; padding: 0.85rem 1rem; margin: 0.75rem 0 1rem;
  font-size: 0.9rem; }
.story-rules p { margin-top: 0; }
.stories-list li { align-items: flex-start; }
.story-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.35rem; }
.story-actions { justify-content: flex-end; flex: none; max-width: 15rem; }
.story-publish { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; justify-content: flex-end; }
@media (max-width: 640px) {
  .stories-list li { flex-direction: column; }
  .story-actions, .story-publish { justify-content: flex-start; max-width: none; }
}

/* --- The patient's page in the iPhone app, by kind of health data (patient_self.html, health_view.py) ---------- */
.health { min-width: 0; }
.hv { min-width: 0; }
.hv[hidden] { display: none; }
.hv > .card { margin-bottom: 0.9rem; }
.hv-label { font-size: 0.78rem; font-weight: 650; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted);
  margin: 1.4rem 0.2rem 0.6rem; }
/* Tiles: two a row, the whole tile is the link. */
.htiles { list-style: none; margin: 0 0 0.9rem; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.7rem; }
.htile { display: flex; flex-direction: column; gap: 0.25rem; height: 100%; padding: 0.95rem 1rem 1rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  text-decoration: none; -webkit-tap-highlight-color: transparent; transition: transform 0.12s ease, box-shadow 0.12s ease; }
.htile:active { transform: scale(0.98); }
@media (prefers-reduced-motion: reduce) { .htile { transition: none; } .htile:active { transform: none; } }
.htile-head { display: flex; align-items: center; gap: 0.55rem; margin-bottom: 0.45rem; min-width: 0; }
.htile-head .tile-icon { width: 32px; height: 32px; border-radius: 10px; }
.htile-head .tile-icon .icon { width: 17px; height: 17px; }
.htile-title { font-weight: 650; font-size: 0.92rem; flex: 1; min-width: 0; line-height: 1.2; }
.hrow-chevron { color: var(--muted); display: inline-flex; flex: none; }
.hrow-chevron .icon { width: 16px; height: 16px; }
.htile-value { font-size: 0.85rem; color: var(--ink-2); line-height: 1.25; }
.htile-value strong { display: block; font: 700 1.6rem/1.1 var(--font-display); color: var(--ink); letter-spacing: -0.01em;
  font-variant-numeric: lining-nums tabular-nums; }
.htile-value.none { color: var(--muted); }
.htile-line { font-size: 0.8rem; color: var(--muted); }
.htile-status { align-self: flex-start; margin-top: auto; position: relative; top: 0.35rem; white-space: normal; }
/* Rows (This week, Your protocol, Devices & apps): one line each, the whole row is the link. */
.hrow-card { display: flex; align-items: center; gap: 0.8rem; color: var(--ink); text-decoration: none; padding: 0.95rem 1.1rem; }
.hrow-card .dots { margin-left: auto; }
.hrow-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.hrow-card .hrow-text { flex: 0 1 auto; }
.hrow-title { font-weight: 650; }
.hrows { list-style: none; padding: 0.25rem 0; }
.hrows li + li { border-top: 1px solid var(--line); }
.hrows a { display: flex; align-items: center; gap: 0.8rem; padding: 0.75rem 1.1rem; color: var(--ink); text-decoration: none; }
.hrows .tile-icon { width: 34px; height: 34px; border-radius: 11px; }
.hrows .tile-icon .icon { width: 18px; height: 18px; }
/* One category's screen: the main screen's header art steps aside. */
body[data-health-view] .health-hero { display: none; }
body[data-health-view] .page.lifted { margin-top: 0; padding-top: 1.1rem; }
.hv-back { display: inline-flex; align-items: center; gap: 0.3rem; font-weight: 600; text-decoration: none; padding: 0.4rem 0.2rem;
  margin-bottom: 0.4rem; min-height: 44px; }
.hv-back span { font-size: 1.5rem; line-height: 1; margin-top: -0.15rem; }
.hv-head { display: flex; align-items: center; gap: 0.8rem; margin: 0 0 1rem; }
.hv-head h1 { font-size: 1.65rem; }
.hv-head h1:focus { outline: none; }
.hv-head p { margin: 0.1rem 0 0; }
.hv-big { margin: 0 0 0.6rem; color: var(--ink-2); }
.hv-big strong { font: 700 2.2rem/1.05 var(--font-display); color: var(--ink); letter-spacing: -0.015em; margin-right: 0.2rem;
  font-variant-numeric: lining-nums tabular-nums; }
.hv-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.1rem 1.2rem; margin: 0 0 0.6rem; }
.hv-stats div { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.45rem 0; border-bottom: 1px solid var(--line); }
.hv-stats dt { color: var(--ink-2); font-size: 0.88rem; }
.hv-stats dd { margin: 0; text-align: right; font-size: 0.9rem; }
.hv .charts { grid-template-columns: minmax(0, 1fr); }
@media (max-width: 420px) { .hv-stats { grid-template-columns: minmax(0, 1fr); } .htile-value strong { font-size: 1.4rem; } }

/* --- Clinic polish (Nov 26): the Friday review, the patient page and the list, for the practitioner -----------------
   Layout and hierarchy only, inside the Calm look: the reason a patient needs you comes right after their name, rows
   are compact, iPads get two-tier rows instead of a table that hides its last columns, and nothing here touches the
   business page (every rule is scoped to a clinic-only class). */

/* Check-ins: one progress strip instead of four tiles. The group counts jump to their group. */
.review-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.5rem; margin: 0 0 1.4rem;
  padding: 0.85rem 1.1rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); }
.rs-progress { flex: 1 1 15rem; min-width: 0; }
.rs-progress p { margin: 0; color: var(--ink-2); font-size: 0.95rem; }
.rs-progress strong { font: 700 1.45rem/1 var(--font-display); color: var(--ink); font-variant-numeric: lining-nums tabular-nums;
  margin-right: 0.1rem; }
.rs-progress .meter.progress { margin-top: 0.55rem; max-width: 24rem; height: 6px; }
.rs-groups { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.45rem; }
.rs-groups a, .rs-groups li > span { display: inline-flex; align-items: center; gap: 0.45rem; min-height: 36px;
  padding: 0.2rem 0.85rem 0.2rem 0.3rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--ink-2); font-size: 0.9rem; text-decoration: none; white-space: nowrap; }
.rs-groups li > span { color: var(--muted); }
.rs-groups strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.rs-groups a:hover { background: var(--surface-2); border-color: var(--line-2); color: var(--ink); }
.rs-groups .tile-icon { width: 28px; height: 28px; border-radius: 50%; }
.rs-groups .tile-icon .icon { width: 15px; height: 15px; }
.triage { scroll-margin-top: 1rem; }

/* Review rows: who, why, the numbers, the check-in. */
table.review .chips { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; }
table.review .chips .chip { margin: 0; }
table.review .more { font-size: 0.78rem; font-weight: 600; color: var(--ink-2); }
/* +N more · Why · n of m targets met, on one line; an open Why takes the next line. */
table.review .row-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 0.1rem 0.75rem; margin-top: 0.3rem; }
table.review .row-meta > * { margin: 0; }
table.review details.why { position: relative; z-index: 2; } /* above the row-wide link */
table.review details.why[open] { order: 9; flex-basis: 100%; }
table.review details.why > summary { padding: 0.15rem 0.45rem; margin-left: -0.45rem; border-radius: 8px; font-size: 0.8rem; }
table.review details.why > summary:hover { background: var(--surface-2); }
table.review details.why > p { max-width: 34rem; }
table.review .focus-line { margin: 0.4rem 0 0; font-size: 0.82rem; }
table.review .focus-line .tag.met { font-size: 0.7rem; padding: 0.05rem 0.45rem; margin: 0 0 0 0.15rem; vertical-align: 1px; }
.targets-met { font-size: 0.78rem; color: var(--muted); }
th .dots-days { display: flex; gap: 3px; margin-top: 0.3rem; }
.dots-days span { width: 18px; text-align: center; font: 600 0.62rem/1 var(--font-ui); color: var(--muted);
  letter-spacing: 0; text-transform: none; }
.dot.missing.nodata { box-shadow: none; border: 1.5px dashed var(--field); }
table.review .approve-btn { max-width: 10.5rem; padding: 0.4rem 0.85rem; border-radius: 14px; line-height: 1.2; }
.peek-btn { display: inline-block; margin-top: 0.2rem; padding: 0.2rem 0; color: var(--accent-ink); font-size: 0.8rem;
  font-weight: 600; text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.peek-btn:hover { text-decoration-thickness: 2px; }
table.review .checkin-when { white-space: normal; }
/* The whole row opens the patient: a hover tint, and a firmer one while pressed. */
table.review tbody tr:has(.rowlink:active) { background: color-mix(in srgb, var(--accent) 9%, transparent); }
a.rowlink:focus-visible { outline: none; }
a.rowlink:focus-visible::after { outline: 3px solid var(--focus); outline-offset: -3px; border-radius: var(--radius); }

/* "Preview": the drafted check-in in a popover (top layer, so a table never clips it). */
.peek { width: min(34rem, calc(100% - 2rem)); max-height: min(85vh, 42rem); margin: auto; padding: 1.3rem 1.4rem 1.2rem;
  overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-lg); }
.peek::backdrop { background: rgba(15, 13, 31, 0.45); }
.peek h3 { margin: 0 0 0.8rem; font-size: 1.05rem; }
.peek-text { margin: 0 0 1rem; padding: 0.85rem 1rem; border-radius: 12px; background: var(--surface-2); font-size: 0.95rem;
  line-height: 1.6; overflow-wrap: anywhere; }
@supports not selector(:popover-open) { .peek-btn, .peek { display: none !important; } }
@media (prefers-reduced-motion: no-preference) {
  .peek:popover-open { transition: opacity 0.16s ease-out, transform 0.16s ease-out; }
  @starting-style { .peek:popover-open { opacity: 0; transform: translateY(10px) scale(0.985); } }
}

/* Desktop: a real table with fixed columns, the same in every group, so numbers line up for scanning down the list
   and nothing reflows while the page loads. This week takes what is left; wide screens give the review more room. */
.page.wide { max-width: 1480px; }
body:not(:has(.auth)):not(.patient):has(main.wide) .hero-inner { max-width: calc(1480px - 4rem); }
@media (min-width: 1201px) {
  table.review { table-layout: fixed; }
  table.review thead th:nth-child(1) { width: 12rem; }
  table.review thead th:nth-child(3) { width: 10.5rem; }
  table.review thead th:nth-child(4) { width: 7.25rem; }
  table.review thead th:nth-child(5) { width: 7rem; }
  table.review thead th:nth-child(6) { width: 6.25rem; }
  table.review thead th:nth-child(7) { width: 7.75rem; }
  table.review thead th:nth-child(8) { width: 10.75rem; }
  table.review td.flags, table.review td.status-cell { min-width: 0; max-width: none; width: auto; }
  table.review .who { min-width: 0; }
  table.review .who > div { min-width: 0; }
  table.review .metric { min-width: 0; }
}
@media (min-width: 1201px) and (max-width: 1380px) {
  table.review th, table.review td { padding-inline: 0.5rem; }
  table.review thead th:nth-child(1) { width: 9.25rem; }
  table.review thead th:nth-child(3) { width: 10rem; }
  table.review .who .avatar { display: none; } /* the initials repeat the name; the name needs the room */
}

/* iPad and small laptops: two-tier rows. Who, why and the check-in on top; the numbers in a row below. */
@media (max-width: 1200px) {
  table.review thead { display: none; }
  table.review, table.review tbody { display: block; }
  table.review tr { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 0.85rem 1.1rem;
    padding: 1rem 1.15rem 1rem 1.3rem; border-bottom: 1px solid var(--line); }
  table.review tbody tr:last-child { border-bottom: 0; }
  table.review td, table.review td:first-child, table.review td:last-child { display: block; padding: 0; border: 0;
    min-width: 0; max-width: none; width: auto; text-align: left; }
  table.review td.who-cell { grid-column: span 3; }
  table.review td.flags { grid-column: span 5; min-width: 0; max-width: none; width: auto; }
  table.review td.status-cell { grid-column: 9 / -1; grid-row: 1; width: auto; }
  /* The numbers always in the second tier: placed by flow, the first would sit in the top tier until the row's
     check-in cell arrived while the page streams in, then move (a layout shift on long reviews). */
  table.review td:not(.who-cell):not(.flags):not(.status-cell) { grid-column: span 2; grid-row: 2; }
  table.review td.empty { grid-column: 1 / -1; padding: 1.5rem 0; }
  table.review .who { min-width: 0; }
  table.review .metric { min-width: 0; }
  table.review td[data-label]:not(.flags)::before { content: attr(data-label); display: block; margin-bottom: 0.2rem;
    font-size: 0.68rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
  table.review td.flags::before { content: none; }
  body:not(.site) table.review tr[class] td:first-child { box-shadow: none; }
  body:not(.site) table.review tr.sev-critical { box-shadow: inset 3px 0 0 color-mix(in srgb, var(--red) 55%, var(--surface)); }
  body:not(.site) table.review tr.sev-warning { box-shadow: inset 3px 0 0 color-mix(in srgb, var(--amber) 55%, var(--surface)); }
  body:not(.site) table.review tr.sev-good { box-shadow: inset 3px 0 0 color-mix(in srgb, var(--green) 55%, var(--surface)); }
  table.review .approve-btn { white-space: normal; text-align: left; }
  body:not(.site):not(.patient) .brand-sub { display: none; }
}

/* Phones: two columns. Who and why first, then the numbers, the check-in last. */
@media (max-width: 700px) {
  table.review tr { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem 1rem; padding: 1rem 1rem 1.05rem 1.15rem; }
  table.review td.who-cell, table.review td.flags { grid-column: 1 / -1; }
  table.review td:not(.who-cell):not(.flags):not(.status-cell) { grid-column: auto; grid-row: auto; }
  table.review td.status-cell { grid-column: auto; grid-row: auto; }
  table.review td.status-cell:has(.approve) { grid-column: 1 / -1; }
  table.review td.status-cell:has(.approve) .approve { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 1rem; }
  table.review td.status-cell .approve-btn { width: auto; flex: 1 1 auto; justify-content: center; }
  .review-summary { padding: 0.8rem 0.9rem; gap: 0.7rem; margin-bottom: 1.1rem; }
  .rs-groups { gap: 0.35rem; }
  .rs-groups a, .rs-groups li > span { font-size: 0.85rem; padding-right: 0.7rem; }
}
@media (max-width: 430px) {
  body:not(.site):not(.patient) .topbar .brand-name { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; }
}

/* Check-ins: the note after approving in place. */
.cell-note { display: flex; gap: 0.35rem; align-items: flex-start; margin: 0.4rem 0 0; font-size: 0.78rem; color: var(--green-ink);
  line-height: 1.35; }
.cell-note .icon { width: 14px; height: 14px; margin-top: 1px; }
.cell-note:focus { outline: none; }
@media (prefers-reduced-motion: no-preference) {
  [data-checkin] .cell-note { animation: cell-in 0.22s ease-out both; }
  @keyframes cell-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
}
.approve-btn[disabled] { opacity: 0.6; cursor: progress; }

/* Patient page: where they stand, at a glance in the header. */
body:not(.site) .hero-stat.group-attention { background: var(--amber-tint); color: var(--ink); font-weight: 600;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--amber) 45%, transparent); }
body:not(.site) .hero-stat.group-attention .icon { color: var(--amber-ink); }
body:not(.site) .hero-stat.group-ontrack { background: var(--green-tint); color: var(--green-ink); font-weight: 600; box-shadow: none; }
body:not(.site) .hero-stat.group-ontrack .icon { color: var(--green-ink); }

/* This week: day letters under the dots, the inputs behind each flag, the week before beside each target. */
.thisweek .dots:has(+ .dots-days) { margin-bottom: 0.25rem; }
.thisweek .dots-days { display: flex; gap: 3px; margin: 0 0 0.75rem; }
.thisweek .dots-days span { width: 24px; font-size: 0.68rem; }
.flag-whys { list-style: none; margin: 0.25rem 0 0.7rem; padding: 0; display: grid; gap: 0.5rem; }
.flag-whys li { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.65rem; }
.flag-whys .chip { margin: 0; flex: none; }
.flag-why { min-width: 0; font-size: 0.86rem; color: var(--ink-2); line-height: 1.4; }
table.scorecard.vs-last td.was { color: var(--ink-2); font-size: 0.88rem; }
.was-met { color: var(--muted); }
@media (max-width: 700px) {
  .flag-whys li { display: block; }
  .flag-whys .flag-why { display: block; margin-top: 0.2rem; }
  /* Phones: the target and its result on one line, this week and the week before underneath. */
  table.cards.vs-last tr { grid-template-columns: minmax(0, 1fr) auto; gap: 0.25rem 0.75rem; padding: 0.75rem 0.9rem; }
  table.cards.vs-last td { padding: 0; }
  table.cards.vs-last td:first-child { grid-column: 1; grid-row: 1; }
  table.cards.vs-last td:nth-child(3) { grid-column: 2; grid-row: 1; align-self: start; padding-right: 0; }
  table.cards.vs-last td:nth-child(2), table.cards.vs-last td:nth-child(4) { grid-column: 1 / -1; }
  table.cards.vs-last td:nth-child(3)[data-label]::before { display: none; }
  table.cards.vs-last td:nth-child(2)[data-label]::before, table.cards.vs-last td:nth-child(4)[data-label]::before {
    display: inline; content: attr(data-label) ": "; text-transform: none; letter-spacing: 0; font-size: inherit;
    font-weight: 400; margin: 0; }
}

/* The side column: the message first, then the protocol and private notes (what to keep in mind while writing it),
   marked days, devices. Sticky, but never hiding its lower cards (app.js sets --side-top). */
body:not(.site) .detail-side { top: var(--side-top, 1rem); }
.composer h2 .status { margin-left: auto; font: 600 0.78rem var(--font-ui); letter-spacing: 0; }
.composer textarea { min-height: 13rem; max-height: min(62vh, 38rem); }
@supports (field-sizing: content) { .composer textarea { field-sizing: content; } } /* grows to fit the whole draft */
.composer-count { margin-top: 0.25rem; }
.composer .composer-actions { gap: 0.45rem; }
/* The one action that matters spans the panel; saving or skipping sit underneath. */
.composer .composer-actions .btn.primary { flex: 1 1 100%; padding-block: 0.7rem; }
.composer .composer-actions .btn.ghost { margin-left: auto; }
.detail-side .protocol .checklist { margin-top: 0; }
.detail-side .protocol .notes-head { margin-top: 1.25rem; }
.notes-text { margin: 0; color: var(--ink-2); }
.markfold { margin-top: 0.65rem; }
.markfold > summary { list-style: none; }
.markfold > summary::-webkit-details-marker { display: none; }
.markfold[open] > summary { margin-bottom: 0.75rem; }
@media (max-width: 700px) {
  /* Phones: previous / next on one row, the brief and the targets side by side, so This week starts sooner. */
  body:not(.site):not(.patient) .hero-person + .hero-stats { margin-top: 0.8rem; }
  .hero-actions:has(.prevnext) { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; }
  .hero-actions:has(.prevnext) > :is(.prevnext, form, .snooze-menu) { grid-column: 1 / -1; }
  .hero-actions:has(.prevnext) > .btn, .hero-actions:has(.prevnext) .snooze-menu > summary { width: 100%; min-width: 0;
    padding-inline: 0.7rem; }
  .detail-side > .protocol { order: 3; }
  .detail-main > details.card, .detail-side > details.card { width: 100%; } /* a folded card stretches like the rest */
}

/* Patients: fixed columns, so the list doesn't reflow while it loads; the name opens the patient. */
@media (min-width: 701px) {
  table.patient-list { table-layout: fixed; }
  table.patient-list th:nth-child(1) { width: 31%; }
  table.patient-list th:nth-child(2) { width: 17%; }
  table.patient-list th:nth-child(3) { width: 22%; }
  table.patient-list th:nth-child(5) { width: 9.5rem; }
  table.patient-list .who { min-width: 0; }
  table.patient-list .who > div { min-width: 0; }
  table.patient-list .who-name { white-space: normal; }
}
table.patient-list a.who-name:hover { text-decoration: underline; }
/* The brief's header lines up with the brief itself. */
body:not(:has(.auth)):not(.patient):has(main.brief-page) .hero-inner { max-width: calc(1000px - 4rem); }
/* The targets table keeps its columns while the page loads (no reflow as rows arrive). */
@media (min-width: 701px) {
  table.scorecard.vs-last { table-layout: fixed; }
  table.scorecard.vs-last th:nth-child(1) { width: 32%; }
  table.scorecard.vs-last th:nth-child(2) { width: 25%; }
  table.scorecard.vs-last th:nth-child(3) { width: 9.5rem; }
}

/* View-only access (context_processors.view_only, the same check tenancy.clinic_required refuses changes with): the
   patient form's fields shown as they're set, and the drafted check-in as text. */
fieldset.viewonly-fields { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 1rem; }
fieldset.viewonly-fields :disabled { color: var(--ink); -webkit-text-fill-color: var(--ink); opacity: 1;
  background-color: var(--surface-2); cursor: default; }
.draft-readonly { padding: 0.85rem 1rem; border-left: 3px solid var(--line-2); border-radius: 0 12px 12px 0;
  background: var(--surface-2); color: var(--ink); line-height: 1.6; overflow-wrap: anywhere; margin-bottom: 0.6rem; }
@media (max-width: 700px) {
  .hero-actions:has(.prevnext) > .btn:only-of-type { grid-column: 1 / -1; }
}

/* Check-ins is one table (dashboard.html): a row group per triage group, each opened by a header row. On desktop the
   column header stays on screen while you scroll a long review; on iPad and phones (cards, each number labelled) the
   group's header row stays instead, like a section header. Jumping to a group, or tabbing through rows, never ends
   under it: the page keeps that much room at the top (scroll-padding) plus a little (scroll-margin). */
.tablewrap.review-box { overflow: visible; overflow: clip; } /* no sideways scroll needed, and clip lets sticky work */
table.review tr.group-row th { padding: 1rem 1.15rem 0.7rem; background: var(--surface); color: var(--ink);
  font: 400 1rem/1.3 var(--font-ui); text-transform: none; letter-spacing: 0; white-space: normal; vertical-align: middle;
  border-bottom: 1px solid var(--line); }
table.review tbody + tbody tr.group-row th { padding-top: 1.5rem; border-top: 1px solid var(--line-2); }
table.review tbody tr.group-row:hover { background: none; }
table.review .group-head { display: inline-flex; align-items: center; gap: 0.6rem; margin: 0; color: var(--ink);
  font: 650 1.05rem/1.3 var(--font-display); letter-spacing: -0.012em; }
table.review .group-head .muted { font: 400 0.82rem var(--font-ui); letter-spacing: 0; }
table.review tbody.triage { scroll-margin-top: 0.5rem; }
@media (min-width: 1201px) {
  table.review thead th { position: sticky; top: 0; z-index: 4; box-shadow: inset 0 -1px 0 var(--line); }
  html:has(table.review thead) { scroll-padding-top: 4.25rem; }
}
@media (max-width: 1200px) {
  table.review tr.group-row { display: block; position: sticky; top: 0; z-index: 4; padding: 0; border-bottom: 0;
    box-shadow: inset 0 -1px 0 var(--line); background: var(--surface); }
  table.review tr.group-row th { display: block; padding: 0.8rem 1.15rem 0.7rem; }
  table.review tbody + tbody tr.group-row th { padding-top: 0.9rem; }
  html:has(table.review thead) { scroll-padding-top: 3.5rem; }
}
/* iPad and smaller: the group counts always on their own line under the progress, so the strip never re-wraps
   (and shifts the page) when the web font arrives. */
@media (max-width: 1200px) { .rs-progress { flex-basis: 100%; } }

/* A practitioner's device suggestion, as the patient sees it (_device_suggestions.html): a highlighted note at the
   top of their page, hard to miss, with what it is, what it costs and one clear button. */
.device-alert { display: flex; gap: 0.85rem; align-items: flex-start; margin: 0 0 1rem; padding: 1rem 1.1rem 1.05rem;
  border-radius: 16px; background: linear-gradient(135deg, color-mix(in srgb, var(--gold) 22%, var(--surface)),
  var(--surface) 75%); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--amber) 55%, transparent),
  0 2px 10px rgba(25, 20, 48, 0.08); }
.device-alert-icon { flex: none; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  background: var(--gold); color: #2a1f05; }
.device-alert-icon .icon { width: 22px; height: 22px; }
.device-alert-body { min-width: 0; }
.device-alert-body > p { margin: 0 0 0.45rem; font-size: 0.92rem; color: var(--ink); line-height: 1.45; }
.device-alert-eyebrow { font: 700 0.72rem/1.2 var(--font-ui) !important; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--amber-ink) !important; margin-bottom: 0.2rem !important; }
.device-alert-title { margin: 0 0 0.35rem; font: 700 1.12rem/1.25 var(--font-display); color: var(--ink); }
.device-alert-meta { font-weight: 600; }
.device-alert-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; margin-top: 0.6rem !important; }
.device-alert-link { font-weight: 600; font-size: 0.88rem; }
.device-alert-fine { margin: 0.55rem 0 0 !important; font-size: 0.78rem !important; color: var(--muted) !important; }
@media (max-width: 480px) { .device-alert { padding: 0.9rem 0.9rem 0.95rem; gap: 0.7rem; } .device-alert-icon { width: 34px; height: 34px; } }

/* --- "Your health" in the app: the patient's main screen (patient_self.html, patient_dashboard.py, your-health.js) ---
   Like a phone's health summary, in Sonoran dusk: sand page, warm-white cards, terracotta actions, one hue per kind of
   data (plum for Heart), the system font. Calm: the one status is a green "At target"; nothing is coloured as a
   warning. Every text/background pair keeps WCAG AA in light and dark. Follows the phone's light/dark setting. */
:root {
  --pd-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", "Segoe UI", Roboto, sans-serif;
  --pd-act: #b0492b; --pd-act-i: #a3432a; --pd-act-t: #f8e4da;
  --pd-food: #3f8a5c; --pd-food-i: #2d6a45; --pd-food-t: #e3efe4;
  --pd-sleep: #5a4aa6; --pd-sleep-i: #4d3f8f; --pd-sleep-t: #ebe7f5;
  --pd-heart: #a1477a; --pd-heart-i: #8a3564; --pd-heart-t: #f6e3ee;
  --pd-body: #b86e00; --pd-body-i: #8a5300; --pd-body-t: #fbeed3;
  --pd-gbp: #1a8f97; --pd-gbp-i: #11706f; --pd-gbp-t: #dff0ee;
  --pd-good: #2d6a45; --pd-good-t: #e3efe4;
  --pd-line2: #d6c8b3; --pd-grid: #ebe2d4; --pd-tgt: #6b6070; --pd-segon: #fffdf9; --pd-sheet: var(--page);
  --pd-toast: #1d1838; --pd-edge: transparent; --pd-unread: var(--accent);
  --pd-shadow: 0 1px 2px rgba(70, 40, 20, 0.05), 0 6px 18px rgba(70, 40, 20, 0.06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --pd-act: #ee9a74; --pd-act-i: #f3a582; --pd-act-t: rgba(238, 154, 116, 0.16);
    --pd-food: #5fbf80; --pd-food-i: #8fd3a4; --pd-food-t: rgba(95, 191, 128, 0.16);
    --pd-sleep: #bcb0f2; --pd-sleep-i: #c9bff5; --pd-sleep-t: rgba(169, 156, 240, 0.16);
    --pd-heart: #e9a3c9; --pd-heart-i: #efb3d4; --pd-heart-t: rgba(233, 163, 201, 0.15);
    --pd-body: #f2b84b; --pd-body-i: #f2c26b; --pd-body-t: rgba(242, 184, 75, 0.15);
    --pd-gbp: #3fbab5; --pd-gbp-i: #72d4cf; --pd-gbp-t: rgba(63, 186, 181, 0.16);
    --pd-good: #8fd3a4; --pd-good-t: rgba(95, 191, 128, 0.16);
    --pd-line2: #4a4170; --pd-grid: #2b2547; --pd-tgt: #b3a9c4; --pd-segon: #423a6e; --pd-sheet: #18142e;
    --pd-toast: #2d2948; --pd-edge: #2e2850;
    --pd-shadow: none;
  }
}
.pd-c-act { --c: var(--pd-act); --ci: var(--pd-act-i); --ct: var(--pd-act-t); }
.pd-c-food { --c: var(--pd-food); --ci: var(--pd-food-i); --ct: var(--pd-food-t); }
.pd-c-sleep { --c: var(--pd-sleep); --ci: var(--pd-sleep-i); --ct: var(--pd-sleep-t); }
.pd-c-heart { --c: var(--pd-heart); --ci: var(--pd-heart-i); --ct: var(--pd-heart-t); }
.pd-c-body { --c: var(--pd-body); --ci: var(--pd-body-i); --ct: var(--pd-body-t); }
.pd-c-gbp { --c: var(--pd-gbp); --ci: var(--pd-gbp-i); --ct: var(--pd-gbp-t); }

main.pd-page { padding: 0 16px calc(40px + env(safe-area-inset-bottom, 0px)); max-width: 640px; }
.pd-app { font: 16px/1.45 var(--pd-font); -webkit-font-smoothing: antialiased; }
.pd-app h1, .pd-app h2, .pd-app h3, .pd-sheet h2, .pd-sheet h3 { font-family: var(--pd-font); }
:where(.hv-hub, .pd-detail, .pd-arrbar, .pd-toast, .pd-devnote) button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer;
  text-align: inherit; -webkit-tap-highlight-color: transparent; }
.pd-app :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.pd-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.pd-i { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:is(.hv-hub, .pd-detail, .pd-sheet) .card { background: var(--surface); border: 1px solid var(--pd-edge); box-shadow: var(--pd-shadow);
  border-radius: 18px; padding: 0; margin: 0; }
.pd-tic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--ct);
  color: var(--ci); flex: none; }
.pd-lnk { color: var(--accent-ink); font-weight: 600; font-size: 15px; min-height: 36px; padding: 0 2px;
  text-decoration: none; display: inline-flex; align-items: center; }
.pd-lnk:disabled { opacity: 0.4; cursor: default; }
.btn-pd { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 14px;
  padding: 0 16px; font-weight: 600; font-size: 16px; white-space: nowrap; text-decoration: none; }
.btn-pd.pri { background: var(--accent); color: var(--on-accent); }
.btn-pd.sec { background: var(--accent-tint); color: var(--accent-ink); }
.btn-pd.sm { min-height: 36px; padding: 0 14px; font-size: 15px; border-radius: 999px; }
.btn-pd:disabled { opacity: 0.4; cursor: default; }

/* The title, and the bell right under the app's own bar. */
.pd-ttl { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 2px 2px; }
.pd-ttl h1 { margin: 0; font-size: 34px; line-height: 41px; font-weight: 700; letter-spacing: -0.01em; color: var(--ink); }
.pd-ttl p { margin: 0; color: var(--muted); font-size: 15px; }
.pd-bell { position: relative; width: 44px; height: 44px; margin: 0 -6px 0 0; display: grid; place-items: center;
  border-radius: 12px; color: var(--ink); flex: none; }
.pd-bell:active { background: var(--surface-2); }
/* In an app build with its own bell (in the app's dusk bar: mobile/src/pageBridge.ts), the page's steps aside. */
html.interlude-native-bell .pd-bell { display: none; }
.pd-bell .pd-i { width: 24px; height: 24px; transform-origin: 50% 12%; }
.pd-badge { position: absolute; top: 4px; right: 3px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px;
  background: #ffd98f; color: #1d1838; font-weight: 700; font-size: 13px; line-height: 20px; text-align: center;
  box-shadow: 0 0 0 2px var(--page); }
@media (prefers-reduced-motion: no-preference) {
  .pd-bell.is-new .pd-i { animation: pd-ring 1.3s ease-in-out 0.9s 1; }
  @keyframes pd-ring { 0%, 100% { transform: rotate(0); } 12% { transform: rotate(14deg); } 26% { transform: rotate(-12deg); }
    40% { transform: rotate(8deg); } 54% { transform: rotate(-5deg); } 68% { transform: rotate(2deg); } }
}

/* The view picker and the latest check-in. */
.pd-picker { width: 100%; margin-top: 12px !important; display: flex; align-items: center; gap: 12px; padding: 10px 12px !important;
  border-radius: 16px !important; color: var(--ink); text-align: left; }
.pd-picker > .pd-i { color: var(--muted); }
.pd-pk { flex: 1; display: grid; line-height: 1.3; min-width: 0; }
.pd-pk small { font-size: 13px; color: var(--muted); }
.pd-pk b { font-size: 17px; font-weight: 600; }
.pd-pk em { font-style: normal; font-size: 13px; color: var(--ink-2); }
.pd-ci { margin-top: 12px !important; padding: 14px 16px 12px !important; transition: box-shadow 0.3s; }
.pd-ci.is-glow { box-shadow: 0 0 0 3px var(--accent); }
.pd-ci-h { display: flex; gap: 10px; align-items: center; }
.pd-ci-h > span:last-child { display: grid; line-height: 1.3; min-width: 0; }
.pd-ci-h b { font-size: 16px; }
.pd-ci-h small { font-size: 13px; color: var(--muted); }
.pd-av { width: 36px; height: 36px; border-radius: 50%; background: var(--pd-sleep-t); color: var(--pd-sleep-i);
  display: grid; place-items: center; font-weight: 700; font-size: 14px; flex: none; }
.pd-ci-m { margin: 10px 0 0; font-size: 16px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; }
.pd-ci-m p { margin: 0 0 0.5em; display: inline; }
.pd-ci.is-open .pd-ci-m { display: block; }
.pd-ci.is-open .pd-ci-m p { display: block; }
.pd-focus { margin: 6px 0 0; display: flex; gap: 8px; align-items: flex-start; background: var(--surface-2); border-radius: 12px;
  padding: 9px 12px; font-size: 15px; line-height: 1.4; }
.pd-focus .pd-i { color: var(--accent); margin-top: 1px; }

/* Section heads, tiles, kinds. */
.pd-shead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 26px 2px 10px; }
.pd-shead h2 { margin: 0; font-size: 22px; line-height: 28px; font-weight: 700; letter-spacing: -0.01em; display: block; }
.pd-shead p { margin: 1px 0 0; font-size: 14px; color: var(--muted); }
.pd-keys { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; position: relative; }
.pd-tgrid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px;
  position: relative; }
.pd-tgrid > .pd-tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
.pd-grp h3 { display: flex; align-items: center; gap: 8px; margin: 22px 2px 10px; font-size: 18px; font-weight: 700; color: var(--ink); }
.pd-grp h3 .pd-i { color: var(--ci); }
.pd-tile { position: relative; min-width: 0; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  --wg: 0.45deg; }
.pd-tile-in { position: relative; display: block; height: 100%; color: var(--ink); text-decoration: none;
  -webkit-touch-callout: none; transition: transform 0.2s; }
.pd-tile a.pd-tile-in:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pd-key .pd-tile-in { padding: 12px 14px 12px 16px !important; }
.pd-th { display: flex; align-items: center; gap: 6px; color: var(--ci); font-weight: 600; min-width: 0; }
.pd-key .pd-th { font-size: 16px; }
.pd-nm { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pd-th .pd-when { color: var(--muted); font-weight: 400; font-size: 14px; white-space: nowrap; }
.pd-th > .pd-i:last-child { color: var(--muted); width: 14px; height: 14px; }
.pd-tb { display: grid; grid-template-columns: minmax(0, 1fr) 44%; gap: 12px; align-items: end; margin-top: 8px; }
.pd-val { white-space: nowrap; display: block; color: var(--ink); }
.pd-val b { font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.pd-val small { font-weight: 600; color: var(--muted); margin: 0 3px; }
.pd-key .pd-val b { font-size: 32px; line-height: 1.05; }
.pd-key .pd-val small { font-size: 16px; }
.pd-sp { position: relative; display: block; height: 56px; }
.pd-sp svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.pd-tr { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: 15px; color: var(--ink-2); }
.pd-tr:empty { display: none; }
.pd-ok { display: inline-flex; align-items: center; gap: 4px; background: var(--pd-good-t); color: var(--pd-good);
  border-radius: 999px; padding: 2px 8px 2px 6px; font-size: 13px; font-weight: 600; }
.pd-ok .pd-i { width: 13px; height: 13px; stroke-width: 2.6; }
.pd-empty { margin: 8px 0 0; font-size: 15px; color: var(--ink-2); }
.pd-empty b { display: block; font-size: 20px; color: var(--ink); margin-bottom: 2px; }
.pd-small { --wg: 0.9deg; }
.pd-small .pd-tile-in { padding: 11px 12px 10px !important; display: flex; flex-direction: column; }
.pd-small .pd-th { font-size: 14px; gap: 5px; }
.pd-small .pd-th .pd-i { width: 15px; height: 15px; }
.pd-small .pd-val { margin-top: 6px; }
.pd-small .pd-val b { font-size: 22px; line-height: 1.1; }
.pd-small .pd-val small { font-size: 13px; }
.pd-small .pd-when { font-size: 13px; color: var(--muted); margin: 1px 0 8px; display: block; }
.pd-small .pd-sp { height: 28px; margin-top: auto; }
.pd-nothing { padding: 16px !important; color: var(--ink-2); }

/* Charts (your-health.js draws them; the colours follow the tile's kind). */
.pd-app svg .bar { fill: var(--c); }
.pd-app svg .dim { opacity: 0.38; }
.pd-app svg .stub { fill: var(--pd-line2); }
.pd-app svg .cap { stroke: var(--c); stroke-linecap: round; }
.pd-app svg .area { fill: var(--c); opacity: 0.12; }
.pd-app svg .ln { fill: none; stroke: var(--c); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.pd-app svg .dotf { fill: var(--c); stroke: var(--dotbg, var(--surface)); stroke-width: 2; }
.pd-app svg .doto { fill: var(--dotbg, var(--surface)); stroke: var(--c); stroke-width: 1.6; }
.pd-app svg .tgt { stroke: var(--pd-tgt); stroke-width: 1.5; stroke-dasharray: 4 4; }
.pd-app svg .band { fill: var(--c); opacity: 0.1; }
.pd-app svg .gl { stroke: var(--pd-grid); stroke-width: 1; }
.pd-app svg .rule { stroke: var(--muted); stroke-width: 1; }
.pd-app svg .ax { font: 13px var(--pd-font); fill: var(--muted); paint-order: stroke; stroke: var(--page); stroke-width: 3px; }

/* The rows under the data, and the footnote. */
.pd-rows { list-style: none; margin: 26px 0 0 !important; padding: 0; overflow: hidden; }
.pd-rows li + li { border-top: 1px solid var(--line); }
.pd-rows a { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 62px; color: var(--ink);
  text-decoration: none; }
.pd-rows .pd-tic { width: 34px; height: 34px; border-radius: 10px; }
.pd-rt { flex: 1; display: grid; line-height: 1.3; min-width: 0; }
.pd-rt b { font-weight: 600; font-size: 16px; }
.pd-rt small { font-size: 13px; color: var(--muted); }
.pd-rows a > .pd-i:last-child { color: var(--muted); }
.pd-foot { margin: 16px 4px 0; font-size: 13px; color: var(--muted); line-height: 1.45; }
.pd-devnote { display: flex; gap: 8px; align-items: flex-start; margin: 0 0 0.8rem; padding: 0.7rem 0.85rem; border-radius: 12px;
  background: var(--surface-2); font-size: 0.92rem; }
.pd-devnote .pd-i { color: var(--accent-ink); margin-top: 2px; }
.pd-devnote .pd-lnk { min-height: 0; font-size: inherit; }

/* Arrange: long-press (or Arrange), gentle wiggle, drag; − and + change the key numbers, arrows move without dragging. */
.pd-arrbar { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; gap: 6px; margin: 0 -16px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px 16px; background: var(--page); border-bottom: 1px solid var(--line); }
.pd-arrbar p { flex: 1; margin: 0; font-size: 14px; color: var(--ink-2); line-height: 1.3; }
.pd-pin { position: absolute; top: -9px; left: -9px; z-index: 2; width: 26px; height: 26px; border-radius: 50%; display: none;
  place-items: center; background: var(--ink) !important; color: var(--page) !important; border: 2px solid var(--page) !important; }
.pd-pin::after { content: ""; position: absolute; inset: -9px; }
.pd-pin .pd-i { width: 14px; height: 14px; stroke-width: 3; }
.pd-pin-plus { background: var(--accent) !important; color: var(--on-accent) !important; }
.pd-pin-on { background: var(--pd-good) !important; color: var(--page) !important; }
.pd-move { position: absolute; right: 6px; bottom: 6px; z-index: 2; display: none; gap: 4px; }
.pd-move button { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2) !important;
  color: var(--ink) !important; }
.pd-move .pd-i { width: 16px; height: 16px; }
.pd-small .pd-move { right: 4px; top: 4px; bottom: auto; }
.pd-small .pd-move button { width: 28px; height: 28px; }
.is-arranging .pd-pin { display: grid; }
.is-arranging .pd-move { display: flex; }
.is-arranging .pd-tile { touch-action: pan-y; cursor: grab; }
.is-arranging .pd-tile-in { cursor: grab; }
.is-arranging .pd-tile .pd-lnk, .is-arranging [data-arrange] { visibility: hidden; }
.is-arranging .pd-th > .pd-i:last-child { visibility: hidden; }
.pd-tile.is-lift { z-index: 20; }
.pd-tile.is-lift .pd-tile-in { animation: none !important; transform: scale(1.04); box-shadow: 0 14px 30px rgba(20, 12, 40, 0.25);
  cursor: grabbing; }
.pd-tile.is-pressing .pd-tile-in { transform: scale(0.97); transition: transform 0.45s ease; }
@media (prefers-reduced-motion: no-preference) {
  .is-arranging .pd-tile-in { animation: pd-wig 0.3s ease-in-out infinite alternate; }
  .is-arranging .pd-tile:nth-child(2n) .pd-tile-in { animation-delay: -0.15s; animation-duration: 0.33s; }
  @keyframes pd-wig { from { transform: rotate(calc(-1 * var(--wg))); } to { transform: rotate(var(--wg)); } }
  .pd-tile.is-in { animation: pd-rise 0.42s cubic-bezier(0.2, 0.8, 0.2, 1) backwards; animation-delay: calc(var(--n, 0) * 45ms); }
  @keyframes pd-rise { from { opacity: 0; transform: translateY(14px); } }
}
@media (prefers-reduced-motion: reduce) {
  .is-arranging .pd-tile-in { outline: 2px dashed var(--pd-line2); outline-offset: 3px; }
  .pd-tile-in, .pd-ci, .pd-sheet, .pd-toast { transition: none !important; }
}

/* A number's own screen. */
.pd-detail { --dotbg: var(--page); padding-top: 4px; }
.pd-back { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; color: var(--accent-ink); font-size: 17px;
  margin: 0 0 0 -6px; padding: 0; text-decoration: none; font-weight: 400; }
.pd-back .pd-i { width: 22px; height: 22px; }
.pd-dh { display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; }
.pd-dh h1 { margin: 0; font-size: 28px; line-height: 1.1; letter-spacing: -0.01em; color: var(--ink); }
.pd-dh h1:focus { outline: none; }
.pd-dh p { margin: 2px 0 0; color: var(--ci); font-weight: 600; font-size: 14px; }
.pd-dh .pd-tic .pd-i { width: 22px; height: 22px; }
.pd-seg { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); background: var(--surface-2); border-radius: 10px; padding: 2px; }
.pd-seg button { min-height: 34px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--ink-2); text-align: center; }
.pd-seg button[aria-checked="true"] { background: var(--pd-segon); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.14); }
.pd-seg button:disabled { opacity: 0.35; cursor: default; }
.pd-dhead { margin-top: 16px; min-height: 88px; }
.pd-dk { font-size: 14px; font-weight: 600; color: var(--muted); }
.pd-dv b { font-size: 36px; line-height: 1.15; }
.pd-dv small { font-size: 18px; }
.pd-dv .pd-tx { font-size: 30px; }
.pd-dw { font-size: 15px; color: var(--muted); }
.pd-dfig { position: relative; height: 236px; margin-top: 6px; touch-action: pan-y; cursor: crosshair; }
.pd-dfig svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.pd-tgtrow { display: flex; align-items: center; gap: 8px; margin: 12px 0 0; font-size: 14px; color: var(--ink-2); }
.pd-dash { width: 22px; border-top: 2px dashed var(--pd-tgt); flex: none; }
.pd-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
.pd-stats > div { padding: 10px 12px !important; display: grid; border-radius: 14px; }
.pd-stats span { font-size: 13px; color: var(--muted); }
.pd-stats b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pd-pane { margin-top: 14px !important; padding: 14px 16px !important; }
.pd-pane h3 { margin: 0 0 4px; font-size: 17px; color: var(--ink); }
.pd-pane p { margin: 4px 0 0; font-size: 15px; line-height: 1.45; color: var(--ink-2); }
.pd-meals ul { list-style: none; margin: 0; padding: 0; }
.pd-meals li { display: grid; grid-template-columns: 4.6rem minmax(0, 1fr) auto; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line);
  align-items: baseline; }
.pd-meals li:first-child { border-top: 0; }
.pd-mt { font-size: 13px; color: var(--muted); white-space: nowrap; }
.pd-mn { font-size: 15px; overflow-wrap: anywhere; }
.pd-meals li b { font-size: 15px; white-space: nowrap; }
.pd-src { font-size: 13px !important; color: var(--muted) !important; }
.pd-morecard { margin-top: 14px !important; display: flex !important; align-items: center; gap: 12px; padding: 14px 16px !important; }
.pd-morecard > .pd-i { color: var(--muted); }

/* Sheets: notices and the view picker (native <dialog>s, so focus stays inside and Escape closes them). */
.pd-sheet { position: fixed; inset: auto 0 0 0; margin: 0 auto; width: 100%; max-width: 640px; max-height: calc(100% - 52px);
  padding: 0; border: 0; border-radius: 18px 18px 0 0; background: var(--pd-sheet); color: var(--ink); font: 16px/1.45 var(--pd-font);
  box-shadow: 0 -8px 30px rgba(14, 10, 30, 0.18); flex-direction: column; overflow: hidden; }
.pd-sheet[open] { display: flex; }
.pd-sheet::backdrop { background: rgba(14, 10, 30, 0.42); }
@media (prefers-reduced-motion: no-preference) {
  .pd-sheet[open] { animation: pd-up 0.34s cubic-bezier(0.2, 0.8, 0.2, 1); }
  @keyframes pd-up { from { transform: translateY(100%); } }
}
:where(.pd-sheet) button { font: inherit; color: inherit; background: none; border: 0; padding: 0; margin: 0; cursor: pointer; text-align: inherit; }
.pd-sheet :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }
.pd-grab { width: 38px; height: 5px; border-radius: 3px; background: var(--pd-line2); margin: 8px auto 2px; flex: none; }
.pd-sh-h { display: flex; align-items: center; gap: 8px; padding: 4px 16px 6px; flex: none; }
.pd-sh-h h2 { flex: 1; margin: 0; font-size: 22px; letter-spacing: -0.01em; color: var(--ink); display: block; }
.pd-sh-p { margin: 0 16px 10px; color: var(--ink-2); font-size: 15px; line-height: 1.4; flex: none; }
.pd-sh-body { overflow-y: auto; flex: 1; min-height: 0; padding: 4px 16px calc(24px + env(safe-area-inset-bottom, 0px));
  overscroll-behavior: contain; }
.pd-sh-f { flex: none; display: grid; gap: 8px; padding: 10px 16px calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--line); background: var(--pd-sheet); }
.pd-nlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.pd-nt-h { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px !important; min-height: 64px; }
.pd-nt-h .pd-tic { width: 38px; height: 38px; }
.pd-nt-t { flex: 1; display: grid; line-height: 1.3; min-width: 0; }
.pd-nt-t b { font-weight: 500; font-size: 16px; }
.pd-nt.is-unread .pd-nt-t b { font-weight: 700; }
.pd-nt-t small { font-size: 13px; color: var(--muted); }
.pd-udot { width: 10px; height: 10px; border-radius: 50%; background: var(--pd-unread); flex: none; visibility: hidden; }
.pd-nt.is-unread .pd-udot { visibility: visible; }
.pd-nt-h > .pd-i { color: var(--muted); transition: transform 0.2s; }
.pd-nt.is-open .pd-nt-h > .pd-i { transform: rotate(180deg); }
.pd-nt-b { padding: 0 14px 14px; }
.pd-nt-b dl { margin: 8px 0 0; display: grid; gap: 2px; }
.pd-nt-b dt { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.pd-nt-b dd { margin: 0 0 8px; font-size: 15px; line-height: 1.45; }
.pd-pv { margin: 0; font-size: 15px; line-height: 1.45; color: var(--ink-2); }
.pd-pv p { margin: 0 0 0.5em; }
.pd-nt-a { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.pd-fine { font-size: 13px; color: var(--muted); margin: 10px 0 0; }
.pd-vlist { list-style: none; margin: 0; padding: 0; overflow: hidden; border-radius: 16px; }
.pd-vlist li + li { border-top: 1px solid var(--line); }
.pd-vrow { width: 100%; display: flex; align-items: center; gap: 12px; padding: 9px 12px !important; min-height: 58px; }
.pd-vrow .pd-tic { width: 34px; height: 34px; border-radius: 10px; }
.pd-vrow[aria-checked="true"] { background: color-mix(in srgb, var(--accent-tint) 70%, transparent) !important; }
.pd-vt { flex: 1; display: grid; line-height: 1.3; min-width: 0; }
.pd-vt b { font-size: 16px; font-weight: 600; }
.pd-vt small { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pd-tg { font-style: normal; font-size: 13px; font-weight: 600; border-radius: 999px; padding: 2px 8px; white-space: nowrap; }
.pd-tg-doc { background: var(--pd-sleep-t); color: var(--pd-sleep-i); }
.pd-tg-me { background: var(--pd-good-t); color: var(--pd-good); }
.pd-ck { width: 20px; color: var(--accent-ink); display: grid; place-items: center; flex: none; visibility: hidden; }
.pd-vrow[aria-checked="true"] .pd-ck { visibility: visible; }

/* The message that follows a choice ("Showing Sleep & stress for now." · Make default). */
.pd-toast { position: fixed; left: 12px; right: 12px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 40;
  max-width: 616px; margin: 0 auto; display: flex; align-items: center; gap: 10px; background: var(--pd-toast); color: #fff;
  border-radius: 14px; padding: 10px 10px 10px 14px; font: 15px/1.35 var(--pd-font); box-shadow: 0 8px 24px rgba(14, 10, 30, 0.3);
  opacity: 0; transform: translateY(12px); pointer-events: none; transition: opacity 0.22s, transform 0.22s; }
.pd-toast.is-on { opacity: 1; transform: none; pointer-events: auto; }
.pd-toast span { flex: 1; }
.pd-toast button { color: #ffd98f; font-weight: 700; min-height: 36px; padding: 0 8px; white-space: nowrap; }
body:has(.pd-app) { background: var(--page); }
body:has(.pd-app) .sitefoot { padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px)); }
