/* ============================================================
   Chronicle — design system
   Dark, manuscript-on-slate. Built primitives first, then views.
   ============================================================ */
/* Self-hosted Qur'anic Arabic face (SIL OFL) — system Arabic fonts render Uthmani tajwīd/pause
   marks (small low mīm U+06ED, ṣalā sign U+06D6, superscript alef …) as stray symbols; this
   renders them correctly while keeping full vocalisation. */
@font-face {
  font-family: "Scheherazade New";
  src: url("/vendor/fonts/scheherazade-new-arabic.woff2?v=201") format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0600-06FF, U+0750-077F, U+08A0-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
/* ===================== THEME TOKENS =====================
   Default = LIGHT "warm parchment" (enterprise-grade, WCAG-AAA primary text 13.5:1).
   [data-theme="dark"] = refined navy-slate. Accessibility layers below override contrast,
   text-size, motion, typeface, spacing and links from the Settings panel.
   Fonts:  --serif/--sans/--mono/--quran-ar are theme-independent (set once here). */
:root {
  color-scheme: light;
  /* surfaces — warm parchment */
  --bg: #f4efe4;             /* app canvas */
  --bg-panel: #fbf8f1;       /* sidebar + raised panels */
  --bg-elevated: #ffffff;    /* cards, inputs, popovers — crisp lift on parchment */
  --bg-hover: #ece4d3;
  --border: #ddd2bd;
  --border-subtle: #e8e0cf;
  --viz-bg: #14171d;         /* deep visualisation canvas (graph/river/matrix) — dark in both themes */

  /* text — warm ink */
  --text: #2a2318;
  --text-muted: #5b5140;
  --text-dim: #7c7059;

  /* brand — aged gold + deep teal.
     --accent = gold FILL (dark ink on top);  --link/--link-2 = AAA-safe accent TEXT. */
  --accent: #c99a20;
  --accent-bright: #d9ab3d;
  --accent-soft: rgba(201, 154, 32, 0.15);
  --accent-2: #0f766e;
  --on-accent: #2a2318;      /* ink placed on a gold fill (fixed across themes) */
  --link: #574000;           /* AAA gold accent text (8.5:1) */
  --link-2: #094f48;         /* AAA teal accent text (8.2:1) */

  /* entity kinds — tuned to read on light */
  --k-person: #2f5fa8;
  --k-tribe: #8a6d12;
  --k-location: #0f766e;
  --k-event: #b4531a;
  --k-role: #6b4bab;
  --k-source: #6b6357;

  /* claim status */
  --st-accepted: #14532b;
  --st-disputed: #8f4a12;
  --st-unverified: #6f665a;
  --st-superseded: #8a8378;

  /* semantic */
  --danger: #8f2418;
  --success: #14532b;

  --r: 12px;
  --r-sm: 8px;
  --r-pill: 999px;
  --shadow: 0 14px 40px rgba(74, 60, 30, 0.13), 0 2px 8px rgba(74, 60, 30, 0.07);
  --shadow-sm: 0 1px 3px rgba(74, 60, 30, 0.12);
  --ring: rgba(201, 154, 32, 0.5);
  --scroll: #cfc4ad;
  --scroll-hover: #b6a988;

  /* a11y-tunable (Settings panel drives these) */
  --fs-root: 14.5px;
  --lh: 1.55;
  --ls: 0em;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "JetBrains Mono", "Fira Code", ui-monospace, Menlo, monospace;
  --quran-ar: "Scheherazade New", "Amiri", "Traditional Arabic", "Geeza Pro", serif;
}

/* ---- DARK theme (refined navy-slate) ---- */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #14171d;
  --bg-panel: #191d24;
  --bg-elevated: #20252e;
  --bg-hover: #262c37;
  --border: #2f3742;
  --border-subtle: #232932;
  --viz-bg: #0b0e13;
  --text: #eef1f5;
  --text-muted: #aab3bf;
  --text-dim: #7b8492;
  --accent: #e0bd6a;
  --accent-bright: #ecd08a;
  --accent-soft: rgba(224, 189, 106, 0.15);
  --accent-2: #5cc0b2;
  --on-accent: #14171d;
  --link: #e6c67c;
  --link-2: #5cc0b2;
  --k-person: #6ea8fe; --k-tribe: #d9b45a; --k-location: #4fb3a6;
  --k-event: #e08a4b; --k-role: #a78bda; --k-source: #8891a0;
  --st-accepted: #7fce97; --st-disputed: #e0a25a; --st-unverified: #8891a0; --st-superseded: #6a7280;
  --danger: #f0857a; --success: #7fce97;
  --shadow: 0 14px 40px rgba(0, 0, 0, 0.5); --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --ring: rgba(224, 189, 106, 0.55);
  --scroll: #2f3742; --scroll-hover: #3d4655;
}
/* System preference when the user hasn't explicitly chosen (no-JS / first paint fallback) */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    color-scheme: dark;
    --bg: #14171d; --bg-panel: #191d24; --bg-elevated: #20252e; --bg-hover: #262c37;
    --border: #2f3742; --border-subtle: #232932; --viz-bg: #0b0e13;
    --text: #eef1f5; --text-muted: #aab3bf; --text-dim: #7b8492;
    --accent: #e0bd6a; --accent-bright: #ecd08a; --accent-soft: rgba(224,189,106,.15); --accent-2: #5cc0b2;
    --on-accent: #14171d; --link: #e6c67c; --link-2: #5cc0b2;
    --k-person:#6ea8fe; --k-tribe:#d9b45a; --k-location:#4fb3a6; --k-event:#e08a4b; --k-role:#a78bda; --k-source:#8891a0;
    --st-accepted:#7fce97; --st-disputed:#e0a25a; --st-unverified:#8891a0; --st-superseded:#6a7280;
    --danger:#f0857a; --success:#7fce97;
    --shadow: 0 14px 40px rgba(0,0,0,.5); --shadow-sm: 0 2px 8px rgba(0,0,0,.4);
    --ring: rgba(224,189,106,.55); --scroll:#2f3742; --scroll-hover:#3d4655;
  }
}

/* ---- ACCESSIBILITY: High-contrast (WCAG AAA everywhere ≥7:1) ---- */
:root[data-contrast="high"] {
  --text-muted: #3a3327; --text-dim: #463e2e;
  --link: #4a3700; --link-2: #083f39;
  --border: #8a7d63; --border-subtle: #b6a988;
  --accent-soft: rgba(201, 154, 32, 0.24);
}
:root[data-theme="dark"][data-contrast="high"],
:root[data-contrast="high"][data-theme="dark"] {
  --text: #ffffff; --text-muted: #d3dae4; --text-dim: #b7bfca;
  --link: #f0d79a; --link-2: #86d5c8; --border: #55606f; --border-subtle: #454f5d;
}
/* ---- ACCESSIBILITY: text size ---- */
:root[data-fontsize="lg"]  { --fs-root: 16px; }
:root[data-fontsize="xl"]  { --fs-root: 18px; }
:root[data-fontsize="xxl"] { --fs-root: 20px; }
/* ---- ACCESSIBILITY: comfortable spacing ---- */
:root[data-spacing="loose"] { --lh: 1.75; --ls: 0.012em; }
/* ---- ACCESSIBILITY: dyslexia-friendly / plain typeface ---- */
:root[data-typeface="readable"] {
  --sans: "Atkinson Hyperlegible", "Verdana", "Trebuchet MS", Tahoma, sans-serif;
  --serif: "Atkinson Hyperlegible", "Verdana", Tahoma, sans-serif;
}
/* ---- ACCESSIBILITY: reduced motion ---- */
:root[data-motion="reduce"] *,
:root[data-motion="reduce"] *::before,
:root[data-motion="reduce"] *::after {
  animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important; scroll-behavior: auto !important;
}
@media (prefers-reduced-motion: reduce) {
  :root:not([data-motion="off"]) *,
  :root:not([data-motion="off"]) *::before,
  :root:not([data-motion="off"]) *::after {
    animation-duration: 0.001ms !important; transition-duration: 0.001ms !important;
  }
}
/* ---- ACCESSIBILITY: always-underline links ---- */
:root[data-links="underline"] a:not(.btn):not(.nav-item) { text-decoration: underline; text-underline-offset: 2px; }

* { box-sizing: border-box; }
/* Author display rules (.modal-backdrop=grid, .drawer/.view=flex/absolute) outrank the
   UA [hidden]{display:none} rule, so the hidden attribute alone won't hide them. Force it. */
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
html { font-size: var(--fs-root); }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
  line-height: var(--lh);
  letter-spacing: var(--ls);
  -webkit-font-smoothing: antialiased;
  transition: background .2s ease, color .2s ease;
}
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 10px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--scroll-hover); }
* { scrollbar-color: var(--scroll) transparent; }
/* AAA-grade focus: thick, high-contrast ring that never relies on colour alone */
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; border-radius: 5px; }
a { color: var(--link); }
.skip-link {
  position: fixed; left: 12px; top: -60px; z-index: 200; background: var(--accent); color: var(--on-accent);
  padding: 10px 16px; border-radius: var(--r-sm); font-weight: 600; transition: top .15s; text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ---------- layout shell ---------- */
/* Sidebar spans full height; a sticky topbar sits over the main content. minmax(0,1fr) on the
   content row keeps .main exactly viewport-tall (a long view can't push it past 100vh). */
.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "sidebar topbar" "sidebar main";
  height: 100vh;
}
.sidebar { grid-area: sidebar; }
.topbar  { grid-area: topbar; }
.main    { grid-area: main; }

/* ---------- sticky topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px; height: 52px;
  background: color-mix(in srgb, var(--bg-panel) 90%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-feature {
  display: inline-flex; align-items: center; gap: 7px; text-decoration: none;
  padding: 6px 12px; border-radius: var(--r-pill); font-size: 13px; font-weight: 600;
  color: var(--on-accent); background: linear-gradient(135deg, var(--accent-bright), var(--accent));
  box-shadow: var(--shadow-sm); transition: filter .15s, transform .12s;
}
.topbar-feature:hover { filter: brightness(1.05); transform: translateY(-1px); }
.topbar-feature .ico-sm { stroke: none; fill: currentColor; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.topbar-links { display: flex; align-items: center; gap: 2px; }
.topbar-link {
  text-decoration: none; color: var(--text-muted); font-size: 13px; font-weight: 500;
  padding: 7px 12px; border-radius: var(--r-sm); transition: background .15s, color .15s;
}
.topbar-link:hover { background: var(--bg-hover); color: var(--text); }
.topbar-link.active { color: var(--link); background: var(--accent-soft); font-weight: 600; }
.topbar-sep { width: 1px; height: 22px; background: var(--border); margin: 0 6px; }
.topbar .icon-btn { padding: 7px; border-radius: 8px; color: var(--text-muted); }
.topbar .icon-btn:hover { background: var(--bg-hover); color: var(--text); }

@media (max-width: 720px) {
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-feature span { display: none; }
  .topbar-link { padding: 7px 8px; }
}

.sidebar {
  display: flex; flex-direction: column;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  min-height: 0; overflow-y: auto;            /* long nav scrolls inside the sidebar, not the page */
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 16px; margin-bottom: 4px; border-bottom: 1px solid var(--border-subtle); }
.brand-mark {
  width: 34px; height: 34px; display: grid; place-items: center;
  font-size: 18px; color: var(--on-accent);
  background: linear-gradient(135deg, var(--accent-bright), var(--accent));
  border-radius: 9px; box-shadow: 0 2px 10px var(--accent-soft);
}
.brand-title { font-family: var(--serif); font-size: 17px; letter-spacing: .3px; }
.brand-sub { font-size: 11px; color: var(--text-dim); letter-spacing: .4px; text-transform: uppercase; }

.nav { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 11px;
  padding: 8px 11px; border: 0; background: transparent;
  color: var(--text-muted); font-size: 13.5px; font-family: inherit; font-weight: 500;
  border-radius: var(--r-sm); cursor: pointer; text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.nav-item.active::before {
  content: ""; position: absolute; left: -12px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 0 3px 3px 0; background: var(--accent);
}
.nav-item.active .ico { stroke: var(--link); }
.ico { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.ico-sm { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding-top: 12px; }
.stats { display: flex; flex-wrap: wrap; gap: 6px; }
.stat {
  font-size: 11px; color: var(--text-muted); background: var(--bg-elevated);
  border: 1px solid var(--border-subtle); border-radius: var(--r-pill); padding: 3px 9px;
}
.stat b { color: var(--text); font-weight: 600; }
.conn { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--text-dim); padding: 0 4px; }
.conn .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--st-unverified); }
.conn.ok .dot { background: var(--st-accepted); box-shadow: 0 0 8px var(--st-accepted); }
.conn.bad .dot { background: var(--st-disputed); }

.main { position: relative; overflow: hidden; }
.view { position: absolute; inset: 0; }

/* ---------- primitives ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font-family: inherit; font-size: 13.5px; font-weight: 500;
  padding: 9px 15px; border-radius: var(--r-sm); border: 1px solid transparent;
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.btn-primary { background: linear-gradient(135deg, var(--accent-bright), var(--accent)); color: var(--on-accent); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.07); box-shadow: 0 4px 16px rgba(201,162,74,.3); }
.btn-ghost { background: var(--bg-elevated); color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { background: transparent; border: 0; color: var(--text-dim); font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }

.input {
  width: 100%; font-family: inherit; font-size: 14px; color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 10px 13px; transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: var(--text-dim); }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.textarea { resize: vertical; line-height: 1.55; font-family: inherit; }

.row { display: flex; gap: 8px; align-items: center; }
.muted { color: var(--text-muted); }
.small { font-size: 12px; }
.spacer { flex: 1; }

/* chips / badges */
.chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px;
  padding: 3px 10px; border-radius: var(--r-pill);
  background: var(--bg-elevated); border: 1px solid var(--border-subtle); color: var(--text-muted);
}
.chip .k-dot { width: 7px; height: 7px; border-radius: 50%; }
.badge { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px; padding: 2px 7px; border-radius: 5px; }
.badge.accepted { color: var(--st-accepted); background: rgba(95,184,122,.13); }
.badge.disputed { color: var(--st-disputed); background: rgba(224,136,59,.14); }
.badge.unverified { color: var(--st-unverified); background: rgba(122,130,140,.13); }
.badge.superseded { color: var(--st-superseded); background: rgba(90,96,104,.13); }

/* kind colours */
.k-person { color: var(--k-person); } .bg-person { background: var(--k-person); }
.k-tribe { color: var(--k-tribe); } .bg-tribe { background: var(--k-tribe); }
.k-location { color: var(--k-location); } .bg-location { background: var(--k-location); }
.k-event { color: var(--k-event); } .bg-event { background: var(--k-event); }
.k-role { color: var(--k-role); } .bg-role { background: var(--k-role); }
.k-source { color: var(--k-source); } .bg-source { background: var(--k-source); }

/* ---------- header (per view) ---------- */
.vhead {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 24px; border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg-panel) 88%, transparent); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 5;
}
.vhead h2 { font-family: var(--serif); font-size: 19px; margin: 0; font-weight: 600; color: var(--text); }
.vhead .sub { color: var(--text-muted); font-size: 12.5px; }

/* ============================================================
   CHAT view
   ============================================================ */
.chat-wrap { display: flex; flex-direction: column; height: 100%; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 28px 0; }
.chat-inner { max-width: 760px; margin: 0 auto; padding: 0 24px; display: flex; flex-direction: column; gap: 22px; }

.welcome { text-align: center; padding: 56px 20px; }
.welcome .big { font-family: var(--serif); font-size: 27px; margin-bottom: 8px; }
.welcome p { color: var(--text-muted); max-width: 480px; margin: 0 auto 26px; }
.suggest { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; max-width: 560px; margin: 0 auto; }
.suggest button {
  text-align: left; padding: 13px 15px; border-radius: var(--r); cursor: pointer;
  background: var(--bg-panel); border: 1px solid var(--border-subtle); color: var(--text-muted);
  font-family: inherit; font-size: 13px; transition: all .15s;
}
.suggest button:hover { border-color: var(--accent); color: var(--text); transform: translateY(-1px); }

.msg { display: flex; gap: 13px; }
.msg .avatar {
  flex: none; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
}
.msg.user .avatar { background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text-muted); }
.msg.bot .avatar { background: linear-gradient(135deg, var(--accent-bright), var(--accent)); color: var(--on-accent); }
.msg .body { flex: 1; min-width: 0; padding-top: 3px; }
.msg.user .body { color: var(--text); font-weight: 500; }

.answer { font-size: 14.5px; }
.answer h1, .answer h2, .answer h3 { font-family: var(--serif); margin: 18px 0 8px; }
.answer h3 { font-size: 16px; }
.answer p { margin: 0 0 12px; }
.answer ul, .answer ol { margin: 0 0 12px; padding-left: 22px; }
.answer li { margin: 4px 0; }
.answer strong { color: #fff; }
.answer code { font-family: var(--mono); font-size: 12.5px; background: var(--bg-elevated); padding: 1px 5px; border-radius: 4px; }
.answer a { color: var(--accent-bright); }
.answer .src-cite { color: var(--accent); font-weight: 600; }

.retrieval { margin-top: 14px; padding-top: 13px; border-top: 1px dashed var(--border); }
.retrieval .rlabel { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim); margin-bottom: 8px; }
.retrieval .chips { display: flex; flex-wrap: wrap; gap: 6px; }

.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,60%,100% { opacity: .25; } 30% { opacity: 1; } }

.composer { border-top: 1px solid var(--border-subtle); padding: 16px 24px; background: var(--bg); }
.composer-inner { max-width: 760px; margin: 0 auto; display: flex; gap: 10px; align-items: flex-end; }
.composer .input { border-radius: var(--r); }
.composer .grow { flex: 1; }

/* ============================================================
   MAP view
   ============================================================ */
.map-wrap { display: flex; flex-direction: column; height: 100%; }
.atlas-body { flex: 1; display: flex; min-height: 0; }
#leaflet { flex: 1; background: #e8eef3; }
.leaflet-container { background: #e8eef3; font-family: var(--sans); }

/* right panel */
.atlas-panel { width: 320px; flex: 0 0 320px; display: flex; flex-direction: column;
  border-left: 1px solid var(--border); background: var(--bg-elevated); min-height: 0; }
.atlas-phead { padding: 12px 14px 8px; font-weight: 600; font-size: 13px; letter-spacing: .02em;
  color: var(--text); border-bottom: 1px solid var(--border); }
.atlas-search { margin: 10px 12px; }
.atlas-filter:not(:empty) { padding: 0 12px 8px; }
.atlas-chip { display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  background: rgba(201,162,74,.14); color: var(--accent-bright); border: 1px solid rgba(201,162,74,.35);
  border-radius: 999px; padding: 4px 10px; font-size: 12px; }
.atlas-chip span { opacity: .7; }
.atlas-list { flex: 1; overflow-y: auto; padding: 4px 6px 16px; }
.atlas-group { position: sticky; top: 0; background: var(--bg-elevated); z-index: 1;
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim);
  padding: 10px 8px 4px; }
.atlas-item { display: flex; align-items: center; gap: 8px; padding: 7px 9px; border-radius: var(--r-sm);
  cursor: pointer; color: var(--text); transition: background .12s; }
.atlas-item:hover { background: rgba(255,255,255,.05); }
.atlas-item.active { background: rgba(201,162,74,.18); box-shadow: inset 2px 0 0 var(--accent); }
.atlas-item .ai-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.atlas-item .ai-count { font-size: 11px; color: var(--text-dim); background: rgba(255,255,255,.06);
  border-radius: 999px; padding: 1px 7px; min-width: 20px; text-align: center; }
.empty.sm { padding: 18px 12px; font-size: 13px; color: var(--text-dim); }

/* marker highlight states (driven by panel cross-link) — keep the -45deg pin rotation */
.hist-marker { transition: transform .14s ease, box-shadow .14s ease; }
.hist-marker.hl { transform: rotate(-45deg) scale(1.6) !important; z-index: 500; }
.hist-marker.glow { transform: rotate(-45deg) scale(1.35) !important; box-shadow: 0 0 0 3px rgba(201,162,74,.45); }

/* ============ Timeline view ============ */
.tl-wrap { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.topic-select { background: var(--bg-elevated); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 6px 10px; font-size: 12.5px; max-width: 280px; cursor: pointer; }
.tl-tools { padding: 0 4px 8px; display: flex; gap: 10px; align-items: center; }
.tl-search { max-width: 360px; flex: 1; }
.tl-focus { white-space: nowrap; font-size: 12.5px; }
.tl-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 4px 12px; }
.tl-chip { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 12px;
  background: var(--bg-elevated); color: var(--text-muted); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 11px; transition: all .12s; }
.tl-chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--text-dim)); }
.tl-chip:hover { color: var(--text); border-color: var(--text-dim); }
.tl-chip.on { color: var(--text); border-color: var(--c, var(--accent)); background: rgba(255,255,255,.05); }
.tl-list { flex: 1; overflow-y: auto; padding: 4px 2px 40px; }
/* era band */
.tl-band { margin-bottom: 10px; }
.tl-band-head { position: sticky; top: 0; z-index: 2; background: var(--bg);
  display: flex; align-items: baseline; gap: 10px; padding: 10px 6px 6px;
  border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.tl-band-name { font-family: var(--serif); font-size: 15px; color: var(--accent-bright); }
.tl-band-sub { font-size: 11.5px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .05em; }
/* row: label | time track | meta */
.tl-row { display: grid; grid-template-columns: 220px 1fr 250px; align-items: center; gap: 10px;
  padding: 3px 8px; border-radius: var(--r-sm); cursor: pointer; transition: background .12s; }
.tl-row:hover { background: rgba(255,255,255,.05); }
.tl-label { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tl-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--text-dim)); flex: 0 0 auto;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c, #888) 20%, transparent); }
.tl-name { font-size: 13.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* the per-era time axis + span bar */
.tl-track { position: relative; height: 16px; background: rgba(255,255,255,.04);
  border-radius: 4px; overflow: hidden; }
.tl-track::before, .tl-track::after { content: ""; position: absolute; top: 0; bottom: 0; width: 1px;
  background: var(--border); }
.tl-track::before { left: 0; } .tl-track::after { right: 0; }
.tl-bar { position: absolute; top: 4px; height: 8px; min-width: 4px; border-radius: 4px;
  background: var(--c, var(--text-dim)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--c,#888) 50%, transparent); }
.tl-bar.point { width: 8px; height: 8px; border-radius: 50%; top: 4px; transform: translateX(-4px); }
.tl-meta { display: flex; align-items: center; gap: 7px; justify-content: flex-end; }
.tl-date { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; }
.tl-dur { font-size: 10px; color: var(--text-dim); background: rgba(255,255,255,.06);
  border-radius: 999px; padding: 1px 6px; white-space: nowrap; }
.tl-type { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--c, var(--text-dim));
  border: 1px solid color-mix(in srgb, var(--c, #888) 45%, transparent); border-radius: 4px; padding: 1px 5px; }
.tl-pin { font-size: 11px; opacity: .85; }
/* expand chevron + nested (contextual) timeline */
.tl-exp { flex: 0 0 auto; cursor: pointer; font-size: 11px; color: var(--accent-bright);
  background: rgba(201,162,74,.12); border: 1px solid rgba(201,162,74,.3); border-radius: 999px;
  padding: 0 7px; line-height: 17px; white-space: nowrap; }
.tl-exp:hover { background: rgba(201,162,74,.22); }
.tl-exp.open { background: rgba(201,162,74,.22); }
.tl-nested { margin: 2px 0 8px 18px; padding: 6px 8px 8px; border-left: 2px solid rgba(201,162,74,.3);
  background: rgba(255,255,255,.025); border-radius: 0 var(--r-sm) var(--r-sm) 0; }
.tl-nested-head { font-size: 11px; color: var(--text-dim); margin: 2px 0 6px; letter-spacing: .02em; }
.tl-nested-empty { font-size: 12px; color: var(--text-dim); padding: 4px; }
.tl-nrow { display: grid; grid-template-columns: 240px 1fr 110px; align-items: center; gap: 10px;
  padding: 2px 6px; border-radius: var(--r-sm); cursor: pointer; }
.tl-nrow:hover { background: rgba(255,255,255,.05); }
.tl-nlabel { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.tl-pred { font-size: 9.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); }
.tl-nname { font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-ntrack { height: 12px; background: rgba(255,255,255,.03); }
.tl-ndate { font-size: 11px; color: var(--text-muted); text-align: right; white-space: nowrap; }
.map-search { display: flex; gap: 10px; flex: 1; max-width: 520px; }
.map-legend { display: flex; gap: 14px; align-items: center; }
.leg { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-muted); }
.leg .d { width: 9px; height: 9px; border-radius: 50%; }
.hist-marker {
  width: 16px; height: 16px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg);
  border: 2px solid #0a0b0d; box-shadow: 0 2px 6px rgba(0,0,0,.5);
}
.hist-marker.hl { width: 22px; height: 22px; box-shadow: 0 0 0 4px var(--accent-soft), 0 2px 8px rgba(0,0,0,.6); }
.leaflet-popup-content-wrapper { background: var(--bg-elevated); color: var(--text); border-radius: var(--r-sm); box-shadow: var(--shadow); }
.leaflet-popup-tip { background: var(--bg-elevated); }
.leaflet-popup-content { margin: 11px 14px; }
.pop-name { font-family: var(--serif); font-size: 15px; margin-bottom: 2px; }
.pop-meta { font-size: 11.5px; color: var(--text-muted); }
.pop-link { color: var(--accent-bright); background: none; border: none; padding: 0; font: inherit;
  font-size: 12px; cursor: pointer; margin-top: 6px; display: inline-block; text-align: left; }
.pop-link:hover { text-decoration: underline; }

/* ============================================================
   GRAPH view
   ============================================================ */
.graph-wrap { display: flex; flex-direction: column; height: 100%; }
#cy { flex: 1; background: radial-gradient(circle at 50% 40%, #1b1f27, var(--viz-bg)); }
.graph-controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.legend-kinds { display: flex; gap: 12px; flex-wrap: wrap; }
.seg { display: flex; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; }
.seg button { background: transparent; border: 0; color: var(--text-muted); padding: 7px 12px; font-size: 12.5px; font-family: inherit; cursor: pointer; }
.seg button:hover { background: var(--bg-hover); color: var(--text); }
.seg button.active { background: var(--accent-soft); color: var(--accent-bright); }

/* ============================================================
   LIBRARY view
   ============================================================ */
.lib-wrap { display: flex; flex-direction: column; height: 100%; }
.lib { flex: 1; overflow-y: auto; padding: 26px 28px 60px; max-width: 1040px; width: 100%; margin: 0 auto; }
.lib-section { margin-bottom: 34px; }
.lib-sec-title { font-family: var(--serif); font-size: 15px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .6px; margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border-subtle); }

.lib-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.action-card { display: flex; align-items: center; gap: 13px; text-align: left; padding: 15px 16px; border-radius: var(--r); cursor: pointer; background: var(--bg-panel); border: 1px solid var(--border-subtle); color: var(--text); font-family: inherit; transition: all .15s; }
.action-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.ac-ico { width: 38px; height: 38px; flex: none; display: grid; place-items: center; font-size: 18px; background: var(--bg-elevated); border-radius: 10px; }
.ac-title { font-weight: 600; font-size: 14px; }
.ac-desc { font-size: 12px; color: var(--text-dim); }

.src-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 13px; }
.src-card { padding: 16px; border-radius: var(--r); cursor: pointer; background: var(--bg-panel); border: 1px solid var(--border-subtle); transition: all .15s; }
.src-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.src-title { font-family: var(--serif); font-size: 16px; margin-bottom: 8px; }
.src-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.src-snip { line-height: 1.5; }
.src-read { color: var(--accent-bright); font-size: 12.5px; margin-top: 10px; font-weight: 500; }
.src-fulltext { white-space: pre-wrap; line-height: 1.7; font-size: 13.5px; color: var(--text); font-family: var(--serif); }

.ent-toolbar { margin-bottom: 16px; max-width: 360px; }
.ent-groups { display: flex; flex-direction: column; gap: 20px; }
.kind-head { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 9px; }
.kind-count { font-size: 11px; color: var(--text-dim); background: var(--bg-elevated); border-radius: var(--r-pill); padding: 1px 8px; }
.ent-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ent-chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px; border-radius: var(--r-pill); cursor: pointer; background: var(--bg-elevated); border: 1px solid var(--border-subtle); color: var(--text); font-family: inherit; font-size: 13px; transition: all .14s; }
.ent-chip:hover { border-color: var(--accent); color: var(--accent-bright); }
.ent-date { font-size: 11px; color: var(--text-dim); }

/* ============================================================
   ENCYCLOPEDIA view (the refined outcome)
   ============================================================ */
.enc-wrap { display: flex; flex-direction: column; height: 100%; }
.enc-body { flex: 1; display: grid; grid-template-columns: 300px 1fr; min-height: 0; }
.enc-tree { overflow-y: auto; border-right: 1px solid var(--border-subtle); padding: 12px 6px; background: var(--bg-panel); }
.enc-run { margin-bottom: 10px; }
.enc-node { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: var(--r-sm); cursor: pointer; font-size: 13.5px; color: var(--text-muted); transition: background .12s, color .12s; }
.enc-node:hover { background: var(--bg-hover); color: var(--text); }
.enc-node.active { background: var(--accent-soft); color: var(--accent-bright); }
.enc-node.no-art { cursor: default; color: var(--text-dim); }
.enc-node.no-art:hover { background: transparent; color: var(--text-dim); }
.enc-dot { color: var(--accent); font-size: 11px; }
.enc-article { overflow-y: auto; padding: 30px 40px 60px; }
.enc-article .answer { max-width: 720px; }
.enc-sources { max-width: 720px; margin-top: 24px; padding-top: 16px; border-top: 1px solid var(--border-subtle); }
.enc-sources .rlabel { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-dim); margin-bottom: 8px; }
.src-ref { display: block; padding: 6px 0; color: var(--accent-bright); font-size: 13px; text-decoration: none; }
.src-ref:hover { text-decoration: underline; }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.6); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 100; }
.modal { width: min(560px, 92vw); background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); padding: 22px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-head h3 { font-family: var(--serif); margin: 0; font-size: 18px; }
.modal .input { margin-top: 12px; }
.modal-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; }

