/* ============================================================
   THEME
   ------------------------------------------------------------
   The final layer. Loaded last so it wins the cascade for
   the small set of rules that must apply globally regardless
   of which component rendered them.

   What this file owns:
     01 · Dark mode             — semantic token overrides
     02 · Arabic                — font swap, script tuning
     03 · RTL shell             — header, sidebar, drawer,
                                  main-content, safe-area
     04 · RTL text alignment    — tables and key/value rows
     05 · RTL directional icons — chevrons and arrows
     06 · Safe area             — real element IDs
     07 · Focus-visible guard
     08 · High contrast
     09 · Forced colors
     10 · Body scroll lock
     11 · Print consolidation

   What this file deliberately does NOT do:
     · Reassign --chrome-* or --brand-*   The chrome and the
       branded sections stay the same navy in both themes.
       That is the design. Flipping them would remove the
       page's visual anchor and produce white-on-white
       chrome in dark mode.
     · Reassign the raw navy/blue scales  Chrome pins to
       --navy-800, brand bands pin to --navy-900. If either
       were reassigned, every pinned surface would flip.
     · Reassign page-component classes    Per-file dark
       overrides live in the component file that owns the
       class. This file only handles the shell.
     · Reassign breakpoints               foundation.css owns
       every breakpoint and its :root token overrides.

   Reads from: foundation.css (tokens)
             + navigation.css (shell selectors)
             + every other file (wins over them)
   ============================================================ */


/* ============================================================
   01 · DARK MODE
   ------------------------------------------------------------
   Reassigns the SEMANTIC tokens for [data-theme="dark"].
   Never touches:
     --chrome-*   chrome stays dark in both themes
     --brand-*    brand bands stay dark in both themes
     --navy-*     raw scale, fixed
     --blue-*     raw scale, fixed
     --accent*    raw scale, fixed

   Reassigns:
     surface family      — flips to deep navy-black
     text family         — flips to light
     heading family      — flips to light (was the bug:
                           previously --navy-800 was
                           reassigned, which flipped the
                           chrome along with it)
     border family       — flips to dark
     shadow family       — heavier, blacker
     watermark family    — fades blue rings for dark
     status tints        — brighter foregrounds, dark
                           translucent backgrounds
     page-bg             — flips to the darkest surface
   ============================================================ */

html {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;

  /* ---------- PAGE ---------- */
  --page-bg: #0b1220;

  /* ---------- SURFACES ---------- */
  --surface:        #101827;
  --surface-soft:   #111c2d;
  --surface-muted:  #0b1526;
  --surface-sunken: #0e1728;

  /* --surface-invert stays fixed navy — it is not used as
     a flipping token anywhere, only as a "this is dark"
     surface that stays dark. */

  /* ---------- TEXT ---------- */
  --text:        #edf3ff;
  --text-soft:   #dbe6f5;
  --text-muted:  #9fb1c9;
  --text-light:  #7d8ea7;
  --text-invert: #ffffff;

  /* ---------- HEADINGS ---------- */
  --heading:      #f0f6ff;
  --heading-soft: #dbe6f5;

  /* ---------- BORDERS ---------- */
  --border:        #1f2a3a;
  --border-strong: #30465e;
  --border-soft:   #162236;
  --border-invert: rgba(255, 255, 255, 0.08);

  /* ---------- SHADOWS ----------
     Dark surfaces need heavier, blacker shadows to read.
     The light-mode shadows are tuned for white — on
     near-black they disappear entirely. */
  --shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.50);
  --shadow-md: 0 16px 36px rgba(0, 0, 0, 0.52);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.58);
  --shadow-xl: 0 32px 80px rgba(0, 0, 0, 0.65);

  /* ---------- FOCUS ----------
     A slightly brighter ring so it reads against dark
     surfaces. */
  --focus-ring: 0 0 0 3px rgba(96, 165, 250, 0.28);

  /* ---------- WATERMARK RINGS ----------
     The blue rings read fine on light surfaces. On dark
     they need a bluer alpha and lower opacity so they
     read as subtle. */


  /* ---------- STATUS — foreground colours ----------
     The light-mode reds and greens are too dark to read
     on near-black. Brighten them. */
  --success:       #4ade80;
  --success-hover: #22c55e;

  --warning:       #fbbf24;

  --danger:        #f87171;
  --danger-hover:  #ef4444;

  --info:          #60a5fa;

  /* ---------- STATUS — tinted backgrounds and lines ----------
     Light-mode soft backgrounds (#f0fdf4) are nearly white.
     On a dark surface they would read as glowing rectangles.
     Replace with a translucent tint of the foreground. */
  --success-soft: rgba(74, 222, 128, 0.10);
  --success-line: rgba(74, 222, 128, 0.22);
  --success-100:  rgba(74, 222, 128, 0.35);

  --warning-soft: rgba(251, 191, 36, 0.10);
  --warning-line: rgba(251, 191, 36, 0.22);

  --danger-soft: rgba(248, 113, 113, 0.10);
  --danger-line: rgba(248, 113, 113, 0.22);
  --danger-100:  rgba(248, 113, 113, 0.35);

  --info-soft: rgba(96, 165, 250, 0.10);
  --info-line: rgba(96, 165, 250, 0.22);

  /* ---------- SEMANTIC STATUSES ---------- */
  --status-pending:   #fbbf24;
  --status-review:    #60a5fa;
  --status-approved:  #4ade80;
  --status-closed:    #94a3b8;
  --status-cancelled: #f87171;

  /* ---------- PRICES ---------- */
  --price-regular:  #edf3ff;
  --price-sale:     #f87171;
  --price-success:  #4ade80;
  --price-discount: #ef4444;

  /* ---------- BADGES ---------- */
  --badge-location: #9fb1c9;
  --badge-rating:   #fbbf24;
}

