/* =====================================================================
   Tokens — warm limestone + Sidi Bou Said blue
   ===================================================================== */
:root {
  --bg: #f5f1ea;
  --bg-2: #ede7dc;
  --surface: #fffdf9;
  --ink: #17202d;
  --ink-2: #444d5c;
  --muted: #7b7f88;
  --line: #e4ddd1;
  --line-2: #cfc6b6;
  --accent: #1f5aa6;
  --accent-ink: #ffffff;
  --accent-soft: #e2ebf7;
  --wed: #c2452d;
  --wed-soft: #f7e3dc;
  --sel-ink: #ffffff;


  --serif: "Newsreader", "Iowan Old Style", Georgia, serif;
  --sans: "Instrument Sans", "Segoe UI", system-ui, sans-serif;
  --arabic: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, sans-serif;
  --bar-h: 60px;
  --tab-h: 0px;
  --r: 8px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e131b; --bg-2: #141b26; --surface: #172030;
    --ink: #e9edf3; --ink-2: #b7c0ce; --muted: #7e889a;
    --line: #233044; --line-2: #34435b;
    --accent: #7eaaf0; --accent-ink: #0e131b; --accent-soft: #1b2b45;
    --wed: #f08068; --wed-soft: #3a2320; --sel-ink: #0e131b;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0e131b; --bg-2: #141b26; --surface: #172030;
  --ink: #e9edf3; --ink-2: #b7c0ce; --muted: #7e889a;
  --line: #233044; --line-2: #34435b;
  --accent: #7eaaf0; --accent-ink: #0e131b; --accent-soft: #1b2b45;
  --wed: #f08068; --wed-soft: #3a2320; --sel-ink: #0e131b;
  color-scheme: dark;
}
:root { --c: var(--accent); }

/* =====================================================================
   Base
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; overflow: hidden;
  display: grid; grid-template-rows: auto 1fr auto;
  height: 100dvh;
  background: var(--bg); color: var(--ink);
  font: 400 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
}
:lang(ar) body { font-family: var(--arabic); }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
svg { display: block; }
.ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.soft { color: var(--muted); }
.label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
:lang(ar) .label { letter-spacing: 0; font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--r);
  background: var(--ink); color: var(--bg); border: 1px solid var(--ink);
  font-size: 14px; font-weight: 500; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn--ghost:hover { background: var(--surface); color: var(--accent); border-color: var(--accent); }


/* =====================================================================
   Header
   ===================================================================== */
