/* ==========================================================================
   Oparo One — the shared design system every Oparo app loads at runtime.
   VERSION = '1.3.0'

   One file, published same-origin to every app by `oparo-one-deploy`
   (oparo-ops/bin) at <origin>/oparo-one/oparo-one.css (login.oparo.ca:
   /ui/oparo-one/, Phone: /phone-assets/oparo-one/). The tool copies it into
   each app's Vite public/ (so app builds and deploys carry it) and into the
   live docroot, and stamps `oparo-one.css?v=<sha256:16>` into each index.html.
   Fonts and the wordmark sit next to it and are referenced relatively, so
   the same bytes work under every prefix.

   Load order does not matter: tokens use html:root (0,1,1) and adapters use
   html[data-oparo-app], so both beat an app's own :root copies. It is
   authoritative for tokens: an app may add tokens but must not redefine these.

   Contents
     1. Fonts            Oparo Sans (Montserrat), Oparo Display (ADA Hybrid)
     2. Tokens           colour (light, dark, more contrast), type, space,
                         radius + continuous corners, elevation, motion,
                         layout, z-index
     3. Foundations      headings, numbers, focus, selection, reduced motion
     4. Frame            app header, lockup, side navigation, mobile tab bar
     5. Components       button, card, toolbar, segmented control, empty
                         state, toast, dialog, visually hidden
     6. App adapters     html[data-oparo-app="…"] — maps each app's legacy
                         classes onto the frame until its markup catches up

   Docs: design-system/README.md (in this repo). Colours are the brand
   palette, unchanged: primary #2563eb (dark #3b82f6 for text/icons,
   #60a5fa focus), background #f7f8fa / #111315, text #111315 / #e8edf5.
   ========================================================================== */

/* 1. Fonts ---------------------------------------------------------------- */
@font-face { font-family: 'Oparo Sans'; font-weight: 400; font-style: normal; font-display: swap; src: url('sans-400.woff2') format('woff2'); }
@font-face { font-family: 'Oparo Sans'; font-weight: 500; font-style: normal; font-display: swap; src: url('sans-500.woff2') format('woff2'); }
@font-face { font-family: 'Oparo Sans'; font-weight: 600; font-style: normal; font-display: swap; src: url('sans-600.woff2') format('woff2'); }
@font-face { font-family: 'Oparo Sans'; font-weight: 700; font-style: normal; font-display: swap; src: url('sans-700.woff2') format('woff2'); }
/* ADA Hybrid has no œ « » ’ — the stack falls back to Oparo Sans per glyph. */
@font-face { font-family: 'Oparo Display'; font-weight: 400 700; font-style: normal; font-display: swap; src: url('display.woff2') format('woff2'); }

/* 2. Tokens --------------------------------------------------------------- */
/* Token selectors are html:root (specificity 0,1,1) so they win over an
   app's own :root copies whatever the load order: one source of truth. */