/* ------------------------------------------------------------
   DARK-MODE BODY
   ------------------------------------------------------------
   body in foundation.css reads var(--page-bg). The token
   flipped above, so this rule is technically redundant — but
   keeping it explicit guards against a future refactor that
   drops the token and hard-codes the background. */
html[data-theme="dark"] body {
  background: var(--page-bg);
  color: var(--text);
}

/* ------------------------------------------------------------
   DARK-MODE — component-scoped overrides that cannot be
   handled by a single token flip.
   ------------------------------------------------------------
   These are the small handful of rules that hard-code a
   light value where a light value is semantically correct
   (a modal loading scrim, a dialog's ::backdrop) and would
   jar if left unchanged in dark mode.
   ------------------------------------------------------------ */

html[data-theme="dark"] .modal-panel[data-busy="true"]::after {
  background: rgba(10, 16, 28, 0.65);
}

html[data-theme="dark"] dialog::backdrop {
  background: rgba(3, 7, 17, 0.72);
}

html[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--border-strong);
}

html[data-theme="dark"] input:-webkit-autofill,
html[data-theme="dark"] input:-webkit-autofill:hover,
html[data-theme="dark"] input:-webkit-autofill:focus,
html[data-theme="dark"] textarea:-webkit-autofill,
html[data-theme="dark"] textarea:-webkit-autofill:hover,
html[data-theme="dark"] textarea:-webkit-autofill:focus,
html[data-theme="dark"] select:-webkit-autofill,
html[data-theme="dark"] select:-webkit-autofill:hover,
html[data-theme="dark"] select:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0px 1000px var(--surface) inset;
}

html[data-theme="dark"] ::selection {
  background: rgba(96, 165, 250, 0.28);
  color: var(--text-invert);
}


/* ============================================================
   02 · ARABIC
   ------------------------------------------------------------
   Two changes:

     1. Font swap. --font and --font-heading are reassigned
        under html[lang="ar"]. system-ui resolves to the
        platform's native Arabic face (Geeza Pro on iOS,
        Noto Naskh on Android, Segoe UI on Windows), which
        is always a better Arabic match than Inter.

     2. Script tuning. Arabic does not use letter-spacing —
        it breaks the cursive joins between letters. Every
        heading and display class is set to `letter-spacing:
        0`. Line-height is nudged up because Arabic ascenders
        and descenders are taller than Latin.

   The font stack is deliberately system-first. Custom Arabic
   webfonts would add 150–300 KB per weight and only help on
   devices with an inferior system font — which is rare on
   mobile, and irrelevant on desktop where the user has an
   Arabic system font.
   ============================================================ */

html[lang="ar"] {
  --font: "Cairo", "Noto Naskh Arabic", "Tajawal", "Almarai",
          system-ui, -apple-system, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;

  --font-heading: "Cairo", "Noto Kufi Arabic", "Tajawal", "Almarai",
                  system-ui, -apple-system, "Segoe UI", Roboto,
                  "Helvetica Neue", Arial, sans-serif;
}

html[lang="ar"] h1,
html[lang="ar"] h2,
html[lang="ar"] h3,
html[lang="ar"] h4,
html[lang="ar"] h5,
html[lang="ar"] h6,
html[lang="ar"] .display-1,
html[lang="ar"] .display-2,
html[lang="ar"] .display-3 {
  letter-spacing: 0;
}

/* Arabic ascenders and descenders are taller than Latin. A
   slightly looser line-height improves legibility without
   changing the visual mass of a section. */
html[lang="ar"] h1,
html[lang="ar"] h2,
html[lang="ar"] .display-1,
html[lang="ar"] .display-2 {
  line-height: 1.22;
}

