/* ==========================================================================
   Aʿlām — calm, editorial scholar atlas (visual language shared with Mutūn)
   ========================================================================== */

:root {
  --bg: #f6f3ec;
  --bg-2: #efebe1;
  --surface: #fffdf8;
  --ink: #1e1b16;
  --ink-2: #575045;
  --ink-3: #8c8476;
  --line: #e5dfd2;
  --line-2: #d6cfbf;
  --accent: #2f5d50;
  --accent-ink: #f6f3ec;
  --accent-soft: #e3ebe5;
  --gold: #a9853b;
  --gold-soft: #f3ead6;
  --warn: #9a5b2b;
  --warn-soft: #f6e6d8;
  --land: #fbf8f1;
  --water: #dfe6e2;
  --river: #c3d2cd;
  --shadow: 0 1px 2px rgba(30, 27, 22, .04), 0 6px 24px -12px rgba(30, 27, 22, .12);
  --shadow-lg: 0 2px 6px rgba(30, 27, 22, .05), 0 24px 48px -24px rgba(30, 27, 22, .25);

  --f-ar: "Amiri", "Noto Naskh Arabic", "Traditional Arabic", serif;
  --f-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --f-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  --radius: 14px;
  --radius-sm: 10px;
  --wrap: 1120px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #13120f; --bg-2: #1a1915; --surface: #1c1b17; --ink: #ede7db; --ink-2: #b7afa0; --ink-3: #7f786c;
    --line: #2b2924; --line-2: #3a3731; --accent: #86bba8; --accent-ink: #12110e; --accent-soft: #1f2c27;
    --gold: #c9a55c; --gold-soft: #2a2418; --warn: #d79a68; --warn-soft: #2c2018; --land: #22211c; --water: #121614; --river: #24302c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 24px 48px -24px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #13120f; --bg-2: #1a1915; --surface: #1c1b17; --ink: #ede7db; --ink-2: #b7afa0; --ink-3: #7f786c;
  --line: #2b2924; --line-2: #3a3731; --accent: #86bba8; --accent-ink: #12110e; --accent-soft: #1f2c27;
  --gold: #c9a55c; --gold-soft: #2a2418; --warn: #d79a68; --warn-soft: #2c2018; --land: #22211c; --water: #121614; --river: #24302c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 24px 48px -24px rgba(0, 0, 0, .7);
  color-scheme: dark;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.6 var(--f-ui); -webkit-font-smoothing: antialiased; min-height: 100vh; }
