/* GedView base stylesheet.
   Palette and shape lean on the legacy PGV "standard" theme (muted blue
   surface, gray text, red hover) but expressed with modern CSS: variables,
   flex/grid, system font stack. No framework. */

:root {
    --gv-bg: #ffffff;
    --gv-text: #1f1f1f;
    --gv-text-muted: #555555;
    --gv-link: #2c4f86;
    --gv-link-hover: #b4232a;
    --gv-border: #c4cdde;
    --gv-surface: #e8eef7;
    --gv-surface-strong: #ccd6ea;
    --gv-surface-soft: #f4f7fc;
    --gv-label: #2a2f3a;
    --gv-accent: #2c5fb3;
    --gv-female: #f3e4f1;
    --gv-female-border: #dd80b0;
    /* Sex tints for person cards / chart boxes. Male mirrors the neutral surface;
       the *-soft pair are the lighter fills behind chart boxes. Defined here so the
       many `var(--gv-male*, fallback)` references resolve to one theme source. */
    --gv-male: #e3ecf8;
    --gv-male-border: #b6c2db;
    --gv-male-soft: #e6f0ff;
    --gv-female-soft: #ffe6f0;
    --gv-placeholder: #a8b0bc;
    --gv-danger: #b00020;
    --gv-danger-strong: #800018;
    --gv-danger-tint: #fdf2f2;
    /* Alt surface for popups, hover-cards and striped rows (was referenced but
       never defined — the chart-hover popup background fell back to transparent). */
    --gv-bg-alt: #f5f7fb;
    /* Muted text. Mirrors --gv-text-muted; ~15 rules referenced --gv-muted with no
       fallback, so muted captions/dates were rendering at full text colour. */
    --gv-muted: #555555;

    --gv-font: ui-sans-serif, system-ui, "Segoe UI", Tahoma, Arial, Helvetica, sans-serif;
    --gv-font-mono: ui-monospace, "Cascadia Mono", Menlo, Consolas, monospace;

    --gv-radius: 7px;
    --gv-space-1: 0.25rem;
    --gv-space-2: 0.5rem;
    --gv-space-3: 0.75rem;
    --gv-space-4: 1rem;
    --gv-space-5: 1.25rem; /* was missing — `var(--gv-space-5)` margins/gaps collapsed to 0 */
    --gv-space-6: 1.5rem;

    /* Single source of truth for content width — header row, top nav,
       main, and footer all snap to the same edges so the layout doesn't
       look like the nav is floating wider than the content. */
    --gv-container: 1240px;

    /* Elevation tokens (2026-06-03 refresh) — soft layered shadows for header/cards. */
    --gv-shadow-sm: 0 1px 2px rgba(20, 30, 60, 0.06), 0 1px 3px rgba(20, 30, 60, 0.05);
    --gv-shadow-md: 0 6px 18px rgba(20, 30, 60, 0.12);
}

input::placeholder,
textarea::placeholder {
    color: var(--gv-placeholder);
    font-style: italic;
    opacity: 1;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 15px;
    /* The full-bleed pattern on .chart-svg-wrap uses 50vw which counts the
       vertical-scrollbar gutter, overshooting the visible viewport by a few
       pixels. Clip horizontal at the document edge so that overshoot can
       never produce a document-level horizontal scrollbar — internal
       scrollers (chart wrap, <pre>, tables) still work. Force the vertical
       scrollbar to always render: Chrome paints `overflow-x: clip` as if
       both axes were clipped when overflow-y is the default `visible`,
       which hid the vertical scrollbar even on pages taller than the
       viewport. Explicit `overflow-y: scroll` restores the affordance and
       also prevents layout reflow when content grows past one screen. */
    overflow-x: clip;
    overflow-y: scroll;
}

body {
    margin: 0;
    font-family: var(--gv-font);
    color: var(--gv-text);
    background-color: var(--gv-bg);
    line-height: 1.45;
}

a {
    color: var(--gv-link);
    text-decoration: none;
}

a:hover {
    color: var(--gv-link-hover);
    text-decoration: underline;
}

/* One consistent keyboard-focus ring for every interactive control. :where() holds
   specificity at 0 so the component-specific focus rules below still win, and
   :focus-visible means a mouse click never leaves a lingering outline (the old
   a:focus rule kept links red + underlined until blur). */
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--gv-accent);
    outline-offset: 2px;
    border-radius: var(--gv-radius);
}

h1, h2, h3, h4 {
    color: var(--gv-label);
    margin: 0 0 var(--gv-space-3);
    font-weight: 600;
    letter-spacing: 0.1px;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.1rem; }

p {
    margin: 0 0 var(--gv-space-3);
}

.container {
    max-width: var(--gv-container);
    margin: 0 auto;
    padding: var(--gv-space-4);
}

/* For prose-heavy pages (auth forms, account settings, individual notes)
   readability matters more than density — opt those in by adding
   .container--narrow to the wrapping element. */
.container--narrow {
    max-width: 760px;
}

/* --- Header ---------------------------------------------------------- */

.site-header {
    border-bottom: 1px solid var(--gv-border);
    background: linear-gradient(to bottom, var(--gv-surface-soft), #ffffff);
    box-shadow: var(--gv-shadow-sm);
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: var(--gv-container);
    margin: 0 auto;
    padding: var(--gv-space-2) var(--gv-space-4);
    gap: var(--gv-space-3);
    flex-wrap: wrap;
}

.header-user {
    font-size: 0.85rem;
    color: var(--gv-text-muted);
}

.header-link {
    font-weight: 600;
}

.tree-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--gv-label);
    letter-spacing: 0.2px;
}

.tree-title:hover {
    color: var(--gv-link-hover);
    text-decoration: none;
}

.tree-switcher {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-left: var(--gv-space-3);
    font-size: 0.85rem;
}

.tree-switcher__label {
    color: var(--gv-text-muted);
}

.tree-switcher select {
    padding: 0.15rem 0.4rem;
    border: 1px solid var(--gv-border);
    border-radius: 3px;
    background: #fff;
    font-size: 0.85rem;
    cursor: pointer;
}

.topmenu {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gv-space-1);
    justify-content: center;
    padding: var(--gv-space-2) var(--gv-space-4) var(--gv-space-3);
    max-width: var(--gv-container);
    margin: 0 auto;
}

.menuitem {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 56px;
    padding: var(--gv-space-2);
    color: var(--gv-text-muted);
    font-size: 0.8rem;
    border-radius: var(--gv-radius);
    transition: background-color 80ms ease-in, color 80ms ease-in;
}

.menuitem:hover,
.menuitem:focus-visible {
    background-color: var(--gv-surface-soft);
    color: var(--gv-link-hover);
    text-decoration: none;
}

.menuitem:focus-visible {
    outline: 2px solid var(--gv-accent);
    outline-offset: 1px;
}

.menuicon {
    font-size: 1.3rem;
    line-height: 1;
}

/* Narrow viewports — phones in portrait. The 14-item icon nav at 56px min
   would wrap into 4-5 rows of cards; tighten footprint and let labels sit
   tighter to their icons. The account-bar above also wraps; shrink its
   font so "Logged in as <name> | …" reads on one or two lines. */
@media (max-width: 480px) {
    .header-row {
        padding: var(--gv-space-2) var(--gv-space-3);
        gap: var(--gv-space-2);
    }
    .header-user {
        font-size: 0.78rem;
        flex-wrap: wrap;
        row-gap: 2px;
    }
    .tree-title {
        font-size: 1.1rem;
    }
    .topmenu {
        padding: var(--gv-space-1) var(--gv-space-2) var(--gv-space-2);
        gap: 0;
    }
    .menuitem {
        min-width: 48px;
        padding: 6px 4px;
        font-size: 0.72rem;
    }
    .menuicon {
        font-size: 1.15rem;
    }
}

/* --- Tables / lists -------------------------------------------------- */

table.gedcom-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--gv-border);
    background-color: var(--gv-bg);
    margin: var(--gv-space-3) 0;
}

table.gedcom-table th {
    background-color: var(--gv-surface-strong);
    color: var(--gv-label);
    font-weight: 600;
    text-align: left;
    padding: var(--gv-space-2) var(--gv-space-3);
    border-bottom: 1px solid var(--gv-border);
}

table.gedcom-table td {
    background-color: var(--gv-surface);
    padding: var(--gv-space-2) var(--gv-space-3);
    border: 1px solid var(--gv-border);
    vertical-align: top;
}

/* Relative life events (legacy $SHOW_RELATIVES_EVENTS) interwoven into the Facts table:
   births/deaths of close family within the focal person's lifespan. Quiet context rows —
   muted text + a thin left accent — so they read as background, not the person's own facts. */
table.gedcom-table tr.fact-row--relative td {
    color: var(--gv-muted);
    background-color: var(--gv-surface-strong);
}
table.gedcom-table tr.fact-row--relative td:first-child {
    border-left: 3px solid var(--gv-border);
}

/* Parents' ages next to a birth date (legacy format_parents_age): a small,
   muted "♀38 ♂42" badge per parent. .parentdeath flags a parent who died around
   the birth — legacy boxed it in a thin gray outline; matched here with a quiet
   neutral border rather than a loud colour. */
.parents-age {
    margin-inline-start: var(--gv-space-2);
    font-size: 0.8em;
    color: var(--gv-muted);
    white-space: nowrap;
}

.parents-age + .parents-age {
    margin-inline-start: var(--gv-space-1);
}

.parents-age.parentdeath {
    border: 1px solid var(--gv-muted);
    border-radius: var(--gv-radius);
    padding: 0 var(--gv-space-1);
}

/* Inline (fact-attached) note text preserves the line breaks the editor stored as CONT
   lines, so a multi-line note reads as it was typed instead of collapsing to one run-on
   line. Record-level notes use <pre class="note-body">, which already preserves newlines. */
.note-inline {
    white-space: pre-line;
}