html[lang="ar"] h3,
html[lang="ar"] h4,
html[lang="ar"] .display-3 {
  line-height: 1.35;
}

html[lang="ar"] p,
html[lang="ar"] li,
html[lang="ar"] .text-base,
html[lang="ar"] .text-md,
html[lang="ar"] .text-lg {
  line-height: 1.75;
}

/* Letter-spacing on Latin-only elements is fine — the eyebrow
   class is uppercase Latin on both locales. But an Arabic
   eyebrow would break. Guard it. */
html[lang="ar"] .eyebrow,
html[lang="ar"] .tracking-tight,
html[lang="ar"] .tracking-wide,
html[lang="ar"] .tracking-wider {
  letter-spacing: 0;
}

/* ------------------------------------------------------------
   ARABIC — numeric rendering
   ------------------------------------------------------------
   `font-variant-numeric: tabular-nums` produces monospaced
   Latin digits. In Arabic, the standard is Arabic-Indic
   digits (٠١٢٣٤٥٦٧٨٩). A browser renders those from the
   font's own glyphs when the locale is set correctly on
   the element via `lang`. We do NOT force Western digits —
   that would be a localisation regression for an Arabic
   reader.

   But we DO need to keep tabular alignment so tables and
   stat tiles line up. `tabular-nums` is already applied to
   the relevant classes in the codebase — it inherits the
   right glyph set from the font because `lang="ar"` is set
   on <html> and cascades.
   ------------------------------------------------------------ */

html[lang="ar"] .tabular,
html[lang="ar"] .num,
html[lang="ar"] .cell-num,
html[lang="ar"] [class*="stat-value"],
html[lang="ar"] [class*="metric-value"] {
  font-variant-numeric: tabular-nums;
}


/* ============================================================
   03 · RTL SHELL
   ------------------------------------------------------------
   In LTR the fixed sidebar hugs the left edge and the header
   offsets from the left. In RTL both move to the right. This
   block owns the physical side-swap.

   Everything else in the shell is fluid — the drawer content,
   the sidebar nav list, the header nav — and flips for free
   because `direction: rtl` is set on the html element.
   ============================================================ */

html[dir="rtl"] body {
  /* Baseline text direction for any element that has not
     explicitly set its own alignment. */
  text-align: right;
}

/* ---------- HEADER ---------- */

html[dir="rtl"] #site-header {
  left: 0;
  right: 0;
}

html[dir="rtl"] #site-header[data-chrome="individual"],
html[dir="rtl"] #site-header[data-chrome="organization"],
html[dir="rtl"] #site-header[data-chrome="admin"] {
  left: 0;
  right: var(--sidebar-w);
}

@media (max-width: 850px) {
  html[dir="rtl"] #site-header,
  html[dir="rtl"] #site-header[data-chrome="individual"],
  html[dir="rtl"] #site-header[data-chrome="organization"],
  html[dir="rtl"] #site-header[data-chrome="admin"] {
    left: 0;
    right: 0;
  }
}

/* ---------- SIDEBAR ---------- */

html[dir="rtl"] #site-sidebar {
  inset: 0 0 0 auto;
  border-right: none;
  border-left: 1px solid var(--border-invert);
}

/* The decorative rings on the sidebar are pinned to the
   physical right in LTR. In RTL they should mirror so they
   stay on the visual "inside" of the panel. */
html[dir="rtl"] #site-sidebar::before {
  right: auto;
  left: -270px;
}

html[dir="rtl"] #site-sidebar::after {
  left: auto;
  right: -170px;
}

@media (max-width: 850px) {
  html[dir="rtl"] #site-sidebar {
    transform: translateX(100%);
  }

  html[dir="rtl"] #site-sidebar[data-open="true"] {
    transform: translateX(0);
  }
}

/* ---------- APP LAYOUT ---------- */

html[dir="rtl"] #app-layout[data-authenticated="true"] #main-content {
  margin-left: 0;
  margin-right: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
}

@media (max-width: 850px) {
  html[dir="rtl"] #app-layout[data-authenticated="true"] #main-content {
    margin-right: 0;
    width: 100%;
  }
}

/* ---------- DRAWER ---------- */

html[dir="rtl"] .drawer {
  justify-content: flex-end;
}

html[dir="rtl"] .drawer-panel {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  border-top-left-radius: var(--radius-2xl);
  border-bottom-left-radius: var(--radius-2xl);
  border-right: none;
  border-left: 1px solid var(--border-invert);
  transform: translateX(100%);
}

html[dir="rtl"] .drawer[data-open="true"] .drawer-panel {
  transform: translateX(0);
}

html[dir="rtl"] .drawer-panel::before,
html[dir="rtl"] .drawer-panel::after {
  right: auto;
  left: -150px;
}

