:root {
  color-scheme: dark;
  --night: #061018;
  --night-2: #0a1822;
  --panel: #0e202b;
  --panel-2: #112733;
  --ink: #f5f3ed;
  --muted: #9ba8ad;
  --gold: #d6a94a;
  --gold-light: #efd48e;
  --line: rgba(220, 185, 105, .19);
  --line-strong: rgba(220, 185, 105, .5);
  --danger: #e59b8d;
  --shadow: 0 28px 80px rgba(0, 4, 9, .52);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { min-width: 100%; min-height: 100%; margin: 0; background: var(--night); color: var(--ink); }
body { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, .tree-node:focus-visible .node-card { outline: 2px solid var(--gold-light); outline-offset: 3px; }
[hidden] { display: none !important; }

.eyebrow { margin: 0 0 9px; color: var(--gold); font-size: .69rem; font-weight: 700; letter-spacing: .18em; text-transform: uppercase; }
.primary-button { min-height: 46px; padding: 0 19px; border: 1px solid #e0ba60; border-radius: 11px; background: linear-gradient(135deg, #d9ad50, #b7832d); color: #09131a; font-weight: 750; box-shadow: 0 10px 26px rgba(164, 111, 22, .18); }
.primary-button:hover { filter: brightness(1.08); }

/* Secure entrance */
.login-screen, .loading-screen { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; min-height: 100dvh; overflow: auto; padding: 28px 18px; background: radial-gradient(circle at 18% 12%, rgba(211, 168, 73, .14), transparent 32%), radial-gradient(circle at 88% 84%, rgba(58, 120, 147, .1), transparent 34%), #061018; }
.login-screen::before, .login-screen::after { content: ""; position: fixed; inset: 22px; border: 1px solid rgba(220, 185, 105, .13); pointer-events: none; }
.login-screen::after { inset: 30px; border-color: rgba(220, 185, 105, .05); }
.login-ornament { position: fixed; inset: 0; display: grid; place-items: center; overflow: hidden; pointer-events: none; opacity: .035; }
.login-ornament img { width: min(82vw, 820px); border-radius: 44%; filter: grayscale(.35); }
.login-card { position: relative; z-index: 2; width: min(100%, 450px); padding: 45px 45px 36px; border: 1px solid rgba(220, 185, 105, .27); border-radius: 24px; background: linear-gradient(150deg, rgba(16, 35, 46, .97), rgba(7, 20, 29, .98)); box-shadow: var(--shadow); }
.login-emblem { position: relative; width: 154px; height: 154px; margin: 0 auto 22px; overflow: hidden; border-radius: 46%; background: #171716; box-shadow: 0 0 0 1px rgba(231,195,111,.18), 0 20px 45px #0008; }
.login-emblem::before { content: ""; position: absolute; z-index: 2; inset: -55%; background: linear-gradient(180deg, transparent 38%, rgba(255,219,128,.82) 49%, rgba(255,240,190,.3) 53%, transparent 64%); transform: translateY(92%) rotate(-8deg); mix-blend-mode: screen; opacity: 0; pointer-events: none; }
.login-emblem::after { content: ""; position: absolute; z-index: 3; inset: 7px; border: 1px solid rgba(244,205,111,.08); border-radius: 42%; opacity: 0; pointer-events: none; }
.login-emblem img, .loading-mark img, .brand-mark img { width: 100%; height: 100%; display: block; object-fit: cover; }
.loading-mark { width: 112px; height: 112px; overflow: hidden; border-radius: 46%; background: #171716; box-shadow: 0 0 38px rgba(223,181,83,.22); animation: emblem-breathe 1.45s ease-in-out infinite; }
.login-screen.is-unlocking .login-emblem { animation: emblem-unlock 1.3s cubic-bezier(.2,.75,.25,1) forwards; }
.login-screen.is-unlocking .login-emblem img { animation: emblem-awaken 1.05s ease forwards; }
.login-screen.is-unlocking .login-emblem::before { animation: emblem-light-rise 1.05s .08s ease-out forwards; }
.login-screen.is-unlocking .login-emblem::after { animation: emblem-ring 1.15s .12s ease-out forwards; }
.login-screen.is-unlocking .login-card > :not(.login-emblem) { animation: unlock-copy .7s .35s ease forwards; pointer-events: none; }
.login-card .eyebrow { text-align: center; }
.login-card h1 { margin: 0 0 17px; font: 400 clamp(2rem, 6vw, 2.7rem)/1.08 Georgia, serif; text-align: center; }
.login-card h1 em { color: var(--gold-light); font-weight: 400; }
.login-intro { margin: 0 auto 30px; color: var(--muted); line-height: 1.65; text-align: center; }
.login-card label { display: block; margin-bottom: 8px; color: #ccd3d4; font-size: .78rem; font-weight: 650; }
.password-field { position: relative; }
.password-manager-username { position: absolute; width: 1px; height: 1px; padding: 0; border: 0; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; opacity: 0; pointer-events: none; }
.password-field input { width: 100%; height: 52px; padding: 0 70px 0 15px; border: 1px solid rgba(229, 235, 235, .17); border-radius: 11px; background: rgba(255,255,255,.055); }
.password-field input:focus { border-color: var(--gold); background: rgba(255,255,255,.075); }
.password-field button { position: absolute; inset-block: 6px; inset-inline-end: 6px; padding: 0 10px; border: 0; background: transparent; color: var(--gold-light); font-size: .75rem; }
.login-error { min-height: 20px; margin: 8px 0 2px; color: var(--danger); font-size: .79rem; }
.login-button { width: 100%; display: flex; justify-content: space-between; align-items: center; }
.privacy-note { margin: 22px 0 0; color: #77868c; font-size: .69rem; line-height: 1.5; text-align: center; }
.loading-screen { gap: 15px; align-content: center; }
.loading-screen .loading-mark { animation: breathe 1.8s ease-in-out infinite; margin: 0; }
.loading-screen p { color: var(--muted); }
@keyframes breathe { 50% { transform: scale(1.06); box-shadow: 0 0 45px rgba(214,169,74,.16); } }

/* App frame */
.app-shell { height: 100dvh; display: grid; grid-template-rows: 72px minmax(0, 1fr); background: var(--night); }
.topbar { position: relative; z-index: 50; display: grid; grid-template-columns: 220px 1fr minmax(150px, 190px); align-items: center; gap: 22px; padding: 0 24px; border-bottom: 1px solid var(--line); background: rgba(5, 15, 23, .92); backdrop-filter: blur(20px); }
.brand { display: inline-flex; align-items: center; gap: 11px; justify-self: start; padding: 0; border: 0; background: transparent; text-align: start; }
.brand-mark { width: 46px; height: 46px; overflow: hidden; border: 1px solid var(--line-strong); border-radius: 13px; background: #171716; box-shadow: 0 5px 16px #0006; }
.brand-copy { display: grid; gap: 2px; text-transform: uppercase; letter-spacing: .13em; }
.brand-copy strong { color: var(--gold-light); font: 1rem Georgia, serif; letter-spacing: .18em; }
.brand-copy span { color: var(--muted); font-size: .66rem; }
.desktop-nav { display: flex; justify-content: center; gap: 5px; }
.nav-item { position: relative; min-height: 42px; padding: 0 16px; border: 0; background: transparent; color: var(--muted); font-size: .82rem; }
.nav-item:hover, .nav-item.is-active { color: var(--ink); }
.nav-item.is-active::after { content: ""; position: absolute; inset-inline: 14px; bottom: -15px; height: 2px; background: var(--gold); }
.top-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.icon-button { width: 41px; height: 41px; display: grid; place-items: center; border: 1px solid rgba(231,237,239,.12); border-radius: 11px; background: rgba(255,255,255,.04); color: var(--gold-light); }
.icon-button svg { width: 18px; height: 18px; display: block; fill: none; stroke: currentColor; stroke-width: 1.7; }
.home-shortcut { padding: 0; align-items: center; justify-items: center; }
.home-shortcut svg { width: 21px; height: 21px; margin: auto; stroke-linecap: round; stroke-linejoin: round; }
.app-main { min-height: 0; position: relative; }
.app-view { position: absolute; inset: 0; visibility: hidden; opacity: 0; pointer-events: none; }
.app-view.is-active { visibility: visible; opacity: 1; pointer-events: auto; }

/* Tree */
.tree-view { display: grid; grid-template-rows: auto minmax(0, 1fr); padding: 0; background: radial-gradient(circle at 50% -20%, rgba(214,169,74,.09), transparent 37%), var(--night); }
.tree-toolbar { position: relative; z-index: 20; display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 82px; padding: 12px 18px; border-bottom: 1px solid var(--line); background: rgba(7,19,28,.88); }
.tree-toolbar .eyebrow { margin-bottom: 4px; }
.tree-toolbar h1 { margin: 0; font: 400 1.45rem Georgia, serif; }
.tree-heading { display: flex; align-items: center; gap: 22px; min-width: 0; }
.tree-legend { display: flex; gap: 11px; color: var(--muted); font-size: .67rem; white-space: nowrap; }
.tree-legend span { display: flex; align-items: center; gap: 5px; }
.tree-legend b { width: 22px; height: 22px; display: grid; place-items: center; border: 1px solid rgba(222,186,104,.32); border-radius: 7px; background: rgba(214,169,74,.1); color: var(--gold-light); font-size: .65rem; }
.tree-controls { display: grid; grid-template-columns: repeat(3, max-content); align-items: center; justify-content: end; gap: 7px; }
.tree-controls > button, .tree-controls span button, .focus-control > button { min-width: 40px; height: 38px; padding: 0 12px; border: 1px solid rgba(229,235,235,.13); border-radius: 9px; background: rgba(255,255,255,.045); color: #ced4d5; font-size: .76rem; }
.tree-controls span { display: flex; }
.tree-controls span button:first-child { border-radius: 9px 0 0 9px; }
.tree-controls span button:last-child { margin-inline-start: -1px; border-radius: 0 9px 9px 0; }
.focus-control { position: relative; }
.focus-popover { position: absolute; z-index: 30; top: calc(100% + 9px); right: 0; width: min(330px, calc(100vw - 24px)); padding: 13px; border: 1px solid var(--line-strong); border-radius: 13px; background: #0b1d28; box-shadow: var(--shadow); }
.focus-popover[hidden] { display: none; }
.focus-popover label { display: block; margin-bottom: 8px; color: var(--gold-light); font-size: .7rem; }
.focus-popover > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 7px; }
.focus-popover input { min-width: 0; height: 40px; padding: 0 10px; border: 1px solid rgba(228,234,235,.15); border-radius: 9px; background: #07151e; }
.focus-popover button { min-width: 58px; border: 1px solid rgba(222,186,104,.3); border-radius: 9px; background: rgba(214,169,74,.12); color: var(--gold-light); }
.tree-canvas-wrap { position: relative; min-height: 0; width: 100%; overflow: hidden; background: radial-gradient(circle at 50% 38%, rgba(24,62,78,.28), transparent 49%), #07131c; box-shadow: inset 0 1px rgba(255,255,255,.025); }
#treeSvg { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#treeSvg.is-dragging { cursor: grabbing; }
.stage-grid { pointer-events: none; }
.generation-guide { stroke: rgba(205,181,128,.1); stroke-width: 1; stroke-dasharray: 4 10; }
.generation-label { fill: #728189; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; }
.spouse-line, .family-line { fill: none; stroke: rgba(213,178,102,.33); stroke-width: 1.4; }
.family-junction { fill: #b99242; opacity: .65; }
.tree-node { cursor: pointer; }
.node-card { fill: #10232f; stroke: rgba(227,231,231,.15); stroke-width: 1; filter: url(#nodeShadow); transition: opacity .2s, stroke .2s; }
.tree-node:hover .node-card, .tree-node.is-related .node-card { stroke: rgba(227,193,111,.62); }
.tree-node.is-selected .node-card { stroke: #e4bd61; stroke-width: 2.4; }
.node-accent.male { fill: #7eb0c9; }.node-accent.female { fill: #c990a2; }.node-accent.unknown { fill: #c5a85e; }
.node-avatar-bg { fill: #182f3b; stroke: rgba(221,185,100,.35); }
.node-initial { fill: #f0d998; font: 15px Georgia, serif; text-anchor: middle; dominant-baseline: middle; }
.node-name { fill: #f3f2ed; font-size: 13px; font-weight: 650; }
.node-life { fill: #89979d; font-size: 10.5px; }
.node-action { cursor: pointer; }
.node-action-hit { fill: rgba(214,169,74,.08); stroke: rgba(222,186,104,.3); transition: fill .16s, stroke .16s; }
.node-action:hover .node-action-hit, .node-action:focus .node-action-hit { fill: rgba(214,169,74,.22); stroke: rgba(238,205,127,.8); }
.node-action-label { fill: #efd486; font-size: 9.5px; font-weight: 750; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.home-halo { fill: rgba(214,169,74,.04); stroke: rgba(214,169,74,.34); stroke-dasharray: 3 4; }
.home-dot { fill: #e5bc5b; }
.nodeLayer-has-path .tree-node:not(.is-path) .node-card, .nodeLayer-has-path .tree-node:not(.is-path) text, .nodeLayer-has-path .tree-node:not(.is-path) image { opacity: .22; }
.tree-node.is-path .node-card { stroke: #edcb78; stroke-width: 2.4; }
.edgeLayer-has-path .relation-edge:not(.is-path) { opacity: .1; }
.relation-edge.is-path { stroke: #e7bd5d; stroke-width: 3; opacity: 1; }
.tree-status, .explore-hint { position: absolute; bottom: 15px; padding: 8px 12px; border: 1px solid rgba(220,185,105,.14); border-radius: 10px; background: rgba(6,17,25,.82); color: #8d9ba0; font-size: .68rem; backdrop-filter: blur(10px); pointer-events: none; }
.tree-status { inset-inline-start: 15px; }.tree-status strong { color: var(--gold-light); }
.explore-hint { inset-inline-end: 15px; transition: opacity .2s; }.explore-hint.is-hidden { opacity: 0; }.touch-hint { display: none; }

/* Content pages */
.content-view { overflow: auto; padding: clamp(30px, 5vw, 65px) max(22px, calc((100vw - 1220px) / 2)) 90px; background: radial-gradient(circle at 20% 0, rgba(214,169,74,.07), transparent 30%), #08141d; }
.page-heading { margin-bottom: 32px; }
.page-heading h1 { margin: 0 0 10px; font: 400 clamp(2rem, 4vw, 3.25rem)/1.1 Georgia, serif; }
.page-heading > p:last-child, .heading-row p { margin: 0; color: var(--muted); line-height: 1.6; }
.heading-row { display: flex; justify-content: space-between; align-items: end; gap: 20px; }
.relationship-builder, .filter-bar { display: grid; align-items: end; gap: 12px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: rgba(15,34,45,.82); }
.relationship-builder { grid-template-columns: 1fr auto 1fr auto; }
.person-picker label { display: block; margin-bottom: 7px; color: #aab4b7; font-size: .72rem; font-weight: 650; }
.person-picker input, .filter-bar input, .filter-bar select { width: 100%; height: 46px; padding: 0 13px; border: 1px solid rgba(228,234,235,.14); border-radius: 10px; background: #0a1922; }
.swap-button { width: 44px; height: 44px; margin-bottom: 1px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--gold-light); font-size: 1.2rem; }
.relationship-result { margin-top: 22px; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(140deg, rgba(16,36,47,.92), rgba(8,23,32,.9)); }
.empty-state { min-height: 330px; display: grid; place-items: center; align-content: center; padding: 30px; text-align: center; }
.empty-icon { width: 62px; height: 62px; display: grid; place-items: center; margin-bottom: 12px; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--gold-light); font-size: 1.7rem; }
.empty-state h2 { margin: 7px 0; font: 1.55rem Georgia, serif; }.empty-state p { max-width: 520px; margin: 0; color: var(--muted); line-height: 1.6; }
.connection-summary { padding: clamp(24px, 4vw, 44px); text-align: center; }
.connection-summary h2 { margin: 8px 0 9px; font: 400 clamp(1.6rem, 4vw, 2.5rem) Georgia, serif; color: var(--gold-light); }
.connection-summary > p { margin: 0; color: var(--muted); }
.path-list { display: flex; justify-content: center; align-items: stretch; flex-wrap: wrap; gap: 0; margin: 35px 0 25px; }
.path-person { position: relative; width: 142px; display: grid; place-items: center; align-content: start; gap: 8px; padding: 14px 10px; border: 1px solid var(--line); background: rgba(255,255,255,.025); }
.path-person:first-child { border-radius: 12px 0 0 12px; }.path-person:last-child { border-radius: 0 12px 12px 0; }
.path-person + .path-person { margin-inline-start: -1px; }
.path-person strong { font-size: .76rem; }.path-person small { color: var(--muted); font-size: .66rem; }
.path-actions { display: flex; justify-content: center; gap: 9px; }.secondary-button { min-height: 42px; padding: 0 15px; border: 1px solid var(--line-strong); border-radius: 9px; background: transparent; color: var(--gold-light); }

/* Directory */
.view-toggle { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 9px; }.view-toggle button { height: 34px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: .74rem; }.view-toggle button.is-active { background: rgba(214,169,74,.14); color: var(--gold-light); }
.filter-bar { grid-template-columns: 1.6fr repeat(3, 1fr); margin-bottom: 20px; padding: 13px; }
.people-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.person-card { min-width: 0; display: grid; grid-template-columns: 52px minmax(0,1fr); gap: 13px; align-items: center; padding: 15px; border: 1px solid rgba(222,186,104,.15); border-radius: 13px; background: #0d202b; text-align: start; }
.person-card:hover { border-color: rgba(222,186,104,.45); transform: translateY(-1px); }
.avatar { width: 52px; height: 52px; display: grid; place-items: center; overflow: hidden; border: 1px solid rgba(222,186,104,.34); border-radius: 50%; background: #17313e; color: var(--gold-light); font: 1rem Georgia, serif; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.person-card > span:not(.avatar), .person-card > span:not(.avatar) > strong, .person-card > span:not(.avatar) > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.person-card > span:not(.avatar) > strong { color: #f2f1ed; font-size: .83rem; }.person-card > span:not(.avatar) > span { margin-top: 5px; color: var(--muted); font-size: .69rem; }
.people-grid.is-list { grid-template-columns: 1fr 1fr; }.people-grid.is-list .person-card { grid-template-columns: 46px 1fr auto; }.people-grid.is-list .person-card::after { content: "Open profile →"; color: var(--gold); font-size: .67rem; }

/* Insights */
.insight-tabs { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 12px; scrollbar-width: thin; }
.insight-tabs button { min-height: 39px; flex: 0 0 auto; padding: 0 14px; border: 1px solid var(--line); border-radius: 9px; background: transparent; color: var(--muted); font-size: .75rem; }.insight-tabs button.is-active { border-color: var(--line-strong); background: rgba(214,169,74,.11); color: var(--gold-light); }
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 9px 0 22px; }.stat-card { min-height: 145px; padding: 23px; border: 1px solid var(--line); border-radius: 15px; background: linear-gradient(145deg, #102430, #0a1a24); }.stat-card span { color: var(--muted); font-size: .72rem; }.stat-card strong { display: block; margin-top: 17px; color: var(--gold-light); font: 2.25rem Georgia, serif; }.stat-card small { display: block; margin-top: 4px; color: #6f8188; font-size: .68rem; }
.dashboard-grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 15px; }.dashboard-card { padding: 24px; border: 1px solid var(--line); border-radius: 15px; background: #0d202b; }.dashboard-card h2 { margin: 0 0 19px; font: 1.2rem Georgia, serif; }.dashboard-card > p { color: var(--muted); }
.bar-row { display: grid; grid-template-columns: minmax(100px,.7fr) 2fr 38px; align-items: center; gap: 11px; margin: 11px 0; font-size: .74rem; }.bar-row > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }.bar-track { height: 7px; overflow: hidden; border-radius: 10px; background: rgba(255,255,255,.06); }.bar-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #9b7025, #e1b95d); }.bar-row strong { color: var(--gold-light); text-align: end; }
.completion-ring { --value: 0; width: 142px; aspect-ratio: 1; display: grid; place-items: center; margin: 10px auto 18px; border-radius: 50%; background: conic-gradient(var(--gold) calc(var(--value)*1%), rgba(255,255,255,.06) 0); }.completion-ring::before { content: ""; position: absolute; width: 108px; aspect-ratio: 1; border-radius: 50%; background: #0d202b; }.completion-ring strong { position: relative; color: var(--gold-light); font: 1.8rem Georgia, serif; }
.quality-list { display: grid; gap: 9px; }.quality-item { display: flex; justify-content: space-between; gap: 15px; padding: 13px 0; border-bottom: 1px solid rgba(255,255,255,.06); color: var(--muted); font-size: .77rem; }.quality-item strong { color: var(--gold-light); }
.photo-gallery { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }.photo-tile { aspect-ratio: .82; position: relative; overflow: hidden; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: #10232e; }.photo-tile img { width: 100%; height: 100%; object-fit: cover; }.photo-tile span { position: absolute; inset-inline: 0; bottom: 0; padding: 28px 8px 8px; background: linear-gradient(transparent, rgba(4,12,18,.94)); font-size: .68rem; text-align: start; }

/* Profile drawer */
.person-panel { position: fixed; z-index: 100; top: 72px; bottom: 0; inset-inline-end: 0; width: min(420px, 100%); overflow: auto; padding: 28px; border-inline-start: 1px solid var(--line); background: rgba(8,23,32,.985); box-shadow: var(--shadow); transform: translateX(105%); transition: transform .28s ease; }.person-panel.is-open { transform: translateX(0); }[dir="rtl"] .person-panel { transform: translateX(-105%); }[dir="rtl"] .person-panel.is-open { transform: translateX(0); }
.panel-close { position: absolute; z-index: 2; top: 15px; inset-inline-end: 15px; width: 38px; height: 38px; border: 1px solid rgba(255,255,255,.1); border-radius: 50%; background: rgba(255,255,255,.04); color: var(--muted); font-size: 1.35rem; }
.profile-header { text-align: center; padding: 15px 0 24px; }.profile-header .avatar { width: 100px; height: 100px; margin: auto; font-size: 1.7rem; }.profile-kicker { margin: 15px 0 7px; color: var(--gold); font-size: .68rem; letter-spacing: .13em; text-transform: uppercase; }.profile-header h2 { margin: 0; font: 400 1.9rem Georgia, serif; }.profile-life { margin-top: 7px; color: var(--muted); font-size: .78rem; }
.profile-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 20px; }.profile-actions button { min-height: 42px; border: 1px solid var(--line); border-radius: 9px; background: rgba(214,169,74,.06); color: var(--gold-light); font-size: .72rem; }
.detail-list { margin: 0 0 22px; }.detail-row { display: grid; grid-template-columns: 100px 1fr; gap: 12px; padding: 12px 0; border-bottom: 1px solid rgba(255,255,255,.06); }.detail-row dt { color: var(--muted); font-size: .7rem; }.detail-row dd { margin: 0; font-size: .77rem; line-height: 1.4; }
.relations-section { margin-top: 23px; }.relations-section h3 { color: var(--gold); font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; }.relation-card { width: 100%; display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 10px; padding: 8px; border: 0; border-radius: 9px; background: transparent; text-align: start; }.relation-card:hover { background: rgba(214,169,74,.08); }.relation-card .avatar { width: 40px; height: 40px; }.relation-card strong { font-size: .76rem; }.relation-card span:last-child { color: var(--gold); }
.panel-scrim { position: fixed; z-index: 90; inset: 72px 0 0; visibility: hidden; opacity: 0; border: 0; background: rgba(0,6,10,.5); transition: opacity .2s; }.panel-scrim.is-visible { visibility: visible; opacity: 1; }
.mobile-nav { display: none; }

@media (max-width: 1100px) {
  .topbar { grid-template-columns: 190px 1fr 150px; padding: 0 15px; }.desktop-nav .nav-item { padding: 0 9px; }.people-grid { grid-template-columns: repeat(3, 1fr); }.stat-grid { grid-template-columns: repeat(2, 1fr); }.photo-gallery { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 760px) {
  body { overflow: hidden; }.login-screen { padding: 18px 14px; }.login-screen::before { inset: 8px; }.login-screen::after { display: none; }.login-card { padding: 34px 22px 28px; }.login-seal { width: 58px; height: 58px; margin-bottom: 20px; }
  .app-shell { grid-template-rows: 60px minmax(0, 1fr) calc(64px + env(safe-area-inset-bottom)); }.topbar { grid-template-columns: 1fr auto; padding: 0 12px; }.brand-mark { width: 37px; height: 37px; }.brand-copy span { display: none; }.desktop-nav { display: none; }.top-actions { gap: 6px; }
  .app-main { grid-row: 2; }.mobile-nav { grid-row: 3; display: grid; grid-template-columns: repeat(4, 1fr); padding: 5px 5px max(5px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: #07141d; }.mobile-nav button { display: grid; place-items: center; gap: 2px; border: 0; background: transparent; color: #849298; font-size: .62rem; }.mobile-nav button span { color: inherit; font-size: 1rem; }.mobile-nav button.is-active { color: var(--gold-light); }
  .tree-view { grid-template-rows: auto minmax(0, 1fr); }.tree-toolbar { min-height: 102px; align-content: center; align-items: center; flex-wrap: wrap; gap: 7px; padding: 8px 10px; }.tree-toolbar .eyebrow { display: none; }.tree-toolbar h1 { font-size: 1.02rem; }.tree-heading { width: 100%; justify-content: space-between; gap: 8px; }.tree-legend { gap: 7px; font-size: .61rem; }.tree-legend b { width: 20px; height: 20px; }.tree-controls { width: 100%; gap: 5px; overflow-x: auto; scrollbar-width: none; }.tree-controls::-webkit-scrollbar { display: none; }.tree-controls > button, .tree-controls span button, .focus-control > button { height: 34px; padding: 0 9px; white-space: nowrap; }.focus-control { position: static; }.focus-popover { position: fixed; top: 112px; left: 12px; right: 12px; width: auto; }.tree-status { bottom: 10px; inset-inline-start: 10px; }.explore-hint { bottom: 10px; inset-inline-end: 10px; }.desktop-hint { display: none; }.touch-hint { display: inline; }
  .content-view { padding: 28px 14px 65px; }.page-heading { margin-bottom: 22px; }.page-heading h1 { font-size: 2rem; }.heading-row { align-items: start; }.relationship-builder { grid-template-columns: 1fr; }.swap-button { margin: -1px auto; transform: rotate(90deg); }.relationship-builder .primary-button { width: 100%; }.relationship-result { margin-top: 14px; }.path-list { flex-direction: column; align-items: center; }.path-person { width: min(100%, 300px); }.path-person:first-child, .path-person:last-child { border-radius: 10px; }.path-person + .path-person { margin: -1px 0 0; }
  .filter-bar { grid-template-columns: 1fr 1fr; }.filter-bar input { grid-column: 1 / -1; }.people-grid, .people-grid.is-list { grid-template-columns: 1fr 1fr; gap: 8px; }.person-card { grid-template-columns: 44px minmax(0,1fr); padding: 11px; }.person-card .avatar { width: 44px; height: 44px; }.people-grid.is-list { grid-template-columns: 1fr; }.people-grid.is-list .person-card::after { display: none; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 8px; }.stat-card { min-height: 120px; padding: 17px; }.stat-card strong { font-size: 1.8rem; }.dashboard-grid { grid-template-columns: 1fr; }.dashboard-card { padding: 18px; }.photo-gallery { grid-template-columns: repeat(3, 1fr); }.bar-row { grid-template-columns: minmax(80px,.8fr) 1.5fr 30px; }
  .person-panel { top: 60px; bottom: calc(64px + env(safe-area-inset-bottom)); padding: 22px; border-radius: 18px 18px 0 0; }.panel-scrim { inset: 60px 0 calc(64px + env(safe-area-inset-bottom)); }
}

@media (max-width: 430px) {
  .brand-copy strong { font-size: .88rem; }.icon-button { width: 38px; height: 38px; }.people-grid { grid-template-columns: 1fr; }.filter-bar { grid-template-columns: 1fr; }.filter-bar input { grid-column: auto; }.stat-grid { grid-template-columns: 1fr 1fr; }.photo-gallery { grid-template-columns: repeat(2, 1fr); }.tree-status { max-width: 56%; }.explore-hint { max-width: 42%; text-align: end; }
}

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

@keyframes emblem-unlock { 0%,18% { transform: scale(1); opacity: 1; filter: brightness(1); } 58% { transform: scale(1.1); opacity: 1; filter: brightness(1.28) drop-shadow(0 0 28px rgba(238,196,98,.68)); } 100% { transform: scale(.76) translateY(-8px); opacity: 0; filter: brightness(1.5) drop-shadow(0 0 48px rgba(238,196,98,.76)); } }
@keyframes emblem-awaken { 0% { filter: brightness(.86) saturate(.84); } 55% { filter: brightness(1.28) saturate(1.12); } 100% { filter: brightness(1.48) saturate(1.18); } }
@keyframes emblem-light-rise { 0% { transform: translateY(92%) rotate(-8deg); opacity: 0; } 18% { opacity: .92; } 75% { opacity: .82; } 100% { transform: translateY(-92%) rotate(-8deg); opacity: 0; } }
@keyframes emblem-ring { 0% { opacity: 0; transform: scale(.88); } 45% { opacity: .72; } 100% { opacity: 0; transform: scale(1.13); } }
@keyframes unlock-copy { to { opacity: 0; transform: translateY(8px); } }
@keyframes emblem-breathe { 50% { transform: scale(1.035); filter: brightness(1.16); } }
@keyframes branch-card-reveal { from { opacity: 0; transform: translateY(15px) scale(.97); } to { opacity: 1; transform: none; } }
@keyframes branch-line-grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }

.connection-branch { position: relative; width: min(100%, 760px); margin: 34px auto 28px; padding: 0; list-style: none; }
.connection-branch::before { content: ""; position: absolute; top: 42px; bottom: 42px; left: 50%; width: 2px; background: linear-gradient(#d8ad51,#718994); transform: translateX(-50%); opacity: .7; }
.connection-branch li { position: relative; width: 50%; padding: 9px 34px; opacity: 0; animation: branch-card-reveal .46s ease forwards; animation-delay: calc(var(--step) * 130ms); }
.connection-branch li:nth-child(odd) { margin-right: auto; text-align: right; }
.connection-branch li:nth-child(even) { margin-left: auto; text-align: left; }
.connection-branch li::after { content: ""; position: absolute; top: 50%; width: 34px; height: 2px; background: #b79753; }
.connection-branch li:nth-child(odd)::after { right: 0; }.connection-branch li:nth-child(even)::after { left: 0; }
.connection-branch .path-person { width: 100%; margin: 0 !important; text-align: start; border-radius: 12px !important; box-shadow: 0 9px 24px #0005; }

.tutorial-overlay { position: fixed; inset: 0; z-index: 500; display: grid; place-items: center; padding: 18px; background: rgba(1,8,12,.82); backdrop-filter: blur(8px); }
.tutorial-card { width: min(100%, 470px); padding: 30px; border: 1px solid rgba(225,190,107,.38); border-radius: 22px; background: linear-gradient(145deg,#112733,#07141d); box-shadow: var(--shadow); text-align: center; }
.tutorial-emblem { width: 82px; height: 82px; margin: 0 auto 16px; border-radius: 22px; object-fit: cover; }
.tutorial-card h2 { margin: 0 0 12px; font: 400 2rem/1.1 Georgia,serif; color: #f3d68e; }
.tutorial-card > p:not(.eyebrow) { min-height: 54px; margin: 0 auto 20px; color: #bdc8cc; line-height: 1.55; }
.tutorial-dots { display: flex; justify-content: center; gap: 7px; margin: 0 0 24px; }
.tutorial-dots i { width: 7px; height: 7px; border-radius: 50%; background: #53636a; }.tutorial-dots i.is-active { width: 23px; border-radius: 5px; background: #ddb65b; }
.tutorial-actions { display: flex; justify-content: space-between; gap: 12px; }.tutorial-actions > button { min-width: 104px; min-height: 44px; border-radius: 10px; }.tutorial-actions > button:first-child { border: 1px solid rgba(255,255,255,.14); background: transparent; color: #bdc8cc; }

/* Focused tree: readable cards, dedicated action row, vertical mobile branches. */
.family-group-box { fill: rgba(159,191,207,.035); stroke: rgba(211,184,121,.19); stroke-width: 1; }
.family-group-label { fill: #d8c599; font: 14px sans-serif; }
.family-group { pointer-events: none; }
.family-group[data-kind="expanded"] .family-group-box { fill: rgba(132,153,164,.025); stroke-dasharray: 6 6; }
.family-group[data-kind="focus"] .family-group-box { fill: rgba(214,169,74,.045); stroke: rgba(229,198,126,.36); }
.tree-person-card { box-sizing: border-box; height: 176px; padding: 10px; display: flex; flex-direction: column; gap: 5px; color: #f4f2ed; font: 16px/1.3 system-ui,sans-serif; user-select: none; }
.tree-person-info { flex: 1; min-height: 0; padding: 0; display: flex; align-items: flex-start; gap: 12px; color: inherit; background: transparent; border: 0; text-align: start; cursor: grab; }
.tree-person-info .avatar { width: 42px; height: 42px; flex: 0 0 42px; font-size: 17px; }
.tree-person-copy { min-width: 0; max-height: 104px; overflow: hidden; display: flex; flex-direction: column; gap: 2px; }
.tree-person-copy strong { font-size: 16px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tree-surnames { min-height: 0; font-size: 13px; color: #dac58f; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.25; overflow-wrap: anywhere; }
.tree-parentage { margin-top: 2px; padding-top: 4px; border-top: 1px solid rgba(255,255,255,.08); color: #9fb4bd; font-size: 12px; line-height: 1.25; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-person-copy small { font-size: 13px; color: #bbc8cd; }
.tree-card-actions { flex: 0 0 38px; display: grid; grid-template-columns: 1fr 1fr; gap: 7px; border-top: 1px solid rgba(255,255,255,.08); padding-top: 3px; }
.tree-card-actions button { width: 100%; min-width: 0; height: 35px; border: 1px solid rgba(222,186,104,.4); border-radius: 7px; background: #19313d; color: #f6d98e; font: 700 15px system-ui; cursor: pointer; }
.tree-card-actions button:hover { background: #2c4652; }
.tree-card-actions button:focus-visible { outline: 3px solid #f8d580; outline-offset: 1px; }
.tree-node.is-selected .node-card { stroke: #f5cf78; stroke-width: 3; fill: #17323f; }
.tree-node.sex-male:not(.is-selected) .node-card { fill: #102b3a; stroke: rgba(103,170,201,.58); }
.tree-node.sex-female:not(.is-selected) .node-card { fill: #2b202e; stroke: rgba(205,126,158,.58); }
.tree-node.sex-unknown:not(.is-selected) .node-card { fill: #29271f; stroke: rgba(197,171,102,.48); }
.tree-node.is-direct:not(.is-selected) .node-card { stroke: rgba(216,197,153,.48); stroke-width: 1.6; }
.tree-node.is-extended { opacity: .66; transition: opacity .18s ease; }
.tree-node.is-extended:hover, .tree-node.is-extended:focus-within { opacity: 1; }
.nodeLayer-has-path .tree-node:not(.is-path) { opacity: .16; }
.path-edge-label { fill: #d6bf87; font: 14px system-ui; }
.tree-secondary-controls { grid-column: 1 / -1; display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 7px; width: 100%; }
.tree-secondary-controls[hidden] { display: none; }
.tree-secondary-controls > button,.tree-secondary-controls span button { min-width: 40px; height: 38px; padding: 0 12px; border: 1px solid rgba(229,235,235,.13); border-radius: 9px; background: rgba(255,255,255,.045); color: #ced4d5; font-size: .76rem; }
.tree-secondary-controls span { display: flex; }
.tree-secondary-controls span button:first-child { border-radius: 9px 0 0 9px; }
.tree-secondary-controls span button:last-child { margin-inline-start: -1px; border-radius: 0 9px 9px 0; }
.tree-more-toggle { grid-column: 1 / -1; justify-self: center; width: 68px; min-width: 68px !important; height: 38px !important; padding: 0 !important; border: 1px solid rgba(214,169,74,.24) !important; border-radius: 999px !important; background: rgba(214,169,74,.08) !important; color: var(--gold-light) !important; }
.tree-more-toggle span { display: grid; place-items: center; width: 100%; height: 100%; line-height: 1; transition: transform .2s ease; }
.tree-more-toggle svg { width: 34px; height: 20px; display: block; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.tree-more-toggle[aria-expanded="true"] span { transform: rotate(180deg); }
#expandBranchButton { white-space: normal; line-height: 1.08; }
.mobile-nav button[data-view="relationship"] span { font-size: 1.38rem; line-height: .8; }
.tree-controls > button[hidden] { display: none; }
.tree-controls button.is-active { background: rgba(214,169,74,.2); border-color: #d6a94a; }
.tree-heading { min-width: 0; }
.tree-heading h1 { max-width: 420px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-toolbar { gap: 12px; }
.person-picker,.focus-popover > div { position: relative; }
.picker-results { position: absolute; z-index: 100; top: 100%; inset-inline: 0; max-height: 290px; overflow: auto; background: #102631; border: 1px solid #75806a; border-radius: 10px; padding: 5px; box-shadow: 0 15px 35px #0008; text-align: start; }
.picker-results[hidden] { display: none; }
.picker-results button { display: block; width: 100%; min-height: 58px; padding: 10px; border: 0; border-radius: 5px; background: transparent; color: #f3f2ed; text-align: start; }
.picker-results strong,.picker-results small { display: block; white-space: normal; overflow-wrap: anywhere; }
.picker-results strong { font-size: 15px; }
.picker-results small { font-size: 13px; color: #c3ced2; margin-top: 4px; }
.picker-results button:hover,.picker-results button[aria-selected=true] { background: #28424b; }
.picker-results p { padding: 10px; }
.focus-popover { width: min(420px,calc(100vw - 24px)); }
.focus-popover input,.person-picker input { font-size: 16px; }
.login-card { position: relative; }
.login-language { display: block; margin-inline-start: auto; margin-bottom: 12px; border: 1px solid #665d42; border-radius: 8px; background: transparent; color: #f1d28c; padding: 7px 12px; }
.path-list { display: grid; grid-template-columns: repeat(auto-fit,minmax(170px,1fr)); gap: 10px; }
.path-person { width: auto; margin: 0 !important; border-radius: 10px !important; }
[dir=rtl] #treeSvg { direction: ltr; }
[dir=rtl] .family-group-label,[dir=rtl] .path-edge-label { direction: rtl; unicode-bidi: plaintext; }
[dir=rtl] .family-group-label { text-anchor: start; }
[dir=rtl] .people-grid.is-list .person-card::after { content: "فتح الملف ←"; }
[dir=rtl] .person-panel { right: auto; left: 0; transform: translateX(-105%); }
[dir=rtl] .person-panel.is-open { transform: translateX(0); }
@media(max-width:760px) {
  .tree-heading { align-items: start; }
  .tree-heading h1 { max-width: 55vw; font-size: 16px; }
  .tree-toolbar { min-height: 0; padding: 8px; gap: 8px; }
  .tree-controls { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px; overflow: visible; }
  .tree-controls > button,.focus-control > button { width: 100%; min-width: 0; height: 42px; padding: 0 5px; font-size: 12px; }
  .tree-more-toggle { grid-column: 2; height: 38px !important; }
  .tree-secondary-controls { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px; }
  .tree-secondary-controls > button,.tree-secondary-controls span button { width: 100%; min-width: 0; height: 38px; padding: 0 5px; font-size: 12px; }
  .tree-controls span { justify-content: stretch; }
  .tree-controls span button { width: 50%; height: 38px; }
  .tree-legend { flex-direction: column; align-items: start; gap: 2px; font-size: 12px; }
  .focus-popover { top: 155px; }
  .picker-results { max-height: min(300px,40dvh); }
  .tree-status { max-width: 70%; font-size: 12px; }
  .explore-hint { display: none; }
  .path-list { grid-template-columns: 1fr; }
  .path-person { width: 100%; }
  .person-card > span:not(.avatar) > strong { font-size: 16px; }.person-card > span:not(.avatar) > span { font-size: 14px; }
  .person-panel { width: 100%; }
  .connection-branch::before { left: 19px; transform: none; }
  .connection-branch li,.connection-branch li:nth-child(odd),.connection-branch li:nth-child(even) { width: 100%; margin: 0; padding: 8px 0 8px 43px; text-align: start; }
  .connection-branch li::after,.connection-branch li:nth-child(odd)::after,.connection-branch li:nth-child(even)::after { left: 19px; right: auto; width: 24px; }
  .login-emblem { width: 126px; height: 126px; }
  .tutorial-card { padding: 25px 20px; }
}