/* Facts-table "Details" cell: each component — the "with {spouse}" link, Type/Cause
   lines, extra sub-tags, and the notes block — sits on its own line, matching legacy
   print_fact's <br/> separation. Previously these were bare inline spans that ran
   together into one unreadable run (06-02 report item 2). */
.fact-related,
.fact-type,
.fact-cause,
.fact-subtag {
    display: block;
}
.fact-related ~ .fact-type,
.fact-type ~ .fact-cause {
    margin-top: 2px;
}
ul.fact-notes {
    list-style: none;
    margin: var(--gv-space-1) 0 0;
    padding: 0;
}
/* Consecutive notes under one fact get a dashed rule between them — the on-screen
   analog of the report-PDF consecutive-notes separator (05-31 report item i). */
.fact-note + .fact-note {
    margin-top: var(--gv-space-1);
    padding-top: var(--gv-space-1);
    border-top: 1px dashed var(--gv-border);
}
.fact-note .note-inline {
    display: block;
}
.fact-note__shared {
    display: inline-block;
    margin-bottom: 2px;
}

/* --- Per-person notes page (/people/{xref}/notes) -------------------------- */
.note-entry__head {
    display: flex;
    align-items: baseline;
    gap: var(--gv-space-3);
    flex-wrap: wrap;
    margin: var(--gv-space-2) 0;
}
.note-entry__head form.note-entry__action {
    display: inline;
    margin: 0;
}
.note-entry__head .link-danger {
    background: none;
    border: none;
    padding: 0;
    color: var(--gv-danger);
    cursor: pointer;
    font: inherit;
    text-decoration: underline;
}
.note-entry__edit {
    display: inline-block;
}
.note-form textarea {
    display: block;
    width: 100%;
    max-width: 48em;
    margin: var(--gv-space-2) 0;
    font: inherit;
}
.note-form--inline {
    display: flex;
    align-items: center;
    gap: var(--gv-space-3);
    flex-wrap: wrap;
}

/* Expanded message body in the inbox table. A bare <pre> defaults to
   white-space: pre (no wrap), so a long line or unbroken URL overflows the
   100%-wide table — and `overflow-x: clip` on <html> then hides the spillover
   with no scrollbar. Wrap long lines (preserving the message's own newlines)
   and break unbroken tokens so the body always stays inside its cell. */
.message-body {
    margin: var(--gv-space-2) 0 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* --- Boxes (person/family cards) ------------------------------------- */

.person-box {
    display: inline-block;
    background-color: var(--gv-surface);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    padding: var(--gv-space-2) var(--gv-space-3);
    margin: var(--gv-space-1);
}

.person-box--female {
    background-color: var(--gv-female);
    border-color: var(--gv-female-border);
}

.person-box--unknown {
    background-color: var(--gv-bg);
    border-style: dashed;
}

/* --- Misc utility ---------------------------------------------------- */

.muted {
    color: var(--gv-text-muted);
}

.date {
    color: #2c3e7a;
}

/* --- Back / return navigation link ----------------------------------- */
/* Single source of truth for every "back to …" link. The leading arrow is
   drawn here so markup never hardcodes a glyph (it used to be split between
   a literal "←", an "&larr;" entity, or omitted entirely). The .back-link
   anchor keeps the normal link color; .page-back is the standalone row that
   sits directly under a page heading and may carry trailing "· meta" text. */
.back-link::before {
    content: "\2190";
    margin-right: 0.4em;
}

.page-back {
    margin: 0 0 var(--gv-space-3);
    color: var(--gv-text-muted);
    font-size: 0.95rem;
}

.error {
    color: #b91c1c;
    font-weight: 600;
}

.notice {
    border-left: 4px solid var(--gv-accent);
    background-color: var(--gv-surface-soft);
    padding: var(--gv-space-3) var(--gv-space-4);
    margin: var(--gv-space-4) 0;
    border-radius: var(--gv-radius);
}

/* --- Footer ---------------------------------------------------------- */

.site-footer {
    margin-top: var(--gv-space-6);
    border-top: 1px solid var(--gv-border);
    color: var(--gv-text-muted);
    background-color: var(--gv-surface-soft);
}

.site-footer .container {
    padding: var(--gv-space-3) var(--gv-space-4);
}
.site-footer__line {
    margin: 0;
    font-size: 0.85rem;
}

/* --- Header user controls ------------------------------------------- */

.header-user {
    display: inline-flex;
    align-items: center;
    gap: var(--gv-space-2);
}

.header-sep {
    color: var(--gv-border);
}

.header-logout {
    margin: 0;
}

.link-button {
    background: none;
    border: none;
    padding: 0;
    color: var(--gv-link);
    cursor: pointer;
    font: inherit;
}

.link-button:hover {
    color: var(--gv-link-hover);
    text-decoration: underline;
}

/* --- Auth forms ----------------------------------------------------- */

.auth-form {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--gv-space-3) var(--gv-space-4);
    align-items: center;
    max-width: 560px;
    margin: var(--gv-space-4) 0;
    padding: var(--gv-space-4);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    background-color: var(--gv-surface-soft);
}

.auth-form label {
    font-weight: 600;
    color: var(--gv-label);
}

.auth-form label.checkbox {
    grid-column: 2;
    font-weight: 400;
}

.auth-form input,
.auth-form select,
.auth-form textarea {
    font: inherit;
    padding: var(--gv-space-2) var(--gv-space-3);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    background-color: var(--gv-bg);
    /* min-width:0 + width:100% lets the 1fr grid column actually constrain
       the field; without it the input's intrinsic size pushes col 2 past
       the form's max-width. */
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.auth-form input[type="file"] {
    padding: var(--gv-space-1) var(--gv-space-2);
}

.auth-form input[type="checkbox"],
.auth-form input[type="radio"] {
    width: auto;
    padding: 0;
}

.auth-form .actions {
    grid-column: 1 / -1;
    display: flex;
    gap: var(--gv-space-3);
    align-items: center;
}

.auth-form button {
    font: inherit;
    padding: var(--gv-space-2) var(--gv-space-4);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    background-color: var(--gv-surface-strong);
    color: var(--gv-label);
    cursor: pointer;
    font-weight: 600;
}

.auth-form button:hover {
    background-color: var(--gv-surface);
    color: var(--gv-link-hover);
}

.auth-form--raw {
    display: block;
    max-width: none;
}

.auth-form--raw textarea {
    width: 100%;
    font-family: var(--gv-font-mono, ui-monospace, "DejaVu Sans Mono", "Menlo", monospace);
    font-size: 0.875rem;
    line-height: 1.45;
    white-space: pre;
}

.auth-form--quick {
    display: block;
    max-width: none;
}

.auth-form--quick .quick-section {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--gv-space-3) var(--gv-space-4);
    align-items: center;
    max-width: 560px;
    margin: var(--gv-space-3) 0;
}

.auth-form--quick h2 {
    margin-top: var(--gv-space-5);
    margin-bottom: var(--gv-space-2);
}

.quick-facts {
    width: 100%;
    border-collapse: collapse;
    margin: var(--gv-space-2) 0 var(--gv-space-4);
}

.quick-facts th,
.quick-facts td {
    padding: var(--gv-space-2);
    border-bottom: 1px solid var(--gv-border);
    vertical-align: middle;
    text-align: left;
}

.quick-facts th {
    background-color: var(--gv-surface-strong);
    color: var(--gv-label);
}

.quick-facts td input[type="text"],
.quick-facts td input:not([type]) {
    width: 100%;
    padding: var(--gv-space-1) var(--gv-space-2);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    background-color: var(--gv-bg);
    box-sizing: border-box;
}

.quick-facts td.center {
    text-align: center;
}

.quick-facts td code {
    margin-left: var(--gv-space-2);
    font-size: 0.85em;
}

/* --- Hourglass chart scroll wrap ----------------------------------- */

.chart-svg-wrap--scroll {
    overflow-x: auto;
    padding: var(--gv-space-2) 0;
}

/* --- Relationship chain -------------------------------------------- */

.rel-kinship {
    font-size: 1.1em;
    padding: var(--gv-space-2) var(--gv-space-3);
    background: var(--gv-surface);
    border-left: 4px solid var(--gv-link);
    border-radius: var(--gv-radius);
}

.rel-chain {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--gv-space-2);
    margin: var(--gv-space-3) 0;
    overflow-x: auto;
}

.rel-box {
    display: flex;
    flex-direction: column;
    min-width: 8em;
    max-width: 12em;
    padding: var(--gv-space-2);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    background: var(--gv-bg);
    text-decoration: none;
    color: var(--gv-label);
}

.rel-box:hover {
    background: var(--gv-surface);
    text-decoration: none;
}