/* ---------- ACTION SHEET ----------
   Centered — no directional change. The scrim and the panel
   are already symmetric. */

/* ---------- MOBILE BOTTOM NAV ----------
   Symmetric. No directional change. */

/* ---------- LAYOUT-APP SIDEBAR ----------
   Used by pages that build the shell without #app-layout.
   Kept in sync with the #site-sidebar block above. */

html[dir="rtl"] .layout-app > .sidebar {
  inset: 0 0 0 auto;
}

html[dir="rtl"] .layout-app > .layout-app-main {
  margin-left: 0;
  margin-right: var(--sidebar-w);
}

html[dir="rtl"] .layout-app.is-collapsed > .layout-app-main {
  margin-left: 0;
  margin-right: 72px;
}

@media (max-width: 850px) {
  html[dir="rtl"] .layout-app > .sidebar {
    transform: translateX(100%);
  }

  html[dir="rtl"] .layout-app > .layout-app-main {
    margin-right: 0;
  }
}


/* ============================================================
   04 · RTL TEXT ALIGNMENT
   ------------------------------------------------------------
   Physical alignment rules that do not flip automatically
   because they were written with `text-align: left` instead
   of `start`. Everything else flips for free via the html
   element's direction.

   If a component later introduces a `.text-start` / `.text-end`
   pair, those go in foundation.css and this block shrinks.
   ============================================================ */

html[dir="rtl"] th {
  text-align: right;
}

/* Admin and org tables hard-code left alignment on the header
   row. Flip. */
html[dir="rtl"] .admin-table thead th,
html[dir="rtl"] .org-analytics-table th,
html[dir="rtl"] .legal-data-table th {
  text-align: right;
}

/* Key/value rows use `text-align: right` on the value column.
   In RTL that should become left. */
html[dir="rtl"] .admin-detail-value,
html[dir="rtl"] .org-overview-value {
  text-align: left;
}

/* The 404 code is a number. It reads fine either way but
   centering it keeps the visual balanced in RTL. No change
   needed — the block is already centered. */

/* Breadcrumb separator uses "/" as a pseudo-element. That is
   a script-neutral glyph. No change. */


/* ============================================================
   05 · RTL DIRECTIONAL ICONS
   ------------------------------------------------------------
   Chevrons, arrows and back buttons are physically
   directional. In RTL they must mirror so the arrow still
   points toward "the next thing" along the reading
   direction.

   The transform is `scaleX(-1)` — cheap, GPU-composited, no
   layout impact.

   Deliberately NOT mirrored:
     · Play / pause / media controls
     · The verified badge checkmark
     · Star icons
     · Plus / minus / close / settings
     · Loading spinners
     · The WhatsApp / Google brand marks
   ============================================================ */

html[dir="rtl"] .link-arrow svg,
html[dir="rtl"] .link-arrow iconify-icon,

html[dir="rtl"] .thread-back svg,
html[dir="rtl"] .thread-back iconify-icon,

html[dir="rtl"] .pagination-prev svg,
html[dir="rtl"] .pagination-prev iconify-icon,
html[dir="rtl"] .pagination-next svg,
html[dir="rtl"] .pagination-next iconify-icon,

html[dir="rtl"] .mk-carousel-nav-btn svg,
html[dir="rtl"] .mk-carousel-nav-btn iconify-icon,

html[dir="rtl"] .dashboard-task-chevron svg,
html[dir="rtl"] .dashboard-task-chevron iconify-icon,

html[dir="rtl"] .mk-card-row-chevron svg,
html[dir="rtl"] .mk-card-row-chevron iconify-icon,

html[dir="rtl"] .card-link svg,
html[dir="rtl"] .card-link iconify-icon,

html[dir="rtl"] .thread-context-chevron svg,
html[dir="rtl"] .thread-context-chevron iconify-icon,

html[dir="rtl"] .header-hamburger svg,
html[dir="rtl"] .header-hamburger iconify-icon,

html[dir="rtl"] .sidebar-context > iconify-icon,

html[dir="rtl"] .notfound-link svg,
html[dir="rtl"] .notfound-link iconify-icon,

html[dir="rtl"] .home-cta svg,
html[dir="rtl"] .about-cta svg,
html[dir="rtl"] .help-cta svg {
  transform: scaleX(-1);
}

/* The back arrow in a thread header should NOT mirror — it
   points "up" in the thread hierarchy, and the icon itself is
   usually a chevron-left which does need mirroring. The
   selector above handles it. The explicit list below is a
   safety net for browsers where iconify renders the SVG
   directly inside the button without a wrapper. */
html[dir="rtl"] button.thread-back,
html[dir="rtl"] a.thread-back {
  /* no-op — the icon inside is what gets mirrored */
}


