/* ==========================================================================
   BFA UI — design system stylesheet  ·  v2.0  ·  Butterfly Agency (BFA)
   One file, no build step. Tokens → base → layout → components → utilities.
   Written with logical properties (inline-start/end) so dir="rtl" just works.
   ========================================================================== */

/* ---------- 0. Fonts (self-hosted, paths relative to this file) ---------- */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-latin-var.woff2") format("woff2-variations"), url("fonts/inter-latin-var.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-latin-ext-var.woff2") format("woff2-variations"), url("fonts/inter-latin-ext-var.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter";
  font-style: italic;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-latin-var-italic.woff2") format("woff2-variations"), url("fonts/inter-latin-var-italic.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2212, U+FEFF, U+FFFD;
}
/* Vazirmatn — Arabic-script face; covers every Sorani Kurdish letter (ڕ ڵ ۆ ێ ە ڤ پ چ ژ گ). */
@font-face { font-family: "Vazirmatn"; font-weight: 400; font-display: swap; size-adjust: 106%; src: url("fonts/vazirmatn-arabic-400.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Vazirmatn"; font-weight: 500; font-display: swap; size-adjust: 106%; src: url("fonts/vazirmatn-arabic-500.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Vazirmatn"; font-weight: 600; font-display: swap; size-adjust: 106%; src: url("fonts/vazirmatn-arabic-600.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }
@font-face { font-family: "Vazirmatn"; font-weight: 700; font-display: swap; size-adjust: 106%; src: url("fonts/vazirmatn-arabic-700.woff2") format("woff2"); unicode-range: U+0600-06FF, U+0750-077F, U+0870-088E, U+0890-0891, U+0897-08E1, U+08E3-08FF, U+200C-200E, U+2010-2011, U+204F, U+2E41, U+FB50-FDFF, U+FE70-FE74, U+FE76-FEFC; }

/* ---------- 1. Tokens ---------- */
:root {
  color-scheme: light;

  /* 1a. Primitives — neutral (cool zinc) */
  --gray-0: #ffffff;
  --gray-25: #fbfbfc;
  --gray-50: #f7f7f8;
  --gray-75: #eef0f3;        /* canvas behind surface cards (v2) */
  --gray-100: #f1f1f3;
  --gray-150: #ebebee;
  --gray-200: #e3e3e7;
  --gray-300: #d1d1d6;
  --gray-400: #9b9fa8;
  --gray-500: #5f636d;
  --gray-600: #474b54;
  --gray-700: #33363d;
  --gray-800: #202227;
  --gray-900: #121316;
  --gray-950: #0a0a0c;

  /* 1b. Primitives — hues (500 = graphics/dots, 600 = text/icons on white, 50/200 = tints & soft lines) */
  --blue-50: #e9f0ff;  --blue-200: #c7d6fd; --blue-500: #3b6cf6; --blue-600: #2556e0; --blue-700: #1d44b8;
  --green-50: #e4f7ec; --green-200: #b5ecc8; --green-500: #22a55b; --green-600: #157f45; --green-700: #116537;
  --amber-50: #fff3df; --amber-200: #fde3a7; --amber-500: #f59e0b; --amber-600: #b45309; --amber-700: #92400e;
  --red-50: #fde9e9;   --red-200: #fecaca;   --red-500: #ef4444;   --red-600: #d42020;   --red-700: #b01b1b;
  --violet-50: #f0e9fe; --violet-500: #8b5cf6; --violet-600: #7041e0;
  --pink-50: #fde8f2; --pink-500: #ec4899;   --teal-500: #14b8a6;   --orange-500: #f97316; --sky-500: #0ea5e9;

  /* 1c. Semantic surfaces — white is the only static surface. Fills below are for STATE only. */
  --bg: var(--gray-0);
  --bg-hover: var(--gray-50);        /* pointer over a row / ghost control */
  --bg-selected: var(--gray-100);    /* current nav item, selected row, active segment track */
  --bg-pressed: var(--gray-150);     /* :active */
  --bg-muted: var(--gray-50);        /* kbd, skeleton base, disabled input */
  /* v2 surface layer (opt-in, see §24): a grey canvas with white cards, soft fills inside cards */
  --bg-canvas: var(--gray-75);       /* page background when .page--canvas / .app--canvas is used */
  --bg-soft: var(--gray-50);         /* soft card fill, floating-label field, inactive chip */
  --bg-fill: var(--gray-150);        /* choice card, soft button, wheel lines */
  --bg-inverse: var(--gray-900);     /* primary button, tooltip, solid badge */
  --bg-inverse-hover: var(--gray-800);
  --backdrop: rgba(14, 14, 16, 0.32);

  /* 1d. Semantic text */
  --text: var(--gray-900);           /* titles, names, primary labels      17.7:1 */
  --text-2: var(--gray-600);         /* body copy, secondary labels         7.7:1 */
  --text-3: var(--gray-500);         /* meta, timestamps, helper text       5.4:1 (4.8 on --bg-selected) */
  --text-4: var(--gray-400);         /* placeholder, disabled (never for meaning) */
  --text-inverse: var(--gray-0);
  --text-link: var(--blue-600);

  /* 1e. Lines */
  --line: var(--gray-150);           /* hairline separators */
  --line-control: var(--gray-200);   /* input / outline-button border */
  --line-strong: var(--gray-300);    /* hover border, checkbox border */
  --line-selected: var(--gray-900);  /* framed list item when selected */
  --line-check: #8a8a93;             /* checkbox / radio border, switch off-track — 3.4:1 non-text contrast */

  /* 1f. Intent */
  --accent: var(--blue-600);
  --accent-dot: var(--blue-500);     /* unread dot, live indicator */
  --focus: var(--blue-600);
  --focus-ring: 0 0 0 3px rgba(37, 86, 224, 0.2);
  --success: var(--green-600); --success-dot: var(--green-500); --success-line: var(--green-200); --success-tint: var(--green-50);
  --warning: var(--amber-600); --warning-dot: var(--amber-500); --warning-line: var(--amber-200); --warning-tint: var(--amber-50);
  --danger: var(--red-600);    --danger-dot: var(--red-500);    --danger-line: var(--red-200);    --danger-tint: var(--red-50);
  --info: var(--blue-600);     --info-dot: var(--blue-500);     --info-line: var(--blue-200);     --info-tint: var(--blue-50);
  --danger-ring: 0 0 0 3px rgba(212, 32, 32, 0.16);
  --accent-tint: var(--blue-50);     /* v2: tinted tile / badge behind accent icons */
  --violet: var(--violet-600); --violet-dot: var(--violet-500); --violet-tint: var(--violet-50);
  --pink: var(--pink-500);     --pink-dot: var(--pink-500);     --pink-tint: var(--pink-50);
  --on-accent: #ffffff;              /* text on an --accent fill */
  --on-danger: #ffffff;              /* text on a --danger fill (danger button) */
  --danger-hover: var(--red-700);

  /* 1g. Label / tag colours (dots and icon glyphs only, never fills) */
  --label-red: var(--red-500); --label-orange: var(--orange-500); --label-amber: var(--amber-500);
  --label-green: var(--green-500); --label-teal: var(--teal-500); --label-blue: var(--blue-500);
  --label-violet: var(--violet-500); --label-pink: var(--pink-500); --label-gray: var(--gray-400);

  /* 1h. Brand slot — swap per project. Default: ink. */
  --brand: var(--gray-900);
  --brand-contrast: var(--gray-0);

  /* 1i. Typography */
  --font-latin: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-arabic: "Vazirmatn", "Inter", "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif;
  --font-sans: "Inter", "Vazirmatn", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --text-2xs: 0.6875rem;  /* 11 — tags, micro labels */
  --text-xs: 0.75rem;     /* 12 — meta, counts, timestamps */
  --text-sm: 0.8125rem;   /* 13 — default control & list text */
  --text-base: 0.875rem;  /* 14 — body, labels, names */
  --text-md: 0.9375rem;   /* 15 — long-form reading */
  --text-lg: 1rem;        /* 16 — dialog & section titles */
  --text-xl: 1.125rem;    /* 18 — pane titles */
  --text-2xl: 1.25rem;    /* 20 — page titles, message subject */
  --text-3xl: 1.5rem;     /* 24 — settings H1 */
  --text-4xl: 1.875rem;   /* 30 — KPI numbers, auth heading */
  --text-5xl: 2.75rem;    /* 44 — v2 hero amounts (contract value, fare) */
  --text-6xl: 4rem;       /* 64 — v2 display figures (temperature) */

  --lh-2xs: 14px; --lh-xs: 16px; --lh-sm: 18px; --lh-base: 20px; --lh-md: 24px;
  --lh-lg: 24px;  --lh-xl: 26px; --lh-2xl: 28px; --lh-3xl: 32px; --lh-4xl: 38px; --lh-5xl: 48px; --lh-6xl: 64px;
  --lh-prose: 1.7;

  --weight-regular: 400; --weight-medium: 500; --weight-semibold: 600; --weight-bold: 700;

  --tracking-tight: -0.02em;   /* ≥ 24px */
  --tracking-snug: -0.011em;   /* 16–20px */
  --tracking-normal: -0.003em; /* body */
  --tracking-caps: 0.04em;     /* uppercase micro labels */

  /* 1j. Space (4px grid) */
  --space-0: 0; --space-px: 1px; --space-0-5: 2px; --space-1: 4px; --space-1-5: 6px; --space-2: 8px;
  --space-2-5: 10px; --space-3: 12px; --space-4: 16px; --space-5: 20px; --space-6: 24px; --space-8: 32px;
  --space-10: 40px; --space-12: 48px; --space-16: 64px; --space-20: 80px;

  /* 1k. Radius */
  --radius-xs: 4px;   /* tags, kbd, checkbox, count in dark tab */
  --radius-sm: 6px;   /* nav items, tabs, segments, small buttons, menu items */
  --radius-md: 8px;   /* buttons, inputs, list items, file tiles, icon buttons */
  --radius-lg: 10px;  /* menus, popovers, callouts, toasts */
  --radius-xl: 12px;  /* dialogs, floating composer */
  --radius-2xl: 16px; /* v2 surface cards, option cards */
  --radius-3xl: 24px; /* v2 hero cards, bottom sheet */
  --radius-full: 999px;

  /* 1l. Control heights */
  --h-xs: 24px; --h-sm: 28px; --h-md: 32px; --h-lg: 36px; --h-xl: 40px; --h-2xl: 44px; --h-3xl: 52px; /* 2xl/3xl: v2 pill CTAs, mobile */

  /* 1m. Elevation — floating layers only, never static content */
  --shadow-xs: 0 1px 2px rgba(16, 16, 20, 0.05);
  --shadow-sm: 0 1px 3px rgba(16, 16, 20, 0.07), 0 1px 2px rgba(16, 16, 20, 0.04);
  --shadow-md: 0 8px 20px -6px rgba(16, 16, 20, 0.12), 0 2px 6px -2px rgba(16, 16, 20, 0.06);
  --shadow-lg: 0 20px 48px -12px rgba(16, 16, 20, 0.2), 0 6px 14px -6px rgba(16, 16, 20, 0.08);
  --inset-highlight: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  --shadow-card: 0 1px 2px rgba(16, 16, 20, 0.04), 0 10px 28px -14px rgba(16, 16, 20, 0.14); /* v2 surface cards */

  /* 1n. Motion */
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --dur-1: 100ms;  /* colour / background on hover */
  --dur-2: 160ms;  /* menus, popovers, toggles */
  --dur-3: 220ms;  /* dialogs, drawers, toasts */
  --dur-4: 320ms;  /* page-level panels */

  /* 1o. Layout */
  --rail-w: 56px;
  --sidebar-w: 248px;
  --topbar-h: 52px;
  --toolbar-h: 44px;
  --list-w: 360px;
  --reading-max: 720px;
  --content-max: 1200px;
  --page-pad: 24px;
  --phone-w: 375px; --phone-h: 812px;  /* v2 phone preview frame */

  /* 1p. Z-index */
  --z-sticky: 10; --z-header: 20; --z-dropdown: 50; --z-drawer: 70; --z-modal: 80; --z-toast: 90; --z-tooltip: 100;

  /* 1q. Icon */
  --icon-stroke: 1.75;
  --icon-stroke-bold: 2.1;   /* v2 canvas & mobile */
}

/* Arabic-script languages: Sorani (ckb), Arabic (ar), Persian (fa), Badini written in Arabic script (kmr-Arab) */
:lang(ckb), :lang(ar), :lang(fa), :lang(kmr-Arab) {
  --font-sans: "Vazirmatn", "Inter", "Segoe UI", Tahoma, sans-serif;
  --tracking-tight: 0; --tracking-snug: 0; --tracking-normal: 0; --tracking-caps: 0;
  --lh-2xs: 18px; --lh-xs: 20px; --lh-sm: 22px; --lh-base: 24px; --lh-md: 28px;
  --lh-lg: 28px; --lh-xl: 30px; --lh-2xl: 32px; --lh-3xl: 38px; --lh-4xl: 44px;
  --lh-prose: 1.9;
}

/* Optional dark theme — opt-in only: <html data-theme="dark">. Default product theme is light/white. */
[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0f11;
  --bg-hover: #17171a;
  --bg-selected: #1e1e22;
  --bg-pressed: #26262b;
  --bg-muted: #17171a;
  --bg-canvas: #0a0a0c; --bg-soft: #17171a; --bg-fill: #26262b; --shadow-card: 0 10px 28px -14px rgba(0, 0, 0, 0.6);
  --bg-inverse: #f4f4f5;
  --bg-inverse-hover: #e4e4e7;
  --backdrop: rgba(0, 0, 0, 0.56);
  --text: #f4f4f5;
  --text-2: #b8b8c0;
  --text-3: #8e8e97;
  --text-4: #62626b;
  --text-inverse: #0f0f11;
  --text-link: #7d9bff;
  --line: #222226;
  --line-control: #2c2c31;
  --line-strong: #3a3a41;
  --line-selected: #f4f4f5;
  --line-check: #6a6a74;
  --accent: #7d9bff; --accent-dot: #5b80ff; --focus: #7d9bff; --focus-ring: 0 0 0 3px rgba(125, 155, 255, 0.28);
  --success: #4ccd85; --success-line: #1d4a31; --success-tint: #0f2219;
  --warning: #f3b440; --warning-line: #4d3812; --warning-tint: #241a08;
  --danger: #ff6b6b;  --danger-line: #4f1f1f; --danger-tint: #261010;
  --info: #7d9bff;    --info-line: #24305a;   --info-tint: #11162a;
  --accent-tint: #11162a; --violet: #b494ff; --violet-tint: #1c1430; --pink: #ff7ab8; --pink-tint: #2a1420;
  --on-accent: #0f0f11; --on-danger: #170707; --danger-hover: #ff8585;
  --brand: #f4f4f5; --brand-contrast: #0f0f11;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 10px 24px -6px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.04);
  --shadow-lg: 0 24px 56px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.05);
  --inset-highlight: none;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; tab-size: 4; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--lh-base);
  letter-spacing: var(--tracking-normal);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd { margin: 0; }
h1, h2, h3, h4, h5, h6 { font-weight: var(--weight-semibold); color: var(--text); }
ul[role="list"], ol[role="list"], .list-reset { list-style: none; margin: 0; padding: 0; }
img, svg, video, canvas { display: block; max-width: 100%; }
img { height: auto; }
input, button, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
button:disabled, [aria-disabled="true"] { cursor: not-allowed; }
a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
hr { border: 0; border-block-start: 1px solid var(--line); margin: 0; }
::selection { background: var(--blue-200); color: var(--gray-900); }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-xs); }
[hidden] { display: none !important; }
code, kbd, samp, pre { font-family: var(--font-mono); font-size: 0.92em; }
table { border-collapse: collapse; }

/* Directional content inside RTL pages: wrap emails, URLs, phone numbers, code in <bdi> or dir="ltr". */
.ltr { direction: ltr; unicode-bidi: isolate; }
[dir="rtl"] .ltr { text-align: right; } /* a block of LTR text still starts on the RTL side */
bdi { unicode-bidi: isolate; }
.num, .tabular { font-variant-numeric: tabular-nums; }

/* ---------- 3. Icons ---------- */
.icon {
  inline-size: 16px; block-size: 16px;
  flex: none;
  fill: none; stroke: currentColor; stroke-width: var(--icon-stroke);
  stroke-linecap: round; stroke-linejoin: round;
  vertical-align: middle;
}
.icon--xs { inline-size: 12px; block-size: 12px; stroke-width: 2; }
.icon--sm { inline-size: 14px; block-size: 14px; stroke-width: 1.9; }
.icon--md { inline-size: 18px; block-size: 18px; }
.icon--lg { inline-size: 20px; block-size: 20px; }
.icon--xl { inline-size: 24px; block-size: 24px; stroke-width: 1.5; }
.icon--2xl { inline-size: 32px; block-size: 32px; stroke-width: 1.4; }
/* Directional glyphs (chevron-left/right, arrow-left/right, reply, forward, undo, redo, send, log-in/out) */
[dir="rtl"] .icon--flip { transform: scaleX(-1); }

/* ---------- 4. Typography styles ---------- */
.t-display { font-size: var(--text-4xl); line-height: var(--lh-4xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tight); }
.t-h1 { font-size: var(--text-3xl); line-height: var(--lh-3xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tight); }
.t-h2 { font-size: var(--text-2xl); line-height: var(--lh-2xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-snug); }
.t-h3 { font-size: var(--text-xl); line-height: var(--lh-xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-snug); }
.t-h4 { font-size: var(--text-lg); line-height: var(--lh-lg); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-snug); }
.t-h5 { font-size: var(--text-base); line-height: var(--lh-base); font-weight: var(--weight-semibold); }
.t-body { font-size: var(--text-base); line-height: var(--lh-base); }
.t-small { font-size: var(--text-sm); line-height: var(--lh-sm); }
.t-caption { font-size: var(--text-xs); line-height: var(--lh-xs); }
.t-micro { font-size: var(--text-2xs); line-height: var(--lh-2xs); font-weight: var(--weight-medium); letter-spacing: var(--tracking-caps); text-transform: uppercase; }
.t-mono { font-family: var(--font-mono); font-size: var(--text-sm); }
.t-medium { font-weight: var(--weight-medium); }
.t-semibold { font-weight: var(--weight-semibold); }
.t-1 { color: var(--text); } .t-2 { color: var(--text-2); } .t-3 { color: var(--text-3); } .t-4 { color: var(--text-4); }
.t-success { color: var(--success); } .t-warning { color: var(--warning); } .t-danger { color: var(--danger); } .t-accent { color: var(--accent); }