/* ---------- drawer ---------- */
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(380px, 90vw); background: var(--bg-panel); border-left: 1px solid var(--border); box-shadow: var(--shadow); z-index: 90; display: flex; flex-direction: column; animation: slideIn .2s ease; }
@keyframes slideIn { from { transform: translateX(20px); opacity: .4; } to { transform: none; opacity: 1; } }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; padding: 20px; border-bottom: 1px solid var(--border-subtle); }
.drawer-kind { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; font-weight: 600; margin-bottom: 3px; }
.drawer-head h3 { font-family: var(--serif); margin: 0; font-size: 19px; }
.drawer-body { padding: 18px 20px; overflow-y: auto; }
.fact { padding: 11px 0; border-bottom: 1px solid var(--border-subtle); }
.fact:last-child { border: 0; }
.fact .rel { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-dim); }
.fact .ftext { margin-top: 2px; }
.fact .fmeta { margin-top: 5px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.kv { display: flex; gap: 8px; margin: 7px 0; font-size: 13px; }
.kv .key { color: var(--text-dim); min-width: 92px; }

/* ---------- toast ---------- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text); padding: 11px 18px; border-radius: var(--r-sm); box-shadow: var(--shadow); z-index: 200; font-size: 13.5px; }
.toast.err { border-color: var(--st-disputed); }

.empty { display: grid; place-items: center; height: 100%; color: var(--text-dim); text-align: center; }
.empty .e-ico { font-size: 34px; opacity: .5; margin-bottom: 10px; }

/* ---- global search (sidebar) + nav groups ---- */
.globalsearch { display: flex; align-items: center; gap: 8px; margin: 4px 0 14px; padding: 8px 10px;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--r-sm); color: var(--text-dim); }
.globalsearch:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.globalsearch .ico-sm { width: 15px; height: 15px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; }
.gs-input { flex: 1; background: none; border: none; outline: none; color: var(--text); font: inherit; font-size: 13px; }
.gs-input::placeholder { color: var(--text-dim); }
.nav-group { font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase; color: var(--text-dim);
  margin: 14px 0 5px 10px; font-weight: 600; }
.nav-group:first-child { margin-top: 2px; }

/* ---- segment shell (hadith / narrators / texts / search) ---- */
.seg-wrap { display: flex; flex-direction: column; height: 100%; }
.seg-body { flex: 1; overflow: auto; padding: 4px 2px 24px; }

/* ---- paged-list primitive ---- */
.pl-bar { display: flex; align-items: center; gap: 12px; padding: 2px 2px 12px; position: sticky; top: 0;
  background: var(--bg); z-index: 2; }
.pl-search { flex: 1; }
.pl-count { white-space: nowrap; }
.pl-results { display: flex; flex-direction: column; gap: 8px; }
.pl-loading, .empty-sm { padding: 16px 4px; color: var(--text-dim); }
.pl-pager { display: flex; align-items: center; justify-content: center; gap: 14px; padding: 16px 0 4px; }
.pl-pageinfo { min-width: 120px; text-align: center; }

/* ---- hadith cards ---- */
.hadith-card { background: var(--bg-panel); border: 1px solid var(--border-subtle); border-radius: var(--r);
  padding: 16px 18px; border-left: 3px solid var(--border); }
.hadith-card.g-sahih { border-left-color: #8ecb7a; }
.hadith-card.g-hasan { border-left-color: #e0bd6a; }
.hadith-card.g-daif  { border-left-color: #d98a8a; }
.hadith-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 9px; }
.hadith-ref { font-variant-numeric: tabular-nums; }
.hadith-en { font-family: var(--serif); font-size: 16.5px; line-height: 1.72; color: var(--text); }
.hadith-en .hadith-p { margin: 0 0 0.85em; }
.hadith-en .hadith-p:last-child { margin-bottom: 0; }
.hadith-ar { font-family: var(--quran-ar); font-size: 21px; line-height: 1.95; color: var(--text); margin-top: 10px; }

/* ===== Hadith landing — collection index (mirrors the Qur'an sūra grid) ===== */
.seg-wrap.hadith .seg-body { padding: 0 24px 40px; }
.hadith-index { max-width: 1080px; margin: 0 auto; padding-top: 14px; }
.hidx-search { display: flex; gap: 10px; margin-bottom: 12px; }
.hidx-input { flex: 1; font-size: 14.5px; padding: 12px 16px; }
.hidx-note { max-width: 780px; margin: 0 0 16px; line-height: 1.5; }
.hidx-pills { display: inline-flex; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 3px; gap: 2px; margin-bottom: 8px; }
.hidx-pill { background: none; border: none; color: var(--text-muted); cursor: pointer; font: inherit;
  font-size: 12.5px; padding: 6px 15px; border-radius: var(--r-pill); }
.hidx-pill.on { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.hidx-section { margin-top: 20px; }
.hidx-sec-h { display: flex; align-items: baseline; gap: 8px; padding-bottom: 10px; margin-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle); }
.hidx-sec-title { font-family: var(--serif); font-size: 15px; font-weight: 600; color: var(--text);
  text-transform: uppercase; letter-spacing: .5px; }
.hcoll-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 12px; }
.hcoll-card { display: flex; flex-direction: column; gap: 4px; min-height: 132px; text-align: left;
  padding: 15px 16px; border-radius: var(--r); background: var(--bg-panel); border: 1px solid var(--border-subtle);
  cursor: pointer; color: inherit; font: inherit; transition: all .15s; }
.hcoll-card:hover { background: var(--bg-elevated); border-color: var(--accent);
  transform: translateY(-2px); box-shadow: 0 6px 22px rgba(201,162,74,.12); }
.hcoll-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.hcoll-title { font-family: var(--serif); font-size: 16px; font-weight: 600; color: var(--text); line-height: 1.25; }
.hcoll-badge { flex: 0 0 auto; font-size: 10px; text-transform: uppercase; letter-spacing: .4px;
  color: var(--text-dim); border: 1px solid var(--border); border-radius: var(--r-pill); padding: 1px 7px; }
.hcoll-badge.graded { color: var(--accent-bright); border-color: var(--accent-soft); background: var(--accent-soft); }
.hcoll-author { line-height: 1.3; }
.hcoll-spacer { flex: 1; }
.hcoll-count { font-size: 13px; color: var(--text); }
.hcoll-count b { font-variant-numeric: tabular-nums; color: var(--accent-bright); }
.hcoll-nograde { font-style: italic; }
.gradebar { display: flex; height: 7px; border-radius: 999px; overflow: hidden; margin-top: 8px;
  background: rgba(255,255,255,.06); }
.gradebar > span { height: 100%; }
.gb-sahih { background: #8ecb7a; } .gb-hasan { background: #e0bd6a; }
.gb-daif { background: #d98a8a; } .gb-other { background: rgba(255,255,255,.2); }

/* ===== Hadith list — centered reading column ===== */
.hadith-back { display: inline-block; padding: 12px 0 4px; }
.hadith-lhead { max-width: 820px; margin: 0 auto 4px; }
.hadith-lhead h3 { font-family: var(--serif); font-size: 20px; font-weight: 600; margin: 0 0 2px; }
.hadith-nonote { margin-top: 8px; padding: 8px 12px; border-left: 2px solid var(--border);
  background: var(--bg-panel); border-radius: 0 6px 6px 0; line-height: 1.5; }
.hadith-filters { max-width: 820px; margin: 0 auto; position: sticky; top: 0; z-index: 4;
  background: linear-gradient(var(--bg) 78%, transparent); padding-top: 8px; }
.hadith-reader { max-width: 820px; margin: 0 auto; }
.hadith-reader .pl-results { display: flex; flex-direction: column; gap: 14px; }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font: inherit; font-size: 12px;
  padding: 4px 0; }
.link-btn:hover { color: var(--accent-bright); text-decoration: underline; }
.narrator-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px;
  padding-top: 10px; border-top: 1px solid var(--border-subtle); }
.ent-chip.sm { padding: 4px 9px; font-size: 12px; }

/* ---- narrators ---- */
.narrator-row { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  background: var(--bg-panel); border: 1px solid var(--border-subtle); border-radius: var(--r-sm);
  padding: 10px 14px; color: var(--text); font: inherit; transition: background .14s, border-color .14s; }
.narrator-row:hover { background: var(--bg-hover); border-color: var(--border); }
.nr-name { flex: 1; font-size: 14px; }
.chip.sm { padding: 2px 8px; font-size: 11px; }
.ent-date { color: var(--accent); font-size: 12px; }
.ent-kind { margin-left: auto; }

/* ---- texts (segmented control + cards) ---- */
.segmented { display: inline-flex; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--r-pill); padding: 3px; gap: 2px; }
.seg-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font: inherit; font-size: 13px;
  padding: 6px 16px; border-radius: var(--r-pill); }
.seg-btn.active { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.text-card { background: var(--bg-panel); border: 1px solid var(--border-subtle); border-radius: var(--r);
  padding: 13px 16px; }
.text-title { color: var(--accent); font-weight: 600; font-size: 13px; margin-bottom: 6px; }
.text-body { font-family: var(--serif); font-size: 14px; line-height: 1.6; color: var(--text-muted); }

/* ---- Scholarly Q&A ---- */
.seg-wrap.qa { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.qa-layout { flex: 1; display: grid; grid-template-columns: 244px minmax(0, 1fr);
  min-height: 0; overflow: hidden; }
.qa-rail { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--border-subtle);
  padding: 12px 10px; gap: 8px; }
.qa-rail-filter { flex: 0 0 auto; font-size: 12.5px; padding: 7px 10px; }
.qa-rail-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; padding-right: 2px; }
.qa-rail-item { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%; text-align: left; background: none; border: 0; border-radius: 7px; cursor: pointer;
  color: var(--text-muted); font: inherit; font-size: 12.5px; padding: 6px 9px; line-height: 1.3; }
.qa-rail-item:hover { background: var(--bg-hover); color: var(--text); }
.qa-rail-item.active { background: var(--accent-soft); color: var(--accent-bright); font-weight: 600; }
.qa-rail-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qa-rail-count { flex: 0 0 auto; font-size: 11px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.qa-rail-item.active .qa-rail-count { color: var(--accent); }

.qa-main { min-height: 0; display: flex; flex-direction: column; padding: 12px 20px 8px; overflow: hidden; }
.qa-main .pl-bar, .qa-main .pl-pager { flex: 0 0 auto; }
.qa-main .pl-results { flex: 1; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px; padding-right: 4px; }

.qa-card { background: var(--bg-panel); border: 1px solid var(--border-subtle);
  border-radius: var(--r); padding: 16px 18px; }
.qa-cat { display: inline-flex; align-items: center; background: var(--accent-soft);
  border: 1px solid transparent; color: var(--accent-bright); cursor: pointer;
  font: inherit; font-size: 11px; font-weight: 600; letter-spacing: .3px; text-transform: uppercase;
  padding: 2px 9px; border-radius: var(--r-pill); }
.qa-cat:hover { border-color: var(--accent); }
.qa-q { font-family: var(--serif); font-size: 18px; font-weight: 600; color: var(--text);
  line-height: 1.32; margin: 9px 0 8px; }
.qa-answer { font-family: var(--serif); font-size: 14.5px; line-height: 1.7; color: var(--text-muted); }
.qa-answer p { margin: 0 0 10px; }
.qa-answer p:last-child { margin-bottom: 0; }
.qa-list { margin: 0 0 10px; padding-left: 22px; display: flex; flex-direction: column; gap: 5px; }
.qa-list li { padding-left: 3px; }
.qa-formula { color: var(--text-dim); font-style: italic; }
.qa-answer.clamped { max-height: 190px; overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, #000 60%, transparent 100%);
  mask-image: linear-gradient(180deg, #000 60%, transparent 100%); }
.qa-toggle { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit;
  font-size: 12.5px; font-weight: 600; padding: 8px 0 2px; }
.qa-toggle:hover { color: var(--accent-bright); }
.qa-src { margin-top: 12px; padding-top: 9px; border-top: 1px solid var(--border-subtle);
  font-size: 11px; color: var(--text-dim); }

/* shared block heading for the sub-panels under an answer (positions, related) */
.qa-block-title { font-size: 11px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase;
  color: var(--text-dim); margin-bottom: 8px; }

/* positions — what is held, and by whom. The attribution rail, made legible. */
.qa-positions { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-subtle); }
.qa-pos-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; align-items: baseline;
  padding: 7px 0; border-bottom: 1px dashed var(--border-subtle); }
.qa-pos-row:last-child { border-bottom: 0; padding-bottom: 0; }
.qa-pos-what { font-size: 13.5px; color: var(--text); }
.qa-pos-who { font-size: 12px; font-weight: 600; color: var(--accent-bright); text-align: right;
  white-space: nowrap; }
.qa-pos-note { grid-column: 1 / -1; }
@media (max-width: 560px) {
  .qa-pos-row { grid-template-columns: 1fr; }
  .qa-pos-who { text-align: left; white-space: normal; }
}

/* related in Chronicle — reuses the encyclopedia's entity-chip vocabulary */
.qa-related { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-subtle); }
.qa-card .enc-ent-chip { text-decoration: none; }
.enc-ent-chip.qa-ref-chip { border-color: rgba(79,179,166,.35); }
.enc-ent-chip.qa-ref-chip:hover { border-color: var(--accent-2); }

/* references-in-answer block + citation chips */
.qa-refs { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-subtle); }
.qa-refs-title { font-size: 11px; font-weight: 600; letter-spacing: .4px; text-transform: uppercase;
  color: var(--text-dim); margin-bottom: 8px; }
.qa-refs-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.cite-chip { cursor: pointer; font: inherit; font-size: 12px; padding: 4px 10px; border-radius: var(--r-pill);
  border: 1px solid var(--border); background: var(--bg-elevated); color: var(--text-muted); }
.cite-chip:hover { color: var(--text); border-color: var(--text-dim); }
.cite-chip.q { border-color: rgba(79,179,166,.4); color: var(--accent-2); }
.cite-chip.q:hover { border-color: var(--accent-2); background: rgba(79,179,166,.1); }
.cite-chip.h { border-color: rgba(201,162,74,.4); color: var(--accent-bright); }
.cite-chip.h:hover { border-color: var(--accent); background: var(--accent-soft); }

/* citation modal */
.cite-overlay { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; padding: 24px; }
.cite-box { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--r-lg, 12px);
  width: min(640px, 100%); max-height: 82vh; display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.cite-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 18px 12px; border-bottom: 1px solid var(--border-subtle); }
.cite-title { font-family: var(--serif); font-size: 17px; font-weight: 600; color: var(--text); }
.cite-sub { font-size: 11.5px; color: var(--text-dim); margin-top: 2px; }
.cite-body { padding: 16px 18px 18px; overflow-y: auto; }
.cite-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.cite-ar { font-size: 25px; line-height: 2.1; color: var(--text); text-align: right;
  margin-bottom: 12px; font-family: var(--quran-ar); }
.cite-en { font-family: var(--serif); font-size: 15px; line-height: 1.7; color: var(--text-muted); }
.cite-caveat { margin-top: 12px; font-size: 12px; color: var(--text-dim); font-style: italic;
  border-left: 2px solid var(--border); padding-left: 10px; }