.rel-box--female { background: #fce7f3; }
.rel-box--male { background: #dbeafe; }

.rel-box__name { font-weight: 600; font-size: 0.95em; }
.rel-box__dates { font-size: 0.8em; color: var(--gv-muted); margin-top: 2px; }
.rel-box__xref { font-family: ui-monospace, monospace; font-size: 0.75em; color: var(--gv-muted); margin-top: 2px; }
.rel-box__sosa {
    display: inline-block;
    font-family: ui-monospace, monospace;
    font-size: 0.75em;
    padding: 1px 6px;
    margin-bottom: 4px;
    background: rgba(0,0,0,0.08);
    border-radius: 999px;
    color: var(--gv-text-muted, #4b5563);
    align-self: center;
}

.rel-arrow {
    font-size: 0.85em;
    color: var(--gv-muted);
    white-space: nowrap;
    padding: 0 var(--gv-space-1);
}

/* --- Picker widget ------------------------------------------------- */

.picker {
    position: relative;
    display: inline-block;
    vertical-align: middle;
}

.picker-hint {
    margin-left: var(--gv-space-2);
    color: var(--gv-muted);
    font-size: 0.9em;
}

.picker-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    margin: 0;
    padding: 0;
    list-style: none;
    background: var(--gv-bg);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    min-width: 100%;
    max-width: 28em;
    max-height: 18em;
    overflow-y: auto;
}

.picker-dropdown__item {
    padding: var(--gv-space-1) var(--gv-space-2);
    cursor: pointer;
    display: flex;
    gap: var(--gv-space-2);
    align-items: baseline;
}

.picker-dropdown__item:hover,
.picker-dropdown__item--active {
    background: var(--gv-surface);
}

.picker-dropdown__xref {
    font-family: ui-monospace, monospace;
    font-size: 0.85em;
    color: var(--gv-muted);
    flex-shrink: 0;
}

.picker-dropdown__label {
    color: var(--gv-label);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Letter index bar ---------------------------------------------- */

.letter-index {
    display: flex;
    gap: var(--gv-space-1);
    flex-wrap: wrap;
    margin: var(--gv-space-2) 0 var(--gv-space-3);
    padding: var(--gv-space-2);
    background-color: var(--gv-surface);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
}

.letter-index__link {
    display: inline-block;
    padding: var(--gv-space-1) var(--gv-space-2);
    border-radius: var(--gv-radius);
    text-decoration: none;
    color: var(--gv-link);
    font-weight: 500;
    min-width: 1.5em;
    text-align: center;
}

.letter-index__link:hover {
    background-color: var(--gv-bg);
    text-decoration: none;
}

.letter-index__link--active {
    background-color: var(--gv-link);
    color: var(--gv-bg);
}

.letter-index__link--active:hover {
    background-color: var(--gv-link);
    color: var(--gv-bg);
}

/* --- People/Edit structured form ----------------------------------- */

/* The .edit-form modifier turns the parent .auth-form into a single-column
   block layout. Without this, the auth-form's 2-col grid drops each fieldset
   into alternating cells, squishing the right-column fieldset to fit the 1fr
   column (visible bug on /people/{xref}/add-relative where the new-name inputs
   collapsed to ~24px). */
.auth-form.edit-form {
    display: block;
    max-width: 960px;
}

.edit-form .edit-fieldset {
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    padding: var(--gv-space-3);
    margin-bottom: var(--gv-space-4);
}

.edit-form .edit-fieldset legend {
    padding: 0 var(--gv-space-2);
    font-weight: 600;
}

.edit-name-grid {
    display: grid;
    grid-template-columns: max-content 1fr;
    column-gap: var(--gv-space-3);
    row-gap: var(--gv-space-2);
    align-items: center;
    margin-bottom: var(--gv-space-3);
}

.edit-name-grid label {
    margin: 0;
    text-align: right;
    font-weight: 500;
}

.edit-help {
    font-size: 0.9em;
    margin-top: 0;
}

.edit-marnm-row,
.edit-fact-row,
/* Grid (not flex-wrap): the 6 add-fact fields wrap into aligned rows. With
   flex-wrap the fields dropped onto a second line at arbitrary widths/zooms and
   sat vertically offset from the first line. A grid keeps wrapped fields in tidy
   rows; align-items:end bottom-aligns each cell so the input boxes line up even
   though the Value/Date/Place labels carry an extra `?`-help line. */
.edit-newfact-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
    gap: var(--gv-space-2) var(--gv-space-3);
    align-items: end;
    margin-bottom: var(--gv-space-2);
    padding: var(--gv-space-2);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    background-color: var(--gv-surface);
}

.edit-marnm-row label,
.edit-fact-row label,
.edit-newfact-row label {
    display: flex;
    flex-direction: column;
    flex: 1 1 9em;
    margin: 0;
    font-size: 0.85em;
    color: var(--gv-label);
}

/* Give the edit-row inputs + selects one consistent box model. They were rendering
   as unstyled native controls of differing heights (a <select> is a few px shorter
   than a text <input>), which left the Tag select sitting off the input baseline.
   Matching padding/border/box-sizing makes every field the same height so they line
   up, and brings them in line with the styled inputs elsewhere in the app. */
.edit-marnm-row label > input,
.edit-marnm-row label > select,
.edit-fact-row label > input,
.edit-fact-row label > select,
.edit-newfact-row label > input,
.edit-newfact-row label > select {
    box-sizing: border-box;
    width: 100%;
    padding: var(--gv-space-1) var(--gv-space-2);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    background-color: var(--gv-bg);
    font: inherit;
}

/* Fact rows display in genealogical precedence order via CSS `order` (set inline
   per row from GedcomFactOrder); the flex column is what makes `order` take
   effect. DOM order stays blob order so posted Fields.Facts[i] indices remain
   valid for the save/copy/delete handlers. */
.edit-fact-list {
    display: flex;
    flex-direction: column;
}

/* Each fact's human name leads its row as a full-width header; the raw GEDCOM
   tag is tucked alongside as a faint hint (owner items #17 / #6). */
.edit-fact-label {
    grid-column: 1 / -1;
    font-weight: 600;
    font-size: 0.95em;
    margin-bottom: var(--gv-space-1);
}

/* De-emphasized GEDCOM tag/code shown beside a human label (name fields, fact
   rows): present for power users, visually secondary. */
.gedcom-code {
    margin-left: 0.3em;
    font-family: ui-monospace, monospace;
    font-weight: 400;
    font-size: 0.8em;
    color: var(--gv-muted);
}

.edit-delete {
    flex: 0 0 auto !important;
    align-items: center !important;
    flex-direction: row !important;
}

.edit-fact-note {
    flex: 1 1 100% !important;
}

.edit-fact-note input {
    font-size: 0.9em;
}

.fact-edit-link {
    margin-left: 0.4em;
    color: var(--gv-link, currentColor);
    text-decoration: none;
    opacity: 0.6;
}
.fact-edit-link:hover { opacity: 1; }

/* --- Read views: individual / family / lists ------------------------ */

.cta {
    display: inline-block;
    padding: var(--gv-space-2) var(--gv-space-4);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    background-color: var(--gv-surface);
    color: var(--gv-label);
    font-weight: 600;
}

.cta:hover {
    background-color: var(--gv-surface-strong);
    color: var(--gv-link-hover);
    text-decoration: none;
}

.indi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--gv-space-3);
    margin: var(--gv-space-4) 0;
}

.indi-card {
    display: block;
    padding: var(--gv-space-3);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    background-color: var(--gv-surface);
    color: var(--gv-text);
    box-shadow: var(--gv-shadow-sm);
    transition: transform 90ms ease, box-shadow 90ms ease;
}

.indi-card--female {
    background-color: var(--gv-female);
    border-color: var(--gv-female-border);
}

.indi-card:hover {
    text-decoration: none;
    background-color: var(--gv-surface-strong);
    color: var(--gv-link-hover);
    transform: translateY(-2px);
    box-shadow: var(--gv-shadow-md);
}

.indi-card__name {
    display: block;
    font-weight: 600;
    margin-bottom: 2px;
}

.indi-card__dates {
    display: block;
    font-size: 0.85rem;
    color: var(--gv-text-muted);
}

.pagination {
    display: flex;
    gap: var(--gv-space-4);
    margin: var(--gv-space-6) 0;
}

.person__header {
    margin-bottom: var(--gv-space-4);
    padding-bottom: var(--gv-space-3);
    border-bottom: 1px solid var(--gv-border);
}

.person__sub {
    color: var(--gv-text-muted);
    font-size: 0.9rem;
}

.detail-links {
    margin-top: var(--gv-space-2);
    font-size: 0.92rem;
    line-height: 1.6;
}
.detail-links-label {
    color: var(--gv-text-muted);
    font-weight: 600;
    margin-right: var(--gv-space-2);
}
.detail-links a + a::before {
    content: " · ";
    color: var(--gv-text-muted);
}

.person__media {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gv-space-2);
    margin: var(--gv-space-4) 0;
}

.media-thumb img {
    max-height: 100px;
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    padding: 3px;
    background-color: var(--gv-bg);
}

.media-thumb:hover img {
    border-color: var(--gv-link-hover);
}

.person-list {
    list-style: none;
    padding: 0;
    margin: var(--gv-space-3) 0;
}

.person-list__item,
.person-list__item--female {
    padding: var(--gv-space-2) var(--gv-space-3);
    margin-bottom: 2px;
    background-color: var(--gv-surface);
    border-left: 4px solid var(--gv-border);
    border-radius: var(--gv-radius);
}

.person-list__item--female {
    background-color: var(--gv-female);
    border-left-color: var(--gv-female-border);
}

/* --- Close Relatives blocks (per-family grouping on /people/{xref}) --- */

.family-block {
    margin: var(--gv-space-3) 0;
    background: var(--gv-surface);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    padding: var(--gv-space-3);
}

.family-block--parent {
    border-left: 4px solid #9ca3d4;
}

.family-block--spouse {
    border-left: 4px solid #d8a86a;
}

.family-block__header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--gv-space-2);
    margin-bottom: var(--gv-space-2);
}

.family-block__header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
}

.family-block__xref {
    font-size: 0.85rem;
    color: var(--gv-text-muted);
}

.family-block__divorced {
    color: #b45309;
    font-weight: 500;
    font-size: 0.9em;
}

.family-table {
    width: 100%;
    border-collapse: collapse;
}

.family-table th,
.family-table td {
    padding: var(--gv-space-1) var(--gv-space-2);
    text-align: left;
    vertical-align: top;
}

.family-table__role {
    width: 7.5em;
    color: var(--gv-text-muted);
    font-weight: 500;
    font-size: 0.9em;
}

.family-table__row--focal td,
.family-table__row--focal th {
    background: #fffbe6;
}

.family-table__row--add td a {
    margin-right: var(--gv-space-2);
    font-size: 0.9em;
}

.person-link {
    text-decoration: none;
    color: var(--gv-link);
}

.person-link:hover {
    text-decoration: underline;
}

.person-link--female {
    color: #a64b9d;
}

.person-link--male {
    color: #2f5b9c;
}