.prose { font-size: var(--text-base); line-height: var(--lh-prose); color: var(--text-2); max-inline-size: 68ch; }
.prose > * + * { margin-block-start: 12px; }
.prose h2, .prose h3 { color: var(--text); margin-block-start: 24px; }
.prose h2 { font-size: var(--text-lg); line-height: var(--lh-lg); }
.prose h3 { font-size: var(--text-base); line-height: var(--lh-base); }
.prose strong { color: var(--text); font-weight: var(--weight-semibold); }
.prose ul, .prose ol { padding-inline-start: 20px; margin-block: 0; }
.prose li + li { margin-block-start: 4px; }
.prose blockquote { border-inline-start: 2px solid var(--line-strong); padding-inline-start: 12px; color: var(--text-3); }
.prose code { background: var(--bg-muted); border: 1px solid var(--line); border-radius: var(--radius-xs); padding: 1px 4px; color: var(--text); }
.prose a { text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--blue-200); }
.prose a.file, .prose a.btn, .prose .file a { text-decoration: none; }

/* ---------- 5. App shell ---------- */
.app {
  display: grid;
  grid-template-columns: auto 1fr;
  block-size: 100dvh;
  overflow: hidden;
  background: var(--bg);
}
.app__main { display: flex; flex-direction: column; min-inline-size: 0; min-block-size: 0; }
.app__body { flex: 1; display: flex; min-block-size: 0; }

/* 5a. Rail — icon-only primary nav (reference 1) */
.rail {
  inline-size: var(--rail-w);
  display: flex; flex-direction: column; align-items: center;
  gap: 4px;
  padding-block: 12px;
  border-inline-end: 1px solid var(--line);
  background: var(--bg);
}
.rail__logo { display: grid; place-items: center; inline-size: 32px; block-size: 32px; margin-block-end: 12px; color: var(--brand); }
.rail__group { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.rail__spacer { flex: 1; }
.rail__item {
  position: relative;
  display: grid; place-items: center;
  inline-size: 36px; block-size: 36px;
  border-radius: var(--radius-md);
  color: var(--text-3);
  transition: background var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
}
.rail__item .icon { inline-size: 18px; block-size: 18px; }
.rail__item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.rail__item[aria-current="page"], .rail__item.is-active { background: var(--bg-selected); color: var(--text); }
.rail__item .dot { position: absolute; inset-block-start: 7px; inset-inline-end: 7px; box-shadow: 0 0 0 2px var(--bg); }

/* 5b. Sidebar — labelled nav (reference 2) */
.sidebar {
  inline-size: var(--sidebar-w);
  display: flex; flex-direction: column;
  border-inline-end: 1px solid var(--line);
  background: var(--bg);
  min-block-size: 0;
}
.sidebar__header { display: flex; align-items: center; gap: 8px; padding: 14px 12px 10px; }
.sidebar__search { padding: 0 12px 8px; }
.sidebar__scroll { flex: 1; overflow-y: auto; padding: 4px 12px 12px; }
.sidebar__footer { padding: 8px 12px 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar__footer > hr { margin-block: 8px; }
.workspace {
  flex: 1; min-inline-size: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 4px 6px; margin-inline-start: -6px;
  border-radius: var(--radius-sm);
  text-align: start;
}
.workspace:hover { background: var(--bg-hover); }
.workspace__mark { inline-size: 24px; block-size: 24px; border-radius: var(--radius-sm); display: grid; place-items: center; background: var(--brand); color: var(--brand-contrast); flex: none; }
.workspace__mark .icon { inline-size: 14px; block-size: 14px; stroke-width: 2.25; }
.workspace__name { font-size: var(--text-base); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-snug); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav + .nav-section, .nav-section + .nav-section { margin-block-start: 16px; }
.nav-section__label {
  display: flex; align-items: center; gap: 4px;
  block-size: 28px; padding-inline: 8px;
  font-size: var(--text-2xs); font-weight: var(--weight-medium); letter-spacing: var(--tracking-caps); text-transform: uppercase;
  color: var(--text-4);
  inline-size: 100%;
}
button.nav-section__label:hover { color: var(--text-3); }
.nav-section__label .icon { inline-size: 12px; block-size: 12px; transition: transform var(--dur-2) var(--ease-out); }
.nav-section__label[aria-expanded="false"] .icon { transform: rotate(-90deg); }
[dir="rtl"] .nav-section__label[aria-expanded="false"] .icon { transform: rotate(90deg); }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  block-size: 32px; padding-inline: 8px;
  border-radius: var(--radius-sm);
  font-size: var(--text-base); color: var(--text-2);
  text-decoration: none;
  transition: background var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
  inline-size: 100%;
  text-align: start;
}
.nav-item .icon { color: var(--text-3); }
.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item:hover .icon { color: var(--text-2); }
.nav-item[aria-current="page"], .nav-item.is-active { background: var(--bg-selected); color: var(--text); font-weight: var(--weight-medium); }
.nav-item[aria-current="page"] .icon, .nav-item.is-active .icon { color: var(--text); }
.nav-item__label { flex: 1; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item__meta { font-size: var(--text-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.nav-item__swatch { inline-size: 8px; block-size: 8px; border-radius: 2px; margin-inline: 4px; flex: none; }

.user-row { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: var(--radius-sm); inline-size: 100%; text-align: start; }
.user-row:hover { background: var(--bg-hover); }
.user-row__name { flex: 1; min-inline-size: 0; font-size: var(--text-sm); font-weight: var(--weight-medium); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row .icon { color: var(--text-3); }

/* 5c. Topbar */
.topbar {
  display: flex; align-items: center; gap: 12px;
  block-size: var(--topbar-h); flex: none;
  padding-inline: 16px;
  border-block-end: 1px solid var(--line);
  background: var(--bg);
}
.topbar__title { display: flex; align-items: center; gap: 8px; font-size: var(--text-base); font-weight: var(--weight-semibold); min-inline-size: 0; }
.topbar__title .icon { color: var(--text-2); }
.topbar__spacer { flex: 1; }
.topbar__actions { display: flex; align-items: center; gap: 8px; }

/* 5d. Page header (inside a pane or page) */
.page-header { display: flex; align-items: center; gap: 16px; padding: 16px var(--page-pad); min-block-size: 64px; }
.page-header__text { flex: 1; min-inline-size: 0; }
.page-header__title { font-size: var(--text-2xl); line-height: var(--lh-2xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-snug); }
.page-header__desc { font-size: var(--text-sm); line-height: var(--lh-sm); color: var(--text-3); margin-block-start: 2px; }
.page-header__actions { display: flex; align-items: center; gap: 8px; }
.subbar { display: flex; align-items: center; gap: 12px; padding: 0 var(--page-pad); min-block-size: 48px; border-block-end: 1px solid var(--line); }

/* 5e. Panes */
.pane { display: flex; flex-direction: column; min-inline-size: 0; min-block-size: 0; background: var(--bg); }
.pane--list { inline-size: var(--list-w); flex: none; border-inline-end: 1px solid var(--line); }
.pane--detail { flex: 1; }
.pane__scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.pane__header { padding: 12px 16px; }
.pane__footer { padding: 12px 16px; border-block-start: 1px solid var(--line); }
.page { flex: 1; overflow-y: auto; }
.page__inner { max-inline-size: var(--content-max); margin-inline: auto; padding: 0 var(--page-pad) 48px; }
.page__inner--narrow { max-inline-size: 760px; }

/* ---------- 6. Buttons ---------- */
.btn {
  --btn-h: var(--h-md);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  block-size: var(--btn-h); padding-inline: 12px;
  border: 1px solid transparent; border-radius: var(--radius-md);
  font-size: var(--text-sm); font-weight: var(--weight-medium); line-height: 1;
  white-space: nowrap; user-select: none;
  text-decoration: none;
  transition: background var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
  position: relative;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--focus-ring); border-color: var(--focus); }
.btn .icon { inline-size: 16px; block-size: 16px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }

.btn--primary { background: var(--bg-inverse); color: var(--text-inverse); border-color: var(--bg-inverse); box-shadow: var(--shadow-xs), var(--inset-highlight); }
.btn--primary:hover { background: var(--bg-inverse-hover); border-color: var(--bg-inverse-hover); }
.btn--primary:active { background: var(--gray-950); }
.btn--secondary { background: var(--bg); color: var(--text); border-color: var(--line-control); box-shadow: var(--shadow-xs); }
.btn--secondary:hover { background: var(--bg-hover); border-color: var(--line-strong); }
.btn--secondary:active { background: var(--bg-selected); }
.btn--secondary .icon, .btn--ghost .icon { color: var(--text-2); }
.btn--ghost { background: transparent; color: var(--text-2); }
.btn--ghost:hover { background: var(--bg-selected); color: var(--text); }
.btn--ghost:hover .icon { color: var(--text); }
.btn--ghost:active { background: var(--bg-pressed); }
.btn--danger { background: var(--danger); color: var(--on-danger); border-color: var(--danger); box-shadow: var(--shadow-xs), var(--inset-highlight); }
.btn--danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn--danger:focus-visible { box-shadow: var(--danger-ring); }
.btn--danger-ghost { background: transparent; color: var(--danger); }
.btn--danger-ghost:hover { background: var(--danger-tint); }
.btn--link { block-size: auto; padding: 0; border: 0; color: var(--text-link); font-weight: var(--weight-medium); }
.btn--link:hover { text-decoration: underline; text-underline-offset: 2px; }

.btn--xs { --btn-h: var(--h-xs); padding-inline: 8px; font-size: var(--text-xs); border-radius: var(--radius-sm); gap: 4px; }
.btn--xs .icon { inline-size: 14px; block-size: 14px; }
.btn--sm { --btn-h: var(--h-sm); padding-inline: 10px; font-size: var(--text-xs); border-radius: var(--radius-sm); gap: 5px; }
.btn--sm .icon { inline-size: 14px; block-size: 14px; }
.btn--lg { --btn-h: var(--h-lg); padding-inline: 14px; font-size: var(--text-base); }
.btn--xl { --btn-h: var(--h-xl); padding-inline: 16px; font-size: var(--text-base); }
.btn--block { inline-size: 100%; }

/* Icon-only. Default is bordered square (reference 1 header actions). Add .btn--ghost for toolbars. */
.btn--icon { inline-size: var(--btn-h); padding: 0; }
.btn--icon.btn--sm .icon { inline-size: 15px; block-size: 15px; }

.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading .icon { visibility: hidden; }
.btn.is-loading::after {
  content: ""; position: absolute; inset: 0; margin: auto;
  inline-size: 14px; block-size: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-inline-end-color: transparent;
  color: var(--text-2); animation: bfa-spin 700ms linear infinite;
}
.btn--primary.is-loading::after, .btn--danger.is-loading::after { color: var(--text-inverse); }

/* Split button (reference 2: “Send Now | ⏱”) */
.btn-split { display: inline-flex; align-items: stretch; border-radius: var(--radius-md); box-shadow: var(--shadow-xs); }
.btn-split > .btn { box-shadow: none; }
.btn-split > .btn:first-child { border-start-end-radius: 0; border-end-end-radius: 0; }
.btn-split > .btn:last-child { border-start-start-radius: 0; border-end-start-radius: 0; inline-size: var(--btn-h); padding: 0; }
.btn-split > .btn--primary:last-child { border-inline-start-color: rgba(255, 255, 255, 0.16); }
.btn-split > .btn--secondary:last-child { margin-inline-start: -1px; }

/* Button group (joined, e.g. prev/next) */
.btn-group { display: inline-flex; }
.btn-group > .btn { border-radius: 0; box-shadow: none; }
.btn-group > .btn + .btn { margin-inline-start: -1px; }
.btn-group > .btn:first-child { border-start-start-radius: var(--radius-md); border-end-start-radius: var(--radius-md); }
.btn-group > .btn:last-child { border-start-end-radius: var(--radius-md); border-end-end-radius: var(--radius-md); }
.btn-group > .btn:hover, .btn-group > .btn:focus-visible { position: relative; z-index: 1; }
.btn-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- 7. Form controls ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-inline-size: 0; }
.field__label { display: flex; align-items: baseline; gap: 6px; font-size: var(--text-sm); line-height: var(--lh-sm); font-weight: var(--weight-medium); color: var(--text); }
.field__optional { font-weight: var(--weight-regular); color: var(--text-3); }
.field__help { font-size: var(--text-xs); line-height: var(--lh-xs); color: var(--text-3); }
.field__error { display: flex; align-items: flex-start; gap: 6px; font-size: var(--text-xs); line-height: var(--lh-xs); color: var(--danger); }
.field__error .icon { inline-size: 14px; block-size: 14px; margin-block-start: 1px; }
.field-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.input, .textarea, .select__trigger {
  --input-h: var(--h-md);
  inline-size: 100%;
  block-size: var(--input-h);
  padding-inline: 10px;
  border: 1px solid var(--line-control);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text);
  font-size: var(--text-sm);
  transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out);
}
.input::placeholder, .textarea::placeholder { color: var(--text-4); opacity: 1; }
.input:hover, .textarea:hover, .select__trigger:hover { border-color: var(--line-strong); }
.input:focus, .textarea:focus, .select__trigger:focus-visible, .select__trigger[aria-expanded="true"] { outline: none; border-color: var(--focus); box-shadow: var(--focus-ring); }
.input:disabled, .textarea:disabled, .select__trigger:disabled { background: var(--bg-muted); color: var(--text-4); border-color: var(--line); cursor: not-allowed; }
.input[aria-invalid="true"], .textarea[aria-invalid="true"], .select__trigger[aria-invalid="true"] { border-color: var(--danger); }
.input[aria-invalid="true"]:focus, .textarea[aria-invalid="true"]:focus { box-shadow: var(--danger-ring); }
.input[readonly] { background: var(--bg-muted); }
.input--sm { --input-h: var(--h-sm); font-size: var(--text-xs); border-radius: var(--radius-sm); padding-inline: 8px; }
.input--lg { --input-h: var(--h-lg); font-size: var(--text-base); }
.textarea { block-size: auto; min-block-size: 88px; padding-block: 8px; line-height: var(--lh-base); resize: vertical; }
.input[type="number"] { font-variant-numeric: tabular-nums; }
.input[type="email"], .input[type="url"], .input[type="tel"], .input--ltr { direction: ltr; }
[dir="rtl"] .input[type="email"], [dir="rtl"] .input[type="url"], [dir="rtl"] .input[type="tel"], [dir="rtl"] .input--ltr { text-align: end; }
.input[type="email"]::placeholder, .input[type="url"]::placeholder, .input[type="tel"]::placeholder { direction: inherit; }

/* Input with leading icon / trailing adornment (search, ⌘K, unit) */
.input-wrap { position: relative; display: flex; align-items: center; inline-size: 100%; }
.input-wrap > .input { flex: 1; }
.input-wrap > .icon { position: absolute; inset-inline-start: 10px; color: var(--text-3); pointer-events: none; }
.input-wrap > .icon ~ .input { padding-inline-start: 32px; }
.input-wrap__end { position: absolute; inset-inline-end: 6px; display: flex; align-items: center; gap: 4px; color: var(--text-3); font-size: var(--text-xs); }
.input-wrap:has(.input-wrap__end) > .input { padding-inline-end: 44px; }
.input-wrap--sm > .icon { inset-inline-start: 8px; inline-size: 14px; block-size: 14px; }
.input-wrap--sm > .icon ~ .input { padding-inline-start: 28px; }

/* Input group (prefix/suffix as attached text) */
.input-group { display: flex; align-items: stretch; inline-size: 100%; }
.input-group__addon {
  display: flex; align-items: center; padding-inline: 10px;
  border: 1px solid var(--line-control); color: var(--text-3); font-size: var(--text-sm); background: var(--bg);
  white-space: nowrap;
}
.input-group__addon:first-child { border-start-start-radius: var(--radius-md); border-end-start-radius: var(--radius-md); border-inline-end: 0; }
.input-group__addon:last-child { border-start-end-radius: var(--radius-md); border-end-end-radius: var(--radius-md); border-inline-start: 0; }
.input-group > .input:not(:first-child) { border-start-start-radius: 0; border-end-start-radius: 0; }
.input-group > .input:not(:last-child) { border-start-end-radius: 0; border-end-end-radius: 0; }

/* Custom select (no native <select> — rule). Trigger looks like an input; list is a .menu with role=listbox. */
.select { position: relative; inline-size: 100%; }
.select__trigger { display: flex; align-items: center; gap: 8px; text-align: start; cursor: pointer; }
.select__value { flex: 1; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select__value:empty::before, .select__value.is-placeholder { color: var(--text-4); }
.select__trigger > .icon:last-child { color: var(--text-3); transition: transform var(--dur-2) var(--ease-out); }
.select__trigger[aria-expanded="true"] > .icon:last-child { transform: rotate(180deg); }
.select > .menu { inline-size: 100%; min-inline-size: 180px; }

/* Checkbox & radio — native inputs, restyled */
.check, .radio { display: inline-flex; align-items: flex-start; gap: 8px; font-size: var(--text-sm); line-height: var(--lh-sm); color: var(--text); cursor: pointer; }
.check input, .radio input, input.checkbox, input.radio-input {
  appearance: none; -webkit-appearance: none; margin: 0; flex: none;
  inline-size: 16px; block-size: 16px; margin-block-start: 1px;
  border: 1px solid var(--line-check); background: var(--bg);
  display: grid; place-content: center;
  transition: background var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out);
  cursor: pointer;
}
.check input, input.checkbox { border-radius: var(--radius-xs); }
.radio input, input.radio-input { border-radius: 50%; }
.check input:hover, .radio input:hover, input.checkbox:hover, input.radio-input:hover { border-color: var(--text-2); }
.check input:checked, .check input:indeterminate, input.checkbox:checked, input.checkbox:indeterminate { background: var(--bg-inverse); border-color: var(--bg-inverse); }
.check input::after, input.checkbox::after {
  content: ""; inline-size: 10px; block-size: 10px; background: var(--text-inverse);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
  transform: scale(0); transition: transform var(--dur-1) var(--ease-out);
}
.check input:checked::after, input.checkbox:checked::after { transform: scale(1); }
.check input:indeterminate::after, input.checkbox:indeterminate::after { -webkit-mask: none; mask: none; block-size: 2px; inline-size: 8px; border-radius: 1px; transform: scale(1); }
.radio input:checked, input.radio-input:checked { border: 5px solid var(--bg-inverse); background: var(--gray-0); }
[data-theme="dark"] .radio input:checked, [data-theme="dark"] input.radio-input:checked { background: var(--bg); }
.check input:focus-visible, .radio input:focus-visible, input.checkbox:focus-visible, input.radio-input:focus-visible { outline: none; box-shadow: var(--focus-ring); border-color: var(--focus); }
.check input:disabled, .radio input:disabled { opacity: 0.45; cursor: not-allowed; }
.check__text, .radio__text { display: flex; flex-direction: column; gap: 2px; }
.check__desc, .radio__desc { font-size: var(--text-xs); line-height: var(--lh-xs); color: var(--text-3); }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 10px; font-size: var(--text-sm); cursor: pointer; }
.switch input {
  appearance: none; -webkit-appearance: none; margin: 0; flex: none; cursor: pointer;
  inline-size: 32px; block-size: 18px; border-radius: var(--radius-full);
  background: var(--line-check); position: relative;
  transition: background var(--dur-2) var(--ease-out);
}
.switch input::after {
  content: ""; position: absolute; inset-block-start: 2px; inset-inline-start: 2px;
  inline-size: 14px; block-size: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(16, 16, 20, 0.2);
  transition: transform var(--dur-2) var(--ease-out);
}
.switch input:checked { background: var(--bg-inverse); }
.switch input:checked::after { transform: translateX(14px); }
[dir="rtl"] .switch input:checked::after { transform: translateX(-14px); }
[data-theme="dark"] .switch input:checked::after { background: var(--bg); }
.switch input:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.switch input:disabled { opacity: 0.45; cursor: not-allowed; }

