/* المشجرة البدرانية الجينية — public styles. Scoped to .bdg-app so the theme is not affected. */
.bdg-app {
	--paper: #f8f9f6; --surface: #ffffff; --ink: #1c2a25; --ink-2: #4a5a53; --line: #dfe5e0; --palm: #1f5e4a; --palm-2: #e3eee8;
	--gold: #b8913f; --gold-2: #f3ead4;
	--agreed: #2e7d5b; --ruled: #3c6e9e; --probable: #a8720f; --open: #a5473a;
	--naskh: "Noto Naskh Arabic", "Geeza Pro", "Traditional Arabic", "Amiri", serif;
	--sans: "Segoe UI", "Noto Sans Arabic", "SF Arabic", Tahoma, system-ui, sans-serif;
	--latin: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
	box-sizing: border-box; max-width: 1180px !important; width: 100%; margin: 24px auto !important; padding: clamp(16px, 3.2vw, 40px);
	background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-radius: 6px;
	font-family: var(--sans); font-size: 16px; line-height: 1.85; text-align: right;
}
.bdg-app[data-theme="dark"] { color-scheme: dark; --paper: #141b18; --surface: #1b2420; --ink: #e5ece8; --ink-2: #a9b8b1; --line: #2d3a35; --palm: #7cc2a4; --palm-2: #20332b; --gold: #d6b36a; --gold-2: #33301f; --agreed: #6fc29b; --ruled: #84b1dd; --probable: #e0aa4c; --open: #e08a7c; }
@media (prefers-color-scheme: dark) {
	.bdg-app[data-theme="auto"] {--paper: #141b18; --surface: #1b2420; --ink: #e5ece8; --ink-2: #a9b8b1; --line: #2d3a35; --palm: #7cc2a4; --palm-2: #20332b; --gold: #d6b36a; --gold-2: #33301f; --agreed: #6fc29b; --ruled: #84b1dd; --probable: #e0aa4c; --open: #e08a7c; }
}
.bdg-app *, .bdg-app *::before, .bdg-app *::after { box-sizing: border-box; }
.bdg-app :where(h2, h3, h4, p, ul, ol, dl, dd, table) { margin: 0; padding: 0; }
.bdg-app :where(ul, ol) { list-style: none; }
.bdg-app a { color: var(--palm); text-underline-offset: 3px; }
.bdg-app button { font: inherit; color: inherit; }
.bdg-app :focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 3px; }

/* hero */
.bdg-hero { padding-bottom: 18px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.bdg-kicker { color: var(--gold); font-size: 14px; margin-bottom: 2px !important; }
.bdg-title { font-family: var(--naskh); font-weight: 700; font-size: clamp(30px, 4.6vw, 50px); line-height: 1.35; color: var(--palm); letter-spacing: 0; }
.bdg-intro { max-width: 62ch; color: var(--ink-2); font-size: 17px; margin-top: 6px !important; }
.bdg-facts { display: flex; flex-wrap: wrap; gap: 4px 22px; color: var(--ink-2); margin-bottom: 14px !important; }
.bdg-facts b { color: var(--ink); font-size: 20px; font-weight: 700; margin-inline-end: 4px; font-variant-numeric: tabular-nums; }
.bdg-loading { color: var(--ink-2); }

/* navigation + search */
.bdg-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; justify-content: space-between; border-bottom: 1px solid var(--line); margin-bottom: 22px; position: sticky; top: 0; z-index: 5; background: var(--paper); padding-top: 6px; }
.bdg-nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin-bottom: -1px; }
.bdg-nav a { white-space: nowrap; padding: 10px 12px 9px; text-decoration: none; color: var(--ink-2); border-bottom: 3px solid transparent; font-weight: 600; }
.bdg-nav a:hover { color: var(--ink); }
.bdg-nav a[aria-current] { color: var(--palm); border-bottom-color: var(--gold); }
.bdg-searchbox { position: relative; flex: 0 1 360px; min-width: 220px; margin-bottom: 8px; }
.bdg-search, .bdg-filter, .bdg-select { width: 100%; font: inherit; font-size: 15px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 8px 12px; min-height: 42px; }
.bdg-search:focus, .bdg-filter:focus, .bdg-select:focus { border-color: var(--palm); outline: none; box-shadow: 0 0 0 3px var(--palm-2); }
.bdg-results { position: absolute; inset-inline: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 10px 30px rgba(20, 40, 32, .14); max-height: 420px; overflow: auto; z-index: 10; }
.bdg-results button { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: right; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 8px 12px; cursor: pointer; }
.bdg-results button:hover, .bdg-results button:focus { background: var(--palm-2); outline: none; }
.bdg-r-label { font-weight: 600; font-family: var(--latin), var(--sans); }
.bdg-results small, .bdg-r-none { color: var(--ink-2); font-size: 13px; }
.bdg-r-none { padding: 10px 12px; }