::selection { background: var(--accent-soft); }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
svg { display: block; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
#app:focus { outline: none; }
.muted { color: var(--ink-3); }
.ar { font-family: var(--f-ar); direction: rtl; }
.skip { position: absolute; inset-inline-start: 8px; top: 8px; transform: translateY(-300%); background: var(--ink); color: var(--bg); padding: 8px 12px; border-radius: 8px; z-index: 3000; }
.skip:focus { transform: none; }
.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; }
@media (max-width: 600px) { .wrap { padding: 0 16px; } .hide-sm { display: none !important; } }
.link { text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.link:hover { text-decoration-color: var(--ink-3); }

/* ---------- Topbar ---------- */
.topbar { position: sticky; top: 0; z-index: 1000; background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px); border-bottom: 1px solid var(--line); }
.topbar__inner { max-width: var(--wrap); margin: 0 auto; padding: 0 24px; height: 60px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
@media (max-width: 600px) { .topbar__inner { padding: 0 8px 0 16px; } }
.brand { display: flex; align-items: baseline; gap: 10px; flex: none; }
.brand__mark { font-family: var(--f-ar); font-size: 26px; line-height: 1; color: var(--accent); }
.brand__name { font-family: var(--f-display); font-size: 19px; letter-spacing: -.01em; }
@media (max-width: 600px) { .brand__name { display: none; } }
.topnav { display: flex; align-items: center; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.topnav a { padding: 7px 11px; border-radius: 999px; color: var(--ink-2); font-size: 14px; font-weight: 500; white-space: nowrap; }
.topnav a:hover { color: var(--ink); }
.topnav a.is-active { color: var(--ink); background: var(--bg-2); }
@media (max-width: 600px) { .topnav a { padding: 7px 8px; font-size: 13.5px; } }
.icon-btn { width: 40px; height: 40px; border-radius: 999px; display: inline-grid; place-items: center; color: var(--ink-2); flex: none; }
.icon-btn:hover { background: var(--bg-2); color: var(--ink); }
.icon-btn svg { width: 19px; height: 19px; }

/* ---------- Buttons, pills ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 46px; padding: 0 22px; border-radius: 999px; font-weight: 500; border: 1px solid var(--line-2); background: var(--surface); transition: border-color .15s, transform .12s; }
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: scale(.98); }
.btn--primary { background: var(--ink); color: var(--bg); border-color: var(--ink); box-shadow: var(--shadow); }
.btn svg { width: 16px; height: 16px; }
.btn--sm { height: 34px; padding: 0 14px; font-size: 13.5px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; letter-spacing: .04em; background: var(--bg-2); color: var(--ink-2); white-space: nowrap; }
.pill--exact { background: var(--accent-soft); color: var(--accent); }
.pill--approximate { background: transparent; border: 1px dashed var(--ink-3); color: var(--ink-2); }
.pill--disputed { background: var(--warn-soft); color: var(--warn); }
.pill--reported { background: var(--gold-soft); color: var(--gold); }
.pill--high { background: var(--accent-soft); color: var(--accent); }
.pill--medium { background: var(--gold-soft); color: var(--gold); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { height: 32px; padding: 0 13px; border-radius: 999px; font-size: 13px; color: var(--ink-2); border: 1px solid var(--line-2); background: var(--surface); white-space: nowrap; }
.chip:hover { color: var(--ink); border-color: var(--ink-3); }
.chip.is-on { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* ---------- Notice ---------- */
.notice { display: flex; gap: 12px; align-items: flex-start; background: var(--gold-soft); color: var(--ink-2); border-radius: var(--radius); padding: 14px 16px; font-size: 13.5px; line-height: 1.55; }
.notice svg { width: 18px; height: 18px; flex: none; margin-top: 2px; color: var(--gold); }
.notice b { color: var(--ink); font-weight: 600; }

/* ---------- Home ---------- */
.hero { padding: 64px 0 28px; text-align: center; }
.hero__ornament { width: 52px; height: 52px; margin: 0 auto 18px; color: var(--gold); opacity: .85; }
.hero__ar { font-family: var(--f-ar); font-size: clamp(48px, 9vw, 84px); line-height: 1.25; margin: 0; font-weight: 400; }
.hero__en { font-family: var(--f-display); font-weight: 300; font-style: italic; font-size: clamp(19px, 2.6vw, 24px); color: var(--ink-2); margin: 4px 0 0; }
.hero__lede { max-width: 600px; margin: 18px auto 0; color: var(--ink-2); font-size: 15.5px; }
.stats { display: flex; justify-content: center; gap: 30px; margin-top: 26px; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; align-items: center; }
.stat__n { font-family: var(--f-display); font-size: 26px; line-height: 1.1; }
.stat__l { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); margin-top: 4px; }
.modes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 36px 0 0; }
@media (max-width: 760px) { .modes { grid-template-columns: 1fr; } }
.mode { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; transition: border-color .2s, box-shadow .2s, transform .2s; }
.mode:hover { border-color: var(--line-2); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.mode svg { width: 28px; height: 28px; color: var(--accent); margin-bottom: 6px; }
.mode h3 { font-family: var(--f-display); font-weight: 400; font-size: 21px; margin: 0; }
.mode p { margin: 0; color: var(--ink-2); font-size: 14px; }
.section-head { display: flex; align-items: baseline; gap: 14px; margin: 48px 0 16px; }
.section-head h2 { font-family: var(--f-display); font-size: 24px; font-weight: 400; margin: 0; letter-spacing: -.01em; white-space: nowrap; }
.section-head .rule { flex: 1; height: 1px; background: var(--line); align-self: center; }
.section-head .meta { font-size: 12.5px; color: var(--ink-3); white-space: nowrap; }
.principles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
@media (max-width: 760px) { .principles { grid-template-columns: 1fr; } }
.principle { padding: 16px 18px; border-left: 2px solid var(--accent); background: var(--surface); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; font-size: 14px; color: var(--ink-2); }
.principle b { display: block; color: var(--ink); font-weight: 600; margin-bottom: 2px; }

/* ---------- Scholar cards / list ---------- */
.toolbar { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin: 28px 0 8px; }
.search { position: relative; flex: 0 1 320px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-3); pointer-events: none; }
.search input { width: 100%; height: 40px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); padding: 0 14px 0 38px; font-size: 14px; outline: none; }
.search input:focus { border-color: var(--accent); }
@media (max-width: 700px) { .search { flex: 1 1 100%; } }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.card { position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; transition: border-color .2s, box-shadow .2s, transform .2s; }
.card:hover { border-color: var(--line-2); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.card__top { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ink-3); letter-spacing: .06em; text-transform: uppercase; }
.card__ar { font-family: var(--f-ar); font-size: 24px; line-height: 1.6; text-align: right; direction: rtl; margin: 10px 0 0; }
.card__en { font-family: var(--f-display); font-style: italic; font-size: 16px; }
.card__meta { font-size: 12.5px; color: var(--ink-3); margin-top: 6px; }
.century-head { font-family: var(--f-display); font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin: 32px 0 12px; }

