:root {
  --color-canvas: #F7F5F0;
  --color-surface: #FCFBF8;
  --color-surface-hover: #F2F0EA;
  --color-text-primary: #172D33;
  --color-text-secondary: #667377;
  --color-text-tertiary: #929B9D;
  --color-text-disabled: #B9BDBC;
  --color-border: #DCD9D1;
  --color-border-strong: #BFC4C1;
  --color-accent: #176B67;
  --color-accent-hover: #125955;
  --color-accent-soft: #E4F0ED;
  --color-warning: #A65F3D;
  --color-warning-soft: #F4E9E2;
  --color-question: #76647C;
  --shadow-floating: 0 1px 2px rgba(23,45,51,.04), 0 6px 24px rgba(23,45,51,.07);
  --shadow-panel: -8px 0 32px rgba(23,45,51,.08);
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-panel: 14px;
  --ease-standard: cubic-bezier(.2,.8,.2,1);
  --duration-fast: 120ms;
  --duration-standard: 220ms;
  --duration-navigation: 420ms;
  --font-11: 11px;
  --font-12: 12px;
  --font-13: 13px;
  --font-14: 14px;
  --font-15: 15px;
  --font-16: 16px;
  --font-18: 18px;
  --font-22: 22px;
  --font-28: 28px;
  --font-36: 36px;
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Cormorant Garamond", Georgia, serif;
}