/* shared */
.bdg-h { font-family: var(--naskh); font-size: 24px; font-weight: 700; color: var(--ink); margin-bottom: 12px !important; }
.bdg-h:focus { outline: none; }
.bdg-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.bdg-app :where(h2, h3, h4) { font-family: var(--sans); letter-spacing: 0; text-transform: none; }
.bdg-app h4 { font-size: 16px; font-weight: 700; margin: 22px 0 8px !important; color: var(--ink); }
.bdg-muted { color: var(--ink-2); font-size: 14px; }
.bdg-code { font-family: var(--latin); font-variant-numeric: tabular-nums; font-weight: 600; letter-spacing: .01em; unicode-bidi: isolate; }
.bdg-link { background: none; border: 0; padding: 0; color: var(--palm); cursor: pointer; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--palm) 35%, transparent); text-underline-offset: 3px; }
.bdg-link:hover { text-decoration-color: currentColor; }
.bdg-chip { background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px; cursor: pointer; font-size: 14px; color: var(--ink); }
.bdg-chip:hover { border-color: var(--palm); color: var(--palm); }
.bdg-chip[disabled] { opacity: .5; cursor: not-allowed; }
.bdg-tag { display: inline-block; margin-inline-start: 6px; padding: 0 8px; border-radius: 999px; background: var(--gold-2); color: var(--ink); font-size: 12px; line-height: 1.9; cursor: help; }
.bdg-tools { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; margin-bottom: 16px; }
.bdg-tools .bdg-filter { flex: 1 1 240px; width: auto; }
.bdg-tools .bdg-select { flex: 1 1 220px; width: auto; }
.bdg-btngroup { display: inline-flex; gap: 6px; }
.bdg-d-actions { margin-top: 18px !important; }
.bdg-check { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.bdg-note { border-inline-start: 3px solid var(--gold); background: var(--gold-2); padding: 12px 16px; border-radius: 0 4px 4px 0; margin-top: 26px; font-size: 15px; }
.bdg-note p + p { margin-top: 6px; }
.bdg-empty, .bdg-hint { color: var(--ink-2); padding: 18px; border: 1px dashed var(--line); border-radius: 4px; text-align: center; }
.bdg-scroll { overflow-x: auto; }
.bdg-table { width: 100%; border-collapse: collapse; font-size: 14px; background: var(--surface); }
.bdg-table th, .bdg-table td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.bdg-table th { font-weight: 600; color: var(--ink-2); background: var(--palm-2); white-space: nowrap; }

/* overview */
.bdg-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); border-top: 1px solid var(--line); }
.bdg-actions li { border-bottom: 1px solid var(--line); }
.bdg-actions a { display: flex; flex-direction: column; padding: 14px 4px 14px 18px; text-decoration: none; color: var(--ink); height: 100%; }
.bdg-actions a:hover b { color: var(--palm); text-decoration: underline; text-decoration-color: var(--gold); text-underline-offset: 5px; }
.bdg-actions b { font-size: 18px; font-family: var(--naskh); }
.bdg-actions span { color: var(--ink-2); font-size: 14px; }
.bdg-glance { margin-top: 30px; }
.bdg-branchlist { columns: 2 280px; column-gap: 28px; }
.bdg-branchrow { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: right; background: none; border: 0; border-inline-start: 2px solid var(--gold); padding: 6px 12px; margin-bottom: 8px; cursor: pointer; break-inside: avoid; }
.bdg-branchrow:hover { background: var(--surface); }
.bdg-branchrow .bdg-code { color: var(--palm); font-size: 17px; }

