/* Evidence tree page (/tree/): the page around the drawing. The colour tokens and the rules for the drawing itself
   (.ft-svg) are in draw.css, which the page loads first.
   Two themes on <html data-theme>: dark (default, from the prototype) and a warm paper light theme. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { overflow-x: clip; }   /* safety net; clip keeps position: sticky working */
html.ft-noscroll { overflow: hidden; }
body { margin: 0; min-height: 100vh; background: var(--ft-page); background-color: var(--ft-bg); color: var(--ft-ink); font-family: var(--ft-f-ui); font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5, p, figure, dl, dd, ol, ul, pre { margin: 0; }
ol, ul { padding: 0; list-style: none; }
button, input, select { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
img { max-width: 100%; height: auto; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--ft-gold); outline-offset: 2px; }
.ft-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- header ---------- */
.ft-top { display: flex; align-items: center; gap: 14px; padding: 14px 24px; border-bottom: 1px solid var(--ft-hair); }
.ft-logo { flex: none; display: block; line-height: 0; }
.ft-logo img { width: 56px; height: 56px; border-radius: 50%; }
.ft-titles { flex: 1; min-width: 0; }
.ft-top h1 { font-family: var(--ft-f-name); font-weight: 700; font-size: 2rem; line-height: 1.3; color: var(--ft-gold-ink); }
.ft-titles p { color: var(--ft-muted); font-size: .92rem; }
.ft-tools { display: flex; align-items: center; gap: 10px; flex: none; }
.ft-home { color: var(--ft-ink2); font-size: .85rem; text-underline-offset: 3px; }
.ft-home:hover { color: var(--ft-gold-ink); }
.ft-tools select { appearance: none; -webkit-appearance: none; background: var(--ft-sheet); border: 1px solid var(--ft-line); border-radius: 8px; padding: 6px 12px; font-size: .8rem; font-weight: 700; cursor: pointer; }
.ft-theme { width: 36px; height: 36px; border: 1px solid var(--ft-line); border-radius: 8px; background: var(--ft-sheet); display: grid; place-items: center; }
.ft-theme svg { width: 18px; height: 18px; fill: none; stroke: var(--ft-gold-ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
:root[data-theme="dark"] .ft-theme .moon, :root[data-theme="light"] .ft-theme .sun { display: none; }

.ft-main { width: 100%; padding: 14px 16px 48px; }
.ftree, .ft-panel { direction: rtl; }
.ftree { position: relative; width: min(1400px, 100%); margin-inline: auto; }
/* the widget stays RTL in every language; text-only elements are ordered by their own first strong letter,
   so translated (Latin) UI strings keep their punctuation in place next to the Arabic names */
.ft-credits p, .ft-btn, .ft-switch span, .ft-legend > summary, .ft-legend .say, .ft-hint, .ft-tip b, .ft-floats > h2, .ft-floats > p,
.ft-fcard figcaption, .ft-legend .hint, .ft-legend b, .ft-results .rn, .ft-results .empty, .ft-error, .ft-stats span, .ft-rotate span,
.ft-panel .eyebrow, .ft-panel h2, .ft-panel h4, .ft-panel h5, .ft-panel .qt, .ft-panel .note, .ft-panel .muted, .ft-panel .st, .ft-panel .bd, .ft-panel .pl,
.ft-panel summary, .ft-panel .src, .ft-panel .srcline, .ft-panel .cta, .ft-panel .add, .ft-reader h2, .ft-reader .rm > span, .ft-reader [role=tab],
.ft-reader .note, .ft-reader .qt, .ft-reader .ql, .ft-reader dt, .ft-reader dd, .ft-reader .own, .ft-reader .muted, .ft-chain h2, .ft-chain .ch p,
.ft-chain .gen, .ft-chain .lb, .ft-chain .card > b { unicode-bidi: plaintext; }

/* ---------- stats and toolbar ---------- */
.ft-stats { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
.ft-stats .tile { display: flex; align-items: baseline; gap: 8px; padding: 6px 14px; border: 1px solid var(--ft-hair); border-radius: 10px; background: color-mix(in srgb, var(--ft-sheet) 70%, transparent); }
a.tile { color: inherit; text-decoration: none; }
a.tile:hover { border-color: var(--ft-gold); }
.ft-stats b { font-family: var(--ft-f-name); font-size: 1.45rem; line-height: 1.2; color: var(--ft-gold-ink); font-variant-numeric: tabular-nums; }
.ft-stats span { font-size: .8rem; color: var(--ft-ink2); }
.ft-stats b { unicode-bidi: plaintext; }
.ft-stats b.wait { visibility: hidden; }   /* placeholder digits hold the tile's width until the data arrives */
.ft-stat-note { color: var(--ft-ink2); font-size: .86rem; line-height: 1.8; margin-bottom: 8px; unicode-bidi: plaintext; }
.ft-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding-block: 4px 10px; }
.ft-search { position: relative; flex: 0 1 320px; min-width: 0; }
.ft-acts { display: contents; }
.ft-search input { min-width: 0; width: 100%; padding: 7px 36px 7px 12px; border: 1px solid var(--ft-line); border-radius: 8px; background: var(--ft-sheet); }
.ft-search input::placeholder { color: var(--ft-muted); opacity: 1; }
.ft-search > svg { position: absolute; right: 11px; top: 50%; translate: 0 -50%; width: 16px; height: 16px; stroke: var(--ft-muted); fill: none; stroke-width: 2; pointer-events: none; }
.ft-results { position: absolute; inset-inline: 0; top: calc(100% + 4px); z-index: 30; padding: 4px; background: var(--ft-sheet); border: 1px solid var(--ft-line); border-radius: 10px; box-shadow: var(--ft-shadow); max-height: min(60vh, 380px); overflow: auto; }
.ft-results li { padding: 6px 10px; border-radius: 7px; cursor: pointer; display: grid; }
.ft-results li[aria-selected="true"], .ft-results li:hover { background: var(--ft-quote); }
/* names without a text node (tree.js, tAttr): the text is drawn here, so there is no word in the page for «Touch to Search» */
[data-t]::before { content: attr(data-t); }
.ft-results .rn { font-family: var(--ft-f-name); font-weight: 700; font-size: 1.05rem; }
.ft-results .rm { font-size: .8rem; line-height: 1.8; color: var(--ft-muted); white-space: normal; overflow-wrap: anywhere; unicode-bidi: plaintext; }   /* the full chain, wrapped, never cut */
.ft-results .empty { color: var(--ft-muted); cursor: default; }
.ft-results .hint { padding: 8px 12px; font-size: .86rem; line-height: 1.8; color: var(--ft-ink2); border-top: 1px solid var(--ft-line); }
.ft-results .hint:first-child { border-top: 0; }
.ft-results .hint:hover { background: none; }
.ft-results .nf { display: grid; gap: 10px; padding: 10px 12px; color: var(--ft-ink); line-height: 1.8; }
.ft-results .nf:hover { background: none; }
.ft-results .nf-btn { justify-self: start; min-height: 44px; padding: 0 20px; border-radius: 10px; background: var(--ft-gold); color: var(--ft-bg); font-weight: 700; display: inline-flex; align-items: center; text-decoration: none; cursor: pointer; }

.ft-switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: .86rem; user-select: none; -webkit-user-select: none; }
.ft-switch input { appearance: none; -webkit-appearance: none; width: 34px; height: 20px; border-radius: 999px; background: var(--ft-line); border: 1px solid var(--ft-muted); position: relative; cursor: pointer; flex: none; margin: 0; }
.ft-switch input::after { content: ""; position: absolute; top: 2px; right: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--ft-ink); transition: right .15s ease-out; }
.ft-switch input:checked { border-color: var(--ft-gold); }
.ft-switch input:checked::after { right: 16px; background: var(--ft-gold); }
.ft-btn { border: 1px solid var(--ft-line); background: var(--ft-sheet); border-radius: 8px; padding: 6px 12px; font-size: .86rem; white-space: nowrap; }
.ft-btn:hover { border-color: var(--ft-gold); }

/* ---------- stage ---------- */
.ft-stage { position: relative; height: clamp(480px, calc(100vh - 170px), 900px); border: 1px solid var(--ft-hair); border-radius: 12px; overflow: hidden; contain: paint; background: var(--ft-page); background-color: var(--ft-bg); }
.ft-stage.fs { position: fixed; inset: 0; z-index: 8000; height: 100vh !important; height: 100dvh !important; border: 0; border-radius: 0; }
#ft-tree { display: block; width: 100%; height: 100%; touch-action: pan-x pan-y; cursor: grab; user-select: none; -webkit-user-select: none; }
.ft-stage.fs #ft-tree { touch-action: none; }
#ft-tree:active { cursor: grabbing; }
.ft-zoom { position: absolute; top: 12px; right: 12px; display: grid; border: 1px solid var(--ft-line); border-radius: 9px; overflow: hidden; background: var(--ft-sheet); z-index: 5; }
.ft-zoom button { width: 38px; height: 36px; display: grid; place-items: center; }
.ft-zoom button + button { border-top: 1px solid var(--ft-line); }
.ft-zoom button:hover, .ft-zoom button[aria-pressed="true"] { background: var(--ft-quote); }
.ft-zoom svg { width: 16px; height: 16px; stroke: var(--ft-ink); stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ft-legend { position: absolute; top: 12px; left: 12px; z-index: 5; background: color-mix(in srgb, var(--ft-sheet) 94%, transparent); border: 1px solid var(--ft-hair); border-radius: 10px; font-size: .82rem; width: max-content; max-width: min(330px, calc(100% - 76px)); }
.ft-legend > summary { list-style: none; cursor: pointer; padding: 6px 12px; font-weight: 700; font-size: .82rem; color: var(--ft-ink2); user-select: none; -webkit-user-select: none; }
.ft-legend > summary::-webkit-details-marker { display: none; }
.ft-legend > summary::after { content: " ▾"; }
.ft-legend[open] > summary::after { content: " ▴"; }
.ft-legend-body { display: grid; gap: 7px; padding: 2px 12px 10px; }
.ft-legend .lx { display: none; }   /* the ✕ is for phones, where the open legend is a card over the tree */
.ft-legend .lead { font-size: .8rem; color: var(--ft-ink2); }
.ft-legend ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ft-legend b { font-weight: 700; }
.ft-legend li.dot { display: flex; align-items: center; gap: 8px; }
.ft-legend li.dot svg { flex: none; }
.ft-legend li.dot path { fill: none; stroke: var(--ft-branch); stroke-width: 3; stroke-linecap: round; stroke-dasharray: 1 6.5; }
.ft-legend .say { font-size: .8rem; line-height: 1.75; color: var(--ft-ink2); border-top: 1px solid var(--ft-line); padding-top: 6px; }
.ft-legend .how { font-size: .8rem; color: var(--ft-gold-ink); min-height: 32px; display: inline-flex; align-items: center; }
.ft-legend .hint { color: var(--ft-muted); font-size: .8rem; }
.ft-hint { position: absolute; left: 50%; top: 50%; translate: -50% -50%; z-index: 6; pointer-events: none; background: rgb(10 12 11 / .88); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: .95rem; white-space: nowrap; max-width: calc(100% - 24px); }
.ft-rotate { position: absolute; inset-inline: 10px; bottom: 10px; z-index: 6; display: flex; align-items: center; justify-content: space-between; gap: 10px; background: var(--ft-sheet); border: 1px solid var(--ft-hair); border-radius: 10px; padding: 8px 12px; font-size: .84rem; }
.ft-rotate button { width: 30px; height: 30px; display: grid; place-items: center; flex: none; }
.ft-rotate svg { width: 14px; height: 14px; stroke: var(--ft-ink); stroke-width: 2; fill: none; stroke-linecap: round; }
.ft-error { position: absolute; inset: 0; z-index: 12; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; color: var(--ft-ink2); background: var(--ft-bg); }
.ft-error .cta { cursor: pointer; }
.ft-credits { width: min(760px, 100%); margin: 30px auto 0; color: var(--ft-ink2); font-size: .98rem; line-height: 2; text-align: center; }
.ft-credits p + p { margin-top: 12px; }
.ft-tip { position: absolute; z-index: 20; pointer-events: none; max-width: min(340px, calc(100% - 8px)); background: #0c0f0d; color: #f1ede3; border: 1px solid var(--ft-hair); border-radius: 8px; padding: 7px 11px; box-shadow: var(--ft-shadow); display: grid; gap: 2px; }
.ft-tip b { font-family: var(--ft-f-name); font-size: 1.1rem; line-height: 1.5; }
.ft-tip span { font-size: .8rem; line-height: 1.7; color: #cfcabd; }

/* ---------- svg ---------- */

/* a link with no document yet (the author's tree only, or a «قيد البحث» circle) is dotted; its dash sizes are set with the path */

/* the small date under a name: «~1170هـ» */

/* the olive trunk: three winding strands (lighter in front, darker behind), bark strokes, a hollow and a knot — paths only */

/* thousands of names: plain discs and plain lines when a fruit is only a few pixels wide, and while a very large tree is moving */

/* allowed motion: the branches grow once on first load; the trunk's leaves sway a little */

/* ---------- person panel ---------- */
.ft-panel { position: absolute; top: 0; bottom: 0; left: 0; width: min(440px, 44%); background: var(--ft-sheet); color: var(--ft-ink); border-inline-start: 1px solid var(--ft-hair); z-index: 10; display: flex; flex-direction: column; opacity: 0; transition: opacity .2s ease-out; visibility: hidden; pointer-events: none; font-family: var(--ft-f-ui); font-size: 15px; line-height: 1.6; }
/* on desktop the panel fades in place: parked off-screen to the left with a transform, it shifted full-page
   captures of the RTL page sideways */
.ft-panel.open { opacity: 1; visibility: visible; pointer-events: auto; }
.ft-panel .ph { display: flex; align-items: flex-start; gap: 10px; padding: 16px 18px 12px; border-bottom: 1px solid var(--ft-hair); }
.ft-panel .ph .grab { display: none; }
.ft-panel .ph .tt { flex: 1; min-width: 0; display: grid; gap: 4px; }
.ft-panel .eyebrow { font-size: .8rem; color: var(--ft-muted); }
/* the estimated birth date, its small tag (how it is known) and the basis the tag reveals */
.ft-panel .born { font-size: .9rem; line-height: 2; color: var(--ft-ink2); }
.ft-panel .born > span { unicode-bidi: plaintext; }
.ft-panel .btag { margin-inline-start: 6px; vertical-align: middle; }
.ft-panel .btag { display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border: 1px solid var(--ft-hair); border-radius: 999px; font-size: .78rem; font-weight: 700; color: var(--ft-gold-ink); cursor: pointer; }
.ft-panel .btag[aria-expanded="true"] { border-color: var(--ft-gold); }
.ft-panel .born .basis { margin-top: 6px; padding: 8px 10px; border-radius: 8px; background: var(--ft-quote); font-size: .84rem; line-height: 1.8; color: var(--ft-ink); unicode-bidi: plaintext; }
.ft-chain .born { font-size: .84rem; color: var(--ft-ink2); unicode-bidi: plaintext; }
.ft-tip .born { color: #e6c964; }
.ft-panel .ph h2 { font-family: var(--ft-f-name); font-weight: 700; font-size: 1.9rem; line-height: 1.4; text-wrap: balance; }
.ft-panel .line { font-family: var(--ft-f-name); font-size: 1.05rem; line-height: 1.9; color: var(--ft-ink2); }
.ft-panel .line .bn { color: var(--ft-muted); }
.ft-panel .lk { font-family: var(--ft-f-name); font-weight: 700; text-decoration: underline; text-decoration-color: var(--ft-hair); text-underline-offset: 4px; }
.ft-panel .lk:hover { text-decoration-color: var(--ft-gold); }
.ft-panel .badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 2px; }
.ft-panel .x { flex: none; width: 36px; height: 36px; border: 1px solid var(--ft-line); border-radius: 8px; display: grid; place-items: center; }
.ft-panel .x svg { width: 14px; height: 14px; stroke: var(--ft-ink); stroke-width: 2; stroke-linecap: round; fill: none; }
.ft-panel .pb { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 14px 18px 24px; display: grid; gap: 18px; align-content: start; overscroll-behavior: contain; }
.ft-panel .ps { display: contents; }   /* desktop: the header stays, the body scrolls; phones: both scroll together (below) */
.ft-panel .pf { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 10px 18px 12px; border-top: 1px solid var(--ft-hair); background: var(--ft-sheet); }
.ft-panel .pf:empty { display: none; }
.ft-panel .pf .cta { white-space: nowrap; }
.ft-panel .sec { display: grid; gap: 8px; min-width: 0; }
.ft-panel .sec > h4 { font-size: .8rem; font-weight: 700; color: var(--ft-muted); }
.ft-panel h5 { font-size: .8rem; font-weight: 700; color: var(--ft-muted); margin-top: 8px; }
.st, .bd { display: inline-flex; align-items: center; gap: 6px; font-size: .8rem; font-weight: 700; padding: 2px 11px; border-radius: 999px; white-space: nowrap; border: 1.4px solid var(--ft-branch); color: var(--ft-ink); }
.bd { border-color: var(--ft-line); font-weight: 600; color: var(--ft-ink2); }
.bd.need { border-color: var(--ft-hair); }
.ft-panel .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ft-panel .pl { border: 1px solid var(--ft-line); background: var(--ft-bg); border-radius: 999px; padding: 2px 12px; font-family: var(--ft-f-name); font-size: 1rem; font-weight: 700; line-height: 1.7; text-align: start; }
.ft-panel .pl:hover { border-color: var(--ft-gold); }
.cta { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--ft-gold); border-radius: 10px; padding: 9px 14px; font-weight: 700; font-size: .92rem; color: var(--ft-ink); background: color-mix(in srgb, var(--ft-gold) 12%, transparent); text-decoration: none; }
.cta:hover { background: color-mix(in srgb, var(--ft-gold) 22%, transparent); }
.ft-panel .add { justify-self: start; border: 1px solid var(--ft-hair); border-radius: 999px; padding: 4px 14px; font-size: .84rem; color: var(--ft-ink2); }
.ft-panel .add:hover { border-color: var(--ft-gold); color: var(--ft-ink); }
.ft-panel .addbox { border: 1px solid var(--ft-hair); border-radius: 10px; padding: 10px 12px; display: grid; gap: 6px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; color: var(--ft-ink2); direction: ltr; text-align: end; }
.small { font-size: .8rem; }
.strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.th { display: grid; gap: 3px; border: 1px solid var(--ft-hair); border-radius: 8px; padding: 4px; background: var(--ft-bg); text-align: start; min-width: 0; }
.th:hover { border-color: var(--ft-gold); }
.th img { width: 100%; height: 118px; object-fit: cover; object-position: top; border-radius: 5px; background: #fff; display: block; }
.th .thm { display: flex; align-items: center; justify-content: space-between; gap: 4px; font-size: .8rem; }
.th .thp { font-size: .8rem; color: var(--ft-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conf { display: inline-flex; align-items: center; gap: 4px; font-size: .8rem; color: var(--ft-ink2); }
.conf i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; border: 1.3px solid var(--ft-ink2); }
.conf i.on { background: var(--ft-ink2); }
.noimg { border: 1px solid var(--ft-line); border-radius: 8px; padding: 10px 12px; display: grid; gap: 4px; }
.noimg b { font-size: .9rem; }
.noimg .thd, .noimg .src { font-size: .8rem; color: var(--ft-muted); }
.lnk { color: var(--ft-gold-ink); font-size: .8rem; }
.qt { font-family: var(--ft-f-name); font-size: 1.12rem; line-height: 1.9; background: var(--ft-quote); border-radius: 8px; padding: 8px 14px; overflow-wrap: anywhere; }
.qt::before { content: "«"; }
.qt::after { content: "»"; }
.ql { font-size: .8rem; color: var(--ft-muted); margin-bottom: 4px; }
.note { font-size: 1.02rem; line-height: 1.9; font-family: var(--ft-f-name); overflow-wrap: anywhere; }
.srcline { font-size: .86rem; line-height: 1.8; color: var(--ft-ink2); border-inline-start: 2px solid var(--ft-hair); padding-inline-start: 10px; overflow-wrap: anywhere; }
.muted { color: var(--ft-muted); }
details.audit { border-top: 1px solid var(--ft-line); padding-top: 8px; }
details.audit > summary { cursor: pointer; font-weight: 700; color: var(--ft-muted); font-size: .8rem; }

/* ---------- document reader ---------- */
.ft-reader { position: fixed; inset: 0; z-index: 10000; background: var(--ft-bg); color: var(--ft-ink); display: flex; flex-direction: column; font-family: var(--ft-f-ui); font-size: 15px; line-height: 1.6; --ft-sheet-h: 48%; }
.ft-reader .rh { display: flex; align-items: flex-start; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--ft-hair); }
.ft-reader .rt { flex: 1; min-width: 0; display: grid; gap: 4px; }
.ft-reader h2 { font-family: var(--ft-f-name); font-size: 1.3rem; line-height: 1.5; }
.ft-reader .rm { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; font-size: .82rem; color: var(--ft-ink2); }
.ft-reader .rm .pg { font-weight: 700; color: var(--ft-ink); }
.ft-reader .rnav { display: flex; align-items: center; gap: 6px; flex: none; direction: ltr; }
.ft-reader .rnav span { font-size: .82rem; font-variant-numeric: tabular-nums; color: var(--ft-ink2); min-width: 3.2em; text-align: center; }
/* the copy button in the reader's tab row copies the text of the open tab */
.ft-reader [role=tablist] .cp, .ft-reader .rt .cp { margin: -6px 0; margin-inline-start: auto; color: var(--ft-gold-ink); }
.ft-reader .rnav button, .ft-reader .rtools button, .ft-chain .ch button { width: 38px; height: 38px; border: 1px solid var(--ft-line); border-radius: 8px; background: var(--ft-sheet); display: grid; place-items: center; }
.ft-reader .rnav button:disabled { opacity: .35; cursor: default; }
.ft-reader svg, .ft-chain .ch svg { width: 16px; height: 16px; stroke: var(--ft-ink); stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.ft-reader .rb { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr minmax(340px, 40%); direction: ltr; position: relative; }
.ft-reader .rv { position: relative; overflow: hidden; display: grid; place-items: center; touch-action: none; cursor: grab; background: #0b0d0c; user-select: none; -webkit-user-select: none; }
:root[data-theme="light"] .ft-reader .rv { background: #e9e3d3; }
.ft-reader .rv:active { cursor: grabbing; }
.ft-reader .rv img { position: absolute; left: 50%; top: 50%; max-width: none; transform-origin: center; will-change: transform; background: #fff; pointer-events: none; }
.ft-reader .rtools { position: absolute; bottom: 12px; left: 50%; translate: -50% 0; display: flex; gap: 6px; }
.ft-reader .rs { direction: rtl; display: flex; flex-direction: column; min-height: 0; border-inline-start: 1px solid var(--ft-hair); background: var(--ft-sheet); }
.ft-reader .grab { display: none; }
.ft-reader .tabs { display: flex; gap: 2px; padding: 8px 12px 0; border-bottom: 1px solid var(--ft-line); overflow-x: auto; flex: none; }
.ft-reader [role=tab] { padding: 8px 12px; font-size: .88rem; font-weight: 700; color: var(--ft-ink2); border-bottom: 2px solid transparent; white-space: nowrap; }
.ft-reader [role=tab][aria-selected="true"] { color: var(--ft-ink); border-bottom-color: var(--ft-gold); }
.ft-reader .tp { flex: 1; overflow: auto; padding: 14px 16px 24px; overscroll-behavior: contain; }
.ft-reader .tr { font-family: 'Amiri', 'Courier New', monospace; font-size: 1.15rem; line-height: 2.1; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--ft-quote); border-inline-start: 3px solid var(--ft-gold); border-radius: 8px; padding: 10px 14px; unicode-bidi: plaintext; text-align: start; margin-top: 10px; }
.mk { display: inline-block; font-family: var(--ft-f-ui); font-size: .66em; line-height: 1.5; color: var(--ft-muted); border: 1px solid var(--ft-line); border-radius: 5px; padding: 0 5px; margin-inline: 2px; vertical-align: middle; }
.mkl { margin-top: 10px; font-size: .8rem; color: var(--ft-muted); }
.ft-reader .own { margin-top: 10px; font-weight: 700; }
.ft-reader .au { display: grid; gap: 12px; }
.ft-reader .au dt { font-size: .8rem; color: var(--ft-muted); }
.ft-reader .au dd { line-height: 1.9; font-family: var(--ft-f-name); font-size: 1.02rem; overflow-wrap: anywhere; }

/* ---------- chain ---------- */
.ft-chain { position: fixed; inset: 0; z-index: 9500; overflow: auto; background: var(--ft-page); background-color: var(--ft-bg); color: var(--ft-ink); font-family: var(--ft-f-ui); font-size: 15px; line-height: 1.6; }
.ft-chain .ch { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px; padding: 12px 18px; background: var(--ft-bg); border-bottom: 1px solid var(--ft-hair); }
.ft-chain .ch > div { flex: 1; min-width: 0; }
.ft-chain h2 { font-family: var(--ft-f-name); font-size: 1.5rem; line-height: 1.4; color: var(--ft-gold-ink); }
.ft-chain .ch p { font-size: .88rem; color: var(--ft-ink2); }
.ft-chain .nasab { width: min(560px, 100% - 32px); margin: 18px auto 0; font-family: var(--ft-f-name); font-size: 1.12rem; line-height: 2; color: var(--ft-ink); unicode-bidi: plaintext; }
.ft-chain .cl { width: min(560px, 100% - 32px); margin: 22px auto 64px; display: grid; }
.ft-chain .cc { display: grid; justify-items: center; position: relative; }
.ft-chain .card { width: 100%; border: 1px solid var(--ft-hair); border-radius: 12px; background: var(--ft-sheet); padding: 12px 16px; display: grid; gap: 6px; opacity: 0; transform: translateY(10px); transition: opacity .25s ease-out, transform .25s ease-out; }
.ft-chain .cc.in .card { opacity: 1; transform: none; }
.ft-chain .basis { font-family: var(--ft-f-name); font-size: 1rem; line-height: 1.9; color: var(--ft-ink2); unicode-bidi: plaintext; }
.ft-chain .gen { font-size: .8rem; color: var(--ft-muted); }
.ft-chain .nm { font-family: var(--ft-f-name); font-size: 1.45rem; line-height: 1.5; }
.ft-chain .strip { grid-template-columns: repeat(auto-fill, 60px); align-items: center; }
.ft-chain .th { padding: 2px; }
.ft-chain .th img { height: 72px; }
.ft-chain .more { font-size: .8rem; color: var(--ft-muted); direction: ltr; }
/* the thin gold line that draws from card to card as the reader scrolls */
.ft-chain .ln { display: block; width: 2px; height: 64px; background: var(--ft-gold); transform: scaleY(0); transform-origin: top; transition: transform .6s ease-out .1s; }
.ft-chain .cc.in .ln { transform: scaleY(1); }
.ft-chain .lb { position: absolute; bottom: 8px; inset-inline-start: calc(50% + 14px); max-width: calc(50% - 18px); display: grid; gap: 0; font-size: .8rem; line-height: 1.5; font-weight: 700; color: var(--ft-ink2); }   /* one line per label: documents, then the civil registry */
.ft-chain .lb > span { unicode-bidi: plaintext; }
.ft-chain .cc.root .card { width: 190px; height: 190px; border-radius: 50%; border: 3px solid var(--ft-gold); place-content: center; text-align: center; box-shadow: 0 0 0 6px color-mix(in srgb, var(--ft-gold) 14%, transparent); }
.ft-chain .cc.root .strip { justify-content: center; grid-template-columns: repeat(3, 34px); }
.ft-chain .cc.root .th:nth-child(n+4), .ft-chain .cc.root .more { display: none; }
.ft-chain .cc.root .th img { height: 40px; }

/* ---------- phones ---------- */
@media (max-width: 720px) {
  .ft-bar { gap: 6px 8px; }
  .ft-search { flex: 1 1 100%; }
  /* one row that scrolls sideways: its height cannot change when the web fonts arrive */
  .ft-acts { display: flex; flex: 1 1 100%; align-items: center; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-block: 2px; }
  .ft-acts::-webkit-scrollbar { display: none; }
  .ft-acts > * { flex: none; }
  .ft-switch { font-size: .8rem; }
  .ft-btn { font-size: .8rem; padding: 5px 10px; }
  .ft-stage { height: 72vh; height: 72svh; min-height: 380px; }
  .ft-legend { top: 8px; left: 8px; font-size: .8rem; }
  /* open on a phone: a card over the stage, with its own ✕; it scrolls inside, and the tree under it is not refitted */
  .ft-legend[open] { top: 12px; left: 12px; right: 12px; width: auto; max-width: none; max-height: calc(100% - 24px); overflow: auto; overscroll-behavior: contain; z-index: 8; background: var(--ft-sheet); font-size: .9rem; }
  .ft-legend[open] > summary { min-height: 44px; display: flex; align-items: center; padding-inline-end: 56px; font-size: .95rem; }
  .ft-legend[open] .lx { display: grid; place-items: center; position: absolute; top: 0; inset-inline-end: 0; width: 44px; height: 44px; border-radius: 10px; cursor: pointer; }
  .ft-legend .lx svg { width: 15px; height: 15px; stroke: var(--ft-ink); stroke-width: 1.8; fill: none; stroke-linecap: round; }
  .ft-hint { font-size: .85rem; white-space: normal; text-align: center; }
  .ft-zoom { top: 8px; right: 8px; }
  .ft-credits { font-size: .9rem; }
  /* bottom sheet: tree.js moves the panel to <body> on phones (and into the stage in full screen) */
  .ft-panel { position: fixed; top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 62%; max-height: 62dvh; z-index: 9000; border-inline-start: 0; border-top: 1px solid var(--ft-hair); border-radius: 16px 16px 0 0; transform: translateY(104%); opacity: 1; transition: transform .22s ease-out; box-shadow: var(--ft-shadow); }
  .ft-stage.fs .ft-panel { position: absolute; }
  .ft-panel.open { transform: none; }
  .ft-panel .ph { padding: 6px 16px 10px; flex-wrap: wrap; }
  .ft-panel .ph .grab { display: block; width: 100%; height: 14px; position: relative; }
  .ft-panel .ph .grab::after { content: ""; position: absolute; top: 5px; left: 50%; translate: -50% 0; width: 40px; height: 4px; border-radius: 2px; background: var(--ft-line); }
  .ft-panel .ph h2 { font-size: 1.75rem; }
  /* the sheet is a column: the header and the body scroll as one, and the buttons' row is a footer that is always in view */
  .ft-panel .ps { display: block; flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; }
  .ft-panel .pb { flex: none; overflow: visible; padding: 12px 16px calc(20px + env(safe-area-inset-bottom, 0px)); }
  .ft-panel .pf { padding: 10px 16px max(12px, env(safe-area-inset-bottom)); }
  .ft-panel .ps:has(+ .pf:not(:empty)) .pb { padding-bottom: 16px; }
  /* reader: the image on top, the text in a sheet that drags up over it */
  .ft-reader .rb { display: block; }
  .ft-reader .rv { position: absolute; inset: 0 0 var(--ft-sheet-h, 48%) 0; height: auto; }
  .ft-reader .rs { position: absolute; left: 0; right: 0; bottom: 0; height: var(--ft-sheet-h, 48%); border-inline-start: 0; border-top: 1px solid var(--ft-hair); border-radius: 14px 14px 0 0; }
  .ft-reader .grab { display: grid; place-items: center; width: 100%; height: 22px; flex: none; touch-action: none; cursor: ns-resize; }
  .ft-reader .grab i { width: 44px; height: 4px; border-radius: 2px; background: var(--ft-muted); }
  .ft-reader h2 { font-size: 1.05rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .ft-reader .rh { padding: 8px 12px; gap: 8px; }
  .ft-reader .rm { font-size: .8rem; gap: 2px 10px; }
  .ft-reader .rm > span:nth-child(2) { flex: 1 1 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ft-reader .rnav button { width: 34px; height: 34px; }
}
/* compact header on small phones: one-line title at 20px and a smaller logo */
@media (max-width: 600px) {
  .ft-top { flex-wrap: wrap; gap: 6px 10px; padding: 8px 12px; }
  .ft-logo img { width: 34px; height: 34px; }
  .ft-top h1 { font-size: 20px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ft-titles p { font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .ft-tools { flex: 1 1 100%; justify-content: space-between; gap: 8px; }
  .ft-tools select { padding: 4px 10px; }
  .ft-theme { width: 32px; height: 32px; }
  .ft-main { padding: 8px 12px 40px; }
  .ft-stats { gap: 6px; margin-bottom: 6px; flex-wrap: nowrap; }
  .ft-stats .tile { flex: 1 1 0; min-width: 0; flex-direction: column; align-items: center; gap: 0; padding: 3px 6px; }
  .ft-stats .tile span { max-width: 100%; height: 2.6em; line-height: 1.3; text-align: center; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .ft-stat-note { font-size: .8rem; line-height: 1.7; min-height: 5.1em; }
  .ft-stats b { font-size: 1.15rem; }
  .ft-stats span { font-size: .8rem; }
}
@media (prefers-reduced-motion: reduce) {
  .ft-panel, .ft-chain .card, .ft-chain .ln, .ft-svg .L-leaves { transition: none; }
  .ft-chain .card { opacity: 1; transform: none; }
  .ft-chain .ln { transform: scaleY(1); }

}
@media print { .ft-panel, .ft-zoom, .ft-bar, .ft-hint, .ft-tip, .ft-rotate, .ft-tools { display: none !important; } }

/* ---------- app-like touch: no text selection or long-press pop-up anywhere on the page ---------- */
body { -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
img { -webkit-user-drag: none; }
/* the only exception: form fields stay editable. Copying is done with the «نسخ» buttons (home.css, touch.js). */
input, textarea, [contenteditable], [contenteditable] * {
  -webkit-user-select: text; user-select: text; -webkit-touch-callout: default;
}
.ft-panel .tst { display: grid; gap: 8px; justify-items: start; }
.ft-panel .tst .who { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; font-family: var(--ft-f-name); font-size: 1.05rem; line-height: 1.8; unicode-bidi: plaintext; }
.ft-chain .ch button.share { width: auto; padding: 0 14px; font: inherit; font-size: .86rem; font-weight: 700; color: var(--ft-gold-ink); border-color: var(--ft-hair); white-space: nowrap; cursor: pointer; }
/* the share box (where the phone's own share sheet is not available): the picture, WhatsApp, download, copy the link */
.ft-share { width: min(420px, 100vw - 24px); max-height: calc(100vh - 24px); padding: 0; border: 1px solid var(--ft-gold); border-radius: 14px; background: var(--ft-sheet); color: var(--ft-ink); font-family: var(--ft-f-ui); overflow: auto; z-index: 9800; }
.ft-share::backdrop { background: rgba(0, 0, 0, .7); }
.ft-share header { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--ft-hair); }
.ft-share h2 { flex: 1; font-family: var(--ft-f-name); font-size: 1.3rem; color: var(--ft-gold-ink); }
.ft-share header button { width: 38px; height: 38px; border: 1px solid var(--ft-line); border-radius: 8px; background: transparent; display: grid; place-items: center; cursor: pointer; }
.ft-share header svg { width: 16px; height: 16px; stroke: var(--ft-ink); stroke-width: 1.8; fill: none; stroke-linecap: round; }
.ft-share img { display: block; width: 216px; height: 270px; margin: 14px auto; border-radius: 8px; border: 1px solid var(--ft-hair); }
.ft-share .acts { display: grid; gap: 8px; padding: 0 14px 14px; }
.ft-share .b { min-height: 46px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--ft-gold); background: transparent; color: var(--ft-gold-ink); font: inherit; font-weight: 700; text-decoration: none; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.ft-share .b.wa { background: var(--ft-gold); color: var(--ft-bg); }
.ft-share .done { margin: 0; padding: 0 14px 14px; text-align: center; font-size: .86rem; color: var(--ft-ink2); }
/* printing the chain: the lineage in words and its cards, nothing else */
@media print {
  html.ft-chain-open body > :not(.ft-chain) { display: none !important; }
  html.ft-chain-open .ft-chain { position: static; overflow: visible; }
  html.ft-chain-open .ft-chain .ch { position: static; } html.ft-chain-open .ft-chain .ch button { display: none; }
  html.ft-chain-open .ft-chain .card { opacity: 1; transform: none; break-inside: avoid; } html.ft-chain-open .ft-chain .ln { transform: scaleY(1); }
}