html:root {
  color-scheme: light dark;

  /* Type */
  --font-sans: 'Oparo Sans', Montserrat, system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
  --font-heading: 'Oparo Display', 'ADA Hybrid', 'Oparo Sans', Montserrat, system-ui, sans-serif;
  --font-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;
  --fs-xs: 0.75rem;   /* 12 */
  --fs-sm: 0.875rem;  /* 14 */
  --fs-md: 1rem;      /* 16 — body */
  --fs-lg: 1.125rem;  /* 18 */
  --fs-xl: 1.25rem;   /* 20 */
  --fs-2xl: 1.5rem;   /* 24 */
  --fs-3xl: 1.875rem; /* 30 */
  --fs-4xl: 2.25rem;  /* 36 */
  --fw-regular: 400; --fw-medium: 500; --fw-semibold: 600; --fw-bold: 700;
  --lh-tight: 1.15; --lh-snug: 1.3; --lh-normal: 1.5;
  /* Tracking is size-specific (apple-design §15): tighter as text grows. */
  --tracking-display: -0.02em; --tracking-heading: -0.01em; --tracking-body: 0; --tracking-small: 0.01em;

  /* Space — 4-pt grid */
  --space-0: 0; --space-1: 4px; --space-2: 8px; --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;

  /* Radius. Continuous corners are a progressive enhancement (Chrome/Edge
     139+); every other engine keeps the circular radius. Nested surfaces use
     --radius-inner = outer − padding (concentric, apple-design §19). */
  --radius-xs: 4px; --radius-sm: 6px; --radius-md: 10px; --radius-lg: 14px; --radius-xl: 18px; --radius-2xl: 24px;
  --radius-full: 9999px;
  --corner-shape: squircle;

  /* Elevation — soft, low-contrast, never a hard drop */
  --shadow-xs: 0 1px 2px 0 rgb(15 23 42 / .06);
  --shadow-sm: 0 1px 3px 0 rgb(15 23 42 / .08), 0 1px 2px -1px rgb(15 23 42 / .06);
  --shadow-md: 0 4px 8px -2px rgb(15 23 42 / .08), 0 2px 4px -2px rgb(15 23 42 / .06);
  --shadow-lg: 0 12px 24px -4px rgb(15 23 42 / .12), 0 4px 8px -4px rgb(15 23 42 / .08);
  --shadow-xl: 0 24px 48px -12px rgb(15 23 42 / .18);

  /* Motion. Short, ease-out entrances; nothing on keyboard-frequent actions. */
  --motion-instant: 80ms; --motion-fast: 120ms; --motion-normal: 180ms; --motion-slow: 260ms; --motion-sheet: 480ms;
  --ease-standard: cubic-bezier(.2, 0, 0, 1);
  --ease-out: cubic-bezier(.23, 1, .32, 1);
  --ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --ease-sheet: cubic-bezier(.32, .72, 0, 1);
  --ease-emphasized: cubic-bezier(.2, 0, 0, 1.2);

  /* Layout */
  --frame-header-h: 56px;
  --frame-sidebar-w: 248px;
  --frame-tabbar-h: 64px;
  --content-max: 1120px;
  --target-min: 44px;     /* comfortable target (WCAG 2.5.8 floor is 24px) */
  --target-compact: 32px;

  /* Z-index */
  --z-sticky: 200; --z-header: 300; --z-overlay: 400; --z-modal: 500; --z-toast: 600; --z-tooltip: 700;

  /* Colour — light (brand palette; contrast-hardened where Phone measured it) */
  --color-background: #f7f8fa;
  --color-surface: #ffffff;
  --color-surface-elevated: #ffffff;
  --color-surface-2: #eef1f5;
  --color-surface-3: #e5e9ef;
  --color-border: #e2e5eb;            /* decorative separators */
  --color-border-subtle: rgb(15 23 42 / .08);
  --color-border-strong: #768091;     /* control boundaries, ≥3:1 (1.4.11) */
  --color-text: #111315;
  --color-text-muted: #454d5a;        /* ≥7:1 on surface and background */
  --color-text-subtle: #5c6570;       /* ≥4.5:1, captions only */
  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-primary-active: #1e40af;
  --color-primary-subtle: rgb(37 99 235 / .12);
  --color-primary-text: #1d4ed8;
  --color-primary-strong: #2563eb;    /* fills that carry white, both themes */
  --color-primary-strong-hover: #1d4ed8;
  --color-on-primary: #ffffff;
  --color-success: #059669; --color-success-subtle: rgb(5 150 105 / .12); --color-success-text: #065f46; --color-success-strong: #047857;
  --color-warning: #d97706; --color-warning-subtle: rgb(217 119 6 / .12); --color-warning-text: #92400e; --color-warning-strong: #92400e;
  --color-danger: #dc2626; --color-danger-hover: #b91c1c; --color-danger-subtle: rgb(248 113 113 / .12); --color-danger-text: #b91c1c; --color-danger-strong: #dc2626;
  --color-info: #2563eb; --color-info-subtle: rgb(37 99 235 / .12); --color-info-text: #1d4ed8;
  --color-paro: #7c3aed; --color-paro-hover: #6d28d9; --color-paro-subtle: rgb(124 58 237 / .12); --color-on-paro: #fff;
  --color-focus-ring: #2563eb;
  --color-link: #1d4ed8;
  --color-scrim: rgb(15 23 42 / .45);
  --color-brand-mark: #3b82f6;        /* the wordmark's own blue (logo, exempt from 1.4.3) */
  --color-material: rgb(255 255 255 / .78);   /* translucent chrome */
  --color-auth-gradient-start: #eef1f6; --color-auth-gradient-end: #f7f8fa;
  /* Surface System (Warm Precision) — governed texture alphas and
     materials. Distribution copy of oparo-platform's DTCG source;
     identical values by governance. Texture layers are neutral-ink
     weaves (theme text colour via color-mix), so they follow the theme. */
  --oparo-texture-none: 0; --oparo-texture-subtle: 0.025; --oparo-texture-soft: 0.05; --oparo-texture-expressive: 0.08;
  --oparo-surface-texture-soft: repeating-linear-gradient(45deg, color-mix(in srgb, var(--color-text) calc(var(--oparo-texture-soft) * 100%), transparent) 0 1px, transparent 1px 8px), repeating-linear-gradient(-45deg, color-mix(in srgb, var(--color-text) calc(var(--oparo-texture-soft) * 100%), transparent) 0 1px, transparent 1px 8px), var(--color-surface);
  --oparo-surface-texture-branded: linear-gradient(135deg, color-mix(in srgb, var(--color-primary) calc(var(--oparo-texture-expressive) * 100%), transparent), color-mix(in srgb, var(--color-paro) calc(var(--oparo-texture-subtle) * 100%), transparent) 58%), repeating-linear-gradient(45deg, color-mix(in srgb, var(--color-text) calc(var(--oparo-texture-subtle) * 100%), transparent) 0 1px, transparent 1px 10px), linear-gradient(180deg, var(--color-auth-gradient-start), var(--color-auth-gradient-end));
  --oparo-material-canvas: var(--color-background);
  --oparo-material-surface: var(--color-surface);
  --oparo-material-elevated: var(--color-surface-elevated);
  --oparo-material-expressive: var(--oparo-surface-texture-soft);
  --oparo-material-branded: var(--oparo-surface-texture-branded);
  --oparo-material-marketing: var(--oparo-surface-texture-branded);
  --focus-width: 2px; --focus-offset: 2px;

  /* Legacy aliases still read by Workspace, Page and shell components */
  --oparo-background: var(--color-background);
  --oparo-surface: var(--color-surface);
  --oparo-surface-raised: var(--color-surface-elevated);
  --oparo-surface-sunken: var(--color-surface-2);
  --oparo-border: var(--color-border);
  --oparo-border-strong: var(--color-border-strong);
  --oparo-text: var(--color-text);
  --oparo-text-muted: var(--color-text-muted);
  --oparo-accent: var(--color-primary);
  --oparo-accent-hover: var(--color-primary-hover);
  --oparo-accent-subtle: var(--color-primary-subtle);
  --oparo-text-on-accent: var(--color-on-primary);
  --oparo-focus-ring: var(--color-focus-ring);
  --oparo-focus-width: var(--focus-width);
  --oparo-focus-offset: var(--focus-offset);
  --oparo-status-danger: var(--color-danger-text);
  --oparo-status-success: var(--color-success-text);
  --oparo-status-warning: var(--color-warning-text);
  --oparo-touch-min: var(--target-min);
  --oparo-motion-ease: var(--ease-standard);
}

