/* ===== AQMAR — design tokens + helpers (lift to webui/styles.css) ===== */

:root {
  /* Dark-forest palette: deep green ground, gold brand. The SPA ships in
     dark mode only — index.html hardcodes data-theme="dark" and there is no
     theme toggle, so these are the single source of truth. (The earlier
     light/earth palette was removed 2026-05-20 — it never rendered.) */
  --bg:        #0c1f0c;
  --bg-2:      #0f2510;
  --bg-3:      #142914;
  --paper:     #142914;
  --ink:       #fbf8f1;
  --ink-2:     #e7decb;
  --muted:     #9bbf94;
  --faint:     #5a7a5a;
  --divider:   #2d4a2d;
  /* --forest is the gold brand color so badge-forest, btn-primary,
     section-kickers, etc. all read as the warm accent. */
  --forest:    #fbbf24;
  --forest-2:  #d4a020;
  --olive:     #b8924a;
  --olive-2:   #d4a865;
  --gold:      #fbbf24;
  --crimson:   #ea4444;
  /* AI verification track (2026-06-10) — teal, distinct from the human
     gold/forest so the two verification dimensions never visually blur. */
  /* Statistics series palette (2026-08-31). Five categorical hues used by
     the stats designs for brigades. Validated with the data-viz colour
     checks against this site's dark surfaces (#142914 paper and #0c1f0c
     ground): every adjacent pair clears the colour-blind separation floor
     and all five clear 3:1 contrast. Re-validate before swapping a hue. */
  --stat-1:    #3987e5;
  --stat-2:    #d95926;
  --stat-3:    #199e70;
  --stat-4:    #c98500;
  --stat-5:    #d55181;
  --ai:        #4cc3b0;
  --ai-dim:    rgba(76, 195, 176, 0.12);

  /* Global-events accents on the lifespan line (2026-07-22): translucent
     gold for event-period bands + age pills, translucent olive for the
     "ongoing" tag. */
  --gold-dim:    rgba(251, 191, 36, 0.12);
  --gold-dim-2:  rgba(251, 191, 36, 0.24);
  --olive-dim:   rgba(184, 146, 74, 0.12);
  --olive-dim-2: rgba(184, 146, 74, 0.30);

  --font-display: "El Messiri", "Amiri", serif;
  --font-naskh:   "Amiri", serif;
  --font-body:    "IBM Plex Sans Arabic", system-ui, sans-serif;
  --font-latin-sans: "IBM Plex Sans", system-ui, sans-serif;
  --font-latin-serif: "IBM Plex Sans", "Amiri", serif;

  /* Fluid type scale — each step interpolates between a mobile min and a
     desktop max, so text resizes smoothly with the viewport (no breakpoints). */
  --text-xs:   clamp(0.72rem, 0.69rem + 0.15vw, 0.80rem);
  --text-sm:   clamp(0.80rem, 0.76rem + 0.20vw, 0.92rem);
  --text-base: clamp(0.94rem, 0.89rem + 0.25vw, 1.06rem);
  --text-lg:   clamp(1.05rem, 0.97rem + 0.40vw, 1.30rem);
  --text-xl:   clamp(1.25rem, 1.08rem + 0.85vw, 1.75rem);
  --text-2xl:  clamp(1.55rem, 1.20rem + 1.70vw, 2.55rem);
  --text-hero: clamp(2.60rem, 1.55rem + 5.20vw, 5.25rem);
}

/* When dark theme is active, the paper-grain pattern needs lighter dots
   so the texture stays visible against the near-black ground. */
html[data-theme="dark"] body::before {
  background-image:
    radial-gradient(rgba(155,191,148,0.04) 1px, transparent 1px),
    radial-gradient(rgba(155,191,148,0.03) 1px, transparent 1px);
  mix-blend-mode: screen;
  opacity: 0.5;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}
html[lang="en"] body { direction: ltr; }
::selection { background: var(--forest); color: var(--paper); }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--forest); outline-offset: 3px; border-radius: 4px; }

/* Paper grain */
body::before {
  content: "";
  position: fixed; inset: 0;
  background-image:
    radial-gradient(rgba(120,90,50,0.025) 1px, transparent 1px),
    radial-gradient(rgba(120,90,50,0.018) 1px, transparent 1px);
  background-size: 3px 3px, 7px 7px;
  background-position: 0 0, 1px 2px;
  pointer-events: none;
  z-index: 0;
  mix-blend-mode: multiply;
}
html[data-theme="dark"] body::before { mix-blend-mode: screen; opacity: 0.4; }

#root { position: relative; z-index: 1; min-height: 100vh; }

/* Type utilities */
.font-display { font-family: var(--font-display); }
.font-naskh   { font-family: var(--font-naskh); }
.font-body    { font-family: var(--font-body); }
.font-latin-sans  { font-family: var(--font-latin-sans); }
.font-latin-serif { font-family: var(--font-latin-serif); }

/* Color utilities */
.bg-paper     { background: var(--paper); }
.bg-page-2    { background: var(--bg-2); }
.bg-page-3    { background: var(--bg-3); }
.bg-forest    { background: var(--forest); }
.text-ink     { color: var(--ink); }
.text-ink-2   { color: var(--ink-2); }
.text-muted   { color: var(--muted); }
.text-faint   { color: var(--faint); }
.text-forest  { color: var(--forest); }
.text-olive   { color: var(--olive); }
.text-paper   { color: var(--paper); }
.border-divider { border-color: var(--divider); }
.bg-forest-grad { background: linear-gradient(110deg, var(--forest) 0%, var(--forest-2) 100%); }

/* Ornaments */
.ornament-row {
  display: flex; align-items: center; justify-content: center; gap: 14px;
}
.ornament-row::before, .ornament-row::after {
  content: ""; flex: 1; height: 1px;
  background: linear-gradient(to left, transparent, var(--divider) 30%, var(--divider) 70%, transparent);
}
.ornament-star {
  width: 12px; height: 12px;
  background: var(--olive);
  clip-path: polygon(50% 0%, 61% 39%, 100% 50%, 61% 61%, 50% 100%, 39% 61%, 0% 50%, 39% 39%);
  opacity: 0.7;
}

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  font-family: var(--font-display);
  font-size: 15px; font-weight: 500;
  border: 1px solid transparent;
  transition: all .15s ease;
  white-space: nowrap;
  line-height: 1;
}
.btn-primary {
  background: var(--forest); color: var(--paper);
  border-color: var(--forest);
}
.btn-primary:hover { background: var(--forest-2); }
.btn-ghost {
  background: transparent; color: var(--ink);
  border-color: var(--divider);
}
.btn-ghost:hover { background: var(--bg-3); }
.btn-text {
  background: transparent; color: var(--muted);
  padding: 6px 0;
  border-radius: 0;
}
.btn-text:hover { color: var(--ink); }

/* Form inputs */
.input, .select, textarea.input {
  width: 100%;
  padding: 10px 14px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--divider);
  border-radius: 4px;
  outline: none;
}
.select {
  appearance: none;
  padding-inline-end: 32px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
.field-label {
  font-family: var(--font-body);
  font-size: var(--text-xs); font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
  letter-spacing: 0;
}

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  background: var(--bg-3);
  color: var(--ink-2);
  border-radius: 999px;
  font-size: 12px; font-weight: 500;
}
.badge-forest  { background: rgba(31,61,43,0.10);   color: var(--forest); }
.badge-olive   { background: rgba(138,109,59,0.13); color: var(--olive); }

/* Cards */
.card {
  background: var(--paper);
  border: 1px solid var(--divider);
  border-radius: 6px;
}
.card-hover {
  transition: all .2s ease;
  box-shadow: 0 1px 0 rgba(0,0,0,0.02);
}
.card-hover:hover {
  transform: translateY(-2px);
  border-color: var(--olive);
  box-shadow: 0 16px 30px -22px rgba(40,30,15,0.4);
}

/* ===== Admin edit — image carousel =====
   Replaces the old 220px portrait + 3-col OCR-frames thumbnail strip with a
   single big stage that cycles through the portrait + every OCR frame for the
   row. Arrows + thumbstrip control it; the big image is clickable for max-
   screen zoom (re-uses the photoZoomed modal, now bound to carouselCurrent). */
.edit-carousel-stage {
  position: relative;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--divider);
  min-height: 460px;
  display: flex; align-items: center; justify-content: center;
}
.edit-carousel-stage img {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  display: block;
  cursor: zoom-in;
}
.edit-carousel-arrow {
  /* Nudged ~2cm below vertical-centre so the prev/next buttons no longer cover
     the birth date printed on the OCR poster/frame — the admin reads the date
     off this image, and centred arrows sat on top of it. */
  position: absolute; top: 70%; transform: translateY(calc(-80% + 2cm));
  width: 44px; height: 44px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 999px;
  font-size: 22px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background .15s ease;
  z-index: 2;
}
.edit-carousel-arrow:hover { background: rgba(0,0,0,0.78); }
.edit-carousel-arrow.prev { inset-inline-start: 12px; }
.edit-carousel-arrow.next { inset-inline-end: 12px; }
.edit-carousel-counter {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.55);
  color: rgba(255,255,255,0.95);
  font-family: var(--font-latin-sans);
  font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px;
  backdrop-filter: blur(6px);
  letter-spacing: 0.05em;
  z-index: 2;
}
.edit-carousel-kind {
  position: absolute; top: 10px; inset-inline-start: 10px;
  background: rgba(31,61,43,0.85);
  color: var(--forest);
  font-family: var(--font-display);
  font-size: 10px;
  padding: 3px 9px; border-radius: 999px;
  letter-spacing: 0.18em; text-transform: uppercase;
  backdrop-filter: blur(6px);
  z-index: 2;
}
.edit-carousel-thumbs {
  margin-top: 10px;
  display: grid; gap: 6px;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
}
.edit-carousel-thumb {
  position: relative;
  aspect-ratio: 4/3;
  background: var(--bg-3);
  border-radius: 5px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color .12s ease;
  padding: 0;
}
.edit-carousel-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.edit-carousel-thumb:hover { border-color: var(--olive); }
.edit-carousel-thumb.active { border-color: var(--forest); }
/* ★ badge on the thumbnail that matches dbo.martyrs.featured_frame_path —
   tells admin "this is what's stored in the DB right now". Sits in the
   top-end corner so it doesn't overlap the active-border thick edge. */