.pedi-pill {
    display: inline-block;
    padding: 0 0.4em;
    font-size: 0.75em;
    background: #fef3c7;
    color: #92400e;
    border-radius: 0.4em;
    text-transform: lowercase;
    margin-left: 0.3em;
}

/* --- Letter index & search & calendar ------------------------------ */

.letter-index {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gv-space-2);
    margin: var(--gv-space-3) 0 var(--gv-space-4);
    padding: var(--gv-space-2);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    background-color: var(--gv-surface-soft);
}

.letter-index a {
    display: inline-block;
    min-width: 1.8em;
    padding: 2px 6px;
    border-radius: var(--gv-radius);
    text-align: center;
}

.letter-index a.is-active,
.letter-index a:hover {
    background-color: var(--gv-surface-strong);
    color: var(--gv-link-hover);
    text-decoration: none;
}

/* Surname index — a compact responsive multi-column flow instead of a single
   tall narrow table, so 140+ surnames use the full page width (mirrors legacy
   PGV's columnar surname list). Each row keeps its name/count pair together. */
.surname-list {
    list-style: none;
    margin: var(--gv-space-4) 0;
    padding: 0;
    columns: 15rem auto;
    column-gap: var(--gv-space-5);
}

.surname-list li {
    break-inside: avoid;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--gv-space-3);
    padding: 3px 2px;
    border-bottom: 1px solid var(--gv-border);
}

.surname-list .surname-count {
    color: var(--gv-muted);
    font-variant-numeric: tabular-nums;
}

.search-form {
    display: flex;
    gap: var(--gv-space-3);
    margin: var(--gv-space-4) 0;
}

.search-form input[type="search"],
.search-form input[type="text"],
.search-form input:not([type]) {
    flex: 1;
    padding: var(--gv-space-2) var(--gv-space-3);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    background-color: var(--gv-bg);
    font: inherit;
}

.search-form input:focus {
    outline: 2px solid var(--gv-accent);
    outline-offset: 1px;
    border-color: var(--gv-accent);
}

.search-form button {
    padding: var(--gv-space-2) var(--gv-space-4);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    background-color: var(--gv-surface-strong);
    color: var(--gv-label);
    cursor: pointer;
    font: inherit;
    font-weight: 600;
}

.search-form button:hover {
    background-color: var(--gv-surface);
    color: var(--gv-link-hover);
}

/* Calendar filter bar — match the app's form controls. Was unstyled native
   <select>s + an "Apply" button sitting loose above the day/month/year tables;
   give it the same surface-soft panel + bordered fields as .chart-toolbar. */
.cal-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--gv-space-2) var(--gv-space-3);
    margin: var(--gv-space-3) 0;
    padding: var(--gv-space-2) var(--gv-space-3);
    background: var(--gv-surface-soft);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
}

.cal-filters label {
    display: inline-flex;
    align-items: center;
    gap: var(--gv-space-2);
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--gv-label);
}

.cal-filters select {
    padding: var(--gv-space-1) var(--gv-space-2);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    background-color: var(--gv-bg);
    font: inherit;
    font-weight: 400;
    cursor: pointer;
}

.cal-filters button {
    padding: var(--gv-space-1) var(--gv-space-4);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    background-color: var(--gv-surface-strong);
    color: var(--gv-label);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.cal-filters button:hover {
    background-color: var(--gv-surface);
    color: var(--gv-link-hover);
}

.cal-nav {
    display: flex;
    gap: var(--gv-space-3);
    align-items: center;
    margin: var(--gv-space-3) 0 var(--gv-space-4);
}

/* Month view — single table; a top border + bold day label separates day groups
   so they read as distinct days without repeating the column header per day. */
.cal-month-table .cal-day-start > td {
    border-top: 2px solid var(--gv-border);
}
.cal-month-table .cal-day-cell {
    font-weight: 600;
    white-space: nowrap;
}

.place-tree {
    list-style: none;
    padding-left: 0;
    margin-top: var(--gv-space-3);
}

.place-tree ul {
    list-style: none;
    padding-left: var(--gv-space-4);
    border-left: 1px dashed var(--gv-border);
    margin-left: var(--gv-space-2);
}

.place-tree > li {
    margin-top: var(--gv-space-2);
}

.place-tree li {
    padding: 2px 0;
}

.place-name {
    font-weight: 600;
}

.place-tree li > .muted {
    margin-left: 4px;
    font-size: 0.85em;
    background: var(--gv-surface-soft);
    padding: 0 6px;
    border-radius: 999px;
}

/* --- Charts -------------------------------------------------------- */

/* Wrapper hosts the connector SVG (absolute, behind the boxes) + the grid, and
   owns the horizontal scroll so both scroll together. */
.pedigree-wrap {
    position: relative;
    overflow-x: auto;
    margin: var(--gv-space-4) 0;
}

.pedigree-connectors {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 0;
    overflow: visible;
}

.pedigree-connector {
    stroke: var(--gv-border);
    stroke-width: 1.5;
    fill: none;
}

.pedigree-grid {
    display: grid;
    gap: var(--gv-space-3);
    position: relative;
    z-index: 1;
}

/* The wrap now owns horizontal scroll; keep the grid from clipping the overlay. */
.pedigree-wrap > .pedigree-grid {
    overflow: visible;
}

.pedigree-grid--g1 { grid-template-columns: repeat(1, minmax(180px, 1fr)); }
.pedigree-grid--g2 { grid-template-columns: repeat(2, minmax(170px, 1fr)); }
.pedigree-grid--g3 { grid-template-columns: repeat(3, minmax(160px, 1fr)); }
.pedigree-grid--g4 { grid-template-columns: repeat(4, minmax(160px, 1fr)); }
.pedigree-grid--g5 { grid-template-columns: repeat(5, minmax(140px, 1fr)); }
.pedigree-grid--g6 { grid-template-columns: repeat(6, minmax(130px, 1fr)); }

/* Portrait orientation: flip the grid so generations stack vertically
   instead of spreading horizontally. Useful on narrow viewports + when ancestor
   names are long. Generation N becomes row N instead of column N; each row has
   2^N person cells side-by-side. */
.pedigree-grid--portrait {
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(auto, max-content);
}
.pedigree-grid--portrait .pedigree-col {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--gv-space-2);
    align-content: flex-start;
    justify-content: center;
}
.pedigree-grid--portrait .pedigree-cell {
    flex: 1 1 calc(var(--pedigree-box-scale, 1) * 140px);
    min-width: calc(var(--pedigree-box-scale, 1) * 110px);
    max-width: calc(var(--pedigree-box-scale, 1) * 200px);
}

/* Box-width scale variable — works in landscape too via min/max
   widening; defaults to 1 so unset CSS inherits the existing layout. */
.pedigree-grid--landscape {
    grid-template-columns: repeat(var(--pedigree-cols, auto-fit), minmax(calc(var(--pedigree-box-scale, 1) * 130px), 1fr));
}

.pedigree-grid--compact {
    gap: var(--gv-space-1);
}
.pedigree-grid--compact .pedigree-col {
    gap: 2px;
}
.pedigree-grid--compact .pedigree-cell {
    min-height: 2.4em;
    padding: var(--gv-space-1) var(--gv-space-2);
    font-size: 0.8rem;
}
.pedigree-grid--compact .pedigree-name {
    font-size: 0.82rem;
    margin-bottom: 0;
}
.pedigree-grid--compact .pedigree-dates {
    font-size: 0.72rem;
}

.pedigree-col {
    display: grid;
    gap: var(--gv-space-2);
    align-content: space-around;
}

.pedigree-cell {
    background-color: var(--gv-surface);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    padding: var(--gv-space-2);
    min-height: 3em;
    font-size: 0.9rem;
}

.pedigree-cell--female {
    background-color: var(--gv-female);
    border-color: var(--gv-female-border);
}

.pedigree-cell--empty {
    background: repeating-linear-gradient(45deg, var(--gv-surface-soft), var(--gv-surface-soft) 4px, transparent 4px, transparent 8px);
    border-style: dashed;
}

.pedigree-name {
    display: block;
    font-weight: 600;
    margin-bottom: 2px;
}

.pedigree-dates {
    color: var(--gv-text-muted);
    font-size: 0.8rem;
}

.pedigree-thumb {
    display: block;
    width: 100%;
    max-width: 80px;
    max-height: 60px;
    object-fit: cover;
    border-radius: var(--gv-radius);
    margin-bottom: 4px;
    background-color: var(--gv-surface-soft);
}

.descendancy-tree {
    list-style: none;
    padding-left: 0;
    margin: var(--gv-space-3) 0;
}

.descendancy-tree--compact .descendancy-box {
    padding: 2px 6px;
    font-size: 0.82rem;
}

.descendancy-row {
    display: inline-flex;
    align-items: center;
    gap: var(--gv-space-2);
}

.descendancy-num {
    font-family: var(--gv-font-mono, monospace);
    font-size: 0.78rem;
    color: var(--gv-text-muted);
    min-width: 3.5em;
}

.descendancy-box {
    display: inline-flex;
    flex-direction: column;
    padding: var(--gv-space-1) var(--gv-space-2);
    background-color: var(--gv-surface);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    min-width: calc(var(--pedigree-box-scale, 1) * 140px);
    font-size: 0.9rem;
}

.descendancy-box--female {
    background-color: var(--gv-female);
    border-color: var(--gv-female-border);
}

.descendancy-box--male {
    background-color: var(--gv-male, var(--gv-surface));
    border-color: var(--gv-male-border, var(--gv-border));
}

.descendancy-box--empty {
    background: repeating-linear-gradient(45deg, var(--gv-surface-soft), var(--gv-surface-soft) 4px, transparent 4px, transparent 8px);
    border-style: dashed;
}

.descendancy-dates {
    font-size: 0.78rem;
}