.cite-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-subtle); }
.cite-grade { font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: var(--r-pill); border: 1px solid; }
.cite-grade.g-sahih { color: #8ecb7a; border-color: #8ecb7a; background: rgba(142,203,122,.12); }
.cite-grade.g-hasan { color: #e0bd6a; border-color: #e0bd6a; background: rgba(224,189,106,.12); }
.cite-grade.g-daif  { color: #d98a8a; border-color: #9c5a5a; background: rgba(217,138,138,.12); }
.cite-grade.g-other { color: #9aa2ac; border-color: #4a5058; }

@media (max-width: 720px) {
  .qa-layout { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .qa-rail { border-right: 0; border-bottom: 1px solid var(--border-subtle); max-height: 190px; }
}

/* ---- universal search groups ---- */
.search-groups { display: flex; flex-direction: column; gap: 18px; }
/* Search view scrolls its results region (header + bar stay fixed), matching the Q&A layout —
   the base .seg-wrap has no overflow, which clipped results at the bottom with no scroll. */
.seg-wrap.search { min-height: 0; }
.seg-wrap.search .pl-bar { padding: 12px 24px; }
.seg-wrap.search .search-groups { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 24px 72px; }
.search-group { background: var(--bg-panel); border: 1px solid var(--border-subtle); border-radius: var(--r); padding: 12px 16px; }
.sg-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.sg-label { font-weight: 600; color: var(--text); }
.sg-count { background: var(--bg-elevated); padding: 1px 8px; border-radius: var(--r-pill); }
.sg-head .link-btn { margin-left: auto; }
.sg-item { padding: 7px 0; border-top: 1px solid var(--border-subtle); }
.sg-item.click { cursor: pointer; }
.sg-item.click:hover .sgi-title { color: var(--accent-bright); }
.sgi-title { font-size: 14px; color: var(--text); display: inline; }
.sgi-text { margin-top: 3px; line-height: 1.5; }

/* ---- hadith facet bar + formatted cards ---- */
.facet-bar { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 2px 10px; }
.facet-sel { padding: 6px 10px; font-size: 12.5px; max-width: 220px; }
.hadith-narr { color: var(--accent-2); font-size: 12.5px; font-weight: 600; margin: 2px 0 6px; }
.chip.topic { background: var(--accent-soft); color: var(--accent-bright); border-color: transparent; }
.hadith-ents { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border-subtle);
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ent-chip.sm.alt { background: rgba(79,179,166,0.14); }

/* ---- relationship matrix heatmap ---- */
.matrix-mount { overflow: auto; }
.heatmap { display: grid; gap: 3px; min-width: 620px; align-items: stretch; }
.hm-corner { font-size: 11px; color: var(--text-dim); display: flex; align-items: flex-end; padding: 4px; }
.hm-colhead { font-size: 11px; color: var(--text-muted); text-align: center; padding: 6px 2px;
  writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
.hm-rowhead { font-size: 12.5px; color: var(--text); display: flex; align-items: center; padding: 0 8px;
  white-space: nowrap; }
.hm-cell { min-height: 40px; display: flex; align-items: center; justify-content: center;
  border-radius: 6px; font-size: 12px; color: var(--text); border: 1px solid var(--border-subtle); }
.hm-cell.has:hover { outline: 2px solid var(--accent); }

/* ---- narrator grouping + parallel narrations ---- */
.nr-name.click { cursor: pointer; }
.nr-name.click:hover { color: var(--accent-bright); }
.nr-hadiths { margin-left: auto; white-space: nowrap; }
.hadith-parallels { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chip.parallel { background: rgba(110,168,254,0.14); color: #a9c8ff; border-color: transparent; cursor: default; }

/* ===== Entity Hub — the navigation backbone ===== */
/* hub/explore scroll as a whole page (not the fixed-height flex column the source views use) */
.seg-wrap.hub, .seg-wrap.explore { display: block; height: 100%; overflow-y: auto; overflow-x: hidden; }
/* States & Aḥkām are tall custom views — let the whole column scroll (else content clips at the bottom) */
.seg-wrap.states, .seg-wrap.ahkam { height: 100%; overflow-y: auto; overflow-x: hidden; padding-bottom: 48px; }
.seg-wrap.hub { padding: 0 24px 72px; }
.seg-wrap.hub > * { max-width: 940px; margin-left: auto; margin-right: auto; }
.seg-wrap.hub .seg-body { flex: none; height: auto; overflow: visible; padding: 0; }
.hub-back { margin: 18px 0 10px; font-size: 12px; }
.hub-header {
  position: relative; padding: 22px 26px; border-radius: var(--r);
  background: linear-gradient(180deg, var(--bg-panel), var(--bg));
  border: 1px solid var(--border-subtle); border-left: 4px solid var(--kc, var(--accent));
  overflow: hidden;
}
.hub-header::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px;
  background: radial-gradient(circle, var(--kc, var(--accent)) 0%, transparent 70%);
  opacity: .06; pointer-events: none;
}
.hub-kind { font-size: 11px; text-transform: uppercase; letter-spacing: 1.4px; font-weight: 600; }
.hub-name { font-family: var(--serif); font-size: 34px; line-height: 1.1; margin: 4px 0 2px; color: var(--text); }
.hub-aliases { margin-top: 4px; }
.hub-stats { display: flex; gap: 26px; margin-top: 18px; flex-wrap: wrap; }
.hub-stat-n { font-size: 22px; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.hub-stat-l { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--text-dim); margin-top: 2px; }

.hub-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
@media (max-width: 760px) { .hub-panels { grid-template-columns: 1fr; } }
.hub-panel { background: var(--bg-panel); border: 1px solid var(--border-subtle); border-radius: var(--r); padding: 16px 18px; }
.hub-panel-h { font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--text-dim); margin-bottom: 12px; }
.hub-relgrp { margin-bottom: 12px; }
.hub-relkind { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; display: block; margin-bottom: 6px; }
.hub-chipwrap { display: flex; flex-wrap: wrap; gap: 7px; }
.ent-chip.rel { padding: 4px 4px 4px 11px; gap: 6px; border-left: 3px solid var(--kc, var(--accent)); }
.ent-chip-name { background: none; border: 0; color: var(--text); font: inherit; cursor: pointer; padding: 0; }
.ent-chip.rel:hover .ent-chip-name { color: var(--accent-bright); }
.ent-co { font-size: 10px; color: var(--text-dim); font-variant-numeric: tabular-nums; background: var(--bg); padding: 1px 6px; border-radius: 8px; }
.ent-chip-filter { background: var(--bg); border: 1px solid var(--border-subtle); color: var(--text-dim); cursor: pointer; border-radius: 6px; width: 20px; height: 20px; font-size: 12px; line-height: 1; padding: 0; }
.ent-chip-filter:hover { color: var(--accent-bright); border-color: var(--accent); }
.ent-chip.self { border-color: var(--kc); color: var(--kc); background: transparent; cursor: default; font-weight: 600; }
.hub-rels { display: flex; flex-direction: column; gap: 8px; }
.hub-rel { display: flex; align-items: baseline; gap: 8px; font-size: 13px; }
.hub-rel-pred { color: var(--text-dim); font-size: 11px; min-width: 118px; text-align: right; text-transform: lowercase; }
.hub-rel .pop-link { margin: 0; }

.hub-shortcuts { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 20px 0 6px; }
.hub-sc-label { margin-right: 4px; }
.chip.sc { cursor: pointer; transition: all .14s; }
.chip.sc:hover { border-color: var(--accent); color: var(--accent-bright); }
.hub-fbar { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin: 4px 0 8px; }
.chip.active-f { cursor: pointer; background: var(--accent-soft); border-color: var(--accent); color: var(--accent-bright); }
.chip.active-f .x { margin-left: 6px; opacity: .7; }
.hub-list-h { font-family: var(--serif); font-size: 17px; color: var(--text-muted); margin: 22px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border-subtle); scroll-margin-top: 12px; }

/* ===== Explore — collection sets landing ===== */
.seg-wrap.explore { padding: 0 28px 72px; }
.seg-wrap.explore > * { max-width: 1080px; margin-left: auto; margin-right: auto; }
.xp-sets { display: flex; flex-direction: column; gap: 28px; margin-top: 8px; }
.xp-set-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.xp-set-title { font-family: var(--serif); font-size: 19px; color: var(--text); margin: 0; }
.xp-set-blurb { margin-top: 3px; max-width: 620px; }
.xp-rail { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(170px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; scroll-snap-type: x proximity; }
.xp-rail::-webkit-scrollbar { height: 7px; }
.xp-card {
  scroll-snap-align: start; text-align: left; cursor: pointer; font-family: inherit;
  background: var(--bg-panel); border: 1px solid var(--border-subtle); border-radius: var(--r);
  border-top: 3px solid var(--kc, var(--accent)); padding: 14px 15px; transition: all .15s; min-height: 92px;
  display: flex; flex-direction: column; gap: 4px;
}
.xp-card:hover { background: var(--bg-elevated); border-color: var(--kc, var(--accent)); transform: translateY(-2px); }
.xp-card-kind { font-size: 10px; text-transform: uppercase; letter-spacing: .8px; font-weight: 600; }
.xp-card-name { font-size: 15px; color: var(--text); font-weight: 500; line-height: 1.25; }
.xp-card-meta { margin-top: auto; }

.xp-dir { margin-top: 40px; border-top: 1px solid var(--border-subtle); padding-top: 20px; }
.xp-tabs { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 0; }
.xp-tab { display: inline-flex; align-items: center; gap: 7px; padding: 6px 13px; border-radius: var(--r-pill); cursor: pointer; font-family: inherit; font-size: 13px; background: var(--bg-elevated); border: 1px solid var(--border-subtle); color: var(--text-muted); transition: all .14s; }
.xp-tab:hover { color: var(--text); border-color: var(--border); }
.xp-tab.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-bright); }
.xp-tab-n { font-size: 10px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.xp-tab.active .xp-tab-n { color: var(--accent-bright); }
.xp-search { width: 100%; margin: 6px 0 16px; }
.xp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }

.hub-desc { margin-top: 8px; max-width: 640px; color: var(--text-muted); font-size: 14px; line-height: 1.55; }

/* clickable stat tiles + flash-highlight target */
.hub-stat.clickable { cursor: pointer; background: none; border: 0; padding: 4px 8px 4px 0; margin: -4px -0 -4px 0; border-radius: var(--r-sm); font: inherit; text-align: left; transition: background .14s; }
.hub-stat.clickable:hover { background: var(--bg-hover); }
.hub-stat.clickable:hover .hub-stat-n { color: var(--accent-bright); }
.hub-stat.clickable .hub-stat-l { text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
@keyframes hubflash { 0% { box-shadow: 0 0 0 2px var(--accent); background: var(--accent-soft); } 100% { box-shadow: none; } }
.hub-flash { animation: hubflash 1.1s ease-out; border-radius: var(--r); }

/* titled collection/theme breakdown groups */
.hub-facets { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 16px; }
@media (max-width: 760px) { .hub-facets { grid-template-columns: 1fr; } }
.hub-facetgrp { background: var(--bg-panel); border: 1px solid var(--border-subtle); border-radius: var(--r); padding: 15px 17px; }
.hub-facetgrp-h { margin-bottom: 11px; }
.hub-facetgrp-title { font-family: var(--serif); font-size: 15px; color: var(--text); display: block; }
.hub-facetgrp-sub { display: block; margin-top: 2px; line-height: 1.45; }
.hub-chiprow { display: flex; flex-wrap: wrap; gap: 7px; }
.chip.sc { cursor: pointer; transition: all .14s; gap: 7px; }
.chip.sc:hover { border-color: var(--accent); color: var(--accent-bright); background: var(--accent-soft); }
.chip.sc .sc-n { font-size: 10px; color: var(--text-dim); font-variant-numeric: tabular-nums; background: var(--bg); padding: 1px 6px; border-radius: 8px; }
.chip.sc:hover .sc-n { color: var(--accent-bright); }

/* ===== Qur'an reader ===== */
.seg-wrap.quran { display: block; height: 100%; overflow-y: auto; overflow-x: hidden; padding: 0 26px 72px; }
.seg-wrap.quran > * { max-width: 900px; margin-left: auto; margin-right: auto; }
.q-index { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 11px; margin-top: 8px; }
.q-sura-card { position: relative; display: flex; align-items: center; gap: 13px; padding: 13px 15px; border-radius: var(--r); background: var(--bg-panel); border: 1px solid var(--border-subtle); cursor: pointer; text-decoration: none; color: inherit; transition: all .15s; }
.q-sura-card:hover { background: var(--bg-elevated); border-color: var(--accent); transform: translateY(-1px); }
.q-sura-num { width: 30px; height: 30px; flex-shrink: 0; display: grid; place-items: center; border-radius: 8px; background: var(--accent-soft); color: var(--accent-bright); font-size: 12px; font-variant-numeric: tabular-nums; }
.q-sura-mid { flex: 1; min-width: 0; }
.q-sura-en { font-size: 15px; color: var(--text); font-weight: 500; }
.q-sura-ar { font-family: var(--quran-ar); font-size: 20px; color: var(--accent-bright); }
.q-back { display: inline-block; margin: 16px 0 8px; font-size: 12px; }
.q-reader-head { border-bottom: 1px solid var(--border-subtle); padding-bottom: 16px; margin-bottom: 6px; }
.q-reader-title { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.q-reader-en { font-family: var(--serif); font-size: 26px; margin: 0; color: var(--text); }
.q-reader-meta { font-size: 12.5px; margin-top: 3px; }
.q-reader-ar { font-family: var(--quran-ar); font-size: 30px; color: var(--accent-bright); }
.q-controls { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; gap: 9px; padding: 12px 0; background: linear-gradient(var(--bg) 70%, transparent); }
.q-sel { width: auto; min-width: 130px; padding: 7px 11px; font-size: 13px; }
.q-translit-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); cursor: pointer; }
.q-bismillah { font-family: var(--quran-ar); font-size: 24px; color: var(--accent-bright); text-align: center; padding: 18px 0 22px; }
.q-ayah { display: flex; gap: 14px; padding: 20px 0; border-bottom: 1px solid var(--border-subtle); }
.q-ayah-num { flex-shrink: 0; width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--accent); color: var(--accent-bright); font-size: 12px; font-variant-numeric: tabular-nums; }
.q-ayah-main { flex: 1; min-width: 0; }
.q-ar { font-family: var(--quran-ar); font-size: 30px; line-height: 2.15; color: var(--text); margin-bottom: 10px; }
.q-translit { font-size: 13px; color: var(--accent-2); font-style: italic; margin-bottom: 8px; line-height: 1.6; }
.q-translit u { text-decoration: none; } .q-translit b { font-weight: 600; color: var(--text-muted); }
.q-tr { font-size: 15.5px; line-height: 1.65; color: var(--text-muted); }
.q-more { margin-top: 10px; }
.q-alltr { margin-top: 10px; border-left: 2px solid var(--border); padding: 4px 0 4px 14px; display: flex; flex-direction: column; gap: 4px; }
.q-alltr-lang { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--accent); margin-top: 8px; }
.q-alltr-row { display: flex; gap: 10px; font-size: 13px; }
.q-alltr-by { flex-shrink: 0; width: 120px; text-align: right; }
.q-alltr-txt { flex: 1; color: var(--text-muted); }

/* Qur'an reader — selective translation controls */
.q-controls { flex-direction: column; align-items: stretch; gap: 10px; }
.q-ctrl-grp { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; }
.q-compare { padding-top: 10px; border-top: 1px dashed var(--border); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.q-extras { display: flex; flex-wrap: wrap; gap: 7px; }
.q-extra { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-bright); }
.q-extra .x { background: none; border: 0; color: inherit; cursor: pointer; margin-left: 6px; font-size: 11px; opacity: .8; }
.q-extra .x:hover { opacity: 1; }
.q-tr { display: block; margin-top: 8px; }
.q-tr-label { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .5px; color: var(--accent); margin-bottom: 2px; }
.q-tr + .q-tr { border-top: 1px solid var(--border-subtle); padding-top: 8px; }

/* Entity Hub — Qur'anic verses section */
.hub-quran { margin-top: 6px; }
.hub-qverses { display: flex; flex-direction: column; gap: 8px; }
.q-verse { display: flex; flex-direction: column; gap: 3px; padding: 11px 14px; border-radius: var(--r-sm); background: var(--bg-panel); border: 1px solid var(--border-subtle); border-left: 3px solid var(--accent-2); text-decoration: none; color: inherit; transition: all .14s; }
.q-verse:hover { background: var(--bg-elevated); border-left-color: var(--accent-bright); }
.q-verse-ref { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--accent-2); }
.q-verse-txt { font-size: 14px; color: var(--text-muted); line-height: 1.55; }

/* Qur'an index — mode toggle + revelation-order list */
.q-seg { display: inline-flex; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--r-sm); overflow: hidden; margin: 6px 0 18px; }
.q-seg-btn { padding: 8px 16px; border: 0; background: transparent; color: var(--text-muted); font: inherit; font-size: 13px; cursor: pointer; transition: all .14s; }
.q-seg-btn.on { background: var(--accent-soft); color: var(--accent-bright); }
.q-rev-note { margin-bottom: 16px; line-height: 1.6; }
.q-rev-legend { display: inline-flex; gap: 10px; margin-left: 4px; }
.q-rev-key { display: inline-flex; align-items: center; gap: 5px; }
.q-rev-key::before { content: ""; width: 9px; height: 9px; border-radius: 2px; }
.q-rev-key.meccan::before { background: var(--accent); } .q-rev-key.medinan::before { background: var(--accent-2); }
.q-rev-list { display: flex; flex-direction: column; gap: 4px; }
.q-rev-item { display: flex; align-items: center; gap: 14px; padding: 9px 14px; border-radius: var(--r-sm); background: var(--bg-panel); border: 1px solid var(--border-subtle); border-left: 3px solid var(--accent); text-decoration: none; color: inherit; transition: all .13s; }
.q-rev-item.medinan { border-left-color: var(--accent-2); }
.q-rev-item:hover { background: var(--bg-elevated); }
.q-rev-ord { width: 34px; flex-shrink: 0; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-dim); font-size: 13px; }
.q-rev-name { flex: 1; color: var(--text); font-weight: 500; }
.q-rev-ar { font-family: var(--quran-ar); font-size: 19px; color: var(--accent-bright); }
.q-rev-meta { width: 150px; text-align: right; flex-shrink: 0; }
@media (max-width: 640px) { .q-rev-ar, .q-rev-meta { display: none; } }

/* Qur'an reader — related hadiths panel */
.q-relhadith { margin: 4px 0 8px; }
.q-rel-toggle { background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-left: 3px solid var(--accent-2); color: var(--text-muted); font: inherit; font-size: 13px; padding: 9px 14px; border-radius: var(--r-sm); cursor: pointer; width: 100%; text-align: left; transition: all .14s; }
.q-rel-toggle:hover { color: var(--text); background: var(--bg-hover); }
.q-rel-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.q-rel-item { padding: 11px 14px; border-radius: var(--r-sm); background: var(--bg-panel); border: 1px solid var(--border-subtle); }
.q-rel-head { display: flex; align-items: center; gap: 9px; margin-bottom: 6px; flex-wrap: wrap; }
.q-rel-phrase { font-style: italic; }
.q-rel-matn { font-size: 13.5px; color: var(--text-muted); line-height: 1.55; }

/* Map — Qur'anic places layer */
.map-quran-toggle.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-bright); }
.quran-marker { width: 15px; height: 15px; border-radius: 50%; background: var(--accent-2); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--accent-2), 0 1px 6px rgba(0,0,0,.4); }
.qpop { font-family: var(--sans); min-width: 150px; }
.qpop-approx { font-size: 10px; color: #b06a2a; background: rgba(224,136,59,.16); padding: 1px 5px; border-radius: 4px; }
.qpop-meta { font-size: 12px; color: #555; margin: 4px 0 6px; }
.qpop-link { font-size: 12px; color: #2a7; font-weight: 600; text-decoration: none; }

/* ===== per-ayah entity relationship modal ===== */
.q-ayah-actions { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; }
.qg-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(6,7,9,.72); display: grid; place-items: center; padding: 24px; backdrop-filter: blur(3px); }
.qg-modal { width: min(920px, 96vw); max-height: 92vh; display: flex; flex-direction: column; background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.qg-head { display: flex; align-items: center; justify-content: space-between; padding: 15px 18px; border-bottom: 1px solid var(--border-subtle); }
.qg-title { font-family: var(--serif); font-size: 18px; color: var(--text); }
.qg-ref { color: var(--accent-bright); }
.qg-scopes { display: flex; flex-wrap: wrap; gap: 7px; padding: 12px 18px 6px; }
.qg-scope { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border-radius: var(--r-pill); cursor: pointer; font: inherit; font-size: 12.5px; background: var(--bg-elevated); border: 1px solid var(--border-subtle); color: var(--text-muted); transition: all .14s; }
.qg-scope:hover { color: var(--text); border-color: var(--border); }
.qg-scope.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-bright); }
.qg-scope-n { font-size: 10px; background: var(--bg); padding: 1px 6px; border-radius: 8px; font-variant-numeric: tabular-nums; }
.qg-legend { display: flex; flex-wrap: wrap; gap: 16px; padding: 4px 18px 12px; font-size: 11.5px; color: var(--text-dim); }
.qg-key { display: inline-flex; align-items: center; gap: 6px; }
.qg-key i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.qg-cy { position: relative; flex: 1; min-height: 520px; background: radial-gradient(circle at 50% 40%, #1b1f27, var(--viz-bg)); }
.qg-none { position: absolute; top: 8px; left: 50%; transform: translateX(-50%); z-index: 2; background: var(--bg-elevated); padding: 4px 12px; border-radius: var(--r-pill); border: 1px solid var(--border-subtle); }

/* edge-style toggle (Separate by source ↔ Merged) */
.qg-edgemode { display: flex; align-items: center; gap: 8px; padding: 0 18px 10px; }
.qg-emode { padding: 5px 11px; border-radius: var(--r-pill); cursor: pointer; font: inherit; font-size: 12px; background: var(--bg-elevated); border: 1px solid var(--border-subtle); color: var(--text-muted); transition: all .14s; }
.qg-emode:hover { color: var(--text); border-color: var(--border); }
.qg-emode.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-bright); }

/* in-modal entity preview (node click stays on the sura page) */
.qg-detail { position: absolute; inset: 0; overflow-y: auto; padding: 16px 22px 22px; }
.qg-d-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.qg-d-foot.top { margin-bottom: 14px; }
.link-btn.accent { color: var(--accent-bright); font-weight: 600; }
.qg-d-head { margin-bottom: 14px; }
.qg-d-kind { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--accent-bright); }
.qg-d-name { font-family: var(--serif); font-size: 26px; color: var(--text); margin-top: 2px; }
.qg-d-also { margin-top: 3px; }
.qg-d-stats { display: flex; flex-wrap: wrap; gap: 26px; padding: 14px 0 4px; border-top: 1px solid var(--border-subtle); }
.qg-d-stat b { font-size: 22px; font-variant-numeric: tabular-nums; color: var(--text); display: block; }
.qg-d-stat span { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); }
.qg-d-sec { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-dim); margin: 20px 0 10px; }
.qg-d-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.qg-d-chip { display: inline-flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: var(--r-pill); cursor: pointer; font: inherit; font-size: 13px; background: var(--bg-elevated); border: 1px solid var(--border-subtle); color: var(--text); transition: all .14s; }
.qg-d-chip:hover { border-color: var(--accent); color: var(--accent-bright); }
.qg-d-chip-n { font-size: 10px; background: var(--bg); padding: 1px 6px; border-radius: 8px; color: var(--text-dim); }