.edit-carousel-thumb-saved {
  position: absolute; top: 2px; inset-inline-end: 2px;
  width: 16px; height: 16px;
  background: var(--forest);
  color: var(--paper);
  border-radius: 999px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; line-height: 1;
  font-weight: 700;
  z-index: 1;
}
/* Status strip directly under the stage. Color reflects the cover-image
   state: forest gold = saved/will-save (good), olive = needs action. */
.edit-carousel-status {
  margin-top: 8px;
  font-family: var(--font-body);
  font-size: 12px;
  padding: 7px 10px;
  border-radius: 4px;
  text-align: center;
}
.edit-carousel-status.is-good {
  background: rgba(251,191,36,0.08);
  color: var(--forest);
  border: 1px solid rgba(251,191,36,0.25);
}
.edit-carousel-status.needs-action {
  background: rgba(184,146,74,0.10);
  color: var(--olive);
  border: 1px solid rgba(184,146,74,0.3);
}
@media (max-width: 1024px) {
  .edit-carousel-stage { min-height: 320px; }
}

/* Portrait placeholder (monogram) */
.portrait {
  position: relative;
  border-radius: 3px;
  overflow: hidden;
  background: linear-gradient(160deg, #cfd9c8 0%, #94ae93 60%, var(--forest-2) 100%);
  box-shadow:
    0 0 0 1px var(--divider),
    0 0 0 5px var(--paper),
    0 0 0 6px var(--divider),
    0 12px 24px -16px rgba(40,30,15,0.35);
  flex-shrink: 0;
}
.portrait.tone-olive {
  background: linear-gradient(160deg, #e8dcc0 0%, #c9b48a 70%, var(--olive-2) 100%);
}
.portrait.naked { box-shadow: none; }
.portrait img {
  width: 100%; height: 100%; object-fit: cover;
  display: block;
}
.portrait .silhouette { position: absolute; inset: 0; opacity: .18; }
.portrait .corner { position: absolute; width: 8px; height: 8px; }
.portrait .corner.tl { top:4px; left:4px; border-top:1px solid rgba(255,255,255,.5); border-left:1px solid rgba(255,255,255,.5); }
.portrait .corner.tr { top:4px; right:4px; border-top:1px solid rgba(255,255,255,.5); border-right:1px solid rgba(255,255,255,.5); }
.portrait .corner.bl { bottom:4px; left:4px; border-bottom:1px solid rgba(255,255,255,.5); border-left:1px solid rgba(255,255,255,.5); }
.portrait .corner.br { bottom:4px; right:4px; border-bottom:1px solid rgba(255,255,255,.5); border-right:1px solid rgba(255,255,255,.5); }

/* Section header */
.section-kicker {
  font-family: var(--font-body);
  font-size: var(--text-xs); font-weight: 500;
  letter-spacing: 0.18em;
  color: var(--olive);
  text-transform: uppercase;
  margin-bottom: 10px;
}
.h1-display {
  font-size: var(--text-hero);
}
.section-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl); font-weight: 500;
  color: var(--ink);
  margin: 0; line-height: 1.15;
}
.section-sub {
  font-family: var(--font-body);
  font-size: var(--text-base); color: var(--muted);
  margin-top: 10px;
  max-width: 560px;
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--faint); border-radius: 999px; border: 2px solid var(--bg); }

/* Grid layouts — defaults live here so the media queries below can override
   them without !important (the defaults used to be inline styles in the HTML). */
.grid-bday       { grid-template-columns: 1.4fr 1.2fr auto; align-items: end; }
/* Two actions share the submit cell now - the birthday search and the
   one-click registry. Wrapping lets them stack rather than squeeze when the
   cell narrows; at <=768px the cell already spans the full row. */
.grid-bday-submit { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.stats-strip {
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--divider);
  border-bottom: 1px solid var(--divider);
}
.grid-filters    { grid-template-columns: 1.4fr 1fr 1fr 1fr 1fr auto; align-items: end; }
.grid-detail     { grid-template-columns: 200px 1fr; }
/* Detail hero (2026-07-23, layout B): the swappable media pair on one side,
   the identity on the other. The media column is capped at the slot's own
   max-width so the identity keeps the remaining space; minmax(0,…) lets a
   long Arabic name wrap instead of forcing the grid wider.
   Three direct children — .hero-media, .tg-watch, .hero-identity — placed by
   CSS rather than source order, so the Telegram button can sit under the
   identity on desktop and under the picture on mobile without duplicating it
   in the markup. Gaps are set here (not Tailwind's gap-10) because the row
   gap wants to be much tighter than the column gap. */
.detail-hero {
  grid-template-columns: minmax(0, 380px) minmax(0, 1fr);
  column-gap: 40px;
  row-gap: 14px;
}
/* The picture spans both rows; the identity and the button stack beside it,
   so the button no longer adds its height to the media column. */
.detail-hero > .hero-media    { grid-column: 1; grid-row: 1 / span 2; }
.detail-hero > .hero-identity { grid-column: 2; grid-row: 1; }
.detail-hero > .tg-watch      { grid-column: 2; grid-row: 2; align-self: start; }
/* Admin edit panel: image carousel on the right (first column in RTL), form on
   the left. 2fr/3fr = ~40%/60% — picked over 50/50 and 60/40 by the user
   2026-05-25 because it gives a big carousel image without cramping the
   9 optional form fields. align-items: start prevents the form's natural
   height from stretching the image column and leaving black letterbox space. */
.grid-detail.is-admin { grid-template-columns: 2fr 3fr; align-items: start; }
.dates-strip {
  grid-template-columns: 1fr 1fr 1fr;
  border-top: 1px solid var(--divider);
  border-bottom: 1px solid var(--divider);
}
/* Cell separators live here (not inline) so the wrap breakpoints below can
   restyle them — copies the .ai-stats-strip pattern. */
.dates-strip > div { border-inline-start: 1px solid var(--divider); }
.dates-strip > div:first-child { border-inline-start: none; }
.grid-2col       { grid-template-columns: 1fr 1fr; }
.footer-grid     { grid-template-columns: 1.5fr 1fr 1fr 1fr; }
.grid-pair       { grid-template-columns: 1fr 1fr; }

/* ===== Person-detail media (2026-06-16, reworked 2026-07-23) =====
   The separate "Media & source" section is gone: the portrait and the video
   card now share one swappable slot inside the detail hero (.media-swap
   below). .media-figure / .media-imgbox are still that slot's frame; the old
   .media-block / .media-figure-lead / .media-side / .media-cap rules were
   removed with the two-column section they styled. */
.media-figure {
  margin: 0;
  background: var(--paper);
  border: 1px solid var(--divider);
  border-radius: 12px;
  overflow: hidden;
}

/* --- Merged media slot (2026-07-23): portrait + video card, one place ---
   The box is the PORTRAIT's exact shape (7:10 — every portrait is 896x1280
   or 1792x2560). The cover frame is 0.799-0.80, so `object-fit: fill`
   stretches it to the same footprint: both images occupy identical space and
   swapping never moves the page a pixel. flex-basis (not width) because every
   image inside is absolutely positioned, so the item has no intrinsic width
   and would otherwise collapse. */
.media-swap { flex: 0 1 380px; max-width: 420px; width: 100%; }
.media-swap .media-imgbox { position: relative; aspect-ratio: 7 / 10; }
.media-swap .media-imgbox > img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: fill;            /* stretch to the portrait's exact size */
}
/* The image not in front, as a tappable corner inset.
   Both sources are full branded posters (verse + logo + wordmark + figure +
   name + dates), not headshots — shrinking a whole poster to ~80px is an
   illegible smudge, and the two posters look alike at that size so it fails
   to signal "the other image". So the inset is SQUARE and crops to the
   figure: object-position pulls the visible window up to the ~28% band where
   both layouts place the person. Sized off the slot so it scales with it. */
.media-inset {
  position: absolute; inset-block-end: 12px; inset-inline-end: 12px;
  width: 27%; min-width: 78px; aspect-ratio: 1 / 1;
  padding: 0; cursor: pointer; overflow: hidden;
  border: 2px solid var(--paper); border-radius: 8px;
  background: var(--bg);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55);
  transition: border-color .15s ease, transform .15s ease;
}
/* cover on a square box from a 0.70 poster keeps the FULL poster width and
   crops height, which leaves the figure tiny. Scaling up inside the
   overflow-hidden button narrows the window onto the figure itself. Origin
   sits at the band where every poster in this channel places the head. */
.media-inset > img {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; object-position: center 30%;
  /* 62%/30% is where this channel's poster template puts the head (the
     figure sits right of the wordmark). Verified against both sources —
     portraits and cover frames — across a sample of rows. A physical
     percentage on purpose: the posters are laid out the same whatever the
     page direction, so this must NOT flip in RTL. */
  transform: scale(1.75); transform-origin: 62% 30%;
}
.media-inset:hover { border-color: var(--forest); transform: scale(1.04); }
.media-inset:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }
/* ⇄ affordance — the cropped thumbnail alone doesn't say "click to swap". */
.media-inset::after {
  content: "⇄";
  position: absolute; inset-block-start: 3px; inset-inline-start: 3px;
  font-size: 11px; line-height: 1; padding: 3px 4px; border-radius: 4px;
  background: rgba(0, 0, 0, 0.6); color: var(--ink);
}
@media (prefers-reduced-motion: reduce) {
  .media-inset { transition: none; }
  .media-inset:hover { transform: none; }
}
/* Names the image in front — replaces the old figcaption, which cannot sit
   under a slot whose content changes. */