@media (prefers-color-scheme: dark) {
  html:root:not([data-theme="light"]) {
    --color-background: #111315;
    --color-surface: #171a1f;
    --color-surface-elevated: #1c2028;
    --color-surface-2: #232833;
    --color-surface-3: #2b313d;
    --color-border: rgb(148 163 184 / .18);
    --color-border-subtle: rgb(148 163 184 / .12);
    --color-border-strong: #94a3b8;
    --color-text: #e8edf5;
    --color-text-muted: #a3b0c2;
    --color-text-subtle: #94a3b8;
    --color-primary: #3b82f6;
    --color-primary-hover: #60a5fa;
    --color-primary-active: #93c5fd;
    --color-primary-subtle: rgb(59 130 246 / .18);
    --color-primary-text: #93c5fd;
    --color-success: #10b981; --color-success-subtle: rgb(16 185 129 / .18); --color-success-text: #6ee7b7;
    --color-warning: #f59e0b; --color-warning-subtle: rgb(245 158 11 / .18); --color-warning-text: #fcd34d;
    --color-danger: #f87171; --color-danger-subtle: rgb(248 113 113 / .15); --color-danger-text: #fca5a5;
    --color-info-text: #93c5fd;
    --color-paro: #8b5cf6; --color-paro-hover: #7c3aed; --color-paro-subtle: rgb(139 92 246 / .18);
    --color-focus-ring: #60a5fa;
    --color-link: #93c5fd;
    --color-scrim: rgb(0 0 0 / .6);
    --color-material: rgb(23 26 31 / .78);
    --color-auth-gradient-start: #1e293b; --color-auth-gradient-end: #111315;
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / .4);
    --shadow-md: 0 4px 10px -2px rgb(0 0 0 / .45);
    --shadow-lg: 0 12px 24px -4px rgb(0 0 0 / .5);
    --shadow-xl: 0 24px 48px -12px rgb(0 0 0 / .6);
  }
}
html:root[data-theme="dark"] {
  --color-background: #111315; --color-surface: #171a1f; --color-surface-elevated: #1c2028; --color-surface-2: #232833; --color-surface-3: #2b313d;
  --color-border: rgb(148 163 184 / .18); --color-border-subtle: rgb(148 163 184 / .12); --color-border-strong: #94a3b8;
  --color-text: #e8edf5; --color-text-muted: #a3b0c2; --color-text-subtle: #94a3b8;
  --color-primary: #3b82f6; --color-primary-hover: #60a5fa; --color-primary-active: #93c5fd; --color-primary-subtle: rgb(59 130 246 / .18); --color-primary-text: #93c5fd;
  --color-success: #10b981; --color-success-subtle: rgb(16 185 129 / .18); --color-success-text: #6ee7b7;
  --color-warning: #f59e0b; --color-warning-subtle: rgb(245 158 11 / .18); --color-warning-text: #fcd34d;
  --color-danger: #f87171; --color-danger-subtle: rgb(248 113 113 / .15); --color-danger-text: #fca5a5;
  --color-info-text: #93c5fd; --color-paro: #8b5cf6; --color-paro-hover: #7c3aed; --color-paro-subtle: rgb(139 92 246 / .18);
  --color-focus-ring: #60a5fa; --color-link: #93c5fd; --color-scrim: rgb(0 0 0 / .6); --color-material: rgb(23 26 31 / .78);
  --color-auth-gradient-start: #1e293b; --color-auth-gradient-end: #111315;
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / .4); --shadow-md: 0 4px 10px -2px rgb(0 0 0 / .45);
  --shadow-lg: 0 12px 24px -4px rgb(0 0 0 / .5); --shadow-xl: 0 24px 48px -12px rgb(0 0 0 / .6);
}
@media (prefers-contrast: more) {
  html:root {
    --color-border: #768091; --color-border-subtle: #768091; --color-text-muted: var(--color-text);
    --color-text-subtle: var(--color-text); --color-material: var(--color-surface);
    --oparo-material-expressive: var(--color-surface); --oparo-material-branded: var(--color-surface); --oparo-material-marketing: var(--color-surface);
  }
}
@media (prefers-reduced-transparency: reduce) { html:root { --color-material: var(--color-surface); --oparo-material-expressive: var(--color-surface); --oparo-material-branded: var(--color-surface); --oparo-material-marketing: var(--color-surface); } }
@media (prefers-reduced-motion: reduce) {
  html:root { --motion-instant: 0ms; --motion-fast: 0ms; --motion-normal: 0ms; --motion-slow: 0ms; --motion-sheet: 0ms; }
}

/* 2b. User theme colour -----------------------------------------------------
   A personal preference (Account → Accessibility and appearance → Theme
   colour; preference key appearance.theme_colour), carried on <html> as
   data-oparo-theme-colour. Each theme overrides ONLY the primary family
   (and the info family, which aliases it) — status colours, the Paro
   identity colour and the brand mark never move, and business branding
   (the client-area appearance layer) is a separate scope this attribute
   never reaches. "blue" (and no attribute) is the base palette above:
   byte-identical to the pre-theme experience. Every value is contrast-
   proven by design-system/tests/theme-colour (WCAG 2.2 AA gates).
   Beige additionally warms the neutral surfaces in light mode; its dark
   mode keeps the shared dark surfaces and warms only the accent family.
   Dark variants come in both dark routes (explicit data-theme and the
   prefers-color-scheme media) at higher specificity than the base dark
   sets, so the theme wins in either route. */