.compact-thumb {
    display: block;
    margin: 0 auto 4px;
    max-width: calc(var(--pedigree-box-scale, 1) * 50px);
}
.compact-thumb img {
    width: 100%;
    height: auto;
    border-radius: 4px;
    display: block;
}
.compact-xref {
    display: block;
    font-family: var(--gv-font-mono, monospace);
    font-size: 0.7rem;
    margin-top: 1px;
}
.compact-reroot {
    display: inline-block;
    margin-top: 3px;
    padding: 0 4px;
    font-size: 0.8rem;
    text-decoration: none;
    color: var(--gv-text-muted);
    border: 1px solid var(--gv-border);
    border-radius: 3px;
    background: var(--gv-surface-soft);
}
.compact-reroot:hover {
    color: var(--gv-text);
    background: var(--gv-surface);
}

.descendancy-booklet {
    display: flex;
    flex-direction: column;
    gap: var(--gv-space-4);
    margin: var(--gv-space-3) 0;
}

.descendancy-fam {
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    padding: var(--gv-space-3);
    background: var(--gv-surface);
}

.descendancy-fam__head {
    font-size: 0.85rem;
    margin-bottom: var(--gv-space-2);
}

.descendancy-fam__marriage {
    color: var(--gv-text-muted);
}

.descendancy-fam__spouses {
    display: flex;
    align-items: center;
    gap: var(--gv-space-2);
    flex-wrap: wrap;
}

.descendancy-fam__amp {
    color: var(--gv-text-muted);
    font-size: 1.2rem;
}

.descendancy-fam__children {
    margin-top: var(--gv-space-3);
    padding-left: var(--gv-space-3);
    border-left: 2px solid var(--gv-border);
}

.descendancy-fam__children-label {
    font-size: 0.8rem;
    margin-bottom: var(--gv-space-2);
}

.descendancy-fam__children-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gv-space-2);
}

.ancestry-cousins {
    margin-top: var(--gv-space-3);
    padding-left: var(--gv-space-3);
    border-left: 2px solid var(--gv-border);
}

.ancestry-cousins__head {
    font-size: 0.85rem;
    margin: 0 0 var(--gv-space-2) 0;
    color: var(--gv-text-muted);
    font-weight: 600;
}

.ancestry-cousins__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--gv-space-3);
}

.ancestry-cousins__sib {
    display: flex;
    flex-direction: column;
    gap: var(--gv-space-2);
}

.ancestry-cousins__spousefam {
    margin-left: var(--gv-space-3);
    padding-left: var(--gv-space-2);
    border-left: 1px dashed var(--gv-border);
}

.ancestry-cousins__spouserow {
    display: flex;
    align-items: center;
    gap: var(--gv-space-2);
    flex-wrap: wrap;
}

.ancestry-cousins__amp {
    color: var(--gv-text-muted);
    font-size: 1.1rem;
}

.ancestry-cousins__faml {
    font-size: 0.85rem;
}

.ancestry-cousins__kids {
    margin-top: var(--gv-space-2);
    margin-left: var(--gv-space-3);
    display: flex;
    flex-wrap: wrap;
    gap: var(--gv-space-2);
}

.branches-form {
    display: flex;
    gap: var(--gv-space-3);
    align-items: center;
    flex-wrap: wrap;
    margin: var(--gv-space-3) 0;
    padding: var(--gv-space-2) var(--gv-space-3);
    background: var(--gv-surface-soft);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
}

.branch-tree,
.branch-children {
    list-style: none;
    padding-left: var(--gv-space-3);
    margin: var(--gv-space-2) 0;
    border-left: 1px dashed var(--gv-border);
}

.branch-tree {
    padding-left: 0;
    border-left: none;
}

.branch-tree > li,
.branch-children > li {
    margin: var(--gv-space-2) 0;
}

.branch-person {
    display: inline-flex;
    align-items: baseline;
    gap: var(--gv-space-2);
    padding: 1px 4px;
    border-radius: 3px;
}

.branch-person.branch-male {
    background: var(--gv-male-soft, #e6f0ff);
}

.branch-person.branch-female {
    background: var(--gv-female-soft, #ffe6f0);
}

.branch-person.branch-matched {
    outline: 1px solid var(--gv-accent, #6a8);
}

.branch-family {
    margin-top: var(--gv-space-2);
    padding-left: var(--gv-space-3);
}

.branch-join {
    color: var(--gv-text-muted);
    margin-right: var(--gv-space-2);
}

.branch-marriage {
    margin-left: var(--gv-space-2);
    font-size: 0.85rem;
}

.treenav-canvas {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    background: var(--gv-surface);
    margin: var(--gv-space-3) 0;
    height: 600px;
    cursor: grab;
    touch-action: none;
}

.treenav-canvas:focus {
    outline: 2px solid var(--gv-accent, #6a8);
    outline-offset: 2px;
}

.chart-canvas--panning {
    cursor: grabbing;
}

/* Shared pan/zoom-enabled chart container (Lifespan, Timeline). Reuses the
   treenav-canvas styling but doesn't fix height (charts auto-size to content). */
.chart-canvas {
    position: relative;
    cursor: grab;
    touch-action: none;
}

.chart-canvas:focus {
    outline: 2px solid var(--gv-accent, #6a8);
    outline-offset: 2px;
}

/* Compact-chart directional cue — small ‹ arrow between columns pointing toward the
   parents column (left-to-right reading: each cell visually points back at "their
   parents are over there"). Pure CSS; no markup change required. */
.pedigree-grid--compact .pedigree-col:not(:first-child) {
    position: relative;
}

.pedigree-grid--compact .pedigree-col:not(:first-child)::before {
    content: "›";
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gv-muted);
    font-size: 1.1em;
    pointer-events: none;
}

.treenav-canvas svg {
    display: block;
    max-width: none;
}

.treenav-zoom {
    position: absolute;
    top: var(--gv-space-2);
    right: var(--gv-space-2);
    display: flex;
    gap: 2px;
    background: var(--gv-surface);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    padding: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.treenav-zoom button {
    min-width: 32px;
    padding: 2px 8px;
    font-size: 0.85rem;
    background: transparent;
    border: 0;
    cursor: pointer;
    color: var(--gv-text);
}

.treenav-zoom button:hover {
    background: var(--gv-surface-soft);
}

.treenav-hint {
    font-size: 0.85rem;
}

.treenav-reroot:hover rect {
    fill: #fbbf24;
}

.chart-toolbar {
    display: flex;
    gap: var(--gv-space-3);
    align-items: center;
    margin: var(--gv-space-3) 0;
    padding: var(--gv-space-2) var(--gv-space-3);
    background: var(--gv-surface-soft);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    flex-wrap: wrap;
}
.chart-toolbar label {
    display: inline-flex;
    gap: var(--gv-space-2);
    align-items: center;
    font-size: 0.9rem;
}
.chart-toolbar select,
.chart-toolbar input[type="text"],
.chart-toolbar input[type="number"] {
    padding: 2px 6px;
    font-size: 0.9rem;
}

.familybook {
    margin-top: var(--gv-space-4);
}
.familybook-root {
    max-width: 320px;
    margin: var(--gv-space-3) auto;
    text-align: center;
    border-width: 2px;
}

@media print {
    /* Family Book is dense; the legacy print layout broke ancestor block / root box
       / descendant list onto separate pages so each section is self-contained.
       page-break-before: always — modern browsers honor the legacy property; the
       newer `break-before: page` would also work but breaks IE/older mobile. */
    .familybook-root { break-before: page; page-break-before: always; }
    .familybook h2 { break-before: page; page-break-before: always; break-after: avoid; }
}

.chart-people {
    list-style: none;
    padding-left: 0;
    margin: var(--gv-space-2) 0;
    font-size: 0.9rem;
}
.chart-people li {
    margin: 2px 0;
    display: flex;
    gap: var(--gv-space-2);
    align-items: center;
    flex-wrap: wrap;
}
.chart-people__swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.2);
}
.chart-people__remove {
    color: var(--gv-text-muted);
    font-size: 0.8rem;
}

.chart-svg-wrap {
    overflow-x: auto;
    /* Full-bleed: break out of the centered `main.container` max-width so
       wide charts (Hourglass, Lifespan, Timeline) can use the full viewport
       instead of scrolling inside a narrow column with empty space on both
       sides. The negative margins are symmetric around the centered parent. */
    margin-top: var(--gv-space-3);
    margin-bottom: var(--gv-space-3);
    margin-left: calc(50% - 50vw);
    margin-right: calc(50% - 50vw);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    background: var(--gv-surface);
    padding: var(--gv-space-2);
}

.descendancy-tree ul {
    list-style: none;
    padding-left: var(--gv-space-4);
    border-left: 1px dashed var(--gv-border);
    margin-left: var(--gv-space-2);
}

.descendancy-tree li {
    padding: 4px 0;
}

.treenav details {
    margin: var(--gv-space-3) 0;
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    padding: var(--gv-space-3);
    background-color: var(--gv-surface-soft);
}

.treenav summary {
    font-weight: 600;
    cursor: pointer;
}

/* --- Media gallery + manage --------------------------------------- */

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--gv-space-3);
    margin: var(--gv-space-4) 0;
}

.media-grid__card {
    margin: 0;
    background-color: var(--gv-surface-soft);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    padding: var(--gv-space-2);
    display: flex;
    flex-direction: column;
    gap: var(--gv-space-2);
    font-size: 0.85rem;
}

.media-grid__card img {
    width: 100%;
    height: 120px;
    object-fit: cover;
    border-radius: var(--gv-radius);
    background-color: var(--gv-surface);
    display: block;
}

.media-grid__card figcaption {
    line-height: 1.2;
    color: var(--gv-text-muted);
    word-break: break-word;
}

.media-grid__actions {
    display: flex;
    gap: var(--gv-space-1);
    align-items: center;
}

.media-grid__actions button {
    padding: 2px 6px;
    font-size: 0.8rem;
    line-height: 1;
}

.media-manage {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
    gap: var(--gv-space-4);
    margin: var(--gv-space-4) 0;
    align-items: start;
}

.media-manage__preview {
    max-width: 100%;
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    background-color: var(--gv-surface);
    padding: 4px;
}

.media-add-row {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(280px, 1fr);
    gap: var(--gv-space-4);
    margin: var(--gv-space-4) 0;
    align-items: start;
}

.auth-form--inline {
    margin: 0;
}

.record-list {
    list-style: none;
    padding-left: 0;
    margin: var(--gv-space-2) 0;
}

.record-list li {
    padding: 2px 0;
}

.danger-zone {
    margin-top: var(--gv-space-4);
    padding: var(--gv-space-3);
    border: 1px solid #f0c0c0;
    background-color: #fdf2f2;
    border-radius: var(--gv-radius);
}

.danger-zone summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--gv-danger);
}