.media-badge {
  position: absolute; inset-block-start: 10px; inset-inline-start: 10px;
  font-size: var(--text-xs); line-height: 1;
  padding: 5px 9px; border-radius: 6px;
  background: rgba(0, 0, 0, 0.55); color: var(--ink);
  pointer-events: none;
}

/* Recorded fields as labelled chips (2026-07-23), replacing the old badges +
   facts-list pair that showed rank/battalion/brigade twice. Each chip carries
   its own label so the value is self-explaining. Only populated fields are
   emitted (detailFacts in app.js), so the row simply disappears for the 16
   rows that have none — never padded with em-dashes. */
.detail-chips { display: flex; flex-wrap: wrap; gap: 9px; }
.detail-chip {
  display: inline-flex; align-items: baseline; gap: 8px;
  background: var(--bg-3); border: 1px solid var(--divider);
  border-radius: 999px; padding: 6px 14px;
}
.detail-chip .ck {
  font-size: 11px; letter-spacing: .1em; color: var(--muted);
  white-space: nowrap;
}
.detail-chip .cv { font-size: 13.5px; font-weight: 600; color: var(--ink); }
/* First chip (rank) leads in the gold accent, keeping the warm note the old
   badge row gave the space under the name. */
.detail-chip.is-lead { background: var(--gold-dim); border-color: var(--gold-dim-2); }
.detail-chip.is-lead .cv { color: var(--forest); }
/* Drillable chips (rank / battalion / brigade) filter the registry by their
   value. City and weapon carry no drill dimension, so the affordance is what
   tells the two apart — it must never be applied to the whole row. Kept
   deliberately quiet for a memorial: the border warms and the value
   underlines, no icon and no colour shift on the text itself. */
.detail-chip.is-drill { cursor: pointer; transition: border-color .15s ease, background .15s ease; }
.detail-chip.is-drill:hover { border-color: var(--forest); background: var(--bg-2); }
.detail-chip.is-drill:hover .cv { text-decoration: underline; text-underline-offset: 3px; }
/* Keyboard users get the same cue plus a real ring; :focus-visible keeps it
   off mouse clicks. */
.detail-chip.is-drill:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }
.detail-chip.is-drill:focus-visible .cv { text-decoration: underline; text-underline-offset: 3px; }
/* The lead chip is already gold-tinted, so a forest border reads as a colour
   clash — warm it within its own palette instead. */
.detail-chip.is-lead.is-drill:hover { border-color: var(--gold); background: var(--gold-dim); }
/* Show the whole image — no crop, no zoom. The box height follows the image's
   natural aspect ratio instead of forcing 4:5 with object-fit:cover. */
.media-imgbox { width: 100%; background: var(--bg); }
.media-imgbox img { width: 100%; height: auto; display: block; }
/* "Watch on Telegram" button — dark-forest gradient card with a gold ▶ disc,
   two-line label, ↗ tail. Tokens only; the gold disc tint is mixed from
   --forest so it tracks the brand color. */
.tg-watch {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background: linear-gradient(110deg, var(--bg-3), var(--bg-2));
  border: 1px solid var(--divider);
  text-decoration: none;
  color: var(--ink);
  transition: transform .2s, box-shadow .2s, border-color .2s;
  box-shadow: 0 6px 18px -10px rgba(0, 0, 0, .6);
}
.tg-watch:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px -10px rgba(0, 0, 0, .7);
  border-color: var(--forest-2);
}
.tg-watch-ic {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  color: var(--forest);
  background: color-mix(in srgb, var(--forest) 16%, transparent);
}
.tg-watch-txt { display: flex; flex-direction: column; min-width: 0; }
.tg-watch-title { font-size: var(--text-sm); font-weight: 700; line-height: 1.25; }
.tg-watch-sub { font-size: var(--text-xs); color: var(--muted); margin-top: 2px; }
.tg-watch-tail { margin-inline-start: auto; color: var(--faint); font-size: 15px; }

/* Admin registry table — scrolls sideways on screens too narrow for its columns,
   so the table never breaks the page layout on a phone. */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll > table { min-width: 720px; }
/* Slimmer inline padding than Tailwind's p-3.5 (14px): with 11 columns the
   28px-per-cell padding alone ate ~300px, crushing the auto-width name
   column. Class+element selector outruns the single-class utility. (2026-06-11) */
.table-scroll th, .table-scroll td { padding-inline: 10px; }
.table-scroll::-webkit-scrollbar { height: 8px; }
.table-scroll::-webkit-scrollbar-track { background: transparent; }
.table-scroll::-webkit-scrollbar-thumb { background: var(--faint); border-radius: 999px; }

/* ===== AI verification (admin, 2026-06-10) ===== */
/* Option B stats strip — 4 cells above the admin filter card. Chosen by the
   user from webui/_preview_ai_verify.html over the in-card chips variant. */
.ai-stats-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--paper);
  border: 1px solid var(--divider);
  border-radius: 8px;
  overflow: hidden;
}
.ai-stat {
  padding: 14px 18px;
  text-align: center;
  border-inline-start: 1px solid var(--divider);
}
.ai-stat:first-child { border-inline-start: none; }
.ai-stat .v {
  font-family: var(--font-latin-sans);
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.ai-stat .l { font-size: 12px; color: var(--muted); margin-top: 2px; }
.ai-stat .v-human { color: var(--gold); }
.ai-stat .v-ai    { color: var(--ai); }
.ai-stat .v-rest  { color: var(--ink-2); }

/* AI badge in the admin table (tooltip carries ai_note) */
.ai-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ai);
  background: var(--ai-dim);
  border: 1px solid rgba(76, 195, 176, 0.35);
  border-radius: 999px;
  padding: 2px 10px;
  cursor: help;
}

/* Admin banner (2026-10-22): one primary action, quiet secondary ones, and a
   live line under the title. The banner's own text colour (text-paper on the
   gold gradient) drives the outlines through currentColor, so they follow it. */
.admin-live { display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  font-size: 12.5px; opacity: .85; margin-top: 6px; }
.admin-live i { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto;
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 14%, transparent); }
.admin-live i.is-ok { background: var(--stat-3); }
.admin-live i.is-bad { background: var(--crimson); }
.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-btn { font: inherit; font-size: 14px; padding: 8px 15px; border-radius: 8px; cursor: pointer;
  color: inherit; background: color-mix(in srgb, currentColor 8%, transparent);
  border: 1px solid color-mix(in srgb, currentColor 30%, transparent); transition: background .15s; }
.admin-btn:hover { background: color-mix(in srgb, currentColor 16%, transparent); }
.admin-btn.is-primary { background: var(--paper); color: var(--ink); border-color: transparent; font-weight: 600; }
.admin-btn.is-primary:hover { background: var(--bg-2); }
.admin-btn.is-quiet { background: transparent; border-color: transparent; opacity: .8; }

/* Admin tabs: an underlined strip; a badge shows what is waiting */
.admin-tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--divider); margin-bottom: 24px; }
.admin-tab { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-size: 14.5px;
  background: transparent; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  color: var(--muted); padding: 10px 16px; cursor: pointer; text-decoration: none; transition: color .15s; }
.admin-tab:hover { color: var(--ink); }
.admin-tab.is-active { color: var(--ink); font-weight: 600; border-bottom-color: var(--forest); }
.admin-tab-n { font-weight: 500; font-size: 11.5px; background: var(--bg-2); color: var(--ink-2);
  border-radius: 999px; padding: 1px 8px; }

/* AI audit panel at the top of the admin edit form */
.ai-note-panel {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  background: var(--ai-dim);
  border: 1px solid rgba(76, 195, 176, 0.35);
  border-radius: 8px;
  padding: 12px 16px;
}
.ai-note-panel .t { font-size: 13.5px; font-weight: 700; color: var(--ai); margin-bottom: 3px; }
.ai-note-panel .d { font-size: 12.5px; color: var(--ink-2); line-height: 1.7; }
.ai-note-panel .when { font-family: var(--font-latin-sans); font-size: 11px; color: var(--muted); margin-top: 4px; }

/* ===== Lifespan line + global events (2026-07-22) =====
   Markup emitted by renderTimeline() in app.js. The horizontal layout
   (.lifeline + .ev-list) renders above 480px; the vertical layout
   (.lifeline-v) replaces it at ≤480px (swap lives in the 480 media query).
   Positions along the line are inline `left` percentages (data-driven,
   PHYSICAL — RTL is converted in JS); all other geometry lives here.
   The line's y inside .lifeline is 112px — keep in sync with LIFELINE_TOP
   in app.js (the SVG leader-line pass needs it as a number). */
.lifeline-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 10px; margin-bottom: 26px; }
.lifeline-kicker { font-family: var(--font-latin-sans); font-size: 11px; letter-spacing: 0.2em; color: var(--olive); text-transform: uppercase; }
.lifeline-lived { font-family: var(--font-display); font-size: 22px; font-weight: 500; margin-top: 4px; }
.lifeline-lived b { color: var(--forest); }
.lifeline-lived .days { color: var(--muted); font-size: 16px; }
.lifeline-legend { display: flex; gap: 18px; font-size: 12px; color: var(--muted); flex-wrap: wrap; align-items: center; }
.lifeline-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.sw { flex: none; display: inline-block; }
.sw-birth { width: 10px; height: 10px; border-radius: 50%; background: var(--olive); box-shadow: 0 0 0 3px var(--paper), 0 0 0 4px var(--olive); }
.sw-mart  { width: 10px; height: 10px; background: var(--forest); transform: rotate(45deg); }
.sw-event { width: 10px; height: 10px; border-radius: 50%; background: var(--paper); border: 2px solid var(--ink-2); }
.sw-band  { width: 18px; height: 8px; border-radius: 4px; background: var(--gold-dim); border: 1px solid var(--gold-dim-2); }