/* Purple */
html:root[data-oparo-theme-colour="purple"] {
  --color-primary: #7c3aed; --color-primary-hover: #6d28d9; --color-primary-active: #5b21b6;
  --color-primary-subtle: rgb(124 58 237 / .12); --color-primary-text: #6d28d9;
  --color-primary-strong: #7c3aed; --color-primary-strong-hover: #6d28d9;
  --color-focus-ring: #7c3aed; --color-link: #6d28d9;
  --color-info: #7c3aed; --color-info-subtle: rgb(124 58 237 / .12); --color-info-text: #6d28d9;
}
@media (prefers-color-scheme: dark) {
  html:root:not([data-theme="light"])[data-oparo-theme-colour="purple"] {
    --color-primary: #a78bfa; --color-primary-hover: #c4b5fd; --color-primary-active: #ddd6fe;
    --color-primary-subtle: rgb(167 139 250 / .18); --color-primary-text: #c4b5fd;
    --color-primary-strong: #7c3aed; --color-primary-strong-hover: #6d28d9;
    --color-focus-ring: #a78bfa; --color-link: #c4b5fd;
    --color-info: #a78bfa; --color-info-subtle: rgb(167 139 250 / .18); --color-info-text: #c4b5fd;
  }
}
html:root[data-theme="dark"][data-oparo-theme-colour="purple"] {
  --color-primary: #a78bfa; --color-primary-hover: #c4b5fd; --color-primary-active: #ddd6fe;
  --color-primary-subtle: rgb(167 139 250 / .18); --color-primary-text: #c4b5fd;
  --color-primary-strong: #7c3aed; --color-primary-strong-hover: #6d28d9;
  --color-focus-ring: #a78bfa; --color-link: #c4b5fd;
  --color-info: #a78bfa; --color-info-subtle: rgb(167 139 250 / .18); --color-info-text: #c4b5fd;
}

/* Pink */
html:root[data-oparo-theme-colour="pink"] {
  --color-primary: #db2777; --color-primary-hover: #be185d; --color-primary-active: #9d174d;
  --color-primary-subtle: rgb(219 39 119 / .12); --color-primary-text: #be185d;
  --color-primary-strong: #be185d; --color-primary-strong-hover: #9d174d;
  --color-focus-ring: #db2777; --color-link: #be185d;
  --color-info: #db2777; --color-info-subtle: rgb(219 39 119 / .12); --color-info-text: #be185d;
}
@media (prefers-color-scheme: dark) {
  html:root:not([data-theme="light"])[data-oparo-theme-colour="pink"] {
    --color-primary: #f472b6; --color-primary-hover: #f9a8d4; --color-primary-active: #fbcfe8;
    --color-primary-subtle: rgb(244 114 182 / .18); --color-primary-text: #f9a8d4;
    --color-primary-strong: #be185d; --color-primary-strong-hover: #9d174d;
    --color-focus-ring: #f472b6; --color-link: #f9a8d4;
    --color-info: #f472b6; --color-info-subtle: rgb(244 114 182 / .18); --color-info-text: #f9a8d4;
  }
}
html:root[data-theme="dark"][data-oparo-theme-colour="pink"] {
  --color-primary: #f472b6; --color-primary-hover: #f9a8d4; --color-primary-active: #fbcfe8;
  --color-primary-subtle: rgb(244 114 182 / .18); --color-primary-text: #f9a8d4;
  --color-primary-strong: #be185d; --color-primary-strong-hover: #9d174d;
  --color-focus-ring: #f472b6; --color-link: #f9a8d4;
  --color-info: #f472b6; --color-info-subtle: rgb(244 114 182 / .18); --color-info-text: #f9a8d4;
}

/* Orange */
html:root[data-oparo-theme-colour="orange"] {
  --color-primary: #ea580c; --color-primary-hover: #c2410c; --color-primary-active: #9a3412;
  --color-primary-subtle: rgb(234 88 12 / .12); --color-primary-text: #9a3412;
  --color-primary-strong: #c2410c; --color-primary-strong-hover: #9a3412;
  --color-focus-ring: #ea580c; --color-link: #9a3412;
  --color-info: #ea580c; --color-info-subtle: rgb(234 88 12 / .12); --color-info-text: #9a3412;
}
@media (prefers-color-scheme: dark) {
  html:root:not([data-theme="light"])[data-oparo-theme-colour="orange"] {
    --color-primary: #fb923c; --color-primary-hover: #fdba74; --color-primary-active: #fed7aa;
    --color-primary-subtle: rgb(251 146 60 / .18); --color-primary-text: #fdba74;
    --color-primary-strong: #c2410c; --color-primary-strong-hover: #9a3412;
    --color-focus-ring: #fb923c; --color-link: #fdba74;
    --color-info: #fb923c; --color-info-subtle: rgb(251 146 60 / .18); --color-info-text: #fdba74;
  }
}
html:root[data-theme="dark"][data-oparo-theme-colour="orange"] {
  --color-primary: #fb923c; --color-primary-hover: #fdba74; --color-primary-active: #fed7aa;
  --color-primary-subtle: rgb(251 146 60 / .18); --color-primary-text: #fdba74;
  --color-primary-strong: #c2410c; --color-primary-strong-hover: #9a3412;
  --color-focus-ring: #fb923c; --color-link: #fdba74;
  --color-info: #fb923c; --color-info-subtle: rgb(251 146 60 / .18); --color-info-text: #fdba74;
}