button.danger {
    background-color: var(--gv-danger);
    color: #ffffff;
    border-color: var(--gv-danger-strong);
}
/* Override .link-button:hover (which sets color to --gv-link-hover, a near-red
   that turns invisible on the danger button's red background). */
button.danger:hover,
button.danger:focus-visible {
    background-color: var(--gv-danger-strong);
    color: #ffffff;
    text-decoration: none;
}

/* Ghost-danger: a link-styled destructive action that lives inline in tables
   (e.g. Delete on /admin/users). The solid-red `.danger` treatment is too
   loud when repeated once per row; ghost mode keeps the affordance with a
   red glyph + hover fill. */
.link-button.danger {
    background: transparent;
    border: 0;
    color: var(--gv-danger);
    padding: 0;
    text-decoration: none;
}

.link-button.danger:hover,
.link-button.danger:focus-visible {
    background: transparent;
    color: var(--gv-danger-strong);
    text-decoration: underline;
}

.notice--error {
    border-left-color: var(--gv-danger);
    background-color: var(--gv-danger-tint);
}

.notice--clipboard {
    display: flex;
    gap: var(--gv-space-3);
    align-items: center;
    flex-wrap: wrap;
    background-color: #fffbea;
    border-left-color: #d4a72c;
}

.reorder-list {
    list-style: none;
    padding: 0;
    margin: var(--gv-space-4) 0;
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
}

.reorder-list__row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--gv-space-2) var(--gv-space-3);
    border-bottom: 1px solid var(--gv-border);
}

.reorder-list__row:last-child {
    border-bottom: none;
}

.reorder-list__actions {
    display: inline-flex;
    gap: var(--gv-space-1);
}

.edit-fact-copy-row {
    margin-top: var(--gv-space-2);
    padding-top: var(--gv-space-2);
    border-top: 1px dashed var(--gv-border);
}

/* Chart hover-links popup — opens on click of any [data-chart-person] element
   inside Pedigree cells or Fanchart wedges. Floats over the page; positioned
   in JS so it can land outside the SVG. */
.chart-hover-popup {
    position: absolute;
    background: #ffffff;
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    padding: var(--gv-space-2);
    z-index: 1000;
    min-width: 140px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 0.9em;
}

.chart-hover-popup__heading {
    font-weight: 600;
    color: var(--gv-muted);
    border-bottom: 1px solid var(--gv-border);
    padding-bottom: 4px;
    margin-bottom: 4px;
    font-family: var(--gv-font-mono, monospace);
}

.chart-hover-popup a {
    padding: 4px 8px;
    border-radius: 4px;
    text-decoration: none;
    color: var(--gv-text);
}

.chart-hover-popup a:hover,
.chart-hover-popup a:focus-visible {
    background-color: var(--gv-bg-alt);
    text-decoration: none;
}

[data-chart-person] {
    cursor: pointer;
}

/* Family-popup nav rendered below the root box on Pedigree / Hourglass / Family Book.
   One row of grouped, comma-separated links per relation. */
.family-popup-nav {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gv-space-4);
    margin: var(--gv-space-3) 0;
    padding: var(--gv-space-2) var(--gv-space-3);
    background: var(--gv-bg-alt, #f5f7fb);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    font-size: 0.92em;
}

.family-popup-nav__group {
    display: flex;
    align-items: baseline;
    gap: 4px;
    flex-wrap: wrap;
}

.family-popup-nav__label {
    font-weight: 600;
    color: var(--gv-muted);
    margin-right: 4px;
}

.family-popup-nav__group a + a::before {
    /* Names render "Surname, Given" (internal comma), so a comma separator between
       people reads ambiguously ("Носов, Виктор , Гаврилюк, Нинэль"). A middot —
       the separator used elsewhere in the chrome — keeps the people visually distinct. */
    content: "· ";
    color: var(--gv-muted);
}

.pager {
    display: flex;
    gap: var(--gv-space-3);
    align-items: center;
    margin: var(--gv-space-4) 0;
}

@media (max-width: 800px) {
    .media-manage,
    .media-add-row {
        grid-template-columns: 1fr;
    }
}

/* --- Lightbox ----------------------------------------------------- */

html.lb-noscroll, html.lb-noscroll body {
    overflow: hidden;
}

.lb-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.86);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.lb-overlay--open {
    display: flex;
}

.lb-stage {
    margin: 0;
    max-width: 92vw;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--gv-space-2);
}

.lb-image {
    max-width: 92vw;
    max-height: 80vh;
    object-fit: contain;
    background-color: #1a1a1a;
    border: 1px solid #444;
}

.lb-caption {
    color: #f0f0f0;
    font-size: 0.9rem;
    text-align: center;
}

.lb-caption a {
    color: #b0d4ff;
}

.lb-close,
.lb-prev,
.lb-next {
    position: absolute;
    background-color: rgba(0, 0, 0, 0.4);
    color: #f0f0f0;
    border: 1px solid #555;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 1.4rem;
    line-height: 42px;
    text-align: center;
    cursor: pointer;
    padding: 0;
}

.lb-close { top: 16px; right: 16px; }
.lb-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 16px; top: 50%; transform: translateY(-50%); }

.lb-close:hover,
.lb-prev:hover,
.lb-next:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* --- Reports ----------------------------------------------------- */

.report-list {
    list-style: none;
    padding: 0;
    margin: var(--gv-space-3) 0;
}

.report-list li {
    margin: var(--gv-space-2) 0;
}

.report-list a {
    font-weight: 600;
}

.report-list__desc {
    display: block;
    color: var(--gv-text-muted);
    font-size: 0.92rem;
    margin-top: 2px;
}

.report-form {
    max-width: 520px;
    margin-top: var(--gv-space-3);
}

/* --- Charts index ------------------------------------------------ */

.chart-list {
    list-style: none;
    padding: 0;
    margin: var(--gv-space-3) 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--gv-space-2);
}

/* Admin hub — a card grid of tool links instead of a bare bullet list, matching
   the charts/reports index look. */
.admin-hub {
    list-style: none;
    padding: 0;
    margin: var(--gv-space-3) 0 var(--gv-space-5);
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--gv-space-2);
}

.admin-hub li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--gv-space-2);
    background: var(--gv-surface-soft);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    padding: var(--gv-space-3);
    margin: 0;
}

.admin-hub a {
    font-weight: 600;
}

.admin-hub__meta {
    background: var(--gv-surface-strong);
    color: var(--gv-muted);
    border-radius: 999px;
    padding: 0 var(--gv-space-2);
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

/* Change-queue diff: "Before"/"After" are column captions, not document
   sections — rendering them as a label (was <h4>) avoids the h1->h4 heading
   outline jump on /admin/changes (WCAG 1.3.1). */
.diff-label {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--gv-text-muted);
    margin-bottom: var(--gv-space-1);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.chart-list li {
    background: var(--gv-surface-soft);
    padding: var(--gv-space-3);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    margin: 0;
}

/* Shared hover affordance for the index card grids so the whole card reads as a
   target, not just the link text. */
.admin-hub li,
.chart-list li {
    transition: border-color 90ms ease, box-shadow 90ms ease, background-color 90ms ease;
}
.admin-hub li:hover,
.chart-list li:hover,
.admin-hub li:focus-within,
.chart-list li:focus-within {
    border-color: var(--gv-accent);
    box-shadow: 0 1px 4px rgba(52, 80, 136, 0.18);
}

.chart-list a {
    font-weight: 600;
    display: inline-block;
    margin-bottom: 4px;
}

.chart-list__desc {
    display: block;
    color: var(--gv-text-muted);
    font-size: 0.92rem;
}

.charts-index-picker {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--gv-space-2);
    margin: var(--gv-space-3) 0;
}

.charts-index-picker label {
    font-weight: 600;
}

.charts-index-picker input[type="text"] {
    width: 12rem;
}

.charts-index-picker p.muted {
    flex-basis: 100%;
    margin: 0;
}

/* --- Family spouses ------------------------------------------------ */

.family-spouses {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gv-space-2);
    margin: var(--gv-space-3) 0;
}

.family-spouses__cell {
    background: var(--gv-surface-soft);
    padding: var(--gv-space-2);
    border-left: 4px solid #bcd3eb;
    border-radius: 4px;
}

.family-spouses__cell--female {
    border-left-color: #e8b8c9;
    background: #fdf5f8;
}

.family-spouses__cell--male {
    border-left-color: #b3cbe0;
    background: #f3f7fb;
}

.family-spouses__cell h3 {
    margin: 0 0 4px;
    font-size: 0.92rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--gv-text-muted);
}

.family-spouses__name {
    font-size: 1.1rem;
    margin-bottom: 2px;
}

.family-spouses__name .xref-pill {
    margin-left: 6px;
    font-size: 0.78rem;
    padding: 1px 6px;
}

.family-spouses__dates {
    font-size: 0.92rem;
}

@media (max-width: 640px) {
    .family-spouses {
        grid-template-columns: 1fr;
    }
}

.chart-controls {
    display: flex;
    gap: var(--gv-space-2);
    align-items: center;
    margin: var(--gv-space-2) 0;
}