.lifeline { position: relative; height: 210px; margin-inline: 12px; }
.lifeline-leaders { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.lifeline-leaders line { stroke: var(--faint); stroke-width: 1; }
.lifeline-base { position: absolute; inset-inline: 0; top: 112px; height: 2px; background: var(--divider); }
.lifeline-life {
  position: absolute; top: 110px; height: 6px; border-radius: 999px;
  background: linear-gradient(to right, var(--olive), var(--forest));
}
/* linear-gradient has no logical directions — flip it per document dir so
   olive always sits on the birth side. */
html[dir="rtl"] .lifeline-life { background: linear-gradient(to left, var(--olive), var(--forest)); }
.lifeline-band {
  position: absolute; top: 107px; height: 12px; border-radius: 6px;
  background: var(--gold-dim); border: 1px solid var(--gold-dim-2);
}
.lifeline-tick { position: absolute; top: 109px; width: 1px; height: 8px; background: var(--faint); transform: translateX(-50%); }
.lifeline-tick span {
  position: absolute; top: 11px; left: 50%; transform: translateX(-50%);
  font-family: var(--font-latin-sans); font-size: 10px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.lifeline .mk { position: absolute; transform: translateX(-50%); }
.lifeline .mk-birth { top: 104px; width: 16px; height: 16px; border-radius: 50%; background: var(--olive); border: 3px solid var(--paper); box-shadow: 0 0 0 1px var(--olive); }
.lifeline .mk-mart  { top: 105px; width: 14px; height: 14px; background: var(--forest); box-shadow: 0 0 0 3px var(--paper), 0 0 0 4px var(--forest); transform: translateX(-50%) rotate(45deg); }
.lifeline .mk-event { top: 106px; width: 12px; height: 12px; border-radius: 50%; background: var(--paper); border: 2px solid var(--ink-2); box-shadow: 0 0 0 2px var(--paper); }
.mk-year { position: absolute; transform: translateX(-50%); white-space: nowrap; font-family: var(--font-naskh); font-size: 12px; font-weight: 700; }
.mk-year-birth { top: 80px; color: var(--olive); }
.mk-year-mart  { top: 128px; color: var(--forest); }
.lifeline .ev-label { position: absolute; text-align: center; white-space: nowrap; visibility: hidden; }
.lifeline .ev-label[data-side="above"] { top: 40px; }
.lifeline .ev-label[data-side="below"] { top: 142px; }
.lifeline .ev-label .n { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.lifeline .ev-label .a { font-size: 11px; color: var(--forest); margin-top: 1px; }

.ev-list { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }
.ev-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ev-row .bullet { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--paper); border: 2px solid var(--ink-2); }
.ev-row .n { font-size: 14.5px; font-weight: 600; color: var(--ink); }
.ev-row .d { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.age-pill {
  font-size: 12px; color: var(--forest); background: var(--gold-dim);
  border: 1px solid var(--gold-dim-2); border-radius: 999px; padding: 1px 10px 2px;
}
/* .tag-ongoing removed 2026-07-23 with end_date — an event is a point in
   time, so nothing is ever "ongoing at his martyrdom". */

/* Vertical (≤480px) layout — birth at top, events in order, martyrdom last. */
.lifeline-v { display: none; position: relative; padding-inline-start: 34px; }
.lifeline-v::before { content: ""; position: absolute; inset-block: 8px; inset-inline-start: 10px; width: 2px; background: var(--divider); }
.lifeline-v .v-entry { position: relative; padding-block: 10px 14px; }
.lifeline-v .v-mk { position: absolute; inset-inline-start: -30px; top: 16px; }
.lifeline-v .v-year { font-family: var(--font-naskh); font-size: 15px; font-weight: 700; }
.lifeline-v .v-year-birth { color: var(--olive); }
.lifeline-v .v-year-mart { color: var(--forest); }
.lifeline-v .v-name { font-size: 14.5px; font-weight: 600; color: var(--ink); }
.lifeline-v .v-date { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; margin-top: 1px; }
.lifeline-v .v-meta { margin-top: 5px; display: flex; gap: 8px; flex-wrap: wrap; }

/* Responsive — tablet (1024) / large phone (768) / small phone (480).
   Grid rules need no !important now that defaults live in classes above. The
   .nav-links / .admin-banner / .hero-pad rules DO keep it — they override
   Tailwind utility classes (.flex / .items-center / .px-9 .py-8). */
@media (max-width: 1024px) {
  .nav-links { display: none !important; }
  /* .nav-hamburger / .mobile-nav are switched on AFTER their base rules
     further down this file - see the note there. */
  .grid-filters { grid-template-columns: 1fr 1fr 1fr; }
  .grid-detail, .grid-detail.is-admin { grid-template-columns: 1fr; }
  .grid-detail-portrait { justify-self: center; }
  /* Media above identity once there isn't room beside it; the slot centres
     rather than stretching to a full-width letterbox. The desktop row/column
     placement is cleared and `order` restores the phone reading order —
     picture, Telegram button, then the identity — so mobile is unchanged by
     the desktop button move. */
  .detail-hero { grid-template-columns: 1fr; row-gap: 20px; }
  .detail-hero > .hero-media,
  .detail-hero > .hero-identity,
  .detail-hero > .tg-watch { grid-column: 1; grid-row: auto; }
  .detail-hero > .hero-media    { order: 1; justify-self: center; width: 100%; max-width: 420px; }
  .detail-hero > .tg-watch      { order: 2; }
  .detail-hero > .hero-identity { order: 3; }
}
@media (max-width: 768px) {
  /* Birthday-match grid: date picker, window pills, submit each get their
     own full-width row — the only layout that reads cleanly this narrow. */
  .grid-bday { grid-template-columns: 1fr; }
  .grid-bday > .grid-bday-window,
  .grid-bday > .grid-bday-submit { grid-column: 1 / -1; }
  .grid-filters { grid-template-columns: 1fr 1fr; }
  .grid-2col { grid-template-columns: 1fr; }
  .stats-strip { grid-template-columns: 1fr 1fr; }
  /* AI stats strip folds 4 cells into 2×2; the 3rd cell starts a new visual
     row so it loses its start-border and gains a top one. */
  .ai-stats-strip { grid-template-columns: 1fr 1fr; }
  .ai-stat:nth-child(3) { border-inline-start: none; }
  .ai-stat:nth-child(n+3) { border-top: 1px solid var(--divider); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-grid > *:first-child { grid-column: 1 / -1; }
  .admin-banner { flex-direction: column; align-items: flex-start !important; gap: 16px; }
  .dates-strip { grid-template-columns: 1fr 1fr; }
  /* 2-col wrap: the age cell starts a new full-width row — no stray start
     border, and a top border separates the rows. */
  .dates-strip > div:nth-child(3) {
    grid-column: 1 / -1;
    border-inline-start: none;
    border-top: 1px solid var(--divider);
  }
  .grid-pair { grid-template-columns: 1fr; }
  /* Tighten the header so logo + controls (incl. the admin button) fit
     small phones without overflowing. !important beats Tailwind px-8 / gap-6. */
  .header-bar { padding-inline: 16px !important; gap: 12px !important; }
}
@media (max-width: 480px) {
  .grid-filters { grid-template-columns: 1fr; }
  .stats-strip { grid-template-columns: 1fr 1fr; }
  .hero-pad { padding: clamp(20px, 5vw, 44px) !important; }
  .lifeline, .ev-list { display: none; }
  .lifeline-v { display: block; }
  .dates-strip { grid-template-columns: 1fr; }
  .dates-strip > div { border-inline-start: none; }
  .dates-strip > div + div { border-top: 1px solid var(--divider); }
  /* The fact chips became tap targets when rank/battalion/brigade were made
     drillable; at the desktop padding they land at 34px tall, under the ~44px
     comfortable-touch floor. Padding (not a fixed height) so a chip whose
     value wraps still grows. Applied to every chip rather than just .is-drill
     so the row keeps one rhythm. */
  .detail-chip { padding: 11px 16px; }
}

/* Skip-to-content link — visible only on keyboard focus */
.skip-link {
  position: absolute; top: -40px; inset-inline-start: 1rem;
  background: var(--forest); color: var(--paper);
  padding: 0.5rem 1rem; border-radius: 0 0 6px 6px;
  font-weight: bold; z-index: 100;
  transition: top 0.15s ease-out;
  font-family: var(--font-body);
}
.skip-link:focus { top: 0; }

/* Loading skeleton — shimmer animation used during the initial data fetch */
.skeleton {
  display: block;
  background: linear-gradient(90deg, var(--bg-3) 0%, var(--bg-2) 50%, var(--bg-3) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: 4px;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Screen-reader-only utility — visually hidden but readable by AT */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Mobile nav drawer + hamburger — desktop hides hamburger; mobile hides nav-links */
.nav-hamburger {
  display: none;
  background: transparent; border: 1px solid var(--divider);
  border-radius: 8px; padding: 6px;
  color: var(--ink); cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.nav-hamburger:hover { background: var(--bg-2); border-color: var(--olive); }
.mobile-nav { display: none; }

/* These two must come AFTER the defaults directly above: the selectors have
   the same specificity, so source order decides. Declared up in the 1024
   block (line ~765) they lost to the `display:none` defaults below them, so
   the hamburger never appeared and a phone had NO navigation at all - the
   drawer was built and populated, but nothing could open it. Fixed
   2026-09-03; keep them here rather than adding !important. */
@media (max-width: 1024px) {
  .nav-hamburger { display: inline-flex; }
  .mobile-nav { display: block; }
}

/* ── Date picker — Litepicker restyled to the AQMAR dark theme ───────────
   Litepicker themes through its own --litepicker-* custom properties; setting
   them on .litepicker overrides the library defaults for every calendar.
   Covers all three pickers (home birthday search + admin birth/martyrdom). */
.litepicker {
  --litepicker-container-months-color-bg: var(--paper);
  --litepicker-container-months-box-shadow-color: rgba(0,0,0,.55);
  --litepicker-footer-color-bg: var(--bg-3);
  --litepicker-footer-box-shadow-color: var(--divider);
  --litepicker-tooltip-color-bg: var(--bg-3);
  --litepicker-month-header-color: var(--ink);
  --litepicker-button-prev-month-color: var(--muted);
  --litepicker-button-next-month-color: var(--muted);
  --litepicker-button-prev-month-color-hover: var(--forest);
  --litepicker-button-next-month-color-hover: var(--forest);
  --litepicker-month-weekday-color: var(--faint);
  --litepicker-month-week-number-color: var(--faint);
  --litepicker-day-width: 40px;
  --litepicker-day-color: var(--ink-2);
  --litepicker-day-color-hover: var(--forest);
  --litepicker-is-today-color: var(--olive-2);
  --litepicker-is-in-range-color: rgba(251,191,36,.14);
  --litepicker-is-locked-color: var(--faint);
  --litepicker-is-start-color: #1a1505;
  --litepicker-is-start-color-bg: var(--forest);
  --litepicker-is-end-color: #1a1505;
  --litepicker-is-end-color-bg: var(--forest);
  --litepicker-highlighted-day-color: var(--ink);
  --litepicker-highlighted-day-color-bg: var(--bg-3);
  --litepicker-button-apply-color-bg: var(--forest);
  --litepicker-button-apply-color: #1a1505;
  --litepicker-button-cancel-color-bg: var(--bg-3);
  --litepicker-button-cancel-color: var(--ink);
  font-family: var(--font-body);
}
.litepicker .container__months {
  border: 1px solid var(--divider);
  border-radius: 8px;
}
.litepicker .container__days > div,
.litepicker .container__days > a { font-size: var(--text-sm); }
/* Month + year <select> dropdowns (the SPA inits Litepicker with dropdowns). */
.litepicker .month-item-header select {
  background: var(--bg-3);
  color: var(--ink);
  border: 1px solid var(--divider);
  border-radius: 6px;
  padding: 4px 6px !important;
  margin: 0 4px;
  font-family: var(--font-body);
}
.litepicker .month-item-header select.month-item-year {
  min-width: 70px;
}

.month-item-year {
    text-align: center;
    text-align-last: center;
}

.month-item-name option,
.month-item-year option {
    text-align: center;
}


.litepicker .month-item-header select option {
  background: var(--bg-2);
  color: var(--ink);
}

/* ===== Boot spinner (offline-cache first load) =====
   Full-screen overlay shown from the first paint until app.js init() has
   loaded the registry and written the cache version. Lives outside the Alpine
   root, so it does not depend on Alpine being ready. */
#boot-spinner {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--bg);
  transition: opacity 0.35s ease;
}
#boot-spinner.boot-hide {
  opacity: 0;
  pointer-events: none;
}
.boot-ring {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 3px solid var(--divider);
  border-top-color: var(--forest);
  animation: boot-spin 0.8s linear infinite;
}
.boot-label {
  font-family: var(--font-body);
  color: var(--muted);
  font-size: var(--text-sm);
  letter-spacing: 0.05em;
}
@keyframes boot-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .boot-ring { animation-duration: 2s; }
}

/* ===== Combined search page — locked secondary filters (F1) =====
   Until the user picks a birthday OR clicks "browse the full registry", the
   secondary filters are dimmed + inert and a dashed hint row explains how to
   unlock them. Toggled by the `filtersUnlocked` Alpine flag. */
.filters-locked .lockable {
  opacity: 0.4;
  filter: grayscale(0.4);
  pointer-events: none;
  user-select: none;
}
.lock-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
  border: 1px dashed var(--divider);
  border-radius: 10px;
  padding: 18px 22px;
  background: rgba(251, 191, 36, 0.05);
}

/* "More filters" collapse toggle (2026-06-17): the heading row is a button.
   The caret points right when collapsed, down when expanded. */
.filters-toggle {
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  text-align: start;
}
.filters-chevron {
  display: inline-block;
  font-size: 11px;
  line-height: 1;
  transform: rotate(-90deg);
  transition: transform .2s ease;
}
.filters-chevron.is-open { transform: rotate(0deg); }

/* ===== Lifespan-line design switcher (2026-07-23) =====
   The visitor picks between the designs the admin offers (data/settings.json
   -> lifeline.enabled). Markup is in index.html above #lifeline-root; the
   designs themselves ship their own scoped CSS from webui/lifeline/. */
.lifeline-switch {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 20px; padding-bottom: 16px;
  border-bottom: 1px dashed var(--divider);
}
.lifeline-switch-lbl {
  /* This label is Arabic (شكل خطّ الحياة) in the default language, and
     --font-latin-sans (IBM Plex Sans) carries no Arabic glyphs - it fell back
     to a system face and read as a different typeface from everything around
     it. --font-body covers both scripts, which is why .section-kicker uses it.
     2026-08-31. */
  font-family: var(--font-body); font-size: 11px; font-weight: 500;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--olive);
}
.lifeline-switch-opts { display: flex; gap: 6px; flex-wrap: wrap; }
.lifeline-switch-btn {
  font-family: inherit; font-size: 12.5px; color: var(--muted);
  background: transparent; border: 1px solid var(--divider);
  border-radius: 999px; padding: 4px 13px 5px; cursor: pointer;
  transition: color .15s ease, border-color .15s ease, background-color .15s ease;
}
.lifeline-switch-btn:hover { color: var(--ink-2); border-color: var(--olive); }
.lifeline-switch-btn[aria-pressed="true"] {
  color: var(--forest); background: var(--gold-dim);
  border-color: var(--gold-dim-2); font-weight: 600;
}
.lifeline-switch-btn:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .lifeline-switch-btn { transition: none; } }

/* Designs are DESKTOP-ONLY. Below the mobile breakpoint every design is
   hidden and the existing vertical layout (.lifeline-v) takes over, so mobile
   renders identically whichever design is selected. !important is required
   here: each design's own stylesheet is injected into <head> at runtime, so
   it lands after this file and would otherwise win on source order. */
@media (max-width: 480px) {
  .lfd-w, .lfd-a, .lfd-b, .lfd-c, .lfd-d, .lfd-e { display: none !important; }
  .lifeline-switch { display: none !important; }
}

/* Admin Settings → lifespan-line designs: offered (checkbox) + default
   (radio) per design. Grid keeps the two controls in aligned columns. */
.lifeline-admin,
.stats-admin { border: 1px solid var(--divider); border-radius: 8px; overflow: hidden; }
.lifeline-admin-head,
.lifeline-admin-row,
.stats-admin-head,
.stats-admin-row {
  display: grid; grid-template-columns: 64px 74px 1fr; align-items: center;
  gap: 8px; padding: 9px 14px;
}
.lifeline-admin-head,
.stats-admin-head {
  background: var(--bg-2); border-bottom: 1px solid var(--divider);
  font-family: var(--font-latin-sans); font-size: 10.5px; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--faint);
}
.lifeline-admin-row,
.stats-admin-row { border-bottom: 1px dashed var(--divider); cursor: pointer; }
.lifeline-admin-row:last-child,
.stats-admin-row:last-child { border-bottom: 0; }
.lifeline-admin-row:hover,
.stats-admin-row:hover { background: var(--bg-2); }
.lifeline-admin-row input,
.stats-admin-row input { accent-color: var(--forest); width: 16px; height: 16px; cursor: pointer; }
.lifeline-admin-row input:disabled,
.stats-admin-row input:disabled { cursor: not-allowed; opacity: 0.4; }
.lifeline-admin-name,
.stats-admin-name { display: flex; flex-direction: column; gap: 1px; }
.lifeline-admin-name b,
.stats-admin-name b { font-size: 14px; font-weight: 600; color: var(--ink); }
.lifeline-admin-name i,
.stats-admin-name i {
  font-style: normal; font-size: 11.5px; color: var(--muted);
  font-family: var(--font-latin-sans);
}