/* Green */
html:root[data-oparo-theme-colour="green"] {
  --color-primary: #16a34a; --color-primary-hover: #15803d; --color-primary-active: #166534;
  --color-primary-subtle: rgb(22 163 74 / .12); --color-primary-text: #166534;
  --color-primary-strong: #15803d; --color-primary-strong-hover: #166534;
  --color-focus-ring: #16a34a; --color-link: #166534;
  --color-info: #16a34a; --color-info-subtle: rgb(22 163 74 / .12); --color-info-text: #166534;
}
@media (prefers-color-scheme: dark) {
  html:root:not([data-theme="light"])[data-oparo-theme-colour="green"] {
    --color-primary: #4ade80; --color-primary-hover: #86efac; --color-primary-active: #bbf7d0;
    --color-primary-subtle: rgb(74 222 128 / .18); --color-primary-text: #86efac;
    --color-primary-strong: #15803d; --color-primary-strong-hover: #166534;
    --color-focus-ring: #4ade80; --color-link: #86efac;
    --color-info: #4ade80; --color-info-subtle: rgb(74 222 128 / .18); --color-info-text: #86efac;
  }
}
html:root[data-theme="dark"][data-oparo-theme-colour="green"] {
  --color-primary: #4ade80; --color-primary-hover: #86efac; --color-primary-active: #bbf7d0;
  --color-primary-subtle: rgb(74 222 128 / .18); --color-primary-text: #86efac;
  --color-primary-strong: #15803d; --color-primary-strong-hover: #166534;
  --color-focus-ring: #4ade80; --color-link: #86efac;
  --color-info: #4ade80; --color-info-subtle: rgb(74 222 128 / .18); --color-info-text: #86efac;
}

/* Beige — warm accent family; light mode also warms the neutral surfaces */
html:root[data-oparo-theme-colour="beige"] {
  --color-primary: #a16207; --color-primary-hover: #854d0e; --color-primary-active: #713f12;
  --color-primary-subtle: rgb(161 98 7 / .14); --color-primary-text: #854d0e;
  --color-primary-strong: #854d0e; --color-primary-strong-hover: #713f12;
  --color-focus-ring: #a16207; --color-link: #854d0e;
  --color-info: #a16207; --color-info-subtle: rgb(161 98 7 / .14); --color-info-text: #854d0e;
  --color-background: #faf6ef; --color-surface: #fffdf8; --color-surface-elevated: #fffdf8;
  --color-surface-2: #f2ecdf; --color-surface-3: #e9e1cf;
  --color-border: #e3dac6; --color-border-subtle: rgb(101 80 40 / .10);
  --color-material: rgb(255 253 248 / .78);
  --color-auth-gradient-start: #f3ecdc; --color-auth-gradient-end: #faf6ef;
}
@media (prefers-color-scheme: dark) {
  html:root:not([data-theme="light"])[data-oparo-theme-colour="beige"] {
    --color-primary: #eab308; --color-primary-hover: #facc15; --color-primary-active: #fde047;
    --color-primary-subtle: rgb(234 179 8 / .18); --color-primary-text: #facc15;
    --color-primary-strong: #854d0e; --color-primary-strong-hover: #713f12;
    --color-focus-ring: #eab308; --color-link: #fde047;
    --color-info: #eab308; --color-info-subtle: rgb(234 179 8 / .18); --color-info-text: #facc15;
    /* Warm dark surfaces: the light block above outranks the base dark
       block on a specificity tie, so the dark surfaces are stated here
       explicitly — without them the light surfaces leak into dark. */
    --color-background: #16130e; --color-surface: #1e1a13; --color-surface-elevated: #262118;
    --color-surface-2: #2b2417; --color-surface-3: #362c1c;
    --color-border: rgb(227 218 198 / .16); --color-border-subtle: rgb(227 218 198 / .10);
    --color-material: rgb(30 26 19 / .78);
    --color-auth-gradient-start: #241d12; --color-auth-gradient-end: #16130e;
  }
}
html:root[data-theme="dark"][data-oparo-theme-colour="beige"] {
  --color-primary: #eab308; --color-primary-hover: #facc15; --color-primary-active: #fde047;
  --color-primary-subtle: rgb(234 179 8 / .18); --color-primary-text: #facc15;
  --color-primary-strong: #854d0e; --color-primary-strong-hover: #713f12;
  --color-focus-ring: #eab308; --color-link: #fde047;
  --color-info: #eab308; --color-info-subtle: rgb(234 179 8 / .18); --color-info-text: #facc15;
  --color-background: #16130e; --color-surface: #1e1a13; --color-surface-elevated: #262118;
  --color-surface-2: #2b2417; --color-surface-3: #362c1c;
  --color-border: rgb(227 218 198 / .16); --color-border-subtle: rgb(227 218 198 / .10);
  --color-material: rgb(30 26 19 / .78);
  --color-auth-gradient-start: #241d12; --color-auth-gradient-end: #16130e;
}

/* Monochrome — the whole primary family in greys */
html:root[data-oparo-theme-colour="monochrome"] {
  --color-primary: #3f4750; --color-primary-hover: #2f353d; --color-primary-active: #23272e;
  --color-primary-subtle: rgb(63 71 80 / .12); --color-primary-text: #2f353d;
  --color-primary-strong: #2f353d; --color-primary-strong-hover: #23272e;
  --color-focus-ring: #3f4750; --color-link: #2f353d;
  --color-info: #3f4750; --color-info-subtle: rgb(63 71 80 / .12); --color-info-text: #2f353d;
}
@media (prefers-color-scheme: dark) {
  html:root:not([data-theme="light"])[data-oparo-theme-colour="monochrome"] {
    --color-primary: #d4d9e0; --color-primary-hover: #e8edf5; --color-primary-active: #ffffff;
    --color-primary-subtle: rgb(212 217 224 / .18); --color-primary-text: #e8edf5;
    --color-primary-strong: #565f6d; --color-primary-strong-hover: #454e5c;
    --color-focus-ring: #d4d9e0; --color-link: #e8edf5;
    --color-info: #d4d9e0; --color-info-subtle: rgb(212 217 224 / .18); --color-info-text: #e8edf5;
  }
}
html:root[data-theme="dark"][data-oparo-theme-colour="monochrome"] {
  --color-primary: #d4d9e0; --color-primary-hover: #e8edf5; --color-primary-active: #ffffff;
  --color-primary-subtle: rgb(212 217 224 / .18); --color-primary-text: #e8edf5;
  --color-primary-strong: #565f6d; --color-primary-strong-hover: #454e5c;
  --color-focus-ring: #d4d9e0; --color-link: #e8edf5;
  --color-info: #d4d9e0; --color-info-subtle: rgb(212 217 224 / .18); --color-info-text: #e8edf5;
}