/* Segmented control (reference 2: All Mails / Unread / Archive) */
.segmented {
  display: inline-flex; align-items: center; gap: 2px;
  padding: 2px; border-radius: var(--radius-md);
  background: var(--bg-selected);
}
.segmented__item {
  display: inline-flex; align-items: center; gap: 6px;
  block-size: 28px; padding-inline: 12px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-3);
  transition: color var(--dur-1) var(--ease-out), background var(--dur-1) var(--ease-out);
  white-space: nowrap;
}
.segmented__item:hover { color: var(--text); }
.segmented__item[aria-pressed="true"], .segmented__item[aria-selected="true"], .segmented__item.is-active {
  background: var(--bg); color: var(--text); box-shadow: var(--shadow-xs), 0 0 0 1px var(--line);
}
[data-theme="dark"] .segmented__item[aria-pressed="true"], [data-theme="dark"] .segmented__item[aria-selected="true"] { background: var(--bg-pressed); }
.segmented__item:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.segmented--sm .segmented__item { block-size: 24px; padding-inline: 8px; font-size: var(--text-xs); }
.segmented--block { display: flex; }
.segmented--block .segmented__item { flex: 1; justify-content: center; }

/* Range slider */
.range { appearance: none; -webkit-appearance: none; inline-size: 100%; block-size: 18px; background: transparent; margin: 0; }
.range::-webkit-slider-runnable-track { block-size: 4px; border-radius: 4px; background: var(--gray-200); }
.range::-moz-range-track { block-size: 4px; border-radius: 4px; background: var(--gray-200); }
.range::-moz-range-progress { block-size: 4px; border-radius: 4px; background: var(--bg-inverse); }
.range::-webkit-slider-thumb { -webkit-appearance: none; inline-size: 16px; block-size: 16px; margin-block-start: -6px; border-radius: 50%; background: #fff; border: 1px solid var(--line-strong); box-shadow: var(--shadow-sm); }
.range::-moz-range-thumb { inline-size: 16px; block-size: 16px; border-radius: 50%; background: #fff; border: 1px solid var(--line-strong); box-shadow: var(--shadow-sm); }
.range:focus-visible { outline: none; }
.range:focus-visible::-webkit-slider-thumb { box-shadow: var(--focus-ring); border-color: var(--focus); }

/* Dropzone */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
  padding: 24px 16px; border: 1px dashed var(--line-strong); border-radius: var(--radius-lg);
  color: var(--text-3); font-size: var(--text-sm);
  transition: border-color var(--dur-1) var(--ease-out), background var(--dur-1) var(--ease-out);
  cursor: pointer;
}
.dropzone .icon { color: var(--text-3); }
.dropzone strong { color: var(--text); font-weight: var(--weight-medium); }
.dropzone:hover, .dropzone.is-dragover { border-color: var(--text-3); background: var(--bg-hover); }

/* ---------- 8. Tabs ---------- */
/* 8a. Pill tabs with counts (reference 1: Primary 67 · Company 23 · Promotions 120) */
.tabs { display: flex; align-items: center; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  block-size: 28px; padding-inline: 10px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text-3);
  transition: background var(--dur-1) var(--ease-out), color var(--dur-1) var(--ease-out);
  white-space: nowrap;
}
.tab .icon { inline-size: 14px; block-size: 14px; }
.tab:hover { color: var(--text); background: var(--bg-hover); }
.tab[aria-selected="true"], .tab.is-active { background: var(--bg-inverse); color: var(--text-inverse); }
.tab[aria-selected="true"] .count, .tab.is-active .count { background: var(--bg); color: var(--text); border-color: transparent; }
.tab:focus-visible { outline: none; box-shadow: var(--focus-ring); }

/* 8b. Underline tabs (page sections, settings) */
.tabs--underline { gap: 20px; border-block-end: 1px solid var(--line); }
.tabs--underline .tab { block-size: 40px; padding-inline: 0; border-radius: 0; background: none; position: relative; color: var(--text-3); }
.tabs--underline .tab:hover { background: none; color: var(--text); }
.tabs--underline .tab[aria-selected="true"], .tabs--underline .tab.is-active { background: none; color: var(--text); }
.tabs--underline .tab[aria-selected="true"]::after, .tabs--underline .tab.is-active::after {
  content: ""; position: absolute; inset-inline: 0; inset-block-end: -1px; block-size: 2px; background: var(--text); border-radius: 2px 2px 0 0;
}
.tabs--underline .tab[aria-selected="true"] .count { background: var(--bg-selected); color: var(--text-2); }

/* ---------- 9. Badges, counts, tags, chips, kbd, dots ---------- */
.count {
  display: inline-flex; align-items: center; justify-content: center;
  min-inline-size: 18px; block-size: 18px; padding-inline: 5px;
  border-radius: var(--radius-xs);
  background: var(--bg-selected); color: var(--text-3);
  font-size: var(--text-2xs); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; line-height: 1;
}
.count--pill { border-radius: var(--radius-full); }
.count--solid { background: var(--bg-inverse); color: var(--text-inverse); }
.count--accent { background: var(--accent); color: var(--on-accent); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  block-size: 22px; padding-inline: 8px;
  border: 1px solid var(--line-control); border-radius: var(--radius-full);
  background: var(--bg);
  font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--text-2);
  white-space: nowrap; line-height: 1;
}
.badge .icon { inline-size: 12px; block-size: 12px; stroke-width: 2; }
.badge--success { color: var(--success); border-color: var(--success-line); }
.badge--warning { color: var(--warning); border-color: var(--warning-line); }
.badge--danger { color: var(--danger); border-color: var(--danger-line); }
.badge--info { color: var(--info); border-color: var(--info-line); }
.badge--solid { /* “NEW” in reference 1 */
  block-size: 18px; padding-inline: 6px; border-radius: var(--radius-xs); border-color: var(--bg-inverse);
  background: var(--bg-inverse); color: var(--text-inverse);
  font-size: 10px; font-weight: var(--weight-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase;
}

.tag { /* “TAG #1” in reference 1 */
  display: inline-flex; align-items: center; gap: 4px;
  block-size: 20px; padding-inline: 6px;
  border: 1px solid var(--line-control); border-radius: var(--radius-xs);
  font-size: 10px; font-weight: var(--weight-medium); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-2);
  white-space: nowrap; line-height: 1;
}
.tag .dot { inline-size: 6px; block-size: 6px; }
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; }

.chip { /* attachment mini, recipient, filter value */
  display: inline-flex; align-items: center; gap: 6px; max-inline-size: 100%;
  block-size: 24px; padding-inline: 8px;
  border: 1px solid var(--line-control); border-radius: var(--radius-sm);
  background: var(--bg); color: var(--text-2);
  font-size: var(--text-xs); line-height: 1; white-space: nowrap;
}
.chip .icon { inline-size: 13px; block-size: 13px; color: var(--text-3); }
.chip--pill { border-radius: var(--radius-full); padding-inline: 3px 10px; }
.chip--pill .avatar { --avatar: 18px; }
.chip__label { overflow: hidden; text-overflow: ellipsis; }
.chip__remove { display: grid; place-items: center; inline-size: 16px; block-size: 16px; margin-inline-end: -4px; border-radius: var(--radius-xs); color: var(--text-3); }
.chip__remove:hover { background: var(--bg-selected); color: var(--text); }
button.chip:hover { border-color: var(--line-strong); color: var(--text); }

.kbd {
  display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  min-inline-size: 20px; block-size: 20px; padding-inline: 5px;
  border: 1px solid var(--line-control); border-block-end-width: 2px; border-radius: var(--radius-xs);
  background: var(--bg);
  font-family: var(--font-sans); font-size: var(--text-2xs); font-weight: var(--weight-medium); color: var(--text-3);
  direction: ltr; line-height: 1;
}

.dot { display: inline-block; inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--accent-dot); flex: none; }
.dot--sm { inline-size: 6px; block-size: 6px; }
.dot--success { background: var(--success-dot); } .dot--warning { background: var(--warning-dot); } .dot--danger { background: var(--danger-dot); }
.dot--neutral { background: var(--gray-300); } .dot--live { animation: bfa-pulse 2s var(--ease-in-out) infinite; }