/* ============================================================
   STATISTICS  (webui/stats-core.js + webui/stats/design-*.js)
   Shared chrome only. Each design's own layout CSS travels with
   its module and is injected at runtime by stats-designs.js.
   ============================================================ */
.st-title{font-family:var(--font-display);font-weight:600;
  font-size:var(--text-lg);margin:0 0 4px}
.st-sub{color:var(--faint);font-size:var(--text-sm);margin:0 0 16px}
.st-card{background:var(--paper);border:1px solid var(--divider);
  border-radius:12px;padding:20px}

.st-card svg{display:block;width:100%;height:auto;overflow:visible}
.st-note{color:var(--faint);font-size:var(--text-xs);margin-top:10px}

/* year strip under a time chart - LTR like the chart; each cell's flex-grow
   is its share of the charted months (statsYearStrip sets it inline) */
.st-years{display:flex;margin-top:10px;padding-top:8px;border-top:1px solid var(--divider)}
.st-year{min-width:0;display:flex;flex-direction:column;gap:2px;padding:4px 6px 2px 8px;
  border-left:1px solid var(--divider);border-radius:0 6px 6px 0;line-height:1.2;
  transition:background .15s}
.st-year-y{font-size:var(--text-xs);color:var(--faint)}
.st-year-n{font-family:var(--font-display);font-weight:600;font-size:var(--text-sm);color:var(--ink-2)}