.chart-controls label {
    font-weight: 600;
}

.report-form .form-row {
    margin-bottom: var(--gv-space-3);
}

.report-form label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
}

.report-form input[type="text"],
.report-form input[type="number"],
.report-form input[type="search"],
.report-form input[type="email"],
.report-form input[type="url"],
.report-form input[type="tel"],
.report-form input[type="date"],
.report-form input[type="password"],
.report-form input:not([type]),
.report-form select,
.report-form textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 8px;
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    font-size: 1rem;
    font-family: inherit;
    background-color: var(--gv-bg);
    color: var(--gv-text);
}

.report-form input:focus,
.report-form select:focus,
.report-form textarea:focus {
    outline: 2px solid var(--gv-accent);
    outline-offset: 1px;
    border-color: var(--gv-accent);
}

.report-form .form-row label input[type="checkbox"] {
    margin-right: 6px;
}

.report-form .primary-button {
    padding: 8px 14px;
    background-color: #335577;
    color: #fff;
    border: 1px solid #224466;
    border-radius: 3px;
    font-size: 1rem;
    cursor: pointer;
}

.report-form .primary-button:hover {
    background-color: #224466;
}

/* Block banner for whole-form errors (used as `<p class="form-error">`). */
.form-error {
    background-color: var(--gv-danger-tint);
    border-left: 4px solid var(--gv-danger);
    padding: 8px 12px;
    margin: var(--gv-space-3) 0;
}

/* Inline field-level errors — `<span asp-validation-for="...">` renders empty
   when ModelState is valid. Without :empty the banner styling above paints an
   empty red bar between every field. The non-empty case still shows red text,
   sized to fit inline next to the input. */
.form-error:empty {
    display: none;
}
/* `<div asp-validation-summary="...">` renders a non-empty wrapper
   (`<ul><li style="display:none"></li></ul>`) even when ModelState is valid,
   so `:empty` misses it. Tag Helpers add this marker class for the valid case. */
.form-error.validation-summary-valid {
    display: none;
}
span.form-error {
    display: inline-block;
    background: transparent;
    border-left: 0;
    padding: 0;
    margin: 0;
    color: var(--gv-danger);
    font-size: 0.9em;
}

/* Success / hint sibling helpers used alongside .form-error. */
.form-success {
    background-color: #ecfdf5;
    border-left: 4px solid #047857;
    padding: 8px 12px;
    margin: var(--gv-space-3) 0;
}
.form-hint {
    display: block;
    color: var(--gv-text-muted);
    font-weight: 400;
    font-size: 0.85em;
}

/* --- Generic form grids (messages, settings, broadcast, admin users) -------
   Each `<label>` wraps its label-text + the input itself, so we lay the form
   out as a single column where each label is a block with stacked rows:
   label name on top, input below. The button sits as the last block. */
.form-grid,
.settings-form {
    display: flex;
    flex-direction: column;
    gap: var(--gv-space-3);
    max-width: 560px;
    margin: var(--gv-space-4) 0;
    padding: var(--gv-space-4);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    background-color: var(--gv-surface-soft);
}
.form-grid > label,
.settings-form > label,
.settings-form > .settings-readonly {
    display: flex;
    flex-direction: column;
    gap: var(--gv-space-1);
    font-weight: 600;
    color: var(--gv-label);
}
.settings-readonly .xref-pill {
    align-self: flex-start;
    font-weight: normal;
}
.form-grid > label.checkbox,
.settings-form > label.checkbox {
    flex-direction: row;
    align-items: center;
    gap: var(--gv-space-2);
    font-weight: 400;
}
.form-grid > label.checkbox input[type="checkbox"],
.settings-form > label.checkbox input[type="checkbox"] {
    width: auto;
    flex-shrink: 0;
}
/* The .inline-form class is a marker on <form>s that should flow inline with
   adjacent buttons/links rather than dropping to their own line — used in
   tables where a row's actions (Edit / Delete / Mark read) sit side-by-side. */
.inline-form {
    display: inline-block;
    margin-left: var(--gv-space-2);
    vertical-align: middle;
}
.inline-form:first-child {
    margin-left: 0;
}
.form-grid input,
.form-grid select,
.form-grid textarea,
.settings-form input,
.settings-form select,
.settings-form textarea {
    font: inherit;
    padding: var(--gv-space-2) var(--gv-space-3);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    background-color: var(--gv-bg);
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}
.form-grid textarea,
.settings-form textarea {
    font-family: var(--gv-font);
    line-height: 1.45;
    resize: vertical;
}
.form-grid button[type="submit"],
.settings-form button[type="submit"] {
    align-self: flex-start;
    font: inherit;
    padding: var(--gv-space-2) var(--gv-space-4);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    background-color: var(--gv-surface-strong);
    color: var(--gv-label);
    cursor: pointer;
    font-weight: 600;
}
.form-grid button[type="submit"]:hover,
.settings-form button[type="submit"]:hover {
    background-color: var(--gv-surface);
    color: var(--gv-link-hover);
}

/* Admin's "Add user" Create form is a single horizontal row of small fields
   followed by a submit — use the same shell but lay labels out side-by-side. */
.form-grid.form-grid--row {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-end;
    max-width: 100%;
}
.form-grid.form-grid--row > label {
    flex: 1 1 180px;
}

/* /search/advanced packs 8 short fields — let them flow into 2–4 columns
   depending on width. The form-grid container around them keeps the shared
   surface treatment from above. */
.advanced-search .form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    max-width: 880px;
}
/* Let the soundex checkbox sit next to the Surname cell and span 2 columns so
   the multi-line phonetic-match explanation has room to read without wrapping
   to a 3rd line. Inherits flex-row + auto-width-checkbox from `label.checkbox`
   in the `.form-grid > label.checkbox` rule above. */
.advanced-search__soundex {
    grid-column: span 2;
    align-items: flex-start !important;
    font-size: 0.85em;
}
.advanced-search > button[type="submit"] {
    margin-top: var(--gv-space-3);
    font: inherit;
    padding: var(--gv-space-2) var(--gv-space-4);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    background-color: var(--gv-surface-strong);
    color: var(--gv-label);
    cursor: pointer;
    font-weight: 600;
}
.advanced-search > button[type="submit"]:hover {
    background-color: var(--gv-surface);
    color: var(--gv-link-hover);
}

/* --- Statistics page (M11) -------------------------------------------------- */
.stats-tabs {
    display: flex;
    gap: var(--gv-space-2);
    margin: var(--gv-space-3) 0;
    border-bottom: 1px solid #c7c7c0;
}
.stats-tabs a {
    padding: 6px 14px;
    text-decoration: none;
    background: #efeeea;
    border: 1px solid #c7c7c0;
    border-bottom: none;
    border-radius: 4px 4px 0 0;
    color: #335577;
}
.stats-tabs a:hover { background: #fff; }

.stats-section {
    margin-bottom: var(--gv-space-5);
    scroll-margin-top: 80px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--gv-space-3);
    margin-bottom: var(--gv-space-3);
}

.stats-card {
    background: #fafaf6;
    border: 1px solid #d8d6cf;
    padding: var(--gv-space-3);
    margin-bottom: var(--gv-space-3);
    border-radius: 4px;
}
.stats-card h3 { margin-top: 0; }

.stats-twocol {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--gv-space-3);
}

.stats-kv {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--gv-space-2);
}
.stats-kv th {
    text-align: left;
    color: #555;
    font-weight: 500;
    padding: 4px 8px 4px 0;
}
.stats-kv td {
    padding: 4px 16px 4px 0;
    font-weight: 600;
}

.stat-chart {
    display: block;
    max-width: 100%;
    height: auto;
    margin: var(--gv-space-2) 0;
}

.stats-list {
    padding-left: 1.4em;
    margin: 0 0 var(--gv-space-2);
}
.stats-list li { margin-bottom: 2px; }

/* --- Maps (M11) ------------------------------------------------------------ */
.map-fullwidth {
    position: relative;
    width: 100%;
    height: 480px;
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    margin: var(--gv-space-3) 0;
}
.map-mini {
    position: relative;
    width: 100%;
    height: 260px;
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    margin: var(--gv-space-2) 0;
}
.map-mini .leaflet-control-attribution,
.map-fullwidth .leaflet-control-attribution {
    font-size: 0.7rem;
}
/* Shown by maps.js only when every tile request fails (offline / OSM unreachable).
   Sits above the blank tile pane (z 200) but below Leaflet's zoom controls (z 1000),
   and ignores pointer events so the map stays pannable. */
.map-offline-note {
    position: absolute;
    inset: 0;
    z-index: 450;
    display: grid;
    place-items: center;
    margin: 0;
    padding: var(--gv-space-4);
    text-align: center;
    color: var(--gv-text-muted);
    background: var(--gv-surface-soft);
    font-size: 0.9rem;
    pointer-events: none;
}