.bar {
  position: relative; z-index: 30;
  display: flex; align-items: center; gap: 20px;
  height: calc(var(--bar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.mark { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: none; }
.mark__lat { font: 500 23px/1 var(--serif); letter-spacing: -0.01em; }
.mark__ar { font: 700 22px/1 "Amiri", serif; color: var(--accent); }

.views { display: flex; gap: 2px; height: 100%; }
.views a {
  position: relative; display: flex; align-items: center; padding: 0 12px;
  text-decoration: none; font-weight: 500; color: var(--muted);
}
.views a:hover { color: var(--ink); }
.views a[aria-current="true"] { color: var(--ink); }
.views a[aria-current="true"]::after {
  content: ""; position: absolute; inset-inline: 12px; bottom: -1px; height: 2px; background: var(--accent);
}

.search { position: relative; flex: 1; max-width: 360px; margin-inline-start: auto; }
.search > svg { position: absolute; inset-inline-start: 11px; top: 50%; translate: 0 -50%; width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 1.6; stroke-linecap: round; pointer-events: none; }
.search input {
  width: 100%; height: 38px; padding-inline: 34px 12px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r);
  font-size: 15px; -webkit-appearance: none; appearance: none;
}
.search input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input::placeholder { color: var(--muted); }
.search input::-webkit-search-cancel-button { display: none; }

.results {
  position: absolute; inset-inline: 0; top: calc(100% + 6px); z-index: 40;
  margin: 0; padding: 4px; list-style: none;
  max-height: min(60vh, 420px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px;
  box-shadow: 0 16px 40px -18px rgba(15, 20, 30, .35);
}
.results li {
  display: grid; grid-template-columns: 1fr auto; column-gap: 10px; align-items: center;
  padding: 7px 10px; border-radius: 6px; cursor: pointer;
}
.results li[aria-selected="true"], .results li:hover { background: var(--bg-2); }
.r__name { font: 500 16px/1.25 var(--serif); }
.r__chain { grid-column: 1; font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r__gen { grid-column: 2; grid-row: 1 / 3; font-size: 12px; color: var(--muted); }
.r__none { color: var(--muted); cursor: default !important; display: block !important; }

.ctl {
  height: 38px; flex: none; border: 1px solid var(--line-2); border-radius: var(--r);
  background: var(--surface); cursor: pointer;
}
.ctl:hover { border-color: var(--ink-2); }
.lang {
  padding-inline: 10px 26px; font-size: 14px; font-weight: 500;
  -webkit-appearance: none; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(-45deg, transparent 50%, var(--muted) 50%);
  background-size: 4px 4px; background-repeat: no-repeat;
  background-position: calc(100% - 14px) 17px, calc(100% - 10px) 17px;
}
[dir="rtl"] .lang { padding-inline: 10px 26px; background-position: 10px 17px, 14px 17px; }
.lang option { background: var(--surface); color: var(--ink); }
.theme { width: 38px; display: grid; place-items: center; }
.theme svg { width: 18px; height: 18px; fill: none; stroke: var(--ink); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
[data-theme="dark"] .theme__moon, [data-theme="light"] .theme__sun { display: none; }

/* =====================================================================
   Main + views
   ===================================================================== */
.main { position: relative; min-height: 0; overflow: hidden; }
.view { position: absolute; inset: 0; }
.view--fiche, .view--liste { overflow-y: auto; overscroll-behavior: contain; }

/* ---------- Graph ---------- */
.view--arbre {
  overflow: hidden; touch-action: none; cursor: grab; outline: none;
  user-select: none; -webkit-user-select: none;
  background-color: var(--bg);
  background-image: radial-gradient(var(--line) 1px, transparent 1.2px);
  background-size: 22px 22px;
}
.view--arbre.is-dragging { cursor: grabbing; }
.world { position: absolute; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
.world--anim { transition: transform .45s cubic-bezier(.3, .7, .2, 1); }

.links { position: absolute; inset: 0; overflow: visible; pointer-events: none; }
.links path { fill: none; stroke: var(--line-2); stroke-width: 1.5; }
.links--path path { stroke: var(--ink); stroke-width: 2.6; }
.links--union path { stroke: var(--wed); stroke-width: 1.8; stroke-dasharray: 6 5; }

.node {
  position: absolute; margin: 0; padding: 0 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--surface);
  border: 1px solid color-mix(in srgb, var(--c) 45%, var(--line));
  border-top: 3px solid var(--c);
  border-radius: 6px;
  cursor: pointer; white-space: nowrap; line-height: 1.15;
  transition: background .12s, transform .12s;
}
.node:hover { background: color-mix(in srgb, var(--c) 9%, var(--surface)); }
.node__name { font: 500 16.5px/1.15 var(--serif); }
.node__name i, .stack__item i { font-style: italic; font-weight: 400; color: var(--muted); font-size: .85em; }
.node__wed { font: italic 400 13px/1.2 var(--serif); color: var(--wed); margin-top: 2px; }
.node--root {
  background: var(--ink); color: var(--bg); border: 0; border-radius: 6px;
}
.node--root .node__name { font-weight: 500; font-size: 17px; letter-spacing: .01em; }
.node--root:hover { background: var(--accent); color: var(--accent-ink); }

.stack {
  position: absolute; padding: 10px 0;
  display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--c) 6%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c) 30%, var(--line));
  border-inline-start: 3px solid var(--c);
  border-radius: 6px;
}
.stack__item {
  height: 22px; margin: 0; padding: 0 8px; border: 0; background: none; border-radius: 3px;
  font: 400 15.5px/22px var(--serif); cursor: pointer; white-space: nowrap;
}
.stack__item:hover { background: color-mix(in srgb, var(--c) 14%, transparent); }
.stack__wed { font-size: 12.5px; color: var(--wed); }

.is-path.node { box-shadow: 0 0 0 2px var(--ink); }
.is-sel.node, .is-sel.stack__item { background: var(--c); color: var(--sel-ink); border-color: var(--c); }
.is-sel.node { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 30%, transparent); }
.is-sel .node__wed, .is-sel .stack__wed, .is-sel i { color: inherit !important; opacity: .85; }
.is-wed.node, .is-wed.stack__item { outline: 2px dashed var(--wed); outline-offset: 3px; }
.is-wed.stack__item { outline-offset: -1px; }

.gens { position: absolute; top: 0; bottom: 0; left: 0; width: 40px; pointer-events: none; transition: opacity .2s; }
.gens::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, var(--bg) 50%, transparent); }
.gens span {
  position: absolute; left: 0; top: -10px; width: 32px; text-align: center;
  font: 500 13px/20px var(--serif); color: var(--muted);
}
.gens--off { opacity: 0; }

