/* v1.8.2.66w.371 — Islamic calm theme system.
 *
 * WHY THIS IS A SEPARATE FILE
 * ---------------------------
 * lhic.css is 7,500 lines with 715 hardcoded hex literals. It also
 * already contains a working `:root[data-theme=...]` mechanism that
 * three accessibility modes (light / dark / hc) ride on. Rather than
 * refactor that file — risky at this size, and it would have blocked
 * the feature for weeks — this file layers a SECOND axis on top:
 *
 *     Look      = brand identity   (emerald | midnight | sand)
 *     Contrast  = accessibility     (normal | hc)
 *
 * giving six resolvable themes:
 *
 *     emerald          midnight        sand
 *     emerald-hc       midnight-hc     sand-hc
 *
 * Loaded AFTER lhic.css, so these blocks win on equal specificity.
 * Every value below is a CSS custom property — no selector-specific
 * overrides — which is why the whole system is 6 blocks of variables
 * and no component code has to know a theme exists.
 *
 * ── Why midnight replaces the old `dark` mode ───────────────────────
 * `midnight` IS the dark brand. Keeping both `dark` and `midnight`
 * would have meant two names for one idea, and the old dark mode had
 * a contrast bug anyway: light ink on a light teal fill (see the
 * contrast note on --accent-text below). The legacy names still
 * resolve — see the alias block at the bottom — so any visitor who
 * had picked "Dark" lands on midnight, which is what they wanted.
 *
 * ── CONTRAST ─────────────────────────────────────────────────────────
 * Every pair in the three brand palettes was machine-verified against
 * WCAG 2.1 before being written here (scripts/verify-theme-contrast.js).
 * 28/28 checks pass. Three values were CHANGED as a result, and the
 * first one was a pre-existing bug in the shipped app, not a new one:
 *
 *   1. --gold-500 was #c89b3c — only 2.34:1 on the cream surface,
 *      below the 3:1 floor WCAG sets for UI components. Re-solved to
 *      #ae8925, which is exactly 3.00:1. This was failing on the live
 *      site before this file existed.
 *   2. midnight's primary button used light ink on a light teal fill
 *      (1.71:1 — effectively invisible). Fixed by introducing an
 *      explicit --accent-text per theme instead of assuming white.
 *   3. sand's bronze was 2.90:1; re-solved to #b5873d at 3.00:1,
 *      with a hue constraint so it stays bronze and doesn't drift
 *      olive when you optimise purely for luminance.
 *
 * ── WHAT THIS DOES NOT FIX ───────────────────────────────────────────
 * The 715 hardcoded hex literals in lhic.css still do not follow the
 * theme. scripts/theme-coverage-report.js lists them by selector so
 * the long tail is at least visible rather than silently wrong. The
 * high-visibility surfaces (header, hero, bismillah strip, cards,
 * badges, buttons, forms, the prayer-plot map) are tokenised and DO
 * follow; everything else keeps the emerald palette.
 */

/* ══════════════════════════════════════════════════════════════════════
   1. EMERALD SERENITY — the incumbent look, preserved.
   The default install must not change appearance, so this block is
   the shipped palette with the one contrast fix noted above.
   ══════════════════════════════════════════════════════════════════════ */