/* tree: the signature element. Gold rails connect each branch to its parent; the selected lineage glows gold. */
.bdg-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; }
@media (min-width: 900px) { .bdg-split { grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; } .bdg-detailwrap { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow: auto; } }
@media (max-width: 899px) { .bdg-split.has-detail .bdg-detailwrap { order: -1; } }
.bdg-treewrap { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 12px 10px 12px 6px; overflow-x: auto; }
.bdg-tree, .bdg-ul { --rail: var(--line); }
.bdg-ul { margin-inline-start: 14px !important; padding-inline-start: 14px !important; border-inline-start: 1px solid var(--rail); }
.bdg-li { position: relative; }
.bdg-ul > .bdg-li::before { content: ""; position: absolute; inset-inline-start: -14px; top: 20px; width: 12px; border-top: 1px solid var(--rail); }
.bdg-ul > .bdg-li:last-child::after { content: ""; position: absolute; inset-inline-start: -15px; top: 21px; bottom: 0; width: 2px; background: var(--surface); }
.bdg-li.on-path > .bdg-ul { border-inline-start-color: var(--gold); }
.bdg-ul > .bdg-li.on-path::before { border-top: 2px solid var(--gold); }
.bdg-row { display: flex; align-items: center; gap: 4px; min-height: 40px; }
.bdg-tog { flex: 0 0 26px; width: 26px; height: 26px; border: 1px solid var(--line); border-radius: 3px; background: var(--paper); cursor: pointer; line-height: 1; font-size: 16px; color: var(--ink-2); }
.bdg-tog:hover { border-color: var(--palm); color: var(--palm); }
.bdg-tog.is-leaf { border: 0; background: none; cursor: default; position: relative; }
.bdg-tog.is-leaf::after { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--line); }
.bdg-node { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; background: none; border: 1px solid transparent; border-radius: 3px; padding: 4px 8px; cursor: pointer; text-align: right; }
.bdg-node:hover { background: var(--palm-2); }
.bdg-node .bdg-code { font-size: 15px; color: var(--ink); }
.bdg-row.on-path .bdg-node .bdg-code { color: var(--palm); }
.bdg-row.is-current .bdg-node { background: var(--gold-2); border-color: var(--gold); }
.bdg-age, .bdg-eqs { color: var(--ink-2); font-size: 12.5px; }
.bdg-count { font-size: 12px; font-weight: 700; min-width: 22px; text-align: center; padding: 0 6px; border-radius: 999px; background: var(--palm); color: var(--surface); font-variant-numeric: tabular-nums; }
/* relation status on the drawing version: the rail into a branch shows how its parent link was established */
.bdg-ul > .bdg-li.is-ruled::before { border-top-color: var(--ruled); }
.bdg-ul > .bdg-li.is-probable::before { border-top: 2px dashed var(--probable); }
.bdg-ul > .bdg-li.is-open::before { border-top: 2px dotted var(--open); }
.bdg-li.is-open > .bdg-row .bdg-node .bdg-code::after { content: " ؟"; color: var(--open); }
.bdg-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; margin: 4px 0 14px; }
.bdg-rel { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; }
.bdg-rel::before { content: ""; width: 26px; border-top: 2px solid var(--agreed); }
.bdg-rel.is-ruled::before { border-top-color: var(--ruled); }
.bdg-rel.is-probable::before { border-top-style: dashed; border-top-color: var(--probable); }
.bdg-rel.is-open::before { border-top-style: dotted; border-top-color: var(--open); }

/* detail panel */
.bdg-detail { position: relative; background: var(--surface); border: 1px solid var(--line); border-top: 3px solid var(--palm); border-radius: 4px; padding: 18px 20px 20px; }
.bdg-detail.is-wide { max-width: 900px; }
.bdg-close { position: absolute; inset-inline-end: 12px; top: 12px; background: none; border: 1px solid var(--line); border-radius: 999px; padding: 2px 12px; cursor: pointer; font-size: 13px; color: var(--ink-2); }
.bdg-close:hover { color: var(--palm); border-color: var(--palm); }
.bdg-d-title { font-size: 26px; color: var(--palm); padding-inline-end: 90px; font-family: var(--naskh); }
.bdg-d-title:focus { outline: none; }
.bdg-crumbs { display: flex; flex-wrap: wrap; gap: 2px 0; margin: 6px 0 14px !important; font-size: 13.5px; color: var(--ink-2); }
.bdg-crumbs li:not(:last-child)::after { content: "‹"; margin: 0 7px; color: var(--gold); }
.bdg-dl { display: flex; flex-wrap: wrap; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px 0; gap: 4px 0; }
.bdg-dl div { flex: 1 1 120px; padding: 4px 12px; border-inline-start: 1px solid var(--line); }
.bdg-dl div:first-child { border-inline-start: 0; padding-inline-start: 0; }
.bdg-dl dt { font-size: 12.5px; color: var(--ink-2); }
.bdg-dl dd { font-weight: 700; font-variant-numeric: tabular-nums; }
.bdg-relbox { margin-top: 14px !important; padding: 10px 14px; border-radius: 4px; background: var(--palm-2); border-inline-start: 3px solid var(--agreed); font-size: 14.5px; }
.bdg-relbox.is-ruled { border-color: var(--ruled); } .bdg-relbox.is-probable { border-color: var(--probable); } .bdg-relbox.is-open { border-color: var(--open); }
.bdg-relbox p { margin-top: 4px; }
.bdg-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.bdg-chips li { border: 1px solid var(--line); border-radius: 3px; padding: 1px 8px; font-size: 13.5px; background: var(--paper); }
.bdg-kids { columns: 2 160px; }
.bdg-kids li { padding: 2px 0; break-inside: avoid; }
.bdg-famlist > li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.bdg-fam { font-weight: 700; font-size: 16px; }
.bdg-samples { margin-top: 4px !important; font-size: 14px; color: var(--ink-2); }
.bdg-samples li { padding: 1px 0; }