/* ---------- 10. Avatars ---------- */
.avatar {
  --avatar: 28px;
  position: relative; display: inline-grid; place-items: center; flex: none;
  inline-size: var(--avatar); block-size: var(--avatar); border-radius: 50%;
  background: var(--bg-selected); color: var(--text-2);
  font-size: calc(var(--avatar) * 0.38); font-weight: var(--weight-semibold); letter-spacing: 0; line-height: 1;
  overflow: visible; user-select: none;
}
.avatar > img { inline-size: 100%; block-size: 100%; border-radius: 50%; object-fit: cover; }
.avatar--xs { --avatar: 18px; } .avatar--sm { --avatar: 24px; } .avatar--md { --avatar: 32px; }
.avatar--lg { --avatar: 40px; } .avatar--xl { --avatar: 56px; } .avatar--2xl { --avatar: 72px; }
.avatar--square { border-radius: var(--radius-sm); } .avatar--square > img { border-radius: var(--radius-sm); }
.avatar::after { content: ""; position: absolute; inset: 0; border-radius: inherit; box-shadow: inset 0 0 0 1px rgba(16, 16, 20, 0.06); pointer-events: none; }
/* Gradient orbs (reference 1) — placeholder identity when no photo; pick by hash of the id: --orb-1 … --orb-8 */
.avatar--orb { color: transparent; }
.avatar--orb-1 { background: radial-gradient(circle at 30% 25%, #ffd1a8, transparent 55%), linear-gradient(135deg, #ff4d6d, #ff9e45); }
.avatar--orb-2 { background: radial-gradient(circle at 30% 25%, #ffe0f4, transparent 55%), linear-gradient(135deg, #f472b6, #a855f7); }
.avatar--orb-3 { background: radial-gradient(circle at 30% 25%, #c8f7ff, transparent 55%), linear-gradient(135deg, #38bdf8, #6366f1); }
.avatar--orb-4 { background: radial-gradient(circle at 30% 25%, #d9ffd6, transparent 55%), linear-gradient(135deg, #34d399, #0ea5e9); }
.avatar--orb-5 { background: radial-gradient(circle at 30% 25%, #fff3b0, transparent 55%), linear-gradient(135deg, #f59e0b, #ef4444); }
.avatar--orb-6 { background: radial-gradient(circle at 30% 25%, #e6dcff, transparent 55%), linear-gradient(135deg, #8b5cf6, #1e3a8a); }
.avatar--orb-7 { background: radial-gradient(circle at 30% 25%, #ffd6e0, transparent 55%), linear-gradient(135deg, #fb7185, #3b82f6); }
.avatar--orb-8 { background: radial-gradient(circle at 30% 25%, #e0fff4, transparent 55%), linear-gradient(135deg, #14b8a6, #84cc16); }
.avatar__status { position: absolute; inset-block-end: -1px; inset-inline-end: -1px; inline-size: 30%; block-size: 30%; min-inline-size: 7px; min-block-size: 7px; border-radius: 50%; background: var(--success-dot); box-shadow: 0 0 0 2px var(--bg); }
.avatar__status--away { background: var(--warning-dot); } .avatar__status--busy { background: var(--danger-dot); } .avatar__status--offline { background: var(--gray-300); }
.avatar-stack { display: inline-flex; }
.avatar-stack > .avatar { box-shadow: 0 0 0 2px var(--bg); }
.avatar-stack > .avatar + .avatar { margin-inline-start: -6px; }

/* ---------- 11. Lists — message / item rows ---------- */
.list { display: flex; flex-direction: column; }
.list-group__header {
  position: sticky; inset-block-start: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px 8px; background: var(--bg);
  font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text);
}
.list-group__header .spacer { flex: 1; }
.list-group__meta { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.list-group__toggle { display: grid; place-items: center; inline-size: 20px; block-size: 20px; border-radius: var(--radius-xs); color: var(--text-3); }
.list-group__toggle:hover { background: var(--bg-selected); color: var(--text); }
.list-group__toggle .icon { transition: transform var(--dur-2) var(--ease-out); }
.list-group__toggle[aria-expanded="false"] .icon { transform: rotate(180deg); }

/* Default: hairline-divided rows (reference 2) */
.item {
  position: relative;
  display: grid; grid-template-columns: auto 1fr; column-gap: 12px;
  padding: 12px 16px;
  border-block-end: 1px solid var(--line);
  color: inherit; text-decoration: none; text-align: start;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease-out);
  inline-size: 100%;
}
.item:hover { background: var(--bg-hover); text-decoration: none; }
.item[aria-selected="true"], .item[aria-current="true"], .item.is-selected { background: var(--bg-selected); }
.item:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; border-radius: 0; }
.item__avatar { padding-block-start: 1px; }
.item__body { min-inline-size: 0; display: flex; flex-direction: column; gap: 2px; }
.item__top { display: flex; align-items: center; gap: 8px; min-block-size: 18px; }
.item__sender { flex: 1; min-inline-size: 0; font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__time { font-size: var(--text-xs); color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.item__subject { display: flex; align-items: center; gap: 8px; font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text); }
.item__subject > span { flex: 1; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__preview { font-size: var(--text-xs); line-height: var(--lh-xs); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item__meta { display: flex; flex-wrap: wrap; gap: 4px; margin-block-start: 6px; }
.item__meta .chip { block-size: 20px; padding-inline: 6px; gap: 4px; font-size: var(--text-2xs); border-radius: var(--radius-xs); }
.item__meta .chip .icon { inline-size: 12px; block-size: 12px; }
.item.is-unread .item__sender, .item.is-unread .item__subject { font-weight: var(--weight-semibold); }
.item:not(.is-unread) .item__subject { color: var(--text-2); font-weight: var(--weight-regular); }
.item__actions {
  position: absolute; inset-block-start: 8px; inset-inline-end: 12px;
  display: none; align-items: center; gap: 2px;
  padding-inline-start: 8px;
  background: inherit;
}
.item:hover .item__actions, .item:focus-within .item__actions { display: flex; }
.item:hover .item__time, .item:focus-within .item__time { visibility: hidden; }
.item__actions .btn { --btn-h: 24px; }
.item__actions .btn .icon { inline-size: 14px; block-size: 14px; }
.item.is-dimmed { opacity: 0.5; }

/* Framed variant (reference 1): each item a hairline-bordered row, selected = ink border */
.list--framed { gap: 8px; padding: 0 12px 12px; }
.list--framed .item { border: 1px solid var(--line); border-radius: var(--radius-md); padding: 10px 12px; }
.list--framed .item:hover { border-color: var(--line-strong); background: var(--bg); }
.list--framed .item[aria-selected="true"], .list--framed .item.is-selected { background: var(--bg); border-color: var(--line-selected); box-shadow: 0 0 0 0.5px var(--line-selected); }
.list--framed .list-group__header { padding-inline: 4px; }

/* Simple row (settings lists, members, integrations) */
.row-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-block-end: 1px solid var(--line); }
.row-item:last-child { border-block-end: 0; }
.row-item__body { flex: 1; min-inline-size: 0; }
.row-item__title { font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text); }
.row-item__desc { font-size: var(--text-xs); line-height: var(--lh-xs); color: var(--text-3); margin-block-start: 2px; }

/* ---------- 12. Reading view ---------- */
.toolbar { display: flex; align-items: center; gap: 2px; block-size: var(--toolbar-h); padding-inline: 12px; border-block-end: 1px solid var(--line); flex: none; }
.toolbar .btn--ghost { --btn-h: 30px; color: var(--text-3); }
.toolbar .btn--ghost .icon { color: currentColor; }
.toolbar .btn--ghost:hover { color: var(--text); }
.toolbar__sep { inline-size: 1px; block-size: 16px; background: var(--line); margin-inline: 6px; flex: none; }
.toolbar__spacer { flex: 1; }
.toolbar--bare { border: 0; padding-inline: 0; block-size: auto; }

.message { padding: 20px 24px 32px; max-inline-size: 880px; }
.message__head { display: flex; align-items: flex-start; gap: 12px; }
.message__from { flex: 1; min-inline-size: 0; }
.message__name { font-size: var(--text-base); font-weight: var(--weight-semibold); color: var(--text); }
.message__email { font-size: var(--text-xs); color: var(--text-3); }
.message__date { font-size: var(--text-xs); color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; padding-block-start: 2px; }
.message__subject { font-size: var(--text-2xl); line-height: var(--lh-2xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-snug); color: var(--text); margin-block: 20px 12px; }
.recipients { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: var(--text-xs); color: var(--text-3); }
.recipients__label { margin-inline-end: 2px; }
.recipients__label:not(:first-child) { margin-inline-start: 8px; }
.message__body { margin-block-start: 20px; padding-block-start: 20px; border-block-start: 1px solid var(--line); }

/* Inline callout — the one small framed block allowed (offers, notices inside content) */
.callout {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--bg);
}
.callout__body { flex: 1; min-inline-size: 0; }
.callout__title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: var(--text-base); font-weight: var(--weight-semibold); color: var(--text); }
.callout__text { font-size: var(--text-sm); line-height: var(--lh-sm); color: var(--text-3); margin-block-start: 4px; }
.callout__aside { display: flex; align-items: center; gap: 12px; font-size: var(--text-sm); color: var(--text-3); white-space: nowrap; }
.callout__aside strong { color: var(--text); font-weight: var(--weight-semibold); }

/* File tiles */
.files { display: flex; flex-wrap: wrap; gap: 8px; }
.file {
  display: inline-flex; align-items: center; gap: 10px; max-inline-size: 260px;
  padding-block: 8px; padding-inline: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--bg); color: inherit; text-decoration: none;
  transition: border-color var(--dur-1) var(--ease-out);
}
a.file:hover, button.file:hover { border-color: var(--line-strong); text-decoration: none; }
.file__icon { color: var(--text-3); flex: none; }
.file__icon--pdf { color: var(--red-600); } .file__icon--doc { color: var(--blue-600); } .file__icon--xls { color: var(--green-600); }
.file__icon--img { color: var(--violet-600); } .file__icon--zip { color: var(--amber-600); } .file__icon--vid { color: var(--pink-500); }
.file__body { min-inline-size: 0; display: flex; flex-direction: column; gap: 1px; }
.file__name { font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file__meta { font-size: var(--text-2xs); color: var(--text-3); font-variant-numeric: tabular-nums; display: flex; gap: 6px; align-items: center; }
.file__meta a { font-weight: var(--weight-medium); }

/* ---------- 13. Composer ---------- */
.composer { border-block-start: 1px solid var(--line); background: var(--bg); display: flex; flex-direction: column; }
.composer__head { display: flex; align-items: center; gap: 10px; padding: 12px 24px 4px; }
.composer__who { flex: 1; min-inline-size: 0; }
.composer__input {
  display: block; inline-size: 100%; min-block-size: 64px; max-block-size: 40vh;
  padding: 8px 24px 12px; border: 0; resize: none; background: transparent;
  font-size: var(--text-base); line-height: var(--lh-prose); color: var(--text);
}
.composer__input::placeholder { color: var(--text-4); }
.composer__input:focus { outline: none; }
.composer__bar { display: flex; align-items: center; gap: 2px; padding-block: 8px; padding-inline: 20px 16px; border-block-start: 1px solid var(--line); }
.composer__bar .btn--ghost { --btn-h: 28px; color: var(--text-3); }
.composer__bar .btn--ghost .icon { inline-size: 15px; block-size: 15px; color: currentColor; }
.composer__bar .btn--ghost:hover, .composer__bar .btn--ghost[aria-pressed="true"] { color: var(--text); }
.composer__bar .btn--ghost[aria-pressed="true"] { background: var(--bg-selected); }

/* Floating composer (reference 2) */
.composer--floating {
  border: 1px solid var(--line); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg);
  margin: 0 20px 20px; overflow: hidden;
}
.composer--floating .composer__head { padding-block: 12px 4px; padding-inline: 16px 12px; }
.composer--floating .composer__input { padding-inline: 16px; }
.composer--floating .composer__bar { border-block-start: 0; padding-block: 8px 12px; padding-inline: 16px 12px; }
.composer__to { display: inline-flex; align-items: center; gap: 6px; font-size: var(--text-sm); color: var(--text-3); padding: 4px 6px; margin-inline-start: -6px; border-radius: var(--radius-sm); }
.composer__to:hover { background: var(--bg-hover); }
.composer__to strong { color: var(--text); font-weight: var(--weight-medium); }

/* ---------- 14. Pagination & meters ---------- */
.pager { display: inline-flex; align-items: center; gap: 12px; font-size: var(--text-xs); color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.progress { block-size: 4px; border-radius: var(--radius-full); background: var(--gray-150); overflow: hidden; }
.progress__bar { block-size: 100%; border-radius: inherit; background: var(--bg-inverse); transition: inline-size var(--dur-4) var(--ease-out); }
.progress--success .progress__bar { background: var(--success-dot); }
.progress--warning .progress__bar { background: var(--warning-dot); }
.progress--danger .progress__bar { background: var(--danger-dot); }
[data-theme="dark"] .progress { background: var(--bg-pressed); }
.meter { display: flex; flex-direction: column; gap: 8px; }
.meter__label { display: flex; justify-content: space-between; gap: 8px; font-size: var(--text-xs); color: var(--text-3); font-variant-numeric: tabular-nums; }
.meter__label strong { color: var(--text); font-weight: var(--weight-medium); }
.spinner { inline-size: 16px; block-size: 16px; border-radius: 50%; border: 2px solid var(--line-strong); border-block-start-color: var(--text); animation: bfa-spin 700ms linear infinite; flex: none; }
.spinner--sm { inline-size: 12px; block-size: 12px; border-width: 1.5px; }
.spinner--lg { inline-size: 24px; block-size: 24px; }
.skeleton { border-radius: var(--radius-xs); background: linear-gradient(90deg, var(--gray-100) 0%, var(--gray-50) 50%, var(--gray-100) 100%); background-size: 200% 100%; animation: bfa-shimmer 1.4s linear infinite; color: transparent !important; }
[data-theme="dark"] .skeleton { background: linear-gradient(90deg, var(--bg-selected) 0%, var(--bg-pressed) 50%, var(--bg-selected) 100%); background-size: 200% 100%; }
.skeleton--text { block-size: 10px; margin-block: 4px; }
.skeleton--circle { border-radius: 50%; }

/* ---------- 15. Breadcrumbs ---------- */
.breadcrumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: var(--text-sm); color: var(--text-3); }
.breadcrumbs a { color: var(--text-3); }
.breadcrumbs a:hover { color: var(--text); text-decoration: none; }
.breadcrumbs .icon { inline-size: 14px; block-size: 14px; color: var(--text-4); }
.breadcrumbs [aria-current="page"] { color: var(--text); font-weight: var(--weight-medium); }

/* ---------- 16. Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { inline-size: 100%; font-size: var(--text-sm); color: var(--text); }
.table th {
  position: sticky; inset-block-start: 0; z-index: 1;
  block-size: 36px; padding: 0 12px;
  border-block-end: 1px solid var(--line);
  background: var(--bg);
  font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--text-3); text-align: start; white-space: nowrap;
}
.table td { block-size: 48px; padding: 8px 12px; border-block-end: 1px solid var(--line); vertical-align: middle; }
.table tbody tr { transition: background var(--dur-1) var(--ease-out); }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr[aria-selected="true"] { background: var(--bg-selected); }
.table th:first-child, .table td:first-child { padding-inline-start: var(--table-edge, 16px); }
.table th:last-child, .table td:last-child { padding-inline-end: var(--table-edge, 16px); }
.table .is-num { text-align: end; font-variant-numeric: tabular-nums; }
.table .is-check { inline-size: 40px; padding-inline-end: 0; }
.table .is-actions { inline-size: 1%; white-space: nowrap; text-align: end; }
.table .is-muted { color: var(--text-3); }
.table--compact td { block-size: 36px; padding-block: 4px; }
.th-sort { display: inline-flex; align-items: center; gap: 4px; color: inherit; font-weight: inherit; }
.th-sort:hover { color: var(--text); }
.th-sort .icon { inline-size: 12px; block-size: 12px; opacity: 0.6; }
.th-sort[aria-sort="ascending"], .th-sort[aria-sort="descending"] { color: var(--text); }
.th-sort[aria-sort="ascending"] .icon, .th-sort[aria-sort="descending"] .icon { opacity: 1; }
.cell-user { display: flex; align-items: center; gap: 10px; min-inline-size: 0; }
.cell-user__name { font-weight: var(--weight-medium); }
.cell-user__sub { font-size: var(--text-xs); color: var(--text-3); }

/* ---------- 17. Data display: description list, stats, timeline ---------- */
.dl { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; }
.dl dt, .dl dd { padding: 12px 0; border-block-end: 1px solid var(--line); font-size: var(--text-sm); }
.dl dt { color: var(--text-3); padding-inline-end: 16px; }
.dl dd { color: var(--text); }
.dl > :nth-last-child(-n + 2) { border-block-end: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); border-block: 1px solid var(--line); }
.stat { padding: 16px 20px; display: flex; flex-direction: column; gap: 4px; }
.stat + .stat { border-inline-start: 1px solid var(--line); }
.stat__label { display: flex; align-items: center; gap: 6px; font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--text-3); }
.stat__value { font-size: var(--text-4xl); line-height: var(--lh-4xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tight); color: var(--text); font-variant-numeric: tabular-nums; }
.stat__delta { display: inline-flex; align-items: center; gap: 4px; font-size: var(--text-xs); font-weight: var(--weight-medium); font-variant-numeric: tabular-nums; }
.stat__delta--up { color: var(--success); } .stat__delta--down { color: var(--danger); }
.stat__delta .icon { inline-size: 12px; block-size: 12px; stroke-width: 2.25; }
.stat__hint { font-size: var(--text-xs); color: var(--text-3); }

.timeline { display: flex; flex-direction: column; }
.timeline__item { position: relative; display: grid; grid-template-columns: 20px 1fr; column-gap: 12px; padding-block-end: 20px; }
.timeline__item::before { content: ""; position: absolute; inset-inline-start: 9.5px; inset-block: 18px 0; inline-size: 1px; background: var(--line); }
.timeline__item:last-child::before { display: none; }
.timeline__marker { display: grid; place-items: center; inline-size: 20px; block-size: 20px; border-radius: 50%; border: 1px solid var(--line-control); background: var(--bg); color: var(--text-3); }
.timeline__marker .icon { inline-size: 11px; block-size: 11px; stroke-width: 2.25; }
.timeline__text { font-size: var(--text-sm); line-height: var(--lh-sm); color: var(--text-2); padding-block-start: 1px; }
.timeline__text strong { color: var(--text); font-weight: var(--weight-medium); }
.timeline__time { font-size: var(--text-xs); color: var(--text-3); margin-block-start: 2px; }

/* ---------- 18. Overlays: menu, popover, tooltip, dialog, drawer, toast, palette ---------- */
.menu {
  position: absolute; z-index: var(--z-dropdown);
  min-inline-size: 200px; max-block-size: min(360px, 70vh); overflow-y: auto;
  padding: 4px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  font-size: var(--text-sm);
  transform-origin: top;
  animation: bfa-pop var(--dur-2) var(--ease-out);
}
.menu[hidden] { display: none; }
.menu--static { position: static; animation: none; z-index: auto; } /* grid/flex items honour z-index even when static */
.menu__item {
  display: flex; align-items: center; gap: 8px; inline-size: 100%;
  min-block-size: 32px; padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--text); text-align: start; text-decoration: none; cursor: pointer;
}
.menu__item .icon { color: var(--text-3); }
.menu__item:hover, .menu__item:focus-visible, .menu__item.is-highlighted { background: var(--bg-selected); outline: none; text-decoration: none; }
.menu__item:hover .icon { color: var(--text); }
.menu__item[aria-disabled="true"] { color: var(--text-4); pointer-events: none; }
.menu__item--danger, .menu__item--danger .icon { color: var(--danger); }
.menu__item--danger:hover { background: var(--danger-tint); }
.menu__label { flex: 1; min-inline-size: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu__desc { display: block; font-size: var(--text-xs); color: var(--text-3); white-space: normal; }
.menu__shortcut { margin-inline-start: 16px; font-size: var(--text-xs); color: var(--text-4); direction: ltr; }
.menu__sep { block-size: 1px; background: var(--line); margin: 4px -4px; }
.menu__heading { padding: 8px 8px 4px; font-size: var(--text-2xs); font-weight: var(--weight-medium); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-4); }
/* Selection inside a menu is shown with a LEADING check column (never a trailing ✓). */
.menu--selectable .menu__item { padding-inline-start: 28px; position: relative; }
.menu--selectable .menu__item[aria-selected="true"], .menu--selectable .menu__item[aria-checked="true"] { font-weight: var(--weight-medium); }
.menu--selectable .menu__item[aria-selected="true"]::before, .menu--selectable .menu__item[aria-checked="true"]::before {
  content: ""; position: absolute; inset-inline-start: 8px; inline-size: 14px; block-size: 14px; background: var(--text);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
}
.menu__search { padding: 4px 4px 6px; border-block-end: 1px solid var(--line); margin: -4px -4px 4px; }
.menu__search .input { border: 0; box-shadow: none !important; }
.menu__empty { padding: 12px 8px; color: var(--text-3); font-size: var(--text-sm); text-align: center; }
.dropdown { position: relative; display: inline-flex; }
.dropdown > .menu { inset-block-start: calc(100% + 6px); inset-inline-start: 0; }
.dropdown--end > .menu { inset-inline-start: auto; inset-inline-end: 0; }
.dropdown--up > .menu { inset-block-start: auto; inset-block-end: calc(100% + 6px); transform-origin: bottom; }

.popover {
  position: absolute; z-index: var(--z-dropdown);
  inline-size: 320px; padding: 16px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  animation: bfa-pop var(--dur-2) var(--ease-out);
}

.tooltip {
  position: fixed; z-index: var(--z-tooltip); pointer-events: none;
  max-inline-size: 240px; padding: 5px 8px;
  border-radius: var(--radius-sm); background: var(--bg-inverse); color: var(--text-inverse);
  font-size: var(--text-xs); font-weight: var(--weight-medium); line-height: var(--lh-xs);
  box-shadow: var(--shadow-sm);
  animation: bfa-fade var(--dur-1) var(--ease-out);
}
.tooltip .kbd { background: transparent; color: var(--gray-400); border-color: rgba(255, 255, 255, 0.2); margin-inline-start: 6px; block-size: 18px; }

.dialog {
  display: flex; flex-direction: column;
  inline-size: min(480px, calc(100vw - 32px)); max-block-size: calc(100dvh - 64px);
  padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius-xl);
  background: var(--bg); color: var(--text); box-shadow: var(--shadow-lg);
  overflow: hidden;
}
dialog.dialog { margin: auto; }
dialog.dialog:not([open]) { display: none; }
dialog.dialog[open] { animation: bfa-dialog-in var(--dur-3) var(--ease-out); }
.dialog--inline { position: static; margin: 0; } /* documentation / previews only */
dialog.dialog::backdrop { background: var(--backdrop); animation: bfa-fade var(--dur-3) var(--ease-out); }
.dialog--sm { inline-size: min(400px, calc(100vw - 32px)) !important; }
.dialog--lg { inline-size: min(640px, calc(100vw - 32px)) !important; }
.dialog--xl { inline-size: min(880px, calc(100vw - 32px)) !important; }
.dialog__head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 20px 0; }
.dialog__titles { flex: 1; min-inline-size: 0; }
.dialog__title { font-size: var(--text-lg); line-height: var(--lh-lg); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-snug); }
.dialog__desc { font-size: var(--text-sm); line-height: var(--lh-sm); color: var(--text-3); margin-block-start: 4px; }
.dialog__head .btn--icon { margin-block-start: -4px; margin-inline-end: -6px; }
.dialog__body { padding: 16px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; }
.dialog__foot { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 4px 20px 20px; }
.dialog__foot--split { justify-content: space-between; }
.dialog__icon { display: grid; place-items: center; inline-size: 36px; block-size: 36px; border-radius: 50%; border: 1px solid var(--line); color: var(--text-2); flex: none; }
.dialog__icon--danger { color: var(--danger); border-color: var(--danger-line); }

dialog.drawer {
  position: fixed; inset-block: 0; inset-inline-end: 0; inset-inline-start: auto; margin: 0;
  inline-size: min(440px, 100vw); max-inline-size: 100vw; block-size: 100dvh; max-block-size: 100dvh;
  padding: 0; border: 0; border-inline-start: 1px solid var(--line);
  background: var(--bg); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog.drawer[open] { display: flex; flex-direction: column; animation: bfa-drawer-in var(--dur-3) var(--ease-out); }
[dir="rtl"] dialog.drawer[open] { animation-name: bfa-drawer-in-rtl; }
dialog.drawer::backdrop { background: var(--backdrop); }
dialog.drawer--start { inset-inline-start: 0; inset-inline-end: auto; border-inline-start: 0; border-inline-end: 1px solid var(--line); }
.drawer__head { display: flex; align-items: center; gap: 12px; padding-inline: 20px 12px; block-size: var(--topbar-h); border-block-end: 1px solid var(--line); flex: none; }
.drawer__title { flex: 1; font-size: var(--text-base); font-weight: var(--weight-semibold); }
.drawer__body { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.drawer__foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-block-start: 1px solid var(--line); }

.toasts { position: fixed; z-index: var(--z-toast); inset-block-end: 20px; inset-inline-end: 20px; display: flex; flex-direction: column; gap: 8px; inline-size: min(380px, calc(100vw - 40px)); pointer-events: none; }
.toast {
  pointer-events: auto;
  display: flex; align-items: flex-start; gap: 10px;
  padding-block: 12px; padding-inline: 14px 12px;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  animation: bfa-toast-in var(--dur-3) var(--ease-out);
}
.toast.is-leaving { animation: bfa-toast-out var(--dur-2) var(--ease-in-out) forwards; }
.toast > .icon { margin-block-start: 1px; }
.toast--success > .icon { color: var(--success); } .toast--danger > .icon { color: var(--danger); }
.toast--warning > .icon { color: var(--warning); } .toast--info > .icon { color: var(--info); }
.toast__body { flex: 1; min-inline-size: 0; }
.toast__title { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text); }
.toast__text { font-size: var(--text-sm); line-height: var(--lh-sm); color: var(--text-3); margin-block-start: 2px; }
.toast__actions { display: flex; gap: 12px; margin-block-start: 8px; }
.toast .btn--icon { --btn-h: 24px; margin-block-start: -4px; margin-inline-end: -4px; }

dialog.palette { inline-size: min(600px, calc(100vw - 32px)); margin-block-start: 14vh; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-xl); background: var(--bg); color: var(--text); box-shadow: var(--shadow-lg); overflow: hidden; }
dialog.palette[open] { display: flex; flex-direction: column; animation: bfa-dialog-in var(--dur-2) var(--ease-out); }
dialog.palette::backdrop { background: var(--backdrop); }
.palette__search { display: flex; align-items: center; gap: 10px; padding: 0 16px; block-size: 52px; border-block-end: 1px solid var(--line); }
.palette__search .icon { color: var(--text-3); }
.palette__search input { flex: 1; border: 0; background: transparent; font-size: var(--text-base); color: var(--text); }
.palette__search input:focus { outline: none; }
.palette__search input::placeholder { color: var(--text-4); }
.palette__results { max-block-size: 360px; overflow-y: auto; padding: 4px 8px 8px; }
.palette__results .menu__item { min-block-size: 36px; }
.palette__foot { display: flex; align-items: center; gap: 16px; padding: 8px 16px; border-block-start: 1px solid var(--line); font-size: var(--text-xs); color: var(--text-3); }
.palette__foot span { display: inline-flex; align-items: center; gap: 6px; }

/* ---------- 19. Feedback: alert, banner, empty, error ---------- */
.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-md);
  background: var(--bg); font-size: var(--text-sm); line-height: var(--lh-sm); color: var(--text-2);
}
.alert > .icon { margin-block-start: 1px; color: var(--text-3); }
.alert__body { flex: 1; min-inline-size: 0; }
.alert__title { font-weight: var(--weight-semibold); color: var(--text); }
.alert__title + .alert__text { margin-block-start: 2px; }
.alert__actions { display: flex; gap: 12px; margin-block-start: 8px; }
.alert--info { border-color: var(--info-line); } .alert--info > .icon { color: var(--info); }
.alert--success { border-color: var(--success-line); } .alert--success > .icon { color: var(--success); }
.alert--warning { border-color: var(--warning-line); } .alert--warning > .icon { color: var(--warning); }
.alert--danger { border-color: var(--danger-line); } .alert--danger > .icon { color: var(--danger); }

.banner { display: flex; align-items: center; gap: 10px; padding: 10px var(--page-pad); border-block-end: 1px solid var(--line); font-size: var(--text-sm); color: var(--text-2); background: var(--bg); }
.banner > .icon { color: var(--text-3); }
.banner__text { flex: 1; min-inline-size: 0; }
.banner--warning > .icon { color: var(--warning); } .banner--danger > .icon { color: var(--danger); } .banner--info > .icon { color: var(--info); }

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 4px; padding: 48px 24px; margin: auto; max-inline-size: 360px; }
.empty__icon { display: grid; place-items: center; inline-size: 44px; block-size: 44px; border-radius: 50%; border: 1px solid var(--line); color: var(--text-3); margin-block-end: 12px; }
.empty__icon .icon { inline-size: 20px; block-size: 20px; }
.empty__title { font-size: var(--text-base); font-weight: var(--weight-semibold); color: var(--text); }
.empty__text { font-size: var(--text-sm); line-height: var(--lh-sm); color: var(--text-3); }
.empty__actions { display: flex; gap: 8px; margin-block-start: 16px; }

/* ---------- 20. Settings layout ---------- */
.settings-section { display: grid; grid-template-columns: minmax(200px, 280px) 1fr; gap: 24px 48px; padding-block: 28px; border-block-end: 1px solid var(--line); }
.settings-section:last-child { border-block-end: 0; }
.settings-section__title { font-size: var(--text-base); font-weight: var(--weight-semibold); color: var(--text); }
.settings-section__desc { font-size: var(--text-sm); line-height: var(--lh-sm); color: var(--text-3); margin-block-start: 4px; }
.settings-section__body { display: flex; flex-direction: column; gap: 20px; min-inline-size: 0; max-inline-size: 560px; }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; padding-block: 16px; border-block-start: 1px solid var(--line); }

/* ---------- 21. Utilities (small, deliberate set) ---------- */
.row { display: flex; align-items: center; gap: var(--gap, 8px); }
.stack { display: flex; flex-direction: column; gap: var(--gap, 8px); }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-inline-size: 0; }
.spacer { flex: 1; }
.between { justify-content: space-between; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-inline-size: 0; }
.line-clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.divider { block-size: 1px; background: var(--line); border: 0; }
.divider-v { inline-size: 1px; align-self: stretch; background: var(--line); }
.hairline-top { border-block-start: 1px solid var(--line); }
.hairline-bottom { border-block-end: 1px solid var(--line); }
.sr-only { position: absolute !important; inline-size: 1px; block-size: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.no-scrollbar { scrollbar-width: none; } .no-scrollbar::-webkit-scrollbar { display: none; }
.scroll-thin { scrollbar-width: thin; scrollbar-color: var(--gray-300) transparent; }

/* ==========================================================================
   v2 — SURFACE & MOBILE LAYER  (sections 24–35)
   Added from nine product references: admin tenant settings, clinic billing
   (drawer + cash dialog), reservation split dialog, filter/login kit, a
   monochrome card collection, and four mobile flows (contract signing,
   ride-share, shipping, onboarding). Opt-in on top of the hairline base:
   nothing here changes an existing component. Same tokens, BEM, logical
   properties, RTL. Rules that apply inside this layer: one ink primary per
   view; tints only behind icons, badges and the hero highlight; shadows only
   on .card--elevated and floating layers; everything else hairline.
   ========================================================================== */

/* ---------- 24. Canvas & pill buttons ---------- */
.icon--fill { fill: currentColor; stroke: none; }
/* Grey canvas with white cards. Add .app--canvas to .app (or .page--canvas to .page). */
.app--canvas .page, .page--canvas { background: var(--bg-canvas); }
.app--canvas > .sidebar { background: var(--bg-soft); }

.btn--pill { border-radius: var(--radius-full); }
.btn--2xl { --btn-h: var(--h-2xl); padding-inline: 20px; font-size: var(--text-base); font-weight: var(--weight-semibold); gap: 8px; }
.btn--3xl { --btn-h: var(--h-3xl); padding-inline: 28px; font-size: var(--text-md); font-weight: var(--weight-semibold); gap: 8px; }
.btn--2xl .icon, .btn--3xl .icon { inline-size: 18px; block-size: 18px; }
.btn--2xl.btn--icon { inline-size: var(--h-2xl); padding: 0; } .btn--3xl.btn--icon { inline-size: var(--h-3xl); padding: 0; }
.btn--round { border-radius: 50%; }
.btn--soft { background: var(--bg-fill); color: var(--text); border-color: transparent; }
.btn--soft:hover { background: var(--line-strong); }
.btn--accent { background: var(--accent); color: var(--on-accent); border-color: var(--accent); box-shadow: var(--shadow-xs); }
.btn--accent:hover { filter: brightness(1.06); }
.btn--outline-danger { background: var(--bg); color: var(--danger); border-color: var(--line-control); }
.btn--outline-danger:hover { background: var(--danger-tint); border-color: var(--danger-line); }
.btn--outline-accent { background: var(--bg); color: var(--accent); border-color: var(--line-control); }
.btn--outline-accent:hover { background: var(--accent-tint); border-color: var(--info-line); }
.btn--link.t-1 { color: var(--text); } .btn--link.t-2 { color: var(--text-2); } .btn--link.t-3 { color: var(--text-3); }
.btn--caps { font-size: var(--text-2xs); font-weight: var(--weight-bold); letter-spacing: var(--tracking-caps); text-transform: uppercase; }
.btn--notif { position: relative; }
.btn--notif::after { content: ""; position: absolute; inset-block-start: 7px; inset-inline-end: 7px; inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--danger-dot); box-shadow: 0 0 0 2px var(--bg); }

