/* ==========================================================================
   Metabolixia design system — RC2
   Light-first. Dark is designed, not inverted: surfaces lift with lightness
   instead of shadow, the accent shifts to hold contrast, and every component
   below is specified for both themes.
   Nothing outside :root and [data-theme] should contain a raw colour value.
   ========================================================================== */

:root {
	/* ---- colour: light (default palette = "clinic") ----
	   The electric indigo (#4b2fd9) and near-black navy canvas (#191534) read
	   cold and heavy across a whole page. This palette keeps one calm primary,
	   warms the neutrals off pure grey, and replaces the navy canvas with a deep
	   pine that sits with the greens rather than fighting them.
	   Alternative palettes are defined below under [data-palette]. ---- */
	--mx-color-primary: #14746a;
	--mx-color-primary-press: #0f5c54;
	--mx-color-primary-soft: #dcefec;
	--mx-color-on-primary: #ffffff;
	--mx-color-secondary: #7a5230;
	--mx-color-secondary-soft: #f4ebe2;
	--mx-color-accent: #e8b04b;
	--mx-color-on-accent: #1d2b28;
	--mx-color-success: #17795d;
	--mx-color-success-soft: #ddefe8;
	--mx-color-warning: #9a6212;
	--mx-color-warning-soft: #fbeed7;
	/* BMI band ramp. Defined once here so the scale is themeable and no
	   component carries a raw hex value. */
	--mx-bmi-under: #cbd5dd;
	--mx-bmi-over: #d99a4e;
	--mx-bmi-obese1: #cf8a52;
	--mx-bmi-obese2: #c17351;
	--mx-bmi-obese3: #ad5b4c;
	--mx-color-danger: #b23a48;
	--mx-color-danger-soft: #f9e4e6;
	--mx-color-info: #2b6b7f;
	--mx-color-info-soft: #e2eff3;

	--mx-color-text: #1d2b28;
	--mx-color-text-muted: #5d6b67;
	--mx-color-text-faint: #8a9793;
	--mx-color-background: #fafaf8;
	--mx-color-surface: #ffffff;
	--mx-color-surface-elevated: #ffffff;
	--mx-color-surface-sunken: #f2f2ee;
	--mx-color-border: #e6e6e0;
	--mx-color-border-strong: #d3d3ca;
	--mx-color-focus: #14746a;

	/* the deep panel used for momentum and marks keeps its own scale in both themes */
	--mx-color-canvas: #16302b;
	--mx-color-on-canvas: #ffffff;
	--mx-color-on-canvas-muted: #a9c2bb;

	/* ---- typography ---- */
	--mx-font-display: "Bricolage Grotesque", "Space Grotesk", "Segoe UI", system-ui, sans-serif;
	--mx-font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
	--mx-font-num: ui-monospace, "SF Mono", "Roboto Mono", Menlo, monospace;

	--mx-type-display: 700 2rem/1.1 var(--mx-font-display);
	--mx-type-heading: 700 1.375rem/1.2 var(--mx-font-display);
	--mx-type-subheading: 600 1.0625rem/1.35 var(--mx-font-body);
	--mx-type-body: 400 0.9375rem/1.55 var(--mx-font-body);
	--mx-type-small: 400 0.8125rem/1.5 var(--mx-font-body);
	--mx-type-caption: 500 0.75rem/1.4 var(--mx-font-body);
	--mx-type-label: 600 0.8125rem/1.3 var(--mx-font-body);
	--mx-type-button: 600 0.9375rem/1 var(--mx-font-body);

	/* ---- spacing ---- */
	--mx-space-xs: 4px;
	--mx-space-sm: 8px;
	--mx-space-md: 12px;
	--mx-space-lg: 16px;
	--mx-space-xl: 24px;
	--mx-space-2xl: 32px;
	--mx-space-3xl: 48px;

	/* ---- radius ---- */
	--mx-radius-small: 8px;
	--mx-radius-medium: 14px;
	--mx-radius-large: 22px;
	--mx-radius-pill: 999px;

	/* ---- elevation ---- */
	--mx-elevation-0: none;
	--mx-elevation-1: 0 1px 2px rgba(20, 18, 43, 0.06);
	--mx-elevation-2: 0 4px 16px rgba(20, 18, 43, 0.08);
	--mx-elevation-3: 0 12px 36px rgba(20, 18, 43, 0.14);
	--mx-elevation-up: 0 -6px 22px rgba(20, 18, 43, 0.07);

	--mx-nav-h: 64px;
	--mx-tap: 48px;
	--mx-ring: 0 0 0 3px var(--mx-color-primary-soft);

	/* ---- compatibility aliases: older inline styles resolve through these ---- */
	--mx-ink: var(--mx-color-text);
	--mx-primary: var(--mx-color-primary);
	--mx-primary-press: var(--mx-color-primary-press);
	--mx-primary-soft: var(--mx-color-primary-soft);
	--mx-citrine: var(--mx-color-accent);
	--mx-jade: var(--mx-color-success);
	--mx-amber: var(--mx-color-warning);
	--mx-coral: #e05a41;
	--mx-crimson: var(--mx-color-danger);
	--mx-bg: var(--mx-color-background);
	--mx-surface: var(--mx-color-surface);
	--mx-surface-2: var(--mx-color-surface-sunken);
	--mx-muted: var(--mx-color-text-muted);
	--mx-line: var(--mx-color-border);
	--mx-t-xs: 0.75rem;
	--mx-t-sm: 0.8125rem;
	--mx-t-md: 0.9375rem;
	--mx-t-lg: 1.125rem;
	--mx-t-xl: 1.5rem;
	--mx-t-2xl: 2rem;
	--mx-t-3xl: 2.75rem;
	--mx-1: var(--mx-space-xs);
	--mx-2: var(--mx-space-sm);
	--mx-3: var(--mx-space-md);
	--mx-4: var(--mx-space-lg);
	--mx-5: var(--mx-space-xl);
	--mx-6: var(--mx-space-2xl);
	--mx-7: var(--mx-space-3xl);
	--mx-r-sm: var(--mx-radius-small);
	--mx-r-md: var(--mx-radius-medium);
	--mx-r-lg: var(--mx-radius-large);
	--mx-r-full: var(--mx-radius-pill);
	--mx-shadow-1: var(--mx-elevation-1);
	--mx-shadow-2: var(--mx-elevation-2);
	--mx-shadow-up: var(--mx-elevation-up);
}

/* ---- colour: dark ----
   Backgrounds are a deep violet-neutral, elevation is expressed as lightness,
   borders lift rather than darken, and every foreground was re-picked to hold
   at least 4.5:1 against its own surface. */
[data-theme="dark"] {
	--mx-color-primary: #9b86ff;
	--mx-color-primary-press: #b3a2ff;
	--mx-color-primary-soft: #262046;
	--mx-color-on-primary: #14122b;
	--mx-color-secondary: #5ec8d8;
	--mx-color-secondary-soft: #14313a;
	--mx-color-accent: #c9f24c;
	--mx-color-on-accent: #14122b;
	--mx-color-success: #45d3a0;
	--mx-color-success-soft: #10322a;
	--mx-color-warning: #eab55f;
	--mx-bmi-under: #5b6b78;
	--mx-bmi-over: #c9954f;
	--mx-bmi-obese1: #bf8551;
	--mx-bmi-obese2: #b0704f;
	--mx-bmi-obese3: #9d584a;
	--mx-color-warning-soft: #34260f;
	--mx-color-danger: #ff8098;
	--mx-color-danger-soft: #3a1622;
	--mx-color-info: #98a9ff;
	--mx-color-info-soft: #1e2145;

	--mx-color-text: #f3f2f9;
	--mx-color-text-muted: #a9a5c8;
	--mx-color-text-faint: #837fa3;
	--mx-color-background: #0f0d1c;
	--mx-color-surface: #191630;
	--mx-color-surface-elevated: #211d3d;
	--mx-color-surface-sunken: #141127;
	--mx-color-border: #2c2850;
	--mx-color-border-strong: #3d3866;
	--mx-color-focus: #9b86ff;

	--mx-color-canvas: #221d40;
	--mx-color-on-canvas: #f3f2f9;
	--mx-color-on-canvas-muted: #a9a5c8;

	--mx-elevation-1: 0 1px 2px rgba(0, 0, 0, 0.4);
	--mx-elevation-2: 0 4px 18px rgba(0, 0, 0, 0.45);
	--mx-elevation-3: 0 14px 40px rgba(0, 0, 0, 0.55);
	--mx-elevation-up: 0 -6px 22px rgba(0, 0, 0, 0.4);
	--mx-ring: 0 0 0 3px rgba(155, 134, 255, 0.35);

	--mx-coral: #ff9273;
	color-scheme: dark;
}