/* families + places */
.bdg-famindex { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 0 28px; border-top: 1px solid var(--line); }
.bdg-famrow { display: flex; flex-direction: column; align-items: flex-start; width: 100%; text-align: right; background: none; border: 0; border-bottom: 1px solid var(--line); padding: 10px 2px; cursor: pointer; }
.bdg-famrow b { font-family: var(--naskh); font-size: 19px; color: var(--ink); }
.bdg-famrow:hover b { color: var(--palm); }
.bdg-famindex .bdg-empty { grid-column: 1 / -1; margin-top: 12px; }
.bdg-places { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; align-items: start; }
.bdg-places > li { background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 12px 16px; }
.bdg-places > li.is-current { border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-2); }
.bdg-places h4 { margin: 0 0 6px !important; font-family: var(--naskh); font-size: 19px; }
.bdg-inline { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px !important; }

/* compare */
.bdg-compare { margin-top: 6px; }
.bdg-paths { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; margin-top: 18px; }
.bdg-pathcol { counter-reset: d; border-inline-start: 1px solid var(--line); }
.bdg-pathcol li { position: relative; padding: 3px 14px; font-size: 14px; }
.bdg-pathcol li::before { content: ""; position: absolute; inset-inline-start: -4px; top: 13px; width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.bdg-pathcol li.is-shared { color: var(--palm); }
.bdg-pathcol li.is-shared::before { background: var(--gold); }
.bdg-pathcol li:not(.is-shared) { font-weight: 700; }

/* about */
.bdg-sources li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.bdg-terms { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 6px 22px; }
.bdg-terms dt { font-weight: 700; }
.bdg-terms dd { color: var(--ink-2); max-width: 70ch; }
.bdg-legendlist li, .bdg-limits li { padding: 3px 0; }
.bdg-limits li::before { content: "—"; color: var(--gold); margin-inline-end: 8px; }

/* segmented control for tree versions */
.bdg-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 4px; overflow: hidden; }
.bdg-seg-b { border: 0; background: var(--surface); padding: 7px 14px; cursor: pointer; font-size: 14px; }
.bdg-seg-b + .bdg-seg-b { border-inline-start: 1px solid var(--line); }
.bdg-seg-b[aria-pressed="true"] { background: var(--palm); color: var(--surface); }

@media (max-width: 640px) {
	.bdg-app { margin: 0; border-radius: 0; border-inline: 0; padding: 18px 16px 28px; }
	.bdg-bar { position: static; }
	.bdg-searchbox { flex-basis: 100%; }
	.bdg-terms { grid-template-columns: 1fr; gap: 0; }
	.bdg-terms dd { margin-bottom: 8px; }
	.bdg-detail { padding: 16px; }
	.bdg-tree .bdg-age, .bdg-tree .bdg-eqs { display: none; }
	.bdg-node { flex-wrap: nowrap; }
	.bdg-nav a { padding: 10px 9px 9px; }
	.bdg-ul { margin-inline-start: 8px !important; padding-inline-start: 10px !important; }
	.bdg-ul > .bdg-li::before { inset-inline-start: -10px; width: 8px; }
	.bdg-ul > .bdg-li:last-child::after { inset-inline-start: -11px; }
}
@media (prefers-reduced-motion: reduce) { .bdg-app * { transition: none !important; scroll-behavior: auto !important; } }
@media print { .bdg-bar, .bdg-tools, .bdg-close, .bdg-chip { display: none !important; } .bdg-app { border: 0; } }

/* poster viewer */
.bdg-pz-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.bdg-pz-pct { font-variant-numeric: tabular-nums; min-width: 4.5em; text-align: center; direction: ltr; }
.bdg-pz { position: relative; overflow: hidden; height: min(78vh, 820px); background: #efe6d2; border: 1px solid var(--line, #ddd); border-radius: 6px; touch-action: none; cursor: grab; user-select: none; direction: ltr; }
.bdg-pz.is-drag { cursor: grabbing; }
.bdg-pz:focus-visible { outline: 3px solid var(--gold, #b8860b); outline-offset: 2px; }
.bdg-pz-img { position: absolute; top: 0; left: 0; max-width: none !important; height: auto; transform-origin: 0 0; will-change: transform; }
