:root {
  color-scheme: light;
  --em-950: #052a21;
  --em-900: #07392c;
  --em-800: #0b4a39;
  --em-700: #0f5f48;
  --em-600: #14785a;
  --em-100: #dcebe3;
  --em-50: #edf5f0;
  --glaze: #f6f9f5;
  --tile: #ffffff;
  --grout: #dce4dc;
  --grout-strong: #c3cfc5;
  --ink: #0f241c;
  --ink-2: #3d5248;
  --ink-3: #5a6e64;
  --on-em: #f1f8f3;
  --on-em-2: #b4d3c4;
  --gap: #eef2ec;
  --sans: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  --naskh: "Noto Naskh Arabic", "Traditional Arabic", serif;
  --kufi: "Reem Kufi", "Noto Naskh Arabic", sans-serif;
  --cell: 26px;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scrollbar-color: var(--grout-strong) var(--glaze); }
body {
  margin: 0;
  background: var(--glaze);
  color: var(--ink);
  font: 400 14px/1.45 var(--sans);
  font-variant-numeric: lining-nums;
}
::selection { background: var(--em-700); color: #fff; }
a { color: var(--em-700); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { color: var(--em-900); }
:focus-visible { outline: 2px solid var(--em-600); outline-offset: 2px; border-radius: 3px; }
h1, h2 { margin: 0; font-weight: 650; letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: 17px; }
h2 { font-size: 15px; }
p { margin: 0; }
button, select, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 8px; top: 8px; z-index: 50; background: #fff; padding: 6px 10px; }
[lang="ar"], .ar { font-family: var(--naskh); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- top bar */
.bar {
  background: var(--em-900);
  color: var(--on-em);
  display: flex; align-items: center; gap: 28px;
  padding: 0 20px;
  min-height: 52px;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; white-space: nowrap; }
.brand:hover { color: #fff; }
.brand-mark { width: 22px; height: 22px; flex: none; }
.brand-mark rect { fill: var(--on-em); }
.brand-mark .m2 { fill: #5fc79e; }
.brand-mark .m3 { fill: #2f9c76; }
.brand-en { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }
.brand-ar { font-family: var(--kufi); font-weight: 500; font-size: 17px; color: var(--on-em-2); padding-inline-start: 10px; border-inline-start: 1px solid rgba(255,255,255,.22); line-height: 1.2; }
.tabs { display: flex; gap: 2px; align-self: stretch; overflow-x: auto; scrollbar-width: none; }
.tabs a {
  display: flex; align-items: center; padding: 0 12px;
  color: var(--on-em-2); text-decoration: none; font-weight: 550; white-space: nowrap;
  border-bottom: 3px solid transparent; border-top: 3px solid transparent;
  transition: color .15s, background-color .15s;
}
.tabs a:hover { color: #fff; background: rgba(255,255,255,.06); }
.tabs a[aria-current="page"] { color: #fff; border-bottom-color: #5fc79e; }
.tabs a:focus-visible { outline-color: #fff; outline-offset: -3px; }
.bar-meta { margin-inline-start: auto; color: var(--on-em-2); font-size: 12.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- filters */
.filters {
  background: var(--em-50);
  border-bottom: 1px solid var(--grout);
  padding: 10px 20px 10px;
  position: sticky; top: 0; z-index: 20;
}
.filters-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; }
.filters label { display: grid; gap: 2px; font-size: 11.5px; font-weight: 600; color: var(--ink-2); }
.filters select, .filters input {
  height: 30px; padding: 0 8px; font-size: 13px; font-weight: 400; color: var(--ink);
  background: var(--tile); border: 1px solid var(--grout-strong); border-radius: 4px;
  min-width: 0; max-width: 190px;
}
.filters input { width: 170px; caret-color: var(--em-600); }
.filters select:hover, .filters input:hover { border-color: var(--em-600); }
.btn-ghost {
  height: 30px; padding: 0 12px; background: transparent; border: 1px solid var(--grout-strong);
  border-radius: 4px; cursor: pointer; font-weight: 550; color: var(--ink-2);
}
.btn-ghost:hover { background: var(--tile); color: var(--ink); border-color: var(--em-600); }
.btn-ghost:disabled { opacity: .45; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--em-700); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.legend { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 9px 0 4px;
  background: var(--tile); border: 1px solid var(--grout-strong); border-radius: 4px;
  font-size: 12.5px; font-weight: 500; cursor: pointer; color: var(--ink);
  transition: opacity .2s var(--ease), border-color .15s;
}
.chip:hover { border-color: var(--ink-3); }
.chip .sw { width: 18px; height: 18px; border-radius: 3px; display: grid; place-items: center; font-size: 9.5px; font-weight: 700; letter-spacing: 0; }
.chip .ct { color: var(--ink-3); font-variant-numeric: tabular-nums; font-size: 11.5px; }
.chip[aria-pressed="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.legend.has-sel .chip[aria-pressed="false"] { opacity: .5; }

/* ---------- layout */
main { padding: 16px 20px 32px; max-width: 1560px; margin: 0 auto; }
.view { display: grid; gap: 14px; }
.lede { font-size: 15px; color: var(--ink-2); max-width: 95ch; }
.lede strong { color: var(--ink); font-weight: 650; }
.panel { background: var(--tile); border: 1px solid var(--grout); border-radius: 6px; min-width: 0; }
.panel-head { padding: 12px 14px 10px; display: grid; gap: 3px; border-bottom: 1px solid var(--grout); }
.panel-head.sub { border-top: 1px solid var(--grout); margin-top: 6px; }
.hint { color: var(--ink-3); font-size: 12.5px; max-width: 85ch; }
.empty { padding: 28px 14px; color: var(--ink-2); text-align: center; }

/* ---------- mosaic */
.mosaic-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 14px; align-items: start; }
.mosaic-scroll { overflow-x: auto; padding: 4px 14px 14px; scrollbar-width: thin; }
.mosaic { display: grid; gap: 2px; width: max-content; align-items: center; position: relative; }
.mosaic .mh {
  font-size: 10.5px; color: var(--ink-3); text-align: center; line-height: 1.1;
  font-variant-numeric: tabular-nums; padding-bottom: 3px; align-self: end;
}
.mosaic .mh b { display: block; font-weight: 650; color: var(--ink-2); font-size: 10px; text-transform: uppercase; letter-spacing: .03em; height: 12px; white-space: nowrap; }
.mosaic .mh.latest { color: var(--ink); font-weight: 700; }
.mosaic .region {
  grid-column: 1 / -1; font-size: 11px; font-weight: 700; color: var(--em-700);
  text-transform: uppercase; letter-spacing: .06em; padding: 9px 0 2px;
  position: sticky; left: 0; width: max-content;
}
.mosaic .cname {
  position: sticky; left: 0; z-index: 2; background: var(--tile);
  padding-inline-end: 10px; height: var(--cell); display: flex; align-items: center; gap: 6px;
  font-weight: 550; font-size: 13px; white-space: nowrap;
}
.mosaic .cname small { color: var(--ink-3); font-weight: 400; font-size: 11px; }
.cell {
  width: var(--cell); height: var(--cell); border-radius: 3px; background: var(--gap);
  display: flex; gap: 1px; overflow: hidden; padding: 0; border: 0; cursor: default;
  transition: opacity .28s var(--ease), transform .28s var(--ease), box-shadow .2s;
}
.cell.has { cursor: pointer; background: transparent; }
.cell.round { border-radius: 50%; }
.cell i {
  flex: 1; display: grid; place-items: center; font-style: normal;
  font-size: 9.5px; font-weight: 700; line-height: 1; min-width: 0;
}
.cell.has:hover { transform: scale(1.12); box-shadow: 0 2px 6px rgba(7, 57, 44, .28); position: relative; z-index: 1; }
.cell[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--tile), 0 0 0 4px var(--ink); position: relative; z-index: 1; }
/* signature: keep one topic glazed, fade the rest */
.mosaic[data-hl] .cell.has:not([data-hit]) { opacity: .13; }
.mosaic[data-hl] .cell.has[data-hit] { transform: scale(1.06); }
.mosaic .colmark { grid-row: 2 / -1; background: var(--em-50); border-radius: 4px; z-index: 0; margin: 0 -2px; pointer-events: none; }
.mosaic > :not(.colmark) { z-index: 1; }
.mosaic > .cname, .mosaic > .region { z-index: 3; }
.mosaic > .region { background: var(--tile); padding-inline-end: 10px; }

/* ---------- side panel */
.side { position: sticky; top: 118px; max-height: calc(100vh - 134px); overflow-y: auto; scrollbar-width: thin; }
.side-head { padding: 12px 14px 10px; border-bottom: 1px solid var(--grout); display: flex; align-items: start; justify-content: space-between; gap: 10px; }
.side-head p { color: var(--ink-3); font-size: 12.5px; }
.icon-btn { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--grout-strong); background: var(--tile); border-radius: 4px; cursor: pointer; flex: none; }
.icon-btn:hover { border-color: var(--em-600); background: var(--em-50); }
.icon-btn svg { width: 14px; height: 14px; stroke: var(--ink); fill: none; stroke-width: 1.8; stroke-linecap: round; }
.latest { list-style: none; margin: 0; padding: 0; }
.latest li + li { border-top: 1px solid var(--grout); }
.latest button {
  display: grid; grid-template-columns: 20px minmax(0, 1fr); gap: 2px 10px; width: 100%; text-align: start;
  padding: 9px 14px; background: none; border: 0; cursor: pointer;
}
.latest button:hover { background: var(--em-50); }
.latest .sw { width: 20px; height: 20px; border-radius: 3px; display: grid; place-items: center; font-size: 9.5px; font-weight: 700; grid-row: span 3; margin-top: 2px; }
.latest .sw.round { border-radius: 50%; }
.latest .who { font-size: 12px; font-weight: 650; color: var(--ink-2); }
.t-orig { font-size: 16px; line-height: 1.55; color: var(--ink); overflow-wrap: anywhere; }
.t-orig:not([lang="ar"]):not([lang="fa"]):not([lang="ur"]) { font-size: 14px; font-weight: 550; line-height: 1.4; }
.t-en { font-size: 13px; color: var(--ink-2); }
.missing { padding: 10px 14px 12px; border-top: 1px solid var(--grout); color: var(--ink-3); font-size: 12.5px; }

.detail { padding: 12px 14px 14px; display: grid; gap: 12px; }
.detail .entry { display: grid; gap: 6px; padding-bottom: 12px; border-bottom: 1px solid var(--grout); }
.detail .entry:last-child { border-bottom: 0; padding-bottom: 0; }
.detail .t-orig { font-size: 21px; line-height: 1.6; }
.detail .t-orig:not([lang="ar"]):not([lang="fa"]):not([lang="ur"]) { font-size: 17px; }
.detail .t-en { font-size: 14.5px; color: var(--ink); font-weight: 550; }
.detail .sum { color: var(--ink-2); max-width: 65ch; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; }
.tag { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 7px; border: 1px solid var(--grout-strong); border-radius: 3px; font-size: 11.5px; font-weight: 550; color: var(--ink-2); white-space: nowrap; }
.tag .dot { width: 10px; height: 10px; border-radius: 2px; }
.tag.warn { border-color: #c98a2b; color: #7a4d06; background: #fdf6e7; }
.src { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; width: max-content; max-width: 100%; }
.src svg { width: 12px; height: 12px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.also h3 { margin: 0 0 4px; font-size: 12px; font-weight: 700; color: var(--em-700); text-transform: uppercase; letter-spacing: .05em; }
.also ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.also li { font-size: 13px; color: var(--ink-2); }
.also li b { color: var(--ink); font-weight: 650; }

/* ---------- tables */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 8px 14px; text-align: start; vertical-align: top; border-bottom: 1px solid var(--grout); }
th.num, td.num { text-align: right; }
thead th { font-size: 11.5px; font-weight: 700; color: var(--ink-2); background: var(--em-50); white-space: nowrap; position: sticky; top: 0; }
thead th button { background: none; border: 0; padding: 0; font-weight: 700; cursor: pointer; color: inherit; display: inline-flex; gap: 4px; align-items: center; }
thead th button:hover { color: var(--em-700); }
thead th button[data-dir]::after { content: ""; border: 4px solid transparent; }
thead th button[data-dir="asc"]::after { border-bottom-color: currentColor; margin-top: -4px; }
thead th button[data-dir="desc"]::after { border-top-color: currentColor; margin-top: 4px; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--glaze); }
td.nowrap { white-space: nowrap; font-variant-numeric: tabular-nums; }
td .sub { display: block; color: var(--ink-3); font-size: 12px; }
.entries td.title { min-width: 320px; max-width: 640px; }
.entries .t-orig { font-size: 16px; }
.entries .sum { color: var(--ink-3); font-size: 12.5px; margin-top: 2px; max-width: 75ch; }
.topic-cell { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.topic-cell .dot { width: 12px; height: 12px; border-radius: 2px; flex: none; }
.cov { display: flex; gap: 1px; align-items: center; }
.cov i { width: 5px; height: 14px; background: var(--gap); border-radius: 1px; }
.cov i.on { background: var(--em-600); }
.cov span { margin-inline-start: 8px; color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sources td.auth { max-width: 300px; }
.sources td.sys { max-width: 340px; }
.sources td.sys .sub, .sources td.auth .sub { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.sources tr.rg td { background: var(--tile); font-size: 11px; font-weight: 700; color: var(--em-700); text-transform: uppercase; letter-spacing: .06em; padding-top: 14px; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 3px; font-size: 11.5px; font-weight: 650; border: 1px solid var(--grout-strong); color: var(--ink-2); white-space: nowrap; }
.badge.unified_text { background: var(--em-700); border-color: var(--em-700); color: #fff; }
.badge.unified_topic { background: var(--em-100); border-color: var(--em-100); color: var(--em-900); }
.badge.directives { border-color: var(--em-600); color: var(--em-800); }
.badge.central_pulpit { border-style: dashed; border-color: var(--em-600); color: var(--em-800); }

/* ---------- convergence */
.conv-layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.network { padding: 6px; }
.network svg { display: block; width: 100%; height: auto; max-height: 620px; }
.network .edge { fill: none; stroke: var(--em-600); stroke-opacity: .34; transition: stroke-opacity .25s var(--ease); }
.network .node circle { fill: var(--em-800); stroke: var(--tile); stroke-width: 2; transition: opacity .25s; }
.network .node.idle circle { fill: var(--grout-strong); }
.network .node text { font: 550 12px var(--sans); fill: var(--ink); }
.network .node.idle text { fill: var(--ink-3); font-weight: 400; }
.network .node { cursor: pointer; }
.network .rlabel { font: 700 10px var(--sans); fill: var(--em-700); letter-spacing: .06em; text-transform: uppercase; }
.network .rarc { fill: none; stroke: var(--grout-strong); stroke-width: 1.5; }
.network svg[data-focus] .edge:not([data-on]) { stroke-opacity: .05; }
.network svg[data-focus] .edge[data-on] { stroke-opacity: .85; stroke: var(--em-800); }
.network svg[data-focus] .node:not([data-on]) { opacity: .35; }
.events { list-style: none; margin: 0; padding: 0; max-height: 640px; overflow-y: auto; scrollbar-width: thin; }
.events li + li { border-top: 1px solid var(--grout); }
.events details { padding: 0; }
.events summary { list-style: none; cursor: pointer; padding: 9px 14px; display: grid; grid-template-columns: 62px minmax(0, 1fr) auto; gap: 2px 10px; align-items: baseline; }
.events summary::-webkit-details-marker { display: none; }
.events summary:hover { background: var(--em-50); }
.events .when { font-variant-numeric: tabular-nums; color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.events .what { font-weight: 650; display: flex; gap: 7px; align-items: center; }
.events .what .dot { width: 11px; height: 11px; border-radius: 2px; flex: none; }
.events .n { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.events .who { grid-column: 2 / -1; color: var(--ink-2); font-size: 13px; }
.events .body { padding: 2px 14px 12px 86px; display: grid; gap: 8px; }
.events .body .t-orig { font-size: 15px; }
.events .body b { font-size: 12px; color: var(--ink-2); }

/* ---------- trends */
.trend-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.chart { padding: 12px 14px 8px; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .ax { font: 400 11px var(--sans); fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--grout); stroke-width: 1; }
.chart .base { stroke: var(--grout-strong); stroke-width: 1; }
.chart rect.seg { transition: opacity .2s; }
.chart svg[data-hl] rect.seg:not([data-hit]) { opacity: .18; }
.mix { padding: 10px 14px 14px; display: grid; gap: 4px; }
.mix .rg { font-size: 11px; font-weight: 700; color: var(--em-700); text-transform: uppercase; letter-spacing: .06em; padding-top: 8px; }
.mix .row { display: grid; grid-template-columns: 118px minmax(0, 1fr) 30px; gap: 10px; align-items: center; font-size: 13px; }
.mix .row .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.mix .mixbar { display: flex; gap: 2px; height: 18px; }
.mix .mixbar i { border-radius: 2px; min-width: 2px; transition: opacity .2s; }
.mix[data-hl] .mixbar i:not([data-hit]) { opacity: .18; }
.mix .row .ct { color: var(--ink-3); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.rank { padding: 10px 14px 14px; display: grid; gap: 5px; }
.rank .row { display: grid; grid-template-columns: minmax(0, 150px) minmax(0, 1fr) auto; gap: 10px; align-items: center; font-size: 13px; }
.rank.wide .row { grid-template-columns: minmax(0, 210px) minmax(0, 1fr) auto; }
.rank .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.rank .track { height: 14px; display: flex; }
.rank .track i { border-radius: 0 3px 3px 0; background: var(--em-600); min-width: 2px; }
.rank .val { color: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; min-width: 74px; text-align: right; }

/* ---------- prose */
.prose { padding: 22px 26px 26px; max-width: 820px; display: grid; gap: 10px; }
.prose h1 { font-size: 24px; letter-spacing: -0.02em; }
.prose h2 { font-size: 16px; margin-top: 16px; }
.prose p, .prose li { font-size: 15px; line-height: 1.6; max-width: 70ch; color: var(--ink-2); }
.prose ul { margin: 0; padding-inline-start: 20px; display: grid; gap: 6px; }
.prose code { font: 13px ui-monospace, Consolas, monospace; background: var(--em-50); padding: 1px 5px; border-radius: 3px; }
.ar-inline { font-size: 1.15em; }
.deflist { margin: 0; display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; font-size: 14px; }
.deflist dt { font-weight: 650; display: flex; align-items: center; gap: 7px; }
.deflist dt .dot { width: 12px; height: 12px; border-radius: 2px; }
.deflist dd { margin: 0; color: var(--ink-2); }

.foot { border-top: 1px solid var(--grout); padding: 16px 20px 28px; color: var(--ink-3); font-size: 12.5px; }
.foot p { max-width: 1520px; margin: 0 auto; }

/* ---------- tooltip */
.tip {
  position: fixed; z-index: 60; pointer-events: none; max-width: 340px;
  background: var(--em-950); color: var(--on-em); border-radius: 5px; padding: 8px 10px;
  font-size: 12.5px; line-height: 1.4; box-shadow: 0 6px 18px rgba(5, 42, 33, .28);
}
.tip b { display: block; font-weight: 650; color: #fff; }
.tip .ar { display: block; font-size: 15px; line-height: 1.6; color: #fff; }
.tip span { color: var(--on-em-2); }

/* ---------- responsive */
@media (max-width: 1180px) {
  .mosaic-layout, .conv-layout, .trend-layout { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; max-height: none; }
  .bar-meta { display: none; }
}
@media (max-width: 720px) {
  :root { --cell: 24px; }
  .bar { flex-wrap: wrap; gap: 0 16px; padding: 8px 14px 0; }
  .tabs { width: 100%; margin: 0 -14px; padding: 0 6px; min-height: 40px; }
  .filters { position: static; padding: 10px 14px; }
  .filters-row { display: grid; grid-template-columns: 1fr 1fr; }
  .filters select, .filters input { max-width: none; width: 100%; }
  .filters .search { grid-column: 1 / -1; }
  main { padding: 12px 12px 24px; }
  .lede { font-size: 14px; }
  .mosaic .cname { font-size: 12px; }
  .events summary { grid-template-columns: 52px minmax(0, 1fr); }
  .events .n { display: none; }
  .events .body { padding-inline-start: 14px; }
  .mix .row { grid-template-columns: 84px minmax(0, 1fr) 24px; }
  .rank .row, .rank.wide .row { grid-template-columns: minmax(0, 110px) minmax(0, 1fr) auto; }
  .prose { padding: 16px; }
  th, td { padding: 7px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0s !important; }
}

@media (max-width: 720px) { .mosaic .cname small { display: none; } }