* { box-sizing: border-box; }
html, body, #app { width: 100%; height: 100%; min-height: 100%; }
body { margin: 0; overflow: hidden; color: var(--color-text-primary); background: var(--color-canvas); font-family: var(--sans); font-size: var(--font-14); line-height: 1.45; -webkit-font-smoothing: antialiased; }
body.tree-view-open { overflow: hidden; overscroll-behavior: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, [role="button"]:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.app, .canvas-shell { position: relative; width: 100%; height: 100%; overflow: hidden; }
.family-tree-page { position: fixed; inset: 0; width: 100%; height: 100vh; height: 100dvh; overflow: hidden; }
.tree-ui-overlay { position: absolute; inset: 0; z-index: 20; pointer-events: none; }
.tree-ui-overlay .tool-palette,
.tree-ui-overlay .zoom-controls,
.tree-ui-overlay .mobile-toolbar,
.tree-ui-overlay .mobile-minimap,
.tree-ui-overlay .popover,
.tree-ui-overlay .person-panel,
.tree-ui-overlay .context-menu,
.tree-ui-overlay .source-viewer,
.tree-ui-overlay .drawer-backdrop,
.tree-ui-overlay .toast,
.tree-ui-overlay .onboarding,
.tree-ui-overlay .empty-state { pointer-events: auto; }
.family-tree { position: absolute; inset: 0; display: block; width: 100%; height: 100%; overflow: hidden; background: var(--color-canvas); cursor: grab; user-select: none; -webkit-user-select: none; touch-action: none; }
.family-canvas { position: absolute; inset: 0; width: 100%; height: 100%; overflow: hidden; touch-action: none; overscroll-behavior: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.family-tree.has-grid { background-image: radial-gradient(circle, rgba(23,45,51,.07) .65px, transparent .75px); background-size: 24px 24px; }
.family-tree.is-panning, .family-tree[data-panning="true"] { cursor: grabbing; }
.viewport-transform { transform-origin: 0 0; }
.relationships, .generation-labels, .people { overflow: visible; }
.relationships path { fill: none; stroke: #C8CBC6; stroke-width: 1; opacity: .55; vector-effect: non-scaling-stroke; stroke-linecap: round; stroke-linejoin: round; transition: stroke .12s ease, stroke-width .12s ease, opacity .12s ease; }
.relationships path.partner { stroke-dasharray: 3 4; }
.relationships path.relation-probable { stroke: #718FA0; stroke-dasharray: 2 3; }
.relationships path.highlight, .relationships path.hover-highlight { stroke: var(--color-accent); stroke-width: 1.75; opacity: 1; }
.relationships path.relation-warning { stroke: var(--color-warning); }
.generation-label { fill: var(--color-text-tertiary); font-family: var(--sans); font-size: 11px; font-weight: 400; }

.person-node { cursor: pointer; outline: none; user-select: none; -webkit-user-select: none; transition: opacity var(--duration-fast) ease; }
.person-node rect { fill: var(--color-surface); stroke: var(--color-border); stroke-width: 1; vector-effect: non-scaling-stroke; transition: fill var(--duration-fast) ease, stroke var(--duration-fast) ease; }
.person-node .status-line { stroke-width: 3; vector-effect: non-scaling-stroke; }
.person-node .node-name { fill: var(--color-text-primary); font-family: var(--sans); font-size: 13px; font-weight: 500; }
.person-node .node-years { fill: var(--color-text-secondary); font-family: var(--sans); font-size: 11px; font-weight: 400; }
.person-node .node-place, .person-node .node-sources, .person-node .node-status-text { fill: var(--color-text-secondary); font-family: var(--sans); font-size: 10px; font-weight: 400; }
.person-node .node-status-text { fill: var(--color-text-tertiary); }
.person-node .selection-dot { fill: var(--color-accent); }
.person-node:hover rect, .person-node:focus-visible rect { fill: #FFFFFF; stroke: #AEB5B2; }
.person-node.selected rect { fill: #FFFFFF; stroke: var(--color-accent); stroke-width: 1.5; }
.person-node.focused rect { fill: var(--color-accent-soft); stroke: var(--color-accent); stroke-width: 1.5; }
.person-node.dimmed { opacity: .55; }
.person-node.dismissed { opacity: .5; }
.person-node.hover-related { opacity: 1; }
.person-node .node-name, .person-node .node-years, .person-node .node-place, .person-node .node-sources, .person-node .node-status-text { pointer-events: none; }
.person-node.placeholder rect { fill: var(--color-surface); stroke: var(--color-border-strong); stroke-dasharray: 4 4; }
.person-node.placeholder .node-name { fill: var(--color-text-secondary); }
.person-node.placeholder .status-line { stroke: var(--color-text-disabled); }
.family-tree[data-detail-level="overview"] .person-node:not(.primary) rect { fill: transparent; stroke: transparent; }
.family-tree[data-detail-level="overview"] .person-node:not(.primary) .node-name { display: none; }
.family-tree[data-detail-level="overview"] .person-node:not(.primary) .status-line { stroke: #C8CBC6; stroke-width: 8; }
.family-tree[data-detail-level="overview"] .person-node.primary .node-name { font-size: 11px; }
.family-tree[data-detail-level="overview"] .node-years, .family-tree[data-detail-level="overview"] .node-place, .family-tree[data-detail-level="overview"] .node-sources, .family-tree[data-detail-level="overview"] .node-status-text { display: none; }
.family-tree[data-detail-level="names"] .node-years, .family-tree[data-detail-level="names"] .node-place, .family-tree[data-detail-level="names"] .node-sources, .family-tree[data-detail-level="names"] .node-status-text { display: none; }
.family-tree[data-detail-level="standard"] .node-place, .family-tree[data-detail-level="standard"] .node-sources, .family-tree[data-detail-level="standard"] .node-status-text { display: none; }
.family-tree[data-detail-level="detail"] .node-status-text, .family-tree[data-detail-level="research"] .node-status-text { display: block; }

.view-context { position: absolute; z-index: 5; top: 24px; right: 28px; display: flex; align-items: flex-start; gap: 8px; max-width: min(320px, calc(100vw - 56px)); padding: 6px 8px; color: var(--color-text-secondary); font-size: var(--font-12); line-height: 1.3; pointer-events: none; }
.view-context strong { display: block; color: var(--color-text-primary); font-size: var(--font-13); font-weight: 600; }
.view-context span:not(.focus-dot) { display: block; margin-top: 2px; }
.focus-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--color-accent); }
.overview-notice { position: absolute; z-index: 6; top: 24px; left: 50%; max-width: min(520px, calc(100vw - 48px)); padding: 7px 12px; border: 1px solid var(--color-border); border-radius: 999px; color: var(--color-text-secondary); background: rgba(252,251,248,.94); box-shadow: var(--shadow-floating); transform: translateX(-50%); font-size: var(--font-12); text-align: center; pointer-events: none; }

.tool-palette, .zoom-controls { position: absolute; z-index: 10; display: flex; align-items: center; height: 48px; padding: 4px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: rgba(252,251,248,.96); box-shadow: var(--shadow-floating); }
.tool-palette { left: 28px; bottom: 28px; gap: 2px; width: auto; transition: width var(--duration-standard) var(--ease-standard); }
.tool-palette.search-open { width: 420px; }
.palette-button { position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-width: 40px; height: 40px; padding: 0 12px; border: 0; border-radius: var(--radius-sm); color: var(--color-text-primary); background: transparent; font-size: var(--font-14); }
.palette-button:hover { background: var(--color-surface-hover); }.palette-button[aria-expanded="true"] { background: #E8E6DF; }
.palette-label { white-space: nowrap; }.icon { display: inline-block; width: 16px; height: 16px; background-position: center; background-repeat: no-repeat; background-size: 16px 16px; }
.palette-search-trigger .icon, .search-field-wrap > .icon { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23172D33' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E"); }
#filterTrigger .icon { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23172D33' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6h16M7 12h10M10 18h4'/%3E%3C/svg%3E"); }
.icon-button { display: inline-grid; place-items: center; min-width: 40px; height: 40px; padding: 0; border: 0; border-radius: var(--radius-sm); color: var(--color-text-primary); background: transparent; }
.icon-button:hover { background: var(--color-surface-hover); }.icon-button .icon { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23172D33' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 6l12 12M18 6 6 18'/%3E%3C/svg%3E"); }
.filter-active-dot { position: absolute; top: 7px; right: 7px; width: 5px; height: 5px; border-radius: 50%; background: var(--color-accent); opacity: 0; }
.palette-button.filter-active .filter-active-dot { opacity: 1; }

.popover { position: absolute; z-index: 20; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); box-shadow: var(--shadow-floating); animation: popover-in var(--duration-standard) var(--ease-standard); }
.search-popover { left: 28px; bottom: 84px; width: 420px; padding: 4px; }
.search-field-wrap { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 4px 0 12px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface); }
.search-field-wrap input { flex: 1; min-width: 0; height: 36px; border: 0; outline: 0; color: var(--color-text-primary); background: transparent; }
.search-results { max-height: 420px; margin-top: 8px; overflow-y: auto; }.search-result { display: flex; align-items: center; width: 100%; min-height: 56px; padding: 8px 12px; border: 0; border-radius: var(--radius-sm); color: var(--color-text-primary); background: transparent; text-align: left; }.search-result:hover, .search-result:focus-visible { background: var(--color-surface-hover); outline: 0; }.search-result strong { display: block; font-size: var(--font-14); font-weight: 500; }.search-result span { display: block; color: var(--color-text-secondary); font-size: var(--font-12); }
.filter-popover { left: 28px; bottom: 84px; width: 300px; max-height: 520px; padding: 16px; overflow-y: auto; }
.popover-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -4px -4px 12px; padding: 0 0 8px 4px; border-bottom: 1px solid var(--color-border); }.popover-heading h2 { margin: 0; color: var(--color-text-primary); font-size: var(--font-16); font-weight: 600; }.popover-heading .icon-button { min-width: 32px; width: 32px; height: 32px; }
.filter-section { margin-top: 16px; }.filter-section h3 { margin: 0 0 8px; color: var(--color-text-secondary); font-size: var(--font-12); font-weight: 500; }.filter-help { margin: -3px 0 9px; color: var(--color-text-tertiary); font-size: var(--font-11); line-height: 1.4; }.segmented-control { display: flex; gap: 2px; }.segmented-control button { min-height: 32px; padding: 0 8px; border: 0; border-radius: var(--radius-sm); color: var(--color-text-secondary); background: transparent; font-size: var(--font-12); }.segmented-control button:hover { background: var(--color-surface-hover); }.segmented-control button[aria-pressed="true"] { color: var(--color-text-primary); background: #E8E6DF; }
.generation-select { width: 100%; height: 40px; padding: 0 10px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); color: var(--color-text-primary); background: var(--color-surface); font: inherit; font-size: var(--font-13); }
.stepper { display: inline-flex; align-items: center; height: 40px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); }.stepper button { width: 40px; height: 38px; border: 0; color: var(--color-text-primary); background: transparent; font-size: 18px; }.stepper button:hover { background: var(--color-surface-hover); }.stepper output { min-width: 40px; text-align: center; font-size: var(--font-14); }.check-list { display: grid; gap: 8px; }.check-list label { display: flex; align-items: center; gap: 8px; color: var(--color-text-primary); font-size: var(--font-13); }.check-list input { width: 16px; height: 16px; margin: 0; accent-color: var(--color-accent); }.text-button { padding: 0; border: 0; color: var(--color-accent); background: transparent; font-size: var(--font-12); }.text-button:hover { color: var(--color-accent-hover); text-decoration: underline; }.reset-button { margin-top: 20px; }.view-row, .switch-row { display: flex; align-items: center; justify-content: space-between; min-height: 40px; border-bottom: 1px solid var(--color-border); color: var(--color-text-primary); font-size: var(--font-13); }.view-row strong { font-weight: 500; color: var(--color-text-secondary); }.switch-row { position: relative; gap: 14px; cursor: pointer; }.switch-row input { position: absolute; opacity: 0; }.switch-row i { position: relative; width: 32px; height: 18px; flex: 0 0 auto; border: 1px solid var(--color-border-strong); border-radius: 10px; background: var(--color-surface-hover); }.switch-row i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--color-text-tertiary); transition: transform var(--duration-fast) ease, background var(--duration-fast) ease; }.switch-row input:checked + i { border-color: var(--color-accent); background: var(--color-accent-soft); }.switch-row input:checked + i::after { background: var(--color-accent); transform: translateX(14px); }

.zoom-controls { right: 28px; bottom: 28px; width: 208px; height: 40px; border-radius: 8px; }.zoom-controls button { width: 40px; height: 32px; padding: 0; border: 0; border-radius: var(--radius-sm); color: var(--color-text-primary); background: transparent; font-size: 18px; }.zoom-controls button:hover { background: var(--color-surface-hover); }.zoom-controls .zoom-readout { width: 56px; color: var(--color-text-secondary); font-size: var(--font-12); }.zoom-controls #homeView, .zoom-controls #fitView { width: 32px; margin-left: auto; }.zoom-controls #fitView { margin-left: 0; }.zoom-controls #homeView .icon { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23172D33' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='7'/%3E%3Cpath d='M12 8v8M8 12h8'/%3E%3C/svg%3E"); }.zoom-controls #fitView .icon { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23172D33' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 3H3v5M16 3h5v5M8 21H3v-5M21 16v5h-5'/%3E%3C/svg%3E"); }

.person-panel { position: absolute; z-index: 30; top: 12px; right: 12px; width: 380px; height: calc(100vh - 24px); overflow: hidden; border: 1px solid var(--color-border); border-radius: var(--radius-panel); background: var(--color-surface); box-shadow: 0 8px 40px rgba(23,45,51,.10); transform: translateX(calc(100% + 24px)); transition: transform var(--duration-standard) var(--ease-standard); }.person-panel.open { transform: translateX(0); }.person-panel-header { display: flex; justify-content: flex-end; padding: 12px 16px 0; }.person-panel-header .icon-button { min-width: 40px; }.person-panel-scroll { height: calc(100% - 52px); padding: 12px 24px 28px; overflow-y: auto; }.person-panel-title { margin: 0; color: var(--color-text-primary); font-family: var(--serif); font-size: var(--font-28); font-weight: 400; line-height: 1.05; }.person-panel-context { margin-top: 5px; color: var(--color-text-secondary); font-size: var(--font-12); }.person-panel-years { margin-top: 6px; color: var(--color-text-secondary); font-size: var(--font-14); }.person-panel-status { display: inline-flex; align-items: center; gap: 7px; margin-top: 20px; color: var(--color-text-primary); font-size: var(--font-13); }.status-symbol { width: 18px; text-align: center; font-size: 16px; }.person-fields { display: grid; gap: 16px; margin-top: 24px; }.person-field dt { margin: 0 0 3px; color: var(--color-text-tertiary); font-size: var(--font-11); }.person-field dd { margin: 0; color: var(--color-text-primary); font-size: var(--font-14); }.person-field dd + dd { color: var(--color-text-secondary); }.person-field-meta { font-size: var(--font-11) !important; }.person-panel-warning { margin: 16px 0 0; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--color-warning); background: var(--color-warning-soft); font-size: var(--font-12); }.panel-rule { height: 1px; margin: 24px 0; border: 0; background: var(--color-border); }.panel-section h3 { display: flex; align-items: center; justify-content: space-between; margin: 0 0 8px; color: var(--color-text-primary); font-size: var(--font-13); font-weight: 600; }.panel-section + .panel-section { margin-top: 24px; }.relation-group-label { margin: 12px 0 4px; color: var(--color-text-tertiary); font-size: var(--font-11); }.relation-link { display: block; width: calc(100% + 16px); margin-left: -8px; padding: 8px; border: 0; border-radius: var(--radius-sm); color: var(--color-text-primary); background: transparent; text-align: left; }.relation-link:hover { background: var(--color-surface-hover); }.relation-link strong { display: block; font-size: var(--font-13); font-weight: 500; }.relation-link span { display: block; margin-top: 2px; color: var(--color-text-secondary); font-size: var(--font-12); }.source-summary, .research-summary { display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 0; border: 0; color: var(--color-text-primary); background: transparent; font-size: var(--font-13); text-align: left; }.source-summary:hover, .research-summary:hover { color: var(--color-accent); }.source-count, .research-count { color: var(--color-text-secondary); }.detail-list-item { padding: 10px 0; border-bottom: 1px solid var(--color-border); }.detail-list-item:last-child { border-bottom: 0; }.detail-list-item strong { display: block; color: var(--color-text-primary); font-size: var(--font-13); font-weight: 500; }.detail-list-item p { margin: 3px 0 0; color: var(--color-text-secondary); font-size: var(--font-12); line-height: 1.45; }.panel-empty { margin: 40px 0; color: var(--color-text-secondary); font-size: var(--font-13); }

.context-menu { position: fixed; z-index: 60; width: 220px; padding: 6px; border: 1px solid var(--color-border); border-radius: var(--radius-md); background: var(--color-surface); box-shadow: var(--shadow-floating); }.context-menu button { display: flex; align-items: center; width: 100%; height: 36px; padding: 0 10px; border: 0; border-radius: var(--radius-sm); color: var(--color-text-primary); background: transparent; font-size: var(--font-13); text-align: left; }.context-menu button:hover { background: var(--color-surface-hover); }.context-menu hr { height: 1px; margin: 6px 0; border: 0; background: var(--color-border); }
.drawer-backdrop { position: absolute; z-index: 25; inset: 0; background: transparent; }.source-viewer { position: absolute; z-index: 70; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(23,45,51,.16); }.source-viewer-card { width: min(640px, 100%); max-height: calc(100vh - 48px); overflow: auto; border: 1px solid var(--color-border); border-radius: var(--radius-panel); background: var(--color-surface); box-shadow: var(--shadow-floating); }.source-viewer-card .popover-heading { margin: 0; padding: 16px 16px 8px 24px; }.source-viewer-content { padding: 8px 24px 28px; }.source-viewer-content p { color: var(--color-text-secondary); font-size: var(--font-13); }.source-viewer-content dl { margin: 20px 0 0; }.source-viewer-content dl > div { display: grid; grid-template-columns: 140px 1fr; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--color-border); }.source-viewer-content dt { color: var(--color-text-tertiary); font-size: var(--font-11); }.source-viewer-content dd { margin: 0; color: var(--color-text-primary); font-size: var(--font-13); overflow-wrap: anywhere; }.source-viewer-content a { color: var(--color-accent); }
.toast { position: absolute; z-index: 80; right: 28px; bottom: 84px; width: 320px; min-height: 48px; padding: 14px 16px; border: 1px solid var(--color-border); border-radius: var(--radius-md); color: var(--color-text-primary); background: var(--color-surface); box-shadow: var(--shadow-floating); font-size: var(--font-13); }
.onboarding { position: absolute; z-index: 8; bottom: 88px; left: 50%; display: flex; align-items: center; gap: 12px; padding: 8px 12px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); color: var(--color-text-secondary); background: var(--color-surface); box-shadow: var(--shadow-floating); transform: translateX(-50%); font-size: var(--font-12); }.onboarding button { width: 24px; height: 24px; border: 0; color: var(--color-text-secondary); background: transparent; font-size: 18px; }
.canvas-status { position: absolute; z-index: 100; top: 50%; left: 50%; display: grid; justify-items: center; gap: 4px; color: var(--color-text-secondary); transform: translate(-50%, -50%); transition: opacity 160ms ease; }.canvas-status strong { color: var(--color-text-primary); font-family: var(--serif); font-size: var(--font-22); font-weight: 500; }.canvas-status span { font-size: var(--font-13); }.canvas-status i { width: 80px; height: 1px; margin-top: 8px; background: var(--color-border-strong); }.canvas-status.loaded { opacity: 0; pointer-events: none; }
.empty-state { position: absolute; top: 50%; left: 50%; display: grid; justify-items: center; gap: 8px; transform: translate(-50%, -50%); text-align: center; }.empty-state h1 { margin: 0; font-family: var(--serif); font-size: var(--font-28); font-weight: 400; }.empty-state p { margin: 0 0 12px; color: var(--color-text-secondary); }
.button { min-height: 40px; padding: 0 14px; border-radius: var(--radius-sm); }.button-primary { border: 0; color: #FFFFFF; background: var(--color-accent); }.button-primary:hover { background: var(--color-accent-hover); }
.legacy-compat { display: none; }

.mobile-toolbar, .mobile-minimap { display: none; }
.mobile-bottom-sheet { touch-action: pan-y; }

@keyframes popover-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 80ms !important; transition-duration: 80ms !important; scroll-behavior: auto !important; } }
@media (max-width: 1439px) { .person-panel { width: 360px; }.tool-palette { left: 20px; bottom: 20px; }.zoom-controls { right: 20px; bottom: 20px; }.search-popover, .filter-popover { left: 20px; bottom: 76px; } }
@media (max-width: 1023px) { .person-panel { width: 340px; }.palette-label { display: none; }.palette-button { width: 40px; padding: 0; }.tool-palette.search-open { width: 300px; }.search-popover { width: 300px; }.view-context { right: 20px; }.zoom-controls { right: 20px; } }
@media (max-width: 767px) { .view-context { top: 16px; right: 16px; max-width: calc(100vw - 32px); }.overview-notice { top: 16px; max-width: calc(100vw - 32px); }.tool-palette { left: 12px; bottom: 12px; }.zoom-controls { display: none; }.search-popover, .filter-popover { left: 12px; bottom: 68px; width: calc(100vw - 24px); max-width: 420px; }.person-panel { top: auto; right: 0; bottom: 0; width: 100%; height: min(72vh, 620px); max-height: 620px; border-right: 0; border-bottom: 0; border-radius: 14px 14px 0 0; transform: translateY(105%); }.person-panel.open { transform: translateY(0); }.person-panel-scroll { padding-right: 20px; padding-left: 20px; }.onboarding { bottom: 72px; white-space: nowrap; }.toast { right: 12px; bottom: 68px; width: calc(100% - 24px); }.source-viewer { padding: 12px; }.source-viewer-card { max-height: calc(100vh - 24px); } }