/* ---------- Scholar page ---------- */
.back { display: inline-flex; align-items: center; gap: 8px; margin-top: 24px; color: var(--ink-3); font-size: 12.5px; font-weight: 500; letter-spacing: .05em; text-transform: uppercase; }
.back:hover { color: var(--ink); }
.back svg { width: 15px; height: 15px; }
.p-hero { text-align: center; padding: 26px 0 8px; }
.p-hero__ar { font-family: var(--f-ar); font-weight: 400; font-size: clamp(40px, 8vw, 70px); line-height: 1.35; margin: 8px 0 0; }
.p-hero__en { font-family: var(--f-display); font-style: italic; font-weight: 300; font-size: clamp(20px, 3vw, 28px); margin: 0; }
.p-hero__names { color: var(--ink-2); font-size: 14px; margin-top: 8px; }
.p-hero__names .ar { font-size: 18px; }
.p-hero__epithet { max-width: 640px; margin: 18px auto 0; font-family: var(--f-ar); font-size: 21px; line-height: 1.8; color: var(--ink-2); direction: rtl; }
.p-hero__epithet small { display: block; direction: ltr; font-family: var(--f-ui); font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.p-grid { display: grid; grid-template-columns: 1fr 340px; gap: 24px; margin-top: 28px; align-items: start; }
@media (max-width: 900px) { .p-grid { grid-template-columns: 1fr; } }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.block { padding: 20px 22px; }
.block + .block { border-top: 1px solid var(--line); }
.block h3 { margin: 0 0 12px; font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; display: flex; align-items: center; gap: 8px; }
.side { display: grid; gap: 16px; position: sticky; top: 76px; }
@media (max-width: 900px) { .side { position: static; } }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px; font-size: 13.5px; margin: 0; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; text-align: right; }
.date-big { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.date-big b { font-family: var(--f-display); font-size: 28px; font-weight: 400; line-height: 1.1; }
.date-big span { color: var(--ink-3); font-size: 13px; }
.reports { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 6px; }
.report { display: grid; grid-template-columns: 64px 1fr auto; gap: 10px; align-items: baseline; font-size: 13.5px; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--bg); }
.report__y { font-family: var(--f-display); font-size: 17px; font-variant-numeric: lining-nums; }
.report__by { color: var(--ink-2); }
.report__note { display: block; color: var(--ink-3); font-size: 12.5px; }
.claims { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.claim { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 14px; }
.claim:last-child { border-bottom: 0; }
.claim__main { min-width: 0; }
.claim__main small { display: block; color: var(--ink-3); font-size: 12.5px; }
.ev-tag { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); margin-right: 6px; }
.person-link { color: var(--ink); font-weight: 500; }
.person-link:hover { color: var(--accent); }
.mini-map { height: 260px; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); margin-top: 4px; }