/* ==================================================================== base */

* { box-sizing: border-box; }
/* Without this, a single wide descendant (a long string, a filter row) forces
   the flex column wider than the viewport and everything overflows right. */
*, *::before, *::after { min-width: 0; }

html, body {
	margin: 0;
	padding: 0;
	background: var(--mx-color-background);
	color: var(--mx-color-text);
	font: var(--mx-type-body);
	font-size: 16px;
	-webkit-text-size-adjust: 100%;
	overflow-x: hidden;
	transition: background-color 0.2s ease, color 0.2s ease;
}

body.mx { min-height: 100dvh; }

h1, h2, h3, .mx-display { font-family: var(--mx-font-display); font-weight: 700; letter-spacing: -0.02em; margin: 0; }
a { color: var(--mx-color-primary); }
button { font: inherit; color: inherit; }

:focus-visible {
	outline: 3px solid var(--mx-color-focus);
	outline-offset: 2px;
	border-radius: var(--mx-radius-small);
}

@media (prefers-reduced-motion: reduce) {
	*, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

.mx-visually-hidden {
	position: absolute; width: 1px; height: 1px; overflow: hidden;
	clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ==================================================================== boot */

.mx-boot-splash { min-height: 100dvh; display: grid; place-content: center; justify-items: center; gap: var(--mx-space-lg); color: var(--mx-color-text-muted); }
.mx-boot-mark {
	width: 56px; height: 56px; display: grid; place-content: center;
	background: var(--mx-color-canvas); color: var(--mx-color-accent);
	border-radius: 18px; font-family: var(--mx-font-display); font-size: 1.5rem;
	animation: mx-pulse 1.4s ease-in-out infinite;
}
@keyframes mx-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.mx-noscript { padding: var(--mx-space-xl); text-align: center; }

/* =================================================================== shell */

.mx-shell { display: flex; flex-direction: column; min-height: 100dvh; overflow-x: clip; }
.mx-topbar-inner, .mx-main { max-width: 1180px; width: 100%; margin-inline: auto; }

.mx-topbar {
	position: sticky; top: 0; z-index: 20;
	display: flex; align-items: center; gap: var(--mx-space-md);
	padding: max(var(--mx-space-md), env(safe-area-inset-top)) var(--mx-space-lg) var(--mx-space-md);
	background: color-mix(in srgb, var(--mx-color-background) 88%, transparent);
	backdrop-filter: blur(14px);
	border-bottom: 1px solid transparent;
}
.mx-topbar h1 { font: var(--mx-type-subheading); }
.mx-topbar .mx-sub { font: var(--mx-type-caption); color: var(--mx-color-text-muted); }
.mx-topbar-actions { margin-left: auto; display: flex; gap: var(--mx-space-sm); align-items: center; }

.mx-main {
	flex: 1;
	padding: var(--mx-space-md) var(--mx-space-lg) calc(var(--mx-nav-h) + var(--mx-space-2xl));
	max-width: 1180px; width: 100%; margin: 0 auto;
}

.mx-stack { display: grid; gap: var(--mx-space-md); }
.mx-stack--tight { gap: var(--mx-space-sm); }
.mx-row { display: flex; align-items: center; gap: var(--mx-space-md); }
.mx-row--between { justify-content: space-between; }
.mx-row--wrap { flex-wrap: wrap; }
.mx-grow { flex: 1; min-width: 0; }

/* ============================================================= bottom nav */

.mx-bottomnav {
	position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
	display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
	background: var(--mx-color-surface);
	border-top: 1px solid var(--mx-color-border);
	box-shadow: var(--mx-elevation-up);
	padding-bottom: env(safe-area-inset-bottom);
}
.mx-bottomnav a {
	min-height: var(--mx-nav-h); display: grid; place-items: center; gap: 2px;
	text-decoration: none; color: var(--mx-color-text-muted);
	font: var(--mx-type-caption); font-weight: 600; padding: var(--mx-space-sm) 0;
	position: relative;
}
.mx-bottomnav a[aria-current="page"] { color: var(--mx-color-primary); }
.mx-bottomnav a[aria-current="page"]::before {
	content: ""; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
	width: 26px; height: 3px; border-radius: 0 0 3px 3px; background: var(--mx-color-primary);
}
.mx-ico { width: 22px; height: 22px; display: block; }

.mx-badge-dot {
	position: absolute; top: 8px; left: 50%; margin-left: 6px;
	min-width: 17px; height: 17px; padding: 0 4px; border-radius: var(--mx-radius-pill);
	background: var(--mx-color-danger); color: var(--mx-color-surface);
	font: var(--mx-type-caption); font-size: 10px; font-weight: 700;
	display: grid; place-items: center;
}
[data-theme="dark"] .mx-badge-dot { color: #14122b; }

/* ================================================================ surfaces */

.mx-card {
	background: var(--mx-color-surface);
	border: 1px solid var(--mx-color-border);
	border-radius: var(--mx-radius-large);
	padding: var(--mx-space-lg);
	box-shadow: var(--mx-elevation-1);
}
.mx-card--elevated { background: var(--mx-color-surface-elevated); box-shadow: var(--mx-elevation-2); }
.mx-card--flat { box-shadow: none; }
.mx-card--ink { background: var(--mx-color-canvas); color: var(--mx-color-on-canvas); border-color: transparent; }
.mx-card--ink .mx-muted, .mx-card--ink .mx-small { color: var(--mx-color-on-canvas-muted); }
.mx-card h2 { font: var(--mx-type-caption); text-transform: uppercase; letter-spacing: 0.08em; color: var(--mx-color-text-muted); font-weight: 700; }

.mx-muted { color: var(--mx-color-text-muted); }
.mx-small { font: var(--mx-type-small); }
.mx-num { font-family: var(--mx-font-num); font-variant-numeric: tabular-nums; }
.mx-eyebrow { font: var(--mx-type-caption); font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--mx-color-text-muted); }
.mx-h1 { font: var(--mx-type-heading); }
.mx-h0 { font: var(--mx-type-display); }

.mx-pill {
	display: inline-flex; align-items: center; gap: 6px;
	padding: 4px 10px; border-radius: var(--mx-radius-pill);
	font: var(--mx-type-caption); font-weight: 700;
	background: var(--mx-color-primary-soft); color: var(--mx-color-primary);
}
.mx-pill--jade { background: var(--mx-color-success-soft); color: var(--mx-color-success); }
.mx-pill--amber { background: var(--mx-color-warning-soft); color: var(--mx-color-warning); }
.mx-pill--coral { background: var(--mx-color-danger-soft); color: var(--mx-color-danger); }
.mx-pill--ink { background: var(--mx-color-canvas); color: var(--mx-color-accent); }
.mx-pill--quiet { background: var(--mx-color-surface-sunken); color: var(--mx-color-text-muted); }

/* ================================================ signature: momentum strip */

.mx-momentum { display: grid; gap: var(--mx-space-md); }
.mx-momentum-figure { font-family: var(--mx-font-display); font-size: 2.75rem; line-height: 1; font-variant-numeric: tabular-nums; }
.mx-strip { display: flex; gap: 4px; align-items: flex-end; }
.mx-strip span {
	flex: 1; height: 34px; border-radius: var(--mx-radius-pill);
	background: rgba(255, 255, 255, 0.13);
	border: 1px solid rgba(255, 255, 255, 0.17);
	position: relative;
}
.mx-strip span[data-done="1"] { background: var(--mx-color-accent); border-color: var(--mx-color-accent); }
.mx-strip span[data-source="telecommunicator"]::after,
.mx-strip span[data-source="clinician"]::after {
	content: ""; position: absolute; left: 50%; bottom: 5px; transform: translateX(-50%);
	width: 5px; height: 5px; border-radius: 50%; background: var(--mx-color-canvas);
}
.mx-strip-legend { display: flex; gap: var(--mx-space-md); font: var(--mx-type-caption); }

.mx-ring { display: grid; place-items: center; position: relative; width: 92px; height: 92px; }
.mx-ring svg { transform: rotate(-90deg); }
.mx-ring-value { position: absolute; text-align: center; font-family: var(--mx-font-display); font-size: 1.125rem; line-height: 1; }
.mx-ring-value small { display: block; font: var(--mx-type-caption); color: inherit; opacity: 0.72; font-family: var(--mx-font-body); }

/* ================================================================= buttons */

.mx-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: var(--mx-space-sm);
	min-height: var(--mx-tap); padding: 0 var(--mx-space-xl);
	border-radius: var(--mx-radius-pill); border: 1px solid transparent;
	background: var(--mx-color-primary); color: var(--mx-color-on-primary);
	font: var(--mx-type-button); cursor: pointer; text-decoration: none;
	transition: transform 0.12s ease, background-color 0.12s ease, border-color 0.12s ease;
}
.mx-btn:active { transform: scale(0.98); background: var(--mx-color-primary-press); }
.mx-btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.mx-btn--block { width: 100%; }
.mx-btn--ghost { background: transparent; color: var(--mx-color-primary); border-color: var(--mx-color-border); }
.mx-btn--quiet { background: var(--mx-color-surface); color: var(--mx-color-text); border-color: var(--mx-color-border); }
.mx-btn--quiet:active { background: var(--mx-color-surface-sunken); }
.mx-btn--citrine { background: var(--mx-color-accent); color: var(--mx-color-on-accent); }
.mx-btn--danger { background: var(--mx-color-danger); color: #ffffff; }
[data-theme="dark"] .mx-btn--danger { color: #14122b; }
.mx-btn--sm { min-height: 36px; padding: 0 var(--mx-space-md); font: var(--mx-type-small); font-weight: 600; }

.mx-sticky-action {
	position: sticky; bottom: calc(var(--mx-nav-h) + var(--mx-space-sm));
	padding: var(--mx-space-md) 0; z-index: 10;
	background: linear-gradient(to top, var(--mx-color-background) 62%, transparent);
}

/* =================================================================== forms */

.mx-field { display: grid; gap: 6px; }
.mx-field > label { font: var(--mx-type-label); }
.mx-field .mx-hint { font: var(--mx-type-caption); color: var(--mx-color-text-muted); }

.mx-input, .mx-select, .mx-textarea {
	width: 100%; min-height: var(--mx-tap); padding: var(--mx-space-md);
	border: 1px solid var(--mx-color-border); border-radius: var(--mx-radius-medium);
	background: var(--mx-color-surface); color: var(--mx-color-text);
	font-size: 16px; /* keeps iOS from zooming on focus */
}
.mx-textarea { min-height: 96px; resize: vertical; }
.mx-input:focus, .mx-select:focus, .mx-textarea:focus {
	border-color: var(--mx-color-primary); outline: none; box-shadow: var(--mx-ring);
}
.mx-input::placeholder, .mx-textarea::placeholder { color: var(--mx-color-text-faint); }

.mx-scale { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: var(--mx-space-sm); }
.mx-scale button {
	min-height: 56px; border-radius: var(--mx-radius-medium);
	border: 1px solid var(--mx-color-border); background: var(--mx-color-surface);
	color: var(--mx-color-text); font-family: var(--mx-font-display); font-size: 1.125rem; cursor: pointer;
}
.mx-scale button[aria-pressed="true"] { background: var(--mx-color-canvas); color: var(--mx-color-accent); border-color: var(--mx-color-canvas); }

.mx-toggle { display: flex; gap: var(--mx-space-sm); }
.mx-toggle button {
	flex: 1; min-height: var(--mx-tap); border-radius: var(--mx-radius-medium);
	border: 1px solid var(--mx-color-border); background: var(--mx-color-surface);
	color: var(--mx-color-text); cursor: pointer; font-weight: 600;
}
.mx-toggle button[aria-pressed="true"] { background: var(--mx-color-primary); color: var(--mx-color-on-primary); border-color: var(--mx-color-primary); }

.mx-choices { display: grid; gap: var(--mx-space-sm); }
.mx-choices button {
	min-height: 60px; padding: 0 var(--mx-space-lg); text-align: left;
	border-radius: var(--mx-radius-medium); border: 1px solid var(--mx-color-border);
	background: var(--mx-color-surface); color: var(--mx-color-text);
	font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: var(--mx-space-md);
}
.mx-choices button[aria-pressed="true"] { border-color: var(--mx-color-primary); background: var(--mx-color-primary-soft); color: var(--mx-color-primary); }

.mx-states { display: flex; flex-wrap: wrap; gap: 6px; }
.mx-states button {
	border: 1px dashed var(--mx-color-border-strong); background: transparent; color: var(--mx-color-text-muted);
	border-radius: var(--mx-radius-pill); padding: 6px 12px; font: var(--mx-type-caption); cursor: pointer; min-height: 34px;
}
.mx-states button[aria-pressed="true"] { border-style: solid; border-color: var(--mx-color-text); color: var(--mx-color-text); background: var(--mx-color-surface); }

.mx-check { display: flex; gap: var(--mx-space-md); align-items: flex-start; }
.mx-check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--mx-color-primary); flex: none; }

.mx-radio-card {
	display: flex; gap: var(--mx-space-md); align-items: flex-start;
	padding: var(--mx-space-md); border: 1px solid var(--mx-color-border);
	border-radius: var(--mx-radius-medium); background: var(--mx-color-surface); cursor: pointer;
}
.mx-radio-card input { accent-color: var(--mx-color-primary); width: 20px; height: 20px; flex: none; margin-top: 2px; }
.mx-radio-card--on { border-color: var(--mx-color-primary); background: var(--mx-color-primary-soft); }

/* =================================================================== lists */

.mx-list { display: grid; gap: var(--mx-space-sm); }
.mx-item {
	display: flex; align-items: center; gap: var(--mx-space-md);
	background: var(--mx-color-surface); border: 1px solid var(--mx-color-border);
	border-radius: var(--mx-radius-medium); padding: var(--mx-space-md);
	min-height: 60px; text-align: left; width: 100%; cursor: pointer; color: var(--mx-color-text);
	transition: border-color 0.12s ease;
}
.mx-item:hover { border-color: var(--mx-color-border-strong); }
.mx-item .mx-avatar {
	width: 40px; height: 40px; border-radius: 50%; flex: none;
	background: var(--mx-color-primary-soft); color: var(--mx-color-primary);
	display: grid; place-items: center; font-weight: 700;
}
.mx-item h3 { font: var(--mx-type-subheading); font-family: var(--mx-font-body); }

.mx-task {
	display: flex; align-items: center; gap: var(--mx-space-md);
	padding: var(--mx-space-md); border-radius: var(--mx-radius-medium);
	border: 1px solid var(--mx-color-border); background: var(--mx-color-surface);
	width: 100%; text-align: left; cursor: pointer; min-height: 60px; color: var(--mx-color-text);
}
.mx-task .mx-tick {
	width: 26px; height: 26px; border-radius: 50%; flex: none;
	border: 2px solid var(--mx-color-border-strong); display: grid; place-items: center;
	font-size: 14px; color: transparent;
}
.mx-task[data-done="1"] { background: var(--mx-color-surface-sunken); }
.mx-task[data-done="1"] .mx-tick { background: var(--mx-color-success); border-color: var(--mx-color-success); color: #ffffff; }
.mx-task[data-done="1"] .mx-label { text-decoration: line-through; color: var(--mx-color-text-muted); }
.mx-task .mx-meta { font: var(--mx-type-caption); color: var(--mx-color-text-muted); }

.mx-empty {
	text-align: center; max-width: 100%; padding: var(--mx-space-2xl) var(--mx-space-lg);
	display: grid; justify-items: center; gap: var(--mx-space-xs);
	border: 1px dashed var(--mx-color-border-strong); border-radius: var(--mx-radius-large);
	color: var(--mx-color-text-muted);
}
.mx-empty strong { display: block; color: var(--mx-color-text); }
.mx-empty p, .mx-empty span { max-width: 46ch; }


/* ==========================================================================
   Alternative palettes. Set data-palette on <html> to switch the whole
   product — public site and app both read these tokens.
   ========================================================================== */

[data-palette="slate"] {
	--mx-color-primary: #3f5871;
	--mx-color-primary-press: #32465b;
	--mx-color-primary-soft: #e6ebf1;
	--mx-color-secondary: #8a5a3b;
	--mx-color-secondary-soft: #f3ebe5;
	--mx-color-accent: #d99a5b;
	--mx-color-on-accent: #1c2530;
	--mx-color-focus: #3f5871;
	--mx-color-text: #1c2530;
	--mx-color-text-muted: #5b6874;
	--mx-color-text-faint: #8b969f;
	--mx-color-background: #fafaf9;
	--mx-color-surface-sunken: #f1f2f3;
	--mx-color-border: #e4e6e8;
	--mx-color-border-strong: #d0d3d7;
	--mx-color-canvas: #232f3c;
	--mx-color-on-canvas-muted: #aebbc7;
}

[data-palette="plum"] {
	--mx-color-primary: #7a3f6d;
	--mx-color-primary-press: #63325a;
	--mx-color-primary-soft: #f2e6ef;
	--mx-color-secondary: #386b6b;
	--mx-color-secondary-soft: #e3efee;
	--mx-color-accent: #e0a24c;
	--mx-color-on-accent: #2b1f28;
	--mx-color-focus: #7a3f6d;
	--mx-color-text: #2b1f28;
	--mx-color-text-muted: #6a5d66;
	--mx-color-text-faint: #968c92;
	--mx-color-background: #fbf9fa;
	--mx-color-surface-sunken: #f4f0f2;
	--mx-color-border: #eae4e7;
	--mx-color-border-strong: #d8cfd4;
	--mx-color-canvas: #2f2130;
	--mx-color-on-canvas-muted: #c1adbd;
}

/* The original RC1-RC4 direction, kept so nothing is lost. */
[data-palette="indigo"] {
	--mx-color-primary: #4b2fd9;
	--mx-color-primary-press: #3c22b8;
	--mx-color-primary-soft: #eeeaff;
	--mx-color-secondary: #0f6f80;
	--mx-color-secondary-soft: #e2f2f4;
	--mx-color-accent: #c9f24c;
	--mx-color-on-accent: #14122b;
	--mx-color-focus: #4b2fd9;
	--mx-color-text: #14122b;
	--mx-color-text-muted: #63607f;
	--mx-color-text-faint: #8b88a6;
	--mx-color-background: #f7f7fb;
	--mx-color-surface-sunken: #f1f0f7;
	--mx-color-border: #e6e4f0;
	--mx-color-border-strong: #d3d0e4;
	--mx-color-canvas: #191534;
	--mx-color-on-canvas-muted: #b3aed6;
}

/* ================================================================ timeline */

.mx-timeline { display: grid; gap: var(--mx-space-lg); }
.mx-timeline-day { display: grid; gap: var(--mx-space-sm); }
.mx-timeline-events { display: grid; position: relative; padding-left: var(--mx-space-xl); }
.mx-timeline-events::before {
	content: ""; position: absolute; left: 7px; top: 14px; bottom: 14px;
	width: 2px; background: var(--mx-color-border);
}
.mx-tl-event { position: relative; padding: var(--mx-space-md) 0; }
.mx-tl-event::before {
	content: ""; position: absolute; left: calc(-1 * var(--mx-space-xl) + 2px); top: 20px;
	width: 12px; height: 12px; border-radius: 50%;
	background: var(--mx-color-surface); border: 2px solid var(--mx-color-border-strong);
}
/*
 * Every marker was an identical hollow ring, so a completed check-in looked the
 * same as an open attention item. Anything that represents something DONE now
 * carries a filled tick.
 */
.mx-tl-event[data-done="1"]::before {
	content: "\2713"; background: var(--mx-color-success); border-color: var(--mx-color-success);
	color: #ffffff; font-size: 9px; font-weight: 700; line-height: 12px; text-align: center;
}
.mx-tl-event[data-type="checkin"]::before { border-color: var(--mx-color-success); }
.mx-tl-event[data-type="checkin_call"][data-done="1"]::before { background: var(--mx-color-warning); border-color: var(--mx-color-warning); }
.mx-tl-event[data-type="call"]::before { border-color: var(--mx-color-secondary); }
.mx-tl-event[data-type="attention"]::before { border-color: var(--mx-color-danger); background: var(--mx-color-danger); content: ""; }
.mx-tl-event[data-type="consent"]::before, .mx-tl-event[data-type="care_team"]::before { border-color: var(--mx-color-primary); }
.mx-tl-time { font: var(--mx-type-caption); color: var(--mx-color-text-faint); font-variant-numeric: tabular-nums; }
.mx-tl-title { font: var(--mx-type-subheading); }
.mx-tl-detail { font: var(--mx-type-small); color: var(--mx-color-text-muted); }

/* ================================================================ messages */

/*
 * A short thread used to render from the top of the page with a large gap down
 * to the composer, which reads as "my message went to the top". Every messenger
 * anchors the conversation to the BOTTOM of the available space.
 *
 * The view becomes a full-height column; the thread takes the remaining room
 * and pushes its content to the end, so one message sits just above the
 * composer and a long thread scrolls normally.
 */
/*
 * --mx-topbar-h was never defined, so this resolved against a guess and the
 * column ended up taller than the visible area — the composer sat below the
 * bottom nav, off screen. Size the thread against the scroll container instead
 * of guessing at chrome heights.
 */
/*
 * A fixed height was right in the installed app and wrong in the browser, where
 * the address bar changes what 100dvh means — it left dead space under the
 * composer. min-height lets the column grow with the conversation and never
 * reserve space it does not need.
 */
/*
 * Any fixed figure here is wrong somewhere: the browser and the installed app
 * measure 100dvh differently, and a magic offset for chrome left a gap under
 * the composer. Let the thread fill whatever the main area actually is.
 */
.mx-shellmain { min-height: 100dvh; }
.mx-main:has(> .mx-thread-view) { display: flex; flex-direction: column; }
.mx-thread-view { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.mx-thread-view > .mx-thread { flex: 1 1 auto; align-content: end; }
/* Browsers without :has fall back to a conservative minimum. */
@supports not selector(:has(*)) {
	.mx-thread-view { min-height: calc(100dvh - var(--mx-nav-h) - 190px); }
}
.mx-thread-view > .mx-thread { flex: 1 1 auto; align-content: end; }
.mx-thread { display: grid; gap: var(--mx-space-sm); padding-bottom: var(--mx-space-md); }
.mx-bubble {
	max-width: min(78%, 520px); padding: var(--mx-space-md) var(--mx-space-lg);
	border-radius: var(--mx-radius-large); border: 1px solid var(--mx-color-border);
	background: var(--mx-color-surface); justify-self: start;
	border-bottom-left-radius: var(--mx-radius-small);
}
.mx-bubble--mine {
	justify-self: end; background: var(--mx-color-primary); color: var(--mx-color-on-primary);
	border-color: transparent; border-bottom-left-radius: var(--mx-radius-large);
	border-bottom-right-radius: var(--mx-radius-small);
}
.mx-bubble--mine .mx-bubble-meta { color: color-mix(in srgb, var(--mx-color-on-primary) 76%, transparent); }
.mx-bubble-meta { font: var(--mx-type-caption); color: var(--mx-color-text-muted); display: flex; gap: var(--mx-space-sm); align-items: baseline; }
.mx-bubble-body { margin: 4px 0 0; white-space: pre-wrap; word-break: break-word; }
.mx-bubble--pending { opacity: 0.6; }
.mx-bubble--failed { border-color: var(--mx-color-danger); }

.mx-composer {
	position: sticky; bottom: 0;
	display: flex; gap: var(--mx-space-sm); align-items: flex-end;
	padding: var(--mx-space-sm) 0 calc(var(--mx-space-sm) + env(safe-area-inset-bottom));
	margin-top: auto;
	background: var(--mx-color-background);
	border-top: 1px solid var(--mx-color-border);
}
/* With the keyboard open the bottom nav is hidden, so the composer sits
   directly above the keyboard instead of a nav-height gap above it. */
body.mx-composing .mx-bottomnav { display: none; }
body.mx-composing .mx-main { padding-bottom: var(--mx-space-lg); }
body.mx-composing .mx-thread-view { min-height: 0; }
.mx-composer .mx-textarea { min-height: var(--mx-tap); max-height: 140px; border-radius: var(--mx-radius-large); }

.mx-thread-kind {
	font: var(--mx-type-caption); font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase;
	padding: 2px 8px; border-radius: var(--mx-radius-small);
}
.mx-thread-kind--private { background: var(--mx-color-primary-soft); color: var(--mx-color-primary); }
.mx-thread-kind--group { background: var(--mx-color-secondary-soft); color: var(--mx-color-secondary); }
.mx-thread-kind--announcement { background: var(--mx-color-warning-soft); color: var(--mx-color-warning); }

/* ================================================================ check-in */

.mx-stepper { display: grid; gap: var(--mx-space-xl); }
.mx-stepper-progress { display: flex; gap: 4px; }
.mx-stepper-progress span { flex: 1; height: 4px; border-radius: var(--mx-radius-pill); background: var(--mx-color-border); }
.mx-stepper-progress span[data-state="done"] { background: var(--mx-color-success); }
.mx-stepper-progress span[data-state="current"] { background: var(--mx-color-primary); }
.mx-question { display: grid; gap: var(--mx-space-lg); min-height: 44dvh; align-content: start; }
.mx-question h2 { font: var(--mx-type-heading); color: var(--mx-color-text); text-transform: none; letter-spacing: -0.02em; }
.mx-stepper-nav { display: flex; gap: var(--mx-space-sm); }
.mx-review-row {
	display: flex; justify-content: space-between; gap: var(--mx-space-md);
	padding: var(--mx-space-md) 0; border-bottom: 1px solid var(--mx-color-border);
}
.mx-review-row:last-child { border-bottom: 0; }

/* ================================================================== charts */

.mx-chart { width: 100%; height: 150px; display: block; }
.mx-chart .mx-line { fill: none; stroke: var(--mx-color-primary); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.mx-chart .mx-area { fill: var(--mx-color-primary-soft); }
.mx-chart .mx-dot { fill: var(--mx-color-primary); }
.mx-chart .mx-axis { stroke: var(--mx-color-border); stroke-width: 1; }

/* ================================================================== sheets */

.mx-sheet-backdrop {
	position: fixed; inset: 0; z-index: 60;
	background: rgba(10, 8, 22, 0.5);
	display: flex; align-items: flex-end; justify-content: center;
}
.mx-sheet {
	background: var(--mx-color-surface-elevated); color: var(--mx-color-text);
	width: 100%; max-width: 640px;
	border-radius: var(--mx-radius-large) var(--mx-radius-large) 0 0;
	padding: var(--mx-space-lg) var(--mx-space-lg) calc(var(--mx-space-xl) + env(safe-area-inset-bottom));
	max-height: 88dvh; overflow-y: auto;
	animation: mx-rise 0.22s ease;
	box-shadow: var(--mx-elevation-3);
}
@keyframes mx-rise { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.mx-sheet-grab { width: 40px; height: 4px; border-radius: 2px; background: var(--mx-color-border-strong); margin: 0 auto var(--mx-space-lg); }

.mx-toast {
	position: fixed; left: 50%; transform: translateX(-50%);
	bottom: calc(var(--mx-nav-h) + var(--mx-space-lg)); z-index: 80;
	background: var(--mx-color-canvas); color: var(--mx-color-on-canvas);
	padding: var(--mx-space-md) var(--mx-space-lg); border-radius: var(--mx-radius-pill);
	font: var(--mx-type-small); box-shadow: var(--mx-elevation-3); max-width: 90vw;
}
.mx-toast--error { background: var(--mx-color-danger); color: #ffffff; }
[data-theme="dark"] .mx-toast--error { color: #14122b; }

.mx-banner {
	border-radius: var(--mx-radius-medium); padding: var(--mx-space-md) var(--mx-space-lg);
	font: var(--mx-type-small); border: 1px solid;
}
.mx-banner--demo { background: var(--mx-color-warning-soft); border-color: var(--mx-color-warning); color: var(--mx-color-warning); }
.mx-banner--attention { background: var(--mx-color-danger-soft); border-color: var(--mx-color-danger); color: var(--mx-color-danger); }
.mx-banner--info { background: var(--mx-color-info-soft); border-color: var(--mx-color-info); color: var(--mx-color-info); }

.mx-attribution { font: var(--mx-type-caption); color: var(--mx-color-text-muted); display: inline-flex; align-items: center; gap: 6px; }
.mx-attribution::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--mx-color-warning); flex: none; }

/* =================================================================== table */

.mx-table { width: 100%; border-collapse: collapse; font: var(--mx-type-small); }
.mx-table th { text-align: left; color: var(--mx-color-text-muted); font-weight: 700; padding: var(--mx-space-sm); border-bottom: 1px solid var(--mx-color-border); }
.mx-table td { padding: var(--mx-space-sm); border-bottom: 1px solid var(--mx-color-border); }

/* ============================================================== pagination */

.mx-pagination { display: flex; align-items: center; justify-content: center; gap: var(--mx-space-xs); flex-wrap: wrap; }
.mx-pagination button {
	min-width: var(--mx-tap); min-height: var(--mx-tap); padding: 0 var(--mx-space-md);
	border-radius: var(--mx-radius-medium); border: 1px solid var(--mx-color-border);
	background: var(--mx-color-surface); color: var(--mx-color-text); cursor: pointer; font-weight: 600;
}
.mx-pagination button[aria-current="true"] { background: var(--mx-color-primary); color: var(--mx-color-on-primary); border-color: var(--mx-color-primary); }
.mx-pagination button[disabled] { opacity: 0.4; cursor: not-allowed; }
.mx-pagination .mx-gap { color: var(--mx-color-text-faint); padding: 0 var(--mx-space-xs); }

/* ==================================================================== auth */

.mx-auth { min-height: 100dvh; display: grid; grid-template-rows: 1fr auto; }
.mx-auth-inner { width: 100%; max-width: 420px; margin: 0 auto; padding: calc(var(--mx-space-2xl) + env(safe-area-inset-top)) var(--mx-space-lg) var(--mx-space-2xl); align-self: center; }
.mx-auth-mark {
	width: 52px; height: 52px; border-radius: 17px;
	background: var(--mx-color-canvas); color: var(--mx-color-accent);
	display: grid; place-content: center; font-family: var(--mx-font-display); font-size: 1.4rem;
	margin-bottom: var(--mx-space-xl);
}
.mx-auth h1 { font: var(--mx-type-display); margin-bottom: var(--mx-space-sm); }
.mx-auth-foot { padding: var(--mx-space-lg); text-align: center; font: var(--mx-type-small); color: var(--mx-color-text-muted); }

/* =================================================================== stats */

/* Four stats across on a phone rather than two half-page blocks. */
.mx-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.mx-stat {
	background: var(--mx-color-surface); border: 1px solid var(--mx-color-border);
	border-radius: var(--mx-radius-medium); padding: 10px 8px; min-width: 0; text-align: center;
}
.mx-stat b { display: block; font-family: var(--mx-font-display); font-size: 1.0625rem; line-height: 1.15; font-variant-numeric: tabular-nums; }
.mx-stat span { font-size: .6875rem; line-height: 1.25; color: var(--mx-color-text-muted); display: block; margin-top: 2px; }
@media (min-width: 600px) {
	.mx-stats { gap: var(--mx-space-sm); }
	.mx-stat { padding: var(--mx-space-md); text-align: left; }
	.mx-stat b { font-size: 1.375rem; }
	.mx-stat span { font: var(--mx-type-caption); }
}

.mx-skeleton {
	background: linear-gradient(90deg, var(--mx-color-surface-sunken) 25%, var(--mx-color-surface) 37%, var(--mx-color-surface-sunken) 63%);
	background-size: 400% 100%; animation: mx-shimmer 1.2s infinite;
	border-radius: var(--mx-radius-medium); height: 76px;
}
@keyframes mx-shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ================================================================= desktop */

@media (min-width: 900px) {
	.mx-bottomnav { display: none; }
	.mx-menubtn { display: none; }
	/*
	 * The sidebar is sticky and 100dvh tall, so its background stopped one
	 * viewport down and the column turned grey for the rest of a long page.
	 * Paint the column on the shell instead, where it runs the full height.
	 */
	.mx-shell--staff, .mx-shell--member {
		display: grid; grid-template-columns: 264px 1fr;
		background-image: linear-gradient(90deg,
			var(--mx-color-surface) 0 264px,
			var(--mx-color-border) 264px 265px,
			transparent 265px);
	}
	.mx-sidebar { border-right: 0; }
	.mx-sidebar { display: flex; }
	.mx-topbar-title h1 { font: var(--mx-type-subheading); }
	.mx-main { padding: var(--mx-space-lg) var(--mx-space-2xl) var(--mx-space-2xl); }
	.mx-sticky-action, .mx-composer { position: static; background: none; }
	.mx-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: var(--mx-space-lg); align-items: start; }
	.mx-stats { grid-template-columns: repeat(3, 1fr); gap: var(--mx-space-lg); }
	.mx-toast { bottom: var(--mx-space-xl); }
	.mx-question { min-height: auto; }
	.mx-split { display: grid; grid-template-columns: 1fr 340px; gap: var(--mx-space-lg); align-items: start; }
}

@media (max-width: 899px) {
	.mx-sidebar { display: none; }
	.mx-cols, .mx-split { display: grid; gap: var(--mx-space-md); }
	.mx-hide-mobile { display: none !important; }
}

/* ============================================== RC3: recognition + motion ==
   Celebration is a single, brief, non-blocking cue. It never gates content and
   it disappears entirely under reduced-motion. */

.mx-celebrate { position: relative; overflow: hidden; }
.mx-celebrate::after {
	content: "";
	position: absolute; inset: 0;
	background: linear-gradient(100deg, transparent 30%, color-mix(in srgb, var(--mx-color-accent) 45%, transparent) 50%, transparent 70%);
	transform: translateX(-100%);
	animation: mx-sweep 1.1s ease-out 1 both;
	pointer-events: none;
}
@keyframes mx-sweep { to { transform: translateX(100%); } }

@media (prefers-reduced-motion: reduce) {
	.mx-celebrate::after { display: none; }
}

/* Work queue and attention rows share the list primitive; severity is carried by
   a glyph as well as colour so it survives greyscale and colour blindness. */
.mx-item[data-severity="urgent"] { border-left: 3px solid var(--mx-color-danger); }
.mx-item[data-severity="attention"] { border-left: 3px solid var(--mx-color-warning); }

/* Search results drop in beneath the field without shifting the page. */
#mx-search-results:not(:empty) {
	margin-top: calc(-1 * var(--mx-space-sm));
	animation: mx-fade 0.16s ease-out;
}
@keyframes mx-fade { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* Press feedback on the primitives that are tapped most on mobile. */
.mx-item:active, .mx-task:active { transform: scale(0.995); }
.mx-item, .mx-task { transition: border-color 0.12s ease, transform 0.08s ease, background-color 0.12s ease; }

@media (prefers-reduced-motion: reduce) {
	.mx-item:active, .mx-task:active { transform: none; }
	#mx-search-results:not(:empty) { animation: none; }
}

/* ==================================================== live sessions + meals */

.mx-live { display: grid; gap: var(--mx-space-xs); border-left: 3px solid var(--mx-color-primary); }
.mx-live-title { font: var(--mx-type-subheading); }
.mx-live .mx-btn { margin-top: var(--mx-space-sm); }

.mx-meal-grid { display: grid; gap: var(--mx-space-lg); grid-template-columns: 1fr; }
@media (min-width: 640px) { .mx-meal-grid { grid-template-columns: repeat(2, 1fr); } }

.mx-meal {
	margin: 0; background: var(--mx-color-surface);
	border: 1px solid var(--mx-color-border); border-radius: var(--mx-radius-large);
	overflow: hidden; display: grid; align-content: start;
}
.mx-meal-photo { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--mx-color-surface-sunken); }
.mx-meal-body { display: grid; gap: var(--mx-space-xs); padding: var(--mx-space-lg); }
.mx-meal-notes { display: grid; gap: var(--mx-space-xs); margin-top: var(--mx-space-sm); padding-top: var(--mx-space-sm); border-top: 1px solid var(--mx-color-border); }
.mx-meal-note { font: var(--mx-type-small); color: var(--mx-color-text-muted); }
.mx-meal-note strong { color: var(--mx-color-primary); }
.mx-btn--danger { background: var(--mx-color-danger); color: #ffffff; border-color: var(--mx-color-danger); }

/* ------------------------------------------------------ multiple journeys */

.mx-journey-row {
	display: flex; align-items: center; gap: var(--mx-space-md);
	padding: var(--mx-space-md) 0; border-bottom: 1px solid var(--mx-color-border);
}
.mx-journey-row:last-child { border-bottom: 0; }
.mx-journey-row h3 { font: var(--mx-type-subheading); }
.mx-journey-row--on { border-left: 3px solid var(--mx-color-primary); padding-left: var(--mx-space-md); }
.mx-journey-switch { border-left: 3px solid var(--mx-color-secondary); }

.mx-item-row { display: flex; align-items: center; gap: var(--mx-space-sm); }
.mx-item-row > .mx-item { flex: 1 1 auto; min-width: 0; }
.mx-item-action { flex: none; }


/* ========================================================= navigation ==== */
/*
 * The Command Center can hold nine sections. They used to be truncated to five
 * with the rest behind a "Go to" button that opened a sheet from the bottom of
 * the screen. Every section is now in a real menu: a permanent rail on wide
 * screens, a full-height drawer everywhere else.
 */

.mx-sidebar {
	display: none;
	flex-direction: column;
	border-right: 1px solid var(--mx-color-border);
	background: var(--mx-color-surface);
	position: sticky; top: 0; height: 100dvh;
	overflow-y: auto; overscroll-behavior: contain;
	padding: var(--mx-space-lg) var(--mx-space-md) var(--mx-space-md);
}
/* Account and sign out sit under the list, not pinned to the viewport floor. */
.mx-sidebar .mx-navfoot { margin-top: auto; }
.mx-shellmain { min-width: 0; display: flex; flex-direction: column; }

.mx-brandblock:focus-visible { outline: 2px solid var(--mx-color-focus); outline-offset: 2px; border-radius: var(--mx-radius-medium); }
.mx-brandblock:focus:not(:focus-visible) { outline: none; }
.mx-brandblock {
	display: flex; align-items: center; gap: var(--mx-space-sm);
	padding: var(--mx-space-xs) var(--mx-space-md) var(--mx-space-md);
	text-decoration: none; color: var(--mx-color-text); min-width: 0;
}
.mx-brandmark {
	width: 34px; height: 34px; flex: none; border-radius: 12px;
	background: var(--mx-color-surface); color: var(--mx-color-primary);
	border: 1px solid var(--mx-color-border);
	display: grid; place-content: center;
}
.mx-brandmark svg { width: 22px; height: 22px; }
.mx-brandtext { display: grid; min-width: 0; }
.mx-brandtext strong { font: var(--mx-type-subheading); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-brandtext span { font: var(--mx-type-caption); color: var(--mx-color-text-muted); }

/*
 * A grid inside a flex column with `flex: 1 1 auto` inherits align-content:
 * stretch, so nine auto rows stretched to fill 100dvh and every menu item sat
 * ~110px from the next. That is the whitespace in the sidebar and the drawer.
 */
/*
 * The inner list owned the scroll, so pointing at the sidebar and scrolling the
 * page scrolled the menu instead and left it showing its last item with dead
 * space above. The sidebar as a whole scrolls now, and only if it has to.
 */
.mx-navlist { display: grid; align-content: start; gap: 2px; flex: 0 0 auto; }
.mx-navlist a {
	display: flex; align-items: center; gap: var(--mx-space-md);
	min-height: 42px; padding: 0 var(--mx-space-md);
	border-radius: var(--mx-radius-medium);
	text-decoration: none; color: var(--mx-color-text);
	font: var(--mx-type-body); font-weight: 600; position: relative;
	transition: background-color .14s ease, color .14s ease;
}
.mx-navlist a:hover { background: var(--mx-color-surface-sunken); }
.mx-navlist a[aria-current="page"] { background: var(--mx-color-primary-soft); color: var(--mx-color-primary); }
.mx-navlist a[aria-current="page"]::before {
	content: ""; position: absolute; left: -8px; top: 12px; bottom: 12px;
	width: 3px; border-radius: 3px; background: var(--mx-color-primary);
}
.mx-navlist a svg { width: 20px; height: 20px; flex: none; }
.mx-navlist .mx-badge-dot { margin-left: auto; }

.mx-navfoot {
	border-top: 1px solid var(--mx-color-border);
	margin-top: var(--mx-space-md); padding-top: var(--mx-space-md);
	display: grid; gap: var(--mx-space-sm);
}
.mx-navuser { font: var(--mx-type-caption); color: var(--mx-color-text-muted); padding-inline: var(--mx-space-md); }
.mx-navfoot .mx-btn { justify-content: flex-start; }

.mx-menubtn {
	width: 44px; height: 44px; flex: none; margin-right: var(--mx-space-sm);
	display: grid; place-content: center;
	border: 1px solid var(--mx-color-border-strong); border-radius: var(--mx-radius-medium);
	background: var(--mx-color-surface); color: var(--mx-color-text); cursor: pointer;
}
.mx-menubtn:active { transform: scale(.96); }

.mx-appmenu { position: fixed; inset: 0; z-index: 80; }
.mx-appmenu[hidden] { display: none; }
.mx-appmenu-scrim {
	position: absolute; inset: 0; background: rgba(0,0,0,.42);
	opacity: 0; transition: opacity .22s ease;
}
.mx-appmenu[data-open="true"] .mx-appmenu-scrim { opacity: 1; }
.mx-appmenu-panel {
	position: absolute; inset: 0 auto 0 0;
	width: min(320px, 88vw);
	background: var(--mx-color-background);
	border-right: 1px solid var(--mx-color-border);
	box-shadow: var(--mx-elevation-3);
	display: flex; flex-direction: column;
	padding: calc(var(--mx-space-md) + env(safe-area-inset-top)) var(--mx-space-md)
	         calc(var(--mx-space-md) + env(safe-area-inset-bottom));
	transform: translateX(-100%);
	transition: transform .24s cubic-bezier(.22,.68,.36,1);
}
.mx-appmenu[data-open="true"] .mx-appmenu-panel { transform: none; }
.mx-appmenu-head { display: flex; align-items: flex-start; gap: var(--mx-space-sm); }
.mx-appmenu-head .mx-brandblock { flex: 1 1 auto; padding-bottom: var(--mx-space-md); }
.mx-appmenu .mx-navlist a { min-height: 48px; font-size: .9375rem; }
body.mx-menu-open { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
	.mx-appmenu-panel, .mx-appmenu-scrim { transition: none; }
}

/* The navigation block above is appended after the main breakpoint block, so
   the wide-screen rules have to be restated here to win on source order. */
@media (min-width: 900px) {
	.mx-sidebar { display: flex; }
	.mx-menubtn { display: none; }
	.mx-bottomnav { display: none; }
	.mx-appmenu { display: none; }
}
.mx-appmenu-panel:focus { outline: none; }

/* A bare number in a circle read as an id. It is the day the session unlocks. */
.mx-avatar--day { display: grid; place-content: center; line-height: 1; gap: 1px; }
.mx-avatar--day em {
	display: block; font-style: normal; font-size: .5rem; font-weight: 700;
	letter-spacing: .08em; text-transform: uppercase; opacity: .7;
}

.mx-segmented { display: flex; gap: 4px; background: var(--mx-color-surface-sunken); padding: 4px; border-radius: var(--mx-radius-medium); }
.mx-segmented button {
	flex: 1; min-height: 36px; border: 0; border-radius: calc(var(--mx-radius-medium) - 3px);
	background: transparent; color: var(--mx-color-text-muted);
	font: var(--mx-type-body); font-weight: 650; cursor: pointer;
}
.mx-segmented button[aria-selected="true"] { background: var(--mx-color-surface); color: var(--mx-color-text); box-shadow: var(--mx-elevation-1); }
.mx-count { font-family: var(--mx-font-num); font-size: .75rem; opacity: .7; margin-left: 4px; }

.mx-review-row {
	width: 100%; text-align: left; border: 0; background: transparent;
	padding: 10px 0; border-bottom: 1px solid var(--mx-color-border); cursor: pointer;
}
.mx-review-row:last-child { border-bottom: 0; }
.mx-review-row:hover { color: var(--mx-color-primary); }
.mx-review-edit { font-size: .75rem; font-weight: 700; color: var(--mx-color-primary); flex: none; }


/* ============================================================== controls == */
/*
 * The attention filters were raw browser selects sitting beside styled inputs.
 * One control style, one height, one border.
 */
.mx-select, .mx-site select.mx-select {
	appearance: none; -webkit-appearance: none;
	width: 100%; min-height: 40px;
	padding: 0 34px 0 var(--mx-space-md);
	border: 1px solid var(--mx-color-border-strong);
	border-radius: var(--mx-radius-medium);
	background-color: var(--mx-color-surface);
	background-image: linear-gradient(45deg, transparent 50%, var(--mx-color-text-muted) 50%),
	                  linear-gradient(135deg, var(--mx-color-text-muted) 50%, transparent 50%);
	background-position: calc(100% - 18px) 17px, calc(100% - 13px) 17px;
	background-size: 5px 5px, 5px 5px;
	background-repeat: no-repeat;
	color: var(--mx-color-text); font: var(--mx-type-body); cursor: pointer;
}
.mx-select:focus-visible { outline: 3px solid var(--mx-color-focus); outline-offset: 2px; }
.mx-filters { display: flex; flex-wrap: wrap; gap: var(--mx-space-sm); }
.mx-filters .mx-select { width: auto; min-width: 148px; flex: 0 1 auto; }

/* Settings rows were oversized blocks; make them a compact list. */
.mx-settings-card { padding: var(--mx-space-lg); }
.mx-settings-card .mx-field { margin-bottom: var(--mx-space-md); }
.mx-settings-card .mx-field:last-child { margin-bottom: 0; }
.mx-radio-card { min-height: 40px; padding: 0 var(--mx-space-md); align-items: center; }
.mx-radio-card span { font: var(--mx-type-body); }

/* =============================================================== records == */

.mx-rec-row { padding: 8px 0; border-bottom: 1px solid var(--mx-color-border); gap: var(--mx-space-md); }
.mx-rec-row:last-of-type { border-bottom: 0; }
.mx-num--flag { color: var(--mx-color-warning); font-weight: 700; }
.mx-avatar { font-size: .6875rem; font-weight: 700; letter-spacing: .02em; }


/* ------------------------------------------------- compact filter rows --- */
/*
 * Members had a search box, a sort select and a role select each on its own
 * line, which pushed the actual list off the first screen on a phone.
 */
.mx-toolbar { display: flex; flex-wrap: wrap; gap: var(--mx-space-sm); align-items: center; }
.mx-toolbar > .mx-input { flex: 1 1 180px; min-width: 0; }
.mx-toolbar > .mx-select { flex: 0 1 auto; min-width: 128px; width: auto; }
.mx-toolbar .mx-count-label { font: var(--mx-type-caption); color: var(--mx-color-text-muted); white-space: nowrap; }
.mx-input, .mx-select { min-height: 40px; }
.mx-input { padding: 0 var(--mx-space-md); }

/* Lists sat flush against the panel edge on every staff screen. */
.mx-list { display: grid; gap: var(--mx-space-sm); }
.mx-list > .mx-item, .mx-list > .mx-item-row { margin: 0; }
.mx-item { padding: var(--mx-space-md); border-radius: var(--mx-radius-medium); }
.mx-segmented + .mx-input, .mx-segmented + .mx-select { margin-top: var(--mx-space-sm); }
.mx-eyebrow + .mx-list { margin-top: var(--mx-space-xs); }

.mx-avatar-img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; flex: none; border: 1px solid var(--mx-color-border); }


/* ------------------------------------------------- spacing after filters -- */
/*
 * A filter row sat flush against the list it filtered, on every staff screen.
 * One rule rather than a margin sprinkled through the markup.
 */
.mx-toolbar + .mx-list,
.mx-toolbar + .mx-empty,
.mx-input + .mx-list,
.mx-select + .mx-list,
.mx-filters + .mx-list,
.mx-field + .mx-list,
.mx-segmented + .mx-list { margin-top: var(--mx-space-lg); }
.mx-field + .mx-empty, .mx-toolbar + .mx-stack { margin-top: var(--mx-space-lg); }

/* Compact controls: the members toolbar was rendering at full input height on
   two lines and taking most of the first screen. */
.mx-toolbar { row-gap: var(--mx-space-sm); }
.mx-toolbar > .mx-input, .mx-toolbar > .mx-select { min-height: 36px; font-size: .875rem; }
.mx-toolbar > .mx-select { min-width: 118px; padding-right: 28px; background-position: calc(100% - 15px) 15px, calc(100% - 10px) 15px; }
@media (max-width: 420px) {
	.mx-toolbar > .mx-input { flex: 1 1 100%; }
	.mx-toolbar > .mx-select { flex: 1 1 calc(50% - var(--mx-space-sm)); min-width: 0; }
}
.mx-toolbar .mx-count-label { flex: 0 0 auto; margin-left: auto; }

/* ================================================================ review == */
/*
 * Meal photos were rendering at natural size, which for a phone camera is
 * enormous. Fixed tiles, cropped, so a queue of forty is scannable.
 */
.mx-review-grid { display: grid; gap: var(--mx-space-md); grid-template-columns: 1fr; }
@media (min-width: 700px) { .mx-review-grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1200px) { .mx-review-grid { grid-template-columns: repeat(3, 1fr); } }
.mx-review-card { display: flex; flex-direction: column; gap: var(--mx-space-md); padding: var(--mx-space-md); }
.mx-review-img {
	width: 100%; height: 180px; object-fit: cover;
	border-radius: var(--mx-radius-medium); background: var(--mx-color-surface-sunken); display: block;
}
.mx-review-doc {
	display: flex; align-items: center; justify-content: center;
	height: 72px; border-radius: var(--mx-radius-medium);
	background: var(--mx-color-surface-sunken); color: var(--mx-color-text-muted);
	font-weight: 700; font-size: .75rem; letter-spacing: .06em; text-decoration: none;
}
.mx-review-body { display: grid; gap: var(--mx-space-sm); }
.mx-review-notes { border-left: 2px solid var(--mx-color-border); padding-left: var(--mx-space-md); }
.mx-review-note { display: grid; gap: 2px; font: var(--mx-type-small); }
.mx-link { border: 0; background: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; }

/* A member's own meal photo, also capped. */
.mx-meal-img { width: 100%; max-height: 320px; object-fit: cover; border-radius: var(--mx-radius-medium); display: block; }

/* ------------------------------------------------------------------ bmi --- */
/*
 * Six equal cells with the labels shrunk to 9px was unreadable and implied the
 * bands are equal widths, which they are not. This is a proportional scale with
 * a marker where the reader actually sits, and a legend underneath.
 */
.mx-body-grid { display: grid; gap: var(--mx-space-md); grid-template-columns: repeat(3, 1fr); }
@media (max-width: 560px) { .mx-body-grid { grid-template-columns: 1fr 1fr; } }

.mx-bmi { display: grid; gap: var(--mx-space-lg); }
.mx-bmi-head { display: flex; align-items: baseline; gap: var(--mx-space-md); }
.mx-bmi-value { font: var(--mx-type-display); font-size: 2.75rem; line-height: 1; font-variant-numeric: tabular-nums; }
.mx-bmi-band-name { font: var(--mx-type-subheading); color: var(--mx-color-text-muted); }

.mx-bmi-scale { position: relative; height: 12px; border-radius: 999px; overflow: hidden; display: flex; }
.mx-bmi-seg { height: 100%; }
.mx-bmi-seg[data-band="under"]      { background: var(--mx-bmi-under); }
.mx-bmi-seg[data-band="healthy"]    { background: var(--mx-color-success); }
.mx-bmi-seg[data-band="overweight"] { background: var(--mx-bmi-over); }
.mx-bmi-seg[data-band="obese1"]     { background: var(--mx-bmi-obese1); }
.mx-bmi-seg[data-band="obese2"]     { background: var(--mx-bmi-obese2); }
.mx-bmi-seg[data-band="obese3"]     { background: var(--mx-bmi-obese3); }

.mx-bmi-marker {
	position: absolute; top: -4px; width: 3px; height: 20px; border-radius: 2px;
	background: var(--mx-color-text); transform: translateX(-50%);
	box-shadow: 0 0 0 2px var(--mx-color-surface);
}
.mx-bmi-legend { display: flex; justify-content: space-between; font: var(--mx-type-caption); color: var(--mx-color-text-faint); }
.mx-bmi-note { font: var(--mx-type-body); color: var(--mx-color-text-muted); }
.mx-bmi-fine { font: var(--mx-type-small); color: var(--mx-color-text-faint); }

.mx-care-notes { border-left: 2px solid var(--mx-color-primary); padding-left: var(--mx-space-md); margin-top: var(--mx-space-sm); display: grid; gap: var(--mx-space-sm); }
.mx-care-note { display: grid; gap: 2px; font: var(--mx-type-small); }

.mx-weight-log { max-height: 220px; overflow-y: auto; }

.mx-push-row { display: flex; flex-wrap: wrap; gap: var(--mx-space-sm); align-items: center; padding-top: var(--mx-space-sm); border-top: 1px solid var(--mx-color-border); }
.mx-push-row p { flex: 1 1 100%; margin: 0; }

/* ============================================================= catalogue == */
.mx-explore {
	display: flex; align-items: center; gap: var(--mx-space-md); width: 100%;
	text-align: left; border: 1px solid var(--mx-color-border); cursor: pointer;
	padding: var(--mx-space-lg); background: var(--mx-color-surface);
}
.mx-explore:hover { border-color: var(--mx-color-primary); }
.mx-explore-body { display: grid; gap: 4px; flex: 1; min-width: 0; }
.mx-explore-name { font: var(--mx-type-subheading); color: var(--mx-color-text); }
.mx-explore-tag { font: var(--mx-type-body); color: var(--mx-color-text-muted); }
.mx-explore-meta { font: var(--mx-type-caption); color: var(--mx-color-text-faint); }

/* The safety notice is a panel, not fine print under a button. */
.mx-safety {
	border-left: 3px solid var(--mx-color-warning); padding: var(--mx-space-md) var(--mx-space-lg);
	background: var(--mx-color-surface-sunken); border-radius: 0 var(--mx-radius-medium) var(--mx-radius-medium) 0;
	display: grid; gap: var(--mx-space-sm);
}
.mx-safety--plain { border-left-color: var(--mx-color-border-strong); }
.mx-safety p { margin: 0; font: var(--mx-type-body); color: var(--mx-color-text-muted); }
.mx-consent-text {
	max-height: 240px; overflow-y: auto; padding: var(--mx-space-md);
	background: var(--mx-color-surface-sunken); border-radius: var(--mx-radius-medium);
	font: var(--mx-type-small); color: var(--mx-color-text-muted); white-space: pre-wrap;
}