/* P0.1 provenance / trust badge */
.hub-kindrow, .qg-d-kindrow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.trust-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: var(--r-pill); font-size: 11px; font-weight: 600; letter-spacing: .02em; border: 1px solid; }
.trust-badge .tb-conf { font-size: 10px; font-weight: 500; opacity: .8; font-variant-numeric: tabular-nums; }
.tb-ontology { color: #4fb3a6; border-color: #4fb3a6; background: rgba(79,179,166,.12); }
.tb-human    { color: #6ea8fe; border-color: #6ea8fe; background: rgba(110,168,254,.12); }
.tb-curated  { color: #e0bd6a; border-color: #e0bd6a; background: rgba(224,189,106,.12); }
.tb-strong   { color: #8ecb7a; border-color: #8ecb7a; background: rgba(142,203,122,.12); }
.tb-llm      { color: #9aa2ac; border-color: #4a5058; background: rgba(154,162,172,.08); }
.tb-weak     { color: #c98a4a; border-color: #7a5a2a; background: rgba(201,138,74,.10); }

/* P1.1 tafsir per-ayah expander */
.q-tafsir { margin-top: 12px; border-left: 2px solid var(--accent); padding-left: 14px; }
.q-taf-note { font-size: 11px; color: var(--accent-bright); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px; }
.q-taf-block { margin-bottom: 16px; }
.q-taf-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 5px; }
.q-taf-name { font-family: var(--serif); font-size: 15px; color: var(--text); font-weight: 600; }
.q-taf-text { font-size: 14px; line-height: 1.7; color: var(--text-muted); max-height: 420px; overflow-y: auto; }
.q-taf-text.rtl { font-size: 17px; line-height: 2; }
.q-taf-text p { margin: 0 0 9px; }
.link-btn.on { color: var(--accent-bright); font-weight: 600; }

/* P1.2 hadith authenticity grade chips */
.chip.grade { font-weight: 600; border: 1px solid; }
.chip.grade-sahih { color: #8ecb7a; border-color: #8ecb7a; background: rgba(142,203,122,.12); }
.chip.grade-hasan { color: #e0bd6a; border-color: #e0bd6a; background: rgba(224,189,106,.12); }
.chip.grade-daif  { color: #d98a8a; border-color: #9c5a5a; background: rgba(217,138,138,.12); }
.chip.grade-other { color: #9aa2ac; border-color: #4a5058; }

/* P1.3 word-by-word morphology */
.q-morph { margin-top: 12px; border-left: 2px solid var(--accent-2, #4fb3a6); padding-left: 14px; }
.q-morph-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.q-morph-word { min-width: 92px; padding: 8px 10px; border: 1px solid var(--border-subtle); border-radius: var(--r); background: var(--bg-elevated); text-align: center; }
.q-morph-form { font-size: 20px; color: var(--text); margin-bottom: 4px; }
.q-morph-pos { font-size: 10px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-dim); }
/* L2 — word-by-word gloss (translit + English) */
.q-morph-translit { font-size: 12px; font-style: italic; color: var(--accent-bright); margin-bottom: 2px; }
.q-morph-gloss { font-size: 12px; color: var(--text); margin-bottom: 4px; line-height: 1.3; }
.q-morph-lem { font-size: 14px; color: var(--text-muted); margin-top: 3px; }
/* L2 — verbs from a root (root concordance modal) */
.q-root-verbs { margin: 6px 0 12px; padding: 10px; border: 1px solid var(--border-subtle); border-radius: var(--r); background: var(--bg-elevated); }
.q-root-verbs-h { text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.q-root-verb { display: flex; gap: 12px; align-items: baseline; padding: 4px 0; border-bottom: 1px solid var(--border-subtle); }
.q-rv-ar { font-size: 17px; color: var(--text); min-width: 70px; }
.q-rv-form { font-size: 11px; color: var(--accent-bright); min-width: 54px; }
.q-rv-gloss { flex: 1; font-size: 13px; color: var(--text-muted); }
.q-morph-root { display: inline-block; margin-top: 5px; font-size: 14px; color: var(--accent-bright); background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--r-pill); padding: 1px 9px; cursor: pointer; font-family: inherit; }
.q-morph-root:hover { background: var(--accent); color: var(--on-accent); }
.q-root-occ { display: flex; gap: 14px; align-items: baseline; padding: 7px 6px; border-bottom: 1px solid var(--border-subtle); text-decoration: none; }
.q-root-occ:hover { background: var(--bg-elevated); }
.q-root-ref { color: var(--accent-bright); font-variant-numeric: tabular-nums; font-weight: 600; min-width: 54px; }
.q-root-forms { font-size: 18px; color: var(--text); }

/* P1.4 isnād chain of transmission */
.isnad { margin-top: 10px; }
.isnad-chain { margin-top: 8px; border-left: 2px solid var(--border); padding-left: 4px; }
.isnad-node { position: relative; display: flex; align-items: center; gap: 9px; padding: 5px 0 5px 16px; }
.isnad-node::before { content: ""; position: absolute; left: -5px; top: 50%; width: 8px; height: 8px; border-radius: 50%; background: var(--border); transform: translateY(-50%); }
.isnad-node.source::before { background: var(--accent); }
.isnad-name { font-size: 14px; color: var(--text); }
.isnad-name.link { background: none; border: 0; cursor: pointer; padding: 0; font: inherit; }
.isnad-name.link:hover { color: var(--accent-bright); text-decoration: underline; }
.gen-badge { font-size: 10px; text-transform: uppercase; letter-spacing: .03em; padding: 1px 8px; border-radius: var(--r-pill); border: 1px solid; }
.gen-src { color: #e0bd6a; border-color: #e0bd6a; background: rgba(224,189,106,.14); }
.gen-1 { color: #e0bd6a; border-color: #b8964a; background: rgba(224,189,106,.10); }
.gen-2 { color: #8ecb7a; border-color: #5f8f52; background: rgba(142,203,122,.10); }
.gen-3 { color: #6ea8fe; border-color: #4a6fa8; background: rgba(110,168,254,.10); }
.gen-4 { color: #a78bda; border-color: #6f5a9a; background: rgba(167,139,218,.10); }
.gen-0 { color: var(--text-dim); border-color: var(--border); }

/* P2.2 cross-corpus analytics — corpus balance bars */
.hub-corpus { margin-top: 16px; max-width: 420px; }
.hub-corpus-h { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.hub-corpus-label { font-size: 12px; font-weight: 600; color: var(--accent-bright); text-transform: uppercase; letter-spacing: .03em; }
.hub-corpus-bar, .xp-cc-bar { display: flex; height: 7px; border-radius: 4px; overflow: hidden; background: var(--bg); }
.xp-cc-bar { height: 5px; margin-top: 7px; }
.hcb-quran { background: #4fb3a6; }
.hcb-hadith { background: #c9a24a; }
.xp-cc .xp-card.cc { min-width: 150px; }

/* P2.3 grounded Ask — citations */
.cite-tag { font-family: var(--mono, monospace); font-size: 11px; color: var(--accent-bright); background: var(--accent-soft); border-radius: 4px; padding: 0 5px; font-weight: 600; }
.cite-card { border-left: 2px solid var(--border); padding: 6px 0 6px 12px; margin-top: 8px; }
.cite-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.cite-ref { font-weight: 600; color: var(--text); }
.cite-ref.link { background: none; border: 0; cursor: pointer; padding: 0; font: inherit; font-weight: 600; color: var(--accent-bright); }
.cite-ref.link:hover { text-decoration: underline; }
.cite-snip { margin-top: 4px; line-height: 1.5; }

/* P2.1 typed relationships in hub */
.hub-rel.typed { flex-wrap: wrap; }
.hub-rel-ev { margin-left: auto; font-variant-numeric: tabular-nums; opacity: .8; }

/* P4 About / governance page */
.about .ab-sec { margin: 26px 0; }
.ab-h { font-family: var(--serif); font-size: 19px; color: var(--text); margin: 0 0 3px; }
.ab-sub { margin-bottom: 12px; max-width: 720px; }
.ab-isnot { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; max-width: 820px; }
.ab-card { padding: 14px 16px; border-radius: var(--r); border: 1px solid var(--border-subtle); background: var(--bg-elevated); }
.ab-card.is { border-left: 3px solid #8ecb7a; } .ab-card.isnot { border-left: 3px solid #d98a8a; }
.ab-card b { display: block; margin-bottom: 5px; } .ab-card p { margin: 0; color: var(--text-muted); font-size: 14px; line-height: 1.55; }
.ab-tiers { display: flex; flex-direction: column; gap: 9px; max-width: 820px; }
.ab-tier { display: flex; align-items: baseline; gap: 12px; }
.ab-tier-d { flex: 1; } .ab-tier .trust-badge { flex: none; min-width: 190px; justify-content: center; }
.ab-edgekey { display: inline-flex; align-items: center; gap: 8px; min-width: 200px; font-size: 13px; color: var(--text); }
.ab-edgekey i { width: 16px; height: 4px; border-radius: 2px; }
.ab-metrics { display: grid; grid-template-columns: repeat(auto-fit,minmax(240px,1fr)); gap: 12px; max-width: 820px; }
.ab-metric { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border: 1px solid var(--border-subtle); border-radius: var(--r); background: var(--bg-elevated); }
.ab-metric-v { font-size: 26px; font-weight: 700; color: var(--accent-bright); font-variant-numeric: tabular-nums; }
.ab-metric-k { color: var(--text); font-size: 14px; }
.ab-limits { max-width: 820px; color: var(--text-muted); line-height: 1.6; padding-left: 20px; }
.ab-limits li { margin-bottom: 7px; }
/* About is an absolute .view inside an overflow:hidden .main → it must scroll internally, and its
   content sits in one centred 820px column (header bar stays full-width, its title in the column). */
.seg-wrap.about { overflow-y: auto; padding-bottom: 44px; }
.seg-wrap.about .vhead { padding-left: 0; padding-right: 0; }
.seg-wrap.about .vhead > div,
.seg-wrap.about > .page-cta,
.seg-wrap.about > .ab-sec { width: min(100% - 48px, 820px); margin-left: auto; margin-right: auto; }

/* L1.1 audio recitation */
.q-ayah-num { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.q-play { background: none; border: 1px solid var(--border); color: var(--accent-bright); border-radius: 50%; width: 26px; height: 26px; cursor: pointer; font-size: 11px; line-height: 1; padding: 0; transition: all .14s; }
.q-play:hover { background: var(--accent-soft); border-color: var(--accent); }
.q-ayah.q-playing { background: var(--accent-soft); border-radius: var(--r); }
.q-ayah.q-playing .q-play { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.q-reader-headright { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#qPlaySura { white-space: nowrap; }

/* L4.1 graph degraded banner */
.graph-degraded { margin: 0 0 10px; padding: 8px 14px; border-radius: var(--r); background: rgba(201,138,74,.12); border: 1px solid #7a5a2a; color: #d9a45a; font-size: 13px; }

/* L2.1 narrator profile modal */
.np-name { font-family: var(--serif); font-size: 20px; color: var(--text); }
.np-meta { margin-bottom: 12px; }
.np-stat { margin: 10px 0; } .np-stat b { font-size: 22px; color: var(--accent-bright); }
.np-gradehead { margin: 12px 0 5px; }
.np-bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: var(--bg); }
.np-bar .grade-sahih { background: #8ecb7a; } .np-bar .grade-hasan { background: #e0bd6a; } .np-bar .grade-daif { background: #d98a8a; }
.np-legend { margin-top: 6px; }
.np-cols { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0; }
.np-note { margin-top: 8px; padding-top: 10px; border-top: 1px solid var(--border-subtle); }

/* L3.3 story pages */
.hub-backrow { display: flex; justify-content: space-between; align-items: center; }
.story .st-hero { border-left: 4px solid var(--kc, var(--accent)); padding: 4px 0 18px 18px; margin-bottom: 8px; }
.st-kind { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--kc); margin-top: 8px; }
.st-name { font-family: var(--serif); font-size: 34px; color: var(--text); margin: 2px 0; }
.st-alias { font-size: 14px; } .st-balance { margin-top: 8px; }
.st-sec { margin: 28px 0; }
.st-h { font-family: var(--serif); font-size: 20px; color: var(--text); margin: 0 0 10px; border-bottom: 1px solid var(--border-subtle); padding-bottom: 6px; }
.st-rels { display: flex; flex-wrap: wrap; gap: 8px; }
.st-rel { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: var(--r-pill); background: var(--bg-elevated); border: 1px solid var(--border-subtle); cursor: pointer; font: inherit; }
.st-rel:hover { border-color: var(--accent); }
.st-rel-pred { color: var(--text-dim); font-size: 12px; } .st-rel-other { color: var(--accent-bright); font-weight: 600; }
.st-rel-ev { font-variant-numeric: tabular-nums; }
.st-ep { margin-bottom: 18px; padding-left: 14px; border-left: 2px solid var(--border); }
.st-ep-h { display: flex; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.st-ep-sura { font-weight: 700; color: var(--accent-bright); } .st-ep-name { font-family: var(--serif); }
.st-verse { display: flex; gap: 12px; padding: 5px 0; }
.st-vnum { color: var(--accent-bright); font-variant-numeric: tabular-nums; min-width: 56px; font-size: 13px; }
.st-vtext { color: var(--text); line-height: 1.6; }
.st-hadith { margin-bottom: 14px; }
.st-hadith-head { display: flex; gap: 8px; margin-bottom: 4px; }
.st-hadith-text { line-height: 1.55; font-size: 14px; }

/* L2.2 classical narrator reliability + weakest-link */
.rel-badge { display: inline-block; padding: 1px 8px; border-radius: var(--r-pill); font-size: 11px; font-weight: 600; color: var(--on-accent); background: var(--rc, #8a929c); }
.isnad-weakest { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0; padding: 7px 12px; border-radius: var(--r); background: color-mix(in srgb, var(--rc) 12%, transparent); border: 1px solid var(--rc); }
.iw-tag { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--rc); font-weight: 700; }
.iw-name { font-family: var(--serif); color: var(--text); }
.iw-grade { padding: 1px 8px; border-radius: var(--r-pill); font-size: 11px; font-weight: 600; color: var(--on-accent); }
.np-classical { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 10px 0; padding: 8px 10px; background: var(--bg); border-radius: var(--r); }
.isnad-node .rel-badge { margin-left: 4px; }
.rel-badge.low { opacity: .5; background: transparent; color: var(--rc); border: 1px dashed var(--rc); }

.hadith-noen { margin-top: 4px; font-style: italic; }

/* Move Q — qirāʾāt expander */
.q-qiraat { margin-top: 8px; padding: 10px 14px; background: var(--bg); border-radius: var(--r); border: 1px solid var(--border-subtle); }
.q-qir-block { padding: 10px 0; border-top: 1px solid var(--border-subtle); }
.q-qir-block:first-of-type { border-top: none; }
.q-qir-text { font-family: var(--quran-ar); font-size: 20px; line-height: 2; color: var(--text); margin: 4px 0 8px; }
.q-qir-diffs { display: flex; flex-wrap: wrap; gap: 6px; }
.q-qir-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: var(--r-pill); font-size: 14px; border: 1px solid; }
.q-qir-chip.reading { background: rgba(224,138,74,.12); border-color: #7a5a2a; }
.q-qir-chip.orthography { background: rgba(138,146,156,.1); border-color: var(--border); }
.q-qir-arrow { color: var(--text-dim); font-size: 12px; }
.q-qir-kind { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-dim); margin-left: 2px; }
.q-qir-chip.reading .q-qir-kind { color: #d9a45a; }
.q-qir-legend { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border-subtle); }

/* Move R — rijāl verification queue */
.audit-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border-subtle); }
.audit-card { padding: 14px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: var(--r); background: var(--bg-elevated); }
.audit-our { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.audit-rank { font-variant-numeric: tabular-nums; color: var(--text-dim); font-weight: 700; }
.audit-name { font-family: var(--serif); font-size: 18px; color: var(--text); }
.audit-cands { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.audit-cand { text-align: right; display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; border: 1px solid var(--border-subtle); border-radius: var(--r); background: var(--bg); cursor: pointer; min-width: 200px; }
.audit-cand:hover { border-color: var(--accent); }
.audit-cand-nm { font-family: var(--quran-ar); color: var(--text); }
.audit-sigs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 2px; }
.audit-sig { font-size: 10px; color: #8ecb7a; background: rgba(142,203,122,.12); padding: 1px 6px; border-radius: var(--r-pill); }
.audit-acts { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

/* narrator-grade panel on rijāl hubs */
.narrator-grade .ng-classical { margin-bottom: 10px; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.narrator-grade .ng-mix-h { margin: 8px 0 5px; }
.narrator-grade .np-bar { display: flex; height: 9px; border-radius: 5px; overflow: hidden; background: var(--bg); max-width: 340px; }
.narrator-grade .np-bar .grade-sahih { background: #8ecb7a; } .narrator-grade .np-bar .grade-hasan { background: #e0bd6a; } .narrator-grade .np-bar .grade-daif { background: #d98a8a; }

/* Qur'an per-ayah entity chips (next row) */
.q-ayah-ents { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* qirāʾāt transmission/uṣūl reference + phenomenon type */
.q-qir-i { margin-left: 8px; font-size: 12px; }
.q-qir-ref { margin: 6px 0 4px; padding: 8px 12px; background: var(--bg); border-radius: var(--r); border: 1px solid var(--border-subtle); }
.q-qir-ref-h { margin-bottom: 6px; }
.q-qir-isnad-step { padding: 1px 0 1px 10px; border-left: 2px solid var(--border); color: var(--text-dim); font-size: 13px; }
.q-qir-usul-h { margin: 8px 0 3px; }
.q-qir-usul { margin: 0; padding-left: 18px; } .q-qir-usul li { font-size: 13px; color: var(--text-dim); margin: 2px 0; }

/* modern qur'an audio player (sticky bottom bar) */
/* ---------- Floating recitation dock (v194) — anchored to the reader FRAME (#view-quran), so it
   is always reachable without scrolling. Compact pill when idle, expands when playing. ---------- */
.q-player { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 40;
  width: min(680px, calc(100% - 40px)); display: flex; flex-direction: column; overflow: hidden;
  background: color-mix(in srgb, var(--bg-elevated) 86%, transparent); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow), 0 10px 34px rgba(0,0,0,.28);
  backdrop-filter: blur(16px) saturate(1.2); transition: border-color .25s, box-shadow .25s, width .25s; }
.q-player.on { border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  box-shadow: var(--shadow), 0 12px 40px color-mix(in srgb, var(--accent) 22%, transparent); }
.q-player:not(.on) { width: min(380px, calc(100% - 40px)); }
.q-pl-line { height: 2px; background: var(--bg-hover); flex: none; }
.q-pl-line i { display: block; height: 100%; width: 0; background: var(--accent); box-shadow: 0 0 7px var(--accent); transition: width .15s linear; }
.q-pl-main { display: flex; align-items: center; gap: 10px; padding: 9px 12px; }
.q-pl-btn { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; transition: all .14s; padding: 0; flex: none; }
.q-pl-btn:hover { border-color: var(--accent); color: var(--accent-bright); }
.q-pl-btn.play { width: 44px; height: 44px; background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-size: 16px; }
.q-pl-btn.play:hover { color: var(--on-accent); filter: brightness(1.08); }
.q-pl-btn.sm { width: 30px; height: 30px; font-size: 12px; }
.q-pl-btn.gear.on { color: var(--accent-bright); border-color: var(--accent); background: var(--accent-soft); }
.q-pl-now { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.q-pl-ref { font-family: var(--serif); font-size: 14.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-pl-sub { font-size: 11.5px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.q-pl-seek { flex: 1.4; height: 6px; background: var(--bg-hover); border-radius: 3px; cursor: pointer; overflow: hidden; min-width: 60px; }
.q-pl-fill { height: 100%; width: 0; background: var(--accent); border-radius: 3px; transition: width .15s linear; }
.q-pl-time { white-space: nowrap; font-variant-numeric: tabular-nums; flex: none; font-size: 11.5px; }
/* collapsed (idle) → compact pill: hide the seek + time */
.q-player:not(.on) .q-pl-seek, .q-player:not(.on) .q-pl-time { display: none; }
/* settings popover (reciter / repeat / speed / sūra-jump) */
.q-pl-settings { padding: 12px 14px 14px; border-top: 1px solid var(--border-subtle); background: var(--bg-panel); display: flex; flex-direction: column; gap: 10px; }
.q-pl-field { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--text-dim); }
.q-pl-field > span:first-child { min-width: 56px; flex: none; }
.q-pl-rec, .q-pl-sura { flex: 1; max-width: 280px; }
.q-pl-modes { display: flex; flex-wrap: wrap; gap: 6px; }
.q-pl-mode { padding: 6px 11px; border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--bg); color: var(--text-dim); cursor: pointer; font-size: 12px; white-space: nowrap; transition: all .14s; }
.q-pl-mode.on { border-color: var(--accent); color: var(--accent-bright); background: var(--accent-soft); }
.q-pl-mode:hover { border-color: var(--accent); }
.q-pl-pop { padding: 12px; margin-top: 6px; background: var(--bg); border: 1px solid var(--accent); border-radius: 10px; }
.q-pl-poprow { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.q-pl-poprow > span { color: var(--text-dim); font-size: 12px; }
.q-pl-in { width: 56px; text-align: center; padding: 5px; }
@media (max-width: 640px) { .q-player, .q-player:not(.on) { width: calc(100% - 24px); bottom: 12px; } }
/* sūra-index card play button */
.q-sura-play { position: absolute; right: 12px; bottom: 9px; width: 30px; height: 30px; border-radius: 50%;
  border: 1px solid var(--border); background: var(--bg-elevated); color: var(--accent-bright); font-size: 11px;
  cursor: pointer; opacity: 0; transform: scale(.9); transition: all .14s; display: inline-flex; align-items: center; justify-content: center; }
.q-sura-card:hover .q-sura-play, .q-sura-play:focus-visible { opacity: 1; transform: scale(1); }
.q-sura-play:hover { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
@media (hover: none) { .q-sura-play { opacity: .8; transform: scale(1); } }

/* (player v2 block removed — superseded by the floating dock above, v194) */

/* A3 — encyclopedia "Sources in scripture" entity chips */
.enc-scripture { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); }
.enc-ent-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.enc-ent-chip { display: inline-flex; flex-direction: column; gap: 1px; padding: 6px 11px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-elevated); text-decoration: none; transition: border-color .14s, transform .14s; }
.enc-ent-chip:hover { border-color: var(--accent); transform: translateY(-1px); }
.enc-ent-chip .ee-name { color: var(--text); font-weight: 500; font-size: 13px; }
.enc-ent-chip .ee-cnt { font-size: 11px; }

/* A4 — disputed typed-relation styling on the hub (matches the graph view's amber) */
.hub-rel.disputed { border-left: 2px solid #e0883b; padding-left: 8px; }
.rel-disputed { color: #e0883b; font-size: 11px; font-weight: 600; white-space: nowrap; }

/* Phase B1 — States (polity lifecycle) view */
.states-body { display: grid; grid-template-columns: 1fr 360px; gap: 18px; align-items: start; }
.states-chart { position: relative; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px; padding: 28px 16px 12px; overflow: hidden; }
.states-grid { position: absolute; inset: 0; pointer-events: none; }
.states-gridline { position: absolute; top: 0; bottom: 22px; width: 1px; background: color-mix(in srgb, var(--border) 60%, transparent); }
.states-gridyear { position: absolute; top: 6px; left: 3px; font-size: 10px; color: var(--text-dim); }
.states-rows { position: relative; margin-top: 20px; display: flex; flex-direction: column; gap: 3px; }
.states-row { position: relative; height: 22px; }
.states-bar { position: absolute; height: 20px; border: none; border-radius: 5px; background: color-mix(in srgb, var(--rc) 42%, var(--bg)); border-left: 3px solid var(--rc); cursor: pointer; transition: filter .12s, transform .12s; min-width: 5px; }
.states-bar:hover { filter: brightness(1.3); transform: scaleY(1.15); z-index: 5; }
.states-bar.extant { border-right: 2px dashed var(--rc); }
/* labels rendered OUTSIDE the bar (Gantt-style) so they never truncate; flip left near the edge */
.states-lbl { position: absolute; top: 0; height: 20px; line-height: 20px; font-size: 11px; white-space: nowrap; color: var(--text); background: none; border: none; cursor: pointer; padding: 0 6px; max-width: 46%; overflow: hidden; text-overflow: ellipsis; }
.states-lbl.on-left { text-align: right; }
.states-lbl:hover { color: var(--accent-bright); }
.states-prov { margin-top: 14px; font-style: italic; }
.states-detail { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px; padding: 18px; max-height: 78vh; overflow-y: auto; position: sticky; top: 12px; }
.sd-head { border-left: 3px solid var(--rc); padding-left: 10px; margin-bottom: 10px; }
.sd-name { font-size: 18px; font-weight: 600; }
.sd-span { color: var(--text-dim); font-variant-numeric: tabular-nums; }
.sd-summary { color: var(--text); line-height: 1.5; }
.sd-facts { display: flex; flex-direction: column; gap: 5px; margin-top: 10px; }
.sd-fact { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent); padding-bottom: 4px; }
.sd-fact > span:last-child { text-align: right; }
.sd-terminated { margin-top: 12px; padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, #e0883b 12%, var(--bg)); border-left: 2px solid #e0883b; font-size: 13px; }
.sd-edges { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.sd-edge { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; }
.sd-edge.disputed { border-left: 2px solid #e0883b; }
.sd-edge-rel { color: var(--accent-bright); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; margin-right: 6px; }
.sd-edge-note { margin-top: 3px; }
.sd-prov { margin-top: 16px; font-style: italic; }
@media (max-width: 900px) { .states-body { grid-template-columns: 1fr; } }

/* Phase B2 — conflicts */
.states-body.conflicts-mode { display: block; }
.conflicts-list { display: flex; flex-direction: column; gap: 10px; max-width: 900px; }
.conflict-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; }
.conflict-card.disputed { border-left: 3px solid #e0883b; }
.conflict-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.conflict-yr { font-variant-numeric: tabular-nums; color: var(--accent-bright); font-weight: 600; min-width: 62px; }
.conflict-kind { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-dim); }
.conflict-name { font-weight: 600; font-size: 15px; }
.conflict-parties { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.party-chip { font-size: 12px; padding: 3px 9px; border-radius: 20px; background: var(--bg); border: 1px solid var(--border); color: var(--text-dim); }
.party-chip.linked { cursor: pointer; color: var(--text); }
.party-chip.linked:hover { border-color: var(--accent); color: var(--accent-bright); }
.conflict-outcome { line-height: 1.5; margin-top: 2px; }
.conflict-sig { margin-top: 5px; font-style: italic; }
.sd-conflicts { display: flex; flex-direction: column; gap: 7px; margin-top: 8px; }
.sd-conflict { padding: 6px 9px; border: 1px solid var(--border); border-radius: 7px; }
.sd-conflict.disputed { border-left: 2px solid #e0883b; }
.sd-conflict-yr { margin-right: 7px; }
.sd-conflict-name { font-weight: 500; font-size: 13px; }
.sd-conflict-out { margin-top: 3px; }

/* States/Conflicts mode toggle — ensure it renders with height and above the header */
.states-toprow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 4px 24px 8px; }
.states #statesSeg { position: relative; z-index: 3; flex: none; }
.states #statesSeg .q-seg-btn { line-height: 1.4; min-height: 34px; }
.states-reset { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; font: inherit;
  font-size: 12.5px; font-weight: 500; color: var(--text-muted); background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: var(--r-sm); padding: 7px 13px; cursor: pointer;
  transition: border-color .15s, color .15s, background .15s; white-space: nowrap; }
.states-reset:hover { border-color: var(--accent); color: var(--text); background: var(--bg-hover); }
.states-reset:active { transform: translateY(1px); }

/* Phase C — Aḥkām evidence index */
.ahkam-disclaimer { background: color-mix(in srgb, #e0883b 12%, var(--bg)); border: 1px solid color-mix(in srgb, #e0883b 40%, var(--border)); border-radius: 10px; padding: 11px 14px; margin-bottom: 18px; font-size: 13px; line-height: 1.5; }
.ahkam-cat { margin-bottom: 22px; }
.ahkam-cat-h { text-transform: uppercase; letter-spacing: .05em; font-size: 12px; color: var(--text-dim); margin-bottom: 10px; }
.ahkam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.ahkam-card { display: block; padding: 12px 14px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 10px; text-decoration: none; transition: border-color .14s, transform .14s; }
.ahkam-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.ahkam-card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.ahkam-card-en { font-weight: 600; color: var(--text); }
.ahkam-card-ar { color: var(--accent-bright); font-size: 15px; }
.ahkam-card-sum { margin: 5px 0; line-height: 1.4; }
.ahkam-works { margin-top: 20px; padding-top: 12px; border-top: 1px solid var(--border); line-height: 1.6; font-style: italic; }
/* Align exactly like the Qur'an reader: ONE centred 900px column shared by the header and the body,
   so the title and content line up on the same left edge (no full-width header band). */
.seg-wrap.ahkam { display: block; padding: 0 26px 72px; }
.seg-wrap.ahkam > * { max-width: 900px; margin-left: auto; margin-right: auto; }
.seg-wrap.ahkam .vhead { position: static; top: auto; background: none; backdrop-filter: none;
  padding-left: 0; padding-right: 0; }
.ahkam-body { padding: 16px 0 0; }
.ak-topic { max-width: none; margin: 0; }
.ahkam-back { display: inline-block; margin-bottom: 12px; }
.ak-seclabel { font-family: var(--serif); font-size: 15px; font-weight: 600; color: var(--text);
  margin: 22px 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border-subtle); }
.ak-count { font-size: 11px; color: var(--on-accent); background: var(--accent); border-radius: var(--r-pill);
  padding: 1px 8px; font-weight: 600; margin-left: 4px; vertical-align: middle; }
.ahkam-topic-head { display: flex; align-items: baseline; gap: 12px; margin: 14px 0 2px; flex-wrap: wrap; }
.ahkam-topic-head h1 { font-family: var(--serif); font-size: 26px; margin: 0; font-weight: 600; }
.ahkam-topic-ar { color: var(--link); font-size: 22px; font-family: var(--quran-ar); }
.ahkam-topic-sum { color: var(--text-muted); margin: 4px 0 16px; font-size: 15px; line-height: 1.55; max-width: 720px; }

/* evidence as reader-style verse cards */
.ak-ev-list { display: flex; flex-direction: column; gap: 12px; }
.ak-ev { padding: 16px 18px; border: 1px solid var(--border-subtle); border-radius: 12px;
  background: var(--bg-elevated); border-left: 3px solid var(--accent); box-shadow: var(--shadow-sm); }
.ak-ev.hadith { border-left-color: var(--accent-2); }
.ak-ev-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.ak-ev-ref { font-weight: 600; color: var(--link); text-decoration: none; font-size: 13.5px; }
.ak-ev-ref:hover { text-decoration: underline; }
.ak-ev-ref.hadith { color: var(--text-muted); font-weight: 600; }
.ak-ev-sura { color: var(--text-dim); font-weight: 500; }
.ak-ar { font-family: var(--quran-ar); font-size: 25px; line-height: 2.05; color: var(--text); margin: 2px 0 10px; }
.ak-tr { font-size: 15px; line-height: 1.65; color: var(--text-muted); margin-bottom: 10px; }
.ak-note { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; line-height: 1.5;
  color: var(--text-muted); padding-top: 10px; border-top: 1px dashed var(--border); }
.ak-note-ico { color: var(--accent); flex: none; }
.ahkam-views { display: flex; flex-direction: column; gap: 8px; }
.ahkam-view { padding: 10px 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg-elevated); }
.ahkam-ruling { display: inline-block; padding: 2px 10px; border-radius: 20px; font-weight: 600; font-size: 13px; margin-right: 8px; }
.ahkam-r-no { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.ahkam-r-must { background: color-mix(in srgb, var(--success) 15%, transparent); color: var(--success); }
.ahkam-r-neutral { background: var(--bg-hover); color: var(--text-muted); }
.ahkam-madhhab { font-size: 12px; color: var(--text-dim); }
.ahkam-cond { margin-top: 6px; line-height: 1.5; }
.ahkam-noview { padding: 11px 13px; border-left: 2px solid var(--accent); background: var(--accent-soft); border-radius: 8px; line-height: 1.5; }
.ahkam-ev { display: flex; flex-direction: column; gap: 7px; }
.ahkam-ev-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; padding: 7px 0; border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent); }
.ahkam-ref { font-weight: 600; color: var(--accent-bright); text-decoration: none; white-space: nowrap; }
.ahkam-ref.hadith { color: var(--text-dim); }
.ahkam-role { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600;
  padding: 2px 9px; border-radius: var(--r-pill); white-space: nowrap; }
.ahkam-role.ok   { color: var(--success); background: color-mix(in srgb, var(--success) 13%, transparent); }
.ahkam-role.qual { color: var(--link);    background: var(--accent-soft); }
.ahkam-role.exc  { color: var(--link-2);   background: color-mix(in srgb, var(--accent-2) 13%, transparent); }
.ahkam-role.disp { color: var(--danger);   background: color-mix(in srgb, var(--danger) 13%, transparent); }
.ahkam-note { flex: 1; min-width: 220px; line-height: 1.45; }
.ahkam-link { color: #d0a15a !important; }

/* Phase C3 — aḥkām candidate review queue */
.ahkam-reviewbar { margin-bottom: 16px; }
.ahkam-cand-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.ahkam-cand { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; padding: 11px 13px; border: 1px solid var(--border); border-radius: 9px; background: var(--bg-elevated); }
.ahkam-cand-main { flex: 1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.ahkam-cand-topic { font-weight: 600; }
.ahkam-cand-actions { display: flex; gap: 6px; flex: none; }

/* D1b — polity story arc (chronological lifecycle+conflicts) */
.sd-story { display: flex; flex-direction: column; gap: 0; margin-top: 6px; border-left: 2px solid var(--border); padding-left: 4px; }
.sd-ev { display: flex; gap: 10px; padding: 7px 0 7px 10px; position: relative; }
.sd-ev::before { content: ""; position: absolute; left: -5px; top: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--text-dim); }
.sd-ev-founded::before { background: #5fb87a; } .sd-ev-end::before { background: #d0685a; }
.sd-ev-conflict::before { background: #d98a5a; } .sd-ev-disputed::before { background: #e0883b; }
.sd-ev-yr { font-variant-numeric: tabular-nums; color: var(--accent-bright); font-weight: 600; min-width: 42px; font-size: 13px; }
.sd-ev-body { flex: 1; line-height: 1.45; font-size: 13px; }
.sd-ev-body .pop-link { color: var(--accent-bright); background: none; border: none; cursor: pointer; padding: 0; font: inherit; }
.sd-ev-body .pop-link:hover { text-decoration: underline; }

/* D1b — Map "States by era" slider */
.map-era-bar { display: flex; align-items: center; gap: 12px; padding: 8px 14px; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 10px; margin: 0 0 10px; }
.map-era-slider { flex: 1; accent-color: var(--accent); cursor: pointer; }
.map-era-year { font-variant-numeric: tabular-nums; color: var(--accent-bright); font-weight: 600; min-width: 62px; text-align: right; }
.map-pop-link { color: var(--accent-bright); }

/* T2/T3 — transformation connectors, toolbar, trace mode, breadcrumb */
.states-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.states-tchip { padding: 4px 10px; border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--bg); color: var(--text-dim); cursor: pointer; font-size: 12px; transition: all .14s; }
.states-tchip.on { border-color: var(--accent); color: var(--accent-bright); background: var(--accent-soft); }
.states-tchip:hover { border-color: var(--accent); }
.states-toolbar-hint { margin-left: auto; }
.states-rows { position: relative; }
.states-svg { position: absolute; inset: 0; z-index: 4; pointer-events: none; overflow: visible; }
.states-svg .states-conn { pointer-events: stroke; cursor: help; transition: opacity .12s; }
.states-svg .states-conn:hover { opacity: 1 !important; stroke-width: 3; }
.states-row { transition: opacity .18s; }
.states-tracing .states-row.dim { opacity: 0.12; }
.states-tracing .states-row.dim .states-bar { pointer-events: none; }
.states-breadcrumb { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 9px 12px; margin-bottom: 12px; background: var(--bg-elevated); border: 1px solid var(--accent); border-radius: 10px; position: sticky; top: 0; z-index: 6; }
.states-breadcrumb .bc-lbl { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .04em; margin-right: 2px; }
.states-breadcrumb .bc-arrow { color: var(--text-dim); }
.bc-node { padding: 3px 9px; border-radius: 16px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 12px; cursor: pointer; }
.bc-node:hover { border-color: var(--accent); }
.bc-node.self { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-bright); font-weight: 600; }
.bc-node.ext { font-style: italic; color: var(--text-dim); cursor: default; }
.bc-exit { margin-left: auto; padding: 3px 10px; border-radius: 16px; border: 1px solid var(--border); background: var(--bg); color: var(--text-dim); cursor: pointer; font-size: 12px; }
.bc-exit:hover { border-color: #d0685a; color: #e59a8e; }

/* T4 — genealogy graph modal */
.bc-gen { padding: 3px 10px; border-radius: 16px; border: 1px solid var(--border); background: var(--bg); color: var(--accent-bright); cursor: pointer; font-size: 12px; }
.bc-gen:hover { border-color: var(--accent); }
.states-gen-modal { width: min(940px, 96vw); }
.states-gen-cy { height: min(620px, 72vh); width: 100%; background: var(--bg); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

/* M3 — Genealogy matrix */
.gm-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.gm-search { max-width: 200px; }
.gm-btn, .gm-tchip { padding: 4px 10px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--bg); color: var(--text-dim); cursor: pointer; font-size: 12px; }
.gm-btn:hover, .gm-tchip:hover { border-color: var(--accent); }
.gm-tchip.on { border-color: var(--accent); color: var(--accent-bright); background: var(--accent-soft); }
.gm-legend { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; font-size: 11px; }
.gm-leg { display: inline-flex; align-items: center; gap: 4px; font-size: inherit; color: var(--text-dim);
  background: transparent; border: 1px solid transparent; border-radius: var(--r-pill, 999px);
  padding: 2px 8px; cursor: pointer; transition: all .12s; }
.gm-leg:hover { border-color: var(--border); color: var(--text); }
.gm-leg.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); font-weight: 600; }
.gm-leg i { width: var(--gm-leg-sw, 11px); height: var(--gm-leg-sw, 11px); border-radius: 2px; display: inline-block; flex: none; }
.gm-scroll { overflow: auto; max-height: 74vh; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-elevated); }
.gm-scroll canvas { display: block; }
.gm-layout { display: grid; position: relative; width: max-content; }
/* frozen headers — sticky corner + row/column rails stay pinned while the grid scrolls */
.gm-corner { position: sticky; top: 0; left: 0; z-index: 3; background: var(--bg-elevated); }
.gm-colhead { position: sticky; top: 0; z-index: 2; background: var(--bg-elevated); }
.gm-rowhead { position: sticky; left: 0; z-index: 2; background: var(--bg-elevated); }
.gm-grid { z-index: 1; }
.gm-tip { position: fixed; z-index: 60; max-width: 320px; background: var(--bg-elevated); border: 1px solid var(--accent); border-radius: 8px; padding: 8px 11px; font-size: 12px; line-height: 1.45; pointer-events: none; box-shadow: 0 8px 30px rgba(0,0,0,.5); }
/* M4 — dynasty strip */
.dynasty-strip { width: 100%; height: 30px; display: block; margin-top: 6px; }
.dynasty-strip .ds-seg { cursor: help; }
.dynasty-strip .ds-seg:hover { opacity: 0.85 !important; }
.ds-legend { margin-top: 5px; }
/* era-break divider: marks where a modern national era departs from the Islamic-dynastic order */
.ds-erabreak, .enc-erabreak { display: flex; align-items: center; justify-content: center;
  margin: 6px 0 2px; font-size: 10.5px; letter-spacing: .3px; text-transform: uppercase;
  color: var(--accent, #b8863b); font-style: italic; opacity: .9; text-align: center; }
.enc-erabreak { white-space: normal; line-height: 1.35; }

/* L3 — Lane's Lexicon in the root modal */
.q-lex { margin: 10px 0 14px; padding: 12px; border: 1px solid var(--accent); border-radius: var(--r); background: var(--accent-soft); }
.q-lex-h { font-weight: 600; color: var(--accent-bright); margin-bottom: 8px; }
.q-lex-entry { margin-bottom: 10px; }
.q-lex-head { font-size: 20px; color: var(--text); margin-bottom: 4px; }
.q-lex-body { font-size: 14px; line-height: 1.6; color: var(--text-muted); max-height: 340px; overflow-y: auto; }
.q-lex-body p { margin: 0 0 6px; }
.q-lex-attr { margin-top: 8px; padding-top: 6px; border-top: 1px solid var(--border-subtle); }
.q-lex-body .lex-ar { color: var(--text); font-size: 1.05em; }
.q-lex-body .lex-sense { margin: 4px 0; padding-left: 8px; border-left: 2px solid var(--border); }

/* L1 — narrator bio + isnād transmission in the profile popover */
.np-biohead, .np-isnadhead { margin-top: 12px; text-transform: uppercase; letter-spacing: .04em; }
.np-bio { margin-top: 4px; font-size: 13px; }
.np-bio-row { padding: 2px 0; }
.np-isnad { margin-top: 6px; }
.np-isnad-h { margin-bottom: 3px; }
.np-isnad-chips { display: flex; flex-wrap: wrap; gap: 5px; max-height: 120px; overflow-y: auto; }
.chip.link-chip { cursor: pointer; border: 1px solid var(--border); background: var(--bg); }
.chip.link-chip:hover { border-color: var(--accent); color: var(--accent-bright); }

/* L4 — Twelver Shia tradition badge (neutral, distinct from grade colours) */
.chip.trad-shia { background: color-mix(in srgb, var(--k-person) 12%, transparent); color: var(--k-person); border: 1px solid color-mix(in srgb, var(--k-person) 34%, transparent); }

/* R0/R1 — Reference Encyclopedia */
#encSeg { margin-left: auto; }
.enc-refcat { font-weight: 600; color: var(--accent-bright); padding: 10px 8px 4px; font-size: 13px; }
.enc-refgroup { margin: 0 4px; }
.enc-refgroup > summary { cursor: pointer; padding: 4px 8px; color: var(--text-dim); font-size: 12px; border-radius: 6px; }
.enc-refgroup > summary:hover { background: var(--bg-elevated); color: var(--text); }
.enc-refgroup .enc-node { padding-left: 20px; }
.enc-arthead { border-bottom: 1px solid var(--border); padding-bottom: 12px; margin-bottom: 14px; }
.enc-arthead h1 { margin: 0 0 3px; font-size: 24px; }
.enc-artsub { font-size: 14px; }
.enc-prov { display: inline-block; margin-top: 8px; font-size: 11px; padding: 3px 9px; border-radius: var(--r-pill); }
.enc-prov-curated { background: var(--accent-soft); color: var(--accent-bright); border: 1px solid var(--accent); }
.enc-prov-machine-drafted { background: color-mix(in srgb, var(--k-person) 12%, transparent); color: var(--k-person); border: 1px solid color-mix(in srgb, var(--k-person) 34%, transparent); }
.enc-prov-external { background: #3a332d; color: #d9b48a; border: 1px solid #5a4a3d; }
.enc-links { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.enc-link { padding: 5px 12px; border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 12px; text-decoration: none; }
.enc-link:hover { border-color: var(--accent); color: var(--accent-bright); }
.enc-seealso .el-ico { margin-right: 5px; opacity: .85; }

/* inline Qur'an verse citation → deep-link to the āyah-anchored reader */
.q-ref { color: var(--accent-bright); text-decoration: none; border-bottom: 1px dotted var(--accent); white-space: nowrap; }
.q-ref:hover { border-bottom-style: solid; }

/* deep-link target: pulse the āyah the reader was opened at (#quran/S:A) */
.q-ayah.q-ayah-target { background: var(--accent-soft); border-radius: var(--r); animation: qAyahPulse 2.6s ease-out 1; }
@keyframes qAyahPulse { 0% { background: color-mix(in srgb, var(--accent) 34%, transparent); } 100% { background: transparent; } }
.enc-lead { font-size: 15px; line-height: 1.6; color: var(--text); margin: 0 0 14px; }
.enc-facts { width: 100%; border-collapse: collapse; margin-bottom: 14px; }
.enc-facts td { padding: 5px 8px; border-bottom: 1px solid var(--border-subtle); font-size: 13px; vertical-align: top; }
.enc-facts .ef-k { color: var(--text-dim); width: 130px; }
.enc-gen-row, .enc-conf-row { padding: 5px 6px; border-bottom: 1px solid var(--border-subtle); font-size: 13px; }
.enc-gen-row.disputed { border-left: 2px solid #d0685a; padding-left: 8px; }
.eg-rel { color: var(--text-dim); font-size: 12px; }
.eg-note { margin-top: 2px; }
.enc-reflink { color: var(--accent-bright); cursor: pointer; text-decoration: none; }
.enc-reflink:hover { text-decoration: underline; }
.enc-reignstrip { position: relative; height: 16px; background: var(--bg-elevated); border-radius: 4px; margin: 4px 0; }
.enc-reign { position: absolute; top: 2px; height: 12px; border-radius: 2px; }
/* readable ruler list (names + periods), below the strip */
.enc-reignlist { list-style: none; margin: 10px 0 0; padding: 0; }
.enc-reign-row { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px;
  padding: 4px 0; border-bottom: 1px solid var(--border-subtle); }
.enc-reign-row:last-child { border-bottom: none; }
.enc-reign-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; align-self: center; }
.enc-reign-per { flex: 0 0 auto; min-width: 82px; font-variant-numeric: tabular-nums;
  color: var(--text-dim); font-size: 13px; }
.enc-reign-nm { font-weight: 600; }
.enc-reign-meta::before { content: "· "; }
.enc-reign-note { flex-basis: 100%; margin-left: 90px; font-style: italic; }
.enc-reign-gap .enc-reign-nm { font-weight: 400; font-style: italic; }
.enc-parties { display: flex; gap: 18px; flex-wrap: wrap; }
.enc-party-side .eps-h { text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
/* commanders & leaders per side — rows, so each side needs width to read as a column */
.enc-cmdrs { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 14px; }
.enc-cmdrs .enc-party-side { flex: 1 1 240px; min-width: 220px; }
.enc-cmdr-row { padding: 5px 6px; border-bottom: 1px solid var(--border-subtle); font-size: 13px; }
.enc-cmdr-row:last-child { border-bottom: none; }
.enc-cmdr-row.disputed { border-left: 2px solid #d0685a; padding-left: 8px; }
.enc-facts tr.disputed td { border-left: 2px solid #d0685a; }
.enc-trans { display: flex; flex-wrap: wrap; gap: 5px; max-height: 130px; overflow-y: auto; }
.enc-artnote { margin-top: 16px; padding-top: 8px; border-top: 1px solid var(--border-subtle); font-style: italic; }
.rel-badge { display: inline-block; padding: 2px 9px; border-radius: var(--r-pill); background: var(--rc); color: var(--on-accent); font-size: 12px; font-weight: 600; }

/* R2 — machine-drafted prose block */
.enc-prose { margin: 4px 0 18px; padding: 14px 16px; background: var(--bg-elevated); border-left: 3px solid #3d5a80; border-radius: 6px; }
.enc-prose-label { font-size: 11px; color: #9ec5ff; margin-bottom: 8px; text-transform: uppercase; letter-spacing: .03em; }
.enc-prose p { margin: 0 0 10px; line-height: 1.65; font-size: 14.5px; }
.enc-prose p:last-child { margin-bottom: 0; }
/* Country Islamic-history narrative (coming of Islam, composition, scholars, contemporary) */
.enc-country-prose { border-left-color: var(--accent, #b07d2b); background: var(--bg-elevated); }
.enc-country-prose .ecp-head { font-weight: 600; color: var(--text); margin: 0 0 4px; font-size: 14.5px; }
.enc-country-prose .ecp-head:not(:first-child) { margin-top: 12px; }
.ecp-caveat { margin: 0 0 8px; font-style: italic; }

/* R3 — ruler key-events timeline */
.enc-events { margin: 4px 0 14px; }
.enc-event { display: flex; gap: 12px; padding: 4px 0; border-bottom: 1px solid var(--border-subtle); font-size: 13px; }
.enc-event .ev-yr { color: var(--accent-bright); font-variant-numeric: tabular-nums; min-width: 44px; }

/* R4 — People inclusion policy note */
.enc-policy > summary { color: var(--accent-bright); font-size: 12px; }
.enc-policy-body { padding: 8px 10px; line-height: 1.5; }

/* R1 — reference search + reciprocal cross-links */
.enc-search { width: calc(100% - 16px); margin: 8px; }
.enc-searchbox { margin: 0 6px 8px; max-height: 46vh; overflow-y: auto; border: 1px solid var(--accent); border-radius: 8px; background: var(--bg-elevated); }
.enc-searchhit { flex-direction: column; align-items: flex-start; gap: 1px; padding: 7px 10px; border-bottom: 1px solid var(--border-subtle); }
.es-kind { font-size: 10px; text-transform: uppercase; color: var(--accent-bright); letter-spacing: .04em; }
.es-title { color: var(--text); }
.es-snip { display: block; }
.enc-crosslink { margin-top: 18px; padding: 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-elevated); }
.enc-xl-ref { border-color: var(--accent); }
.enc-xlink { display: block; padding: 4px 0; color: var(--accent-bright); text-decoration: none; }
.enc-xlink:hover { text-decoration: underline; }

/* R5 — "Read encyclopedia article" cross-view links */
.enc-readlink { display: inline-block; margin: 6px 0 10px; padding: 4px 12px; border-radius: var(--r-pill); border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent-bright); font-size: 12px; text-decoration: none; }
.enc-readlink:hover { background: var(--accent); color: var(--on-accent); }
a.conflict-name.enc-readlink { border: none; background: none; padding: 0; margin: 0; font-weight: 600; }
a.conflict-name.enc-readlink:hover { color: var(--accent-bright); background: none; text-decoration: underline; }

/* ===== River of Islam (F5 UX remediation) ===== */
.river-wrap { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.river-toolbar { display: flex; flex-direction: column; gap: 5px; padding: 6px 2px; }
.river-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.river-btn { padding: 4px 11px; border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--bg); color: var(--text); cursor: pointer; font-size: 12.5px; }
.river-btn:hover { border-color: var(--accent); color: var(--accent-bright); }
.river-btn.river-story { border-color: var(--accent); color: var(--accent-bright); font-weight: 600; }
.river-btn.river-play { border-color: #3d5a80; color: #9ec5ff; }
.river-eras { display: flex; gap: 3px; flex-wrap: wrap; }
.river-erabtn { padding: 3px 9px; border-radius: var(--r-pill); border: 1px solid var(--border); background: var(--bg); color: var(--text-dim); cursor: pointer; font-size: 11.5px; }
.river-erabtn:hover { border-color: var(--accent); color: var(--accent-bright); }
.river-erabtn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-bright); font-weight: 600; }
.river-span { margin-left: auto; font-size: 12.5px; color: var(--accent-bright); font-variant-numeric: tabular-nums; font-weight: 600; padding: 2px 10px; border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--bg-elevated); }
.river-lodnote { }
.river-legend { display: flex; gap: 11px; margin-left: auto; flex-wrap: wrap; }
.rl-item { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--text-dim); }
.rl-item i { width: 13px; height: 13px; border-radius: 3px; display: inline-block; }
/* main = river column + drawer */
.river-main { flex: 1; display: flex; gap: 0; min-height: 0; position: relative; }
.river-left { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.river-axis { height: 30px; flex: none; border: 1px solid var(--border); border-bottom: none; border-radius: 10px 10px 0 0; background: var(--bg-elevated); overflow: hidden; }
.river-axis-svg { display: block; }
.axis-yr { font-family: var(--sans); font-variant-numeric: tabular-nums; }
.axis-era { font-family: var(--sans); font-weight: 600; letter-spacing: .03em; opacity: .85; text-transform: uppercase; }
.axis-cursor { font-family: var(--sans); font-weight: 700; }
.river-stage { flex: 1; overflow-y: scroll; overflow-x: hidden; border: 1px solid var(--border); background: var(--bg-elevated); min-height: 200px; position: relative; scrollbar-width: auto; scrollbar-color: var(--accent) var(--bg); }
/* prominent, easy-to-grab vertical scrollbar (WebKit) */
.river-stage::-webkit-scrollbar { width: 16px; }
.river-stage::-webkit-scrollbar-track { background: rgba(255,255,255,0.04); border-radius: 8px; }
.river-stage::-webkit-scrollbar-thumb { background: var(--accent); border: 3px solid var(--bg-elevated); border-radius: 8px; min-height: 44px; }
.river-stage::-webkit-scrollbar-thumb:hover { background: var(--accent-bright); }
.river-svg { display: block; }
.river-svg .river-node { cursor: pointer; }
.river-svg .river-node:hover rect:first-child { stroke: var(--accent-bright); stroke-width: 1.8; }
.river-svg .river-node.dim { opacity: 0.22; }
.river-svg .river-node.focus rect:first-child { stroke: var(--accent-bright); stroke-width: 2.4; }
.river-svg .node-lbl { pointer-events: none; font-family: var(--sans); font-weight: 500; }
.river-svg .band-lbl { pointer-events: none; font-family: var(--sans); font-weight: 600; letter-spacing: .02em; }
/* breadcrumb — single scrollable line */
.river-crumb { display: flex; align-items: center; gap: 6px; padding: 6px 8px; background: var(--bg-elevated); border: 1px solid var(--accent); border-bottom: none; }
.rc-count { font-size: 11px; color: var(--accent-bright); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; font-weight: 600; }
.rc-scroll { display: flex; align-items: center; gap: 5px; overflow-x: auto; flex: 1; scrollbar-width: thin; -webkit-mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 12px), transparent); }
.rc-node { padding: 2px 9px; border-radius: 13px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-size: 12px; cursor: pointer; white-space: nowrap; }
.rc-node.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-bright); font-weight: 600; }
.rc-arr { color: var(--text-dim); }
.rc-exit { padding: 2px 9px; border-radius: 13px; border: 1px solid var(--border); background: var(--bg); color: var(--text-dim); cursor: pointer; }
/* overview */
.river-ovwrap { flex: none; border: 1px solid var(--border); border-top: none; border-radius: 0 0 10px 10px; background: var(--bg-elevated); }
.river-overview { height: 52px; overflow: hidden; cursor: pointer; }
.river-ov-svg { display: block; }
.river-ov-win { cursor: grab; }
.river-ovaxis { position: relative; height: 15px; }
.ovyr { position: absolute; transform: translateX(-50%); font-size: 9.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
/* right drawer */
.river-drawer { width: 384px; flex: none; margin-left: 8px; overflow-y: auto; border: 1px solid var(--accent); border-radius: 10px; background: var(--bg-elevated); padding: 16px 16px 24px; position: relative; }
.river-drawer.open { animation: rdslide .18s ease; }
@keyframes rdslide { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
.rd-close { position: absolute; top: 10px; right: 12px; background: none; border: none; color: var(--text-dim); font-size: 16px; cursor: pointer; }
.rd-close:hover { color: var(--text); }
.rd-head h3 { margin: 0 0 3px; padding-right: 24px; font-size: 19px; }
.rd-sub { margin-bottom: 4px; }
.rd-badge { display: inline-block; margin: 4px 4px 0 0; font-size: 10.5px; padding: 2px 8px; border-radius: var(--r-pill); }
.rd-badge-disputed { background: #3a2d2d; color: #e59a8e; border: 1px solid #5a3d3d; }
.rd-badge-heritage { background: var(--bg-hover); color: var(--text-muted); border: 1px solid var(--border); }
.rd-links { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; }
.rd-reigns { width: 100%; height: 15px; display: block; margin: 3px 0; }
.rd-row { padding: 4px 0; border-bottom: 1px solid var(--border-subtle); font-size: 13px; }
.rd-goto, .rd-anchor { color: var(--accent-bright); cursor: pointer; text-decoration: none; }
.rd-goto:hover, .rd-anchor:hover b { text-decoration: underline; color: var(--accent-bright); }
.rd-anchornote { margin: 4px 0 6px; font-style: italic; }
.rd-anchor { display: block; padding: 4px 0; }
/* story card — docked bottom-center of the river column */
.river-storycard { position: absolute; left: 50%; transform: translateX(-50%); bottom: 78px; z-index: 20; width: min(560px, 92%); background: var(--bg-elevated); border: 1px solid var(--accent); border-radius: 12px; padding: 14px 16px; box-shadow: 0 12px 44px rgba(0,0,0,.6); }
.rs-top { display: flex; align-items: center; justify-content: space-between; }
.rs-title { font-weight: 600; color: var(--accent-bright); font-size: 14.5px; }
.rs-x { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 15px; }
.rs-caption { font-size: 14px; line-height: 1.65; margin: 8px 0 12px; color: var(--text); }
.rs-nav { display: flex; gap: 8px; justify-content: flex-end; }
.rs-nav .river-btn[disabled] { opacity: .4; pointer-events: none; }
/* fast tooltip */
.river-tip { position: fixed; z-index: 60; max-width: 260px; background: var(--bg-elevated); border: 1px solid var(--accent); border-radius: 8px; padding: 7px 11px; font-size: 12.5px; line-height: 1.5; pointer-events: none; box-shadow: 0 8px 30px rgba(0,0,0,.55); }
@media (max-width: 1100px) { .river-drawer { position: absolute; right: 0; top: 0; height: 100%; z-index: 30; box-shadow: -8px 0 30px rgba(0,0,0,.5); } }

/* row-height / zoom control groups + scroll hint */
.river-grp { display: inline-flex; align-items: center; gap: 2px; padding: 0 2px 0 6px; border: 1px solid var(--border); border-radius: var(--r-sm); }
.river-grp .river-btn { border: none; padding: 3px 7px; }
.river-glbl { font-size: 13px; color: var(--text-dim); }
.river-scrollhint { font-size: 11px; color: var(--text-dim); margin-left: 8px; }

/* ---- Graph & Map v109: co-occurrence graph perf UI + always-on map base layers ---- */
.btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-bright); }
.btn-xs { padding: 3px 8px; font-size: 11px; }

/* graph stage holds #cy plus absolute overlays (loading spinner, hover hint) */
.graph-stage { position: relative; flex: 1; min-height: 0; display: flex; }
.graph-stage #cy { flex: 1; }
.graph-loading { position: absolute; inset: 0; z-index: 20; display: flex; gap: 12px;
  align-items: center; justify-content: center; background: rgba(10,11,13,.55);
  color: var(--text-muted); font-size: 13px; backdrop-filter: blur(1px); }
.graph-loading[hidden] { display: none; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--border);
  border-top-color: var(--accent); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.graph-hint { position: absolute; left: 12px; bottom: 12px; z-index: 15; max-width: 60%;
  padding: 5px 10px; border-radius: 8px; background: rgba(20,22,26,.92); border: 1px solid var(--border);
  color: var(--text); font-size: 12px; pointer-events: none; box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.graph-hint[hidden] { display: none; }

/* map layer toggles */
.map-layers { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.map-lyr-count { font-variant-numeric: tabular-nums; opacity: .7; font-size: 11px; }
.atlas-panel.hidden { display: none; }

/* River lineage/region layout toggle (v110) */
.river-modebtn { padding: 3px 9px !important; font-size: 12px; }
.river-modebtn.on { background: var(--accent-soft); border-color: var(--accent) !important; color: var(--accent-bright); font-weight: 600; }

/* ---- ⚔ Wars view (W2 canvas + basic dossier) ---- */
.wars-svg text.wars-band-lbl { font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.wars-node { cursor: pointer; }
.wars-node.sel path, .wars-node.sel rect { stroke: #e0bd6a; stroke-width: 2; }
.wars-legend { gap: 9px; }
.river-drawer-x { position: absolute; top: 10px; right: 12px; background: none; border: none; color: var(--text-dim); font-size: 15px; cursor: pointer; }
.river-drawer-x:hover { color: var(--text); }
.wars-dh { display: flex; align-items: center; gap: 8px; padding-right: 20px; }
.wars-dh h3 { margin: 0; font-size: 16px; }
.wars-kind-dot { width: 11px; height: 11px; border-radius: 3px; flex: none; }
.wars-meta { color: var(--text-muted); font-size: 12.5px; margin: 4px 0 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wars-kind { text-transform: capitalize; }
.wars-axis-chip { font-size: 10.5px; padding: 1px 8px; border-radius: 10px; border: 1px solid var(--border); text-transform: capitalize; }
.wars-axis-chip.internal { background: rgba(110,168,254,.14); color: #a9c8ff; border-color: transparent; }
.wars-axis-chip.external { background: rgba(224,136,59,.14); color: #e6a860; border-color: transparent; }
.wars-axis-chip.mixed { background: rgba(183,139,224,.14); color: #c9a9e6; border-color: transparent; }
.wars-sides { display: flex; flex-direction: column; gap: 10px; margin-bottom: 8px; }
.wars-side { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--bg); }
.wars-side-h { font-weight: 600; font-size: 13px; margin-bottom: 5px; }
.wars-lead { font-size: 12.5px; line-height: 1.65; }
.wl-role { color: var(--text-dim); text-transform: capitalize; font-size: 11px; }
.wl-killed { color: #d98a8a; }
.wl-derived { color: var(--text-dim); font-size: 10px; border: 1px solid var(--border); border-radius: 6px; padding: 0 4px; }
.wars-sec-h { font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); margin: 14px 0 5px; }
.wars-cas { font-size: 12.5px; line-height: 1.7; }
.wars-basis { font-size: 10px; padding: 0 6px; border-radius: 8px; text-transform: capitalize; border: 1px solid var(--border); }
.wars-basis.traditional { color: #d9a45a; border-color: #7a5a2a; }
.wars-basis.scholarly { color: #8ecb7a; border-color: #3e6a34; }
.wars-basis.contemporary, .wars-basis.official { color: #9ec5ff; border-color: #3d5a80; }
.wars-disp { color: #d9a45a; font-size: 11px; }
.wars-outcome { font-size: 12.5px; line-height: 1.6; color: var(--text); }
.wars-partof { font-size: 12px; color: var(--text-muted); margin-top: 12px; }
.wars-article { margin-top: 14px; display: inline-block; }

/* ⚔ Wars — losses strip (W3) */
.wars-losses { height: 96px; flex: none; border-top: 1px solid var(--border); background: rgba(255,255,255,0.012); position: relative; }
.wars-loss-svg { display: block; }
.wars-loss-title { font-weight: 600; letter-spacing: .02em; }
.wars-lossnode { cursor: default; }

/* ⚔ Wars — W4 dossier extras + compare tray */
.wars-pin { margin: 2px 0 4px; }
.wars-pin.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-bright); }
.wars-polity { color: var(--accent-bright); text-decoration: none; }
.wars-polity:hover { text-decoration: underline; }
.wars-cas-side { margin-bottom: 8px; }
.wars-cas-sh { font-weight: 600; font-size: 12px; margin-bottom: 2px; }
.wars-src { color: var(--text-dim); font-size: 10.5px; line-height: 1.45; margin: 1px 0 4px; }
.wars-compare { position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 40; background: var(--bg-elevated);
  border: 1px solid var(--accent); border-radius: 10px; padding: 10px 14px; box-shadow: 0 -8px 30px rgba(0,0,0,.5); }
.wars-cmp-h { font-weight: 600; font-size: 12px; margin-bottom: 6px; display: flex; align-items: center; gap: 10px; }
.wars-cmp-clear { background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--text-dim); font-size: 11px; padding: 1px 8px; cursor: pointer; }
.wars-cmp-clear:hover { color: var(--text); border-color: var(--accent); }
.wars-cmp-cols { display: flex; gap: 12px; flex-wrap: wrap; }
.wars-cmp-col { flex: 1 1 220px; min-width: 200px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; position: relative; background: var(--bg); }
.wars-cmp-x { position: absolute; top: 5px; right: 7px; background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 12px; }
.wars-cmp-x:hover { color: var(--text); }
.wars-cmp-name { font-weight: 600; font-size: 13px; padding-right: 16px; }
.wars-cmp-parties { margin: 2px 0; }
.wars-cmp-cas { font-size: 12px; margin-top: 3px; }
.wars-cmp-scale { margin-top: 8px; }
.wars-cmp-svg { display: block; }

/* ⚔ Wars — W5 filters + methodology */
.wars-count { margin-left: auto; font-variant-numeric: tabular-nums; }
.wars-kindrow { gap: 7px !important; flex-wrap: wrap; }
.wars-kindchip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text-muted); font-size: 11.5px; cursor: pointer; text-transform: capitalize; }
.wars-kindchip i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; }
.wars-kindchip:hover { border-color: var(--accent); color: var(--text); }
.wars-kindchip.off { opacity: .38; }
.wars-seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.wars-segbtn { background: var(--bg); border: none; color: var(--text-muted); font-size: 12px; padding: 4px 11px; cursor: pointer; text-transform: capitalize; border-right: 1px solid var(--border); }
.wars-segbtn:last-child { border-right: none; }
.wars-segbtn.on { background: var(--accent-soft); color: var(--accent-bright); font-weight: 600; }
.wars-search { max-width: 220px; padding: 5px 10px; font-size: 12.5px; }
.wars-info { color: var(--text-muted); }
.wars-method { position: absolute; right: 8px; top: 100%; z-index: 50; width: 380px; margin-top: 4px;
  background: var(--bg-elevated); border: 1px solid var(--accent); border-radius: 10px; padding: 14px 16px; box-shadow: 0 12px 40px rgba(0,0,0,.55); }
.wars-method-h { font-weight: 600; margin-bottom: 6px; }
.wars-method p { font-size: 12.5px; line-height: 1.55; margin: 0 0 8px; color: var(--text); }
.river-toolbar { position: relative; }

/* ---- Knowledge Graph v116: search/focus/panel exploration UI ---- */
.graph-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.graph-search { width: 190px; padding: 5px 10px; font-size: 12.5px; }
.graph-sgrp { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--border); border-radius: 8px; padding: 3px 9px; background: var(--bg); }
.graph-slbl { font-size: 11px; color: var(--text-dim); white-space: nowrap; font-variant-numeric: tabular-nums; }
.graph-slider { width: 90px; accent-color: var(--accent); cursor: pointer; }
.graph-breadcrumb { position: absolute; left: 12px; top: 10px; z-index: 18; display: flex; align-items: center; gap: 10px;
  background: rgba(16,18,22,.86); border: 1px solid var(--border); border-radius: 8px; padding: 4px 11px; font-size: 12px; max-width: 70%; }
.gc-focus { color: var(--accent-bright); font-weight: 600; }
.gc-meta { color: var(--text-dim); }
.gc-clear { background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--text-dim); font-size: 11px; padding: 0 7px; cursor: pointer; }
.gc-clear:hover { color: var(--text); border-color: var(--accent); }
#cy.focused { }
.graph-panel { position: absolute; right: 10px; top: 10px; bottom: 10px; width: 288px; z-index: 20; overflow-y: auto;
  background: var(--bg-elevated); border: 1px solid var(--accent); border-radius: 10px; padding: 14px 14px 20px; box-shadow: -8px 0 30px rgba(0,0,0,.45); }
.graph-panel[hidden] { display: none; }
.graph-panel-x { position: absolute; top: 9px; right: 11px; background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 14px; }
.graph-panel-x:hover { color: var(--text); }
.gp-head { display: flex; align-items: center; gap: 8px; padding-right: 18px; }
.gp-head h3 { margin: 0; font-size: 15px; }
.gp-head .k-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }
.gp-meta { color: var(--text-muted); font-size: 12px; margin: 3px 0 10px; text-transform: capitalize; }
.gp-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.gp-sec { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); margin-bottom: 6px; }
.gp-nbrs { display: flex; flex-direction: column; gap: 3px; }
.gp-nbr { display: flex; align-items: center; gap: 7px; text-align: left; background: var(--bg); border: 1px solid var(--border);
  border-radius: 7px; padding: 5px 8px; cursor: pointer; color: var(--text); font-size: 12.5px; }
.gp-nbr:hover { border-color: var(--accent); background: var(--accent-soft); }
.gp-nbr .k-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.gp-nbr-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gp-nbr-w { color: var(--text-dim); font-size: 10.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---- Knowledge Graph v117: overview window (roots: connections · Qur'an · hadith · history) ---- */
.graph-panel { width: 344px; }
.gp-tabs { display: flex; gap: 2px; margin: 10px 0 8px; border-bottom: 1px solid var(--border); }
.gp-tab { background: none; border: none; color: var(--text-dim); font-size: 12px; padding: 6px 9px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.gp-tab:hover { color: var(--text); }
.gp-tab.on { color: var(--accent-bright); border-bottom-color: var(--accent); font-weight: 600; }
.gp-body { }
.gp-nbr-row { margin-bottom: 3px; }
.gp-nbr { width: 100%; }
.gp-why { background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--text-dim); font-size: 10.5px; padding: 1px 7px; cursor: pointer; margin: 2px 0 0 20px; }
.gp-why:hover { color: var(--accent-bright); border-color: var(--accent); }
.gp-evidence { margin: 4px 0 6px 20px; border-left: 2px solid var(--accent); padding-left: 8px; }
.gp-evidence[hidden] { display: none; }
.gp-ev-h { font-size: 11px; color: var(--accent-bright); font-weight: 600; margin-bottom: 4px; }
.gp-ev { font-size: 11.5px; line-height: 1.5; margin-bottom: 6px; color: var(--text); }
.gp-ev-ref { color: var(--text-dim); font-weight: 600; margin-right: 4px; }
.gp-ev-more { background: none; border: none; color: var(--accent-bright); font-size: 11px; cursor: pointer; padding: 0; }
.gp-aya, .gp-hist { display: block; text-decoration: none; border: 1px solid var(--border); border-radius: 7px; padding: 6px 9px; margin-bottom: 5px; background: var(--bg); }
.gp-aya:hover, .gp-hist:hover { border-color: var(--accent); }
.gp-aya-ref { display: block; font-size: 11px; color: var(--accent-bright); font-weight: 600; }
.gp-aya-t { display: block; font-size: 12px; color: var(--text); line-height: 1.5; margin-top: 2px; }
.gp-had { border: 1px solid var(--border); border-radius: 7px; padding: 6px 9px; margin-bottom: 5px; background: var(--bg); }
.gp-had-ref { font-size: 11px; color: var(--text-dim); font-weight: 600; margin-bottom: 2px; display: flex; gap: 6px; align-items: center; }
.gp-had-t { font-size: 12px; color: var(--text); line-height: 1.5; }
.gp-hist-kind { display: inline-block; font-size: 9.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; margin-right: 6px; }
.gp-hist-t { font-size: 12.5px; color: var(--accent-bright); font-weight: 600; }
.gp-hist-s { display: block; font-size: 11px; color: var(--text-dim); margin-top: 2px; }

/* ⚔ Wars — modes: By-start Gantt + Rivalries matrix (v118) */
.wars-modeseg { margin-right: 4px; }
.wars-mx .river-grp, .wars-mx .river-eras, .wars-mx .river-span { display: none; }  /* time-only controls off in matrix */
.wars-mx-svg { display: block; }
.wars-mx-svg text.wars-mx-lbl { pointer-events: none; }
.wars-mxcell { cursor: pointer; }
.wars-mxcell:hover rect { stroke: #e0bd6a; stroke-width: 1.5; }
.wars-vs { color: #e0685a; }
.wars-pairlist { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.wars-pairitem { display: flex; align-items: center; gap: 8px; text-align: left; background: var(--bg); border: 1px solid var(--border);
  border-radius: 7px; padding: 6px 9px; cursor: pointer; color: var(--text); font-size: 12.5px; }
.wars-pairitem:hover { border-color: var(--accent); background: var(--accent-soft); }
.wars-pi-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wars-pi-yr { color: var(--text-dim); font-size: 11px; font-variant-numeric: tabular-nums; }

/* ⚔ Wars — Rivalries scorecard (v123) */
.wars-sc { width: 100%; border-collapse: collapse; margin-top: 8px; font-size: 12.5px; }
.wars-sc th { text-align: right; color: var(--text-dim); font-weight: 600; font-size: 10.5px; text-transform: uppercase; padding: 3px 5px; border-bottom: 1px solid var(--border); }
.wars-sc th:first-child { text-align: left; }
.wars-sc td { padding: 3px 5px; text-align: right; font-variant-numeric: tabular-nums; border-bottom: 1px solid rgba(255,255,255,0.04); }
.wars-sc td.sc-name { text-align: left; color: var(--text); overflow: hidden; text-overflow: ellipsis; max-width: 150px; white-space: nowrap; }
.wars-sc .sc-w { color: #8ecb7a; } .wars-sc .sc-l { color: #d98a8a; } .wars-sc .sc-t { color: var(--text-muted); } .wars-sc .sc-d { color: #d9a45a; }
.wars-sc tr.sc-total td { border-top: 2px solid var(--border); font-weight: 700; color: var(--text); padding-top: 5px; }
.wars-sc tr.sc-total td.sc-name { color: var(--text-dim); font-weight: 600; }
.wars-hh { font-size: 12.5px; margin: 4px 0 8px; color: var(--text); }
.sc-back { margin: 2px 0 6px; }
.sc-chip { font-size: 10px; padding: 0 6px; border-radius: 8px; border: 1px solid var(--border); white-space: nowrap; }
.sc-cw { color: #8ecb7a; border-color: #3e6a34; } .sc-ct { color: var(--text-muted); } .sc-cd { color: #d9a45a; border-color: #7a5a2a; }
.wars-pairitem { gap: 6px; }

/* ⚔ Wars — scorecard period column + sort toggle (v124) */
.wars-sc td.sc-name { max-width: 118px; }
.wars-sc .sc-period { color: var(--text-dim); font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sc-sort { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-dim); margin: 8px 0 2px; }
.sc-sortbtn { background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--text-dim); font-size: 11px; padding: 1px 8px; cursor: pointer; }
.sc-sortbtn:hover { color: var(--text); border-color: var(--accent); }
.sc-sortbtn.on { background: var(--accent-soft); color: var(--accent-bright); border-color: transparent; }

/* ============================================================
   Arabic script — global sweep. Every RTL text element (Qur'an verses, hadith
   matns, sūra/entity names, word-by-word, tafsīr, qirāʾāt diffs) renders with
   the self-hosted Uthmani-capable face so tajwīd/pause marks don't fall back to
   a system font that shows them as stray symbols. Placed last so it wins the
   equal-specificity tie against any class that set a Latin --serif. */
[dir="rtl"] { font-family: var(--quran-ar); }

/* ---------- Participate / community layer (feedback · contribute · support) ---------- */
.community-body { max-width: 760px; margin: 0 auto; width: 100%; }
.cm-seg { flex-wrap: wrap; margin: 4px 0 18px; }
.cm-seg button { display: inline-flex; align-items: center; gap: 7px; }
.cm-seg-ico { font-size: 13px; opacity: .85; }
.cm-panel { animation: cm-fade .18s ease; }
@keyframes cm-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.cm-form { display: flex; flex-direction: column; gap: 15px; }
.cm-lead { margin: 0 0 4px; font-size: 13.5px; line-height: 1.5; }
.cm-field { display: flex; flex-direction: column; gap: 6px; }
.cm-label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); letter-spacing: .01em; }
.cm-req { color: var(--accent-bright); }
.cm-hint { margin-top: -1px; }
.cm-contact { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cm-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.cm-notice { margin: -4px 0 0; line-height: 1.45; }
.cm-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.cm-actions { display: flex; align-items: center; gap: 14px; margin-top: 4px; }
.cm-status { color: var(--text-dim); }
.cm-status.err { color: var(--st-disputed); }

.cm-success { text-align: center; padding: 40px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; animation: cm-fade .2s ease; }
.cm-success-ico { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-bright); font-size: 26px; font-weight: 700; }
.cm-success h3 { margin: 4px 0 0; font-family: var(--serif); font-weight: 600; }
.cm-success p { max-width: 460px; margin: 0; line-height: 1.55; font-size: 13.5px; }

/* contribute intro */
.cm-intro { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 22px; }
.cm-intro-col h4 { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--text); }
.cm-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 7px; }
.cm-list li { font-size: 12.8px; line-height: 1.5; color: var(--text-muted); }
.cm-consent { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border-subtle);
  border-radius: var(--r-sm); background: var(--bg-elevated); cursor: pointer; }
.cm-consent .cm-check { margin-top: 2px; flex-shrink: 0; accent-color: var(--accent); width: 16px; height: 16px; }
.cm-consent span { line-height: 1.5; }

/* support / share / donate */
.sup-body { display: flex; flex-direction: column; gap: 18px; }
.sup-card { border: 1px solid var(--border-subtle); border-radius: 12px; background: var(--bg-elevated); padding: 20px 22px; }
.sup-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.sup-card-head h3 { margin: 0; font-family: var(--serif); font-size: 16.5px; font-weight: 600; }
.sup-ico { font-size: 19px; }
.sup-card p { line-height: 1.55; font-size: 13.5px; }
.sup-share-row { display: flex; gap: 8px; margin: 14px 0 12px; flex-wrap: wrap; }
.sup-url { flex: 1; min-width: 180px; font-size: 13px; color: var(--text-muted); }
.sup-share-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.sup-share-btn { display: inline-flex; align-items: center; justify-content: center; padding: 9px 12px; border-radius: var(--r-sm);
  border: 1px solid var(--border); background: var(--bg); color: var(--text-muted); font-size: 12.8px; font-weight: 500;
  text-decoration: none; transition: all .15s; }
.sup-share-btn:hover { background: var(--bg-hover); color: var(--text); border-color: var(--accent); }
.sup-trans { margin: 6px 0 16px; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; }
.sup-trans li { font-size: 13px; line-height: 1.5; color: var(--text-muted); }
.sup-donate-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 12px; }
.sup-donate-btn { flex-direction: column; align-items: flex-start; gap: 2px; padding: 11px 18px; text-decoration: none; }
.sup-donate-host { font-size: 10.5px; font-weight: 500; opacity: .7; }
.sup-donate-empty { padding: 14px 16px; border: 1px dashed var(--border); border-radius: var(--r-sm); line-height: 1.55; font-size: 13px; }
.sup-link { color: var(--accent-bright); }
.sup-cross-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.sup-cross .btn { text-decoration: none; }

@media (max-width: 620px) {
  .cm-contact, .cm-grid2, .cm-intro { grid-template-columns: 1fr; }
}

/* ============================================================
   Theme controls + Display/Accessibility settings panel
   ============================================================ */
.brand-actions { margin-left: auto; display: flex; gap: 2px; align-self: flex-start; }
.brand-actions .icon-btn { padding: 6px; border-radius: 7px; }
/* sun/moon swap: show the icon for the theme you'd switch TO */
.ico-sun { display: none; }
.ico-moon { display: inline; }
:root[data-theme="dark"] .ico-sun { display: inline; }
:root[data-theme="dark"] .ico-moon { display: none; }

.set-backdrop {
  position: fixed; inset: 0; z-index: 120; display: grid; place-items: center;
  background: rgba(28, 22, 10, 0.42); backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .18s ease; padding: 20px;
}
:root[data-theme="dark"] .set-backdrop { background: rgba(0, 0, 0, 0.55); }
.set-backdrop.open { opacity: 1; }
.set-panel {
  width: min(560px, 100%); max-height: 88vh; overflow: auto;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow); transform: translateY(8px) scale(.99); transition: transform .18s ease;
}
.set-backdrop.open .set-panel { transform: none; }
.set-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px 14px; border-bottom: 1px solid var(--border-subtle); position: sticky; top: 0; background: var(--bg-elevated); }
.set-head h2 { margin: 0; font-family: var(--serif); font-size: 18px; font-weight: 600; }
.set-close { margin-left: auto; font-size: 15px; }
.set-body { padding: 8px 22px 4px; }
.set-field { padding: 14px 0; border-bottom: 1px solid var(--border-subtle); }
.set-field:last-child { border-bottom: 0; }
.set-field-head { margin-bottom: 10px; }
.set-label { font-size: 13.5px; font-weight: 600; color: var(--text); }
.set-hint { margin-top: 2px; line-height: 1.4; }
.set-seg { width: 100%; }
.set-seg button { flex: 1; padding: 9px 8px; font-size: 12.8px; }
.set-divider { height: 1px; background: var(--border-subtle); margin: 6px 0; }
.set-toggle { display: flex; align-items: center; gap: 14px; padding: 13px 0; border-bottom: 1px solid var(--border-subtle); cursor: pointer; }
.set-toggle:last-child { border-bottom: 0; }
.set-toggle > div:first-child { flex: 1; }
.set-switch {
  flex: none; width: 44px; height: 26px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--bg-hover); position: relative; cursor: pointer; transition: background .16s, border-color .16s;
}
.set-switch-knob {
  position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--text-dim); transition: transform .16s, background .16s;
}
.set-switch.on { background: var(--accent); border-color: var(--accent); }
.set-switch.on .set-switch-knob { transform: translateX(18px); background: var(--on-accent); }
.set-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 22px 20px; position: sticky; bottom: 0; background: var(--bg-elevated); border-top: 1px solid var(--border-subtle); }

@media (max-width: 640px) { .set-seg { flex-wrap: wrap; } .set-seg button { flex: 1 0 40%; } }

/* ============================================================
   Features showcase
   ============================================================ */
.feat-body { max-width: 1000px; margin: 0 auto; width: 100%; }
.feat-ethos {
  font-family: var(--serif); font-size: 18px; line-height: 1.6; color: var(--text);
  max-width: 720px; margin: 6px 0 22px;
}
/* three signature pillars — larger, distinct from the compact grids below */
.feat-pillars { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 34px; }
.feat-pillar {
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px; padding: 20px;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.feat-pillar::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.feat-pillar-ico {
  width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 20px;
  background: var(--accent-soft); margin-bottom: 12px;
}
.feat-pillar h3 { margin: 0 0 6px; font-family: var(--serif); font-size: 16px; font-weight: 600; }
.feat-pillar p { margin: 0; font-size: 13px; line-height: 1.55; }

/* grouped feature catalogue */
.feat-group { margin-bottom: 30px; }
.feat-group-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border-subtle); }
.feat-group-ico {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; font-size: 17px;
  background: var(--bg-hover); flex: none;
}
.feat-group-title { margin: 0; font-family: var(--serif); font-size: 16px; font-weight: 600; }
.feat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.feat-item {
  display: flex; gap: 12px; align-items: flex-start; padding: 13px 15px;
  background: var(--bg-panel); border: 1px solid var(--border-subtle); border-radius: 11px;
  text-decoration: none; color: inherit; transition: border-color .15s, transform .12s, box-shadow .15s;
}
.feat-item.link { cursor: pointer; }
.feat-item.link:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.feat-item-ico { color: var(--accent); font-size: 11px; margin-top: 3px; flex: none; }
.feat-item-n { font-size: 13.5px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 6px; }
.feat-item-d { margin-top: 2px; line-height: 1.45; }
.feat-arrow { color: var(--link); font-weight: 700; opacity: 0; transform: translateX(-3px); transition: opacity .15s, transform .15s; }
.feat-item.link:hover .feat-arrow { opacity: 1; transform: none; }
.feat-foot { max-width: 720px; margin: 8px 0 24px; line-height: 1.5; }

@media (max-width: 760px) { .feat-pillars { grid-template-columns: 1fr; } }

/* shared "See Features" call-to-action (About, Support) */
.page-cta {
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  margin: 4px auto 18px; max-width: 760px; width: 100%; padding: 13px 18px;
  border: 1px solid var(--border); border-radius: 12px; text-decoration: none;
  background: linear-gradient(120deg, var(--accent-soft), transparent 70%);
  color: var(--text); transition: border-color .15s, transform .12s, box-shadow .15s;
}
.page-cta:hover { border-color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.page-cta-txt { font-size: 13.5px; }
.page-cta-txt b { color: var(--text); }
.page-cta-arrow { flex: none; font-weight: 700; color: var(--link); font-size: 13px; white-space: nowrap; }
.about .page-cta { margin-left: 24px; margin-right: 24px; max-width: none; }

/* ============================================================
   MEMBERSHIP — accounts · annotations · study · billing
   (MEMBERSHIP_STUDY_PLAN). Token-driven; works in light + dark.
   ============================================================ */
/* topbar account control */
.auth-slot { display: inline-flex; align-items: center; }
.btn-ghost.auth-signin { padding: 6px 14px; border-radius: var(--r-pill); font-size: 13px; cursor: pointer; }
.auth-avatar { position: relative; display: inline-flex; align-items: center; gap: 6px; background: transparent; border: 0; cursor: pointer; padding: 2px; }
.avatar-initial { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent-bright), var(--accent)); color: var(--on-accent); font-weight: 700; font-size: 13px; }
.plan-badge { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 1px 7px; border-radius: var(--r-pill); }
.plan-basic { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent-bright, var(--accent)); }
.plan-premium { background: linear-gradient(135deg, var(--accent-bright), var(--accent)); color: var(--on-accent); }
.plan-free { background: var(--bg-hover); color: var(--text-muted); }
.auth-menu { position: absolute; top: 54px; right: 12px; z-index: 60; min-width: 180px; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-md, 0 8px 30px rgba(0,0,0,.18)); padding: 6px; }
.auth-menu-item { display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 8px; background: none;
  border: 0; color: var(--text); font: inherit; font-size: 13.5px; cursor: pointer; text-decoration: none; }
.auth-menu-item:hover { background: var(--bg-hover); }

/* auth + modals */
.auth-modal .qg-head { border-bottom: 1px solid var(--border-subtle); }
.auth-modal-body { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.auth-label { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-top: 4px; }
.auth-msg { font-size: 12.5px; color: var(--danger); padding: 4px 2px; }
.auth-msg.ok { color: var(--success); }
.auth-links { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; flex-wrap: wrap; }
.auth-alt { margin-top: 8px; }

/* Sign in with Google.
   Google's brand guidelines require their mark on a neutral surface with legible
   contrast and the wordmark intact, so this deliberately does NOT inherit the
   site's dark accent buttons. The surface stays light in both themes for the
   same reason — a recoloured Google button is the kind of thing that reads as a
   phishing page. */
.auth-social { display: flex; flex-direction: column; gap: 10px; }
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: #fff; color: #1f1f1f; border: 1px solid #dadce0;
  font-weight: 600; font-size: 14px; min-height: 42px; border-radius: 8px;
  cursor: pointer;
}
.btn-google:hover { background: #f7f8f8; border-color: #d2d5d9; }
.btn-google:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-google svg { flex: 0 0 18px; }
.auth-divider { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: 12px; }
.auth-divider::before, .auth-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border-subtle);
}
.upsell-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.upsell-pitch { font-size: 14.5px; line-height: 1.6; color: var(--text); }
.upsell-note { text-align: center; }
.btn-danger { background: color-mix(in srgb, var(--danger) 14%, var(--bg-elevated)); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 22%, var(--bg-elevated)); }

/* account view */
.acct-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; padding: 0 24px 40px; align-items: start; }
.acct-card { background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.acct-card-title { font-size: 15px; font-weight: 700; color: var(--text); margin: 0; }
.acct-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 13.5px; }
.acct-row-label { color: var(--text-muted); font-weight: 600; }
.acct-row-value { color: var(--text); text-align: right; }
.acct-btnrow { display: flex; gap: 10px; flex-wrap: wrap; }
.pw-changer { display: flex; flex-direction: column; gap: 8px; }
.acct-signedout { padding: 40px 24px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.verified-pill, .unverified-pill { margin-left: 8px; font-size: 10px; font-weight: 700; text-transform: uppercase; padding: 1px 7px; border-radius: var(--r-pill); }
.verified-pill { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.unverified-pill { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }

/* ---- annotations: highlights, toolbar, bookmarks (M1) ---- */
:root { --hl-gold: rgba(201,154,32,.34); --hl-teal: rgba(45,142,130,.30); --hl-rose: rgba(178,58,72,.28); --hl-slate: rgba(90,104,120,.30); }
:root[data-theme="dark"], :root:not([data-theme]) { }
[data-theme="dark"] { --hl-gold: rgba(224,189,106,.32); --hl-teal: rgba(92,192,178,.28); --hl-rose: rgba(240,133,122,.26); --hl-slate: rgba(150,165,185,.28); }
mark.hl { background: var(--hl-gold); color: inherit; border-radius: 3px; padding: .04em 0; cursor: pointer; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
mark.hl-teal { background: var(--hl-teal); } mark.hl-rose { background: var(--hl-rose); } mark.hl-slate { background: var(--hl-slate); }
mark.hl[data-note]::after { content: "🗒"; font-size: .62em; vertical-align: super; margin-left: 1px; opacity: .7; }
.annot-block { cursor: text; }

.annot-toolbar, .annot-menu { position: absolute; z-index: 200; display: flex; gap: 5px; align-items: center;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 12px; padding: 6px 8px;
  box-shadow: 0 8px 30px rgba(0,0,0,.22); }
.annot-menu { flex-wrap: wrap; max-width: 220px; }
.annot-dot { width: 20px; height: 20px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; padding: 0; }
.annot-dot:hover { border-color: var(--text-dim); transform: scale(1.12); }
.dot-gold { background: #c99a20; } .dot-teal { background: #2d8e82; } .dot-rose { background: #b23a48; } .dot-slate { background: #5a6878; }
.annot-tool { background: transparent; border: 0; cursor: pointer; font-size: 15px; padding: 2px 5px; border-radius: 7px; color: var(--text-muted); }
.annot-tool:hover { background: var(--bg-hover); }
.annot-cta { background: var(--accent-soft, rgba(201,154,32,.15)); border: 0; color: var(--accent-bright, var(--accent)); font: inherit; font-size: 12.5px; font-weight: 600; padding: 5px 11px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.annot-menu-item { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text); font: inherit; font-size: 13px; padding: 7px 9px; border-radius: 7px; cursor: pointer; }
.annot-menu-item:hover { background: var(--bg-hover); } .annot-menu-item.danger { color: var(--danger); }
.annot-note-quote { border-left: 3px solid var(--accent); padding: 4px 0 4px 12px; margin: 0 0 4px; color: var(--text-muted); font-style: italic; font-size: 13.5px; }
.annot-note-input { width: 100%; resize: vertical; font-family: var(--serif); }

.bookmark-btn { background: none; border: 0; cursor: pointer; color: var(--text-dim); padding: 2px; border-radius: 6px; line-height: 0; opacity: .55; transition: all .14s; }
.bookmark-btn:hover { opacity: 1; color: var(--accent); }
.bookmark-btn.on { opacity: 1; color: var(--accent); }
.bookmark-btn.on svg { fill: currentColor; }
.bookmark-btn svg { fill: none; stroke: currentColor; stroke-width: 2; width: 15px; height: 15px; }
.hadith-head-sp { flex: 1; }

/* ---- My Study view ---- */
.study-toprow { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 24px 14px; flex-wrap: wrap; }
.study-tabs { display: flex; gap: 4px; background: var(--bg-panel); border: 1px solid var(--border-subtle); border-radius: var(--r-pill); padding: 3px; }
.study-tab { background: none; border: 0; color: var(--text-muted); font: inherit; font-size: 13px; padding: 6px 15px; border-radius: var(--r-pill); cursor: pointer; }
.study-tab.on { background: var(--bg-elevated); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,.1)); }
.study-export { display: flex; gap: 12px; }
.study-body { padding: 0 24px 40px; }
.study-gate { padding: 50px 24px; display: flex; flex-direction: column; gap: 16px; align-items: flex-start; }
.study-filters { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.study-search { min-width: 240px; flex: 1; max-width: 380px; }
.study-colors { display: flex; gap: 6px; }
.study-color-chip { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; font-size: 10px; color: var(--text-dim); background: var(--bg-hover); }
.study-color-chip.on { border-color: var(--text); }
.study-color-chip.dot-gold { background: #c99a20; } .study-color-chip.dot-teal { background: #2d8e82; }
.study-color-chip.dot-rose { background: #b23a48; } .study-color-chip.dot-slate { background: #5a6878; }
.study-list { display: flex; flex-direction: column; gap: 20px; max-width: 820px; }
.study-group { background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: 14px; padding: 16px 18px; }
.study-group-src { display: inline-block; font-weight: 700; color: var(--link, var(--accent)); text-decoration: none; margin-bottom: 10px; font-size: 13.5px; }
.study-group-src:hover { text-decoration: underline; }
.study-hl { display: flex; gap: 12px; align-items: flex-start; padding: 8px 0; border-top: 1px solid var(--border-subtle); }
.study-hl:first-of-type { border-top: 0; }
.study-hl-bar { flex: none; width: 4px; align-self: stretch; border-radius: 3px; min-height: 24px; }
.study-hl-bar.dot-gold { background: #c99a20; } .study-hl-bar.dot-teal { background: #2d8e82; }
.study-hl-bar.dot-rose { background: #b23a48; } .study-hl-bar.dot-slate { background: #5a6878; }
.study-hl-main { flex: 1; }
.study-hl-quote { margin: 0; font-family: var(--serif); font-size: 15px; line-height: 1.6; color: var(--text); }
.study-hl-note { margin-top: 6px; font-size: 13px; color: var(--text-muted); background: var(--bg-hover); padding: 7px 11px; border-radius: 8px; }
.study-hl-del { opacity: .4; } .study-hl-del:hover { opacity: 1; color: var(--danger); }
.study-bm-list, .study-reading { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; max-width: 900px; }
.study-bm, .study-read-card { display: flex; align-items: center; gap: 10px; background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: 12px; padding: 13px 15px; text-decoration: none; color: var(--text); }
.study-bm:hover, .study-read-card:hover { border-color: var(--accent); }
.study-bm-ico { color: var(--accent); } .study-bm-label { flex: 1; font-weight: 600; font-size: 13.5px; }
.study-read-card { flex-direction: column; align-items: flex-start; gap: 4px; }
.study-read-src { font-weight: 700; font-size: 14px; }
.study-read-arrow { color: var(--link, var(--accent)); font-size: 12.5px; font-weight: 600; margin-top: 4px; }

/* ---- Learn view (Premium) ---- */
.learn-body { padding: 0 24px 40px; }
.learn-premium-banner { display: flex; justify-content: space-between; align-items: center; gap: 16px; background: linear-gradient(120deg, var(--accent-soft, rgba(201,154,32,.12)), transparent); border: 1px solid var(--border-subtle); border-radius: 14px; padding: 16px 20px; margin-bottom: 22px; flex-wrap: wrap; }
.learn-rail { display: grid; grid-template-columns: 1.4fr repeat(3, 1fr); gap: 14px; padding: 0 24px 22px; }
.learn-review-card { display: flex; flex-direction: column; justify-content: center; gap: 2px; background: linear-gradient(135deg, var(--accent-bright), var(--accent)); color: var(--on-accent); border-radius: 16px; padding: 18px 20px; text-decoration: none; }
.lr-big { font-size: 34px; font-weight: 800; line-height: 1; } .lr-lbl { font-size: 12.5px; opacity: .9; }
.lr-go { margin-top: 8px; font-size: 12.5px; font-weight: 700; }
.learn-stat { background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: 16px; padding: 16px 18px; display: flex; flex-direction: column; justify-content: center; text-decoration: none; color: var(--text); }
.learn-stat-lbl { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.learn-stat-val { font-size: 24px; font-weight: 700; margin-top: 2px; } .learn-stat-val.small { font-size: 15px; color: var(--link, var(--accent)); }
.learn-deck-cta:hover { border-color: var(--accent); }
.learn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.learn-topic { background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: 16px; padding: 18px; }
.learn-topic-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.learn-topic-title { font-size: 15px; font-weight: 700; margin: 0; text-transform: capitalize; }
.learn-topic-items { display: flex; flex-direction: column; gap: 8px; }
.learn-item { display: flex; align-items: center; gap: 10px; background: var(--bg); border: 1px solid var(--border-subtle); border-radius: 10px; padding: 10px 12px; text-decoration: none; color: var(--text); font: inherit; font-size: 13.5px; text-align: left; cursor: pointer; width: 100%; }
.learn-item:hover { border-color: var(--accent); background: var(--bg-hover); }
.learn-item-title { flex: 1; } .learn-item-ico { font-size: 15px; }
.learn-lock { opacity: .6; }
.learn-mastery { font-size: 12px; font-weight: 700; color: var(--success); background: color-mix(in srgb, var(--success) 14%, transparent); padding: 2px 9px; border-radius: var(--r-pill); }
.learn-mastery.none { color: var(--text-dim); background: var(--bg-hover); }
.learn-stage { padding: 0 24px 40px; max-width: 840px; }
.learn-player-head { display: flex; align-items: center; gap: 14px; }
.learn-crumb { font-weight: 700; color: var(--text); }
.learn-prov { padding: 0 24px 12px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.trad-tag { background: var(--bg-hover); padding: 1px 8px; border-radius: var(--r-pill); text-transform: capitalize; }
.learn-next { margin-top: 20px; display: inline-block; }
.learn-review-empty { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.lr-check { width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 50%; background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); display: grid; place-items: center; font-size: 28px; font-weight: 800; }

/* ---- Pricing view (M4) ---- */
.price-toggle-row { display: flex; justify-content: center; padding: 0 24px 22px; }
.price-toggle { display: inline-flex; background: var(--bg-panel); border: 1px solid var(--border-subtle); border-radius: var(--r-pill); padding: 3px; }
.price-toggle-btn { background: none; border: 0; color: var(--text-muted); font: inherit; font-size: 13px; padding: 7px 16px; border-radius: var(--r-pill); cursor: pointer; }
.price-toggle-btn.on { background: var(--bg-elevated); color: var(--text); font-weight: 600; box-shadow: var(--shadow-sm, 0 1px 3px rgba(0,0,0,.1)); }
.price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; max-width: 960px; margin: 0 auto; padding: 0 24px; align-items: stretch; }
.price-card { position: relative; background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: 18px; padding: 26px 22px; display: flex; flex-direction: column; gap: 8px; }
.price-card.featured { border-color: var(--accent); box-shadow: 0 8px 40px color-mix(in srgb, var(--accent) 18%, transparent); }
.price-card.current { outline: 2px solid var(--success); outline-offset: -1px; }
.price-ribbon { position: absolute; top: -11px; left: 50%; transform: translateX(-50%); background: linear-gradient(135deg, var(--accent-bright), var(--accent)); color: var(--on-accent); font-size: 11px; font-weight: 700; padding: 3px 12px; border-radius: var(--r-pill); text-transform: uppercase; letter-spacing: .04em; }
.price-name { font-size: 19px; font-weight: 800; }
.price-tagline { min-height: 18px; }
.price-amount { display: flex; align-items: baseline; gap: 3px; margin: 8px 0; }
.price-num { font-size: 36px; font-weight: 800; letter-spacing: -.02em; }
.price-per { font-size: 14px; color: var(--text-muted); }
.price-features { list-style: none; margin: 6px 0 18px; padding: 0; display: flex; flex-direction: column; gap: 9px; flex: 1; }
.price-features li { position: relative; padding-left: 24px; font-size: 13.5px; color: var(--text); line-height: 1.4; }
.price-features li::before { content: "✓"; position: absolute; left: 0; top: 0; color: var(--success); font-weight: 800; }
.price-cta-current { text-align: center; padding: 10px; font-size: 13px; font-weight: 600; color: var(--success); border: 1px dashed var(--border); border-radius: 10px; }
.price-cta-current.muted { color: var(--text-muted); }
.price-foot { max-width: 720px; margin: 26px auto 40px; text-align: center; padding: 0 24px; line-height: 1.6; }

/* ---- Legal / disclaimer pages (M5) ---- */
.foot-links { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 5px; font-size: 11px; color: var(--text-dim); }
.foot-links a { color: var(--text-dim); text-decoration: none; }
.foot-links a:hover { color: var(--accent); text-decoration: underline; }
/* #view-legal is an absolute .view inside an overflow:hidden .main, so it must scroll internally;
   the nav + body share one centred max-width column (auto margins) instead of hugging the left. */
#view-legal { position: absolute; inset: 0; overflow-y: auto; }
#view-legal .vhead { padding-left: 0; padding-right: 0; }
#view-legal .vhead > div { max-width: 760px; width: 100%; margin: 0 auto; padding: 0 24px; }
.legal-nav { display: flex; gap: 6px; padding: 18px 24px; flex-wrap: wrap; max-width: 760px; margin: 0 auto; }
.legal-tab { padding: 7px 15px; border-radius: var(--r-pill); border: 1px solid var(--border-subtle); background: var(--bg-elevated); color: var(--text-muted); font-size: 13px; text-decoration: none; }
.legal-tab.on { background: var(--accent-soft, rgba(201,154,32,.14)); color: var(--accent-bright, var(--accent)); border-color: transparent; font-weight: 600; }
.legal-tab:hover { color: var(--text); }
.legal-body { max-width: 760px; margin: 0 auto; padding: 0 24px 56px; }
.legal-h { font-size: 15.5px; font-weight: 700; margin: 26px 0 8px; color: var(--text); }
.legal-p { font-size: 14.5px; line-height: 1.7; color: var(--text); margin: 0 0 12px; }
.legal-ul { margin: 0 0 14px; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.legal-ul li { font-size: 14px; line-height: 1.6; color: var(--text); }
.legal-link { color: var(--link, var(--accent)); text-decoration: none; font-weight: 600; }
.legal-link:hover { text-decoration: underline; }
.legal-foot { margin-top: 24px; }
.legal-callout { display: flex; gap: 14px; align-items: flex-start; background: var(--accent-soft, rgba(201,154,32,.1)); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--border)); border-radius: 14px; padding: 18px 20px; margin-bottom: 8px; }
.legal-callout-ico { font-size: 26px; line-height: 1; flex: none; }
.legal-callout .legal-p { margin: 6px 0 0; }
.legal-cta-row { display: flex; gap: 12px; margin: 6px 0 16px; flex-wrap: wrap; }

/* ---- Signup landing page ---- */
.signup-wrap { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 44px; max-width: 1080px; margin: 0 auto; padding: 32px 24px 60px; align-items: start; }
@media (max-width: 900px) { .signup-wrap { grid-template-columns: 1fr; gap: 30px; } .signup-formcol { order: -1; } }
.signup-hero { padding-top: 8px; }
.signup-badge { display: inline-block; font-weight: 700; font-size: 13px; letter-spacing: .04em; color: var(--accent-bright, var(--accent)); background: var(--accent-soft, rgba(201,154,32,.14)); padding: 5px 13px; border-radius: var(--r-pill); margin-bottom: 18px; }
.signup-title { font-family: var(--serif); font-size: 34px; font-weight: 800; line-height: 1.12; letter-spacing: -.02em; margin: 0 0 14px; color: var(--text); }
.signup-lede { font-size: 15.5px; line-height: 1.65; color: var(--text-muted); margin: 0 0 26px; max-width: 520px; }
.signup-benefits { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 20px; margin-bottom: 30px; }
@media (max-width: 560px) { .signup-benefits { grid-template-columns: 1fr; } }
.signup-benefit { display: flex; gap: 12px; align-items: flex-start; }
.signup-benefit-ico { font-size: 22px; line-height: 1.2; flex: none; }
.signup-benefit-h { font-weight: 700; font-size: 14.5px; color: var(--text); margin-bottom: 2px; }
.signup-benefit-p { font-size: 13px; line-height: 1.55; color: var(--text-muted); }
.signup-tiers { border-top: 1px solid var(--border-subtle); padding-top: 22px; }
.signup-tiers-head { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-bottom: 14px; }
.signup-tier-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }
.signup-tier { position: relative; border: 1px solid var(--border-subtle); border-radius: 14px; padding: 14px 14px 16px; background: var(--bg-elevated); }
.signup-tier.featured { border-color: var(--accent); box-shadow: 0 6px 24px color-mix(in srgb, var(--accent) 14%, transparent); }
.signup-tier-tag { position: absolute; top: -9px; left: 12px; font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; background: var(--success); color: #fff; padding: 2px 8px; border-radius: var(--r-pill); }
.signup-tier.featured .signup-tier-tag { background: linear-gradient(135deg, var(--accent-bright), var(--accent)); color: var(--on-accent); }
.signup-tier-name { font-weight: 700; font-size: 14px; }
.signup-tier-price { font-size: 20px; font-weight: 800; margin: 3px 0; letter-spacing: -.01em; }
.signup-tier-note { font-size: 11.5px; line-height: 1.4; color: var(--text-muted); }
.signup-compare { font-size: 13px; font-weight: 600; color: var(--link, var(--accent)); text-decoration: none; }
.signup-compare:hover { text-decoration: underline; }
.signup-card { background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: 20px; padding: 28px 26px; box-shadow: 0 12px 48px rgba(0,0,0,.08); position: sticky; top: 24px; display: flex; flex-direction: column; gap: 9px; }
.signup-card-title { font-size: 20px; font-weight: 800; margin: 0; }
.signup-card-sub { margin: 0 0 6px; }
.signup-submit { margin-top: 8px; font-size: 15px; padding: 12px; }
.signup-legal { margin: 12px 0 0; line-height: 1.5; }
.signup-signin { margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--border-subtle); }

/* ---- topbar auth buttons (signed-out) ---- */
.auth-signin-link { background: none; border: 0; color: var(--text-muted); font: inherit; font-size: 13.5px; cursor: pointer; padding: 6px 8px; border-radius: 8px; }
.auth-signin-link:hover { color: var(--text); }
.auth-signup-btn { display: inline-block; background: linear-gradient(135deg, var(--accent-bright), var(--accent)); color: var(--on-accent); font-size: 13px; font-weight: 700; padding: 7px 15px; border-radius: var(--r-pill); text-decoration: none; margin-left: 4px; transition: filter .14s, box-shadow .14s; }
.auth-signup-btn:hover { filter: brightness(1.06); box-shadow: 0 4px 14px rgba(201,154,32,.32); }

/* ---- welcome / thank-you screen ---- */
.welcome-wrap { max-width: 640px; margin: 0 auto; padding: 40px 24px 60px; }
.welcome-card { background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: 22px; padding: 40px 36px; box-shadow: 0 16px 60px rgba(0,0,0,.09); text-align: center; }
.welcome-check { width: 68px; height: 68px; margin: 0 auto 18px; border-radius: 50%; display: grid; place-items: center; font-size: 34px; font-weight: 800; color: var(--on-accent); background: linear-gradient(135deg, var(--accent-bright), var(--accent)); box-shadow: 0 8px 26px rgba(201,154,32,.3); animation: welcomePop .4s cubic-bezier(.2,.9,.3,1.3); }
@keyframes welcomePop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .welcome-check { animation: none; } }
.welcome-eyebrow { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent-bright, var(--accent)); margin-bottom: 8px; }
.welcome-title { font-family: var(--serif); font-size: 30px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 12px; color: var(--text); }
.welcome-lede { font-size: 15px; line-height: 1.65; color: var(--text-muted); margin: 0 auto 24px; max-width: 480px; }
.welcome-verify { display: flex; gap: 12px; align-items: flex-start; text-align: left; background: var(--accent-soft, rgba(201,154,32,.1)); border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--border)); border-radius: 14px; padding: 14px 16px; margin: 0 0 24px; }
.welcome-verify-ico { font-size: 20px; flex: none; }
.welcome-verify p { margin: 3px 0 0; }
.welcome-steps-head { text-align: left; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin-bottom: 10px; }
.welcome-steps { display: flex; flex-direction: column; gap: 10px; margin-bottom: 26px; }
.welcome-step { display: flex; align-items: center; gap: 13px; text-align: left; background: var(--bg); border: 1px solid var(--border-subtle); border-radius: 13px; padding: 13px 15px; text-decoration: none; color: var(--text); transition: border-color .14s, transform .14s; }
.welcome-step:hover { border-color: var(--accent); transform: translateY(-1px); }
.welcome-step-ico { font-size: 22px; flex: none; }
.welcome-step-h { font-weight: 700; font-size: 14.5px; }
.welcome-step-p { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }
.welcome-step-arrow { margin-left: auto; color: var(--link, var(--accent)); font-weight: 700; }
.welcome-cta-row { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---- tags + extended annotation UI ---- */
.annot-sep { width: 1px; align-self: stretch; background: var(--border); margin: 2px 3px; }
mark.hl[data-tagged]::after { content: "🏷"; font-size: .58em; vertical-align: super; margin-left: 1px; opacity: .7; }
.annot-menu-tags { display: flex; flex-wrap: wrap; gap: 4px; width: 100%; padding: 4px 2px 2px; border-top: 1px solid var(--border-subtle); margin-top: 2px; }
.annot-tag-chip { font-size: 11px; background: var(--accent-soft, rgba(201,154,32,.14)); color: var(--accent-bright, var(--accent)); padding: 1px 8px; border-radius: var(--r-pill); font-weight: 600; }
.annot-tag-hint { margin: 2px 0 6px; line-height: 1.4; }
/* study: tag filter bar + chips */
.study-tagbar { display: flex; flex-wrap: wrap; gap: 7px; margin: -6px 0 18px; }
.study-tag-filter { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; padding: 4px 11px; border-radius: var(--r-pill); border: 1px solid var(--border-subtle); background: var(--bg-elevated); color: var(--text-muted); cursor: pointer; font-weight: 600; }
.study-tag-filter:hover { color: var(--text); border-color: var(--accent); }
.study-tag-filter.on { background: var(--accent-soft, rgba(201,154,32,.16)); color: var(--accent-bright, var(--accent)); border-color: transparent; }
.study-tag-count { font-size: 10.5px; background: color-mix(in srgb, var(--text-dim) 22%, transparent); color: var(--text-muted); padding: 0 6px; border-radius: var(--r-pill); }
.study-hl-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.study-tag-chip { font-size: 11.5px; background: var(--bg-hover); color: var(--text-muted); border: 0; padding: 2px 9px; border-radius: var(--r-pill); cursor: pointer; font-weight: 600; }
.study-tag-chip:hover { background: var(--accent-soft, rgba(201,154,32,.16)); color: var(--accent-bright, var(--accent)); }
/* make tafsīr paragraphs + word glosses read as annotatable */
.q-taf-text p.annot-block { border-radius: 4px; }
.q-morph-gloss.annot-block { cursor: text; }

/* ---- Q&A card header (topic + bookmark) ---- */
.qa-card-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.qa-card-top .qa-cat { margin: 0; }
.qa-card-top .bookmark-btn { margin-left: auto; }

/* ============================================================ Charts & Insights (V0/V1) */
.insights { margin: 26px 0 8px; }
.insights-head h3 { margin: 0 0 2px; font-size: 1.15rem; }
.insights-head .sub { color: var(--text-muted); font-size: .88rem; margin-bottom: 14px; }
.insights-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.chart-card {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px 14px 8px; min-width: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.chart-card.cc-wide { grid-column: 1 / -1; }
.cc-title { font-weight: 650; font-size: .95rem; color: var(--text); }
.cc-hint { color: var(--text-dim); font-size: .78rem; margin-top: 1px; }
.chart-mount { width: 100%; height: 240px; margin-top: 8px; }
.chart-card.cc-wide .chart-mount { height: 180px; }
.insights-empty {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 14px;
  background: var(--bg-elevated); border: 1px dashed var(--border);
  border-radius: 14px; padding: 22px; color: var(--text-muted); font-size: .92rem;
}
.insights-empty .ie-emoji { font-size: 1.8rem; }
.empty-sm { color: var(--text-muted); font-size: .88rem; padding: 12px; grid-column: 1 / -1; }
/* generic chart mount used by corpus views (matrix, sunburst, sankey) */
.viz-chart { width: 100%; height: 440px; }
.viz-chart.tall { height: 560px; }
@media (max-width: 640px) { .chart-mount { height: 210px; } .viz-chart { height: 360px; } }

/* states "📊 Charts" mode + quran roots treemap layout */
.states-charts { display: grid; gap: 16px; padding: 4px 2px 20px; }
#qRootsMount { margin-top: 12px; }

/* coverage matrix controls + dynamic-height chart */
.matrix-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 4px 0 12px; }
.mx-toggle { display: inline-flex; align-items: center; gap: 7px; font-size: .88rem; color: var(--text); cursor: pointer; user-select: none; }
.mx-toggle input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.mx-note { color: var(--text-dim); }
.viz-chart.matrix-chart { height: var(--mx-h, 560px); }

/* ============================================================ Learn redesign (LEARN_REDESIGN L2/L3/L4) */
.learn-body { margin-top: 8px; }
/* header band */
.learn-hero { display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 16px; padding: 18px 20px; margin-bottom: 16px; }
.xp-ring { --pct: 0; width: 88px; height: 88px; border-radius: 50%; flex: 0 0 auto;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--bg-hover) 0);
  display: grid; place-items: center; }
.xp-ring-inner { width: 68px; height: 68px; border-radius: 50%; background: var(--bg-elevated);
  display: grid; place-items: center; text-align: center; }
.xp-ring-lvl { font-weight: 700; font-size: .82rem; color: var(--text); line-height: 1.1; padding: 0 4px; }
.xp-ring-pct { font-size: .68rem; color: var(--text-dim); }
.lh-mid { flex: 1; min-width: 200px; }
.lh-xp { font-size: 1.5rem; font-weight: 750; color: var(--text); }
.lh-sub { color: var(--text-muted); font-size: .86rem; margin: 2px 0 10px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.lh-dot { color: var(--text-dim); }
.lh-continue { display: inline-block; }
.lh-spark { width: 160px; height: 64px; flex: 0 0 auto; }
@media (max-width: 640px) { .lh-spark { display: none; } }
/* tabs */
.learn-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.learn-tab { background: none; border: 0; padding: 9px 14px; font-size: .92rem; font-weight: 600; color: var(--text-muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.learn-tab:hover { color: var(--text); }
.learn-tab.on { color: var(--accent); border-bottom-color: var(--accent); }
/* paths grid */
.lp-level-head { font-weight: 700; font-size: .95rem; color: var(--text-muted); margin: 14px 0 8px; }
.lp-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); margin-bottom: 8px; }
.lp-card { display: flex; gap: 14px; align-items: center; text-align: left; background: var(--bg-elevated);
  border: 1px solid var(--border); border-radius: 14px; padding: 14px; cursor: pointer; color: inherit; text-decoration: none;
  transition: border-color .15s, transform .15s; font: inherit; }
.lp-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.lp-card.locked { opacity: .82; }
.lp-ring { --pct: 0; width: 52px; height: 52px; border-radius: 50%; flex: 0 0 auto;
  background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--bg-hover) 0); display: grid; place-items: center; }
.lp-ring span { width: 40px; height: 40px; border-radius: 50%; background: var(--bg-elevated); display: grid; place-items: center;
  font-size: .74rem; font-weight: 700; color: var(--text); }
.lp-card-title { font-weight: 700; font-size: 1rem; }
.lp-card-blurb { color: var(--text-muted); font-size: .82rem; margin: 2px 0 4px; }
.lp-card-meta { color: var(--text-dim); font-size: .78rem; font-weight: 600; }
/* unit ladder */
.lp-ladder { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.lp-unit { display: flex; gap: 14px; align-items: center; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; text-decoration: none; color: inherit; transition: border-color .15s; }
a.lp-unit:hover { border-color: var(--accent); }
.lp-unit-mark { width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto; display: grid; place-items: center;
  font-weight: 700; background: var(--bg-hover); color: var(--text-muted); }
.lp-completed .lp-unit-mark { background: var(--accent); color: var(--on-accent, #2a1f07); }
.lp-available .lp-unit-mark, .lp-in_progress .lp-unit-mark { background: var(--accent-soft); color: var(--accent); }
.lp-locked { opacity: .6; }
.lp-checkpoint { border-style: dashed; }
.lp-unit-body { flex: 1; min-width: 0; }
.lp-unit-title { font-weight: 650; }
.lp-unit-blurb { color: var(--text-muted); font-size: .82rem; margin: 1px 0 4px; }
.lp-unit-phases { display: flex; gap: 6px; }
.lp-phasedot { font-size: .8rem; opacity: .75; }
.lp-unit-score { font-weight: 700; color: var(--accent); font-size: .9rem; }
/* badges */
.badge-head { font-weight: 700; color: var(--text-muted); margin-bottom: 12px; }
.badge-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.badge-tile { text-align: center; background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px; padding: 16px 12px; }
.badge-tile.locked { opacity: .55; filter: grayscale(.6); }
.badge-tile.owned { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent-soft) inset; }
.badge-ico { font-size: 2rem; }
.badge-lbl { font-weight: 700; margin-top: 4px; }
.badge-desc { color: var(--text-muted); font-size: .78rem; margin-top: 2px; }
/* unit player */
.up-stepper { display: flex; gap: 6px; margin: 8px 0 14px; flex-wrap: wrap; }
.up-step { display: flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; font-size: .8rem; font-weight: 600;
  background: var(--bg-hover); color: var(--text-dim); }
.up-step.active { background: var(--accent); color: var(--on-accent, #2a1f07); }
.up-step.done { background: var(--accent-soft); color: var(--accent); }
.up-phase { font-weight: 700; font-size: .82rem; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px; }
.up-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  position: sticky; bottom: 0; z-index: 4; background: var(--bg); border-top: 1px solid var(--border);
  padding-top: 12px; padding-bottom: 14px; margin-top: 16px; box-shadow: 0 -8px 16px -8px rgba(0,0,0,.14); }
.up-next { flex: 0 0 auto; }
.up-prov { flex: 1 1 auto; min-width: 0; }
.up-prov { color: var(--text-dim); }
.up-next.ready { animation: upPulse 1.4s ease-in-out infinite; }
@keyframes upPulse { 0%,100% { box-shadow: 0 0 0 0 var(--accent-soft); } 50% { box-shadow: 0 0 0 6px transparent; } }
:root[data-motion="reduce"] .up-next.ready { animation: none; }
.up-complete { text-align: center; padding: 30px 16px; }
.up-complete-ring { width: 76px; height: 76px; border-radius: 50%; margin: 0 auto 14px; display: grid; place-items: center;
  font-size: 2.2rem; background: var(--accent-soft); color: var(--accent); }
.up-complete-ring.done { background: var(--accent); color: var(--on-accent, #2a1f07); }
.up-xp { font-size: 1.8rem; font-weight: 800; color: var(--accent); margin: 6px 0; }
.up-pathdone { font-weight: 700; margin: 6px 0; }
.up-cta { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
/* celebration modals */
.celebrate-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: grid; place-items: center; z-index: 9998; padding: 20px; }
.celebrate-card { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 18px; padding: 28px 30px; text-align: center; max-width: 360px; }
.celebrate-card.pop { animation: celebPop .4s cubic-bezier(.2,1.3,.4,1); }
@keyframes celebPop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.celebrate-emoji { font-size: 3rem; }
.celebrate-kicker { text-transform: uppercase; letter-spacing: .08em; font-size: .74rem; font-weight: 700; color: var(--accent); margin-top: 4px; }
.celebrate-card h3 { margin: 4px 0 6px; font-size: 1.35rem; }
.celebrate-go { margin-top: 16px; }
/* leaderboard */
.lb-optin { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; }
.lb-optin-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.lb-alias-input { max-width: 180px; }
.lb-leave { color: var(--danger, #c0523f); }
.lb-tabs { display: flex; gap: 4px; margin-bottom: 12px; }
.lb-tab { background: var(--bg-hover); border: 0; padding: 7px 14px; border-radius: 999px; font-weight: 600; font-size: .85rem; color: var(--text-muted); cursor: pointer; }
.lb-tab.on { background: var(--accent); color: var(--on-accent, #2a1f07); }
.lb-board { display: flex; flex-direction: column; gap: 4px; }
.lb-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 10px; background: var(--bg-elevated); border: 1px solid var(--border-subtle); }
.lb-row.you { border-color: var(--accent); background: var(--accent-soft); }
.lb-rank { width: 40px; font-weight: 700; color: var(--text-muted); }
.lb-rank.medal { font-size: 1.2rem; }
.lb-alias { flex: 1; font-weight: 600; }
.lb-xp { font-weight: 700; color: var(--accent); }
.lb-yourank { display: flex; gap: 12px; align-items: center; margin-top: 12px; padding: 12px 14px; border-radius: 10px;
  background: var(--accent-soft); font-weight: 600; }
.lb-pct { background: var(--accent); color: var(--on-accent, #2a1f07); border-radius: 999px; padding: 2px 10px; font-size: .78rem; }
.lb-yourank .lb-xp { margin-left: auto; }
.lb-pulse { text-align: center; padding: 30px 16px; background: var(--bg-elevated); border: 1px dashed var(--border); border-radius: 14px; }
.lb-pulse-emoji { font-size: 2.4rem; }
.lb-pulse-title { font-weight: 700; font-size: 1.1rem; margin: 6px 0; }
.lb-pulse-you { margin-top: 10px; font-weight: 600; color: var(--accent); }

/* ---- Learn view: scroll + centered content (fix: was overflow:visible + left-aligned) ----
   The sticky .vhead stays full-width; everything below it centers at a readable column, and the
   view scrolls so the unit-player "Next →" / completion CTAs are always reachable. */
#view-learn { overflow-y: auto; overflow-x: hidden; padding-bottom: 56px; }
#view-learn > *:not(.vhead) {
  max-width: 980px; width: 100%; margin-left: auto; margin-right: auto;
  padding-left: 24px; padding-right: 24px; box-sizing: border-box;
}
/* the unit player reads best at a tighter measure (like the Qur'an/Hadith readers) */
#view-learn > .up-stepper, #view-learn > .up-stage, #view-learn > .up-footer { max-width: 880px; }

/* SEO/AIO — server-rendered content shown to no-JS crawlers/AI engines before the SPA boots.
   The SPA removes #seo-ssr in boot(); these styles only matter for JS-less clients. */
.seo-ssr { max-width: 760px; margin: 0 auto; padding: 40px 24px 64px; line-height: 1.6; }
.seo-ssr h1 { font-size: 1.9rem; margin: 0 0 .5em; line-height: 1.2; }
.seo-ssr h2 { font-size: 1.25rem; margin: 1.4em 0 .4em; }
.seo-ssr p { margin: 0 0 1em; }
.seo-ssr table { border-collapse: collapse; margin: 0 0 1em; }
.seo-ssr th, .seo-ssr td { text-align: left; padding: 4px 14px 4px 0; vertical-align: top; }
.seo-ssr th { font-weight: 600; white-space: nowrap; opacity: .8; }
.seo-ssr nav { opacity: .85; }

/* ============================================================================
   HOME — the living "Today on Chronicle" landing page (v184)
   ============================================================================ */
/* .view is position:absolute inset:0 inside a .main that clips overflow — so the
   home view must scroll INTERNALLY (like .enc-article / .lib do), or its lower
   content is cut off with no page scroll. */
#view-home { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.hm-wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px 64px; }
.hm-loading { padding: 60px 0; text-align: center; color: var(--text-dim); }

/* ── hero ── */
.hm-hero { text-align: center; padding: 56px 0 40px; }
.hm-dateline { font-size: 12.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); font-weight: 600; margin-bottom: 18px; }
.hm-h1 { font-family: var(--serif); font-size: clamp(30px, 5.2vw, 52px); line-height: 1.1; letter-spacing: -.02em; color: var(--text); margin: 0 auto 18px; max-width: 16ch; }
.hm-tagline { font-size: clamp(15px, 2vw, 17.5px); line-height: 1.6; color: var(--text-dim); max-width: 62ch; margin: 0 auto 30px; }
.hm-search { display: flex; gap: 8px; max-width: 620px; margin: 0 auto 22px; }
.hm-search-input { flex: 1; padding: 15px 20px; border: 1.5px solid var(--border); border-radius: var(--r-pill); background: var(--bg-elevated); color: var(--text); font-size: 16px; box-shadow: var(--shadow-sm); }
.hm-search-input:focus { outline: 3px solid var(--ring); outline-offset: 1px; border-color: var(--accent); }
.hm-search-btn { padding: 0 26px; border: none; border-radius: var(--r-pill); background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 15px; cursor: pointer; }
.hm-search-btn:hover { background: var(--accent-2, var(--accent)); }
.hm-modes { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.hm-mode { display: inline-flex; align-items: center; gap: 8px; padding: 11px 20px; border: 1.5px solid var(--border); border-radius: var(--r-pill); background: var(--bg-elevated); color: var(--text); font-size: 14.5px; font-weight: 600; cursor: pointer; transition: transform .12s, border-color .12s; }
.hm-mode:hover { transform: translateY(-2px); border-color: var(--accent); }
.hm-mode-ic { font-size: 17px; }

/* ── section shell ── */
.hm-sec { margin-top: 52px; }
.hm-sec-h { margin-bottom: 20px; }
.hm-sec-h h2 { font-family: var(--serif); font-size: 25px; letter-spacing: -.01em; color: var(--text); margin: 0 0 4px; }
.hm-sec-h p { font-size: 14px; color: var(--text-dim); margin: 0; }

/* ── today strip ── */
.hm-today { display: grid; grid-template-columns: 1.15fr 1.15fr .9fr; gap: 16px; }
.hm-card { background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: var(--r); padding: 20px 20px 18px; border-top: 3px solid var(--accent); display: flex; flex-direction: column; box-shadow: var(--shadow-sm); }
.hm-ayah { border-top-color: #b07d2b; }
.hm-hadith { border-top-color: #2f7668; }
.hm-name { border-top-color: #7a603a; }
.hm-card-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.hm-card-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; color: var(--accent); }
.hm-card-meta { font-size: 12px; color: var(--text-muted); }
.hm-ar { font-family: var(--quran-ar, "Scheherazade New", "Amiri", serif); font-size: 26px; line-height: 1.9; color: var(--text); margin: 4px 0 12px; text-align: right; }
.hm-name-ar { font-size: 40px; text-align: center; margin: 6px 0 8px; }
.hm-en { font-size: 14.5px; line-height: 1.62; color: var(--text-dim); margin: 0 0 14px; flex: 1; }
.hm-name-en { font-family: var(--serif); font-size: 20px; color: var(--text); text-align: center; margin: 0 0 6px; }
.hm-name-mean { font-size: 15px; color: var(--accent); text-align: center; font-weight: 600; margin: 0 0 10px; }
.hm-name-root { font-size: 12.5px; line-height: 1.55; color: var(--text-muted); margin: 0 0 12px; flex: 1; }
.hm-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.hm-chip { font-size: 11px; padding: 3px 9px; border-radius: var(--r-pill); font-weight: 600; background: var(--bg-hover); color: var(--text-dim); }
.hm-chip-coll { background: color-mix(in srgb, #2f7668 16%, transparent); color: #2f7668; }
.hm-chip-sahih { background: color-mix(in srgb, #2e7d46 18%, transparent); color: #2e7d46; }
.hm-chip-trad { border: 1px solid var(--border); }
.hm-card-link { align-self: flex-start; background: none; border: none; padding: 0; color: var(--link); font-size: 13.5px; font-weight: 600; cursor: pointer; }
.hm-card-link:hover { text-decoration: underline; }

/* ── start / shelf ── */
.hm-start { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.hm-start-tile { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 18px; border: 1px solid var(--border-subtle); border-radius: var(--r); background: var(--bg-elevated); cursor: pointer; transition: border-color .12s, transform .12s; }
.hm-start-tile:hover { border-color: var(--accent); transform: translateY(-2px); }
.hm-start-ic { font-size: 22px; }
.hm-start-t { font-weight: 700; color: var(--text); font-size: 15px; }
.hm-start-d { font-size: 13px; color: var(--text-dim); }
.hm-due { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; margin-bottom: 14px; background: color-mix(in srgb, var(--accent) 12%, var(--bg-elevated)); border: 1px solid var(--accent-soft, var(--border)); border-radius: var(--r); font-size: 14.5px; color: var(--text); }
.hm-due-btn { background: var(--accent); color: var(--on-accent); border: none; padding: 8px 16px; border-radius: var(--r-pill); font-weight: 700; cursor: pointer; }

/* ── this week ── */
.hm-week { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.hm-week-card { display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 20px; border: 1px solid var(--border-subtle); border-left: 4px solid var(--accent); border-radius: var(--r); background: var(--bg-elevated); cursor: pointer; transition: transform .12s, box-shadow .12s; }
.hm-week-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.hm-slot-figure { border-left-color: #7a603a; } .hm-slot-state { border-left-color: #7d6a3a; }
.hm-slot-topic { border-left-color: #b07d2b; } .hm-slot-country { border-left-color: #4a6a9a; }
.hm-slot-event { border-left-color: #a2503f; } .hm-slot-explorer { border-left-color: #5a6aa0; }
.hm-week-kicker { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--text-muted); }
.hm-week-title { font-family: var(--serif); font-size: 19px; color: var(--text); line-height: 1.2; }
.hm-week-blurb { font-size: 13.5px; line-height: 1.55; color: var(--text-dim); flex: 1; }
.hm-week-go { font-size: 13px; font-weight: 600; color: var(--link); margin-top: 2px; }

/* ── lanes ── */
.hm-lanes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.hm-lane { padding: 18px; border: 1px solid var(--border-subtle); border-radius: var(--r); background: var(--bg-panel, var(--bg-elevated)); }
.hm-lane-h { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.hm-lane-ic { font-size: 18px; }
.hm-lane-h h3 { font-size: 14.5px; margin: 0; color: var(--text); }
.hm-lane-links { display: flex; flex-direction: column; gap: 7px; }
.hm-lane-link { text-align: left; background: none; border: none; padding: 0; color: var(--link); font-size: 13.5px; cursor: pointer; }
.hm-lane-link:hover { text-decoration: underline; }

/* ── wander ── */
.hm-wander { display: flex; flex-wrap: wrap; gap: 9px; }
.hm-wander-chip { padding: 9px 16px; border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--bg-elevated); color: var(--text); font-size: 13.5px; cursor: pointer; transition: border-color .12s; }
.hm-wander-chip:hover { border-color: var(--accent); color: var(--accent); }

/* ── trust ── */
.hm-trust { margin-top: 56px; padding: 30px; border: 1px solid var(--border-subtle); border-radius: var(--r); background: var(--bg-panel, var(--bg-elevated)); }
.hm-trust-h { font-family: var(--serif); font-size: 21px; color: var(--text); margin: 0 0 18px; }
.hm-trust-pts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-bottom: 22px; }
.hm-trust-pt { display: flex; gap: 11px; }
.hm-trust-ic { font-size: 18px; color: var(--accent); }
.hm-trust-pt b { display: block; font-size: 14px; color: var(--text); margin-bottom: 3px; }
.hm-trust-pt p { font-size: 13px; line-height: 1.5; color: var(--text-dim); margin: 0; }
.hm-counts { display: flex; flex-wrap: wrap; gap: 26px; padding: 18px 0; border-top: 1px solid var(--border-subtle); border-bottom: 1px solid var(--border-subtle); margin-bottom: 18px; }
.hm-count { display: flex; flex-direction: column; }
.hm-count b { font-family: var(--serif); font-size: 24px; color: var(--accent); }
.hm-count span { font-size: 12px; color: var(--text-dim); }
.hm-trust-links { display: flex; flex-wrap: wrap; gap: 18px; }
.hm-link { background: none; border: none; padding: 0; color: var(--link); font-weight: 600; font-size: 13.5px; cursor: pointer; }
.hm-link:hover { text-decoration: underline; }

/* ── responsive ── */
@media (max-width: 860px) {
  .hm-today, .hm-week, .hm-lanes, .hm-trust-pts { grid-template-columns: 1fr 1fr; }
  .hm-start { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .hm-today, .hm-week, .hm-lanes, .hm-trust-pts { grid-template-columns: 1fr; }
  .hm-hero { padding: 32px 0 26px; }
  .hm-search { flex-direction: column; }
  .hm-search-btn { padding: 13px; }
}
.hm-card-note { font-size: 12px; font-style: italic; color: var(--text-muted); margin: 0 0 12px; line-height: 1.45; }

/* Single-hadith permalink (#hadith/one/…) — scroll + centre + card, matching the reader (v186) */
#view-hadithOne { position: absolute; inset: 0; }
.seg-wrap.hone { height: 100%; }
.hone .hone-body { flex: 1; min-height: 0; overflow-y: auto; padding: 22px 24px 64px; }
.hone .hadith-card, .hone .hone-nav { max-width: 860px; margin-left: auto; margin-right: auto; }
.hone .hone-nav { margin-top: 18px; }
.hone .hadith-ar { word-break: break-word; overflow-wrap: anywhere; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-subtle); }
.hone .hadith-note { margin-top: 14px; }
.hone .chip.coll { background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.hone .chip.trad { border: 1px solid var(--border); }

/* ============================================================================
   LEXICON — Lane's Arabic-English Lexicon, learner-first master-detail (v187)
   ============================================================================ */
.seg-wrap.lex { height: 100%; }
.lex-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px 1fr; }
.lex-rail { border-right: 1px solid var(--border-subtle); overflow-y: auto; padding: 16px 14px 40px;
  display: flex; flex-direction: column; gap: 12px; background: var(--bg-panel); }
.lex-search { width: 100%; padding: 10px 14px; border: 1.5px solid var(--border); border-radius: var(--r-pill);
  background: var(--bg-elevated); color: var(--text); font-size: 14px; }
.lex-search:focus { outline: 2px solid var(--ring); border-color: var(--accent); }
.lex-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-dim); cursor: pointer; }
.lex-rail-lbl { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-muted); font-weight: 700; margin-top: 4px; }
.lex-letters { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.lex-letter { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; font-size: 18px;
  font-family: var(--quran-ar); border: 1px solid var(--border-subtle); border-radius: var(--r-sm);
  background: var(--bg-elevated); color: var(--text); cursor: pointer; transition: all .1s; }
.lex-letter:hover { border-color: var(--accent); color: var(--accent); }
.lex-letter.active { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.lex-list { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.lex-list-h { font-size: 11px; color: var(--text-muted); padding: 6px 4px; text-transform: uppercase; letter-spacing: .05em; }
.lex-root-row { display: grid; grid-template-columns: auto 1fr; align-items: baseline; gap: 8px 10px;
  text-align: left; padding: 9px 12px; border: none; border-radius: var(--r-sm); background: none;
  color: var(--text); cursor: pointer; }
.lex-root-row:hover { background: var(--bg-hover); }
.lex-root-row.active { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.lex-root-ar { font-family: var(--quran-ar); font-size: 20px; color: var(--text); }
.lex-root-tr { font-size: 12.5px; color: var(--accent); font-style: italic; }
.lex-root-meta { grid-column: 2; font-size: 11.5px; color: var(--text-muted); }
.lex-qbadge { grid-column: 2; justify-self: start; font-size: 10.5px; font-weight: 600; padding: 1px 7px;
  border-radius: var(--r-pill); background: color-mix(in srgb, #2f7668 15%, transparent); color: #2f7668; }
.lex-loading { padding: 30px 16px; color: var(--text-dim); font-size: 13.5px; }

/* detail pane */
.lex-detail { overflow-y: auto; padding: 28px 36px 60px; }
.lex-welcome { max-width: 760px; }
.lex-welcome h2 { font-family: var(--serif); font-size: 26px; color: var(--text); margin: 0 0 10px; }
.lex-lede { font-size: 15px; line-height: 1.65; color: var(--text-dim); margin: 0 0 26px; }
.lex-starter-h { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin: 0 0 12px; }
.lex-starter { display: flex; flex-wrap: wrap; gap: 9px; }
.lex-starter-chip { display: inline-flex; align-items: baseline; gap: 8px; padding: 9px 15px;
  border: 1px solid var(--border-subtle); border-radius: var(--r-pill); background: var(--bg-elevated); cursor: pointer; transition: all .12s; }
.lex-starter-chip:hover { border-color: var(--accent); transform: translateY(-2px); }
.lex-chip-ar { font-family: var(--quran-ar); font-size: 20px; color: var(--text); }
.lex-chip-tr { font-size: 12px; color: var(--accent); font-style: italic; }
.lex-chip-n { font-size: 11.5px; color: var(--text-muted); font-weight: 600; }

.lex-dhead { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 18px; padding-bottom: 18px;
  margin-bottom: 20px; border-bottom: 1px solid var(--border-subtle); }
.lex-droot { font-family: var(--quran-ar); font-size: 46px; color: var(--text); line-height: 1; }
.lex-dtr { font-size: 20px; color: var(--accent); font-style: italic; }
.lex-usage { display: inline-flex; align-items: baseline; gap: 5px; margin-left: auto; padding: 9px 16px;
  border: 1px solid color-mix(in srgb, #2f7668 40%, transparent); border-radius: var(--r-pill);
  background: color-mix(in srgb, #2f7668 10%, transparent); color: #2f7668; font-size: 13px; cursor: pointer; }
.lex-usage:hover { background: color-mix(in srgb, #2f7668 18%, transparent); }
.lex-usage b { font-size: 15px; }
.lex-usage-go { font-weight: 600; }
.lex-usage.none { margin-left: auto; color: var(--text-muted); font-size: 12.5px; border: none; background: none; }
.lex-forms-h { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin: 0 0 14px; font-weight: 700; }
.lex-form { padding: 16px 18px; margin-bottom: 12px; border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent); border-radius: var(--r); background: var(--bg-elevated); }
.lex-form-top { display: flex; align-items: baseline; gap: 12px; }
.lex-form-hw { font-family: var(--quran-ar); font-size: 26px; color: var(--text); }
.lex-form-sense { font-family: var(--serif); font-size: 15.5px; line-height: 1.6; color: var(--text); margin: 8px 0 6px; }
.lex-entry-wrap { margin-top: 8px; }
.lex-entry-wrap summary { cursor: pointer; font-size: 12.5px; color: var(--link); font-weight: 600; user-select: none; }
.lex-entry { margin-top: 10px; font-size: 14px; line-height: 1.75; color: var(--text-dim); }
.lex-entry [dir="rtl"], .lex-entry [lang="ar"] { font-family: var(--quran-ar); font-size: 1.25em; color: var(--text); }
.lex-attr { margin-top: 26px; padding-top: 14px; border-top: 1px solid var(--border-subtle);
  font-size: 11.5px; line-height: 1.5; color: var(--text-muted); }

/* responsive: single column; a selected root swaps the rail for the detail */
@media (max-width: 760px) {
  .lex-body { grid-template-columns: 1fr; }
  .lex-rail { border-right: none; }
  #view-lexicon.detail-open .lex-rail { display: none; }
  #view-lexicon:not(.detail-open) .lex-detail { display: none; }
  .lex-detail { padding: 20px 18px 60px; }
  .lex-droot { font-size: 38px; }
}
.lex-back { display: none; background: none; border: none; color: var(--link); font-weight: 600; font-size: 13px; cursor: pointer; padding: 0 0 14px; }
@media (max-width: 760px) { .lex-back { display: inline-block; } }

/* Prose views that append vhead + content directly to their absolute .view (inside an overflow:hidden
   .main) need an internal scroll, or their content clips on short/mobile viewports (v189 audit fix). */
#view-signup, #view-pricing, #view-account { overflow-y: auto; }

/* ============================================================================
   ENTITY HUB — the search-first directory front-door to the per-entity hubs (v193)
   ============================================================================ */
#view-entities { position: absolute; inset: 0; }
.seg-wrap.entities { height: 100%; }
.eh-body { flex: 1; min-height: 0; overflow-y: auto; padding: 22px 28px 60px; max-width: 1120px; width: 100%; margin: 0 auto; }
.eh-hero { margin-bottom: 18px; }
.eh-lede { font-size: 14.5px; line-height: 1.6; color: var(--text-dim); margin: 0 0 16px; max-width: 70ch; }
.eh-search { width: 100%; max-width: 620px; padding: 13px 18px; border: 1.5px solid var(--border); border-radius: var(--r-pill); background: var(--bg-elevated); color: var(--text); font-size: 15.5px; box-shadow: var(--shadow-sm); }
.eh-search:focus { outline: 3px solid var(--ring); outline-offset: 1px; border-color: var(--accent); }

/* facets */
.eh-facets { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.eh-facet { display: inline-flex; align-items: center; gap: 7px; padding: 7px 14px; border: 1px solid var(--border-subtle); border-radius: var(--r-pill); background: var(--bg-elevated); color: var(--text); font-size: 13px; cursor: pointer; transition: all .12s; }
.eh-facet:hover { border-color: var(--kc, var(--accent)); }
.eh-facet.active { background: var(--kc, var(--accent)); color: #fff; border-color: transparent; font-weight: 600; }
.eh-facet.active .eh-facet-n { color: rgba(255,255,255,.85); }
.eh-facet-n { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.eh-more { position: relative; }
.eh-more > summary { list-style: none; padding: 7px 14px; border: 1px dashed var(--border); border-radius: var(--r-pill); background: none; color: var(--text-dim); font-size: 13px; cursor: pointer; }
.eh-more[open] > summary { color: var(--accent); border-color: var(--accent); }
.eh-more-grid { display: flex; flex-wrap: wrap; gap: 7px; padding: 12px; margin-top: 8px; border: 1px solid var(--border-subtle); border-radius: var(--r); background: var(--bg-panel); max-width: 640px; }
.eh-meta { margin: 2px 0 12px; }

/* results grid */
.eh-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.eh-loading { grid-column: 1/-1; padding: 30px 4px; color: var(--text-dim); }
.eh-card { text-align: left; display: flex; flex-direction: column; gap: 6px; padding: 14px 15px; border: 1px solid var(--border-subtle); border-left: 3px solid var(--kc, var(--accent)); border-radius: var(--r); background: var(--bg-elevated); cursor: pointer; transition: transform .1s, box-shadow .1s; }
.eh-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.eh-card-top { display: flex; align-items: center; justify-content: space-between; }
.eh-kind { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.eh-notable { color: var(--accent); font-size: 13px; }
.eh-name { font-family: var(--serif); font-size: 16px; color: var(--text); line-height: 1.25; }
.eh-foot { margin-top: 2px; }
.eh-foot-nums { font-variant-numeric: tabular-nums; }
.eh-foot-bar { height: 4px; border-radius: 2px; background: var(--bg-hover); margin-top: 5px; overflow: hidden; }
.eh-foot-bar i { display: block; height: 100%; border-radius: 2px; }
.eh-loadmore-row { display: flex; justify-content: center; margin-top: 22px; }
.eh-loadmore { padding: 10px 24px; border: 1px solid var(--border); border-radius: var(--r-pill); background: var(--bg-elevated); color: var(--text); font-weight: 600; font-size: 14px; cursor: pointer; }
.eh-loadmore:hover { border-color: var(--accent); color: var(--accent); }

@media (max-width: 560px) { .eh-body { padding: 18px 16px 60px; } .eh-grid { grid-template-columns: 1fr 1fr; } }