/* ---------- 25. Cards & tiles ---------- */
.card { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-2xl); min-inline-size: 0; }
.card--elevated { border-color: transparent; box-shadow: var(--shadow-md); }
.card--soft { border-color: transparent; background: var(--bg-soft); }
.card--fill { border-color: transparent; background: var(--bg-fill); }
.card--ink { border-color: transparent; background: var(--bg-inverse); color: var(--text-inverse); }
.card--ink .t-2, .card--ink .t-3, .card--ink .t-4, .card--ink .t-micro { color: rgba(255, 255, 255, 0.65); }
.card--tint { border-color: transparent; background: var(--accent-tint); }
.card--sm { border-radius: var(--radius-xl); }
.card--xl { border-radius: var(--radius-3xl); }
.card--clip { overflow: hidden; }
.card--outline-accent { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card--outline-ink { border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 20px 0; }
.card__body { padding: 20px; }
.card__body--sm { padding: 14px 16px; }
.card__foot { display: flex; align-items: center; gap: 12px; padding: 0 20px 20px; }
.card__title { font-size: var(--text-md); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-snug); }
.card__sub { font-size: var(--text-sm); line-height: var(--lh-sm); color: var(--text-3); margin-block-start: 2px; }
.card__cap { display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-weight: var(--weight-medium); color: var(--text-2); }
.card__cap .icon { color: var(--text-3); }
.card + .card { margin-block-start: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 20px; align-items: start; }
.cards--masonry { display: block; columns: 4 240px; column-gap: 20px; }
.cards--masonry > .card { break-inside: avoid; margin-block-end: 20px; }
.layout-2 { display: grid; grid-template-columns: 1fr 380px; gap: 24px; align-items: start; }
.layout-2--rev { grid-template-columns: 380px 1fr; }

/* Icon tile — a tinted square behind an icon (card corners, option rows, specs) */
.tile { display: inline-flex; align-items: center; justify-content: center; flex: none; inline-size: 44px; block-size: 44px; border-radius: var(--radius-xl); background: var(--bg-soft); color: var(--text-2); }
.tile .icon { inline-size: 20px; block-size: 20px; }
.tile--sm { inline-size: 36px; block-size: 36px; border-radius: var(--radius-lg); } .tile--sm .icon { inline-size: 16px; block-size: 16px; }
.tile--lg { inline-size: 56px; block-size: 56px; border-radius: var(--radius-2xl); } .tile--lg .icon { inline-size: 24px; block-size: 24px; }
.tile--xl { inline-size: 72px; block-size: 72px; border-radius: 20px; } .tile--xl .icon { inline-size: 32px; block-size: 32px; stroke-width: 1.5; }
.tile--round { border-radius: 50%; }
.tile--outline { background: var(--bg); border: 1px solid var(--line); color: var(--text); }
.tile--white { background: var(--bg); color: var(--text); }
.tile--ink { background: var(--bg-inverse); color: var(--text-inverse); }
.tile--success { background: var(--success-tint); color: var(--success); }
.tile--warning { background: var(--warning-tint); color: var(--warning); }
.tile--danger { background: var(--danger-tint); color: var(--danger); }
.tile--info, .tile--accent { background: var(--accent-tint); color: var(--accent); }
.tile--violet { background: var(--violet-tint); color: var(--violet); }
.tile--pink { background: var(--pink-tint); color: var(--pink); }

/* Placeholder image */
.ph { display: grid; place-items: center; aspect-ratio: 4 / 3; border-radius: var(--radius-xl); background: var(--bg-soft); color: var(--line-strong); overflow: hidden; }
.ph .icon { inline-size: 36px; block-size: 36px; stroke-width: 1.5; }
.ph > img { inline-size: 100%; block-size: 100%; object-fit: cover; }
.ph--sm { inline-size: 72px; aspect-ratio: 1; border-radius: var(--radius-md); } .ph--sm .icon { inline-size: 26px; block-size: 26px; }
.ph--wide { aspect-ratio: 3 / 1; }

/* ---------- 26. KPI, amounts, highlight ---------- */
.kpi { display: flex; align-items: center; gap: 14px; min-inline-size: 0; }
.kpi__label { font-size: var(--text-sm); color: var(--text-3); }
.kpi__row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.kpi__value { font-size: var(--text-3xl); line-height: var(--lh-3xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tight); font-variant-numeric: tabular-nums; }
.kpi__delta { display: inline-flex; align-items: center; gap: 3px; font-size: var(--text-xs); font-weight: var(--weight-medium); color: var(--success); font-variant-numeric: tabular-nums; }
.kpi__delta--down { color: var(--danger); }
.kpi__delta .icon { inline-size: 12px; block-size: 12px; stroke-width: 2.25; }
.kpi-row { display: flex; align-items: center; gap: 32px; flex-wrap: wrap; }
.kpi-row > .divider-v { block-size: 40px; align-self: center; }

.amount { font-size: var(--text-3xl); line-height: var(--lh-3xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-tight); font-variant-numeric: tabular-nums; }
.amount--lg { font-size: var(--text-4xl); line-height: var(--lh-4xl); }
.amount--xl { font-size: var(--text-5xl); line-height: var(--lh-5xl); letter-spacing: -0.03em; }
.amount--2xl { font-size: var(--text-6xl); line-height: var(--lh-6xl); letter-spacing: -0.04em; }
.amount__unit { font-size: 0.5em; font-weight: var(--weight-medium); color: var(--text-2); letter-spacing: 0; }
.mini-stat__label { font-size: var(--text-2xs); font-weight: var(--weight-medium); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-3); margin-block-end: 4px; }
.mini-stat__value { font-size: var(--text-xl); line-height: var(--lh-xl); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }

/* Highlight — the one gradient allowed: a hero figure (fare, total) on a soft tint fading to grey */
.highlight { --hl: var(--success-tint); padding: 24px; border-radius: var(--radius-2xl); background: linear-gradient(180deg, var(--hl) 0%, var(--bg-soft) 100%); text-align: center; }
.highlight--accent { --hl: var(--accent-tint); } .highlight--danger { --hl: var(--danger-tint); } .highlight--warning { --hl: var(--warning-tint); } .highlight--violet { --hl: var(--violet-tint); }

/* ---------- 27. Badges, counts, ratings, pills ---------- */
/* Tinted badges — soft fill + coloured text (status pills in tables, "In Transit", "Verified ID") */
.badge--tint { border-color: transparent; background: var(--bg-selected); color: var(--text-2); font-weight: var(--weight-semibold); }
.badge--tint.badge--success { background: var(--success-tint); color: var(--success); }
.badge--tint.badge--warning { background: var(--warning-tint); color: var(--warning); }
.badge--tint.badge--danger { background: var(--danger-tint); color: var(--danger); }
.badge--tint.badge--info { background: var(--accent-tint); color: var(--accent); }
.badge--tint.badge--violet { background: var(--violet-tint); color: var(--violet); }
.badge--tint.badge--ink { background: var(--bg-inverse); color: var(--text-inverse); }
.badge--lg { block-size: 30px; padding-inline: 14px; font-size: var(--text-sm); border-radius: var(--radius-full); }
.badge--lg .icon { inline-size: 14px; block-size: 14px; }
.badge--caps { text-transform: uppercase; letter-spacing: var(--tracking-caps); font-size: var(--text-2xs); }
.badge--dot::before { content: ""; inline-size: 6px; block-size: 6px; border-radius: 50%; background: currentColor; }