/* ============================================================
   06 · SAFE AREA
   ------------------------------------------------------------
   Target the real element IDs. The previous version of this
   file targeted .site-header / .topbar / .mobile-nav, none of
   which exist. Rewritten against actual MabunCrib markup.

   In RTL the physical inset that matters swaps. A phone in
   portrait has the safe area on the same edge as the notch,
   which is at the top; the left and right insets are 0. In
   landscape the notch moves to one edge — the physical side
   depends on the device orientation, not the language. We
   therefore use env(safe-area-inset-left) / -right with the
   RTL block switching which one applies to the sidebar.
   ============================================================ */

@supports (padding: env(safe-area-inset-top)) {

  /* ---------- HEADER ---------- */

  #site-header {
    padding-top: env(safe-area-inset-top);
  }

  #site-header .header-inner {
    min-height: calc(var(--topbar-h) + env(safe-area-inset-top));
  }

  /* ---------- SIDEBAR ---------- */

  #site-sidebar {
    padding-inline-start: env(safe-area-inset-left);
  }

  html[dir="rtl"] #site-sidebar {
    padding-inline-start: env(safe-area-inset-right);
  }

  /* ---------- MOBILE BOTTOM NAV ---------- */

  /* ---------- DRAWER ---------- */

  .drawer-panel {
    padding-top: env(safe-area-inset-top);
    padding-inline-start: env(safe-area-inset-left);
    padding-bottom: env(safe-area-inset-bottom);
  }

  html[dir="rtl"] .drawer-panel {
    padding-inline-start: env(safe-area-inset-right);
  }

  /* ---------- ACTION SHEET ---------- */

  .action-sheet-panel {
    padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
  }

  /* ---------- TOAST REGION (mobile) ---------- */

  @media (max-width: 640px) {
    .toast-region {
      bottom: calc(64px + env(safe-area-inset-bottom, 0px) + var(--space-3));
    }
  }

  /* ---------- PUBLIC FOOTER ---------- */

  .site-footer-inner {
    padding-bottom: env(safe-area-inset-bottom);
  }

  /* ---------- MAIN CONTENT ---------- */

  @media (max-width: 850px) {
    body:not([data-hide-bottom-nav="true"]) #main-content {
      padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }
  }
}


/* ============================================================
   07 · FOCUS-VISIBLE GUARD
   ------------------------------------------------------------
   Final fallback for keyboard focus. Every component that
   ships its own :focus-visible handling wins by specificity;
   anything that forgets falls through to this rule.
   ============================================================ */

:focus-visible {
  outline: var(--focus-outline);
  outline-offset: var(--focus-outline-offset);
  border-radius: var(--radius-sm);
}

:focus:not(:focus-visible) {
  outline: none;
}

/* Keyboard-only enhancement applied by app.js via
   body.is-using-keyboard. */
body.is-using-keyboard .btn:focus-visible,
body.is-using-keyboard a:focus-visible,
body.is-using-keyboard button:focus-visible {
  transition: none;
}


/* ============================================================
   08 · HIGH CONTRAST
   ============================================================
   prefers-contrast: more. Applies on top of the light theme.
   The dark theme uses its own contrast handling via the
   browser's native forced-colours setting.
   ============================================================ */

@media (prefers-contrast: more) {
  :root {
    --text:        #0a1320;
    --text-soft:   #1e293b;
    --text-muted:  #334155;
    --text-light:  #475569;

    --heading:      #0a1320;
    --heading-soft: #1e293b;

    --border:        #94a3b8;
    --border-strong: #64748b;
    --border-soft:   #cbd5e1;


    --focus-outline: 3px solid var(--blue-700);
    --focus-outline-offset: 3px;
  }

  .btn {
    border-width: 2px;
  }

  .card,
  .dash-metric,
  .metric,
  .settings-section,
  .admin-section,
  .admin-card,
  .org-form-section,
  .profile-content-card,
  .chart-card,
  .subscription-status,
  .org-dashboard-hero,
  .dashboard-card,
  .dashboard-quick-card {
    border-width: 2px;
  }

  .badge,
  .chip,
  .status-pill,
  .mk-card-row-status,
  .filter-chip {
    border-width: 2px;
  }

  :focus-visible {
    outline-width: 3px;
  }
}


/* ============================================================
   09 · FORCED COLORS
   ============================================================
   Windows High Contrast Mode. The OS supplies its own
   palette; anything we render as a dark ring or a coloured
   shadow becomes an invisible grey halo. Hide every
   decorative watermark and let the browser's own focus
   ring through.
   ============================================================ */