/* 3. Foundations ---------------------------------------------------------- */
/* Zero-specificity defaults (:where) so an app's own component rules win. */
:where(h1, h2, h3, h4) { text-wrap: balance; }
:where(p, li, dd) { text-wrap: pretty; }
:where(time, .oparo-num, [data-numeric], td.num, .num, .count, .badge-count) { font-variant-numeric: tabular-nums; }
:where(:focus-visible) { outline: var(--focus-width) solid var(--color-focus-ring); outline-offset: var(--focus-offset); }
/* Headings and regions that receive programmatic focus on route change
   (tabindex="-1") are not controls: the screen reader announces them, and a
   ring on a heading reads as a broken text field. Controls keep their ring. */
:is(h1, h2, h3, main, [role="main"], section, article)[tabindex="-1"]:focus { outline: none; box-shadow: none; }
::selection { background: color-mix(in srgb, var(--color-primary) 24%, transparent); }
@media (hover: hover) { :where(a, button) { -webkit-tap-highlight-color: transparent; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
@media (min-resolution: 2dppx) { :where(hr, .oparo-hairline) { border-width: .5px; } }

/* 4. Frame ---------------------------------------------------------------- */
/* Header: translucent material, hairline, same height in every app.
   Right cluster order is fixed: [app actions] · apps · notifications · account. */
.oparo-header {
  position: sticky; top: 0; z-index: var(--z-header);
  display: flex; align-items: center; gap: var(--space-3);
  min-height: var(--frame-header-h); padding: 0 var(--space-4);
  background: var(--color-material);
  -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--color-border-subtle);
}
.oparo-header__spacer { flex: 1 1 auto; }

/* Lockup: OPARO wordmark + product name. One per app, top-left. The
   wordmark is decorative (mask, aria-hidden); a visually hidden "Oparo "
   keeps the accessible name "Oparo Align" etc. */
.oparo-lockup {
  display: inline-flex; align-items: center; gap: 10px; min-height: var(--target-min);
  color: var(--color-text); text-decoration: none; white-space: nowrap; flex: 0 0 auto;
  border-radius: var(--radius-sm);
}
.oparo-lockup__mark {
  display: inline-block; width: 72px; height: 20px; flex: 0 0 auto;
  background-color: var(--color-brand-mark);
  -webkit-mask: url('wordmark.svg') no-repeat left center / contain; mask: url('wordmark.svg') no-repeat left center / contain;
}
.oparo-lockup__divider { width: 1px; height: 18px; background: var(--color-border); flex: 0 0 auto; }
.oparo-lockup__product {
  font-family: var(--font-heading); font-size: var(--fs-lg); font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-heading); line-height: 1; color: var(--color-text);
}
.oparo-lockup__context { font-size: var(--fs-sm); color: var(--color-text-muted); font-weight: var(--fw-medium); overflow: hidden; text-overflow: ellipsis; }
@media (forced-colors: active) { .oparo-lockup__mark { background-color: CanvasText; forced-color-adjust: none; } }
@media (max-width: 480px) { .oparo-lockup__mark { width: 60px; } .oparo-lockup__product { font-size: var(--fs-md); } }

/* Side navigation */
.oparo-sidenav { display: flex; flex-direction: column; gap: 2px; padding: var(--space-3); }
.oparo-sidenav__label { margin: var(--space-4) var(--space-3) var(--space-1); font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--color-text-subtle); letter-spacing: var(--tracking-small); }
.oparo-sidenav__item {
  appearance: none; border: 0; background: transparent; font: inherit; width: 100%; text-align: start;
  display: flex; align-items: center; gap: var(--space-3); min-height: 40px; padding: 0 var(--space-3);
  border-radius: var(--radius-md); corner-shape: var(--corner-shape);
  color: var(--color-text-muted); font-size: var(--fs-sm); font-weight: var(--fw-medium); text-decoration: none; cursor: pointer;
  transition: background-color var(--motion-fast) var(--ease-standard), color var(--motion-fast) var(--ease-standard);
}
@media (hover: hover) { .oparo-sidenav__item:hover { background: var(--color-surface-2); color: var(--color-text); } }
.oparo-sidenav__item[aria-current="page"], .oparo-sidenav__item[aria-current="true"] { background: var(--color-primary-subtle); color: var(--color-primary-text); }

/* Mobile tab bar (Phone's pattern): ≤767px, 4–5 destinations, labels always
   visible, safe-area aware. A translucent material like the header. */
.oparo-tabbar {
  position: fixed; inset: auto 0 0 0; z-index: var(--z-header);
  display: none; justify-content: space-around; align-items: stretch;
  min-height: var(--frame-tabbar-h); padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  background: var(--color-material); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--color-border-subtle);
}
.oparo-tabbar__item {
  appearance: none; border: 0; background: transparent; font: inherit; cursor: pointer;
  flex: 1 1 0; min-width: 0; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--color-text-muted); font-size: 11px; font-weight: var(--fw-semibold); text-decoration: none; border-radius: var(--radius-md);
}
.oparo-tabbar__item svg { width: 22px; height: 22px; }
.oparo-tabbar__item[aria-current="page"], .oparo-tabbar__item[aria-current="true"] { color: var(--color-primary-text); }
.oparo-tabbar__label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 767px) {
  .oparo-tabbar { display: flex; }
  .oparo-has-tabbar { padding-bottom: calc(var(--frame-tabbar-h) + env(safe-area-inset-bottom)); }
}