.count--lg { min-inline-size: 30px; block-size: 30px; padding-inline: 9px; font-size: var(--text-sm); border-radius: var(--radius-full); }
.has-count { position: relative; display: inline-flex; }
.has-count > .count { position: absolute; inset-block-start: -8px; inset-inline-end: -8px; }
.has-count > .count--lg { inset-block-start: -12px; inset-inline-end: -12px; }

.rating { display: inline-flex; align-items: center; gap: 4px; font-weight: var(--weight-semibold); color: var(--info); font-variant-numeric: tabular-nums; }
.rating .icon { inline-size: 14px; block-size: 14px; fill: currentColor; stroke: none; }
.stars { display: inline-flex; gap: 2px; color: var(--text); }
.stars .icon { inline-size: 12px; block-size: 12px; fill: currentColor; stroke: none; }
.stars .is-off { color: var(--line-strong); }

/* Amount pills: received (ink) / sent (grey) */
.pill-amount { display: inline-flex; align-items: center; block-size: 28px; padding-inline: 12px; border-radius: var(--radius-full); background: var(--bg-inverse); color: var(--text-inverse); font-size: var(--text-2xs); font-weight: var(--weight-bold); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pill-amount--neg { background: var(--line-strong); color: var(--text); }
.pill-amount--soft { background: var(--bg-fill); color: var(--text); }

/* ---------- 28. Form additions ---------- */
.input--pill { border-radius: var(--radius-full); }
.input--fill { background: var(--bg-soft); border-color: transparent; }
.input--fill:focus { background: var(--bg); }
.input--xl { --input-h: var(--h-2xl); font-size: var(--text-base); padding-inline: 14px; border-radius: var(--radius-xl); }
.input--3xl { --input-h: var(--h-3xl); font-size: var(--text-base); padding-inline: 16px; }
.input-wrap--xl > .icon { inset-inline-start: 16px; } .input-wrap--xl > .icon ~ .input { padding-inline-start: 44px; }
.input-wrap__sep { position: absolute; inset-inline-start: 38px; inline-size: 1px; block-size: 18px; background: var(--line-strong); }
.input-wrap__sep ~ .input { padding-inline-start: 52px !important; }
.input-wrap__prefix { position: absolute; inset-inline-start: 12px; color: var(--text-2); font-weight: var(--weight-medium); pointer-events: none; }
.input-wrap__prefix ~ .input { padding-inline-start: 28px; }
.input-wrap__end .badge { margin-inline-end: 4px; }
.counter { font-size: var(--text-2xs); color: var(--text-3); text-align: end; font-variant-numeric: tabular-nums; }

/* Floating-label box: label inside, value below (login forms, range outputs, phone numbers) */
.float { position: relative; display: flex; align-items: center; gap: 12px; block-size: 56px; padding-inline: 14px; background: var(--bg-soft); border: 1px solid transparent; border-radius: var(--radius-xl); transition: border-color var(--dur-1) var(--ease-out), background var(--dur-1) var(--ease-out); }
.float:focus-within { background: var(--bg); border-color: var(--text); }
.float > .icon { color: var(--text-3); }
.float__body { flex: 1; min-inline-size: 0; display: flex; flex-direction: column; justify-content: center; gap: 1px; }
.float__label { font-size: var(--text-2xs); line-height: var(--lh-2xs); color: var(--text-3); }
.float__body > input, .float__body > select { inline-size: 100%; block-size: 20px; padding: 0; border: 0; background: none; outline: 0; font-size: var(--text-base); font-weight: var(--weight-medium); color: var(--text); }
.float__body > input:read-only { cursor: default; }
.float__value { font-size: var(--text-base); font-weight: var(--weight-medium); }
.float__end { display: flex; align-items: center; color: var(--text-3); }
.float--outline { background: var(--bg); border-color: var(--line-control); }
.float--active { border-color: var(--text); background: var(--bg); }
.float--sm { block-size: 52px; }

/* Phone number with country code */
.input-phone { display: flex; align-items: center; gap: 6px; padding: 6px; border: 1px solid var(--line-control); border-radius: var(--radius-xl); background: var(--bg); }
.input-phone__cc { display: flex; align-items: center; gap: 8px; block-size: var(--h-2xl); padding-inline: 14px; border-radius: 9px; background: var(--bg-soft); font-weight: var(--weight-semibold); flex: none; direction: ltr; }
.input-phone > .float { flex: 1; block-size: var(--h-2xl); background: none; border: 0; padding-inline: 8px; }
.input-phone .float__body > input { direction: ltr; }
.flag { font-size: 18px; line-height: 1; }

/* Toggle pill: [ On ● ] */
.toggle-pill { display: inline-flex; align-items: center; gap: 8px; block-size: var(--h-lg); padding-inline: 14px 6px; border-radius: var(--radius-full); background: var(--bg-inverse); color: var(--text-inverse); font-size: var(--text-sm); font-weight: var(--weight-semibold); user-select: none; transition: background var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out); }
.toggle-pill__knob { inline-size: 24px; block-size: 24px; border-radius: 50%; background: var(--bg); transition: background var(--dur-2) var(--ease-out); }
.toggle-pill[aria-pressed="false"] { background: var(--bg-fill); color: var(--text-2); }
.toggle-pill[aria-pressed="false"] .toggle-pill__knob { background: var(--text-4); }
.toggle-pill:focus-visible { box-shadow: var(--focus-ring); }

/* Circle check (black filled circle with tick — lists, "Remember me") */
.check--circle input, .radio--circle input { inline-size: 20px; block-size: 20px; border-radius: 50%; border-color: var(--line-strong); margin-block-start: 0; }
.check--circle input::after { inline-size: 12px; block-size: 12px; }
.check--circle, .radio--circle { align-items: center; }
.radio--circle input:checked { border-width: 6px; }

/* Choice chips — quick amounts, price options; single select with [data-chips] */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip--choice { block-size: var(--h-lg); padding-inline: 14px; border-radius: var(--radius-md); font-size: var(--text-sm); font-weight: var(--weight-medium); color: var(--text); background: var(--bg); justify-content: center; }
.chip--choice:hover { border-color: var(--text); }
.chip--choice[aria-pressed="true"], .chip--choice.is-active { border-color: var(--text); background: var(--bg-soft); }
.chip--fill { background: var(--bg-fill); border-color: transparent; }
.chip--fill[aria-pressed="true"], .chip--fill.is-active { background: var(--bg-inverse); color: var(--text-inverse); border-color: transparent; }
.chip--fill[aria-pressed="true"] .chip__sub { color: rgba(255, 255, 255, 0.6); }
.chip--stack { flex-direction: column; block-size: auto; padding: 8px 14px; gap: 3px; }
.chip__sub { display: block; font-size: 9px; line-height: 1; font-weight: var(--weight-medium); color: var(--text-3); letter-spacing: var(--tracking-caps); text-transform: uppercase; }
.chips--grow > .chip { flex: 1; }

/* Segmented additions */
.segmented--lg .segmented__item { block-size: var(--h-2xl); padding-inline: 24px; font-size: var(--text-md); }
.segmented--white { background: var(--bg); border: 1px solid var(--line-control); padding: 4px; gap: 4px; border-radius: var(--radius-xl); }
.segmented--white .segmented__item { block-size: 36px; border-radius: 9px; }
.segmented--white .segmented__item[aria-pressed="true"] { background: var(--bg-soft); box-shadow: none; }

/* Dual range (price filter). Two native ranges stacked; JS [data-range] draws the fill and writes the outputs. */
.range-dual { position: relative; block-size: 44px; }
.range-dual__track { position: absolute; inset-inline: 10px; inset-block-start: 50%; block-size: 2px; transform: translateY(-50%); background: var(--line-control); border-radius: 2px; }
.range-dual__fill { position: absolute; inset-block: 0; background: var(--bg-inverse); border-radius: 2px; }
.range-dual > input[type="range"] { position: absolute; inset-inline-start: 0; inset-block-start: 0; inline-size: 100%; block-size: 44px; margin: 0; appearance: none; -webkit-appearance: none; background: none; pointer-events: none; outline: 0; }
.range-dual > input[type="range"]::-webkit-slider-runnable-track { block-size: 0; background: none; }
.range-dual > input[type="range"]::-moz-range-track { block-size: 0; background: none; }
.range-dual > input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; inline-size: 20px; block-size: 20px; margin-block-start: -10px; border-radius: 50%; background: var(--bg-inverse); border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--bg-inverse), var(--shadow-sm); pointer-events: auto; cursor: grab; }
.range-dual > input[type="range"]::-moz-range-thumb { inline-size: 14px; block-size: 14px; border-radius: 50%; background: var(--bg-inverse); border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--bg-inverse); pointer-events: auto; cursor: grab; }
.range-dual__out { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-block-start: 8px; }

/* Editor — textarea with a formatting bar below */
.editor { border: 1px solid var(--line-control); border-radius: var(--radius-xl); background: var(--bg); overflow: hidden; }
.editor > .textarea { border: 0; border-radius: 0; box-shadow: none !important; background: var(--bg-soft); min-block-size: 120px; }
.editor > .textarea:focus { background: var(--bg); }
.editor__bar { display: flex; align-items: center; gap: 2px; padding: 6px 8px; border-block-start: 1px solid var(--line); flex-wrap: wrap; }
.editor__bar .btn--ghost { --btn-h: 34px; inline-size: 34px; color: var(--text-2); }
.editor__sep { inline-size: 1px; block-size: 20px; background: var(--line); margin-inline: 4px; }

/* File row — a document line with preview action (KYC uploads) */
.file--row { display: flex; inline-size: 100%; max-inline-size: none; padding: 12px 14px; border-radius: var(--radius-xl); }
.file--row .file__body { flex: 1; }
.file__glyph { display: grid; place-items: center; inline-size: 36px; block-size: 36px; border-radius: var(--radius-md); background: var(--danger-tint); color: var(--danger); font-size: 9px; font-weight: var(--weight-bold); letter-spacing: var(--tracking-caps); flex: none; }
.file__glyph--doc { background: var(--accent-tint); color: var(--accent); }
.file__glyph--img { background: var(--success-tint); color: var(--success); }
.file__glyph--xls { background: var(--success-tint); color: var(--success); }

/* Dropzone additions */
.dropzone--soft { background: var(--bg-soft); border-radius: var(--radius-xl); padding: 28px 20px; gap: 8px; }
.dropzone__title { font-size: var(--text-base); font-weight: var(--weight-semibold); color: var(--text); }
.dropzone__sub { font-size: var(--text-xs); line-height: var(--lh-sm); color: var(--text-3); }
.dropzone__sub b { color: var(--text); font-weight: var(--weight-semibold); }
.dropzone > input[type="file"] { display: none; }

/* ---------- 29. Options, choices, meta, key/value ---------- */
/* Option card — icon tile + title/sub, selected = ink outline (signing methods, payment methods) */
.options { display: flex; flex-direction: column; gap: 10px; }
.option { position: relative; display: flex; align-items: center; gap: 14px; inline-size: 100%; padding: 12px 14px; border: 1px solid var(--line-control); border-radius: var(--radius-xl); background: var(--bg); color: inherit; text-align: start; cursor: pointer; transition: border-color var(--dur-1) var(--ease-out), box-shadow var(--dur-1) var(--ease-out); }
.option:hover { border-color: var(--line-strong); text-decoration: none; }
.option > input { position: absolute; opacity: 0; inline-size: 0; block-size: 0; }
.option[aria-pressed="true"], .option.is-selected, .option:has(> input:checked) { border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.option:focus-visible, .option:has(> input:focus-visible) { box-shadow: var(--focus-ring); border-color: var(--focus); }
.option__body { flex: 1; min-inline-size: 0; }
.option__title { display: block; font-weight: var(--weight-medium); }
.option__sub { display: block; font-size: var(--text-xs); line-height: var(--lh-xs); color: var(--text-2); }
.option__end { margin-inline-start: auto; display: flex; align-items: center; color: var(--text-3); }
.option--dashed { border-style: dashed; }
.option--fill { background: var(--bg-soft); border-color: transparent; }

/* Choice card — large filled card, selected one turns ink (onboarding goals) */
.choice { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; inline-size: 100%; padding: 20px; border-radius: var(--radius-xl); background: var(--bg-fill); color: var(--text); cursor: pointer; text-align: start; transition: background var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out); }
.choice > input { position: absolute; opacity: 0; inline-size: 0; block-size: 0; }
.choice__title { display: block; font-size: var(--text-lg); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-snug); }
.choice__sub { display: block; font-size: var(--text-xs); color: var(--text-3); margin-block-start: 2px; }
.choice > .icon { inline-size: 24px; block-size: 24px; flex: none; }
.choice[aria-pressed="true"], .choice.is-selected, .choice:has(> input:checked) { background: var(--bg-inverse); color: var(--text-inverse); }
.choice[aria-pressed="true"] .choice__sub, .choice.is-selected .choice__sub, .choice:has(> input:checked) .choice__sub { color: rgba(255, 255, 255, 0.6); }
.choice:has(> input:focus-visible) { box-shadow: var(--focus-ring); }

/* Selectable list rows with a trailing circle check (country picker) */
.list--select .row-item { cursor: pointer; padding-inline: 4px; border-radius: 0; }
.list--select .row-item:hover { background: var(--bg-hover); }
.list--select .row-item.is-selected { background: var(--bg-soft); font-weight: var(--weight-medium); }
.list--select .row-item .check { pointer-events: none; margin-inline-start: auto; }

/* Meta row — icon · label/value groups divided by hairlines */
.meta-row { display: flex; align-items: center; flex-wrap: wrap; gap: 12px 0; }
.meta { display: flex; align-items: center; gap: 12px; padding-inline-end: 22px; margin-inline-end: 22px; border-inline-end: 1px solid var(--line); }
.meta:last-of-type { border: 0; padding-inline-end: 0; margin-inline-end: 0; }
.meta > .icon { color: var(--text-3); inline-size: 18px; block-size: 18px; }
.meta__label { font-size: var(--text-xs); color: var(--text-3); }
.meta__value { font-weight: var(--weight-semibold); }
.meta-row > .spacer + * { margin-inline-start: auto; }

/* Key / value lines (bills, details, summaries) */
.kv { display: flex; flex-direction: column; gap: 10px; font-size: var(--text-sm); }
.kv__row { display: flex; justify-content: space-between; gap: 16px; }
.kv__row > dt, .kv__row > .kv__k { color: var(--text-2); }
.kv__row > dd, .kv__row > .kv__v { font-weight: var(--weight-medium); text-align: end; font-variant-numeric: tabular-nums; }
.kv__row small { display: block; font-size: var(--text-2xs); color: var(--text-3); font-weight: var(--weight-regular); }
.kv__row--total { border-block-start: 1px solid var(--line); padding-block-start: 12px; margin-block-start: 2px; font-size: var(--text-md); }
.kv__row--total > dt, .kv__row--total > .kv__k { color: var(--text); font-weight: var(--weight-semibold); }
.kv__row--total > dd, .kv__row--total > .kv__v { font-weight: var(--weight-semibold); }
.kv--loose { gap: 14px; }
.kv--lined { gap: 0; }
.kv--lined .kv__row { padding-block: 10px; border-block-end: 1px solid var(--line); }
.kv--lined .kv__row:last-child { border-block-end: 0; }

/* Info grid — label above value, two columns (patient details) */
.info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px 24px; }
.info-grid > div > dt, .info-grid__label { font-size: var(--text-2xs); font-weight: var(--weight-medium); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--text-3); margin-block-end: 4px; }
.info-grid > div > dd { font-weight: var(--weight-medium); }
.info-tile { display: flex; align-items: flex-start; gap: 12px; min-inline-size: 0; }
.info-tile__value { font-weight: var(--weight-medium); }

/* Media row — avatar, title/sub, actions (rider contact) */
.media { display: flex; align-items: center; gap: 12px; }
.media__body { flex: 1; min-inline-size: 0; }
.media__title { font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.media__sub { font-size: var(--text-xs); color: var(--text-3); }
.media__actions { display: flex; align-items: center; gap: 4px; flex: none; }

/* Setting row — title/description + control (reminder) */
.setting { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-block: 14px; }
.setting__title { font-weight: var(--weight-semibold); }
.setting__sub { font-size: var(--text-xs); line-height: var(--lh-sm); color: var(--text-3); margin-block-start: 2px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-block: 20px 12px; }
.section-head > a { font-size: var(--text-sm); color: var(--text-2); font-weight: var(--weight-medium); }

/* Quote line (clinical note) and secure notice */
.quote { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius-lg); font-size: var(--text-sm); color: var(--text-2); font-style: italic; }
.quote > .btn { margin-inline-start: auto; font-style: normal; }
.notice { display: flex; align-items: center; gap: 8px; font-size: var(--text-xs); color: var(--text-2); }
.notice > .icon { color: var(--success); }

/* Avatar additions */
.avatar--ink { background: var(--bg-inverse); color: var(--text-inverse); }
.avatar--accent { background: var(--accent-tint); color: var(--accent); }
.avatar--pink { background: var(--pink-tint); color: var(--pink); }
.avatar--outline { background: var(--bg); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-control); }
.avatar--outline::after { display: none; }