/* ranked bars */
.st-rank{display:flex;flex-direction:column;gap:9px}
.st-row{display:grid;grid-template-columns:1fr 62px;gap:12px;align-items:center}
.st-lbl{font-size:var(--text-sm);color:var(--ink-2);white-space:nowrap;
  overflow:hidden;text-overflow:ellipsis}
.st-val{text-align:left;color:var(--muted);font-size:var(--text-sm)}
.st-track{position:relative;height:26px;background:var(--bg-2);
  border-radius:6px;overflow:hidden;margin-top:4px}
.st-bar{position:absolute;inset-block:0;right:0;border-radius:0 6px 6px 0}

/* numbered ranking (most common birth years) - the order is the statistic */
.st-ranked{list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:6px}
.st-rk{display:grid;grid-template-columns:auto minmax(3.6em,auto) 1fr auto;gap:10px;
  align-items:center;padding:5px 8px;border-radius:8px;transition:background .15s}
.st-rk-n{width:1.9em;height:1.9em;line-height:1.8em;text-align:center;border-radius:999px;
  border:1px solid var(--divider);color:var(--faint);font-size:var(--text-xs)}
.st-ranked li:first-child .st-rk-n{border-color:var(--forest);color:var(--forest)}
.st-rk-l{font-family:var(--font-display);font-weight:600;font-size:var(--text-base);color:var(--ink)}
.st-rk-track{display:block;height:12px;background:var(--bg-2);border-radius:6px;overflow:hidden}
.st-rk-bar{display:block;height:100%;border-radius:6px}
.st-rk-v{color:var(--muted);font-size:var(--text-sm);white-space:nowrap}

/* brigade × year grid (the time tab) - a row per brigade, a cell per year,
   every bar on one scale shared by the whole grid. Under 480px the header
   row hides and each cell shows its own year (.st-bg-cy) instead. */
.st-bg{display:flex;flex-direction:column;gap:12px}
.st-bg-head,.st-bg-row{display:grid;grid-template-columns:minmax(8em,10em) 1fr;gap:12px;align-items:center}
.st-bg-cells{display:grid;gap:6px}
.st-bg-yh{color:var(--faint);font-size:var(--text-xs);padding:2px 7px;border-radius:6px;transition:background .15s}
.st-bg-b{display:flex;align-items:center;gap:8px;font-size:var(--text-sm);color:var(--ink-2);
  min-width:0;border-radius:6px;padding:4px 6px;margin:-4px -6px;transition:background .15s}
.st-bg-b span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.st-bg-b b{color:var(--faint);font-weight:400;margin-inline-start:auto}
.st-bg-cell{display:flex;flex-direction:column;background:var(--bg-2);border-radius:6px;
  padding:5px 7px 6px;min-width:0;transition:background .15s}
.st-bg-cy{display:none;color:var(--faint);font-size:var(--text-xs);line-height:1.2}
.st-bg-n{font-family:var(--font-display);font-weight:600;font-size:var(--text-sm);color:var(--ink);line-height:1.1}
.st-bg-track{display:block;height:6px;border-radius:3px;background:var(--paper);margin-top:5px;overflow:hidden}
.st-bg-fill{display:block;height:100%;border-radius:3px}

/* headline figures above the tabs (statsFigures) */
.st-figs{display:grid;gap:1px;background:var(--divider);
  grid-template-columns:repeat(4,1fr);
  border:1px solid var(--divider);border-radius:12px;overflow:hidden}
.st-fig{background:var(--paper);padding:18px 16px}
.st-fv{font-family:var(--font-display);font-weight:700;line-height:1.15;
  font-size:var(--text-xl);color:var(--forest)}
.st-fl{color:var(--muted);font-size:var(--text-sm);margin-top:6px}

/* rank tree (statsRankTree) - a row per unit level, highest first; the
   commander card carries the accent border, the deputy sits beside it */
.st-tree{display:flex;flex-direction:column;gap:10px}
.st-tr-lvl{display:grid;grid-template-columns:7em 1fr;gap:16px;align-items:center}
.st-tr-unit{font-family:var(--font-display);color:var(--faint);font-size:var(--text-xs)}
.st-tr-unit b{display:block;color:var(--ink-2);font-size:var(--text-base);font-weight:600}
.st-tr-cards{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}
.st-tr-card{background:var(--bg-2);border:1px solid var(--divider);border-radius:10px;
  padding:10px 14px;min-width:0;transition:background .15s,border-color .15s}
.st-tr-card.is-lead{border-color:var(--forest)}
.st-tr-card.is-empty{background:transparent;border-style:dashed;opacity:.6}
.st-tr-n{font-family:var(--font-display);font-weight:600;font-size:var(--text-sm);color:var(--ink);
  white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.st-tr-m{display:flex;flex-wrap:wrap;gap:4px 12px;color:var(--muted);font-size:var(--text-xs);margin-top:3px}
.st-tr-bar{display:block;height:5px;border-radius:3px;background:var(--paper);margin-top:8px;overflow:hidden}
.st-tr-bar i{display:block;height:100%;background:var(--forest)}
.st-tr-cut{border-top:2px dashed var(--stat-2);margin:6px 0 4px calc(7em + 16px);text-align:center;line-height:0}
.st-tr-cut span{background:var(--paper);padding:0 10px;color:var(--stat-2);font-size:var(--text-xs);line-height:1.4}

/* ages at earlier events (statsEventAges) - one 100% bar per event */
.st-ev{display:flex;flex-direction:column;gap:12px}
.st-ev-row{display:grid;grid-template-columns:minmax(9em,15em) 1fr;gap:14px;align-items:center}
.st-ev-n{font-size:var(--text-sm);color:var(--ink-2)}
.st-ev-n small{display:block;color:var(--faint);font-size:var(--text-xs)}
.st-ev-bar{display:flex;height:24px;border-radius:6px;overflow:hidden;background:var(--bg-2)}
.st-ev-bar span{display:flex;align-items:center;justify-content:center;min-width:0;overflow:hidden}
.st-ev-bar b{font-size:var(--text-xs);font-weight:600;color:var(--bg);white-space:nowrap}
.st-ev-legend{display:flex;gap:8px 16px;flex-wrap:wrap;margin-top:14px;font-size:var(--text-sm);color:var(--ink-2)}
.st-ev-legend span{display:flex;align-items:center;gap:7px}

/* milestones (statsMilestones) reuse the figures strip, as many columns as tiles */
.st-miles{grid-template-columns:repeat(auto-fit,minmax(160px,1fr))}
.st-ml-d{color:var(--ink);font-size:var(--text-sm);margin-top:4px}

/* commanders per year (statsCommanders) */
.st-cmd{display:grid;gap:12px;grid-template-columns:repeat(auto-fit,minmax(140px,1fr))}
.st-cmd-c{background:var(--bg-2);border-radius:10px;padding:14px}
.st-cmd-y{color:var(--faint);font-size:var(--text-xs)}
.st-cmd-v{font-family:var(--font-display);font-weight:700;font-size:var(--text-lg);color:var(--ink)}
.st-cmd-s{color:var(--muted);font-size:var(--text-xs)}
.st-cmd-t{display:block;height:6px;border-radius:3px;background:var(--paper);margin-top:8px;overflow:hidden}
.st-cmd-t i{display:block;height:100%;background:var(--stat-3)}

/* battalions inside their brigade (statsUnits) - a card per brigade */
.st-units{display:grid;gap:14px;grid-template-columns:repeat(auto-fit,minmax(300px,1fr))}
.st-unit-h{display:flex;align-items:center;gap:8px;margin:-4px -6px 12px;padding:4px 6px;
  border-radius:8px;font-family:var(--font-display);font-weight:600;
  font-size:var(--text-base);color:var(--ink);transition:background .15s}
.st-unit-h b{margin-inline-start:auto;color:var(--faint);font-weight:400;
  font-family:var(--font-body);font-size:var(--text-xs)}

/* colour swatch - identity is never colour-alone, so a name always sits beside it */
.st-sw{width:11px;height:11px;border-radius:3px;flex:0 0 auto;display:inline-block}

/* table view — every chart ships one */
.st-table{margin-top:16px;border-top:1px solid var(--divider);padding-top:12px}
.st-table summary{cursor:pointer;color:var(--muted);font-size:var(--text-sm)}
.st-tw{overflow-x:auto;max-height:320px;margin-top:12px}
.st-tw table{border-collapse:collapse;width:100%;font-size:var(--text-sm)}
.st-tw th,.st-tw td{text-align:right;padding:7px 12px;
  border-bottom:1px solid var(--divider);white-space:nowrap}
.st-tw th{color:var(--muted);font-weight:500;position:sticky;top:0;background:var(--paper)}
.st-tw td.num{color:var(--ink-2)}

/* hover readout */
#stats-tip,#visits-tip,#overview-tip{position:fixed;pointer-events:none;opacity:0;transition:opacity .12s;
  z-index:80;background:var(--bg);border:1px solid var(--divider);border-radius:9px;
  padding:9px 13px;font-size:var(--text-sm);color:var(--ink);max-width:280px;
  box-shadow:0 10px 28px rgba(0,0,0,.55)}
#stats-tip .stt,#visits-tip .stt,#overview-tip .stt{color:var(--forest);font-family:var(--font-display);
  font-weight:600;margin-bottom:3px}
#stats-tip .stv,#visits-tip .stv,#overview-tip .stv{color:var(--muted);font-variant-numeric:tabular-nums;line-height:1.5}

/* ============================================================
   ADMIN OVERVIEW  (webui/admin-overview.js)
   ============================================================ */