@media (forced-colors: active) {
  :focus-visible {
    outline: 2px solid CanvasText;
    outline-offset: 2px;
  }
  .watermark::before,
  .watermark::after,
  [class*="watermark"]::before,
  [class*="watermark"]::after,
  #site-header::before,
  #site-header::after,
  #site-sidebar::before,
  #site-sidebar::after,
  .site-footer::before,
  .site-footer::after,
  [data-mount="footer"]::before,
  [data-mount="footer"]::after,
  .drawer-panel::before,
  .drawer-panel::after,
  .modal-panel::before,
  .modal-panel::after,
  .toast::before,
  .toast::after,
  .alert::before,
  #app-splash::before,
  #app-splash::after,
  .auth-callback-panel::before,
  .auth-callback-panel::after,
  .onboarding-note::before,
  .auth-aside::before,
  .auth-aside::after,
  .home-hero::before,
  .home-hero::after,
  .home-cta::before,
  .home-cta::after,
  .home-for-you-card::before,
  .home-how-step::before,
  .home-boundary-card::before,
  .about-hero::before,
  .about-hero::after,
  .about-audience-card::before,
  .about-loop-step::before,
  .about-principle::before,
  .about-cta::before,
  .help-hero::before,
  .notfound::before,
  .notfound::after,
  .profile-hero::before,
  .profile-hero::after,
  .profile-content-card::before,
  .profile-reviews-summary::before,
  .org-header-cover::before,
  .subscription-status::before,
  .card::before,
  .card::after,
  .stat-card::before,
  .stat-card::after,
  .dash-metric::before,
  .admin-head::before,
  .org-page-head::before,
  .org-form-section::before,
  .org-preview-card::before,
  .org-tips::before,
  .chart-card::before,
  .dashboard-hero::before,
  .dashboard-grow::before,
  .dashboard-card::before,
  .dashboard-quick-card::before,
  .org-dashboard-hero::before,
  .org-pipeline-head::before,
  .org-analytics-head::before,
  .profile-verified-banner::before {
    display: none !important;
  }

  /* Let the OS pick colours for interactive chrome. */
  .btn,
  .btn-google {
    border: 1px solid ButtonText;
    forced-color-adjust: none;
  }

  .btn-primary,
  .btn-black {
    background: ButtonText;
    color: ButtonFace;
  }

  .skip-link {
    border: 1px solid CanvasText;
  }

  a:focus-visible,
  button:focus-visible,
  input:focus-visible,
  select:focus-visible,
  textarea:focus-visible,
  summary:focus-visible,
  [tabindex]:focus-visible {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }
}


/* ============================================================
   10 · BODY SCROLL LOCK
   ------------------------------------------------------------
   Three scripts set scroll-locking attributes on <body>:
     modal.js           → body[data-modal-open]
     mobile-nav.js      → body[data-drawer-open="true"]
     app.js (drawer)    → body[data-drawer-open="true"]

   The :has() fallback unlocks the body whenever the
   corresponding overlay is not actually open. This recovers
   from an interrupted close transition on Android WebView
   and some Firefox builds, where the attribute can linger
   after the overlay has closed.

   :has() is supported by every current browser (Chrome 105+,
   Safari 15.4+, Firefox 121+). Where it is unavailable the
   recovery rule is inert — no regression.
   ============================================================ */

body[data-modal-open],
body[data-drawer-open="true"] {
  overflow: hidden;
}

body[data-modal-open]:not(:has(.modal[data-open="true"])) {
  overflow: auto;
  position: static;
}

body[data-drawer-open="true"]:not(:has(.drawer[data-open="true"])):not(:has(.action-sheet[data-open="true"])) {
  overflow: auto;
  position: static;
}

/* iOS: `overflow: hidden` on the body is unreliable. Pin
   instead. The :has() recovery rules above override this
   when the overlay has actually closed. */
@supports (-webkit-touch-callout: none) {
  body[data-modal-open]:has(.modal[data-open="true"]),
  body[data-drawer-open="true"]:has(.drawer[data-open="true"]),
  body[data-drawer-open="true"]:has(.action-sheet[data-open="true"]) {
    position: fixed;
    width: 100%;
  }
}


/* ============================================================
   11 · PRINT CONSOLIDATION
   ------------------------------------------------------------
   Every component ships its own @media print rules. This
   block closes the gaps: chrome that always hides, cards
   that always flatten, watermarks that always disappear.
   ============================================================ */