/* ---------- 30. Steps, routes, steppers, tracks ---------- */
/* Numbered Q&A (questionnaire answers) */
.steps { display: flex; flex-direction: column; gap: 10px; }
.step { display: flex; gap: 14px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--radius-xl); background: var(--bg); }
.step__n { display: grid; place-items: center; flex: none; inline-size: 22px; block-size: 22px; margin-block-start: 2px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: var(--text-2xs); font-weight: var(--weight-semibold); }
.step__q { font-size: var(--text-xs); color: var(--text-3); }
.step__a { font-weight: var(--weight-medium); margin-block-start: 2px; }

/* Segmented progress (onboarding, multi-step) */
.progress-steps { display: flex; gap: 6px; }
.progress-steps > i { flex: 1; block-size: 3px; border-radius: 2px; background: var(--line); }
.progress-steps > i.is-done { background: var(--text); }
.progress-steps--sm { inline-size: 150px; } .progress-steps--sm > i { block-size: 4px; }

/* Vertical route — pickup → stops → dropoff */
.route { position: relative; display: flex; flex-direction: column; gap: 20px; padding-inline-start: 30px; }
.route::before { content: ""; position: absolute; inset-inline-start: 6px; inset-block: 8px; inline-size: 2px; background: var(--line); }
.route__stop { position: relative; display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.route__stop::before { content: ""; position: absolute; inset-inline-start: -30px; inset-block-start: 3px; inline-size: 14px; block-size: 14px; border-radius: 50%; background: var(--bg); border: 2px solid var(--line-strong); z-index: 1; }
.route__stop.is-active::before { border-color: var(--info); box-shadow: 0 0 0 4px var(--info-tint); }
.route__stop.is-active::after { content: ""; position: absolute; inset-inline-start: -24px; inset-block-start: 17px; block-size: calc(100% + 10px); inline-size: 2px; background: var(--info); }
.route__stop.is-done::before { border-color: var(--info); background: var(--info-tint); }
.route__stop.is-end::before { background: var(--bg-fill); }
.route__label { font-size: var(--text-sm); color: var(--text-3); }
.route__name { font-weight: var(--weight-medium); }
.route__time { font-weight: var(--weight-semibold); text-align: end; white-space: nowrap; font-variant-numeric: tabular-nums; }
.route__time small { display: block; font-weight: var(--weight-regular); color: var(--text-3); font-size: var(--text-xs); }

/* Horizontal tracking stepper (received → in transit → delivered). --progress is set by [data-progress]. */
.stepper { position: relative; display: flex; justify-content: space-between; --progress: 0%; }
.stepper::before, .stepper::after { content: ""; position: absolute; inset-block-start: 10px; inset-inline: 11px; block-size: 2px; background: var(--line-strong); border-radius: 2px; }
.stepper::after { background: var(--bg-inverse); inset-inline-end: auto; inline-size: var(--progress); }
.stepper__step { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; }
.stepper__step:first-child { align-items: flex-start; text-align: start; }
.stepper__step:last-child { align-items: flex-end; text-align: end; }
.stepper__node { display: grid; place-items: center; inline-size: 22px; block-size: 22px; border-radius: 50%; border: 2px solid var(--bg-inverse); background: var(--bg); }
.stepper__node .icon { inline-size: 12px; block-size: 12px; stroke-width: 2.6; }
.stepper__step.is-done .stepper__node { background: var(--bg-inverse); color: var(--text-inverse); }
.stepper__step.is-pending .stepper__node { border-color: var(--line-strong); background: var(--line-strong); color: transparent; }
.stepper__label { font-size: var(--text-xs); font-weight: var(--weight-semibold); }
.stepper__label small { display: block; font-weight: var(--weight-regular); color: var(--text-3); font-size: 10px; }
.stepper--accent::after { background: var(--accent); }
.stepper--accent .stepper__node { border-color: var(--accent); }
.stepper--accent .stepper__step.is-done .stepper__node { background: var(--accent); }

/* Two-point trip  ● ──────── ○ */
.trip { display: flex; align-items: flex-start; gap: 12px; }
.trip__dot { inline-size: 8px; block-size: 8px; border-radius: 50%; background: var(--text); margin-block-start: 6px; flex: none; }
.trip__dot--hollow { background: var(--line-strong); }
.trip__line { flex: 1; block-size: 1px; background: var(--line); margin-block-start: 9px; }
.trip__point { font-size: var(--text-2xs); font-weight: var(--weight-medium); color: var(--text-2); }

/* Track timeline — time column, ink node, text (shipment events). Variant of .timeline. */
.timeline--track .timeline__item { grid-template-columns: 72px 22px 1fr; column-gap: 14px; padding-block-end: 24px; }
.timeline--track .timeline__item::before { inset-inline-start: 96px; inset-block: 24px 0; inline-size: 0; border-inline-start: 2px dotted var(--line-strong); background: none; }
.timeline--track .timeline__time { margin: 0; font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--text); font-variant-numeric: tabular-nums; }
.timeline--track .timeline__time small { display: block; font-weight: var(--weight-regular); color: var(--text-3); font-size: var(--text-2xs); }
.timeline--track .timeline__marker { inline-size: 22px; block-size: 22px; border: 0; background: var(--bg-inverse); color: var(--text-inverse); }
.timeline--track .timeline__marker .icon { inline-size: 12px; block-size: 12px; stroke-width: 2.6; }
.timeline--track .timeline__marker.is-pending { background: var(--bg); border: 2px solid var(--line-strong); color: transparent; }
.timeline--track .timeline__text { font-size: var(--text-xs); line-height: var(--lh-sm); padding-block-start: 2px; }

/* ---------- 31. Mobile: phone frame, tab bar, bottom sheet ---------- */
/* .phone is a 375×812 preview frame for mobile screens. On a real mobile page drop the frame and put
   .phone__screen / .phone__cta / .tabbar / .sheet directly in <body>. */