.place-coord-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--gv-space-2);
    align-items: end;
    margin: var(--gv-space-3) 0;
}
.place-coord-form label {
    display: flex;
    flex-direction: column;
    font-size: 0.9rem;
    color: #555;
}
.place-coord-form input {
    padding: 6px 8px;
    border: 1px solid #aaa;
    border-radius: 3px;
    font-size: 1rem;
}
.place-coord-form button {
    padding: 8px 14px;
    background: #335577;
    color: #fff;
    border: 1px solid #224466;
    border-radius: 3px;
    font-size: 1rem;
    cursor: pointer;
}
.place-coord-form button:hover { background: #224466; }

.home-surnames {
    margin-top: var(--gv-space-4);
}

/* --- Error pages (M12) ------------------------------------------------------ */
.error-page {
    max-width: 540px;
    margin: var(--gv-space-5) auto;
    text-align: center;
}
.error-page .error-code {
    font-size: 4rem;
    font-weight: 200;
    color: #888;
    margin: 0;
}
.error-page h1 {
    margin: var(--gv-space-1) 0 var(--gv-space-3);
}
.error-page .error-trace {
    margin-top: var(--gv-space-4);
    color: #999;
}

/* --- Shared notes ---------------------------------------------------------- */
.notes-list {
    list-style: none;
    padding: 0;
    margin: var(--gv-space-3) 0 var(--gv-space-6);
}
.note-entry {
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    background: var(--gv-surface-soft);
    padding: var(--gv-space-3) var(--gv-space-4);
    margin-bottom: var(--gv-space-3);
}
.note-entry h3 {
    margin: 0 0 var(--gv-space-2);
    font-size: 1rem;
}
.note-entry__link {
    display: inline-flex;
    align-items: center;
    gap: var(--gv-space-2);
    text-decoration: none;
    color: var(--gv-link);
}
.note-entry__link:hover {
    color: var(--gv-link-hover);
    text-decoration: underline;
}
.xref-pill {
    display: inline-block;
    font-family: var(--gv-font-mono);
    font-size: 0.85em;
    background: var(--gv-surface-strong);
    color: var(--gv-text);
    padding: 0 var(--gv-space-2);
    border-radius: var(--gv-radius);
    border: 1px solid var(--gv-border);
}
/* Inbox marker for messages with no sender account (public contact form / legacy
   anonymous): warning-tinted so a typed-in "admin" name can't read as internal. */
.external-pill {
    display: inline-block;
    font-size: 0.78em;
    background: #fdf3e3;
    color: #8a5a00;
    padding: 0 var(--gv-space-2);
    border-radius: var(--gv-radius);
    border: 1px solid #e8c98a;
    cursor: help;
    vertical-align: middle;
}
.note-body {
    margin: 0;
    padding: var(--gv-space-2);
    background: #fff;
    border: 1px dashed var(--gv-border);
    border-radius: var(--gv-radius);
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: var(--gv-font-mono);
    font-size: 0.9rem;
    color: var(--gv-text);
    max-height: 30em;
    overflow: auto;
}
.note-detail header h1 {
    display: flex;
    align-items: center;
    gap: var(--gv-space-2);
    flex-wrap: wrap;
}
.note-references {
    margin-top: var(--gv-space-4);
}

/* Contextual help — round "?" trigger placed inline next to a form label,
   opens a modal <dialog> rendered by HelpTagHelper. The selector is
   button.help-trigger so its specificity (0,1,1) ties with form-button
   rules like .auth-form button; since this block is declared later in the
   file, the help-trigger styling wins on equal specificity. */
button.help-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    margin-left: var(--gv-space-1);
    padding: 0;
    border: 1px solid var(--gv-border);
    border-radius: 50%;
    background: var(--gv-surface-soft);
    color: var(--gv-accent);
    font: 600 0.8rem/1 var(--gv-font);
    cursor: pointer;
    vertical-align: middle;
}
button.help-trigger:hover,
button.help-trigger:focus-visible {
    background: var(--gv-surface);
    color: var(--gv-link-hover);
    outline: none;
}
.help-dialog {
    max-width: 32rem;
    padding: var(--gv-space-4) var(--gv-space-6);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    color: var(--gv-text);
    background: var(--gv-bg);
}
.help-dialog::backdrop {
    background: rgba(15, 23, 42, 0.45);
}
.help-dialog h2 {
    margin: 0 0 var(--gv-space-3);
    font-size: 1.1rem;
    color: var(--gv-accent);
}
.help-dialog__body {
    font-size: 0.95rem;
    line-height: 1.5;
}
.help-dialog__actions {
    margin-top: var(--gv-space-4);
    text-align: right;
}
.help-dialog__actions button {
    padding: var(--gv-space-2) var(--gv-space-4);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    background: var(--gv-surface);
    color: var(--gv-accent);
    font: inherit;
    cursor: pointer;
}
.help-dialog__actions button:hover,
.help-dialog__actions button:focus-visible {
    background: var(--gv-surface-strong);
    outline: none;
}

/* --- Portal / dashboard blocks --------------------------------------------- */
.portal-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--gv-space-4);
    margin-top: var(--gv-space-3);
}
.portal-column {
    display: flex;
    flex-direction: column;
    gap: var(--gv-space-4);
    min-width: 0;
}
@media (max-width: 800px) {
    .portal-grid { grid-template-columns: 1fr; }
}
.portal-grid .block {
    background: var(--gv-surface);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    padding: var(--gv-space-3) var(--gv-space-4);
}
.portal-grid .block h2 {
    margin: 0 0 var(--gv-space-2);
    font-size: 1.1rem;
    color: var(--gv-accent);
}
.portal-grid .block p:last-child { margin-bottom: 0; }
.portal-grid .block img {
    max-width: 100%;
    height: auto;
}
.random-thumb {
    display: block;
}
.portal-grid .welcome-user {
    margin-top: var(--gv-space-3);
    padding-top: var(--gv-space-3);
    border-top: 1px dashed var(--gv-border);
}
.portal-grid .stats-summary {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: var(--gv-space-1) var(--gv-space-3);
    margin: 0;
}
.portal-grid .stats-summary dt { margin: 0; }
.portal-grid .stats-summary dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.portal-actions {
    margin: var(--gv-space-3) 0;
}
.portal-customize-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--gv-space-5);
}
@media (max-width: 800px) {
    .portal-customize-grid { grid-template-columns: 1fr; }
}
.portal-customize-column {
    background: var(--gv-surface);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    padding: var(--gv-space-3) var(--gv-space-4);
}
.portal-customize-list {
    list-style: none;
    padding: 0;
    margin: 0 0 var(--gv-space-3);
}
.portal-customize-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--gv-space-2) 0;
    border-bottom: 1px solid var(--gv-border);
}
.portal-customize-row:last-child { border-bottom: none; }
.portal-customize-actions {
    display: inline-flex;
    gap: var(--gv-space-2);
    align-items: center;
}
.portal-inline-form {
    display: inline;
    margin: 0;
}
.portal-inline-form button {
    background: transparent;
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    padding: 0 var(--gv-space-2);
    height: 1.8rem;
    min-width: 1.8rem;
    cursor: pointer;
    font: inherit;
    color: var(--gv-accent);
}
.portal-inline-form button:hover,
.portal-inline-form button:focus-visible {
    background: var(--gv-surface-strong);
    outline: none;
}
.portal-add-form {
    display: flex;
    align-items: center;
    gap: var(--gv-space-2);
    margin-top: var(--gv-space-3);
    padding-top: var(--gv-space-3);
    border-top: 1px solid var(--gv-border);
}
.portal-add-label {
    display: flex;
    align-items: center;
    gap: var(--gv-space-2);
    flex: 1;
}
.portal-add-form select { flex: 1; }
.portal-reset-form {
    margin-top: var(--gv-space-4);
}

/* Anti-bot honeypot wrapper. Pulled out of the visible viewport rather than
   hidden with display:none so that bots that filter on visibility=hidden /
   display=none still see and fill the field. */
.bot-trap {
    position: absolute !important;
    left: -10000px !important;
    top: auto;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    opacity: 0 !important;
}

/* --- GEDCOM date helper -------------------------------------------------- */

.gedcom-date {
    position: relative;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.gedcom-date > input {
    flex: 1 1 0;
    min-width: 0;
    width: auto;
}

.gedcom-date__trigger {
    flex: 0 0 auto;
    margin-left: var(--gv-space-1);
    padding: 0 var(--gv-space-1);
    background: var(--gv-surface);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    cursor: pointer;
    font-size: 0.9em;
    line-height: 1.4;
}

.gedcom-date__trigger:hover {
    background: var(--gv-bg);
}

.gedcom-date__hint {
    flex: 1 1 100%;
    margin-top: 2px;
    color: var(--gv-muted);
    font-size: 0.85em;
}

.gedcom-date__hint:empty {
    display: none;
    margin: 0;
}

.gedcom-date__hint--error {
    color: var(--gv-danger);
}

.gedcom-date--invalid {
    border-color: var(--gv-danger) !important;
    outline-color: var(--gv-danger);
}

.gedcom-date__pop {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    margin-top: 2px;
    padding: var(--gv-space-2);
    background: var(--gv-bg);
    border: 1px solid var(--gv-border);
    border-radius: var(--gv-radius);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    min-width: 22em;
}

/* :not([hidden]) lets the UA stylesheet's `[hidden] { display: none }` win for
   the BET-branch row without an !important override. */
.gedcom-date__row:not([hidden]) {
    display: flex;
    gap: var(--gv-space-2);
    align-items: flex-end;
    margin-bottom: var(--gv-space-2);
    flex-wrap: wrap;
}

.gedcom-date__row label {
    display: flex;
    flex-direction: column;
    font-size: 0.85em;
    color: var(--gv-muted);
}

.gedcom-date__row input,
.gedcom-date__row select {
    margin-top: 2px;
}

.gedcom-date__row input[type="number"] {
    /* Day caps at 31 (2 digits) but year takes 4. Sized for the year — the day
       input shares the rule but only ever needs the first ~3em. */
    width: 6em;
}

.gedcom-date__and {
    align-self: center;
    font-weight: bold;
    color: var(--gv-muted);
    margin-right: var(--gv-space-1);
}

.gedcom-date__actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--gv-space-2);
}

.merge-form {
    max-width: none;
}

.merge-diff {
    width: 100%;
    border-collapse: collapse;
    margin: var(--gv-space-3) 0;
}

.merge-diff th,
.merge-diff td {
    padding: var(--gv-space-2);
    border-bottom: 1px solid var(--gv-border);
    vertical-align: top;
    text-align: left;
}

.merge-diff__group th {
    background-color: var(--gv-surface-strong);
    color: var(--gv-label);
    padding-top: var(--gv-space-3);
}

.merge-diff__body {
    margin: 0;
    font-size: 0.9em;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--gv-muted);
}