.hint {
  position: absolute; left: 50%; bottom: 24px; translate: -50% 0; margin: 0;
  max-width: calc(100% - 32px); padding: 8px 14px; border-radius: 8px;
  background: var(--ink); color: var(--bg); font-size: 13.5px; text-align: center;
  pointer-events: none; transition: opacity .4s;
}
.hint--off { opacity: 0; }

.tools {
  position: absolute; right: 16px; bottom: 16px;
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px;
}
.tools button { width: 40px; height: 40px; display: grid; place-items: center; background: none; border: 0; cursor: pointer; color: var(--ink); }
.tools button + button { border-top: 1px solid var(--line); }
.tools button:hover { background: var(--bg-2); color: var(--accent); }
.tools svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.map {
  position: absolute; left: 16px; bottom: 16px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: 8px;
  cursor: crosshair; touch-action: none;
}

/* ---------- Detail sheet ---------- */
.sheet {
  position: absolute; z-index: 20; top: 0; bottom: 0; inset-inline-end: 0;
  width: min(400px, 100%);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-inline-start: 1px solid var(--line);
  box-shadow: -18px 0 40px -30px rgba(15, 20, 30, .4);
  animation: slide-in .26s cubic-bezier(.3, .7, .2, 1);
}
[dir="rtl"] .sheet { box-shadow: 18px 0 40px -30px rgba(15, 20, 30, .4); }
@keyframes slide-in { from { transform: translateX(20px); opacity: 0; } }
[dir="rtl"] .sheet { animation-name: slide-in-rtl; }
@keyframes slide-in-rtl { from { transform: translateX(-20px); opacity: 0; } }
.sheet__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 0 24px; }
[dir="rtl"] .sheet__head { padding: 14px 24px 0 16px; }
.sheet__gen { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 14px; font-size: 13px; font-weight: 500; color: var(--muted); }
.sheet__close { width: 34px; height: 34px; display: grid; place-items: center; background: none; border: 0; border-radius: 8px; cursor: pointer; color: var(--ink-2); }
.sheet__close:hover { background: var(--bg-2); }
.sheet__close svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; }
.sheet__body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 4px 24px 32px; }
.sheet__name { margin: 0; font: 500 40px/1.05 var(--serif); letter-spacing: -0.015em; overflow-wrap: anywhere; text-align: start; }
.sheet__note { margin: 2px 0 0; font: italic 400 18px var(--serif); color: var(--ink-2); }
.sheet__lead { margin: 8px 0 0; color: var(--ink-2); }
.sheet__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