.phone-stage { display: flex; gap: 40px; justify-content: center; align-items: flex-start; flex-wrap: wrap; padding: 48px 24px; min-block-size: 100dvh; background: var(--bg-canvas); }
.phone { position: relative; display: flex; flex-direction: column; flex: none; inline-size: var(--phone-w); block-size: var(--phone-h); overflow: hidden; background: var(--bg); border-radius: 48px; border: 10px solid #111; box-shadow: var(--shadow-lg); }
.phone--bare { border: 0; border-radius: 44px; box-shadow: var(--shadow-md); }
.phone__island { position: absolute; inset-block-start: 12px; inset-inline-start: 50%; transform: translateX(-50%); inline-size: 110px; block-size: 32px; border-radius: var(--radius-full); background: #111; z-index: 5; }
[dir="rtl"] .phone__island { transform: translateX(50%); }
.phone__status { display: flex; align-items: center; justify-content: space-between; padding: 18px 28px 0; font-weight: var(--weight-semibold); font-size: var(--text-md); flex: none; font-variant-numeric: tabular-nums; }
.phone__status .icon { inline-size: 16px; block-size: 16px; }
.phone__status > span:last-child { display: flex; align-items: center; gap: 5px; }
.phone__screen { position: relative; flex: 1; overflow: auto; padding: 16px 20px 24px; background: var(--bg-soft); scrollbar-width: none; }
.phone__screen::-webkit-scrollbar { display: none; }
.phone__screen > * { flex-shrink: 0; }
.phone__screen--white { background: var(--bg); }
.phone__island + .phone__screen { padding-block-start: 64px; }
.phone__bar { position: relative; display: flex; align-items: center; justify-content: center; min-block-size: 44px; padding: 4px 0 16px; font-size: var(--text-lg); font-weight: var(--weight-semibold); }
.phone__bar > .btn:first-child { position: absolute; inset-inline-start: 0; inset-block-start: 0; }
.phone__bar > .btn:last-child:not(:first-child) { position: absolute; inset-inline-end: 0; inset-block-start: 0; }
.phone__cta { display: flex; flex-direction: column; align-items: center; gap: 12px; flex: none; padding: 12px 20px 24px; background: var(--bg-soft); }
.phone__cta--white { background: var(--bg); }
.phone__cta--row { flex-direction: row; align-items: stretch; }
.phone__cta--row > .btn--block { flex: 1; }
.phone__home { position: absolute; inset-block-end: 8px; inset-inline-start: 50%; transform: translateX(-50%); inline-size: 134px; block-size: 5px; border-radius: 3px; background: #111; z-index: 5; }
.phone__logo { display: flex; align-items: center; gap: 8px; font-size: 22px; font-weight: var(--weight-bold); letter-spacing: -0.03em; }
.phone > .backdrop { position: absolute; inset: 0; z-index: 5; background: var(--backdrop); opacity: 0; pointer-events: none; transition: opacity var(--dur-3) var(--ease-out); }
.phone > .backdrop.is-open { opacity: 1; pointer-events: auto; }
.m-row { display: flex; justify-content: space-between; align-items: center; padding-block: 10px; font-size: var(--text-sm); }
.m-row__k { display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.m-row__k .icon { inline-size: 15px; block-size: 15px; color: var(--text-3); }
.m-row__v { font-weight: var(--weight-medium); }
.m-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.m-pair__label { font-size: var(--text-xs); color: var(--text-2); margin-block-end: 4px; }
.m-pair__value { font-weight: var(--weight-semibold); }
.m-pair__value small { display: block; font-size: var(--text-2xs); color: var(--text-3); font-weight: var(--weight-regular); }
.m-pair > .text-end .m-pair__label { text-align: end; }

/* Bottom sheet — lives inside .phone (absolute). Open with [data-sheet-open="id"], close with [data-sheet-close]. */
.sheet { position: absolute; inset-inline: 0; inset-block-end: 0; z-index: 6; max-block-size: 92%; overflow: auto; padding: 28px 20px 24px; background: var(--bg); border-radius: 28px 28px 0 0; box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.15); transform: translateY(100%); transition: transform var(--dur-4) var(--ease-out); scrollbar-width: none; }
.sheet::-webkit-scrollbar { display: none; }
.sheet.is-open { transform: none; }
.sheet__handle { inline-size: 40px; block-size: 4px; border-radius: 2px; background: var(--line-strong); margin: 0 auto 20px; }
body > .sheet { position: fixed; z-index: var(--z-modal); }

/* Floating tab bar */
.tabbar { display: flex; align-items: center; gap: 4px; inline-size: max-content; padding: 8px; background: var(--bg); border-radius: var(--radius-full); box-shadow: var(--shadow-lg); }
.tabbar > a, .tabbar > button { display: flex; align-items: center; gap: 8px; block-size: 48px; min-inline-size: 48px; padding-inline: 14px; border-radius: var(--radius-full); color: var(--text-3); font-size: var(--text-sm); font-weight: var(--weight-semibold); text-decoration: none; transition: background var(--dur-2) var(--ease-out), color var(--dur-2) var(--ease-out); }
.tabbar > a:hover { text-decoration: none; color: var(--text); }
.tabbar > .is-active, .tabbar > [aria-current="page"] { background: var(--bg-inverse); color: var(--text-inverse); padding-inline: 18px; }
.tabbar .icon { inline-size: 18px; block-size: 18px; }
.phone > .tabbar { position: absolute; inset-block-end: 36px; inset-inline-start: 50%; transform: translateX(-50%); z-index: 4; }
[dir="rtl"] .phone > .tabbar { transform: translateX(50%); }

/* ---------- 32. Widgets: ring, bars, wheel, spec, cards ---------- */
/* Countdown ring — [data-ring="0.72"] sets --p; [data-countdown="seconds"] ticks the time */
.ring { position: relative; display: grid; place-items: center; inline-size: 160px; block-size: 160px; --c: 452; --p: 0.5; }
.ring > svg { position: absolute; inset: 0; inline-size: 100%; block-size: 100%; transform: rotate(-90deg); }
.ring > svg circle { fill: none; stroke-width: 8; stroke-linecap: round; }
.ring__bg { stroke: var(--bg-fill); }
.ring__fg { stroke: var(--bg-inverse); stroke-dasharray: var(--c); stroke-dashoffset: calc(var(--c) * (1 - var(--p))); transition: stroke-dashoffset var(--dur-4) var(--ease-out); }
.ring--accent .ring__fg { stroke: var(--accent); } .ring--success .ring__fg { stroke: var(--success-dot); }
.ring__body { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; }
.ring__value { font-size: var(--text-2xl); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-snug); font-variant-numeric: tabular-nums; }

/* Mini bars: <div class="bars"><i style="--h:60%"></i>…</div> */
.bars { display: flex; align-items: flex-end; gap: 6px; block-size: 56px; }
.bars > i { flex: 1; min-inline-size: 3px; block-size: var(--h, 20%); border-radius: 2px; background: var(--text); }
.bars > i.is-dim { background: var(--line); }
.bars--thin { gap: 10px; justify-content: center; } .bars--thin > i { flex: none; inline-size: 3px; }

/* Number wheel picker — [data-wheel data-value="#input"] */
.wheel { position: relative; block-size: 300px; overflow: hidden; -webkit-mask-image: linear-gradient(transparent, #000 32%, #000 68%, transparent); mask-image: linear-gradient(transparent, #000 32%, #000 68%, transparent); }
.wheel__list { block-size: 100%; overflow-y: auto; scroll-snap-type: y mandatory; padding: 125px 0; margin: 0; list-style: none; scrollbar-width: none; }
.wheel__list::-webkit-scrollbar { display: none; }
.wheel__item { display: grid; place-items: center; block-size: 50px; scroll-snap-align: center; font-size: 26px; font-weight: var(--weight-medium); color: var(--text-3); font-variant-numeric: tabular-nums; transition: font-size var(--dur-2), color var(--dur-2); cursor: pointer; }
.wheel__item.is-active { font-size: var(--text-5xl); font-weight: var(--weight-semibold); color: var(--text); }
.wheel::before, .wheel::after { content: ""; position: absolute; inset-inline: 22%; block-size: 1px; background: var(--line-strong); inset-block-start: calc(50% - 27px); pointer-events: none; z-index: 1; }
.wheel::after { inset-block-start: calc(50% + 27px); }

/* Spec tile — icon square + label + value (engine · power · speed) */
.spec-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.spec { display: flex; flex-direction: column; gap: 8px; }
.spec > .tile { inline-size: 56px; block-size: 56px; border-radius: 14px; color: var(--text); }
.spec__label { font-size: var(--text-2xs); color: var(--text-3); }
.spec__value { font-size: var(--text-sm); font-weight: var(--weight-semibold); }

/* Success / empty state inside a card (compact variant of .empty) */
.empty--card { padding: 24px 16px; gap: 6px; max-inline-size: none; }
.empty--card > .icon { inline-size: 40px; block-size: 40px; stroke-width: 1.5; margin-block-end: 10px; }
.empty--card .empty__actions { flex-direction: column; align-items: center; gap: 12px; margin-block-start: 14px; }

/* Saved payment card tile */
.cc { display: flex; flex-direction: column; gap: 6px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius-xl); background: var(--bg); }
.cc__num { font-size: 10px; letter-spacing: 0.18em; color: var(--text-3); direction: ltr; text-align: start; }
.cc__brand { font-size: var(--text-sm); font-weight: var(--weight-bold); font-style: italic; letter-spacing: -0.02em; }
.cc__dot { inline-size: 12px; block-size: 12px; border-radius: 50%; background: var(--text); margin-inline-start: auto; }
.cc__dot--off { background: var(--line-strong); }

/* Music player row */
.player { display: flex; align-items: center; gap: 12px; }
.player__art { inline-size: 44px; block-size: 44px; border-radius: 50%; background: var(--bg-inverse); flex: none; }
.player__body { flex: 1; min-inline-size: 0; }
.player__title { font-size: var(--text-xs); font-weight: var(--weight-semibold); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player__sub { font-size: 10px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player__controls { display: flex; align-items: center; gap: 4px; margin-inline-start: auto; }

/* Copy row — id + copy button */
.copy-row { display: inline-flex; align-items: center; gap: 8px; }

/* ---------- 33. Overlay additions: floating drawer, split dialog, rail ---------- */
/* Floating drawer — inset rounded panel (billing drawer). Native <dialog class="drawer drawer--floating"> */
dialog.drawer--floating { inset-block: 12px; inset-inline-end: 12px; block-size: auto; max-block-size: calc(100dvh - 24px); border: 0; border-radius: var(--radius-2xl); }
dialog.drawer--floating[open] { animation-name: bfa-dialog-in; }
.drawer__head .btn-row { gap: 8px; }
.drawer__body--pad { padding: 20px; }
.drawer__body > * { flex-shrink: 0; }
.dialog__body > * { flex-shrink: 0; }

/* Split dialog — a start pane (questionnaire, rail) and an end pane (record) */
.dialog--split { inline-size: min(1040px, calc(100vw - 32px)) !important; }
.dialog__split { display: grid; grid-template-columns: 420px 1fr; max-block-size: calc(100dvh - 64px); min-block-size: 0; }
.dialog__split > * { min-inline-size: 0; overflow: auto; }
.pane--start { display: grid; grid-template-columns: 1fr auto; border-inline-end: 1px solid var(--line); background: var(--bg-soft); }
.pane--end { display: flex; flex-direction: column; }
.pane__head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 12px; }
.pane__body { padding: 8px 20px 20px; display: flex; flex-direction: column; gap: 16px; }
.pane__body > * { flex-shrink: 0; }
.pane__foot { display: flex; gap: 10px; padding: 16px 20px; border-block-start: 1px solid var(--line); margin-block-start: auto; }
.rail-mini { display: flex; flex-direction: column; gap: 8px; padding: 18px 12px; border-inline-start: 1px solid var(--line); }
.rail-mini > .btn { inline-size: 36px; block-size: 36px; border-radius: 50%; background: var(--bg); border: 1px solid var(--line-control); color: var(--text-2); }
.rail-mini > .btn.is-active { background: var(--accent-tint); color: var(--accent); border-color: transparent; }

/* ---------- 34. Utilities for the layer ---------- */
.g-0 { gap: 0; } .g-4 { gap: 4px; } .g-6 { gap: 6px; } .g-10 { gap: 10px; } .g-12 { gap: 12px; } .g-16 { gap: 16px; } .g-20 { gap: 20px; } .g-24 { gap: 24px; } .g-32 { gap: 32px; }
.mt-4 { margin-block-start: 4px; } .mt-8 { margin-block-start: 8px; } .mt-12 { margin-block-start: 12px; } .mt-16 { margin-block-start: 16px; } .mt-20 { margin-block-start: 20px; } .mt-24 { margin-block-start: 24px; } .mt-32 { margin-block-start: 32px; } .mt-auto { margin-block-start: auto; }
.mb-4 { margin-block-end: 4px; } .mb-8 { margin-block-end: 8px; } .mb-12 { margin-block-end: 12px; } .mb-16 { margin-block-end: 16px; } .mb-20 { margin-block-end: 20px; } .mb-24 { margin-block-end: 24px; }
.ms-auto { margin-inline-start: auto; } .mx-auto { margin-inline: auto; }
.p-0 { padding: 0; } .p-16 { padding: 16px; } .p-20 { padding: 20px; } .px-20 { padding-inline: 20px; } .py-12 { padding-block: 12px; }
.text-end { text-align: end; } .text-center { text-align: center; } .text-start { text-align: start; }
.w-full { inline-size: 100%; } .flex-none { flex: none; }
.center { display: flex; flex-direction: column; align-items: center; text-align: center; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; } .grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.row-start { align-items: flex-start; } .row-center { justify-content: center; } .row-end { justify-content: flex-end; }
.stack > * { flex-shrink: 0; }
.nowrap { white-space: nowrap; }

/* ---------- 35. Responsive for the layer ---------- */
@media (max-width: 1023.98px) {
  .layout-2, .layout-2--rev { grid-template-columns: 1fr; }
  .dialog__split { grid-template-columns: 1fr; }
  .pane--start { border-inline-end: 0; border-block-end: 1px solid var(--line); }
}
@media (max-width: 767.98px) {
  .grid-2, .grid-3, .info-grid, .spec-row { grid-template-columns: 1fr; }
  .kpi-row { flex-direction: column; align-items: stretch; gap: 16px; }
  .kpi-row > .divider-v { display: none; }
  .meta-row { flex-direction: column; align-items: stretch; }
  .meta { border: 0; padding-inline-end: 0; margin-inline-end: 0; inline-size: 100%; }
  .meta-row > .spacer + * { margin-inline-start: 0; }
  .phone-stage { padding: 24px 12px; gap: 24px; }
  .phone { inline-size: 100%; max-inline-size: var(--phone-w); block-size: min(var(--phone-h), calc(100dvh - 48px)); }
  dialog.drawer--floating { inset: 0; border-radius: 0; max-block-size: 100dvh; }
  .cards--masonry { columns: 1; }
}


/* ---------- 36. Canvas & mobile refinements (the four primary references) ---------- */
/* Everything here is scoped to the opt-in contexts: .app--canvas / .page--canvas (desktop) and .phone / .phone-stage (mobile).
   Bolder icons in tiles and nav, darker ink, 14px labels over 44px inputs, tinted active nav, grey table head,
   diffuse card shadows, a topbar search pill, and larger mobile type. The hairline base is untouched. */
.app--canvas, .page--canvas, .phone-stage, .phone { --icon-stroke: var(--icon-stroke-bold); }

/* Sidebar & topbar on the canvas */
.app--canvas > .sidebar { background: var(--bg); }
.app--canvas .workspace { border: 1px solid var(--line); background: var(--bg); padding: 6px 8px; margin-inline-start: 0; border-radius: var(--radius-lg); }
.app--canvas .workspace__mark { inline-size: 28px; block-size: 28px; border-radius: var(--radius-md); }
.app--canvas .nav-item { block-size: 38px; font-size: var(--text-base); font-weight: var(--weight-medium); color: var(--text-2); }
.app--canvas .nav-item .icon { inline-size: 18px; block-size: 18px; }
.app--canvas .nav-item[aria-current="page"], .app--canvas .nav-item.is-active { background: var(--accent-tint); color: var(--accent); }
.app--canvas .nav-item[aria-current="page"] .icon, .app--canvas .nav-item.is-active .icon { color: var(--accent); }
.app--canvas .nav-section__label { color: var(--text-3); }
.app--canvas .topbar { block-size: 64px; padding-inline: 24px; gap: 16px; }
.app--canvas .topbar__title { font-size: var(--text-2xl); letter-spacing: var(--tracking-snug); }
.topbar__search { flex: 1; max-inline-size: 380px; margin-inline-start: auto; }
.topbar__search .input { --input-h: 40px; background: var(--bg-soft); border-color: transparent; border-radius: var(--radius-full); font-size: var(--text-sm); }
.topbar__search .input:focus { background: var(--bg); border-color: var(--line-strong); box-shadow: none; }
.topbar__user { display: flex; align-items: center; gap: 10px; padding-inline-start: 14px; border-inline-start: 1px solid var(--line); margin-inline-start: 4px; font-size: var(--text-sm); font-weight: var(--weight-medium); }
.topbar__user .icon { color: var(--text-3); }
.app--canvas .page-header__title { font-size: var(--text-2xl); }
.app--canvas .page-header__desc { font-size: var(--text-base); color: var(--text-2); }

/* Cards: diffuse shadow instead of a hairline, like the reference */
.app--canvas .card, .page--canvas .card { border-color: transparent; box-shadow: var(--shadow-card); }
.app--canvas .card--elevated, .page--canvas .card--elevated { box-shadow: var(--shadow-md); }
.app--canvas .card--soft, .app--canvas .card--fill, .app--canvas .card--ink, .app--canvas .card--tint,
.page--canvas .card--soft, .page--canvas .card--fill, .page--canvas .card--ink, .page--canvas .card--tint { box-shadow: none; }
.app--canvas .card .card, .page--canvas .card .card { box-shadow: none; border-color: var(--line); }
.app--canvas .card__title, .page--canvas .card__title { font-size: var(--text-lg); }
.app--canvas .card__sub, .page--canvas .card__sub { font-size: var(--text-base); color: var(--text-2); }

/* Forms: 14px labels, 44px inputs, radius 12 */
.app--canvas .field__label, .page--canvas .field__label { font-size: var(--text-base); color: var(--text-2); font-weight: var(--weight-medium); }
.app--canvas .input, .app--canvas .textarea, .app--canvas .select__trigger,
.page--canvas .input, .page--canvas .textarea, .page--canvas .select__trigger { --input-h: var(--h-2xl); border-radius: var(--radius-xl); font-size: var(--text-base); padding-inline: 14px; }
.app--canvas .input-wrap > .icon ~ .input, .page--canvas .input-wrap > .icon ~ .input { padding-inline-start: 40px; }
.app--canvas .input-wrap > .icon, .page--canvas .input-wrap > .icon { inset-inline-start: 14px; }
.app--canvas .input-wrap__end, .page--canvas .input-wrap__end { inset-inline-end: 10px; }
.app--canvas .textarea, .page--canvas .textarea { padding-block: 12px; }
.app--canvas .select > .menu, .page--canvas .select > .menu { border-radius: var(--radius-xl); }
.app--canvas .btn, .page--canvas .btn { font-size: var(--text-base); }
.app--canvas .btn--sm, .page--canvas .btn--sm { font-size: var(--text-sm); }
.app--canvas .btn .icon, .page--canvas .btn .icon { inline-size: 18px; block-size: 18px; }
.app--canvas .btn--sm .icon, .page--canvas .btn--sm .icon { inline-size: 16px; block-size: 16px; }
.app--canvas .btn--xs .icon, .page--canvas .btn--xs .icon { inline-size: 14px; block-size: 14px; }

/* Data: 14px rows, grey uppercase head, 56px rows, bold status pills */
.app--canvas .table, .page--canvas .table { font-size: var(--text-base); }
.app--canvas .table th, .page--canvas .table th { background: var(--bg-soft); font-size: var(--text-2xs); font-weight: var(--weight-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase; block-size: 44px; }
.app--canvas .table th .th-sort, .page--canvas .table th .th-sort { text-transform: inherit; letter-spacing: inherit; font-size: inherit; font-weight: inherit; }
.app--canvas .table td, .page--canvas .table td { block-size: 60px; }
.app--canvas .table--compact td, .page--canvas .table--compact td { block-size: 44px; }
.app--canvas .table--compact th, .page--canvas .table--compact th { block-size: 40px; }
.app--canvas .kv, .page--canvas .kv { font-size: var(--text-base); }
.app--canvas .kv__row > dd, .page--canvas .kv__row > dd, .app--canvas .kv__row > .kv__v, .page--canvas .kv__row > .kv__v { font-weight: var(--weight-semibold); }
.app--canvas .badge--tint, .page--canvas .badge--tint { block-size: 24px; padding-inline: 10px; font-size: var(--text-xs); }
.app--canvas .badge--tint.badge--caps, .page--canvas .badge--tint.badge--caps { font-size: var(--text-2xs); }
.app--canvas .tile .icon { inline-size: 22px; block-size: 22px; }
.app--canvas .tile--sm .icon { inline-size: 18px; block-size: 18px; }
.app--canvas .kpi__label, .page--canvas .kpi__label { font-size: var(--text-base); }
.app--canvas .t-caption.t-3, .page--canvas .t-caption.t-3 { color: var(--text-2); }
.app--canvas .info-grid > div > dt, .app--canvas .info-grid__label { color: var(--text-2); }
.app--canvas .step__q { color: var(--text-2); font-size: var(--text-sm); }
.app--canvas .step__a { font-size: var(--text-base); }

/* Overlays on the canvas */
.app--canvas .drawer__head { block-size: 64px; }
.app--canvas .drawer__title { font-size: var(--text-lg); }
.app--canvas .dialog__title { font-size: var(--text-xl); }

/* Mobile: larger, bolder, darker */
.phone__screen { font-size: var(--text-md); line-height: 22px; }
.phone .tile .icon { inline-size: 22px; block-size: 22px; }
.phone .tile--sm .icon { inline-size: 18px; block-size: 18px; }
.phone .btn .icon { inline-size: 18px; block-size: 18px; }
.phone .btn--3xl { font-size: var(--text-lg); }
.phone .t-h5, .phone .section-head .t-h5 { font-size: var(--text-lg); line-height: var(--lh-lg); }
.phone .card__body--sm { padding: 16px; }
.phone .m-row { font-size: var(--text-md); padding-block: 11px; }
.phone .m-row__k { color: var(--text-2); }
.phone .m-row__k .icon { inline-size: 16px; block-size: 16px; }
.phone .m-row__v { font-weight: var(--weight-semibold); }
.phone .m-pair__label { font-size: var(--text-sm); color: var(--text-2); }
.phone .m-pair__value { font-size: var(--text-md); }
.phone .m-pair__value small { font-size: var(--text-xs); }
.phone .kv { font-size: var(--text-base); }
.phone .kv__row > dd { font-weight: var(--weight-semibold); }
.phone .kv--lined .kv__row { padding-block: 12px; }
.phone .route__label { font-size: var(--text-md); }
.phone .route__name { font-size: var(--text-md); }
.phone .route__time { font-size: var(--text-lg); }
.phone .route__time small { font-size: var(--text-sm); }
.phone .route { gap: 22px; }
.phone .badge--tint.badge--lg { block-size: 36px; padding-inline: 14px; font-size: var(--text-md); font-weight: var(--weight-medium); }
.phone .badge--tint.badge--lg .icon { inline-size: 16px; block-size: 16px; }
.phone .badge--tint { block-size: 26px; padding-inline: 12px; font-size: var(--text-sm); font-weight: var(--weight-medium); }
.phone .setting__title { font-size: var(--text-lg); }
.phone .setting__sub { font-size: var(--text-sm); color: var(--text-2); }
.phone .media__title { font-size: var(--text-md); }
.phone .media__sub { font-size: var(--text-sm); }
.phone .timeline--track .timeline__time { font-size: var(--text-md); }
.phone .timeline--track .timeline__text { font-size: var(--text-sm); }
.phone .stepper__label { font-size: var(--text-sm); }
.phone .stepper__label small { font-size: var(--text-xs); }
.phone .stepper__node { inline-size: 24px; block-size: 24px; }
.phone .stepper::before, .phone .stepper::after { inset-block-start: 11px; inset-inline: 12px; block-size: 3px; }
.phone .highlight { padding: 28px 24px; }
.phone .highlight .t-caption { font-size: var(--text-md); }
.phone .rating { font-size: var(--text-md); }
.phone .rating .icon { inline-size: 16px; block-size: 16px; }
.phone .t-medium { font-weight: var(--weight-semibold); }
.phone .avatar--sm { --avatar: 28px; }
.phone .option__title { font-size: var(--text-md); }
.phone .option__sub { font-size: var(--text-sm); }
.phone .choice__title { font-size: var(--text-xl); }
.phone .choice__sub { font-size: var(--text-sm); }
.phone .input--3xl { font-size: var(--text-md); }
.phone .phone__bar { font-size: var(--text-xl); }

/* ---------- 22. Motion ---------- */
@keyframes bfa-spin { to { transform: rotate(360deg); } }
@keyframes bfa-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@keyframes bfa-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes bfa-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes bfa-pop { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes bfa-dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes bfa-drawer-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes bfa-drawer-in-rtl { from { transform: translateX(-24px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes bfa-toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes bfa-toast-out { to { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; scroll-behavior: auto !important; }
}

/* ---------- 23. Responsive & input modality ---------- */
/* Touch: every interactive control grows to a 40px target */
@media (pointer: coarse) {
  :root { --h-sm: 36px; --h-md: 40px; --h-lg: 44px; }
  .nav-item { block-size: 40px; }
  .rail__item { inline-size: 40px; block-size: 40px; }
  .menu__item { min-block-size: 40px; }
  .item__actions { display: none !important; }
  .item:hover .item__time { visibility: visible; }
}
/* Desktop collapse: [data-sidebar-toggle] adds .is-sidebar-collapsed */
@media (min-width: 1024px) { .app.is-sidebar-collapsed > .sidebar { display: none; } }
/* < 1024: sidebar becomes a drawer (toggle with [data-sidebar-toggle]) */
@media (max-width: 1023.98px) {
  :root { --list-w: 320px; --page-pad: 20px; }
  .app > .sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; z-index: var(--z-drawer);
    box-shadow: var(--shadow-lg); transform: translateX(-100%); transition: transform var(--dur-3) var(--ease-out);
  }
  [dir="rtl"] .app > .sidebar { transform: translateX(100%); }
  .app.is-sidebar-open > .sidebar { transform: none; }
  .app.is-sidebar-open:has(> .sidebar)::after { content: ""; position: fixed; inset: 0; z-index: calc(var(--z-drawer) - 1); background: var(--backdrop); }
  .settings-section { grid-template-columns: 1fr; gap: 16px; }
}
/* < 768: single pane. List shows; selecting an item adds .is-detail-open on .app__body to swap to detail. */
@media (max-width: 767.98px) {
  :root { --page-pad: 16px; --topbar-h: 52px; }
  .app { grid-template-columns: 1fr; }
  .app > .rail { display: none; }
  .pane--list { inline-size: 100%; border-inline-end: 0; }
  .app__body > .pane--detail { display: none; }
  .app__body.is-detail-open > .pane--list { display: none; }
  .app__body.is-detail-open > .pane--detail { display: flex; }
  .hide-mobile { display: none !important; }
  .page-header { flex-wrap: wrap; row-gap: 12px; }
  .page-header__actions { flex-wrap: wrap; inline-size: 100%; }
  .message { padding: 16px; }
  .composer__head, .composer__input { padding-inline: 16px; }
  .stat + .stat { border-inline-start: 0; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stats .stat:nth-child(even) { border-inline-start: 1px solid var(--line); }
  .stats .stat:nth-child(n + 3) { border-block-start: 1px solid var(--line); }
  .dl { grid-template-columns: 1fr; }
  .dl dt { border-block-end: 0; padding-block-end: 0; }
  .callout { flex-direction: column; align-items: stretch; gap: 12px; }
  .callout__aside { justify-content: space-between; }
  .app__main:has(.app__body.is-detail-open) > .subbar { display: none; }
  .app.is-sidebar-open > .rail { display: flex; position: fixed; inset-block: 0; inset-inline-start: 0; z-index: var(--z-drawer); box-shadow: var(--shadow-lg); animation: bfa-drawer-in var(--dur-3) var(--ease-out); }
  .app.is-sidebar-open:has(> .rail)::after { content: ""; position: fixed; inset: 0; z-index: calc(var(--z-drawer) - 1); background: var(--backdrop); }
  .toasts { inset-inline: 12px; inset-block-end: 12px; inline-size: auto; }
}
@media (min-width: 768px) { .show-mobile { display: none !important; } }

/* Print: ink on white, no chrome */
@media print {
  .rail, .sidebar, .topbar, .toolbar, .composer, .toasts { display: none !important; }
  .app { display: block; block-size: auto; }
  body { color: #000; }
}