/* citation chip + popover */
.cite { flex: none; display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 9px; border-radius: 999px; border: 1px solid var(--line-2); font-size: 11.5px; font-weight: 600; color: var(--ink-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cite:hover, .cite[aria-expanded="true"] { border-color: var(--accent); color: var(--accent); }
.cite svg { width: 12px; height: 12px; }
.cite-pop { position: fixed; z-index: 2000; width: min(420px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 16px 18px; font-size: 13.5px; }
.cite-pop h4 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 17px; }
.cite-pop .loc { color: var(--ink-2); margin: 2px 0 10px; }
.cite-pop blockquote { margin: 0 0 10px; padding: 10px 12px; background: var(--bg); border-radius: var(--radius-sm); font-family: var(--f-ar); font-size: 19px; line-height: 1.8; direction: rtl; text-align: right; }
.cite-pop .status { font-size: 12px; color: var(--ink-3); }
.cite-pop .links { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 8px; font-size: 12.5px; }
.cite-pop .x { position: absolute; top: 8px; right: 8px; }

/* ---------- Atlas ---------- */
.atlas { position: relative; height: calc(100vh - 60px); height: calc(100dvh - 60px); }
.atlas #map { position: absolute; inset: 0; background: var(--bg-2); }
.era { position: absolute; z-index: 500; left: 16px; right: 16px; top: 14px; max-width: 560px; margin: 0 auto; background: color-mix(in srgb, var(--surface) 94%, transparent); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 10px 16px 8px; }
.era__row { display: flex; align-items: baseline; gap: 10px; }
.era__lbl { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.era__v { font-family: var(--f-display); font-size: 21px; }
.era__ce { font-size: 12.5px; color: var(--ink-3); }
.era__n { margin-left: auto; font-size: 12.5px; font-weight: 600; color: var(--accent); }
.era input[type=range] { width: 100%; accent-color: var(--accent); margin: 4px 0 0; }
.era__ticks { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--ink-3); }
.era__all { font-size: 12px; color: var(--ink-2); display: inline-flex; gap: 6px; align-items: center; margin-left: 6px; }
.sheet { position: absolute; z-index: 500; left: 16px; bottom: 16px; width: 380px; max-height: calc(100% - 140px); overflow-y: auto; background: color-mix(in srgb, var(--surface) 97%, transparent); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 18px 20px; }
@media (max-width: 640px) { .sheet { left: 8px; right: 8px; bottom: 8px; width: auto; max-height: 46%; } .era { left: 8px; right: 8px; top: 8px; } }
.sheet h2 { font-family: var(--f-display); font-weight: 400; font-size: 23px; margin: 0; line-height: 1.2; }
.sheet .ar { font-size: 22px; color: var(--gold); }
.sheet__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.sheet p { margin: 6px 0; color: var(--ink-2); font-size: 13.5px; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--ink-2); margin: 10px 0 4px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 99px; margin-right: 6px; vertical-align: -1px; }
.row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 12px; text-align: left; }
.row:hover { background: var(--bg-2); }
.row__t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.row__t b { font-weight: 600; font-size: 14px; }
.row__t span { font-size: 12.5px; color: var(--ink-3); }
.dot { width: 9px; height: 9px; border-radius: 99px; background: var(--accent); flex: none; }
.dot--off { background: transparent; border: 1.5px solid var(--ink-3); }
.stops { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; counter-reset: s; }
.stop { display: grid; grid-template-columns: 26px 1fr auto; gap: 10px; align-items: start; padding: 7px 0; border-bottom: 1px dashed var(--line); font-size: 13.5px; }
.stop:last-child { border-bottom: 0; }
.stop__n { width: 24px; height: 24px; border-radius: 99px; background: var(--ink); color: var(--bg); display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.stop__n--u { background: transparent; border: 1.5px solid var(--ink-3); color: var(--ink-3); }
.fine { font-size: 12px; color: var(--ink-3); line-height: 1.5; }
/* leaflet theming */
.leaflet-container { font: inherit; background: var(--bg-2); }
.leaflet-control-attribution { font-size: 10px; background: color-mix(in srgb, var(--surface) 80%, transparent) !important; color: var(--ink-3); }
.leaflet-control-attribution a { color: var(--ink-2); }
.leaflet-bar a { background: var(--surface); color: var(--ink); border-color: var(--line) !important; }
.city-pin { display: grid; place-items: center; }
.city-pin span { display: grid; place-items: center; border-radius: 99px; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700; border: 2px solid var(--surface); box-shadow: 0 2px 6px rgba(0,0,0,.25); }
.city-pin.is-dim span { background: var(--surface); color: var(--ink-3); border-color: var(--line-2); box-shadow: none; }
.city-pin.is-approx span { border-style: dashed; }
.city-label { background: color-mix(in srgb, var(--surface) 92%, transparent); border: 0; border-radius: 99px; box-shadow: var(--shadow); color: var(--ink); font-size: 11.5px; font-weight: 600; padding: 1px 8px; }
.city-label::before { display: none; }
.stop-pin span { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 99px; background: var(--ink); color: var(--bg); font-size: 11px; font-weight: 700; border: 2px solid var(--gold); }
.stop-pin.is-u span { background: var(--surface); color: var(--ink); border: 2px dashed var(--ink-3); }

/* ---------- Timeline ---------- */
.tl { margin-top: 20px; overflow-x: auto; }
.tl svg { min-width: 760px; width: 100%; height: auto; }
.tl text { fill: var(--ink-2); font-size: 12px; font-family: var(--f-ui); }
.tl .axis line { stroke: var(--line); }
.tl .axis text { fill: var(--ink-3); font-size: 11px; }
.tl .bar { fill: var(--accent); opacity: .85; }
.tl .bar--approx { fill: none; stroke: var(--accent); stroke-dasharray: 3 3; }
.tl .bar--disp { fill: var(--warn); opacity: .55; }
.tl a:hover text { fill: var(--accent); }
.tl a:hover .bar { opacity: 1; }

/* ---------- Network ---------- */
.net { margin-top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.net svg { display: block; width: 100%; height: auto; }
.net .edge { fill: none; stroke: var(--ink-3); stroke-opacity: .28; stroke-width: 1.2; }
.net .edge--medium { stroke-dasharray: 4 4; }
.net .edge.is-on { stroke: var(--accent); stroke-opacity: .95; stroke-width: 2; }
.net .edge.is-in { stroke: var(--gold); stroke-opacity: .95; stroke-width: 2; }
.net .edge.is-off { stroke-opacity: .07; }
.net .node circle { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.net .node text { fill: var(--ink); font-size: 12px; font-family: var(--f-ui); paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
.net .node.is-off { opacity: .3; }
.net .node.is-sel circle { fill: var(--accent); }
.net .axis text { fill: var(--ink-3); font-size: 11px; }
.net .axis line { stroke: var(--line); }

/* ---------- Tables / sources ---------- */
.src { padding: 18px 20px; }
.src + .src { border-top: 1px solid var(--line); }
.src h4 { margin: 0; font-family: var(--f-display); font-weight: 400; font-size: 18px; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.src h4 .ar { font-size: 20px; color: var(--ink-2); }
.src p { margin: 4px 0; font-size: 13.5px; color: var(--ink-2); }
.src .review { background: var(--warn-soft); color: var(--ink-2); padding: 8px 10px; border-radius: var(--radius-sm); font-size: 13px; margin-top: 8px; }
.prose { max-width: 720px; color: var(--ink-2); }
.prose h2 { font-family: var(--f-display); font-weight: 400; color: var(--ink); font-size: 24px; margin: 36px 0 8px; }
.prose li { margin: 4px 0; }

.foot { margin: 72px 0 36px; padding-top: 24px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 12.5px; display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.foot a { text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }

/* ---------- small screens ---------- */
.topnav { min-width: 0; }
.net { overflow-x: auto; }
@media (max-width: 600px) {
  .section-head { flex-wrap: wrap; row-gap: 2px; }
  .section-head h2 { white-space: normal; font-size: 21px; }
  .section-head .rule { display: none; }
  .section-head .meta { flex-basis: 100%; }
  .stats { gap: 18px; }
  .p-hero__epithet { font-size: 18px; }
  .report { grid-template-columns: 44px 1fr auto; }
}

/* named lists & catalogue */
.named { background: var(--bg); border-radius: var(--radius-sm); padding: 12px 14px; margin-top: 8px; }
.named__ar { font-family: var(--f-ar); direction: rtl; text-align: right; font-size: 18px; line-height: 1.95; margin: 0; }
.named__ar .person-link { color: var(--accent); text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 35%, transparent); text-underline-offset: 4px; }
.named__foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 6px; }
details.cat { margin-top: 12px; }
details.cat summary { cursor: pointer; font-size: 13px; color: var(--ink-2); }
code { font-size: 12.5px; background: var(--bg-2); padding: 1px 6px; border-radius: 6px; }

/* language switcher (as in Mutūn) */
.langsw { display: inline-flex; gap: 2px; margin: 0 4px; padding: 2px; border-radius: 999px; background: var(--bg-2); flex: none; }
.langsw button { height: 28px; min-width: 32px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; color: var(--ink-3); }
.langsw button.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.langsw button[lang="ar"] { font-family: var(--f-ar); font-size: 15px; }
@media (max-width: 600px) { .langsw button { min-width: 26px; padding: 0 5px; } }

/* right-to-left */
[dir="rtl"] body { font-family: var(--f-ui), var(--f-ar); }
[dir="rtl"] .kv dd { text-align: left; }
[dir="rtl"] .back svg { transform: scaleX(-1); }
[dir="rtl"] .principle { border-left: 0; border-right: 2px solid var(--accent); border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
[dir="rtl"] .search svg { left: auto; right: 14px; }
[dir="rtl"] .search input { padding: 0 38px 0 14px; }
[dir="rtl"] .cite-pop .x { right: auto; left: 8px; }
[dir="rtl"] .row, [dir="rtl"] .card__top, [dir="rtl"] .claim { text-align: right; }
[dir="rtl"] .card__en, [dir="rtl"] .p-hero__en { font-family: var(--f-ar); font-style: normal; }
[dir="rtl"] .tl svg, [dir="rtl"] .net svg, [dir="rtl"] .leaflet-container { direction: ltr; }
[dir="rtl"] .sheet { left: auto; right: 16px; }
@media (max-width: 640px) { [dir="rtl"] .sheet { right: 8px; left: 8px; } }
/* in Arabic the Latin name is already shown in Arabic: hide the duplicate */
html[lang="ar"] .claim__main > .ar.muted, html[lang="ar"] .stop .ar.muted, html[lang="ar"] .sheet__head .ar,
html[lang="ar"] .p-hero__ar + .p-hero__en, html[lang="ar"] .card__ar + .card__en { display: none; }

/* display settings */
.prefs-btn { position: relative; }
.prefs-dot { position: absolute; top: 8px; right: 8px; width: 7px; height: 7px; border-radius: 99px; background: var(--gold); }
.prefs { position: fixed; z-index: 2100; width: min(340px, calc(100vw - 16px)); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 14px 16px; display: grid; gap: 10px; }
.prefs__row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.prefs__lbl { font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
.prefs__note { margin: -2px 0 2px; }
.seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 999px; background: var(--bg-2); }
.seg button { height: 30px; padding: 0 12px; border-radius: 999px; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.seg button.is-on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
html[data-cal="ce"] .era__ce { display: none; }
.card__top .chips { gap: 4px; flex-wrap: nowrap; }
.claim > span { flex-wrap: wrap; justify-content: flex-end; }
.claim__main { overflow-wrap: anywhere; }
.card__top .chips { flex-wrap: wrap; justify-content: flex-end; }
.card__top { align-items: flex-start; }
.report { grid-template-columns: minmax(64px, max-content) 1fr auto; }
.report__y { white-space: nowrap; }

/* network: vertical generations with name pills */
.net { overflow: visible; background: transparent; border: 0; }
.net svg { width: 100%; height: auto; min-width: 0; }
.net .band rect { fill: var(--surface); stroke: var(--line); }
.net .band text { fill: var(--ink-3); font-size: 11px; font-family: var(--f-ui); letter-spacing: .02em; }
.net .edges .edge { fill: none; stroke: var(--ink-3); stroke-opacity: .22; stroke-width: 1.1; transition: stroke-opacity .2s; }
.net .node { cursor: pointer; }
.net .node rect { fill: var(--bg); stroke: var(--line-2); stroke-width: 1; transition: fill .15s, stroke .15s; }
.net .node text { fill: var(--ink); font-size: 12.5px; font-family: var(--f-ui); paint-order: normal; stroke: none; pointer-events: none; }
.net .node text.ar-t { font-family: var(--f-ar); font-size: 15px; }
.net .node:hover rect, .net .node:focus-visible rect { stroke: var(--accent); }
.net .node:focus { outline: none; }
.net .node.is-sel rect { fill: var(--accent); stroke: var(--accent); }
.net .node.is-sel text { fill: var(--accent-ink); font-weight: 600; }
.net .node.is-t rect { stroke: var(--gold); stroke-width: 2; fill: var(--gold-soft); }
.net .node.is-s rect { stroke: var(--accent); stroke-width: 2; fill: var(--accent-soft); }
.net .node.is-off { opacity: .28; }
.net-card { margin-top: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
.net-card__head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.net-card__head .person-link { font-family: var(--f-display); font-size: 20px; }
.net-card__cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.net-card__cols h3 { margin: 0 0 8px; font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; }
@media (max-width: 640px) { .net-card__cols { grid-template-columns: 1fr; } }
.net-layout { display: grid; gap: 16px; align-items: start; }
@media (min-width: 1000px) {
  .net-layout { grid-template-columns: minmax(0, 1fr) 300px; }
  .net-card { margin-top: 0; position: sticky; top: 76px; max-height: calc(100vh - 96px); overflow-y: auto; }
  .net-card__cols { grid-template-columns: 1fr; }
}
.net .edges .edge.is-on { stroke: var(--accent); stroke-opacity: .9; stroke-width: 2; }
.net .edges .edge.is-in { stroke: var(--gold); stroke-opacity: .9; stroke-width: 2; }
.net .edges .edge.is-off { stroke-opacity: .05; }
.net .edges .edge--medium { stroke-dasharray: 4 4; }