.reg { margin: 20px 0 0; }
.reg__row { display: grid; grid-template-columns: 108px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.reg dt { font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding-top: 3px; }
:lang(ar) .reg dt { letter-spacing: 0; font-size: 13px; }
.reg dd { margin: 0; min-width: 0; font: 400 16.5px/1.5 var(--serif); }
.reg a, .hero a:not(.btn), .lineage a { text-decoration: underline; text-decoration-color: var(--line-2); text-underline-offset: 3px; }
.reg a:hover, .hero a:not(.btn):hover, .lineage a:hover { color: var(--accent); text-decoration-color: currentColor; }
a.wed { color: var(--wed); }
.big { font-size: 26px; line-height: 1; }
.kids { margin: 0; padding: 0; list-style: none; columns: 2; column-gap: 18px; }
.kids li { display: flex; justify-content: space-between; gap: 8px; break-inside: avoid; }
.kids .num { color: var(--muted); font: 400 13px var(--sans); padding-top: 3px; }
.kids__with { margin: 0 0 2px; font: italic 14px var(--serif); }
.kids + .kids__with { margin-top: 10px; }
.lineage { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.lineage .label { margin: 0 0 6px; }
.lineage ol { margin: 0; padding: 0; list-style: none; text-align: left; font: 400 15.5px/1.6 var(--serif); }
.lineage li { display: inline; }
.lineage li + li::before { content: " › "; color: var(--muted); }
.lineage a { color: var(--ink-2); text-decoration: none; }
.lineage span { font-weight: 600; }

/* ---------- Profile (Fiche) ---------- */
.fiche { max-width: 980px; margin: 0 auto; padding: 18px 24px 64px; }
.crumbs ol {
  display: flex; align-items: center; gap: 6px; margin: 0 0 22px; padding: 0; list-style: none;
  overflow-x: auto; scrollbar-width: none; white-space: nowrap; font-size: 13.5px; color: var(--muted);
}
.crumbs ol::-webkit-scrollbar { display: none; }
.crumbs li + li::before { content: "/"; margin-inline-end: 6px; color: var(--line-2); }
.crumbs a { text-decoration: none; }
.crumbs a:hover { color: var(--accent); }
.crumbs [aria-current] { color: var(--ink); font-weight: 500; }

.hero {
  position: relative; display: grid; grid-template-columns: 1fr auto; gap: 24px 40px; align-items: end;
  padding: 28px 32px 28px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line);
  overflow: hidden;
}
.hero::before { content: ""; position: absolute; inset-block: 0; inset-inline-start: 0; width: 5px; background: var(--c); }
.hero__kicker { margin: 0 0 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; font-size: 13px; font-weight: 500; color: var(--muted); }
.hero__name { margin: 0; font: 500 clamp(44px, 7vw, 72px)/1 var(--serif); letter-spacing: -0.025em; overflow-wrap: anywhere; }
.hero__note { margin: 4px 0 0; font: italic 400 21px var(--serif); color: var(--ink-2); }
.hero__line { margin: 12px 0 0; font: 400 18px/1.45 var(--serif); }
.hero__line .label { margin-inline-end: 4px; font-family: var(--sans); }
.hero__line + .hero__line { margin-top: 4px; }
.hero__btn { margin-top: 20px; }
.hero__stats { display: flex; margin: 0; }
.hero__stats div { padding: 0 22px; text-align: center; }
.hero__stats div + div { border-inline-start: 1px solid var(--line); }
.hero__stats dd { margin: 0; font: 400 40px/1 var(--serif); }
.hero__stats dt { margin-top: 6px; font-size: 12px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.hero__stats div { display: flex; flex-direction: column-reverse; }
:lang(ar) .hero__stats dt { letter-spacing: 0; font-size: 13px; }

.block { margin-top: 36px; }
.block__title { display: flex; align-items: baseline; gap: 10px; margin: 0 0 14px; font: 500 24px/1.2 var(--serif); }
.block__title span { font: 500 13px var(--sans); color: var(--muted); }
.block__sub { margin: -6px 0 12px; font: italic 16px var(--serif); }
.cards { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.cards--sm { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
.pcard {
  position: relative; display: flex; flex-direction: column; gap: 2px;
  padding: 14px 16px 13px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--line);
  text-decoration: none; overflow: hidden;
  transition: border-color .15s, transform .15s;
  animation: rise .35s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--i, 0) * 22ms);
}
.pcard::before { content: ""; position: absolute; inset-inline-start: 0; inset-block: 0; width: 3px; background: var(--c); }
.pcard:hover { border-color: var(--c); transform: translateY(-1px); }
.pcard__name { font: 500 20px/1.2 var(--serif); }
.pcard__name i { font-weight: 400; color: var(--muted); font-size: .8em; }
.pcard__wed { font: italic 14px var(--serif); color: var(--wed); }
.pcard__meta { margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.cards--sm .pcard { padding: 10px 14px; }
.cards--sm .pcard__name { font-size: 17px; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* ---------- List ---------- */
.liste { max-width: 900px; margin: 0 auto; padding: 18px 24px 64px; }
.liste__bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 20px; margin-bottom: 16px; }
.liste__actions { display: flex; gap: 8px; }
.liste__gens { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.liste__gens .label { margin-inline-end: 6px; }
.gbtn {
  min-width: 34px; height: 32px; padding: 0 6px; border-radius: 6px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line-2); font: 500 14px var(--serif);
}
.gbtn:hover { border-color: var(--accent); color: var(--accent); }

.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 8px 14px; }
.tree ul { margin-left: 15px; padding-left: 14px; border-left: 1.5px solid color-mix(in srgb, var(--c) 35%, var(--line)); }
.tn[aria-expanded="false"] > ul { display: none; }
.tn { position: relative; }
.tree ul > .tn::before { content: ""; position: absolute; left: -14px; top: 20px; width: 11px; height: 1.5px; background: color-mix(in srgb, var(--c) 35%, var(--line)); }
.tn__row { display: flex; align-items: center; gap: 6px; min-height: 40px; padding-right: 8px; border-radius: 8px; white-space: nowrap; }
.tn__tog, .tn__leaf { width: 28px; height: 28px; flex: none; display: grid; place-items: center; }
.tn__tog { border: 0; background: none; border-radius: 6px; cursor: pointer; color: var(--c); }
.tn__tog:hover { background: var(--bg-2); }
.tn__tog .ico { transition: rotate .18s; }
.tn[aria-expanded="true"] > .tn__row .tn__tog .ico { rotate: 90deg; }
.tn__leaf::after { content: ""; width: 6px; height: 6px; border-radius: 2px; background: var(--c); opacity: .7; }
.tn__name { padding: 4px 6px; border-radius: 6px; text-decoration: none; font: 500 17px/1.2 var(--serif); }
.tn__name i { font-weight: 400; color: var(--muted); font-size: .85em; }
.tn__name:hover { background: color-mix(in srgb, var(--c) 12%, transparent); }
.tn__wed { font: italic 14px var(--serif); color: var(--wed); }
.tn__count { font-size: 12px; color: var(--muted); padding: 2px 7px; border-radius: 99px; background: var(--bg-2); }
.tn--sel > .tn__row { background: color-mix(in srgb, var(--c) 14%, transparent); }
.tn--sel > .tn__row .tn__name { color: var(--c); }

@media (min-width: 761px) {
  .has-sheet .view--liste { padding-inline-end: 400px; }
}

/* ---------- Tab bar (phone) ---------- */
.tabbar { display: none; }

/* =====================================================================
   Phone
   ===================================================================== */
@media (max-width: 760px) {
  :root { --bar-h: 56px; }
  .bar { gap: 8px; padding-inline: 14px; }
  .views { display: none; }
  .mark__ar { display: none; }
  .mark__lat { font-size: 21px; }
  [lang="ar"] .mark__lat { display: none; }
  [lang="ar"] .mark__ar { display: inline; }
  .search { margin-inline-start: 4px; }
  .search input { font-size: 16px; }
  .lang { padding-inline: 8px 22px; background-position: calc(100% - 12px) 17px, calc(100% - 8px) 17px; }

  .tabbar {
    display: grid; grid-template-columns: repeat(3, 1fr);
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--surface); border-top: 1px solid var(--line);
  }
  .tabbar a {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    height: 58px; text-decoration: none; font-size: 12px; font-weight: 500; color: var(--muted);
  }
  .tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
  .tabbar a[aria-current="true"] { color: var(--accent); }

  .map { display: none; }
  .hint { bottom: 16px; font-size: 13px; }
  .has-sheet .tools { display: none; }

  .sheet {
    top: auto; inset-inline: 0; width: 100%; height: 60%;
    border-inline-start: 0; border-top: 1px solid var(--line); border-radius: 14px 14px 0 0;
    box-shadow: 0 -16px 40px -24px rgba(15, 20, 30, .45) !important;
    animation: slide-up .28s cubic-bezier(.3, .7, .2, 1) !important;
  }
  @keyframes slide-up { from { transform: translateY(28px); opacity: 0; } }
  .sheet__head { padding: 12px 10px 0 18px; }
  [dir="rtl"] .sheet__head { padding: 12px 18px 0 10px; }
  .sheet__body { padding: 2px 18px 24px; }
  .sheet__name { font-size: 34px; }
  .reg__row { grid-template-columns: 90px 1fr; }

  .fiche, .liste { padding: 14px 14px 40px; }
  .hero { grid-template-columns: 1fr; padding: 22px 20px 20px 24px; gap: 20px; }
  .hero__stats { border-top: 1px solid var(--line); padding-top: 16px; }
  .hero__stats div { flex: 1; padding: 0 8px; }
  .hero__stats dd { font-size: 32px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .cards--sm { grid-template-columns: 1fr 1fr; }
  .pcard { padding: 12px 12px 11px 14px; }
  .pcard__name { font-size: 18px; overflow-wrap: anywhere; }
  .liste__bar { flex-direction: column; align-items: stretch; }
  .tree { margin-inline: -14px; border-radius: 0; border-inline: 0; }
  .tree ul { margin-left: 13px; padding-left: 8px; }
  .tree ul > .tn::before { left: -8px; width: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Latin names keep LTR shaping but follow the page alignment in Arabic */
:root[dir="rtl"] .sheet__name, :root[dir="rtl"] .hero__name, :root[dir="rtl"] .hero__note, :root[dir="rtl"] .sheet__note { text-align: right; }

/* Arabic names: Amiri instead of the Latin serif, no fake italics */
:lang(ar) :is(.node__name, .node__wed, .stack__item, .stack__wed, .sheet__name, .sheet__note, .hero__name, .hero__note, .hero__line,
  .pcard__name, .pcard__wed, .tn__name, .tn__wed, .r__name, .reg dd, .lineage ol, .kids__with, .block__sub, .crumbs ol) {
  font-family: "Amiri", var(--serif); font-style: normal;
}
:lang(ar) :is(.node__name i, .stack__item i, .pcard__name i, .tn__name i) { font-style: normal; }
:lang(ar) .stack__item { line-height: 22px; font-size: 15px; }
:lang(ar) .sheet__name, :lang(ar) .hero__name { line-height: 1.3; letter-spacing: 0; }
:lang(ar) .node__name { font-size: 18.5px; }
:lang(ar) .node--root .node__name { font-size: 18px; }
:lang(ar) .tn__name, :lang(ar) .pcard__name { font-size: 1.12em; }

.load-error { margin: 15vh auto; max-width: 30ch; text-align: center; font: 400 20px/1.4 var(--serif); color: var(--ink-2); }