/* Drawer (the "More" sheet on mobile, side panels on desktop) */
.oparo-drawer { position: fixed; z-index: var(--z-modal); inset: auto 0 0 0; max-height: 85dvh; overflow: auto;
  background: var(--color-surface-elevated); border-radius: var(--radius-xl) var(--radius-xl) 0 0; corner-shape: var(--corner-shape);
  box-shadow: var(--shadow-xl); padding: var(--space-2) var(--space-3) calc(var(--space-4) + env(safe-area-inset-bottom)); }
.oparo-drawer::backdrop, .oparo-scrim { background: var(--color-scrim); }
.oparo-drawer[open] { animation: oparo-sheet-in var(--motion-sheet) var(--ease-sheet); }
@keyframes oparo-sheet-in { from { transform: translateY(100%); } to { transform: none; } }
@media (prefers-reduced-motion: reduce) { .oparo-drawer[open] { animation: oparo-fade-in var(--motion-fast) linear; } }
@keyframes oparo-fade-in { from { opacity: 0; } to { opacity: 1; } }

/* 1.1.0: the drawer as a native modal <dialog> (focus trap, Esc, inert page for free).
   Reset the UA dialog box so it is a bottom sheet, plus a header row with the close
   button. The tab bar's "More" opens it; focus returns to "More" on close. */
dialog.oparo-drawer { margin: 0; width: 100%; max-width: none; border: 0; color: var(--color-text); }
dialog.oparo-drawer:not([open]) { display: none; }
.oparo-drawer__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  min-height: var(--target-min); padding: var(--space-1) 0 var(--space-2); }
.oparo-drawer__title { margin: 0; font-family: var(--font-heading); font-size: var(--fs-lg); font-weight: var(--fw-bold); }
.oparo-drawer__grab { width: 36px; height: 5px; margin: 0 auto var(--space-1); border-radius: var(--radius-full); background: var(--color-border-strong); opacity: .5; }
.oparo-drawer__close { appearance: none; border: 0; background: transparent; color: inherit; cursor: pointer;
  min-width: var(--target-min); min-height: var(--target-min); display: grid; place-items: center; border-radius: var(--radius-md); }
.oparo-drawer__close:hover { background: var(--color-surface-2); }
/* Tab bar items: focus ring inside the bar, press feedback, and a pill behind the
   current item's icon (the selected state is not colour alone). */
.oparo-tabbar__item:focus-visible { outline: 2px solid var(--color-focus-ring); outline-offset: -2px; }
.oparo-tabbar__item:active { transform: scale(.96); }
@media (prefers-reduced-motion: reduce) { .oparo-tabbar__item:active { transform: none; } }
.oparo-tabbar__icon { display: grid; place-items: center; width: 52px; height: 28px; border-radius: var(--radius-full); }
.oparo-tabbar__item[aria-current="page"] .oparo-tabbar__icon, .oparo-tabbar__item[aria-current="true"] .oparo-tabbar__icon { background: var(--color-primary-subtle); }
@media (forced-colors: active) {
  .oparo-tabbar__item[aria-current="page"], .oparo-tabbar__item[aria-current="true"] { outline: 2px solid CanvasText; outline-offset: -4px; }
}

/* 5. Components ----------------------------------------------------------- */
.oparo-vh { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.oparo-btn {
  appearance: none; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 40px; padding: 0 var(--space-4); border-radius: var(--radius-md); corner-shape: var(--corner-shape);
  border: 1px solid var(--color-border); background: var(--color-surface); color: var(--color-text);
  font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-semibold); cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background-color var(--motion-fast) var(--ease-standard), border-color var(--motion-fast) var(--ease-standard), transform var(--motion-instant) var(--ease-out);
}
.oparo-btn:active { transform: scale(.97); }
@media (hover: hover) { .oparo-btn:hover { background: var(--color-surface-2); } }
.oparo-btn--primary { background: var(--color-primary-strong); border-color: transparent; color: #fff; }
@media (hover: hover) { .oparo-btn--primary:hover { background: var(--color-primary-strong-hover); } }
.oparo-btn--quiet { background: transparent; border-color: transparent; }
.oparo-btn--danger { background: var(--color-danger-strong); border-color: transparent; color: #fff; }
.oparo-btn[disabled], .oparo-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }

.oparo-card { background: var(--color-surface); border: 1px solid var(--color-border-subtle); border-radius: var(--radius-lg); corner-shape: var(--corner-shape); box-shadow: var(--shadow-sm); padding: var(--space-5); }

.oparo-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); row-gap: var(--space-2); }
.oparo-toolbar__title { margin: 0 auto 0 0; font-family: var(--font-heading); font-size: var(--fs-2xl); letter-spacing: var(--tracking-display); line-height: var(--lh-tight); }
.oparo-toolbar__group { display: inline-flex; align-items: center; gap: var(--space-2); flex-wrap: nowrap; }

.oparo-segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--color-surface-2); border-radius: var(--radius-md); corner-shape: var(--corner-shape); }
.oparo-segmented > * { appearance: none; border: 0; background: transparent; font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--color-text-muted); min-height: 32px; padding: 0 var(--space-3); border-radius: calc(var(--radius-md) - 3px); cursor: pointer; }
.oparo-segmented > [aria-checked="true"], .oparo-segmented > [aria-pressed="true"], .oparo-segmented > [aria-selected="true"], .oparo-segmented > [aria-current="page"] { background: var(--color-surface); color: var(--color-text); box-shadow: var(--shadow-xs); }

.oparo-empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-2); padding: var(--space-12) var(--space-6); color: var(--color-text-muted); }
.oparo-empty__icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 50%; background: var(--color-surface-2); color: var(--color-text-muted); margin-bottom: var(--space-2); }
.oparo-empty__title { margin: 0; font-family: var(--font-heading); font-size: var(--fs-lg); font-weight: var(--fw-bold); color: var(--color-text); letter-spacing: var(--tracking-heading); }
.oparo-empty__hint { margin: 0; font-size: var(--fs-sm); max-width: 42ch; }
.oparo-empty__action { margin-top: var(--space-3); }