.ov-toolbar{display:flex;justify-content:flex-end;align-items:center;gap:12px;margin-bottom:14px}
.ov-updated{color:var(--faint);font-size:var(--text-xs)}
.ov-kpis{display:grid;gap:12px;grid-template-columns:repeat(5,minmax(0,1fr))}
.ov-kpi{display:flex;flex-direction:column;text-align:start;font:inherit;color:inherit;
  background:var(--paper);border:1px solid var(--divider);border-radius:12px;padding:16px;min-width:0}
button.ov-kpi{cursor:pointer;transition:border-color .15s}
button.ov-kpi:hover{border-color:var(--faint)}
.ov-kpi-l{color:var(--muted);font-size:var(--text-sm)}
.ov-kpi-v{font-family:var(--font-display);font-weight:700;font-size:var(--text-2xl);line-height:1.15;
  margin-top:6px;color:var(--ink)}
.ov-kpi.is-warn .ov-kpi-v{color:var(--stat-2)}
.ov-kpi-h{color:var(--faint);font-size:var(--text-xs);margin-top:4px}
.ov-grid{display:grid;gap:14px;grid-template-columns:minmax(0,1.25fr) minmax(0,1fr);margin-top:14px}
.ov-card{background:var(--paper);border:1px solid var(--divider);border-radius:12px;padding:18px 20px;min-width:0}
.ov-card.ov-wide{grid-column:1/-1}
.ov-card h3{font-family:var(--font-display);font-size:var(--text-base);font-weight:600;margin:0 0 4px}
.ov-sub{color:var(--faint);font-size:var(--text-xs);margin:0 0 14px}
.ov-chart{display:flex;align-items:flex-end;gap:3px;height:150px;border-bottom:1px solid var(--divider);padding-bottom:2px}
.ov-col{flex:1 1 0;min-width:0;height:100%;display:flex;flex-direction:column;justify-content:flex-end;position:relative}
.ov-col i{display:block}
.ov-col-a{background:var(--forest);border-radius:3px 3px 0 0}
.ov-col-b{background:var(--stat-1)}
.ov-col.is-gap::after,.ov-sw-gap{background:repeating-linear-gradient(135deg,transparent 0 4px,var(--crimson) 4px 6px);opacity:.4}
.ov-col.is-gap::after{content:"";position:absolute;inset:0;border-radius:3px}
.ov-axis{display:flex;justify-content:space-between;color:var(--faint);font-size:var(--text-xs);margin-top:6px}
.ov-leg{display:flex;gap:6px 14px;flex-wrap:wrap;color:var(--ink-2);font-size:var(--text-xs);margin-top:10px}
.ov-leg span{display:flex;align-items:center;gap:6px}
.ov-sw{display:inline-block;width:10px;height:10px;border-radius:2px}
.ov-sw-a{background:var(--forest)} .ov-sw-b{background:var(--stat-1)}
.ov-sw-ok{background:var(--stat-3)} .ov-sw-idle{background:var(--stat-3);opacity:.35}
.ov-sw-fail{background:var(--crimson)}
.ov-health{display:flex;flex-direction:column;gap:11px}
.ov-hr{display:flex;justify-content:space-between;align-items:baseline;gap:12px;
  padding-bottom:10px;border-bottom:1px solid var(--divider)}
.ov-hr:last-child{border-bottom:0;padding-bottom:0}
.ov-hr-k{color:var(--muted);font-size:var(--text-sm);flex:0 0 auto}
.ov-hr-v{color:var(--ink);font-size:var(--text-sm);text-align:end}
.ov-dot{display:inline-block;width:8px;height:8px;border-radius:50%;margin-inline-end:7px}
.ov-dot.is-ok{background:var(--stat-3)} .ov-dot.is-bad{background:var(--crimson)}
.ov-ok{color:var(--stat-3)} .ov-bad{color:var(--crimson);font-weight:600}
.ov-runs{display:flex;gap:3px}
.ov-runs i{flex:1 1 0;height:16px;border-radius:2px;background:var(--stat-3);opacity:.85}
.ov-runs i.is-idle{opacity:.35} .ov-runs i.is-fail{background:var(--crimson);opacity:1}
.ov-q{display:flex;flex-direction:column;gap:6px}
.ov-qr{display:grid;grid-template-columns:8.5em 1fr 9em;gap:12px;align-items:center;font:inherit;
  font-size:var(--text-sm);color:inherit;background:transparent;border:0;padding:5px 6px;margin:0 -6px;
  border-radius:8px;text-align:start}
button.ov-qr{cursor:pointer} button.ov-qr:hover{background:var(--bg-2)}
.ov-qr-n{color:var(--ink-2)}
.ov-qr-t{display:block;height:8px;border-radius:4px;background:var(--bg-2);overflow:hidden}
.ov-qr-t i{display:block;height:100%;background:var(--forest)}
.ov-qr-c{color:var(--muted);font-size:var(--text-xs);text-align:end}
.ov-todo{display:flex;flex-direction:column}
.ov-td{display:flex;align-items:center;gap:12px;padding:11px 6px;margin:0 -6px;font:inherit;color:inherit;
  background:transparent;border:0;border-bottom:1px solid var(--divider);border-radius:8px;
  text-align:start;cursor:pointer}
.ov-td:last-child{border-bottom:0}
.ov-td:hover{background:var(--bg-2)}
.ov-td-c{min-width:3.4em;text-align:center;font-family:var(--font-display);font-weight:700;color:var(--ink);
  background:var(--bg-2);border-radius:8px;padding:4px 6px}
.ov-td:hover .ov-td-c{background:var(--paper)}
.ov-td-t{flex:1;font-size:var(--text-sm);color:var(--ink-2)}
.ov-td-t small{display:block;color:var(--faint);font-size:var(--text-xs)}
.ov-td-go{color:var(--forest);font-size:var(--text-xs);white-space:nowrap}
.ov-empty{color:var(--muted);font-size:var(--text-sm)}
.ov-tw{overflow-x:auto}
.ov-tbl{width:100%;border-collapse:collapse;font-size:var(--text-sm)}
.ov-tbl th{color:var(--muted);font-weight:500;text-align:start;padding:7px 8px;border-bottom:1px solid var(--divider);white-space:nowrap}
.ov-tbl td{padding:8px;border-bottom:1px solid var(--divider);color:var(--ink-2);white-space:nowrap}
.ov-tbl tr:last-child td{border-bottom:0}
.ov-delta{color:var(--stat-3)}
.ov-td:focus-visible,button.ov-qr:focus-visible,button.ov-kpi:focus-visible{outline:2px solid var(--forest);outline-offset:2px}
@media (max-width:1024px){
  .ov-kpis{grid-template-columns:repeat(3,minmax(0,1fr))}
  .ov-grid{grid-template-columns:minmax(0,1fr)}
}
@media (max-width:640px){
  .ov-kpis{grid-template-columns:repeat(2,minmax(0,1fr))}
  .ov-qr{grid-template-columns:6.5em 1fr 7.5em;gap:8px}
  .ov-hr{flex-direction:column;gap:2px}
  .ov-hr-v{text-align:start}
}

/* the two statistics tabs (one per AQMAR_STATS key) */
.stats-tabs{display:flex;gap:4px;border-bottom:1px solid var(--divider)}
.stats-tab{font-family:var(--font-display);font-size:var(--text-base);color:var(--muted);
  background:transparent;border:0;border-bottom:2px solid transparent;margin-bottom:-1px;
  padding:10px 18px;cursor:pointer;transition:color .18s,border-color .18s}
.stats-tab:hover{color:var(--ink)}
.stats-tab[aria-selected="true"]{color:var(--ink);font-weight:600;border-bottom-color:var(--forest)}

/* pill toggle button - the admin visits tab's period picker uses it */
.stats-switch-btn{font-family:var(--font-display);font-size:var(--text-sm);
  color:var(--muted);background:transparent;border:1px solid var(--divider);
  border-radius:999px;padding:5px 15px;cursor:pointer;transition:all .18s}
.stats-switch-btn:hover{color:var(--ink);border-color:var(--faint)}
.stats-switch-btn[aria-pressed="true"]{background:var(--forest);color:var(--bg);
  border-color:var(--forest)}

/* ---- statistics on a phone ----
   The time charts carry no axis text, so nothing in them needs a minimum
   width: they scale to the card and the page never scrolls sideways. Their
   viewBox is 900 units wide with preserveAspectRatio="none", so the natural
   height at 375px would be a 95px sliver - give them a fixed height here
   instead (strokes are non-scaling, so the stretch costs nothing). */
@media (max-width:640px){
  .st-card{padding:14px 12px}
  .st-card svg.st-area{height:150px}
  .st-title{font-size:var(--text-base)}
  .st-sub{margin-bottom:12px}
  .st-tw{max-height:260px}
}
@media (max-width:480px){
  .st-row{grid-template-columns:1fr 52px}
  .st-lbl{font-size:var(--text-xs)}
  .st-rk{gap:8px;padding:5px 4px}
  .st-rk-v{font-size:var(--text-xs)}
  .st-bg-head{display:none}
  .st-bg-row{grid-template-columns:1fr;gap:6px}
  .st-bg-b{margin:0;padding:2px 0}
  .st-bg-cy{display:block}
  .st-tr-lvl,.st-ev-row{grid-template-columns:1fr;gap:6px}
  .st-tr-cut{margin-inline-start:0}
  .st-units{grid-template-columns:1fr}
  .st-figs{grid-template-columns:repeat(2,1fr)}
  .stats-tab{padding:9px 12px;font-size:var(--text-sm)}
}


/* ---- chart drill-down ---- */
/* Anything carrying data-drill-dim is clickable; make that legible rather
   than leaving the visitor to discover it by accident. */