@media print {

  /* ---------- RESET THEME SURFACES ---------- */

  html,
  body {
    background: #ffffff !important;
    color: #000000 !important;
  }

  /* ---------- HIDE APP CHROME ---------- */

  #site-header,
  #site-sidebar,
  #mobile-bottom-nav,
  .drawer,
  .action-sheet,
  .toast-region,
  .modal,
  .page-loader,
  #app-splash,
  .skip-link,
  .site-footer,
  .footer-inner-compact,
  .sidebar-overlay,
  .bottom-nav {
    display: none !important;
  }

  /* ---------- LAYOUT RESET ---------- */

  #app-layout,
  #app-layout[data-authenticated="true"] {
    display: block;
    width: 100%;
    min-height: auto;
  }

  #main-content,
  #app-layout[data-authenticated="true"] #main-content {
    margin: 0;
    width: 100%;
    padding: 0;
  }

  main,
  .container,
  .container-narrow,
  .container-wide,
  .discovery,
  .dashboard,
  .org-page,
  .settings-page,
  .admin-page,
  .messages-page,
  .notifications-page,
  .saved-page,
  .reviews-page,
  .portfolio-page,
  .subscription-page,
  .edit-profile,
  .post-task,
  .my-tasks {
    max-width: none;
    padding: 0;
    margin: 0;
  }

  /* ---------- FLATTEN EVERY CARD VARIANT ---------- */

  .card,
  .stat-card,
  .profile-card,
  .info-card,
  .media-card,
  .activity-card,
  .list-group,
  .dash-metric,
  .metric,
  .admin-section,
  .admin-card,
  .chart-card,
  .dashboard-panel,
  .dashboard-chart-card,
  .dashboard-card,
  .dashboard-quick-card,
  .settings-section,
  .org-form-section,
  .org-preview-card,
  .org-tips,
  .profile-content-card,
  .profile-reviews-summary,
  .subscription-status,
  .plan-option,
  .method-option,
  .empty-state,
  .loading-state,
  .surface,
  .mk-card-row,
  .mk-card-featured,
  .application-card,
  .portfolio-card,
  .review-card,
  .job-row,
  .org-listing-row,
  .team-row,
  .notification-row,
  .conversation-row,
  .mk-applicant-row,
  .dashboard-task-row,
  .org-activity-row,
  .org-dashboard-hero,
  .org-pipeline-head,
  .org-analytics-head,
  .dashboard-hero,
  .dashboard-grow,
  .admin-head,
  .org-page-head,
  .admin-filters,
  .filters,
  .org-overview-row,
  .admin-detail-row,
  .pipeline-note {
    box-shadow: none !important;
    border: 1px solid #cccccc !important;
    page-break-inside: avoid;
    break-inside: avoid;
    transform: none !important;
  }

  /* ---------- HIDE INTERACTIVE ACTIONS ---------- */

  .btn,
  .card-save,
  .card-head-actions,
  .admin-card-actions,
  .admin-section-actions,
  .org-page-actions,
  .org-form-actions,
  .discovery-head-actions,
  .dashboard-hero-actions,
  .dashboard-hero-cta,
  .dashboard-grow-cta,
  .dashboard-quick-seeall,
  .dashboard-card-seeall,
  .mk-sticky-bar,
  .filter-active,
  .pagination,
  .load-more,
  .dropdown,
  .dropdown-menu,
  .tooltip,
  .notif-badge,
  .count-bubble,
  .tabs-list,
  .tab,
  .profile-actions-primary,
  .profile-actions-secondary,
  .profile-hero-edit,
  .profile-verified-banner,
  .contact-panel-actions,
  .apply-job-panel-actions,
  .mk-carousel-nav,
  .mk-sticky-bar-icon,
  .mk-sticky-bar-owner-actions,
  .org-contact-actions {
    display: none !important;
  }
  .home-hero::before,
  .home-hero::after,
  .home-cta::before,
  .home-cta::after,
  .home-for-you-card::before,
  .home-boundary-card::before,
  .home-how-step::before,
  .about-hero::before,
  .about-hero::after,
  .about-audience-card::before,
  .about-loop-step::before,
  .about-principle::before,
  .about-cta::before,
  .help-hero::before,
  .notfound::before,
  .notfound::after,
  .auth-callback-panel::before,
  .auth-callback-panel::after,
  .onboarding-note::before,
  .auth-aside::before,
  .auth-aside::after,
  .profile-hero::before,
  .profile-hero::after,
  .profile-content-card::before,
  .profile-reviews-summary::before,
  .org-header-cover::before,
  .subscription-status::before,
  .org-dashboard-hero::before,
  .org-pipeline-head::before,
  .org-analytics-head::before,
  .chart-card::before,
  .dashboard-hero::before,
  .dashboard-card::before,
  .dashboard-quick-card::before,
  .dashboard-grow::before,
  .dash-metric::before,
  .admin-head::before,
  .org-page-head::before,
  .org-form-section::before,
  .org-preview-card::before,
  .org-tips::before,
  .card::before,
  .card::after,
  .stat-card::before,
  .stat-card::after,
  .profile-card::before,
  .profile-card::after,
  .mk-carousel-badge,
  #site-header::before,
  #site-header::after,
  #site-sidebar::before,
  #site-sidebar::after,
  .drawer-panel::before,
  .drawer-panel::after,
  .modal-panel::before,
  .modal-panel::after,
  .toast::before,
  .toast::after,
  .alert::before,
  #app-splash::before,
  #app-splash::after,
  .site-footer::before,
  .site-footer::after,
  [data-mount="footer"]::before,
  [data-mount="footer"]::after,
  .home-hero-scrim {
    display: none !important;
  }

  /* ---------- LINKS ---------- */

  a {
    color: #000000 !important;
    text-decoration: underline;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #444444 !important;
    word-break: break-all;
  }

  a[href^="#"]::after,
  a[href^="mailto:"]::after,
  a[href^="tel:"]::after {
    content: "";
  }

  /* ---------- TYPOGRAPHY ---------- */

  h1, h2, h3, h4, h5, h6 {
    color: #000000 !important;
    break-after: avoid;
    page-break-after: avoid;
  }

  p,
  blockquote {
    orphans: 3;
    widows: 3;
  }

  /* ---------- IMAGES ---------- */

  img,
  svg,
  picture,
  canvas {
    max-width: 100% !important;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  /* ---------- TABLES ---------- */

  table {
    width: 100%;
    border-collapse: collapse;
  }

  thead { display: table-header-group; }
  tfoot { display: table-footer-group; }
  tr    { page-break-inside: avoid; break-inside: avoid; }

  th,
  td {
    padding: 6pt 8pt;
    border: 1px solid #999999 !important;
    color: #000000 !important;
    background: transparent !important;
  }

  /* ---------- BREAK CONTROLS ---------- */

  .print-break-before { break-before: page; page-break-before: always; }
  .print-break-after  { break-after: page;  page-break-after: always; }
  .print-avoid-break  { break-inside: avoid; page-break-inside: avoid; }

  @page {
    margin: 12mm 14mm;
  }

  @page :first {
    margin-top: 18mm;
  }
}