:root[data-theme="emerald"],
:root[data-theme="emerald-hc"] {
  --focus-ring: 2px solid var(--green-500);
  --green-900: #0e3a2f;
  --green-700: #155a48;
  --green-500: #1f8c6b;
  --green-300: #5fb89b;
  --green-100: #d5ebe1;
  --gold-700: #8a6d24;
  --gold-500: #ae8925;   /* was #c89b3c = 2.34:1 on --surface. FAIL. */
  --gold-300: #e4c879;
  --gold-100: #f8edcd;
  --ink-900: #0a1e1a;
  --ink-700: #2c3a36;
  --ink-500: #54635e;
  --ink-300: #93a39e;
  --ink-100: #e3e9e7;
  --surface: #f6f5ee;
  --white: #ffffff;

  --danger: #b03a2e; --on-danger: #ffffff; --on-fill: #ffffff;
  --warn: #b8860b;
  --ok: #1f8c6b;
  --danger-bg: #fee2e2;  --danger-fg: #991b1b;
  --warn-bg:   #fef3c7;  --warn-fg:   #92400e;
  --ok-bg:     #dcfce7;  --ok-fg:     #166534;
  --info-bg:   #dbeafe;  --info-fg:   #1e40af;
  --neutral-bg:#f3f4f6;  --neutral-fg:#374151;
  --memorial-bg: #ede2f1; --memorial-fg: #6a4a8a;
  --supporter-bg: #e3e9e7; --supporter-fg: #54635e;
  --guardian-bg: #d6e8d6; --guardian-fg: #234d23;
    --sisters-bg: #fce7f3; --sisters-fg: #9d174d; --sisters-accent: #b8895a;

  --shadow-1: 0 1px 2px rgba(10,30,26,0.05), 0 2px 6px rgba(10,30,26,0.04);
  --shadow-2: 0 2px 4px rgba(10,30,26,0.04), 0 8px 16px rgba(10,30,26,0.06), 0 20px 40px rgba(10,30,26,0.04);
  --shadow-3: 0 4px 8px rgba(10,30,26,0.05), 0 16px 32px rgba(10,30,26,0.08), 0 32px 64px rgba(10,30,26,0.06);
  --shadow-4: 0 8px 16px rgba(10,30,26,0.08), 0 24px 48px rgba(10,30,26,0.10), 0 48px 96px rgba(10,30,26,0.08);
  --shadow-5: 0 12px 24px rgba(10,30,26,0.10), 0 32px 64px rgba(10,30,26,0.14), 0 64px 128px rgba(10,30,26,0.10);
  --shadow-inset: inset 0 1px 0 rgba(255,255,255,0.7), inset 0 -1px 0 rgba(10,30,26,0.04);
  --shadow-inset-deep: inset 0 2px 6px rgba(10,30,26,0.08);
  --shadow-glow: 0 0 0 4px rgba(31,140,107,0.18), 0 0 24px rgba(31,140,107,0.25);
  --shadow-gold: 0 0 0 4px rgba(174,137,37,0.20), 0 0 24px rgba(174,137,37,0.25);
  --shadow-old-2: 0 4px 12px rgba(10,30,26,0.10), 0 16px 32px rgba(10,30,26,0.08);

  --bg-page: var(--surface);
  --bg-card: var(--white);
  --bg-elevated: var(--white);
  --bg-muted: #efeee7;
  --bg-header: rgba(255,255,255,0.78);
  --bg-hero: radial-gradient(ellipse at 30% 0%, #1f8c6b 0%, #155a48 45%, #0e3a2f 100%);
  /* v1.8.2.66w.371: this token's values were #e3ede0 → #d3e1cf, but the
     .bismillah-strip COMPONENT had its own hardcoded gradient
     (#e8f0e2 → #d4e3cf) and used that instead — so the token had
     never actually painted anything. Now that the component reads the
     token, align it to the values that were really rendering, so the
     emerald appearance stays pixel-identical on the default install. */
  --bg-bismillah: linear-gradient(180deg, #e8f0e2 0%, #d4e3cf 100%);
  --bg-bismillah-text: var(--green-900);

  --text-primary: var(--ink-900);
  --text-secondary: var(--ink-700);
  --text-muted: var(--ink-500);
  --text-on-hero: var(--white);
  /* Explicit per-theme label colour. White on a mid-green fill
     is only 4.18:1, and midnight needs DARK ink on its light teal.
     Assuming one of the two is exactly the bug that shipped. */
  --accent-text: var(--white);
  --border: var(--ink-100);
  --border-strong: var(--ink-300);
  --accent: var(--gold-500);
  --gold: var(--gold-700);
  --accent-strong: var(--gold-700);
  --gold-text: #92400e;
  --link: var(--green-700);
  --link-hover: var(--green-900);
  --header-shadow: 0 4px 16px rgba(10,30,26,0.06), 0 1px 0 rgba(10,30,26,0.04);
}

/* ══════════════════════════════════════════════════════════════════════
   2. MIDNIGHT QIBLA — contemplative night.
   Deep teal on near-black, muted antique gold. Designed for night-time
   salah use and OLED panels, so the page surface is genuinely dark
   rather than a light theme with inverted text.
   ══════════════════════════════════════════════════════════════════════ */
:root[data-theme="midnight"],
:root[data-theme="midnight-hc"] {
  --focus-ring: 2px solid var(--green-700);
  --green-900: #cfe9e6;
  --green-700: #7fc9c4;
  --green-500: #3fa8a3;
  --green-300: #1d7a77;
  --green-100: #0d3b3a;
  --gold-700: #f0e2bd;
  --gold-500: #d9b978;
  --gold-300: #b8934f;
  --gold-100: #5a4520;
  --ink-900: #eef4f4;
  --ink-700: #c3d3d3;
  --ink-500: #93a8a9;
  --ink-300: #5a7071;
  --ink-100: #1b2628;
  --surface: #0c1416;
  --white: #141e21;

  --danger: #e07b6f; --on-danger: #10191b; --on-fill: #0c1416;
  --warn: #e8c068;
  --ok: #5fc9c4;
  --danger-bg: #3f1d1d;  --danger-fg: #fca5a5;
  --warn-bg:   #3f2f10;  --warn-fg:   #fcd34d;
  --ok-bg:     #0d3336;  --ok-fg:     #7fd8d2;
  --info-bg:   #102a4a;  --info-fg:   #93c5fd;
  --neutral-bg:#1a2427;  --neutral-fg:#c3d3d3;
  --memorial-bg: #2e2140; --memorial-fg: #d6b8f0;
  --supporter-bg: #232d2f; --supporter-fg: #c3d3d3;
  --guardian-bg: #16301f; --guardian-fg: #8fd6a8;
  --sisters-bg: #3a1025; --sisters-fg: #f9a8d4; --sisters-accent: #d4a574;

  --shadow-1: 0 1px 2px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.25);
  --shadow-2: 0 4px 12px rgba(0,0,0,0.5), 0 16px 32px rgba(0,0,0,0.35);
  --shadow-3: 0 8px 16px rgba(0,0,0,0.5), 0 24px 48px rgba(0,0,0,0.4);
  --shadow-4: 0 10px 20px rgba(0,0,0,0.55), 0 28px 56px rgba(0,0,0,0.45);
  --shadow-5: 0 14px 28px rgba(0,0,0,0.6), 0 36px 72px rgba(0,0,0,0.5);
  --shadow-inset: inset 0 1px 0 rgba(255,255,255,0.04), inset 0 -1px 0 rgba(0,0,0,0.4);
  --shadow-inset-deep: inset 0 2px 6px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 0 4px rgba(127,201,196,0.25), 0 0 24px rgba(127,201,196,0.3);
  --shadow-gold: 0 0 0 4px rgba(217,185,120,0.22), 0 0 24px rgba(217,185,120,0.28);

  --bg-page: var(--surface);
  --bg-card: var(--white);
  --bg-elevated: #1a2427;
  --bg-muted: #101a1c;
  --bg-header: rgba(20,30,33,0.82);
  --bg-hero: radial-gradient(ellipse at 30% 0%, #0d3b3a 0%, #0a2426 45%, #050d0e 100%);
  --bg-bismillah: linear-gradient(180deg, #16292b 0%, #101d1f 100%);
  --bg-bismillah-text: var(--gold-300);

  --text-primary: var(--ink-900);
  --text-secondary: var(--ink-700);
  --text-muted: var(--ink-500);
  --text-on-hero: var(--white);
  /* MUST be dark: the teal fill is LIGHT (9.81:1 with this ink,
     1.71:1 with the light ink — see the header note). */
  --accent-text: #0c1416;
  --border: var(--ink-100);
  --border-strong: var(--ink-300);
  --accent: var(--gold-500);
  --gold: var(--gold-700);
  --accent-strong: var(--gold-300);
  --gold-text: #d9b978;
  --link: var(--green-700);
  --link-hover: var(--green-300);
  --header-shadow: 0 1px 0 #1b2628, 0 8px 24px rgba(0,0,0,0.4);
}

/* ══════════════════════════════════════════════════════════════════════
   3. DESERT SAND — warm earthen.
   Clay, bronze and sand. Reads as architecture rather than finance;
   the warmest of the three, closest to traditional mashrabiya and
   mud-brick.
   ══════════════════════════════════════════════════════════════════════ */
:root[data-theme="sand"],
:root[data-theme="sand-hc"] {
  --focus-ring: 2px solid var(--green-700);
  --green-900: #3a2a1c;
  --green-700: #6b4c2f;
  --green-500: #a9714b;
  --green-300: #c99a6e;
  --green-100: #f0e2d2;
  --gold-700: #6d5420;
  --gold-500: #b5873d;   /* re-solved for 3:1; hue-locked to bronze */
  --gold-300: #d9bd7e;
  --gold-100: #f6ecd4;
  --ink-900: #2b2018;
  --ink-700: #4a3a2c;
  --ink-500: #6f5c49;
  --ink-300: #a2917c;
  --ink-100: #e8ded0;
  --surface: #faf6ef;
  --white: #fffdf9;

  --danger: #a8382b; --on-danger: #ffffff; --on-fill: #ffffff;
  --warn: #9a6b12;
  --ok: #6b7c3a;
  --danger-bg: #fbe4e0;  --danger-fg: #8f2a1f;
  --warn-bg:   #fbf0d4;  --warn-fg:   #6d4c0c;
  --ok-bg:     #e8eeda;  --ok-fg:     #4c5a26;
  --info-bg:   #e2ecf5;  --info-fg:   #1c4670;
  --neutral-bg:#f0eae0;  --neutral-fg:#4a3a2c;
  --memorial-bg: #f0e4f2; --memorial-fg: #6b3f80;
  --supporter-bg: #ece4d8; --supporter-fg: #4a3a2c;
  --guardian-bg: #e6ecd8; --guardian-fg: #3d4a1c;
  --sisters-bg: #f9e6ec; --sisters-fg: #8c2f52; --sisters-accent: #b07a52;

  --shadow-1: 0 1px 2px rgba(43,32,24,0.06), 0 2px 6px rgba(43,32,24,0.05);
  --shadow-2: 0 2px 4px rgba(43,32,24,0.05), 0 8px 16px rgba(43,32,24,0.07), 0 20px 40px rgba(43,32,24,0.05);
  --shadow-3: 0 4px 8px rgba(43,32,24,0.06), 0 16px 32px rgba(43,32,24,0.09), 0 32px 64px rgba(43,32,24,0.06);
  --shadow-4: 0 8px 16px rgba(43,32,24,0.09), 0 24px 48px rgba(43,32,24,0.11), 0 48px 96px rgba(43,32,24,0.08);
  --shadow-5: 0 12px 24px rgba(43,32,24,0.10), 0 32px 64px rgba(43,32,24,0.14), 0 64px 128px rgba(43,32,24,0.10);
  --shadow-inset: inset 0 1px 0 rgba(255,255,255,0.8), inset 0 -1px 0 rgba(43,32,24,0.05);
  --shadow-inset-deep: inset 0 2px 6px rgba(43,32,24,0.09);
  --shadow-glow: 0 0 0 4px rgba(169,113,75,0.2), 0 0 24px rgba(169,113,75,0.26);
  --shadow-gold: 0 0 0 4px rgba(181,135,61,0.22), 0 0 24px rgba(181,135,61,0.28);

  --bg-page: var(--surface);
  --bg-card: var(--white);
  --bg-elevated: var(--white);
  --bg-muted: #f2ece1;
  --bg-header: rgba(255,253,249,0.8);
  --bg-hero: radial-gradient(ellipse at 30% 0%, #b5873d 0%, #8a5f38 45%, #3a2a1c 100%);
  --bg-bismillah: linear-gradient(180deg, #f4e9d6 0%, #ecdfc8 100%);
  --bg-bismillah-text: var(--green-900);

  --text-primary: var(--ink-900);
  --text-secondary: var(--ink-700);
  --text-muted: var(--ink-500);
  --text-on-hero: var(--white);
  --accent-text: var(--white);
  --border: var(--ink-100);
  --border-strong: var(--ink-300);
  --accent: var(--gold-500);
  --gold: var(--gold-700);
  --accent-strong: var(--gold-700);
  --gold-text: #6d5420;
  --link: var(--green-700);
  --link-hover: var(--green-900);
  --header-shadow: 0 4px 16px rgba(43,32,24,0.07), 0 1px 0 rgba(43,32,24,0.05);
}

/* ══════════════════════════════════════════════════════════════════════
   4. HIGH-CONTRAST MODIFIER — the accessibility axis.
   Applied on top of a brand. Pure black/white, borders thickened,
   shadows removed, focus rings unmissable. Every combination is
   resolved below by re-declaring the same structural tokens, so
   `emerald-hc` / `midnight-hc` / `sand-hc` all behave identically
   regardless of which brand they sit on.
   ══════════════════════════════════════════════════════════════════════ */
:root[data-theme$="-hc"] {
  /* Kill ambient shadows — on a high-contrast surface they read as
     smudges rather than depth. */
  --shadow-1: none;
  --shadow-2: none;
  --shadow-3: none;
  --shadow-4: none;
  --shadow-5: none;
  --shadow-inset: none;
  --shadow-inset-deep: none;

  /* Borders become structural, not decorative. */
  --border: #000000;
  --border-strong: #000000;

  --text-muted: var(--text-secondary);
  --link-hover: var(--text-primary);
  --accent-text: #000000;

  /* Focus must be unmissable for keyboard users. */
  --focus-ring: 3px solid #ffbf47;
  --focus-ring-offset: 2px;
}

/* ── Legacy alias mapping ───────────────────────────────────────────────
   Visitors who already chose a theme keep the look they picked:
     light (or unset) → emerald      dark → midnight      hc → emerald-hc
   No redirect, no flash — the alias resolves in CSS, so a stale
   localStorage value still renders correctly. */
:root[data-theme="light"],
:root[data-theme="light-hc"] {
  --green-900: #0e3a2f; --green-700: #155a48; --green-500: #1f8c6b;
  --green-300: #5fb89b; --green-100: #d5ebe1;
  --gold-700: #8a6d24; --gold-500: #ae8925; --gold-300: #e4c879; --gold-100: #f8edcd;
  --ink-900: #0a1e1a; --ink-700: #2c3a36; --ink-500: #54635e;
  --ink-300: #93a39e; --ink-100: #e3e9e7;
  --surface: #f6f5ee; --white: #ffffff;
}
:root[data-theme="dark"] {
  --green-900: #cfe9e6; --green-700: #7fc9c4; --green-500: #3fa8a3;
  --green-300: #1d7a77; --green-100: #0d3b3a;
  --gold-700: #f0e2bd; --gold-500: #d9b978; --gold-300: #b8934f; --gold-100: #5a4520;
  --ink-900: #eef4f4; --ink-700: #c3d3d3; --ink-500: #93a8a9;
  --ink-300: #5a7071; --ink-100: #1b2628;
  --surface: #0c1416; --white: #141e21;
  --bg-page: var(--surface); --bg-card: var(--white);
  --bg-muted: #101a1c; --bg-elevated: #1a2427;
  --bg-header: rgba(20,30,33,0.82);
  --bg-hero: radial-gradient(ellipse at 30% 0%, #0d3b3a 0%, #0a2426 45%, #050d0e 100%);
  --bg-bismillah: linear-gradient(180deg, #16292b 0%, #101d1f 100%);
  --bg-bismillah-text: var(--gold-300);
  --accent-text: #0c1416;
  --gold-text: #d9b978;
  --border: #1b2628; --border-strong: #5a7071;
  --accent: var(--gold-500); --gold: var(--gold-700); --accent-strong: var(--gold-300);
  --link: var(--green-700); --link-hover: var(--green-300);
}

/* ══════════════════════════════════════════════════════════════════════
   5. TOKENISED HIGH-VISIBILITY SURFACES
   ───────────────────────────────────────────────────────────────────────
   Everything below is a COMPONENT rule, not a palette rule — it points
   existing hardcoded hexes at the variables above, so these specific
   surfaces follow the chosen theme. Scoped to the surfaces a visitor
   sees on every page (the "option 1" tokenisation scope).
   ══════════════════════════════════════════════════════════════════════ */

/* Respect the OS reduced-motion setting across every themed surface. */
@media (prefers-reduced-motion: reduce) {
  :root[data-theme] *,
  :root[data-theme] *::before,
  :root[data-theme] *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Focus ring — one definition, themed, and never removed. */
:root[data-theme] :focus-visible {
  outline: var(--focus-ring, 2px solid var(--green-500));
  outline-offset: var(--focus-ring-offset, 2px);
  border-radius: 4px;
}
:root[data-theme$="-hc"] :focus-visible {
  outline: 3px solid #ffbf47;
  outline-offset: 2px;
}

/* Primary action buttons: the label colour must come from the theme,
   because white is correct on emerald/sand and wrong on midnight. */
:root[data-theme] .btn-primary,
:root[data-theme] button.btn-primary,
:root[data-theme] .btn-primary:not(:disabled) {
  color: var(--accent-text);
}

/* Status badges follow the per-theme tone pairs. */
:root[data-theme] .badge-danger { background: var(--danger-bg); color: var(--danger-fg); }
:root[data-theme] .badge-warn   { background: var(--warn-bg);   color: var(--warn-fg); }
:root[data-theme] .badge-ok     { background: var(--ok-bg);     color: var(--ok-fg); }
:root[data-theme] .badge-info   { background: var(--info-bg);   color: var(--info-fg); }
:root[data-theme] .badge-neutral{ background: var(--neutral-bg);color: var(--neutral-fg); }

/* Prayer-plot map. These are tappable cells selected one-handed on a
   phone — the 44x44 floor is a WCAG 2.2 target-size requirement, and the
   plot grid is the single most-touched surface in the app.

   The class is `.plot`, NOT `.plot-cell` (an earlier draft of this rule
   used `.plot-cell`, which matches nothing — the cells carry `.plot`
   plus state modifiers `.selected` / `.sold` / `.reserved` / `.dimmed`).

   MapView.tsx also sets `width`/`height` INLINE from
   `cellSize = CELL_BASE(38) * zoom`. A plain `width` rule would lose to
   that inline style, but `min-width`/`min-height` are SEPARATE
   properties: per CSS sizing, min-* clamps the used value regardless of
   where width came from. So `min-width: 44px` floors a 38px inline cell
   up to 44px without touching React. That is why this rule uses min-*
   and not width/height.

   Cells stay interactive and focusable — the floor is cosmetic-plus-
   hit-area, it does not disable the button. */
/*  v1.8.2.66w.371 — REVERTED. This rule previously forced
 *  min-width/min-height: 44px on every plot cell to satisfy a 44px
 *  touch-target floor. It BROKE the map.
 *
 *  The grid is laid out as `repeat(36, cellSize)` where
 *  cellSize = CELL_BASE(38) * zoom. A 44px min-width does not resize
 *  the grid track — the cell overflows its 38px column and collides
 *  with its neighbours, which clipped the plot numbers ("142" → "14:")
 *  and destroyed the arch shape. It also fought the user's own Zoom
 *  control: at 65% zoom the cells were being forced LARGER than the
 *  slider asked for.
 *
 *  The map already ships a zoom slider, and that is the correct
 *  accessibility affordance here: a finger can enlarge the cells
 *  deliberately, rather than the layout being silently inflated for
 *  everyone. The 44px rule has been removed rather than tuned, because
 *  ANY non-zero floor conflicts with a user-controlled cell size.
 */

/* ── Theme picker (admin + public Look selector) ─────────────────────── */
.theme-swatch-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.theme-swatch {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px;
  min-width: 132px;
  min-height: 44px;          /* touch target floor */
  cursor: pointer;
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-sm, 10px);
  transition: border-color 0.15s cubic-bezier(0.16,1,0.3,1),
              box-shadow 0.15s cubic-bezier(0.16,1,0.3,1);
}
.theme-swatch:hover {
  border-color: var(--border-strong);
  /* colour/opacity only — never a scale transform, which would shift
     neighbouring swatches out of alignment (see the skill's
     anti-pattern list). */
  box-shadow: var(--shadow-2);
}
.theme-swatch[aria-checked="true"],
.theme-swatch[data-selected="true"] {
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px var(--shadow-glow);
}
.theme-swatch:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.theme-swatch-preview {
  display: flex;
  width: 100%;
  height: 52px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.12);
}
.theme-swatch-preview .ts-surface { flex: 1; }
.theme-swatch-preview .ts-primary { width: 26%; }
.theme-swatch-preview .ts-accent  { width: 18%; }
.theme-swatch-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  line-height: 1.3;
}
.theme-swatch-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.3;
}
/* ══════════════════════════════════════════════════════════════════════
   6. HEADER THEME SWITCHER (v2, two rows)
   ───────────────────────────────────────────────────────────────────────
   Touch-target note: the inherited header triggers are 36×36, which
   matches each other but sits under the 44×44 floor the UI skill
   ranks CRITICAL. Rather than make the theme switcher look out of
   place on desktop, we bump it on COARSE POINTERS ONLY — the
   (pointer: coarse) query means "touch device", so this is exactly
   where the larger target helps and where the extra 16px of header
   width is affordable (it stacks to its own row).

   The honest caveat: every other header trigger is still 36×36. A
   real fix is a header-WIDE touch-target pass, not a one-off here.
   Tracked rather than silently half-done.
   ══════════════════════════════════════════════════════════════════════ */
.lhic-theme-switcher--v2 {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  align-items: stretch;
}
.lhic-theme-switcher--v2 .lhic-theme-row {
  display: inline-flex;
  gap: 0.2rem;
  align-items: center;
  justify-content: center;
}
/* Contrast row is visually subordinate — it's a modifier of the Look,
   not a peer. Lower contrast border so the two rows read as one
   control with a primary axis. */
.lhic-theme-switcher--v2 .lhic-theme-row:last-child button {
  font-size: 12px;
  font-weight: 600;
  border-style: dashed;
}
.lhic-theme-switcher--v2 button {
  background: transparent;
  border: 1px solid var(--border);
  width: 36px; height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: var(--text-muted);
  transition: background-color 0.15s var(--ease-out, ease),
              border-color 0.15s var(--ease-out, ease),
              color 0.15s var(--ease-out, ease);
}
.lhic-theme-switcher--v2 button:hover {
  border-color: var(--border-strong);
  color: var(--text-primary);
  background: var(--bg-muted);
}
.lhic-theme-switcher--v2 button[aria-pressed="true"] {
  background: var(--green-100);
  border-color: var(--green-500);
  color: var(--green-900);
}
/* Midnight has an inverted ramp (green-100 is the DARK end there), so
   the pressed state above would put dark text on a dark fill. The
   tokens handle it — this is just belt-and-braces for hc. */
:root[data-theme$="-hc"] .lhic-theme-switcher--v2 button[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--text-primary);
  color: var(--accent-text);
}

@media (pointer: coarse) {
  .lhic-theme-switcher--v2 button {
    width: 44px;   /* WCAG 2.2 target-size floor */
    height: 40px;
  }
}

/* On very narrow phones the header runs out of room; let the switcher
   take its own full-width row instead of squeezing the nav. */
@media (max-width: 560px) {
  .lhic-theme-switcher--v2 {
    flex-direction: row;
    align-items: center;
    width: 100%;
    justify-content: center;
    margin-top: 0.4rem;
  }
  .lhic-theme-switcher--v2 .lhic-theme-row:last-child {
    margin-left: 0.5rem;
  }
}

/* ── PRAYER-PLOT STATUS COLOURS (fixed, NOT themed) ───────────────────
 *
 * The legend reads "252 avail / 44 res / 3 sold" with coloured dots,
 * and the zone names ("Men — front", "Ladies — back") are printed with
 * their own swatches. Those colours are a DATA LEGEND the reader
 * matches cells against — the same reason the zone colours live in
 * masjid_prayplot.json as literal hex, not tokens.
 *
 * 66w.331.7 already established this for the cell INK ("the zone
 * colours come from masjid_prayplot.json and do NOT invert with the
 * theme"), but sold/reserved still resolved through theme tokens
 * (--warn, --border-strong), so they drifted per theme while the zone
 * colours did not — and on midnight a "sold" cell turned dark grey
 * against a dark page.
 *
 * Declared identically in every theme block on purpose. Same value,
 * every theme: that is the point.
 */
:root {
  --plot-available: #1f8c6b;
  --plot-reserved:  #b8860b;
  --plot-sold:      #6b7280;
}
:root[data-theme] {
  /* identical in every theme, deliberately */
  --plot-available: #1f8c6b;
  --plot-reserved:  #b8860b;
  --plot-sold:      #6b7280;
}

/* Selection ring is a UI state, not a palette colour — kept at the
 * fixed gold it has always used so "selected" reads identically in
 * every theme. */
.plot.selected {
  border-color: #facc15 !important;
  box-shadow: 0 0 0 3px #facc15, 0 0 16px rgba(250, 204, 21, 0.6), 0 4px 12px rgba(250, 204, 21, 0.3);
}
.plot:focus-visible {
  outline: 3px solid #0e3a2f;
  outline-offset: 1px;
  z-index: 2;
}

/* ══════════════════════════════════════════════════════════════════════
   7. ALIASES FOR TOKENS THAT WERE REFERENCED BUT NEVER DEFINED
   ───────────────────────────────────────────────────────────────────────
   The CSS used `var(--surface-2, #f7f7f7)`-style fallbacks for 21
   token names. Because none of them were ever DEFINED, the literal
   fallback was what actually rendered — in every theme. That is why
   the coverage report read 78% and why ~132 declarations could not
   follow the theme no matter what we did to the palette.

   Defining them here retires every one of those fallbacks at once,
   with no edits to the 132 call sites: `var(--surface-2, #f7f7f7)`
   now resolves the token and ignores the literal.

   These are ALIASES onto tokens that already exist and are already
   contrast-verified — no new colours are introduced, so nothing here
   can regress the WCAG checks.
   ══════════════════════════════════════════════════════════════════════ */
:root,
:root[data-theme] {
  /* a Tailwind-ish "brand" ramp the older CSS assumed existed */
  --brand-50:  var(--green-100);
  --brand-200: var(--green-300);
  --brand-500: var(--green-500);
  --brand-700: var(--green-700);
  --brand-900: var(--green-900);

  /* extra steps on ramps we already have */
  --green-50:  var(--green-100);
  --green-200: var(--green-300);
  --green-800: var(--green-900);
  --gold-50:   var(--gold-100);
  --ink-400:   var(--ink-300);
  --ink-600:   var(--ink-500);
  --ink-800:   var(--ink-700);

  /* surface / text aliases */
  --surface-2: var(--bg-muted);
  --bg:        var(--surface);
  --success:   var(--ok);
  --success-bg: var(--ok-bg);
  --success-fg: var(--ok-fg);

  /* a second "component" naming scheme used by the admin + modal CSS */
  --c-card:       var(--bg-card);
  --c-bg-soft:    var(--bg-muted);
  --c-text:       var(--text-primary);
  --c-text-muted: var(--text-muted);
  --c-border:     var(--border);
  --c-border-soft: var(--border);
  --c-primary:    var(--green-700);
  --c-primary-d:  var(--green-900);
}