.st-drill { cursor: pointer; }
rect.st-drill:hover { fill: rgba(251, 191, 36, 0.10); }
.st-bar.st-drill:hover { filter: brightness(1.18); }
.st-rk.st-drill:hover, .st-year.st-drill:hover, .st-bg-b.st-drill:hover,
.st-bg-yh.st-drill:hover,
.st-unit-h.st-drill:hover { background: var(--bg-2); }
.st-bg-cell.st-drill:hover, .st-tr-card.st-drill:hover { background: var(--bg-3); }
tr.st-drill:hover td { background: var(--bg-2); }
.st-drill:focus-visible,
rect.st-drill:focus-visible { outline: 2px solid var(--forest); outline-offset: 2px; }

/* the chip above the results that explains a narrowed grid */
.drill-chip {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 18px; border-radius: 8px; background: var(--bg-2);
  border: 1px solid var(--divider); border-inline-start: 3px solid var(--forest);
}
.drill-chip-lbl {
  /* Arabic label - see the note on .lifeline-switch-lbl. */
  font-family: var(--font-body); font-size: 10.5px; font-weight: 500;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--faint);
}
.drill-chip b { font-family: var(--font-display); font-size: var(--text-base); color: var(--ink); }
.drill-chip-n { color: var(--muted); font-size: var(--text-sm); }
.drill-chip-x, .drill-chip-back {
  background: transparent; border: 1px solid var(--divider); border-radius: 999px;
  color: var(--muted); cursor: pointer; padding: 4px 12px; font-size: var(--text-sm);
}
.drill-chip-x { margin-inline-start: auto; padding: 4px 10px; }
.drill-chip-x:hover { color: var(--crimson); border-color: var(--crimson); }
.drill-chip-back:hover { color: var(--ink); border-color: var(--faint); }


/* ============================================================
   VISITOR ANALYTICS  (2026-10-15)
   Admin «الزيارات» tab (webui/admin-visits.js) and the public
   consent bar (webui/visit-tracker.js). Series colours are
   --stat-4 (visits) and --stat-1 (visitors), a pair validated
   on --paper; the heatmap is --stat-1 at rising opacity.
   ============================================================ */
.visits-toolbar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:14px}
.visits-toolbar-lbl{color:var(--faint);font-size:var(--text-xs);margin-inline-end:4px}
.visits-toolbar-end{display:flex;gap:8px;margin-inline-start:auto;flex-wrap:wrap}
.visits-msg{color:var(--muted);font-size:var(--text-sm);margin:0 0 10px}
.visits-privacy{color:var(--faint);font-size:var(--text-xs);line-height:1.8;max-width:95ch;margin:0 0 22px;
  border-inline-start:3px solid var(--divider);padding-inline-start:12px}

.vnotice{background:var(--gold-dim);border:1px solid var(--olive);color:var(--ink-2);border-radius:10px;
  padding:12px 16px;font-size:var(--text-sm);line-height:1.8;margin-bottom:20px}
.vstore{margin:0 0 14px}
.vtiles{display:grid;gap:1px;background:var(--divider);border:1px solid var(--divider);border-radius:12px;
  overflow:hidden;grid-template-columns:repeat(4,1fr)}
.vtiles.five{grid-template-columns:repeat(5,1fr)}
.vt{background:var(--paper);padding:18px 18px 16px;min-width:0}
.vt-v{font-family:var(--font-display);font-weight:700;font-size:var(--text-xl);color:var(--ink);line-height:1.1}
.vtiles.five .vt-v{font-size:var(--text-lg)}
.vt-l{color:var(--muted);font-size:var(--text-sm);margin-top:6px}
.vt-d{color:var(--faint);font-size:var(--text-xs);margin-top:4px}
.vt-d.up,.vt-d.down{color:var(--ink-2)}
.vt-d.up::before{content:"\25B2  ";color:var(--stat-3)}
.vt-d.down::before{content:"\25BC  ";color:var(--crimson)}
.vsec{margin-top:36px;min-width:0}
.vgrid2{display:grid;grid-template-columns:1fr 1fr;gap:22px;margin-top:36px}
.vgrid3{display:grid;grid-template-columns:repeat(3,1fr);gap:22px;margin-top:36px}
.vgrid2 .vsec,.vgrid3 .vsec{margin-top:0}
.vhint{color:var(--faint);font-size:var(--text-xs);line-height:1.7;margin:10px 0 0}
.vempty{color:var(--faint);font-size:var(--text-sm);margin:0}
.vcode{color:var(--faint);font-size:var(--text-xs);font-family:var(--font-latin-sans);margin-inline-start:6px}
.vgrid3 .vcode{display:none}

.lc svg{display:block;width:100%;height:220px;overflow:visible}
.lc-x{display:flex;justify-content:space-between;color:var(--faint);font-size:var(--text-xs);margin-top:6px}
.lc-legend{display:flex;gap:18px;flex-wrap:wrap;margin-top:12px;font-size:var(--text-sm);color:var(--ink-2)}
.lc-legend i{display:inline-block;width:18px;height:3px;border-radius:2px;vertical-align:middle;margin-inline-end:7px}

.vtbl{width:100%;border-collapse:collapse;font-size:var(--text-sm)}
.vtbl th{color:var(--muted);font-weight:500;text-align:start;padding:8px 10px;
  border-bottom:1px solid var(--divider);white-space:nowrap}
.vtbl td{padding:8px 10px;border-bottom:1px solid var(--divider);color:var(--ink-2)}
.vtbl .n{text-align:end;font-variant-numeric:tabular-nums;white-space:nowrap}
.vclick{cursor:pointer}
.vclick:hover td,.vclick[aria-expanded="true"] td{background:var(--bg-2)}
.vclick:focus-visible{outline:2px solid var(--forest);outline-offset:-2px}
.vshare{display:flex;align-items:center;gap:8px;min-width:110px}
.vshare-t{flex:1;height:8px;background:var(--bg-2);border-radius:4px;overflow:hidden}
.vshare-b{display:block;height:100%;background:var(--stat-1);border-radius:4px}
.vshare-p{color:var(--faint);font-size:var(--text-xs);min-width:3.4em;text-align:end}
.vid{font-family:var(--font-latin-sans);color:var(--forest);font-size:var(--text-xs);background:var(--gold-dim);
  border-radius:6px;padding:2px 7px;direction:ltr;unicode-bidi:isolate}
.vbadge{font-size:var(--text-xs);border:1px solid var(--divider);border-radius:999px;padding:1px 8px;color:var(--muted)}
.vbadge.ret{border-color:var(--stat-3);color:var(--ink-2)}
.vact td{background:var(--bg-2)}
.vact ol{margin:4px 0;padding-inline-start:22px;color:var(--ink-2);line-height:1.9;font-size:var(--text-xs)}
.vact time{color:var(--faint);margin-inline-end:8px}
.vfilter{display:flex;align-items:center;gap:8px;color:var(--muted);font-size:var(--text-sm);margin-bottom:12px}
.vfilter select{max-width:220px;padding:6px 10px}
.vscroll{overflow-x:auto}
.vpager{display:flex;align-items:center;justify-content:center;gap:16px;margin-top:12px;color:var(--muted);font-size:var(--text-sm)}

.hm{display:grid;grid-template-columns:4.6em repeat(24,1fr);gap:3px;align-items:center;direction:ltr}
.hm-d{color:var(--muted);font-size:var(--text-xs);text-align:right;padding-right:6px;direction:rtl}
.hm-c{height:22px;border-radius:4px;background:var(--stat-1)}
.hm-h{color:var(--faint);font-size:10px;text-align:center}
.hm-scale{display:flex;gap:4px;align-items:center;margin-top:12px;color:var(--faint);font-size:var(--text-xs)}
.hm-scale span{width:22px;height:12px;border-radius:3px;background:var(--stat-1);display:inline-block}

@media (max-width:1024px){
  .vgrid2,.vgrid3{grid-template-columns:1fr}
}
@media (max-width:768px){
  .vtiles,.vtiles.five{grid-template-columns:1fr 1fr}
}
@media (max-width:640px){
  .vhide{display:none}
  .lc svg{height:160px}
  .vtbl td,.vtbl th{padding:7px 6px}
  .hm{grid-template-columns:3.4em repeat(24,1fr);gap:2px}
  .hm-c{height:16px}
}

/* consent bar - public site. A bar, never a modal: no overlay, no focus
   trap, nothing behind it is blocked. Equal weight on both buttons. */
.consent-bar{position:fixed;inset-inline:16px;bottom:16px;z-index:70;max-width:880px;margin-inline:auto;
  display:flex;align-items:center;gap:16px;flex-wrap:wrap;background:var(--bg-3);
  border:1px solid var(--divider);border-radius:12px;padding:14px 18px;box-shadow:0 10px 28px rgba(0,0,0,.45)}
.consent-text{flex:1 1 320px;margin:0;color:var(--ink-2);font-size:var(--text-sm);line-height:1.8}
.consent-more{background:none;border:0;padding:0;margin-inline-start:6px;color:var(--forest);
  font:inherit;cursor:pointer;text-decoration:underline}
.consent-actions{display:flex;gap:8px}
.consent-btn{background:transparent;color:var(--ink);border:1px solid var(--faint);border-radius:999px;
  padding:7px 20px;font-size:var(--text-sm)}
.consent-btn:hover{border-color:var(--forest);color:var(--forest)}
.footer-privacy{background:none;border:0;padding:0;margin-inline-start:12px;color:var(--muted);
  font:inherit;cursor:pointer;text-decoration:underline}
.footer-privacy:hover{color:var(--forest)}
.about-privacy{border:1px solid var(--divider);border-radius:8px;padding:20px 22px;background:var(--paper)}
@media (max-width:480px){
  .consent-bar{inset-inline:8px;bottom:8px;padding:12px 14px}
  .consent-actions{width:100%}
  .consent-btn{flex:1}
}