@media (max-width: 767px) {
  html, body, #app { width: 100%; height: 100%; margin: 0; overflow: hidden; }
  body.tree-view-open { overscroll-behavior: none; }
  .canvas-shell { position: fixed; inset: 0; width: 100%; height: 100vh; height: 100dvh; overflow: hidden; }
  .family-tree { touch-action: none; overscroll-behavior: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
  .person-node { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
  .tool-palette { display: none !important; }
  .mobile-toolbar { position: fixed; left: 50%; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 50; display: flex; align-items: center; height: 52px; padding: 4px; gap: 2px; background: rgba(252,251,248,.97); border: 1px solid var(--color-border); border-radius: 12px; box-shadow: var(--shadow-floating); transform: translateX(-50%); pointer-events: auto; }
  .mobile-toolbar-button { position: relative; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border: 0; border-radius: var(--radius-sm); color: var(--color-text-primary); background: transparent; }
  .mobile-toolbar-button:active, .mobile-toolbar-button[aria-expanded="true"] { background: #E8E6DF; }
  .mobile-toolbar-button .icon { width: 18px; height: 18px; background-size: 18px 18px; }
  .mobile-toolbar-button .icon-search, .mobile-toolbar-button:first-child .icon { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23172D33' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E"); }
  .mobile-toolbar-button .icon-filter, .mobile-toolbar-button:nth-child(2) .icon { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23172D33' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6h16M7 12h10M10 18h4'/%3E%3C/svg%3E"); }
  .mobile-toolbar-button .icon-home { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23172D33' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M2 12h3M19 12h3M12 2v3M12 19v3'/%3E%3C/svg%3E"); }
  .mobile-toolbar-button .icon-overview { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23172D33' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 3H3v5M16 3h5v5M8 21H3v-5M21 16v5h-5'/%3E%3C/svg%3E"); }
  .filter-active-dot { position: absolute; top: 7px; right: 7px; width: 5px; height: 5px; border-radius: 50%; background: var(--color-accent); opacity: 0; }
  .mobile-toolbar-button.filter-active .filter-active-dot { opacity: 1; }
  .popover.mobile-sheet { position: fixed; z-index: 100; right: 0; bottom: 0; left: 0; width: 100%; max-width: none; border-right: 0; border-bottom: 0; border-radius: 16px 16px 0 0; box-shadow: 0 -8px 36px rgba(23,45,51,.14); animation: mobile-sheet-in 160ms var(--ease-standard); touch-action: pan-y; }
  .search-popover.mobile-sheet { min-height: 70dvh; max-height: calc(100dvh - 12px); padding: 10px 16px calc(24px + env(safe-area-inset-bottom)); }
  .filter-popover.mobile-sheet { max-height: 82dvh; padding: 10px 20px calc(24px + env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; }
  .mobile-sheet-handle { width: 38px; height: 4px; margin: 0 auto 12px; border-radius: 4px; background: #C8CBC6; }
  .mobile-sheet .popover-heading { margin-top: 0; }
  .mobile-sheet .search-results { max-height: calc(70dvh - 90px); overflow-y: auto; overscroll-behavior: contain; }
  .drawer-backdrop { z-index: 90; background: rgba(23,45,51,.08); }
  .person-panel.mobile-sheet { position: fixed; top: auto; right: 0; bottom: 0; left: 0; width: 100%; height: 42dvh; max-height: none; border-radius: 16px 16px 0 0; transform: translateY(105%); transition: height 160ms var(--ease-standard), transform 180ms var(--ease-standard); box-shadow: 0 -8px 36px rgba(23,45,51,.14); touch-action: pan-y; }
  .person-panel.mobile-sheet.sheet-expanded { height: 88dvh; }
  .person-panel.mobile-sheet.open { transform: translateY(0); }
  .person-panel.mobile-sheet .person-panel-header { padding-top: 0; }
  .person-panel.mobile-sheet .person-panel-scroll { height: calc(100% - 48px); padding-bottom: calc(28px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
  .person-panel.mobile-sheet .mobile-sheet-handle { margin-top: 10px; }
  .view-context { top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); }
  .onboarding { bottom: calc(70px + env(safe-area-inset-bottom)); max-width: calc(100vw - 24px); overflow: hidden; }
  .toast { right: 12px; bottom: calc(70px + env(safe-area-inset-bottom)); width: calc(100% - 24px); }
  .mobile-minimap { position: absolute; z-index: 40; right: max(12px, env(safe-area-inset-right)); bottom: calc(70px + env(safe-area-inset-bottom)); display: block; width: 132px; height: 90px; padding: 5px; border: 1px solid var(--color-border); border-radius: 10px; background: rgba(252,251,248,.92); box-shadow: var(--shadow-floating); pointer-events: auto; }
  .mobile-minimap[hidden] { display: none; }
  .mobile-minimap svg { display: block; width: 100%; height: 100%; overflow: visible; }
  .mobile-minimap .minimap-edge { fill: none; stroke: #B9BDBC; stroke-width: .7; vector-effect: non-scaling-stroke; }
  .mobile-minimap .minimap-node { fill: #C8CBC6; }
  .mobile-minimap .minimap-node.status-probable { fill: #718FA0; }
  .mobile-minimap .minimap-viewport { fill: rgba(23,107,103,.08); stroke: var(--color-accent); stroke-width: 1; vector-effect: non-scaling-stroke; }
  .mobile-minimap .minimap-focus { fill: var(--color-accent); }
  .family-tree[data-detail-level="overview"] .relationships path { stroke-width: 1.2; }
  .family-tree[data-detail-level="overview"] .person-node .overview-hit { fill: transparent; }
  .family-tree[data-detail-level="overview"] .person-node .overview-dot { stroke: none; }
  .family-tree .mobile-overview .overview-name { fill: var(--color-text-secondary); font-family: var(--sans); font-size: 10px; font-weight: 500; pointer-events: none; }
  .family-tree .mobile-navigation rect { fill: var(--color-surface); stroke: var(--color-border); }
  .family-tree .mobile-navigation .node-name { fill: var(--color-text-primary); font-family: var(--sans); font-size: 10.5px; line-height: 12px; font-weight: 500; }
  .family-tree .mobile-navigation .node-years { fill: var(--color-text-secondary); font-family: var(--sans); font-size: 10px; }
  .family-tree .mobile-standard rect, .family-tree .mobile-detail rect { fill: var(--color-surface); stroke: var(--color-border); }
  .family-tree .mobile-standard .node-name, .family-tree .mobile-detail .node-name { fill: var(--color-text-primary); font-family: var(--sans); font-size: 14px; line-height: 16px; font-weight: 500; }
  .family-tree .mobile-standard .node-years, .family-tree .mobile-detail .node-years { fill: var(--color-text-secondary); font-family: var(--sans); font-size: 12px; }
  .family-tree .mobile-detail .node-place, .family-tree .mobile-detail .node-status-text { fill: var(--color-text-tertiary); font-family: var(--sans); font-size: 10px; }
  .family-tree .mobile-navigation.selected rect, .family-tree .mobile-standard.selected rect, .family-tree .mobile-detail.selected rect { stroke: var(--color-accent); stroke-width: 1.5; }
  .family-tree .mobile-navigation.focused rect, .family-tree .mobile-standard.focused rect, .family-tree .mobile-detail.focused rect { fill: var(--color-accent-soft); stroke: var(--color-accent); stroke-width: 1.5; }
}

@keyframes mobile-sheet-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Content states added for the usability audit. */
.search-result-count { margin: 8px 12px 4px; color: var(--color-text-tertiary); font-size: var(--font-11); }
.research-note { padding: 12px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); background: var(--color-surface-hover); }
.research-note + .research-note { margin-top: 10px; }
.research-note-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; color: var(--color-text-tertiary); font-size: var(--font-11); }
.research-note h3, .research-note h4 { margin: 10px 0 2px; color: var(--color-text-secondary); font-size: var(--font-11); font-weight: 600; }
.research-note h3 { margin-top: 8px; }
.research-note p { margin: 0; color: var(--color-text-primary); font-size: var(--font-13); line-height: 1.45; }
.source-primary-action { display: inline-flex; width: 100%; justify-content: center; margin: 4px 0 8px; text-decoration: none; }
.source-technical-details { margin-top: 20px; border-top: 1px solid var(--color-border); }
.source-technical-details summary { padding: 12px 0 4px; color: var(--color-text-secondary); cursor: pointer; font-size: var(--font-12); }
.source-technical-details p { margin: 8px 0 0; }