.oparo-toast { display: flex; align-items: center; gap: var(--space-3); min-height: 48px; padding: var(--space-3) var(--space-4);
  background: var(--color-text); color: var(--color-background); border-radius: var(--radius-lg); corner-shape: var(--corner-shape); box-shadow: var(--shadow-lg);
  animation: oparo-toast-in var(--motion-slow) var(--ease-out); }
@keyframes oparo-toast-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

.oparo-dialog { border: 0; padding: 0; background: var(--color-surface-elevated); color: var(--color-text); border-radius: var(--radius-xl); corner-shape: var(--corner-shape); box-shadow: var(--shadow-xl); max-width: min(560px, calc(100vw - 32px)); }
.oparo-dialog::backdrop { background: var(--color-scrim); }

/* 6. App adapters --------------------------------------------------------- */
/* Each block maps an app's existing classes onto the shared frame. They are
   intentionally small: structural changes live in the app source. */

/* Every app: body text and headings on the shared type. */
html[data-oparo-app] body { font-family: var(--font-sans); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
html[data-oparo-app] :is(h1, h2, h3) { font-family: var(--font-heading); }

/* Align */
html[data-oparo-app="align"] .appbar { min-height: var(--frame-header-h); background: var(--color-material); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--color-border-subtle); }
html[data-oparo-app="align"] :is(.card, .panel, .modal, .dialog, .drawer, .menu, .popover, input:not([type="radio"], [type="checkbox"], [type="range"]), select, textarea, .btn) { corner-shape: var(--corner-shape); }

/* Horizon */
html[data-oparo-app="horizon"] .topbar { min-height: var(--frame-header-h); background: var(--color-material); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); border-bottom: 1px solid var(--color-border-subtle); }
html[data-oparo-app="horizon"] :is(.card, .panel, .modal, .dialog, .drawer, .menu, .segmented, input:not([type="radio"], [type="checkbox"], [type="range"]), select, textarea, .btn) { corner-shape: var(--corner-shape); }

/* Page and Files share one source of tokens (packages/page-ui). */
html[data-oparo-app="page"], html[data-oparo-app="files"] {
  --font: var(--font-sans);
}
html:is([data-oparo-app="page"], [data-oparo-app="files"]) .topbar {
  min-height: var(--frame-header-h); padding: 0 var(--space-4); gap: var(--space-3);
  background: var(--color-material); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--color-border-subtle);
}
html:is([data-oparo-app="page"], [data-oparo-app="files"]) .topbar-user { gap: var(--space-1); }
html:is([data-oparo-app="page"], [data-oparo-app="files"]) .page-notif-trigger { width: 44px; height: 44px; border-radius: var(--radius-full); color: var(--color-text-muted); }
html:is([data-oparo-app="page"], [data-oparo-app="files"]) :is(.dl-title, .dr-title) {
  margin: 0; font-family: var(--font-heading); font-size: var(--fs-2xl); font-weight: var(--fw-bold); letter-spacing: var(--tracking-display); line-height: var(--lh-tight); color: var(--color-text);
}
html[data-oparo-app="files"] .dr-head { row-gap: var(--space-3); }
html[data-oparo-app="files"] .dr-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html[data-oparo-app="files"] .fx-group { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--color-text-subtle); text-transform: none; letter-spacing: var(--tracking-small); }
html:is([data-oparo-app="page"], [data-oparo-app="files"]) :is(.btn, button.btn, .card, .panel, .modal, [role="dialog"], [role="menu"], input:not([type="radio"], [type="checkbox"], [type="range"]), select, textarea) { corner-shape: var(--corner-shape); }

/* Phone */
html[data-oparo-app="phone"] :is(.card, .dialog, .modal, .sheet, input:not([type="radio"], [type="checkbox"], [type="range"]), select, textarea, .btn) { corner-shape: var(--corner-shape); }

/* Oparo ID */
html[data-oparo-app="id"] :is(.card, .flow-card, input:not([type="radio"], [type="checkbox"], [type="range"]), select, textarea, button) { corner-shape: var(--corner-shape); }

/* 7. Surface System — level application (see design-system/SURFACE-SYSTEM.md
   in this repo and the design of record in oparo-platform,
   design-system/foundations/materials/README.md). */
/* Oparo Surface System — level application (Warm Precision).
   A surface level reaches an application only through this shared block
   or a shared component that sets data-oparo-surface. Levels:
   s0 canvas (flat), s1 surface (solid), s2 elevated (solid + elevation,
   backed by a real border), s3 expressive (governed soft texture),
   s4 branded (governed brand texture), s5 marketing (branded base).
   In forced colours the system flattens: boundaries are carried by the
   border and the semantic elements, never by texture, gradient or
   shadow. The Surface System introduces no animation of its own. */
[data-oparo-surface="s0"] { background: var(--oparo-material-canvas); }
[data-oparo-surface="s1"] { background: var(--oparo-material-surface); }
[data-oparo-surface="s2"] { background: var(--oparo-material-elevated); border: 1px solid var(--color-border-subtle); box-shadow: var(--shadow-lg); }
[data-oparo-surface="s3"] { background: var(--oparo-material-expressive); }
[data-oparo-surface="s4"] { background: var(--oparo-material-branded); }
[data-oparo-surface="s5"] { background: var(--oparo-material-marketing); }
@media (forced-colors: active) {
  [data-oparo-surface] { background: Canvas; color: CanvasText; box-shadow: none; }
  [data-oparo-surface="s2"] { border-color: CanvasText; }
}
