/* شجرة الأسرة — عرض «الشخص في المركز». جوال أولاً. */
.saif-gt { --g-ink: var(--wp--preset--color--ink, #2B2724); --g-charcoal: var(--wp--preset--color--charcoal, #46403C); --g-clay: var(--wp--preset--color--clay, #6E635B); --g-line: #E8DECF; --g-henna: var(--wp--preset--color--henna, #A35139); --g-amber: #FFB162; --g-sand: #E6D5BC; color: var(--g-ink); position: relative; }
.saif-gt * { box-sizing: border-box; }
.saif-gt [hidden] { display: none !important; }
html.saif-lock, html.saif-lock body { overflow: hidden; }

/* ───── شرائح فروع الأسرة ───── */
.saif-branches-wrap { margin: 0 0 14px; }
.saif-branches-title { font-size: 1.1rem; font-weight: 600; color: var(--wp--preset--color--charcoal, #46403C); margin: 0 0 10px; }
.saif-branches { display: flex; gap: 10px; overflow-x: auto; padding: 2px 2px 10px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.saif-branches::-webkit-scrollbar { display: none; }
.saif-branch { flex: 0 0 150px; scroll-snap-align: start; display: flex; flex-direction: column; gap: 2px; padding: 14px; border-radius: 10px; color: #fff !important; text-decoration: none; min-height: 118px; position: relative; overflow: hidden; box-shadow: 0 2px 10px rgba(43, 39, 36, .1); }
.saif-branch::after { content: ""; position: absolute; inset-inline-end: -14px; bottom: -14px; width: 64px; height: 64px; background: rgba(255, 255, 255, .13); transform: rotate(45deg); border-radius: 6px; }
.saif-branch small { opacity: .85; font-size: .72rem; }
.saif-branch b { font-size: 1.05rem; font-weight: 600; line-height: 1.4; }
.saif-branch span { margin-top: auto; font-size: .82rem; opacity: .92; }
@media (min-width: 900px) { .saif-branch { flex-basis: 190px; } }

/* ───── البحث والأزرار السريعة ───── */
.gt-note { margin: 0 0 10px; padding: 10px 14px; background: #F4EADB; border-radius: 10px; color: var(--g-charcoal); font-size: .88rem; }
.gt-empty { padding: 24px; text-align: center; color: var(--g-clay); border: 1px dashed #C7A589; border-radius: 12px; background: #fff; }
.ft-bar { position: relative; z-index: 7; margin-bottom: 10px; }
.ft-search { position: relative; }
.ft-q { width: 100%; height: 48px; border: 1px solid var(--g-line); border-radius: 12px; padding: 0 14px; font: 500 16px inherit; font-family: inherit; background: #fff; color: var(--g-ink); box-shadow: 0 2px 10px rgba(43, 39, 36, .06); outline: 0; -webkit-appearance: none; appearance: none; }
.ft-q:focus { border-color: var(--g-amber); box-shadow: 0 0 0 3px rgba(255, 177, 98, .35); }
.ft-results { position: absolute; inset-inline: 0; top: 52px; z-index: 8; background: #fff; border: 1px solid var(--g-line); border-radius: 12px; box-shadow: 0 10px 26px rgba(43, 39, 36, .16); max-height: 280px; overflow: auto; display: none; }
.ft-results button { display: block; width: 100%; text-align: start; border: 0; background: none; padding: 11px 14px; font: 500 15px inherit; font-family: inherit; cursor: pointer; border-bottom: 1px solid #F1E9DA; color: var(--g-ink); }
.ft-results button small { display: block; color: var(--g-clay); font-weight: 400; font-size: .8rem; }
.ft-none { margin: 0; padding: 12px 14px; color: var(--g-clay); font-size: .9rem; }
.ft-quick { display: flex; gap: 8px; margin-top: 8px; overflow-x: auto; scrollbar-width: none; }
.ft-quick::-webkit-scrollbar { display: none; }
.ft-pill { flex: none; display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border: 1px solid var(--g-line); border-radius: 999px; background: #fff; color: var(--g-charcoal); font: 600 13px inherit; font-family: inherit; cursor: pointer; }
.ft-pill svg { width: 16px; height: 16px; }
.ft-pill--on { background: var(--g-ink); color: var(--g-amber); border-color: var(--g-ink); }

/* ───── المسرح ───── */
.ft-stage { background: linear-gradient(180deg, #FBF7EE, #F3EDE3); border: 1px solid var(--g-line); border-radius: 16px; padding: 14px 10px 18px; min-height: 480px; overflow: hidden; touch-action: pan-y; }
.saif-gt:not(.is-ready) .ft-stage::before { content: ""; display: block; height: 380px; border-radius: 12px; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .7), transparent) 0 0 / 200% 100%, #EFE6D3; animation: ft-shimmer 1.4s linear infinite; }
@keyframes ft-shimmer { to { background-position: -200% 0, 0 0; } }

.ft-av { --s: 56px; width: var(--s); height: var(--s); border-radius: 50%; background: #E6D5BC; color: #B49B72; display: grid; place-items: center; overflow: hidden; flex: none; }
.ft-av svg { width: 70%; height: 70%; fill: currentColor; }
.ft-av img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ft-av--s { --s: 30px; }
.ft-av--m { --s: 50px; }
.ft-av--l { --s: 78px; border: 4px solid var(--g-amber); box-shadow: 0 4px 12px rgba(255, 177, 98, .35); }

/* الأجداد */
.ft-anc { display: flex; flex-direction: column; align-items: center; }
.ft-gp { border: 0; background: none; color: var(--g-clay); font: 500 12px inherit; font-family: inherit; cursor: pointer; opacity: .75; padding: 2px 8px; }
.ft-par { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 6px; border: 1px solid var(--g-line); border-radius: 999px; background: #fff; color: var(--g-ink); font: 600 13px inherit; font-family: inherit; cursor: pointer; max-width: 100%; }
.ft-par svg { width: 14px; height: 14px; color: #9A7456; flex: none; }
.ft-line { display: block; width: 2px; height: 12px; background: #C7A589; }
.ft-top { font-size: .8rem; color: #9A7456; font-weight: 600; padding: 4px 0 8px; }

/* الصف الأوسط: أخ أكبر · البطاقة · أخ أصغر */
.ft-row { display: grid; grid-template-columns: 58px minmax(0, 1fr) 58px; gap: 4px; align-items: center; max-width: 520px; margin: 0 auto; }
.ft-row--solo { grid-template-columns: minmax(0, 1fr); max-width: 340px; }
.ft-peek { display: flex; flex-direction: column; align-items: center; gap: 3px; border: 0; background: none; padding: 4px 0; cursor: pointer; color: var(--g-clay); font: 500 11px inherit; font-family: inherit; opacity: .8; min-width: 0; }
.ft-peek span { max-width: 62px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ft-peek .ft-av { --s: 46px; }
.ft-peek--none { opacity: 0; pointer-events: none; }
.ft-card { background: #fff; border: 1px solid var(--g-line); border-radius: 18px; padding: 14px 14px 16px; text-align: center; box-shadow: 0 8px 22px rgba(43, 39, 36, .09); }
.ft-gen { display: inline-block; font-size: .7rem; font-weight: 700; background: var(--g-amber); color: var(--g-ink); border-radius: 999px; padding: 2px 10px; }
.ft-card .ft-av { margin: 10px auto 8px; }
.ft-name { margin: 0; font-size: 1.12rem; font-weight: 700; line-height: 1.5; color: var(--g-ink); }
.ft-died { display: block; font-size: .75rem; color: var(--g-clay); }
.ft-branch { margin: 2px 0 8px; font-size: .78rem; color: var(--g-clay); }
.ft-stats { display: flex; border-block: 1px solid #EFE6D6; margin-bottom: 10px; }
.ft-stats div { flex: 1; padding: 7px 2px; }
.ft-stats b { display: block; font-size: 1.15rem; font-weight: 700; line-height: 1.2; }
.ft-stats span { font-size: .7rem; color: var(--g-clay); }
.ft-nokids { margin: 0 0 10px; font-size: .8rem; color: var(--g-clay); padding: 8px 0; border-block: 1px solid #EFE6D6; }
.ft-act { display: flex; flex-wrap: wrap; gap: 6px; }
.ft-btn { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; border-radius: 10px; border: 1px solid var(--g-line); background: #F3EDE3; color: var(--g-charcoal); font: 600 12.5px inherit; font-family: inherit; cursor: pointer; text-decoration: none; padding: 0 8px; }
.ft-btn svg { width: 16px; height: 16px; flex: none; }
.ft-btn--main { background: var(--g-ink); color: var(--g-amber); border-color: var(--g-ink); flex: 1 1 100%; }
.ft-btn--icon { flex: 0 0 44px; padding: 0; }
.ft-btn:not(.ft-btn--main):not(.ft-btn--icon) { flex: 1 1 0; }
.ft-swipe { text-align: center; margin: 6px 0 0; font-size: .72rem; color: #9A7456; }

/* الأبناء */
.ft-kids { margin-top: 8px; }
.ft-kids__link { display: block; width: 2px; height: 14px; background: #C7A589; margin: 0 auto 6px; }
.ft-kids__h { display: flex; justify-content: space-between; align-items: center; padding: 0 6px 6px; }
.ft-kids__h b { font-size: .95rem; }
.ft-kids__h button { border: 0; background: none; color: var(--g-henna); font: 700 .82rem inherit; font-family: inherit; cursor: pointer; padding: 6px 4px; }
.ft-kidrow { display: flex; gap: 10px; overflow-x: auto; padding: 2px 6px 8px; scroll-snap-type: x proximity; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.ft-kidrow::-webkit-scrollbar { display: none; }
.ft-chip { flex: 0 0 66px; scroll-snap-align: start; display: flex; flex-direction: column; align-items: center; gap: 2px; border: 0; background: none; padding: 4px 0; cursor: pointer; color: var(--g-ink); font-family: inherit; }
.ft-chip b { font-size: .8rem; font-weight: 600; max-width: 66px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ft-chip small { font-size: .68rem; color: var(--g-clay); }
.ft-chip:active .ft-av { transform: scale(.94); }

/* حركة الانتقال */
.ft-stage[data-anim="down"] .ft-row, .ft-stage[data-anim="down"] .ft-kids { animation: ft-down .32s ease both; }
.ft-stage[data-anim="up"] .ft-row, .ft-stage[data-anim="up"] .ft-kids { animation: ft-up .32s ease both; }
.ft-stage[data-anim="older"] .ft-row { animation: ft-older .3s ease both; }
.ft-stage[data-anim="younger"] .ft-row { animation: ft-younger .3s ease both; }
@keyframes ft-down { from { opacity: 0; transform: translateY(26px); } }
@keyframes ft-up { from { opacity: 0; transform: translateY(-26px); } }
@keyframes ft-older { from { opacity: 0; transform: translateX(34px); } }
@keyframes ft-younger { from { opacity: 0; transform: translateX(-34px); } }

/* ───── الأوراق السفلية ───── */
.ft-layer { position: fixed; inset: 0; z-index: 1100; display: block; }
.ft-layer[hidden] { display: none; }
.ft-layer__scrim { position: absolute; inset: 0; background: rgba(43, 39, 36, .5); opacity: 0; transition: opacity .2s; }
.ft-layer__box { position: absolute; inset: auto 0 0 0; max-height: 88dvh; overflow: auto; background: #F3EDE3; border-radius: 18px 18px 0 0; padding: 10px 14px calc(18px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .24s ease; max-width: 640px; margin: 0 auto; }
.ft-layer.is-open .ft-layer__scrim { opacity: 1; }
.ft-layer.is-open .ft-layer__box { transform: none; }
.ft-grip { display: block; width: 40px; height: 4px; border-radius: 2px; background: #D9C9AE; margin: 2px auto 10px; }
.ft-layer__h { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.ft-layer__h b { font-size: 1.02rem; }
.ft-x { width: 38px; height: 38px; border: 0; border-radius: 10px; background: #fff; font-size: 22px; line-height: 1; cursor: pointer; color: var(--g-charcoal); }
.ft-sorts { display: flex; gap: 6px; margin-bottom: 12px; overflow-x: auto; scrollbar-width: none; }
.ft-sorts button { flex: none; height: 34px; padding: 0 13px; border: 1px solid var(--g-line); border-radius: 999px; background: #fff; font: 600 12px inherit; font-family: inherit; color: var(--g-charcoal); cursor: pointer; }
.ft-sorts button[aria-pressed="true"] { background: var(--g-ink); color: var(--g-amber); border-color: var(--g-ink); }
.ft-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 6px; }
.ft-grid .ft-chip { flex: none; }
.ft-grid .ft-chip b { max-width: 100%; }

/* القرابة */
.ft-pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: stretch; }
.ft-pick { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 6px; border: 1px solid var(--g-line); border-radius: 14px; background: #fff; cursor: pointer; font: 600 .85rem inherit; font-family: inherit; color: var(--g-ink); min-height: 112px; justify-content: center; text-align: center; }
.ft-pick--on { border-color: var(--g-amber); box-shadow: 0 0 0 3px rgba(255, 177, 98, .35); }
.ft-pick small { color: var(--g-clay); font-weight: 400; font-size: .7rem; }
.ft-pair__x { align-self: center; color: var(--g-henna); }
.ft-pair__x svg { width: 24px; height: 24px; }
.ft-rel__search { margin-top: 10px; position: relative; }
.ft-rel__list { margin-top: 6px; background: #fff; border: 1px solid var(--g-line); border-radius: 12px; max-height: 220px; overflow: auto; }
.ft-rel__list button { display: block; width: 100%; text-align: start; border: 0; background: none; padding: 10px 14px; font: 500 15px inherit; font-family: inherit; cursor: pointer; border-bottom: 1px solid #F1E9DA; color: var(--g-ink); }
.ft-rel__list button small { display: block; color: var(--g-clay); font-size: .78rem; font-weight: 400; }
.ft-result { margin-top: 14px; background: var(--g-ink); color: #fff; border-radius: 16px; padding: 14px; text-align: center; }
.ft-result small { display: block; color: #C7A589; font-size: .72rem; }
.ft-result strong { display: block; font-size: 1.45rem; color: var(--g-amber); margin: 2px 0; line-height: 1.4; }
.ft-result span { color: #E6D9C8; font-size: .82rem; }
.ft-path { list-style: none; margin: 14px 0 0; padding: 0 6px; position: relative; }
.ft-path::before { content: ""; position: absolute; inset-inline-start: 25px; top: 14px; bottom: 14px; width: 2px; background: #C7A589; }
.ft-path li { position: relative; display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: .85rem; color: var(--g-clay); }
.ft-path li .ft-av { --s: 38px; position: relative; }
.ft-path li.is-end { color: var(--g-ink); font-weight: 600; }
.ft-path li.is-end .ft-av { background: var(--g-amber); color: var(--g-ink); }
.ft-path li.is-top { color: var(--g-ink); font-weight: 700; }
.ft-path li.is-top .ft-av { background: var(--g-henna); color: #fff; }
.ft-toast { position: fixed; z-index: 1300; inset-inline: 16px; bottom: calc(86px + env(safe-area-inset-bottom)); margin: 0 auto; width: max-content; max-width: calc(100% - 32px); background: var(--g-ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: .85rem; opacity: 0; pointer-events: none; transition: opacity .2s; }
.ft-toast.on { opacity: 1; }

@media (min-width: 700px) {
	.ft-stage { padding: 22px 18px 26px; }
	.ft-row { grid-template-columns: 90px minmax(0, 1fr) 90px; }
	.ft-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
	.ft-layer__box { border-radius: 18px; inset: auto 0 24px 0; }
}
@media (prefers-reduced-motion: reduce) {
	.ft-stage[data-anim] .ft-row, .ft-stage[data-anim] .ft-kids { animation: none !important; }
	.ft-layer__box, .ft-layer__scrim, .ft-toast { transition: none; }
	.saif-gt:not(.is-ready) .ft-stage::before { animation: none; }
}

/* ───── طبقات الأجيال المتراكمة ───── */
.ft-lv { scroll-margin-bottom: 170px; scroll-margin-top: 90px; }
.ft-lv__h { display: flex; justify-content: space-between; align-items: center; padding: 0 6px 6px; }
.ft-lv__h button { border: 0; background: none; color: var(--g-henna); font: 700 .82rem inherit; font-family: inherit; cursor: pointer; padding: 6px 4px; }
.ft-lv .ft-kidrow { position: relative; }
.ft-conn { display: block; width: 2px; height: 16px; background: #C7A589; margin: 4px auto 8px; }
.ft-chip { position: relative; }
.ft-chip .ft-av { border: 3px solid transparent; transition: border-color .15s, box-shadow .15s, opacity .15s; }
.ft-chip--dim .ft-av, .ft-chip--dim b, .ft-chip--dim small { opacity: .55; }
.ft-chip--sel .ft-av { border-color: var(--g-amber); box-shadow: 0 3px 10px rgba(255, 177, 98, .45); }
.ft-chip--sel b { font-weight: 800; }
.ft-chip--sel::after { content: ""; position: absolute; bottom: -10px; left: 50%; width: 8px; height: 8px; margin-left: -4px; background: var(--g-amber); border-radius: 50%; }
.ft-leaf { text-align: center; margin: 14px 0 0; font-size: .85rem; color: var(--g-clay); }
.ft-stage[data-anim="down"] .ft-lv--last { animation: ft-down .32s ease both; }
@media (prefers-reduced-motion: reduce) { .ft-stage[data-anim] .ft-lv--last { animation: none !important; } }

/* الشريط الثابت بأسفل الشاشة */
.ft-dock { position: sticky; bottom: 14px; z-index: 40; margin-top: 10px; display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #fff; border: 1px solid var(--g-line); border-radius: 16px; box-shadow: 0 -2px 18px rgba(43, 39, 36, .16); }
@media (max-width: 899px) { .ft-dock { bottom: calc(80px + env(safe-area-inset-bottom)); } }
.ft-dock__t { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 0; text-align: start; cursor: pointer; font-family: inherit; color: var(--g-ink); }
.ft-dock__t span { min-width: 0; display: block; }
.ft-dock__t b { display: block; font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ft-dock__t small { display: block; font-size: .72rem; color: var(--g-clay); }
.ft-btn--sm { flex: none; height: 38px; padding: 0 13px; font-size: 12px; }
.ft-btn--sm.ft-btn--icon { flex: 0 0 40px; padding: 0; }
.ft-dock__t small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ft-btn--sm.ft-btn--main { flex: none; }
.ft-par--card { width: 100%; justify-content: flex-start; margin-bottom: 10px; }
.ft-info .ft-card { box-shadow: none; }

/* توسيط الأجيال */
.ft-lv__h { position: relative; justify-content: center; }
.ft-lv__h button { position: absolute; inset-inline-end: 6px; top: 0; }
.ft-kidrow { justify-content: safe center; }

/* الأجيال: تلتف في أسطر بدل السحب الجانبي */
.ft-lv .ft-kidrow { flex-wrap: wrap; overflow: visible; justify-content: center; gap: 12px 10px; padding: 2px 4px 10px; scroll-snap-type: none; }
.ft-lv .ft-chip { flex: 0 0 72px; }
.ft-lv .ft-chip b { max-width: 72px; }

/* ───── عرض كل الشجرة ───── */
.ft-pill--map { background: var(--g-ink); color: var(--g-amber); border-color: var(--g-ink); }
.ft-pill--map.ft-pill--on { background: var(--g-amber); color: var(--g-ink); border-color: var(--g-amber); }
.ft-zoombar { position: sticky; top: calc(var(--saif-hh, 66px) + 6px); z-index: 45; display: flex; align-items: center; justify-content: center; gap: 8px; margin: 0 auto 8px; width: max-content; max-width: 100%; padding: 5px 8px; background: rgba(255, 255, 255, .96); border: 1px solid var(--g-line); border-radius: 999px; box-shadow: 0 4px 16px rgba(43, 39, 36, .14); }
.ft-zoombar button { height: 36px; min-width: 36px; padding: 0 10px; border: 1px solid var(--g-line); border-radius: 999px; background: #F3EDE3; color: var(--g-ink); font: 700 18px/1 inherit; font-family: inherit; cursor: pointer; }
.ft-zoombar .ft-zfit { font-size: 12px; padding: 0 14px; }
.ft-zoombar span { min-width: 44px; text-align: center; font-size: .8rem; font-weight: 700; color: var(--g-clay); }
.is-fullview .ft-stage { touch-action: pan-y; }
.is-fullview .ft-lv .ft-kidrow { gap: calc(12px * var(--z, 1)) calc(10px * var(--z, 1)); padding: 2px 2px 8px; }
.is-fullview .ft-lv .ft-chip { flex: 0 0 calc(72px * var(--z, 1)); gap: calc(2px * var(--z, 1)); padding: 2px 0; }
.is-fullview .ft-lv .ft-chip .ft-av { --s: calc(50px * var(--z, 1)); border: max(2px, calc(3px * var(--z, 1))) solid var(--rc, transparent); }
.is-fullview .ft-lv .ft-chip b { font-size: calc(.8rem * var(--z, 1)); max-width: calc(72px * var(--z, 1)); }
.is-fullview .ft-lv .ft-chip small { font-size: calc(.68rem * var(--z, 1)); }
.is-fullview.ft-zs .ft-lv .ft-chip b, .is-fullview.ft-zs .ft-lv .ft-chip small { display: none; }
.is-fullview .ft-lv .ft-chip--sel .ft-av { border-color: var(--g-amber); box-shadow: 0 0 0 3px rgba(255, 177, 98, .5); }
.is-fullview .ft-lv .ft-chip--sel::after { display: none; }
.is-fullview .ft-conn { height: 10px; margin: 2px auto 4px; }
.is-fullview .ft-lv { scroll-margin-top: 130px; }

@media (min-width: 900px) {
	.ft-dock { max-width: 640px; margin-inline: auto; }
	.ft-bar { max-width: 760px; }
	.ft-lv .ft-kidrow { max-width: 1000px; margin-inline: auto; }
}