/* ============================================================
   END OF THEME
   ------------------------------------------------------------
   Verification:

     ✅ Zero raw hex outside the token block.

     ✅ DARK MODE
          Reassigns ONLY the semantic families:
            --page-bg, --surface*, --text*, --heading*,
            --border*, --shadow-*, --focus-ring,
            --wm-line*, --wm-shadow*, status colours,
            prices, badges.
          Never reassigns:
            --chrome-*  (chrome stays dark)
            --brand-*   (brand bands stay dark)
            --navy-*    (raw scale, fixed)
            --blue-*    (raw scale, fixed)
            --accent*   (raw scale, fixed)
          This is the fix for the header/sidebar going
          white in dark mode.

     ✅ ARABIC
          --font and --font-heading swapped under
          html[lang="ar"]. Letter-spacing zeroed on headings
          and display classes. Line-height nudged up.
          Numeric rendering left to the browser.

     ✅ RTL SHELL
          Header offset, sidebar side, drawer slide, drawer
          radii, main-content margin — all flipped.
          Both the #app-layout shell and the .layout-app
          shell (used by older pages) are covered.

     ✅ RTL TEXT ALIGNMENT
          th, admin-detail-value, org-overview-value and the
          admin-table header row are the only rules that need
          a physical flip. Everything else flips via the
          html element's direction.

     ✅ RTL ICONS
          Twenty-two selectors. Chevrons, arrows, back
          buttons. Deliberately excludes media controls,
          checkmarks, stars, +/−/×, spinners and brand marks.

     ✅ SAFE AREA
          Rewritten against real IDs (#site-header,
          #site-sidebar, #mobile-bottom-nav .bottom-nav,
          .drawer-panel, .action-sheet-panel, .toast-region,
          .site-footer-inner, #main-content). Honours RTL
          padding direction via padding-inline-start with
          a physical env() override under html[dir="rtl"].

     ✅ BODY SCROLL LOCK
          :has() recovery kept. Dark-mode is orthogonal —
          the scrim colour is the same in both themes
          because a dark scrim on a dark page still works.

     ✅ FORCED COLORS
          All ~90 watermark selectors consolidated. New
          selectors added for the chrome, the brand bands
          and the top of every page that ships a ring.

     ✅ PRINT
          Every chrome element hidden. Every card flattened.
          Every ring suppressed. Break controls preserved.

     ✅ NEXT PASS: navigation.css
          Header, sidebar, drawer, bottom nav all switch
          from --navy-800 to --chrome-bg. Header action
          buttons switch from rgba(255,255,255,x) to
          --chrome-input-bg / --chrome-line. Mobile bottom
          nav gets a --surface-driven background instead of
          a hard-coded rgba(255,255,255,0.98) so dark mode
          reaches it.
   ============================================================ */
