:root {
  --bg: #f2f0ea;
  --surface: rgba(255,255,255,.92);
  --surface-solid: #fff;
  --surface-soft: #f8f7f3;
  --ink: #1d2924;
  --muted: #748078;
  --muted-2: #929a94;
  --line: #dfe3de;
  --line-strong: #cdd5cf;
  --accent: #356c55;
  --accent-strong: #245440;
  --accent-soft: #e9f2ed;
  --gold: #b79b63;
  --danger: #a94d4d;
  --shadow-sm: 0 1px 2px rgba(29,41,36,.05), 0 4px 12px rgba(29,41,36,.05);
  --shadow-md: 0 14px 40px rgba(29,41,36,.12), 0 3px 12px rgba(29,41,36,.07);
  --shadow-lg: 0 26px 70px rgba(25,34,30,.18);
  --radius: 18px;
  --topbar: 74px;
  --toolbar: 58px;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
body {
  overflow: hidden;
  color: var(--ink);
  background: var(--bg);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { color: inherit; }
svg { display: block; }

.app-shell { height: 100%; }
.topbar {
  height: var(--topbar);
  display: grid;
  grid-template-columns: minmax(210px, 1fr) minmax(320px, 600px) minmax(210px, 1fr);
  align-items: center;
  gap: 22px;
  padding: 0 22px;
  background: rgba(255,255,255,.88);
  border-bottom: 1px solid rgba(205,213,207,.8);
  backdrop-filter: blur(18px) saturate(1.2);
  position: relative;
  z-index: 80;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  width: fit-content;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: white;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  box-shadow: 0 7px 18px rgba(53,108,85,.2);
}
.brand-copy { display: grid; line-height: 1.05; }
.brand-copy strong { font-family: Georgia, "Times New Roman", serif; font-size: 19px; letter-spacing: .01em; }
.brand-copy small { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .12em; margin-top: 4px; }

.search-wrap {
  height: 44px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 11px;
  background: #f5f5f2;
  border: 1px solid #e1e4df;
  border-radius: 14px;
  position: relative;
  transition: .2s ease;
}
.search-wrap:focus-within { background: white; border-color: #b6cbbf; box-shadow: 0 0 0 4px rgba(53,108,85,.08); }
.search-wrap > svg { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.search-wrap input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 14px; }
.search-wrap input::placeholder { color: #98a099; }
kbd { border: 1px solid #d8ddd8; border-bottom-width: 2px; border-radius: 6px; background: white; padding: 2px 7px; font-size: 11px; color: var(--muted); }
.search-results {
  position: absolute;
  top: 52px;
  left: 0;
  right: 0;
  max-height: min(480px, 65vh);
  overflow: auto;
  padding: 7px;
  background: rgba(255,255,255,.98);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  z-index: 120;
}
.search-result {
  width: 100%;
  border: 0;
  background: transparent;
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 11px;
  align-items: center;
  text-align: left;
  padding: 9px;
  border-radius: 12px;
  cursor: pointer;
}
.search-result:hover, .search-result.active { background: var(--accent-soft); }
.search-avatar { width: 42px; height: 42px; border-radius: 11px; background: #e7ebe8; overflow: hidden; display: grid; place-items: center; color: var(--accent); font-weight: 700; }
.search-avatar img { width: 100%; height: 100%; object-fit: cover; }
.search-copy { min-width: 0; }
.search-copy strong, .search-copy small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-copy strong { font-size: 13px; }
.search-copy small { color: var(--muted); margin-top: 3px; font-size: 11px; }
.search-year { color: var(--muted-2); font-size: 11px; }
.search-empty { padding: 18px; text-align: center; color: var(--muted); font-size: 13px; }

.top-actions { justify-self: end; display: flex; gap: 8px; }
.ghost-btn, .icon-btn, .tool-btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.9);
  cursor: pointer;
  transition: .16s ease;
}
.ghost-btn:hover, .icon-btn:hover, .tool-btn:hover { border-color: #bfc9c2; background: white; transform: translateY(-1px); }
.ghost-btn { height: 40px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: 12px; font-size: 13px; font-weight: 600; }
.ghost-btn svg, .icon-btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; }

.workspace { height: calc(100vh - var(--topbar)); display: flex; min-height: 0; }
.canvas-panel { min-width: 0; flex: 1; display: flex; flex-direction: column; position: relative; }
.canvas-toolbar {
  height: var(--toolbar);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(205,213,207,.75);
  background: rgba(249,248,244,.8);
  backdrop-filter: blur(12px);
  position: relative;
  z-index: 25;
}
.focus-chip { min-width: 0; display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 999px; color: #58645d; font-size: 12px; font-weight: 600; }
.focus-chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.presence-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 4px rgba(53,108,85,.1); flex: 0 0 auto; }
.toolbar-actions { display: flex; align-items: center; gap: 6px; }
.tool-btn { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; background: rgba(255,255,255,.78); }
.tool-text { width: auto; padding: 0 11px; font-size: 12px; font-weight: 650; }
.zoom-label { min-width: 46px; text-align: center; font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }

.tree-viewport {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
  touch-action: none;
  cursor: grab;
  background:
    radial-gradient(circle at 18px 18px, rgba(71,90,79,.085) 1px, transparent 1.25px) 0 0 / 36px 36px,
    linear-gradient(180deg, #f8f7f2 0%, #f1efe9 100%);
}
.tree-viewport:active { cursor: grabbing; }
.tree-viewport::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 20px 50px rgba(31,44,37,.025);
}
.tree-world { position: absolute; left: 0; top: 0; width: 2400px; height: 1600px; transform-origin: 0 0; will-change: transform; }
.connector-layer, .node-layer { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.connector-layer { pointer-events: none; }
.family-line { fill: none; stroke: #aeb8b1; stroke-width: 1.55; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.spouse-line { stroke: #8fa197; stroke-width: 1.8; }
.connector-dot { fill: #8fa197; }
.node-layer { pointer-events: none; }

.person-card {
  width: 224px;
  height: 92px;
  position: absolute;
  pointer-events: auto;
  display: grid;
  grid-template-columns: 58px minmax(0,1fr);
  align-items: center;
  gap: 11px;
  padding: 11px;
  border: 1px solid rgba(205,213,207,.95);
  border-radius: 16px;
  background: rgba(255,255,255,.96);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: left;
  transition: box-shadow .2s ease, border-color .2s ease, background .2s ease, transform .2s ease, opacity .22s ease;
  will-change: left, top, transform;
}
.person-card:hover { border-color: #b9c7be; box-shadow: 0 10px 28px rgba(38,58,47,.11); transform: translateY(-2px); }
.person-card.selected { border-color: var(--accent); background: #fbfefc; box-shadow: 0 0 0 3px rgba(53,108,85,.09), 0 12px 30px rgba(38,58,47,.12); }
.person-card.focus-person::before {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: -1px;
  height: 3px;
  border-radius: 4px 4px 0 0;
  background: var(--accent);
}
.person-photo {
  width: 58px;
  height: 68px;
  border-radius: 12px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #e7ebe7, #dce3de);
  color: #617168;
  font-family: Georgia, serif;
  font-size: 20px;
  font-weight: 700;
}
.person-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.person-copy { min-width: 0; }
.person-name { font-family: Georgia, "Times New Roman", serif; font-size: 15px; font-weight: 700; line-height: 1.2; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.person-name-ar { margin-top: 2px; direction: rtl; text-align: left; font-family: Tahoma, "Segoe UI", sans-serif; color: #526158; font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.person-meta { margin-top: 7px; color: var(--muted); font-size: 10.5px; line-height: 1.25; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

.profile-panel {
  width: 372px;
  flex: 0 0 372px;
  min-width: 0;
  background: rgba(255,255,255,.96);
  border-left: 1px solid var(--line);
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  transition: width .28s ease, flex-basis .28s ease, transform .28s ease, opacity .2s ease;
  box-shadow: -10px 0 34px rgba(26,39,32,.035);
  z-index: 40;
}
.profile-panel[aria-hidden="true"] { width: 0; flex-basis: 0; border-left-color: transparent; opacity: 0; pointer-events: none; }
.panel-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.88);
  display: grid;
  place-items: center;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  z-index: 5;
}
.panel-close:hover { background: white; border-color: #bdc8c0; }
.panel-close.static { position: static; flex: 0 0 auto; }
.profile-hero { padding: 26px 24px 21px; border-bottom: 1px solid var(--line); }
.profile-photo {
  width: 112px;
  height: 132px;
  margin-bottom: 18px;
  border-radius: 18px;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #e7ebe7, #d9e1dc);
  color: #5f7167;
  font-family: Georgia, serif;
  font-size: 34px;
  box-shadow: 0 12px 30px rgba(35,54,44,.1);
}
.profile-photo img { width: 100%; height: 100%; object-fit: cover; }
.eyebrow { display: block; color: var(--accent); font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .13em; }
.profile-hero h1 { margin: 5px 42px 0 0; font-family: Georgia, "Times New Roman", serif; font-size: 28px; line-height: 1.08; font-weight: 700; }
.profile-arabic { margin: 7px 0 0; direction: rtl; text-align: left; color: #546259; font-size: 17px; }
.profile-years { margin-top: 9px; color: var(--muted); font-size: 12px; }
.focus-action { margin-top: 17px; height: 38px; border: 1px solid #c7d6cc; background: var(--accent-soft); color: var(--accent-strong); border-radius: 11px; padding: 0 13px; font-size: 12px; font-weight: 700; cursor: pointer; }
.focus-action:hover { background: #dfeee6; }
.profile-section { padding: 20px 24px; border-bottom: 1px solid var(--line); }
.profile-section h2 { margin: 0 0 13px; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.fact-grid { display: grid; gap: 12px; }
.fact { display: grid; grid-template-columns: 94px 1fr; gap: 10px; font-size: 12px; line-height: 1.45; }
.fact span:first-child { color: var(--muted); }
.fact span:last-child { color: #35433b; font-weight: 560; }
.bio-text { margin: 0; color: #46564d; line-height: 1.7; font-size: 13px; white-space: pre-line; }
.profile-empty { padding: 36px 24px; color: var(--muted); }

.canvas-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  max-width: calc(100% - 40px);
  white-space: nowrap;
  padding: 7px 12px;
  border: 1px solid rgba(205,213,207,.85);
  border-radius: 999px;
  color: #7c8680;
  background: rgba(255,255,255,.75);
  backdrop-filter: blur(10px);
  font-size: 10px;
  pointer-events: none;
  z-index: 15;
}
.load-indicator {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255,255,255,.94);
  box-shadow: var(--shadow-sm);
  color: var(--muted);
  font-size: 11px;
  z-index: 30;
}
.load-top { top: 14px; }
.load-bottom { bottom: 48px; }
.spinner { width: 12px; height: 12px; border: 2px solid #d5ddd7; border-top-color: var(--accent); border-radius: 50%; animation: spin .75s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { position: absolute; inset: 0; z-index: 20; display: grid; place-content: center; text-align: center; padding: 30px; pointer-events: none; }
.empty-icon { width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 20px; display: grid; place-items: center; background: white; border: 1px solid var(--line); color: var(--accent); font-size: 28px; box-shadow: var(--shadow-sm); }
.empty-state h2 { margin: 0; font-family: Georgia, serif; font-size: 22px; }
.empty-state p { margin: 7px 0 0; color: var(--muted); font-size: 13px; }

.sheet-backdrop { position: fixed; inset: 0; background: rgba(21,31,26,.25); backdrop-filter: blur(2px); z-index: 150; }
.branches-sheet {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(460px, 94vw);
  padding: 24px;
  background: rgba(255,255,255,.98);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  z-index: 160;
  transform: translateX(102%);
  transition: transform .28s cubic-bezier(.2,.8,.2,1);
  overflow: auto;
}
.branches-sheet.open { transform: translateX(0); }
.sheet-header { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.sheet-header h2 { margin: 5px 0 5px; font-family: Georgia, serif; font-size: 25px; }
.sheet-header p { margin: 0; max-width: 330px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.branch-list { display: grid; gap: 9px; padding: 16px 0 30px; }
.branch-card { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 12px; text-align: left; border: 1px solid var(--line); border-radius: 15px; background: white; padding: 14px; cursor: pointer; transition: .16s ease; }
.branch-card:hover { border-color: #b8c7be; box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.branch-card strong { display: block; font-family: Georgia, serif; font-size: 15px; }
.branch-card small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.branch-count { align-self: center; border-radius: 999px; padding: 5px 8px; background: var(--surface-soft); color: var(--muted); font-size: 10px; font-weight: 700; }
.branch-loading { padding: 30px 0; text-align: center; color: var(--muted); font-size: 12px; }

@media (max-width: 980px) {
  .topbar { grid-template-columns: auto minmax(220px, 1fr) auto; padding: 0 14px; gap: 12px; }
  .brand-copy small { display: none; }
  .ghost-btn span { display: none; }
  .ghost-btn { width: 40px; padding: 0; justify-content: center; }
  .profile-panel { position: fixed; left: 8px; right: 8px; bottom: 8px; width: auto; height: min(72vh, 650px); flex: none; border: 1px solid var(--line); border-radius: 22px; transform: translateY(0); box-shadow: var(--shadow-lg); }
  .profile-panel[aria-hidden="true"] { width: auto; height: min(72vh, 650px); transform: translateY(calc(100% + 18px)); opacity: 1; border-color: var(--line); }
  .profile-hero { padding-top: 22px; }
}

@media (max-width: 680px) {
  :root { --topbar: 64px; --toolbar: 52px; }
  .topbar { grid-template-columns: auto 1fr auto; padding: 0 10px; gap: 8px; }
  .brand-mark { width: 36px; height: 36px; border-radius: 11px; }
  .brand-copy { display: none; }
  .search-wrap { height: 40px; border-radius: 12px; }
  .search-wrap kbd { display: none; }
  .top-actions { gap: 5px; }
  .icon-btn, .ghost-btn { width: 38px; height: 38px; }
  #fullscreenButton { display: none; }
  .canvas-toolbar { padding: 0 10px; }
  .focus-chip { padding-left: 5px; max-width: 45vw; }
  .tool-btn { width: 32px; height: 32px; }
  .tool-text { width: auto; }
  .canvas-hint { display: none; }
  .person-card { width: 200px; height: 84px; grid-template-columns: 51px 1fr; padding: 9px; border-radius: 14px; }
  .person-photo { width: 51px; height: 62px; border-radius: 11px; }
  .person-name { font-size: 14px; }
  .profile-panel { left: 5px; right: 5px; bottom: 5px; height: 78vh; border-radius: 20px; }
  .profile-photo { width: 92px; height: 110px; }
  .branches-sheet { width: 100%; border-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important; }
}

/* Native hidden attribute must always win over component display rules. */
[hidden] { display: none !important; }

/* ================================================================
   Geramon colour themes — v2.4.15
   Default: Cream + Forest
   ================================================================ */
html[data-theme="cream-forest"] {
  --theme-bg: #f1eadc;
  --theme-topbar: rgba(255,252,245,.96);
  --theme-toolbar: rgba(247,242,232,.94);
  --theme-canvas-a: #fbf7ee;
  --theme-canvas-b: #eee6d7;
  --theme-dot: rgba(53,94,74,.10);
  --theme-surface: rgba(255,252,246,.98);
  --theme-surface-solid: #fffdf8;
  --theme-surface-soft: #f6f0e5;
  --theme-card: rgba(255,253,248,.99);
  --theme-card-border: #d8d2c3;
  --theme-ink: #21362d;
  --theme-muted: #718078;
  --theme-muted-2: #909991;
  --theme-line: #d7d1c3;
  --theme-line-strong: #bbb9ab;
  --theme-accent: #355e4a;
  --theme-accent-strong: #284938;
  --theme-accent-soft: #e3ece5;
  --theme-selected-bg: #e7f0e9;
  --theme-selected-ring: rgba(53,94,74,.24);
  --theme-selected-shadow: rgba(35,65,51,.30);
  --theme-connector: #9daa9f;
  --theme-spouse: #718b7a;
  --theme-avatar-a: #e7e8de;
  --theme-avatar-b: #d6ded6;
  --theme-avatar-text: #5b6f64;
  --theme-hint-bg: rgba(255,252,246,.88);
  --theme-overlay: rgba(27,40,33,.27);
}

html[data-theme="slate-copper"] {
  --theme-bg: #e8e2dc;
  --theme-topbar: rgba(249,247,244,.96);
  --theme-toolbar: rgba(235,231,227,.95);
  --theme-canvas-a: #f5f2ef;
  --theme-canvas-b: #ddd6cf;
  --theme-dot: rgba(82,75,69,.11);
  --theme-surface: rgba(251,249,247,.98);
  --theme-surface-solid: #fdfbf9;
  --theme-surface-soft: #eee9e4;
  --theme-card: rgba(253,251,249,.99);
  --theme-card-border: #cbc3bc;
  --theme-ink: #2e3337;
  --theme-muted: #6d7276;
  --theme-muted-2: #8d9296;
  --theme-line: #cec7c1;
  --theme-line-strong: #afa59d;
  --theme-accent: #a65f35;
  --theme-accent-strong: #7f4122;
  --theme-accent-soft: #f0dfd3;
  --theme-selected-bg: #fae8dc;
  --theme-selected-ring: rgba(166,95,53,.25);
  --theme-selected-shadow: rgba(105,66,44,.30);
  --theme-connector: #9da2a6;
  --theme-spouse: #9b765f;
  --theme-avatar-a: #e4dfdb;
  --theme-avatar-b: #d4ccc5;
  --theme-avatar-text: #6c5f56;
  --theme-hint-bg: rgba(251,249,247,.88);
  --theme-overlay: rgba(42,40,38,.28);
}

html[data-theme="deep-navy"] {
  --theme-bg: #dfe9f5;
  --theme-topbar: rgba(245,249,253,.97);
  --theme-toolbar: rgba(229,238,248,.96);
  --theme-canvas-a: #eef4fb;
  --theme-canvas-b: #d5e2f0;
  --theme-dot: rgba(33,65,102,.12);
  --theme-surface: rgba(248,251,255,.98);
  --theme-surface-solid: #fbfdff;
  --theme-surface-soft: #e8f0f8;
  --theme-card: rgba(250,252,255,.99);
  --theme-card-border: #bdcadd;
  --theme-ink: #1b2c3e;
  --theme-muted: #61748a;
  --theme-muted-2: #8291a3;
  --theme-line: #c2cfdd;
  --theme-line-strong: #9db0c5;
  --theme-accent: #244f7d;
  --theme-accent-strong: #183858;
  --theme-accent-soft: #dce9f6;
  --theme-selected-bg: #d8e8f8;
  --theme-selected-ring: rgba(36,79,125,.25);
  --theme-selected-shadow: rgba(24,56,88,.30);
  --theme-connector: #879db6;
  --theme-spouse: #6682a2;
  --theme-avatar-a: #dce5ee;
  --theme-avatar-b: #cad8e6;
  --theme-avatar-text: #4c6785;
  --theme-hint-bg: rgba(248,251,255,.89);
  --theme-overlay: rgba(24,45,69,.28);
}

html[data-theme] {
  --bg: var(--theme-bg);
  --surface: var(--theme-surface);
  --surface-solid: var(--theme-surface-solid);
  --surface-soft: var(--theme-surface-soft);
  --ink: var(--theme-ink);
  --muted: var(--theme-muted);
  --muted-2: var(--theme-muted-2);
  --line: var(--theme-line);
  --line-strong: var(--theme-line-strong);
  --accent: var(--theme-accent);
  --accent-strong: var(--theme-accent-strong);
  --accent-soft: var(--theme-accent-soft);
  --selected-bg: var(--theme-selected-bg);
  --selected-ring: var(--theme-selected-ring);
  --selected-shadow: var(--theme-selected-shadow);
}

body { background: var(--theme-bg); color: var(--theme-ink); }
.topbar { background: var(--theme-topbar); border-bottom-color: var(--theme-line); }
.brand-mark { background: var(--theme-accent); box-shadow: 0 7px 18px var(--theme-selected-ring); }
.search-wrap { background: var(--theme-surface-soft); border-color: var(--theme-line); }
.search-wrap:focus-within { background: var(--theme-surface-solid); border-color: var(--theme-accent); box-shadow: 0 0 0 4px var(--theme-selected-ring); }
.search-results, .profile-panel, .branches-sheet { background: var(--theme-surface); }
.search-avatar { background: var(--theme-avatar-a); color: var(--theme-accent); }
.search-result:hover, .search-result.active { background: var(--theme-accent-soft); }
.ghost-btn, .icon-btn, .tool-btn, .panel-close, .branch-card, .load-indicator { background: var(--theme-surface); border-color: var(--theme-line); }
.ghost-btn:hover, .icon-btn:hover, .tool-btn:hover, .panel-close:hover, .branch-card:hover { background: var(--theme-surface-solid); border-color: var(--theme-line-strong); }
.canvas-toolbar { background: var(--theme-toolbar); border-bottom-color: var(--theme-line); }
.presence-dot { background: var(--theme-accent); box-shadow: 0 0 0 4px var(--theme-selected-ring); }
.tree-viewport {
  background:
    radial-gradient(circle at 18px 18px, var(--theme-dot) 1px, transparent 1.25px) 0 0 / 36px 36px,
    linear-gradient(180deg, var(--theme-canvas-a) 0%, var(--theme-canvas-b) 100%);
}
.family-line { stroke: var(--theme-connector); }
.spouse-line { stroke: var(--theme-spouse); }
.connector-dot { fill: var(--theme-spouse); }
.person-card { background: var(--theme-card); border-color: var(--theme-card-border); }
.person-card:hover { border-color: var(--theme-accent); }
.person-photo, .profile-photo { background: linear-gradient(145deg, var(--theme-avatar-a), var(--theme-avatar-b)); color: var(--theme-avatar-text); }
.person-name-ar, .profile-arabic { color: var(--theme-muted); }
.profile-panel, .profile-hero, .profile-section { border-color: var(--theme-line); }
.fact span:last-child, .bio-text { color: var(--theme-ink); }
.focus-action { background: var(--theme-accent-soft); color: var(--theme-accent-strong); border-color: var(--theme-line-strong); }
.focus-action:hover { background: var(--theme-selected-bg); }
.canvas-hint { background: var(--theme-hint-bg); border-color: var(--theme-line); color: var(--theme-muted); }
.sheet-backdrop { background: var(--theme-overlay); }
.empty-icon { background: var(--theme-surface-solid); }

.theme-control {
  height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 7px 0 10px;
  border: 1px solid var(--theme-line);
  border-radius: 12px;
  background: var(--theme-surface);
  color: var(--theme-muted);
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}
.theme-control:focus-within { border-color: var(--theme-accent); box-shadow: 0 0 0 3px var(--theme-selected-ring); }
.theme-label { text-transform: uppercase; letter-spacing: .08em; font-size: 9px; }
.theme-control select {
  appearance: auto;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--theme-ink);
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
.theme-control option { color: #1f2933; background: #fff; }

@media (max-width: 980px) {
  .theme-label { display: none; }
  .theme-control { padding-left: 7px; padding-right: 5px; }
  .theme-control select { max-width: 120px; }
}
@media (max-width: 680px) {
  .theme-control { height: 38px; width: 92px; padding: 0 4px 0 7px; }
  .theme-control select { width: 100%; max-width: none; font-size: 11px; }
}


/* v2.4.16 — descendant branch collapse controls */
.person-card.branch-collapsed {
  border: 2px solid var(--theme-accent) !important;
  background: linear-gradient(180deg, var(--theme-selected-bg), var(--theme-card)) !important;
  box-shadow: inset 0 -4px 0 var(--theme-accent), 0 10px 28px var(--theme-selected-ring);
}
.person-card.branch-collapsed .person-meta {
  color: var(--theme-accent-strong);
}
.branch-toggle {
  position: absolute;
  z-index: 55;
  width: 30px;
  height: 30px;
  padding: 0;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1.5px solid var(--theme-line-strong);
  background: var(--theme-surface);
  color: var(--theme-accent-strong);
  box-shadow: 0 5px 14px var(--theme-selected-ring);
  cursor: pointer;
  transition: transform .16s ease, background .16s ease, color .16s ease, border-color .16s ease, box-shadow .16s ease;
}
.branch-toggle:hover {
  transform: translate(-50%, -50%) scale(1.1);
  border-color: var(--theme-accent);
  box-shadow: 0 7px 18px var(--theme-selected-shadow);
}
.branch-toggle:focus-visible {
  outline: 3px solid var(--theme-selected-ring);
  outline-offset: 2px;
}
.branch-toggle.collapsed {
  background: var(--theme-accent);
  color: #fff;
  border-color: var(--theme-accent);
  box-shadow: 0 0 0 5px var(--theme-selected-ring), 0 7px 20px var(--theme-selected-shadow);
}
.branch-toggle svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
@media (max-width: 760px) {
  .branch-toggle { width: 32px; height: 32px; }
}
