:root {
  color-scheme: dark;
  --panel: #172126;
  --panel-2: #24302d;
  --line: #3c4945;
  --text: #f2eee4;
  --muted: #b5beb8;
  --accent: #b77959;
  --accent-2: #91a197;
  --panel-width: 390px;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #05080b; color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.explorer-view { position: fixed !important; inset: 0 var(--panel-width) 0 0; }
#globe { background: #dce3df; }
.content-view { overflow: auto; background: radial-gradient(circle at 20% 0%, #1b2b34 0, #0c1318 42%, #06090c 100%); }
#constellation-view { overflow: hidden; touch-action: none; cursor: grab; background: radial-gradient(circle at 48% 44%, #1b3441 0, #09131a 38%, #030609 100%); perspective: 1100px; }
#constellation-view::before { content: ''; position: absolute; inset: 0; opacity: .38; pointer-events: none; background-image: radial-gradient(circle, rgba(255,255,255,.8) 0 1px, transparent 1.5px), radial-gradient(circle, rgba(127,199,184,.55) 0 1px, transparent 1.5px); background-position: 0 0, 53px 81px; background-size: 137px 137px, 211px 211px; }
#constellation-view.dragging { cursor: grabbing; }
.panel { position: fixed; z-index: 20; width: var(--panel-width); right: 0; top: 0; bottom: 0; overflow-y: auto; background: linear-gradient(180deg, rgba(22,31,39,.98), rgba(9,14,18,.99)); border-left: 1px solid #344651; padding: 26px 24px 34px; box-shadow: -18px 0 50px rgba(0,0,0,.35); }
header { padding-bottom: 19px; border-bottom: 1px solid var(--line); }
.eyebrow { color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: .22em; margin: 0 0 7px; }
h1 { font-family: Georgia, serif; font-size: 34px; font-weight: 500; line-height: 1; margin: 0; }
.intro { color: var(--muted); margin: 10px 0 0; }
.view-nav { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 18px; padding: 4px; border-radius: 8px; background: #101815; }
.view-tab { border: 0; border-radius: 5px; padding: 8px 3px; color: var(--muted); background: transparent; font-size: 11px; }
.view-tab.active { color: #0b1513; background: var(--accent-2); font-weight: 800; }
h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .14em; color: #c9d1d5; margin: 0 0 13px; }
section { padding: 20px 0; border-bottom: 1px solid var(--line); }
label { color: #cbd4d9; font-size: 12px; }
input[type="search"], input[type="email"], input[type="password"], input[type="text"], input[type="date"], input[inputmode="numeric"], textarea, select { color: var(--text); background: #101715; border: 1px solid #56635d; border-radius: 8px; padding: 12px; outline: none; width: 100%; }
input:focus, select:focus { border-color: var(--accent-2); box-shadow: 0 0 0 2px rgba(127,199,184,.14); }
.auth-gate { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 24px; overflow-y: auto; background: radial-gradient(circle at 30% 20%, #314039 0, #17211e 42%, #0b100e 100%); }
.auth-gate[hidden] { display: none; }
.login-card { width: min(520px, 100%); margin: auto; padding: 42px; border: 1px solid #68766e; border-radius: 18px; background: rgba(23,33,30,.98); box-shadow: 0 30px 100px rgba(0,0,0,.48); }
.login-card h1 { margin: 5px 0 12px; font-family: Georgia, serif; font-size: 45px; font-weight: 500; }
.login-card > p:not(.eyebrow):not(.login-error) { color: var(--muted); line-height: 1.55; }
.login-card label { display: grid; gap: 8px; margin-top: 19px; color: #f2eee4; font-size: 16px; font-weight: 650; }
.login-card input, .login-card textarea { min-height: 52px; font-size: 18px; }
.login-card textarea { min-height: 76px; resize: vertical; }
.auth-lead { font-size: 17px; }
.auth-help, .field-help { color: var(--muted); font-size: 14px; line-height: 1.5; }
.optional { color: var(--muted); font-size: 13px; font-weight: 400; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 78px; }
.show-password { position: absolute; right: 7px; top: 7px; min-width: 62px; height: 38px; border: 1px solid #66756d; border-radius: 7px; color: var(--text); background: #27332e; font-weight: 700; }
.large-action { min-height: 52px; font-size: 17px; }
.secondary { width: 100%; min-height: 46px; margin-top: 10px; border: 1px solid #718078; border-radius: 8px; color: var(--text); background: transparent; font-weight: 750; }
.form-message { margin: 16px 0 0; padding: 13px; border-radius: 8px; line-height: 1.45; }
.form-message.success { color: #e5f3e8; background: #2c5540; }
.form-message.error { color: #ffe2dd; background: #713e37; }
.login-error { margin: 14px 0 0; color: #ffaaa4; }
.signed-in-user { color: var(--accent-2); font-size: 11px; overflow: hidden; text-overflow: ellipsis; }
.search-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 8px; }
.search-row button { border: 0; border-radius: 7px; padding: 0 14px; color: #07100e; background: var(--accent-2); font-weight: 750; }
.search-results { margin-top: 7px; border: 1px solid #344651; border-radius: 7px; max-height: 220px; overflow: auto; background: #0a1014; }
.search-results button { width: 100%; text-align: left; border: 0; border-bottom: 1px solid #26343d; padding: 10px 11px; color: var(--text); background: transparent; }
.search-results button:hover { background: #1b2931; }
.search-results small { display: block; color: var(--muted); margin-top: 2px; }
.selected-root { margin-top: 10px; padding: 11px; border-radius: 7px; background: rgba(224,168,77,.10); border: 1px solid rgba(224,168,77,.35); color: #f6d8a6; }
.selected-root.empty { background: transparent; border-color: #27363f; color: var(--muted); }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; background: #090e12; border-radius: 8px; padding: 4px; }
.segmented input, .chip-grid input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 8px 4px; text-align: center; border-radius: 5px; font-size: 11px; }
.segmented input:checked + span { color: #08100f; background: var(--accent-2); font-weight: 750; }
.range-heading { display: flex; justify-content: space-between; margin-top: 17px; }
.depth-section .range-heading { margin-top: 0; }
.range-heading output { color: var(--accent); font-weight: 800; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.control-help { margin: 7px 0 0; color: var(--muted); font-size: 10px; line-height: 1.4; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.checks label { display: flex; gap: 7px; align-items: flex-start; }
.checks input { accent-color: var(--accent-2); }
.layer-checks { display: grid; gap: 8px; margin-top: 12px; }
.layer-checks label { display: grid; grid-template-columns: 18px 1fr; gap: 9px; align-items: start; padding: 9px 10px; border: 1px solid rgba(126,163,180,.18); border-radius: 10px; background: rgba(8,18,23,.34); cursor: pointer; }
.layer-checks label:has(input:checked) { border-color: rgba(224,168,77,.48); background: rgba(224,168,77,.07); }
.layer-checks label:has(input:disabled) { opacity: .48; cursor: not-allowed; }
.layer-checks input { margin-top: 3px; accent-color: var(--accent); }
.layer-checks span { display: grid; gap: 2px; }
.layer-checks strong { font-size: 12px; color: var(--text); }
.layer-checks small { color: var(--muted); font-size: 10px; line-height: 1.35; }
.layer-action { margin-top: 10px; }
.chip-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-grid span { display: block; padding: 6px 9px; border: 1px solid #33444e; border-radius: 20px; color: var(--muted); }
.chip-grid input:checked + span { color: #11201c; background: var(--accent-2); border-color: var(--accent-2); }
.year-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.year-grid label { display: grid; gap: 6px; }
.primary { width: 100%; border: 0; color: #171006; background: linear-gradient(135deg, #f0c16f, var(--accent)); font-weight: 800; padding: 12px; border-radius: 8px; margin-top: 18px; box-shadow: 0 5px 18px rgba(224,168,77,.18); }
.summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.summary div { text-align: center; background: #0a1014; padding: 11px 4px; border-radius: 7px; border: 1px solid #26343d; }
.summary strong { display: block; font-family: Georgia, serif; color: var(--accent); font-size: 24px; font-weight: 500; }
.summary span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }
.surname-list { display: flex; gap: 6px; flex-wrap: wrap; }
.surname-list button { color: #cdd5d9; background: #101a20; border: 1px solid #344651; border-radius: 20px; padding: 6px 9px; font-size: 11px; }
.surname-list button.active { color: #111; background: var(--accent); border-color: var(--accent); }
.section-title { display: flex; justify-content: space-between; align-items: center; }
.section-title span { color: var(--muted); font-size: 11px; }
.event-list { display: grid; gap: 7px; max-height: 330px; overflow-y: auto; padding-right: 3px; }
.event-card { text-align: left; color: var(--text); background: #0b1217; border: 1px solid #293943; border-left: 3px solid var(--event-color, var(--accent)); border-radius: 6px; padding: 9px 10px; }
.event-card:hover { background: #152128; }
.event-card strong, .event-card span { display: block; }
.event-card strong { font-size: 12px; }
.event-card span { color: var(--muted); margin-top: 3px; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 20px; }
.text-button { padding: 0; background: none; border: 0; color: var(--muted); font-size: 11px; }
.text-button:hover { color: var(--text); }
.loading { position: fixed; z-index: 30; left: calc((100% - var(--panel-width))/2); top: 28px; transform: translateX(-50%); padding: 10px 15px; border: 1px solid #455863; border-radius: 30px; background: rgba(10,17,22,.9); box-shadow: 0 8px 28px rgba(0,0,0,.35); }
.loading span { display: inline-block; width: 9px; height: 9px; margin-right: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1s infinite alternate; }
#toast { position: fixed; z-index: 40; left: 18px; bottom: 18px; max-width: 430px; padding: 11px 14px; border-radius: 7px; color: #fff; background: #a53b36; opacity: 0; pointer-events: none; transform: translateY(10px); transition: .2s; }
#toast.show { opacity: 1; transform: none; }
.we-pp-content { color: #172129 !important; max-width: 310px; }
.we-pp-content h3 { margin: 0 0 5px; font-size: 15px; }
.we-pp-content p { margin: 3px 0; }

.admin-content { width: min(920px, calc(100% - 70px)); margin: 0 auto; padding: 64px 0 100px; }
.admin-content > h2 { margin: 5px 0 12px; color: var(--text); font-family: Georgia, serif; font-size: 42px; font-weight: 500; letter-spacing: -.02em; text-transform: none; }
.admin-content > p:not(.eyebrow) { color: var(--muted); font-size: 16px; }
.admin-requests { display: grid; gap: 18px; margin-top: 28px; }
.admin-request { padding: 24px; border: 1px solid #4b5b53; border-radius: 14px; background: rgba(23,33,30,.95); }
.admin-request header { display: flex; justify-content: space-between; gap: 18px; padding: 0 0 15px; }
.admin-request h3 { margin: 0 0 5px; font-size: 23px; }
.admin-request a { color: #c6d5cc; }
.request-status { color: #d3aa89; font-size: 11px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.request-status.status-pending { color: #f0c16f; }
.request-status.status-approved { color: #8ed5bc; }
.request-status.status-activated { color: #9bd8ac; }
.admin-request dl { display: grid; gap: 10px; }
.admin-request dl div { display: grid; grid-template-columns: 130px 1fr; gap: 14px; }
.admin-request dt { color: var(--muted); }
.admin-request dd { margin: 0; }
.admin-person-results { display: grid; margin-top: 5px; border-radius: 8px; overflow: hidden; }
.admin-person-results button { padding: 11px; border: 0; border-bottom: 1px solid #46534d; color: var(--text); background: #202b27; text-align: left; }
.admin-person-results small { color: var(--muted); }
.admin-selected-person { color: #d9b894; }
.workflow-state { margin: 18px 0; padding: 14px 16px; border-left: 4px solid #c9954b; border-radius: 5px; color: var(--muted); background: rgba(201,149,75,.08); font-size: 15px; line-height: 1.5; }
.workflow-state strong { color: var(--text); }
.workflow-state.success { border-left-color: #6ebd8e; background: rgba(110,189,142,.08); }
.admin-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.admin-actions.single { grid-template-columns: 1fr; }
.admin-actions .primary { margin-top: 0; }
.empty-admin { padding: 35px; border: 1px dashed #56635d; border-radius: 12px; text-align: center; }
.person-picker-dialog { width: min(620px, calc(100vw - 30px)); padding: 0; border: 1px solid #554e43; border-radius: 16px; color: var(--text); background: #211f1b; box-shadow: 0 24px 70px rgba(0,0,0,.45); }
.person-picker-dialog::backdrop { background: rgba(8,7,6,.78); }
.person-picker-card { position: relative; padding: 34px; }
.person-picker-card h2 { margin: 5px 42px 10px 0; color: var(--text); font-family: Georgia,serif; font-size: 32px; font-weight: 500; line-height: 1.1; letter-spacing: -.02em; text-transform: none; }
.person-picker-card > p:not(.eyebrow) { color: var(--muted); font-size: 16px; }
.person-picker-card > label { display: block; margin-top: 24px; font-size: 15px; font-weight: 700; }
.person-picker-close { position: absolute; right: 18px; top: 18px; width: 40px; height: 40px; border: 1px solid #5b5449; border-radius: 50%; color: var(--text); background: #171512; font-size: 24px; }
.person-picker-search-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 8px; }
.person-picker-search-row input { min-height: 52px; font-size: 17px; }
.person-picker-search-row > button { min-width: 82px; border: 0; border-radius: 8px; color: #fffaf0; background: #71313c; font-weight: 800; }
.person-picker-results { display: grid; gap: 6px; margin-top: 15px; max-height: min(390px, 45vh); overflow-y: auto; }
.person-picker-results > button { padding: 13px 14px; border: 1px solid #4c463d; border-radius: 8px; color: var(--text); background: #191816; text-align: left; }
.person-picker-results > button:hover { border-color: #a88a50; background: #28241e; }
.person-picker-results strong, .person-picker-results small { display: block; }
.person-picker-results small { margin-top: 3px; color: var(--muted); }

@media (max-width: 720px) {
  :root { --panel-width: 100%; }
  .auth-gate { align-items: start; padding: 12px; }
  .login-card { padding: 28px 22px; border-radius: 14px; }
  .login-card h1 { font-size: 42px; }
  .panel { width: 100%; top: auto; height: min(48vh, 430px); padding: 18px; border-left: 0; border-top: 1px solid #56635d; }
  .explorer-view { inset: 0 0 min(48vh, 430px) 0; }
  .view-nav { grid-template-columns: repeat(3, 1fr); }
  .view-tab { min-height: 40px; font-size: 13px; }
  .constellation-heading { left: 18px; top: 18px; }
  .constellation-heading > p:last-of-type, .pedigree-legend { display: none; }
  .constellation-controls { left: 18px; bottom: 18px; }
  .admin-content { width: calc(100% - 28px); padding: 28px 0 70px; }
  .admin-request dl div { grid-template-columns: 1fr; gap: 3px; }
}

/* Ramus archival palette: restrained print and record-office colours. */
:root {
  --panel: #191816;
  --panel-2: #24211d;
  --line: #403b34;
  --text: #eee8dc;
  --muted: #ada496;
  --accent: #a88a50;
  --accent-2: #8f3f4b;
}
html, body { background: #0e0d0c; }
.content-view, #constellation-view { background: #11110f; }
#constellation-view::before { opacity: .12; background-image: radial-gradient(circle, #8e8679 0 1px, transparent 1.5px); background-size: 152px 152px; }
.panel { background: #191816; border-color: #403b34; box-shadow: -8px 0 24px rgba(0,0,0,.22); }
.auth-gate { background: #171512; }
.login-card { border-color: #554e43; background: #211f1b; box-shadow: 0 20px 55px rgba(0,0,0,.32); }
.eyebrow { color: #b99b60; }
.view-nav, .segmented { background: #11100e; }
.view-tab.active { color: #f4eee2; background: #71313c; }
input[type="search"], input[type="email"], input[type="password"], input[type="text"], input[type="date"], input[inputmode="numeric"], textarea, select { border-color: #5b5449; background: #171512; }
input:focus, textarea:focus, select:focus { border-color: #a88a50; box-shadow: 0 0 0 2px rgba(168,138,80,.18); }
.primary { color: #fffaf0; background: #71313c; box-shadow: none; }
.primary:hover { background: #823b47; }
.secondary, .show-password { border-color: #686054; background: #29251f; }
.search-row button, .place-search-row button { color: #fffaf0; background: #71313c; }
.selected-root { color: #dbc89d; border-color: #665634; background: #282319; }
.story-hero, .place-chooser-hero, .research-hero { border-color: #4c463d; background: #1c1a17; box-shadow: none; }
.story-hero::after { display: none; }
.story-panel, .story-locations, .place-hero, .place-picker-section, .quality-panel { border-color: #403b34; background: #191816; }
.life-event, .person-pill, .place-card, .research-card, .admin-request { border-color: #403b34; background: #201e1a; }
.constellation-link { filter: none; }
.family-hub circle { filter: none; fill: #282319; }
.constellation-node rect { fill: #1d1c19; stroke: #6b6459; filter: drop-shadow(0 8px 12px rgba(0,0,0,.25)); }
.constellation-node.root rect { fill: #2a241b; stroke: #b09154; filter: none; }
.constellation-node.selected rect, .constellation-node.approaching rect { stroke: #d6c18f; filter: none; }
.constellation-node:hover rect { stroke: #b09154; }
.constellation-controls button, .pedigree-inspector-actions button { border-color: #585145; background: #211f1b; }
.pedigree-inspector { border-color: #554e43; background: #1d1b18; box-shadow: 0 18px 45px rgba(0,0,0,.35); backdrop-filter: none; }

.story-content { width: min(1050px, calc(100% - 80px)); margin: 0 auto; padding: 64px 0 100px; }
.story-hero { position: relative; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, 34%); align-items: stretch; gap: 35px; min-height: 300px; padding: 34px 38px 34px 50px; border: 1px solid #344651; border-radius: 20px; background: linear-gradient(135deg, rgba(27,45,55,.94), rgba(10,16,21,.96)); box-shadow: 0 25px 70px rgba(0,0,0,.28); }
.story-hero:not(:has(.story-portrait)) { grid-template-columns: 1fr; padding: 46px 50px; min-height: 240px; }
.story-identity { position: relative; z-index: 1; align-self: center; }
.story-hero::after { content: ''; position: absolute; width: 420px; height: 420px; right: -150px; top: -220px; border-radius: 50%; border: 1px solid rgba(224,168,77,.35); box-shadow: 0 0 90px rgba(224,168,77,.10); }
.story-hero h2 { max-width: 700px; margin: 7px 0 10px; color: var(--text); font-family: Georgia, serif; font-size: clamp(38px, 5vw, 68px); font-weight: 500; line-height: .98; letter-spacing: -.035em; text-transform: none; }
.story-lifespan { color: var(--accent); font-family: Georgia, serif; font-size: 22px; }
.story-portrait { position: relative; z-index: 1; min-height: 260px; margin: 0; overflow: hidden; border: 1px solid rgba(224,168,77,.34); border-radius: 14px; background: #090f13; box-shadow: 0 18px 45px rgba(0,0,0,.4); }
.story-portrait::after { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 45px rgba(0,0,0,.24); pointer-events: none; }
.story-portrait img { display: block; width: 100%; height: 100%; min-height: 260px; object-fit: cover; object-position: center; }
.story-portrait.loading-portrait { background: linear-gradient(110deg, #0b1217 20%, #17262e 38%, #0b1217 56%); background-size: 220% 100%; animation: portrait-loading 1.35s linear infinite; }
.story-portrait.loading-portrait img { visibility: hidden; }
.story-stats { display: flex; gap: 28px; margin-top: 35px; }
.story-stats strong { display: block; font-size: 22px; font-family: Georgia, serif; }
.story-stats span { color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .12em; }
.story-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(260px, .8fr); gap: 32px; margin-top: 38px; }
.story-panel { padding: 26px; border: 1px solid #2c3d47; border-radius: 14px; background: rgba(13,21,26,.82); }
.story-panel > h3 { margin: 0 0 22px; font-family: Georgia, serif; font-size: 24px; font-weight: 500; }
.life-timeline { position: relative; display: grid; gap: 14px; padding-left: 26px; }
.life-timeline::before { content: ''; position: absolute; top: 8px; bottom: 8px; left: 6px; width: 1px; background: linear-gradient(var(--accent), #31434d); }
.life-event { position: relative; padding: 14px 16px; border-radius: 9px; background: #111b21; border: 1px solid #293a44; }
.life-event::before { content: ''; position: absolute; left: -26px; top: 20px; width: 9px; height: 9px; border: 2px solid #0d151a; border-radius: 50%; background: var(--event-color, var(--accent)); }
.life-event header { display: flex; justify-content: space-between; gap: 10px; padding: 0; border: 0; }
.life-event strong { color: #e6ecef; }
.life-event time { color: var(--accent); white-space: nowrap; }
.life-event p { margin: 7px 0 0; color: var(--muted); line-height: 1.45; }
.evidence-badge { display: inline-block; margin-top: 8px; color: var(--accent-2); font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.evidence-details { margin-top: 9px; border-top: 1px solid #293a44; padding-top: 8px; }
.evidence-details summary { color: var(--accent-2); cursor: pointer; font-size: 10px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.evidence-details[open] summary { margin-bottom: 9px; }
.citation-card { padding: 10px; border-radius: 7px; background: #091116; }
.citation-card + .citation-card { margin-top: 7px; }
.citation-card strong, .citation-card span { display: block; }
.citation-card strong { color: #e7edf0; font-size: 11px; }
.citation-card span { margin-top: 4px; color: var(--muted); font-size: 10px; line-height: 1.45; }
.evidence-badge.family { color: #f2bd72; }
.evidence-badge.uncited, .evidence-badge.lead { color: #ef8c84; }
.evidence-badge.bounded { color: #b9a3ed; }
.relation-group + .relation-group { margin-top: 22px; }
.relation-group h4 { margin: 0 0 9px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: .14em; }
.person-pills { display: grid; gap: 7px; }
.person-pill { width: 100%; padding: 10px 11px; border: 1px solid #30424c; border-radius: 8px; color: var(--text); background: #101a20; text-align: left; }
.person-pill:hover { border-color: var(--accent-2); background: #17252c; }
.person-pill span { display: block; color: var(--muted); margin-top: 2px; font-size: 10px; }
.empty-story { padding: 100px 30px; color: var(--muted); text-align: center; }
.story-locations { margin-top: 32px; padding: 26px; border: 1px solid #2c3d47; border-radius: 14px; background: rgba(13,21,26,.82); }
.story-location-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.story-location-heading h3 { margin: 3px 0 0; font-family: Georgia, serif; font-size: 28px; font-weight: 500; }
.story-location-heading > span { color: var(--muted); font-size: 11px; }
#story-map { width: 100%; height: 430px; overflow: hidden; border: 1px solid #3a4e59; border-radius: 11px; background: #dce3df; }
.story-place-list { display: flex; gap: 8px; overflow-x: auto; padding-top: 13px; }
.story-place-list button { min-width: 180px; padding: 10px 12px; border: 1px solid #30424c; border-left: 3px solid var(--event-color); border-radius: 8px; color: var(--text); background: #101a20; text-align: left; }
.story-place-list button:hover { border-color: var(--accent-2); }
.story-place-list strong, .story-place-list span { display: block; }
.story-place-list span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.place-hero { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(340px, .8fr); gap: 24px; padding: 28px; border: 1px solid #344651; border-radius: 18px; background: rgba(13,21,26,.88); }
.place-intro { padding: 24px 18px; }
.place-intro h2 { margin: 6px 0 12px; color: var(--text); font-family: Georgia, serif; font-size: clamp(36px, 5vw, 62px); font-weight: 500; line-height: 1; letter-spacing: -.03em; text-transform: none; }
.place-intro > p:last-of-type { color: var(--muted); line-height: 1.55; }
.place-summary { display: flex; gap: 25px; margin-top: 28px; }
.place-summary strong, .place-summary span { display: block; }
.place-summary strong { color: var(--accent); font-family: Georgia, serif; font-size: 25px; }
.place-summary span { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .12em; }
#place-map { min-height: 390px; overflow: hidden; border: 1px solid #40545f; border-radius: 12px; background: #dce3df; }
.place-columns { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .7fr); gap: 28px; margin-top: 30px; }
.place-person-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; }
.place-person-list .person-pill { min-height: 58px; }
.place-hierarchy { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.place-hierarchy button { padding: 7px 10px; border: 1px solid #30424c; border-radius: 20px; color: var(--text); background: #101a20; }
.place-chooser-hero { padding: 38px 42px; border: 1px solid #344651; border-radius: 18px; background: linear-gradient(135deg, rgba(27,45,55,.94), rgba(10,16,21,.96)); }
.place-chooser-hero h2 { margin: 5px 0 10px; color: var(--text); font-family: Georgia, serif; font-size: clamp(34px, 5vw, 56px); font-weight: 500; line-height: 1; letter-spacing: -.03em; text-transform: none; }
.place-chooser-hero > p:not(.eyebrow) { color: var(--muted); }
.place-search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; margin-top: 24px; }
.place-search-row input { width: 100%; padding: 12px 13px; border: 1px solid #40545f; border-radius: 8px; color: var(--text); background: #091015; }
.place-search-row button { padding: 0 20px; border: 0; border-radius: 8px; color: #07100e; background: var(--accent-2); font-weight: 800; }
.place-picker-section { margin-top: 26px; padding: 25px; border: 1px solid #2c3d47; border-radius: 14px; background: rgba(13,21,26,.82); }
.place-picker-section .section-title h3 { margin: 0; font-family: Georgia, serif; font-size: 23px; font-weight: 500; }
.place-card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 9px; margin-top: 18px; }
.place-card { position: relative; min-height: 76px; padding: 13px 13px 12px 35px; border: 1px solid #30424c; border-radius: 9px; color: var(--text); background: #101a20; text-align: left; }
.place-card:hover { border-color: var(--accent-2); background: #17262d; }
.place-card strong, .place-card small { display: block; }
.place-card small { margin-top: 5px; color: var(--muted); }
.place-pin-dot { position: absolute; left: 14px; top: 18px; width: 9px; height: 9px; border: 2px solid #72818a; border-radius: 50%; }
.place-pin-dot.mapped { border-color: var(--accent-2); background: var(--accent-2); box-shadow: 0 0 10px rgba(127,199,184,.4); }
.research-hero { padding: 38px 42px; border: 1px solid #344651; border-radius: 18px; background: linear-gradient(135deg, rgba(27,45,55,.94), rgba(10,16,21,.96)); }
.research-hero h2 { margin: 5px 0 10px; color: var(--text); font-family: Georgia, serif; font-size: clamp(36px,5vw,58px); font-weight: 500; line-height: 1; text-transform: none; letter-spacing: -.03em; }
.research-hero > p:not(.eyebrow) { color: var(--muted); }
.research-counts { display: grid; grid-template-columns: repeat(6,minmax(110px,1fr)); gap: 9px; margin-top: 28px; }
.research-count { padding: 14px; border: 1px solid #31444e; border-radius: 9px; color: var(--text); background: #0d171c; text-align: left; }
.research-count.active { border-color: var(--accent); background: rgba(224,168,77,.12); }
.research-count strong, .research-count span { display: block; }
.research-count strong { color: var(--accent); font-family: Georgia,serif; font-size: 26px; }
.research-count span { margin-top: 3px; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .12em; }
.research-grid { display: grid; grid-template-columns: minmax(0,1.4fr) minmax(260px,.65fr); gap: 28px; margin-top: 28px; }
.research-list { display: grid; gap: 10px; }
.research-card { padding: 17px; border: 1px solid #30424c; border-left: 3px solid var(--status-color,#71838d); border-radius: 9px; background: #101a20; }
.research-card header { display: flex; justify-content: space-between; gap: 12px; padding: 0; border: 0; }
.research-card h4 { margin: 0; font-size: 14px; }
.research-card p { margin: 9px 0 0; color: var(--muted); line-height: 1.45; }
.research-status { color: var(--status-color); font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; white-space: nowrap; }
.research-meta { display: flex; gap: 12px; margin-top: 10px; color: #7fc7b8; font-size: 10px; }
.investigation-list { display: grid; gap: 9px; max-height: 660px; overflow-y: auto; }
.research-details { margin-top: 14px; padding-top: 11px; border-top: 1px solid #293a44; }
.research-details summary { color: var(--accent-2); cursor: pointer; font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.research-details h5 { margin: 16px 0 5px; color: #dfe7ea; font-size: 10px; letter-spacing: .09em; text-transform: uppercase; }
.research-details ul { margin: 6px 0 0; padding-left: 18px; color: var(--muted); line-height: 1.55; }
.research-note-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.research-note-link { padding: 6px 9px; border: 1px solid #38505b; border-radius: 16px; color: var(--accent-2); background: #0b151a; font-size: 10px; }
.investigation-item { width: 100%; padding: 11px; border: 1px solid transparent; border-radius: 8px; color: var(--muted); background: #0c151a; font-size: 11px; line-height: 1.5; text-align: left; }
button.investigation-item:hover { border-color: var(--accent-2); color: var(--text); }
.research-note-dialog { width: min(900px,calc(100vw - 48px)); max-height: calc(100vh - 60px); padding: 0; border: 1px solid #40545f; border-radius: 15px; color: var(--text); background: #0b1318; box-shadow: 0 25px 90px rgba(0,0,0,.72); }
.research-note-dialog::backdrop { background: rgba(2,6,8,.8); backdrop-filter: blur(5px); }
.research-note-dialog header { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 20px 24px; border-bottom: 1px solid #30424c; background: #101b21; }
.research-note-dialog h2 { margin: 3px 0 0; font-family: Georgia,serif; font-size: 26px; font-weight: 500; text-transform: capitalize; }
.research-note-dialog header button { width: 36px; height: 36px; border: 1px solid #40545f; border-radius: 50%; color: var(--text); background: #0a1217; font-size: 23px; }
.research-note-dialog pre { margin: 0; padding: 26px; color: #c5d0d5; font: 12px/1.65 ui-monospace,SFMono-Regular,Menlo,monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.quality-panel { margin-top: 28px; padding: 26px; border: 1px solid #344651; border-radius: 14px; background: rgba(13,21,26,.86); }
.quality-panel .section-title { display: flex; align-items: end; justify-content: space-between; gap: 18px; }
.quality-panel .section-title h3 { margin: 3px 0 0; font-family: Georgia,serif; font-size: 28px; font-weight: 500; }
.quality-panel .section-title > span { color: var(--muted); font-size: 10px; }
.quality-metrics { display: grid; grid-template-columns: repeat(4,1fr); gap: 9px; margin-top: 20px; }
.quality-metric { padding: 13px; border: 1px solid #31444e; border-radius: 9px; color: var(--text); background: #0d171c; text-align: left; }
.quality-metric.active { border-color: var(--accent-2); background: rgba(127,199,184,.1); }
.quality-metric strong,.quality-metric span { display: block; }
.quality-metric strong { color: var(--accent-2); font: 24px Georgia,serif; }
.quality-metric span { margin-top: 4px; color: var(--muted); font-size: 9px; letter-spacing: .09em; text-transform: uppercase; }
.quality-results { margin-top: 22px; }
.quality-results h4 { margin: 0 0 9px; color: var(--muted); font-size: 10px; letter-spacing: .11em; text-transform: uppercase; }
.quality-row { display: grid; grid-template-columns: 90px minmax(220px,1fr) minmax(180px,.8fr); align-items: center; gap: 14px; padding: 11px 12px; border-top: 1px solid #25353e; }
.quality-event-type { padding-left: 13px; border-left: 3px solid var(--event-color); color: #dfe7ea; font-size: 11px; }
.quality-row strong,.quality-row span { display: block; }
.quality-row > div > span { margin-top: 3px; color: var(--muted); font-size: 10px; }
.quality-people { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.quality-people button { padding: 5px 8px; border: 1px solid #38505b; border-radius: 14px; color: var(--accent-2); background: #0a1419; font-size: 9px; }

@media (max-width: 1180px) {
  .research-counts { grid-template-columns: repeat(3,1fr); }
  .quality-metrics { grid-template-columns: repeat(2,1fr); }
  .quality-row { grid-template-columns: 80px minmax(180px,1fr); }
  .quality-people { grid-column: 2; justify-content: flex-start; }
}

.constellation-heading { position: absolute; z-index: 2; left: 42px; top: 35px; pointer-events: none; }
.constellation-heading h2 { margin: 4px 0; color: var(--text); font-family: Georgia, serif; font-size: 34px; font-weight: 500; text-transform: none; letter-spacing: -.02em; }
.constellation-heading > p:last-of-type { margin: 0; color: var(--muted); }
.pedigree-legend { display: flex; gap: 15px; margin-top: 11px; color: var(--muted); font-size: 10px; }
.pedigree-legend span::before { content: ''; display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 50%; vertical-align: -1px; }
.pedigree-legend .father::before { background: #62b9e8; }
.pedigree-legend .mother::before { background: #e895ad; }
.constellation-controls { position: absolute; z-index: 3; left: 42px; bottom: 34px; display: flex; gap: 6px; }
.constellation-controls button { min-width: 38px; height: 38px; padding: 0 12px; border: 1px solid #40545f; border-radius: 8px; color: var(--text); background: rgba(13,22,27,.9); font-weight: 700; }
.constellation-controls button:hover { border-color: var(--accent-2); background: #17262d; }
#constellation { display: block; width: 100%; height: 100%; min-height: 720px; overflow: hidden; outline: none; user-select: none; }
.constellation-background { pointer-events: none; }
#constellation:focus-visible { box-shadow: inset 0 0 0 2px var(--accent-2); }
.generation-band { fill: rgba(15,25,31,.4); stroke: rgba(75,99,111,.16); stroke-width: 1; rx: 16; }
.generation-band.current { fill: rgba(224,168,77,.055); stroke: rgba(224,168,77,.2); }
.constellation-link { fill: none; stroke: #54717e; stroke-width: 2; opacity: .65; filter: drop-shadow(0 0 5px rgba(127,199,184,.25)); }
.constellation-link.parent-line { stroke: #6a8794; }
.constellation-link.branch-father { stroke: #62b9e8; }
.constellation-link.branch-mother { stroke: #e895ad; }
.constellation-link.child-line { stroke: var(--accent); }
.constellation-link.partner { stroke: var(--accent); stroke-dasharray: 7 5; }
.partnership-date { fill: #e0c98f; font-size: 10px; text-anchor: middle; paint-order: stroke; stroke: #071016; stroke-width: 4px; stroke-linejoin: round; pointer-events: none; }
.family-hub { cursor: default; }
.family-hub circle { fill: rgba(224,168,77,.12); stroke: var(--accent); stroke-width: 2; filter: drop-shadow(0 0 15px rgba(224,168,77,.42)); }
.family-hub .hub-core { fill: var(--accent); stroke: #fff0cc; stroke-width: 1; }
.family-hub text { fill: #f3d395; font-size: 9px; letter-spacing: .12em; text-anchor: middle; }
.constellation-node { cursor: pointer; }
.constellation-node rect { fill: rgba(17,27,33,.94); stroke: #4e6672; stroke-width: 1.5; rx: 12; filter: drop-shadow(0 14px 22px rgba(0,0,0,.42)); }
.constellation-node.root rect { fill: #193039; stroke: var(--accent); stroke-width: 2.5; filter: drop-shadow(0 0 22px rgba(224,168,77,.26)); }
.constellation-node.approaching rect { stroke: #fff0cc; stroke-width: 3; filter: drop-shadow(0 0 32px rgba(224,168,77,.7)); }
.constellation-node.selected rect { stroke: #fff0cc; stroke-width: 3; filter: drop-shadow(0 0 24px rgba(224,168,77,.62)); }
.constellation-node:hover rect { stroke: var(--accent-2); }
.constellation-node:focus { outline: none; }
.constellation-node:focus-visible rect { stroke: #fff0cc; stroke-width: 3; }
.constellation-node.branch-father rect { stroke: #4e9cc5; }
.constellation-node.branch-mother rect { stroke: #c97991; }
.constellation-node.branch-partner rect { stroke: #ac91d4; }
.constellation-node .node-name { fill: #f2f0e9; font-size: 17px; font-weight: 650; }
.constellation-node .node-portrait { pointer-events: none; filter: drop-shadow(0 2px 5px rgba(0,0,0,.48)); }
.constellation-node .node-life { fill: #9cabb4; font-size: 12px; }
.constellation-node .node-relation { fill: var(--accent); font-size: 9px; letter-spacing: .12em; text-transform: uppercase; }
.constellation-node .node-evidence { fill: #8999a2; font-size: 9px; text-anchor: end; }
.constellation-node .node-evidence.complete { fill: #7fc7b8; }
.constellation-node .node-evidence.incomplete { fill: #d99a72; }
.constellation-node .node-parent-state { fill: #9cabb4; font-size: 9px; letter-spacing: .04em; }
.constellation-node .node-parent-state.missing { fill: #e58d83; }
.constellation-node .node-parent-state.partial { fill: #e2bd71; }
.generation-label { fill: #7f929c; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; dominant-baseline: middle; }
.pedigree-inspector { position: absolute; z-index: 5; top: 34px; right: 32px; width: min(310px,calc(100% - 64px)); padding: 24px; border: 1px solid #4a616c; border-radius: 14px; background: rgba(10,18,23,.96); box-shadow: 0 24px 70px rgba(0,0,0,.58); backdrop-filter: blur(10px); }
.pedigree-inspector[hidden] { display: none; }
.pedigree-inspector-close { position: absolute; top: 12px; right: 12px; width: 31px; height: 31px; border: 1px solid #40545f; border-radius: 50%; color: var(--text); background: #101b21; font-size: 20px; }
.pedigree-inspector h3 { margin: 5px 30px 2px 0; font-family: Georgia,serif; font-size: 27px; font-weight: 500; }
.pedigree-inspector-life { margin: 0; color: var(--accent); }
.pedigree-inspector dl { display: grid; gap: 0; margin: 20px 0; }
.pedigree-inspector dl div { display: grid; grid-template-columns: 88px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid #263741; }
.pedigree-inspector dt { color: var(--muted); font-size: 9px; letter-spacing: .08em; text-transform: uppercase; }
.pedigree-inspector dd { margin: 0; color: #dce5e8; font-size: 11px; }
.pedigree-inspector-actions { display: grid; grid-template-columns: 1fr 1.25fr; gap: 7px; }
.pedigree-inspector-actions button { min-height: 40px; padding: 8px; border: 1px solid #40545f; border-radius: 8px; color: var(--text); background: #142129; font-size: 10px; font-weight: 750; }
.pedigree-inspector-actions .primary { border-color: var(--accent); color: #161108; background: var(--accent); }
@keyframes pulse { to { opacity: .25; transform: scale(.7); } }
@keyframes portrait-loading { to { background-position-x: -220%; } }

@media (max-width: 800px) {
  :root { --panel-width: 100%; }
  .explorer-view { inset: 0 0 46% 0; }
  .panel { top: 54%; width: 100%; border-left: 0; border-top: 1px solid #344651; }
  .loading { left: 50%; top: 18px; }
  .story-hero { grid-template-columns: 1fr; padding: 28px; }
  .story-portrait { max-height: 360px; }
}

/* Final archival surface overrides live last so legacy view styles cannot
   reintroduce the former teal gradients and luminous card treatment. */
.story-hero, .place-chooser-hero, .research-hero { border-color: #4c463d; background: #1c1a17; box-shadow: none; }
.story-hero::after { display: none; }
.story-panel, .story-locations, .place-hero, .place-picker-section, .quality-panel { border-color: #403b34; background: #191816; }
.life-event, .person-pill, .place-card, .research-card, .admin-request { border-color: #403b34; background: #201e1a; }
.constellation-controls button, .pedigree-inspector-actions button { border-color: #585145; background: #211f1b; }
.constellation-controls button:hover { border-color: #a88a50; background: #2a2722; }
.generation-band { fill: rgba(34,31,27,.42); stroke: rgba(126,115,98,.17); }
.generation-band.current { fill: rgba(168,138,80,.055); stroke: rgba(168,138,80,.2); }
.constellation-link { filter: none; stroke: #746e64; }
.constellation-link.parent-line { stroke: #7b7468; }
.constellation-link.child-line, .constellation-link.partner { stroke: #a88a50; }
.family-hub circle { fill: #282319; stroke: #a88a50; filter: none; }
.family-hub .hub-core { fill: #a88a50; stroke: #e6d7b5; }
.constellation-node rect { fill: #1d1c19; stroke: #6b6459; filter: drop-shadow(0 8px 12px rgba(0,0,0,.25)); }
.constellation-node.root rect { fill: #2a241b; stroke: #b09154; filter: none; }
.constellation-node.selected rect, .constellation-node.approaching rect { stroke: #d6c18f; filter: none; }
.constellation-node:hover rect { stroke: #b09154; }
.pedigree-inspector { border-color: #554e43; background: #1d1b18; box-shadow: 0 18px 45px rgba(0,0,0,.35); backdrop-filter: none; }
