/*
 * base.css — the small site-wide Foliale baseline (DECISIONS.md "Asset strategy",
 * tier 2). Loaded on EVERY page, AFTER Bootstrap, BEFORE any per-feature CSS. Kept
 * deliberately small: shared look/typography only — feature styling never goes here.
 */

/* --- Fira Sans (self-hosted, woff2, weights 300–900 normal + italic) ------------
 * font-display: swap — text renders immediately in the fallback, then swaps to Fira
 * Sans when loaded. Each weight/style is a separate file, fetched on demand when the
 * page actually uses it. */
/* fira-sans-300 - latin */
@font-face {
  font-display: swap;
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 300;
  src: url('/assets/fonts/fira-sans/fira-sans-v18-latin-300.woff2') format('woff2');
}
/* fira-sans-300italic - latin */
@font-face {
  font-display: swap;
  font-family: 'Fira Sans';
  font-style: italic;
  font-weight: 300;
  src: url('/assets/fonts/fira-sans/fira-sans-v18-latin-300italic.woff2') format('woff2');
}
/* fira-sans-regular - latin */
@font-face {
  font-display: swap;
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 400;
  src: url('/assets/fonts/fira-sans/fira-sans-v18-latin-regular.woff2') format('woff2');
}
/* fira-sans-italic - latin */
@font-face {
  font-display: swap;
  font-family: 'Fira Sans';
  font-style: italic;
  font-weight: 400;
  src: url('/assets/fonts/fira-sans/fira-sans-v18-latin-italic.woff2') format('woff2');
}
/* fira-sans-500 - latin */
@font-face {
  font-display: swap;
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 500;
  src: url('/assets/fonts/fira-sans/fira-sans-v18-latin-500.woff2') format('woff2');
}
/* fira-sans-500italic - latin */
@font-face {
  font-display: swap;
  font-family: 'Fira Sans';
  font-style: italic;
  font-weight: 500;
  src: url('/assets/fonts/fira-sans/fira-sans-v18-latin-500italic.woff2') format('woff2');
}
/* fira-sans-600 - latin */
@font-face {
  font-display: swap;
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 600;
  src: url('/assets/fonts/fira-sans/fira-sans-v18-latin-600.woff2') format('woff2');
}
/* fira-sans-600italic - latin */
@font-face {
  font-display: swap;
  font-family: 'Fira Sans';
  font-style: italic;
  font-weight: 600;
  src: url('/assets/fonts/fira-sans/fira-sans-v18-latin-600italic.woff2') format('woff2');
}
/* fira-sans-700 - latin */
@font-face {
  font-display: swap;
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 700;
  src: url('/assets/fonts/fira-sans/fira-sans-v18-latin-700.woff2') format('woff2');
}
/* fira-sans-700italic - latin */
@font-face {
  font-display: swap;
  font-family: 'Fira Sans';
  font-style: italic;
  font-weight: 700;
  src: url('/assets/fonts/fira-sans/fira-sans-v18-latin-700italic.woff2') format('woff2');
}
/* fira-sans-800 - latin */
@font-face {
  font-display: swap;
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 800;
  src: url('/assets/fonts/fira-sans/fira-sans-v18-latin-800.woff2') format('woff2');
}
/* fira-sans-800italic - latin */
@font-face {
  font-display: swap;
  font-family: 'Fira Sans';
  font-style: italic;
  font-weight: 800;
  src: url('/assets/fonts/fira-sans/fira-sans-v18-latin-800italic.woff2') format('woff2');
}
/* fira-sans-900 - latin */
@font-face {
  font-display: swap;
  font-family: 'Fira Sans';
  font-style: normal;
  font-weight: 900;
  src: url('/assets/fonts/fira-sans/fira-sans-v18-latin-900.woff2') format('woff2');
}
/* fira-sans-900italic - latin */
@font-face {
  font-display: swap;
  font-family: 'Fira Sans';
  font-style: italic;
  font-weight: 900;
  src: url('/assets/fonts/fira-sans/fira-sans-v18-latin-900italic.woff2') format('woff2');
}

/* --- Foliale design tokens ------------------------------------------------------
 * The single place for system defaults (DECISIONS Day 33 "Painting P1: the palette", "Painting P3a"). A future theme layer
 * overrides these (it can simply re-declare them at :root or on a scope); nothing else hardcodes these values:
 * no hex colour appears in any stylesheet outside this block (TokensTest), and feature CSS reads var(--foliale-*). */
/* THE TYPE AND SIZES — tokens that are the same in every theme (Dark mode 2 split them from the colours). */
:root {
    --foliale-font-family: 'Fira Sans', system-ui, sans-serif;
    --foliale-font-size-base: 1rem;   /* placeholder, tunable */
    --foliale-bar-h: 48px;            /* the shell bars' height (header = footer; border included) */
    /* PORTRAIT FRAME — the 7:9 portrait (PortraitSpec: 350x450 stored, 86x110 thumbnail). ONE place for
       the frame's aspect and its display heights; the width follows from the aspect. Used by .portrait-frame
       (below) and the chart's box image (chart.js reads the same 7:9 from PortraitSpec via the data). */
    --foliale-portrait-aspect: 7 / 9;
    --foliale-portrait-header-h: 154px;   /* the person page header (120 x 154) */
    --foliale-portrait-thumb-h: 110px;    /* thumbnails: the portrait page's photo pool (86 x 110) */
    --foliale-portrait-small-h: 72px;     /* the family view's boxes: grandparents + children (56 x 72) */
    /* The People list's font, defaulting to the site's (tunable alone). */
    --foliale-people-font-family: var(--foliale-font-family);
    --foliale-people-font-size: var(--foliale-font-size-base);
}

/* THE TOKENS — the ONLY place a colour is written (Dark mode 1: ColourTokensTest checks every stylesheet, view and script).
   TWO BLOCKS (Dark mode 2): this LIGHT block, and the DARK block below it (screen only). A new colour token needs BOTH
   values — ColourTokensTest fails on a name in one block and not the other. This block is declared on :root AND on any
   [data-bs-theme="light"] host, so a light-scoped element (the chart's print copy) always re-reads the light values
   whatever theme the page shows; and print never sees the dark block. */
:root,
[data-bs-theme="light"] {
    /* THE PALETTE (Painting P1). ONE surface grey for the rails and the centre; white rows / blocks on it;
       a hairline edge; three text greys under the body text; the gender colours (a STRIP in the rails, a
       border + 8% fill on chart boxes — never a row fill); teal the single ACTION colour; green for home. */
    --foliale-surface: #EEEEEE;       /* rails and centre background */
    --foliale-row: #FFFFFF;           /* a row / block on the surface; the header and footer */
    --foliale-row-active: #E4E4E4;    /* the open / selected row */
    --foliale-label: #E2E2E2;         /* a label cell or chip on white */
    --foliale-edge: #D9D9D9;          /* hairlines and borders (the shell's edges, inputs in the rails) */
    --foliale-text: #1F2328;          /* body text */
    /* MUTED text — dates, counts, secondary facts. Also every PLACEHOLDER (below), so example text in an
       empty field never reads as a value typed in. */
    --foliale-muted: #6C757D;
    --foliale-faint: #8A8F95;         /* the faintest text: IDs, codes */
    --foliale-heading: #5F5E5A;       /* section / group headings (.fo-heading); the left rail's nav icons */
    --foliale-female: #B5553E;
    --foliale-male: #2E7D8A;
    --foliale-unknown: #B4B2A9;       /* gender unknown (also a living person hidden from this account) */
    --foliale-action: #2E7D8A;        /* the single action colour (teal): the active nav icon, centre links, section actions, buttons */
    --foliale-action-rgb: 46, 125, 138;   /* the same teal as an r, g, b triple — for Bootstrap's --bs-link-color-rgb / --bs-primary-rgb */
    --foliale-home: #3C7A4A;          /* the default person's house; = success */
    --foliale-home-rgb: 60, 122, 74;  /* the same green as a triple — for Bootstrap's --bs-success-rgb (.text-success) */

    /* THE CONTROL STATES AND ROLE PAIRS (Painting P3a). The action teal's hover and press steps; then, per role, a
       pale TINT (a badge's / alert's fill, a secondary button's hover) and an INK (text on that tint). */
    --foliale-action-hover: #256670;
    --foliale-action-press: #1F5A63;
    --foliale-action-tint: #E3F0F2;   /* also the "this one" highlight: the person's own census line, the chart's root box */
    --foliale-action-ink: #1F5A63;
    --foliale-danger: #A3352B;        /* delete / remove / detach; the marriage heart */
    --foliale-danger-rgb: 163, 53, 43;   /* the same red as a triple — for Bootstrap's --bs-danger-rgb (.text-danger) */
    --foliale-danger-tint: #F6E3E0;
    --foliale-danger-ink: #8A2E25;
    --foliale-warning-tint: #FBEFD9;  /* needs research and the other research flags */
    --foliale-warning-ink: #7A5410;
    --foliale-success-tint: #E8F1EA;  /* success = --foliale-home (Living) */
    --foliale-success-ink: #2C5E38;
    --foliale-neutral-tint: #EEEEEE;  /* = --foliale-surface: kinds, classifications, counts */
    --foliale-neutral-ink: #5F5E5A;

    /* BOOTSTRAP'S OWN LIGHT SURFACES (Dark mode 1): the values Bootstrap 5.3 draws today, held as tokens so its components —
       modals, dropdowns, tables, form controls, the muted / body text utilities — follow the palette (routed in the block
       below). Light mode renders exactly as before. */
    --foliale-body-text: #212529;                        /* Bootstrap's body text: the page body, .text-body, inherited text */
    --foliale-body-text-rgb: 33, 37, 41;
    --foliale-row-rgb: 255, 255, 255;                    /* --foliale-row as a triple (Bootstrap's body background) */
    --foliale-secondary-text: rgba(33, 37, 41, 0.75);    /* .text-muted — Bootstrap's secondary text */
    --foliale-tertiary-text: rgba(33, 37, 41, 0.5);
    --foliale-emphasis: #000000;                         /* Bootstrap's emphasis: table text, the chart box border */
    --foliale-emphasis-rgb: 0, 0, 0;
    --foliale-secondary-bg: #E9ECEF;                     /* a disabled / read-only control */
    --foliale-secondary-bg-rgb: 233, 236, 239;
    --foliale-tertiary-bg: #F8F9FA;                      /* a dropdown item's hover */
    --foliale-tertiary-bg-rgb: 248, 249, 250;
    --foliale-muted-rgb: 108, 117, 125;                  /* --foliale-muted as a triple (Bootstrap's secondary) */
    --foliale-link: #0D6EFD;                             /* a link outside the centre (the centre's links are the action teal) */
    --foliale-link-rgb: 13, 110, 253;
    --foliale-link-hover: #0A58CA;
    --foliale-link-hover-rgb: 10, 88, 202;
    --foliale-rule: #DEE2E6;                           /* Bootstrap's own borders: tables, a modal's header / footer, rules */
    --foliale-rule-translucent: rgba(0, 0, 0, 0.175);  /* a dropdown's edge */
    --foliale-mark: #FFF3CD;                        /* <mark> */
    --foliale-code: #D63384;
    --foliale-valid: #198754;                            /* a valid form field */
    --foliale-backdrop: #000000;                         /* the modal backdrop (at Bootstrap's 50%) */
    --foliale-shade: #000000;                            /* the danger button's hover / press steps are mixed toward it */
    /* the form switch's knob, unchecked and focused — an SVG data URI (a CSS variable cannot reach inside one) */
    --foliale-switch-knob: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%280, 0, 0, 0.25%29'/%3e%3c/svg%3e");

    /* THE CHART (P2b): the box text and lines, the boxes, the person it was opened from, colour by generation (four tints,
       cycled). Colour by gender: the border in the gender colour, the fill the same colour at 8% — chart.js computes each
       --foliale-chart-<gender>-fill as a solid colour from these tokens on every draw (the print copy reads computed
       colours); the color-mix() here is the value before that. */
    --foliale-chart-text: var(--foliale-body-text);
    --foliale-chart-muted: var(--foliale-secondary-text);
    --foliale-chart-line: var(--foliale-secondary-text);
    --foliale-chart-box: var(--foliale-row);
    --foliale-chart-box-border: var(--foliale-emphasis);
    --foliale-chart-family: var(--foliale-row);
    --foliale-chart-root: var(--foliale-action);
    --foliale-chart-root-fill: var(--foliale-action-tint);
    --foliale-chart-gen-0: #D1E7DD;
    --foliale-chart-gen-1: #CFE2FF;
    --foliale-chart-gen-2: #FFF3CD;
    --foliale-chart-gen-3: #E2E3E5;
    --foliale-chart-female-fill: color-mix(in srgb, var(--foliale-female) 8%, var(--foliale-row));
    --foliale-chart-male-fill: color-mix(in srgb, var(--foliale-male) 8%, var(--foliale-row));
    --foliale-chart-unknown-fill: color-mix(in srgb, var(--foliale-unknown) 8%, var(--foliale-row));

    /* MAPS (MP1–MP3): a pin, its number and edge, a child place's pin, an undated pin, the person's trail; an APPROXIMATE
       pin (a place with no coordinates, shown at its nearest located ancestor) — a solid lighter fill, its number, and
       an undated one's. (The OpenStreetMap tiles are pictures — never recoloured here.) */
    --foliale-map-pin: var(--foliale-action);
    --foliale-map-pin-ink: #FFFFFF;
    --foliale-map-pin-edge: var(--foliale-row);
    --foliale-map-child: #198754;
    --foliale-map-undated: var(--foliale-muted);
    --foliale-map-trail: var(--foliale-action);
    --foliale-map-pin-approx: #B9DEE3;
    --foliale-map-pin-approx-ink: #12363C;
    --foliale-map-undated-approx: #CDD1D5;

    /* THE ROLES A THEME SETS APART (Dark mode 2). In light each is today's value; dark gives each its own. */
    --foliale-primary: var(--foliale-action);          /* the solid primary button's fill (dark keeps the deep teal) */
    --foliale-primary-hover: var(--foliale-action-hover);
    --foliale-primary-press: var(--foliale-action-press);
    --foliale-on-solid: #FFFFFF;                       /* text on a solid fill: the primary and solid danger buttons */
    --foliale-danger-solid: var(--foliale-danger);     /* the solid danger button (the final confirm) */
    --foliale-danger-solid-hover: color-mix(in srgb, var(--foliale-danger) 81%, var(--foliale-shade));
    --foliale-danger-solid-press: color-mix(in srgb, var(--foliale-danger) 71%, var(--foliale-shade));
    --foliale-input-bg: var(--foliale-row);            /* inputs, selects, textareas */
    --foliale-input-edge: var(--foliale-edge);
    --foliale-input-text: var(--foliale-text);
    --foliale-placeholder: var(--foliale-muted);       /* every placeholder: grey, never read as a value */
    --foliale-ring-gap: var(--foliale-row);            /* the focus ring's 2px gap, inside its 2px of action */
    --foliale-frame: var(--foliale-surface);           /* behind a portrait or thumbnail that does not fill its frame */
    --foliale-band: var(--foliale-row);                /* the People rail's surname band */
    --foliale-chart-ground: var(--foliale-row);        /* the chart's background */
    --foliale-btn-neutral-edge: var(--foliale-edge);   /* the neutral button (Cancel, Back, paging …): its border, */
    --foliale-btn-neutral-text: var(--foliale-text);   /* its text, */
    --foliale-btn-neutral-hover: var(--foliale-surface);   /* its hover fill */
    --foliale-backdrop-opacity: 0.5;                   /* the modal backdrop (Bootstrap's) */
}

/* BOOTSTRAP FOLLOWS THE TOKENS (Dark mode 1): every Bootstrap theme variable its components and utilities read, set from
   the palette in ONE block — .text-muted, .text-danger, .text-success, .text-primary, .border-primary, .text-body, form
   validation, modals, dropdowns, tables, links. A theme is then a token swap. (Same selector as Bootstrap's own block;
   base.css loads after it, so this wins.) */
:root,
[data-bs-theme="light"] {
    --bs-body-color: var(--foliale-body-text);
    --bs-body-color-rgb: var(--foliale-body-text-rgb);
    --bs-body-bg: var(--foliale-row);
    --bs-body-bg-rgb: var(--foliale-row-rgb);
    --bs-emphasis-color: var(--foliale-emphasis);
    --bs-emphasis-color-rgb: var(--foliale-emphasis-rgb);
    --bs-secondary-color: var(--foliale-secondary-text);
    --bs-secondary-color-rgb: var(--foliale-body-text-rgb);
    --bs-secondary-bg: var(--foliale-secondary-bg);
    --bs-secondary-bg-rgb: var(--foliale-secondary-bg-rgb);
    --bs-tertiary-color: var(--foliale-tertiary-text);
    --bs-tertiary-color-rgb: var(--foliale-body-text-rgb);
    --bs-tertiary-bg: var(--foliale-tertiary-bg);
    --bs-tertiary-bg-rgb: var(--foliale-tertiary-bg-rgb);
    --bs-link-color: var(--foliale-link);
    --bs-link-color-rgb: var(--foliale-link-rgb);
    --bs-link-hover-color: var(--foliale-link-hover);
    --bs-link-hover-color-rgb: var(--foliale-link-hover-rgb);
    --bs-code-color: var(--foliale-code);
    --bs-highlight-color: var(--foliale-body-text);
    --bs-highlight-bg: var(--foliale-mark);
    --bs-border-color: var(--foliale-rule);
    --bs-border-color-translucent: var(--foliale-rule-translucent);
    --bs-form-valid-color: var(--foliale-valid);
    --bs-form-valid-border-color: var(--foliale-valid);
    --bs-secondary: var(--foliale-muted);
    --bs-secondary-rgb: var(--foliale-muted-rgb);
    --bs-primary: var(--foliale-action);
    --bs-primary-rgb: var(--foliale-action-rgb);
    --bs-success-rgb: var(--foliale-home-rgb);
    --bs-danger: var(--foliale-danger);
    --bs-danger-rgb: var(--foliale-danger-rgb);
    --bs-form-invalid-color: var(--foliale-danger);
    --bs-form-invalid-border-color: var(--foliale-danger);
}
.modal-backdrop {
    --bs-backdrop-bg: var(--foliale-backdrop);
    --bs-backdrop-opacity: var(--foliale-backdrop-opacity);
}

/* THE DARK TOKENS (Dark mode 2, DECISIONS Day 35 "Dark mode: the design") — every name the light block defines, with its
   dark value; on [data-bs-theme="dark"] (the server writes it for Dark; the head script for Follow my device), INSIDE
   @media screen so print always uses the light block. Bootstrap's own dark rules (the close button, the select arrow,
   the checkbox marks, color-scheme) come from the same attribute. */
@media screen {
    [data-bs-theme="dark"] {
        --foliale-surface: #1C1D1F;
        --foliale-row: #26282B;
        --foliale-row-active: #383B40;    /* the open rail row */
        --foliale-label: #2F3134;         /* the label column */
        --foliale-edge: #3A3C40;
        --foliale-text: #E4E6E8;
        --foliale-muted: #9AA0A6;
        --foliale-faint: #7D8288;
        --foliale-heading: #A8A69F;
        --foliale-female: #E0907A;
        --foliale-male: #5BB5C2;
        --foliale-unknown: #8A8880;
        --foliale-action: #5BB5C2;        /* links, outlines, text actions, the focus ring */
        --foliale-action-rgb: 91, 181, 194;
        --foliale-home: #6FB07F;
        --foliale-home-rgb: 111, 176, 127;
        --foliale-action-hover: #8FD0DA;  /* a link's / text action's hover */
        --foliale-action-press: #8FD0DA;
        --foliale-action-tint: #1F3A3F;
        --foliale-action-ink: #8FD0DA;
        --foliale-danger: #E07A70;        /* the outline and the text */
        --foliale-danger-rgb: 224, 122, 112;
        --foliale-danger-tint: #3E2421;
        --foliale-danger-ink: #F0A59D;
        --foliale-warning-tint: #3D3220;
        --foliale-warning-ink: #E6C27A;
        --foliale-success-tint: #213528;
        --foliale-success-ink: #8FCB9E;
        --foliale-neutral-tint: #33312C;
        --foliale-neutral-ink: #C9C6BC;

        --foliale-body-text: #E4E6E8;
        --foliale-body-text-rgb: 228, 230, 232;
        --foliale-row-rgb: 38, 40, 43;
        --foliale-secondary-text: rgba(228, 230, 232, 0.75);
        --foliale-tertiary-text: rgba(228, 230, 232, 0.5);
        --foliale-emphasis: #FFFFFF;
        --foliale-emphasis-rgb: 255, 255, 255;
        --foliale-secondary-bg: #383B40;
        --foliale-secondary-bg-rgb: 56, 59, 64;
        --foliale-tertiary-bg: #2F3134;
        --foliale-tertiary-bg-rgb: 47, 49, 52;
        --foliale-muted-rgb: 154, 160, 166;
        --foliale-link: #5BB5C2;
        --foliale-link-rgb: 91, 181, 194;
        --foliale-link-hover: #8FD0DA;
        --foliale-link-hover-rgb: 143, 208, 218;
        --foliale-rule: #3A3C40;
        --foliale-rule-translucent: #3A3C40;   /* a modal's / dropdown's edge: the edge colour */
        --foliale-mark: #4D3D12;               /* a dark amber; <mark>'s text is the body text */
        --foliale-code: #E685B5;
        --foliale-valid: #6FB07F;
        --foliale-backdrop: #000000;
        --foliale-shade: #000000;
        /* the switch knob, unchecked: light on the dark track */
        --foliale-switch-knob: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='rgba%28255, 255, 255, 0.25%29'/%3e%3c/svg%3e");

        --foliale-chart-text: #E4E6E8;
        --foliale-chart-muted: #9AA0A6;
        --foliale-chart-line: #6B6F75;         /* lines and connectors */
        --foliale-chart-box: var(--foliale-row);
        --foliale-chart-box-border: #9AA0A6;
        --foliale-chart-family: var(--foliale-row);
        --foliale-chart-root: var(--foliale-action);
        --foliale-chart-root-fill: var(--foliale-action-tint);
        --foliale-chart-gen-0: #233A2C;        /* today's green, blue, yellow and grey tints, dark */
        --foliale-chart-gen-1: #22324A;
        --foliale-chart-gen-2: #42391E;
        --foliale-chart-gen-3: #36383C;
        --foliale-chart-female-fill: #4A2C25;  /* solid hex: chart.js uses them as they are */
        --foliale-chart-male-fill: #1F3F45;
        --foliale-chart-unknown-fill: #3A3935;

        --foliale-map-pin: var(--foliale-action);
        --foliale-map-pin-ink: #1C1D1F;        /* the number on a pin: dark on the light teal */
        --foliale-map-pin-edge: var(--foliale-row);
        --foliale-map-child: #6FB07F;
        --foliale-map-undated: var(--foliale-muted);
        --foliale-map-trail: var(--foliale-action);
        --foliale-map-pin-approx: #C2E6EB;     /* pale: stands out on the dimmed tiles, apart from the mid-teal own pin */
        --foliale-map-pin-approx-ink: #12363C;
        --foliale-map-undated-approx: #C4C8CC;

        --foliale-primary: #2E7D8A;            /* the solid primary stays the deep teal, white text */
        --foliale-primary-hover: #3790A0;
        --foliale-primary-press: #2A7480;
        --foliale-on-solid: #FFFFFF;
        --foliale-danger-solid: #A3352B;
        --foliale-danger-solid-hover: #B84236;
        --foliale-danger-solid-press: #8A2E25;
        --foliale-input-bg: #1C1D1F;
        --foliale-input-edge: #4A4D52;
        --foliale-input-text: #E4E6E8;
        --foliale-placeholder: #7D8288;
        --foliale-ring-gap: var(--foliale-surface);
        --foliale-frame: #303236;              /* portrait and thumbnail placeholders */
        --foliale-band: #303236;               /* the rail's surname band */
        --foliale-chart-ground: var(--foliale-surface);
        --foliale-btn-neutral-edge: #55585D;
        --foliale-btn-neutral-text: #C4C7CA;
        --foliale-btn-neutral-hover: #303236;
        --foliale-backdrop-opacity: 0.6;
    }

    /* An unchecked checkbox / radio / switch in dark: Bootstrap's rule-coloured hairline vanishes on the dark row, so its
       edge is the faint grey (≈ 3.8:1 on the row) on the input ground. Checked ones stay the action colour. */
    [data-bs-theme="dark"] .form-check-input:not(:checked) {
        background-color: var(--foliale-input-bg);
        border-color: var(--foliale-faint);
    }

    /* The logo is black line art on a transparent ground (the app's own mark, not a user image): drawn light in dark. */
    [data-bs-theme="dark"] .app-header-logo {
        filter: invert(0.9);
    }

    /* MAPS in dark: ONLY the tile pane (the OpenStreetMap pictures) is dimmed; pins, the trail, popups and the controls are
       not filtered — the popups and controls take the row and text tokens. */
    [data-bs-theme="dark"] .leaflet-tile-pane {
        filter: brightness(0.72) saturate(0.8);
    }
    [data-bs-theme="dark"] .leaflet-container {
        background: var(--foliale-surface);
    }
    [data-bs-theme="dark"] .leaflet-container .leaflet-popup-content-wrapper,
    [data-bs-theme="dark"] .leaflet-container .leaflet-popup-tip,
    [data-bs-theme="dark"] .leaflet-container .leaflet-bar a,
    [data-bs-theme="dark"] .leaflet-container .leaflet-control-attribution,
    [data-bs-theme="dark"] .leaflet-container .leaflet-control-layers {
        background: var(--foliale-row);
        color: var(--foliale-text);
    }
    [data-bs-theme="dark"] .leaflet-container .leaflet-bar a {
        border-bottom-color: var(--foliale-edge);
    }
    [data-bs-theme="dark"] .leaflet-container .leaflet-tooltip {
        background: var(--foliale-row);
        color: var(--foliale-text);
        border-color: var(--foliale-edge);
    }
    [data-bs-theme="dark"] .leaflet-container .leaflet-tooltip-top::before { border-top-color: var(--foliale-row); }
    [data-bs-theme="dark"] .leaflet-container .leaflet-tooltip-bottom::before { border-bottom-color: var(--foliale-row); }
    [data-bs-theme="dark"] .leaflet-container .leaflet-tooltip-left::before { border-left-color: var(--foliale-row); }
    [data-bs-theme="dark"] .leaflet-container .leaflet-tooltip-right::before { border-right-color: var(--foliale-row); }
    [data-bs-theme="dark"] .leaflet-container .leaflet-bar,
    [data-bs-theme="dark"] .leaflet-container .leaflet-control-layers {
        border-color: var(--foliale-edge);
    }
    [data-bs-theme="dark"] .leaflet-container .leaflet-control-attribution a,
    [data-bs-theme="dark"] .leaflet-container .leaflet-popup-content a {
        color: var(--foliale-action);
    }
}

/* PRINT is always light: the dark block above is screen-only; Bootstrap's own dark switches are put back. */
@media print {
    [data-bs-theme="dark"] {
        color-scheme: light;
        --bs-btn-close-filter: none;
    }
}

/* App-wide tooltip skin — the ONE delegated tooltip instance (tooltip.js) sets
   customClass:"custom-tooltip" on every tooltip. Sensible defaults now ("not ugly"); styling is
   DEFERRED — a later pass can back these with --foliale-tooltip-* tokens. */
.custom-tooltip {
    --bs-tooltip-bg: var(--foliale-text);   /* dark neutral: the body text colour */
    --bs-tooltip-color: var(--foliale-row);
    --bs-tooltip-opacity: 0.95;
    --bs-tooltip-font-size: 0.8125rem;
    --bs-tooltip-border-radius: 0.375rem;
    --bs-tooltip-padding-x: 0.6rem;
    --bs-tooltip-padding-y: 0.35rem;
}

/* === PAINTING P3a — THE CONTROLS ================================================================================
   Bootstrap's classes stay in the markup; here they are restyled onto the palette through Bootstrap's own component
   variables. Placed early so a feature rule further down (.rail-btn, .fo-head-actions …) still refines a role.

   FIVE BUTTON ROLES:
   - PRIMARY (.btn-primary) — solid action teal, white text 500; the ONE Save / Create / submit of a form.
   - SECONDARY (.btn-outline-primary) — white, 1px teal border, teal text; a button that ADDS or OPENS something.
   - NEUTRAL (.btn-outline-secondary, .btn-secondary, .btn-light) — white, 1px edge border, body text; Cancel, Back,
     Keep, paging, toolbars, toggles, choices in a list.
   - TEXT ACTION (.btn-link, the section headings' actions) — teal text, no border; underlined on hover.
   - DANGER (.btn-outline-danger — opens a delete / remove / detach; .btn-danger — the FINAL confirm only).
   All: 6px corners, a 100ms colour transition; disabled at 50% opacity, no hover change, a not-allowed cursor. */
.btn,
.btn-sm,
.btn-lg,
.btn-group-sm > .btn,
.btn-group-lg > .btn {
    --bs-btn-border-radius: 6px;
}
.btn {
    --bs-btn-disabled-opacity: 0.5;
    --bs-btn-focus-box-shadow: 0 0 0 2px var(--foliale-ring-gap), 0 0 0 4px var(--foliale-action);
    transition: color 100ms ease-in-out, background-color 100ms ease-in-out, border-color 100ms ease-in-out;
}
.btn:disabled,
.btn.disabled,
fieldset:disabled .btn {
    cursor: not-allowed;
}
/* A real disabled <button> takes the pointer so the cursor shows (it fires no click); a disabled LINK keeps
   Bootstrap's pointer-events: none, so it can never navigate. Each role's disabled colours equal its rest colours,
   so hovering one changes nothing. */
.btn:disabled {
    pointer-events: auto;
}
.btn-primary {
    --bs-btn-font-weight: 500;
    --bs-btn-color: var(--foliale-on-solid);
    --bs-btn-bg: var(--foliale-primary);
    --bs-btn-border-color: var(--foliale-primary);
    --bs-btn-hover-color: var(--foliale-on-solid);
    --bs-btn-hover-bg: var(--foliale-primary-hover);
    --bs-btn-hover-border-color: var(--foliale-primary-hover);
    --bs-btn-active-color: var(--foliale-on-solid);
    --bs-btn-active-bg: var(--foliale-primary-press);
    --bs-btn-active-border-color: var(--foliale-primary-press);
    --bs-btn-disabled-color: var(--foliale-on-solid);
    --bs-btn-disabled-bg: var(--foliale-primary);
    --bs-btn-disabled-border-color: var(--foliale-primary);
}
.btn-outline-primary {
    --bs-btn-color: var(--foliale-action);
    --bs-btn-bg: var(--foliale-row);
    --bs-btn-border-color: var(--foliale-action);
    --bs-btn-hover-color: var(--foliale-action-ink);
    --bs-btn-hover-bg: var(--foliale-action-tint);
    --bs-btn-hover-border-color: var(--foliale-action);
    --bs-btn-active-color: var(--foliale-action-ink);
    --bs-btn-active-bg: var(--foliale-action-tint);
    --bs-btn-active-border-color: var(--foliale-action-press);
    --bs-btn-disabled-color: var(--foliale-action);
    --bs-btn-disabled-bg: var(--foliale-row);
    --bs-btn-disabled-border-color: var(--foliale-action);
}
.btn-outline-secondary,
.btn-secondary,
.btn-light {
    --bs-btn-color: var(--foliale-btn-neutral-text);
    --bs-btn-bg: var(--foliale-row);
    --bs-btn-border-color: var(--foliale-btn-neutral-edge);
    --bs-btn-hover-color: var(--foliale-btn-neutral-text);
    --bs-btn-hover-bg: var(--foliale-btn-neutral-hover);
    --bs-btn-hover-border-color: var(--foliale-btn-neutral-edge);
    --bs-btn-active-color: var(--foliale-btn-neutral-text);
    --bs-btn-active-bg: var(--foliale-row-active);
    --bs-btn-active-border-color: var(--foliale-btn-neutral-edge);
    --bs-btn-disabled-color: var(--foliale-btn-neutral-text);
    --bs-btn-disabled-bg: var(--foliale-row);
    --bs-btn-disabled-border-color: var(--foliale-btn-neutral-edge);
}
.btn-link {
    --bs-btn-font-weight: 400;
    --bs-btn-color: var(--foliale-action);
    --bs-btn-hover-color: var(--foliale-action-hover);
    --bs-btn-active-color: var(--foliale-action-press);
    --bs-btn-disabled-color: var(--foliale-action);
    text-decoration: none;
}
.btn-link:hover {
    text-decoration: underline;
}
.btn-outline-danger {
    --bs-btn-color: var(--foliale-danger);
    --bs-btn-bg: var(--foliale-row);
    --bs-btn-border-color: var(--foliale-danger);
    --bs-btn-hover-color: var(--foliale-danger-ink);
    --bs-btn-hover-bg: var(--foliale-danger-tint);
    --bs-btn-hover-border-color: var(--foliale-danger);
    --bs-btn-active-color: var(--foliale-danger-ink);
    --bs-btn-active-bg: var(--foliale-danger-tint);
    --bs-btn-active-border-color: var(--foliale-danger-ink);
    --bs-btn-disabled-color: var(--foliale-danger);
    --bs-btn-disabled-bg: var(--foliale-row);
    --bs-btn-disabled-border-color: var(--foliale-danger);
}
/* The solid danger darkens by the primary's own step in light (hover ≈ 81% of the colour, press ≈ 71% — the tokens);
   dark gives its own three steps. */
.btn-danger {
    --bs-btn-font-weight: 500;
    --bs-btn-color: var(--foliale-on-solid);
    --bs-btn-bg: var(--foliale-danger-solid);
    --bs-btn-border-color: var(--foliale-danger-solid);
    --bs-btn-hover-color: var(--foliale-on-solid);
    --bs-btn-hover-bg: var(--foliale-danger-solid-hover);
    --bs-btn-hover-border-color: var(--foliale-danger-solid-hover);
    --bs-btn-active-color: var(--foliale-on-solid);
    --bs-btn-active-bg: var(--foliale-danger-solid-press);
    --bs-btn-active-border-color: var(--foliale-danger-solid-press);
    --bs-btn-disabled-color: var(--foliale-on-solid);
    --bs-btn-disabled-bg: var(--foliale-danger-solid);
    --bs-btn-disabled-border-color: var(--foliale-danger-solid);
}
.btn-close {
    --bs-btn-close-focus-shadow: 0 0 0 2px var(--foliale-ring-gap), 0 0 0 4px var(--foliale-action);
}

/* THE FOCUS RING — one for every control: 2px of the action teal outside 2px of white, on keyboard focus
   (:focus-visible). Bootstrap's blue glow is removed from inputs, selects, checkboxes and buttons. */
.form-control:focus,
.form-select:focus,
.form-check-input:focus {
    border-color: var(--foliale-input-edge);
    outline: 0;
    box-shadow: none;
}
/* …and a focused field keeps the input ground (Bootstrap's :focus repaints it with the body background — the row). */
.form-control:focus,
.form-select:focus {
    background-color: var(--foliale-input-bg);
}
.btn:focus-visible,
.btn-check:focus-visible + .btn,
.btn-close:focus-visible,
.form-control:focus-visible,
.form-select:focus-visible,
.form-check-input:focus-visible,
.form-control.is-invalid:focus-visible,
.form-select.is-invalid:focus-visible,
.rail-row a:focus-visible,
.rail-row button:focus-visible,
.rail-row summary:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 2px var(--foliale-ring-gap), 0 0 0 4px var(--foliale-action);
}

/* FORM CONTROLS — a 1px edge border, 6px corners, the body text; a checked box / radio / switch in the action teal.
   (The switch's knob keeps Bootstrap's grey when focused, not its blue.) */
.form-control,
.form-select {
    border: 1px solid var(--foliale-input-edge);
    border-radius: 6px;
    color: var(--foliale-input-text);
    background-color: var(--foliale-input-bg);
}
.form-check-input:checked,
.form-check-input[type="checkbox"]:indeterminate {
    background-color: var(--foliale-action);
    border-color: var(--foliale-action);
}
.form-switch .form-check-input:focus:not(:checked) {
    --bs-form-switch-bg: var(--foliale-switch-knob);
}

/* BADGES — a soft pill: 12px, 2px 8px, 10px corners, a pale fill and the ink of the same hue. Five roles, each a
   class on the badge: ACTION (structural — "primary", "you", "new"), SUCCESS (Living), NEUTRAL (kinds,
   classifications, counts — also a badge with no role class), WARNING (needs research, unattached and the other
   research flags), DANGER (the 110+ check, an incomplete backup and the other warnings). */
.badge {
    --bs-badge-font-size: 12px;
    --bs-badge-font-weight: 500;
    --bs-badge-padding-x: 8px;
    --bs-badge-padding-y: 2px;
    --bs-badge-border-radius: 10px;
    --bs-badge-color: var(--foliale-neutral-ink);
    background-color: var(--foliale-neutral-tint);
}
.badge.fo-badge--action {
    --bs-badge-color: var(--foliale-action-ink);
    background-color: var(--foliale-action-tint);
}
.badge.fo-badge--success {
    --bs-badge-color: var(--foliale-success-ink);
    background-color: var(--foliale-success-tint);
}
.badge.fo-badge--neutral {
    --bs-badge-color: var(--foliale-neutral-ink);
    background-color: var(--foliale-neutral-tint);
}
.badge.fo-badge--warning {
    --bs-badge-color: var(--foliale-warning-ink);
    background-color: var(--foliale-warning-tint);
}
.badge.fo-badge--danger {
    --bs-badge-color: var(--foliale-danger-ink);
    background-color: var(--foliale-danger-tint);
}

/* ALERTS — the soft fill and ink of the matching role, no border, 6px corners. (info reads as the action teal.) */
.alert {
    --bs-alert-border-radius: 6px;
}
.alert-primary,
.alert-info {
    --bs-alert-color: var(--foliale-action-ink);
    --bs-alert-bg: var(--foliale-action-tint);
    --bs-alert-border-color: transparent;
    --bs-alert-link-color: var(--foliale-action-ink);
}
.alert-success {
    --bs-alert-color: var(--foliale-success-ink);
    --bs-alert-bg: var(--foliale-success-tint);
    --bs-alert-border-color: transparent;
    --bs-alert-link-color: var(--foliale-success-ink);
}
.alert-secondary,
.alert-light {
    --bs-alert-color: var(--foliale-neutral-ink);
    --bs-alert-bg: var(--foliale-neutral-tint);
    --bs-alert-border-color: transparent;
    --bs-alert-link-color: var(--foliale-neutral-ink);
}
.alert-warning {
    --bs-alert-color: var(--foliale-warning-ink);
    --bs-alert-bg: var(--foliale-warning-tint);
    --bs-alert-border-color: transparent;
    --bs-alert-link-color: var(--foliale-warning-ink);
}
.alert-danger {
    --bs-alert-color: var(--foliale-danger-ink);
    --bs-alert-bg: var(--foliale-danger-tint);
    --bs-alert-border-color: transparent;
    --bs-alert-link-color: var(--foliale-danger-ink);
}

body {
    /* Fira Sans is the SITE-WIDE default font — every page/view inherits it. Change
       --foliale-font-family (above) to change the whole app. */
    font-family: var(--foliale-font-family);
    font-size: var(--foliale-font-size-base);
    /* A hair more line-height than Bootstrap's default, for record-dense pages. */
    line-height: 1.6;
}

/* PLACEHOLDERS render GREY (--foliale-muted), never the body colour: example text ("1954", "4a", "e.g. …") lives
   ONLY in placeholder attributes, never in a value, and must not look typed in. (Bootstrap's own rule uses
   --bs-secondary-color, 75% of the body colour — too close to real text. A floating label's transparent
   placeholder, more specific, still wins.) */
::placeholder,
.form-control::placeholder {
    color: var(--foliale-placeholder);
    opacity: 1;
}

.navbar-brand {
    font-weight: 600;
    letter-spacing: 0.02em;
}

/*
 * Application shell — full-height flex ROW inside a viewport-locked frame:
 * [ left nav rail | centre column | right list rail ]. The two rails run the full
 * viewport height; the centre column is itself a flex COLUMN (header / content / footer)
 * so header + footer span only the centre's width. Height/flex/scroll behaviour is done
 * with BOOTSTRAP UTILITIES in layout.php (app-shell: d-flex vh-100 overflow-hidden;
 * per region flex-grow-1 / flex-shrink-0 / overflow-y-auto). This file carries what
 * Bootstrap has no utility for: the fixed rail widths, min-width:0 so the centre can
 * shrink, and (Painting P1) the shell's paint: both rails on --foliale-surface with a
 * --foliale-edge hairline on their centre-facing edge; header and footer white with the
 * same hairline.
 */

/* ONE HEADING STYLE for section / group headings (Painting P1): the right rail's surname groups, the left
   rail's page-spine heading; the centre's blocks in P2. */
.fo-heading {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--foliale-heading);
}

/* Left nav: fixed width (Bootstrap has no 12rem utility). Full-height flex-column +
   overflow are utilities in the markup. At the top the page spine and the page actions; the
   constant navigation and the admin group pinned to the BOTTOM (mt-auto on .app-nav-group--bottom). */
.app-sidebar {
    width: 12rem;
    padding: 0.75rem 0;
    background: var(--foliale-surface);
    border-right: 1px solid var(--foliale-edge);
    font-size: 14px;
}

/* Header + footer use Bootstrap's border-bottom / border-top utilities, which colour via
   --bs-border-color (and set the property !important). Re-point that variable on these
   shell elements to the edge token so the shell's hairlines match, without an !important
   override. Both bars are white. */
.app-centre > .app-header.border-bottom,
.app-centre > .app-footer.border-top {
    --bs-border-color: var(--foliale-edge);
    background: var(--foliale-row);
}

/* THE TWO SHELL BARS share one height — the header MIRRORS the footer. Both carry .app-bar, held at
   --foliale-bar-h (48px — the signed-in footer's own height: py-2 around its btn-sm Sign out, plus the border;
   border-box, so the border is inside it). Fixed, not a floor: the header (whose content is shorter) no longer
   sits 8px under the footer. */
.app-bar {
    min-height: var(--foliale-bar-h);
    height: var(--foliale-bar-h);
}

/* HEADER (Painting P1): the logo + the wordmark only, across the centre column. A compact line-height keeps
   the header's 1rem content UNDER the shared .app-bar height (the body's 1.6 line-height would otherwise make
   it taller than the footer's smaller text). */
.app-header {
    line-height: 1.2;
}
/* The logo FILLS the bar's height inside the same vertical padding the footer uses (py-2: 0.5rem above and
   below) and the bar's 1px border. */
.app-header-logo {
    height: calc(var(--foliale-bar-h) - 1rem - 1px);
    width: auto;
}
.app-header-name {
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--foliale-text);
}
/* THE TREE NAME (tree.name; _header-tree.php): after the wordmark, muted, one line — it gives way first, cut short with
   an ellipsis (.text-truncate) when long; the full name is its tooltip. */
.app-header-tree {
    color: var(--foliale-muted);
    min-width: 0;
    flex: 0 1 auto;
}
/* Settings → Tree: the name's box is as wide as a long name needs, no wider. */
.settings-text {
    max-width: 32rem;
}
/* THE THEME CONTROL (Dark mode 2; _theme-control.php): a bare icon button at the bar's right — the footer icons' muted
   grey, the text colour on hover / open — and a small menu of three items, a tick before the current one. */
.app-theme-toggle {
    color: var(--foliale-muted);
    background: none;
    border: 0;
    border-radius: 6px;
    padding: 0.25rem 0.4rem;
    font-size: 1.1rem;
    line-height: 1;
}
.app-theme-toggle:hover,
.app-theme-toggle[aria-expanded="true"] {
    color: var(--foliale-text);
}
.app-theme-toggle:focus-visible {
    outline: 0;
    box-shadow: 0 0 0 2px var(--foliale-ring-gap), 0 0 0 4px var(--foliale-action);
}
.app-theme-menu {
    --bs-dropdown-min-width: 12rem;
    --bs-dropdown-font-size: 14px;
    --bs-dropdown-link-color: var(--foliale-text);
    --bs-dropdown-link-hover-color: var(--foliale-text);
    --bs-dropdown-link-hover-bg: var(--foliale-surface);
    --bs-dropdown-link-active-color: var(--foliale-text);
    --bs-dropdown-link-active-bg: var(--foliale-row-active);
    --bs-dropdown-border-color: var(--foliale-edge);
}
.app-theme-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.app-theme-tick {
    color: var(--foliale-action);
}

/* Footer THREE ZONES: left icons | centre per-page context (#app-footer-centre) | right (reserved).
   The centre grows and centres the compact page <h1>; left/right hold their intrinsic width. The
   right zone is given the SAME min-width as the left icon cluster so the centre title stays visually
   centred under the footer, not shoved by the icons. Compact now — the painting pass refines. */
.app-footer-right {
    min-width: 3.5rem;   /* ~= the two left icons + gap, so the centre title is balanced */
}
.app-footer-title {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--foliale-text);   /* readable, not the footer's muted grey */
}
/* Foliale's version in the Settings page's centre footer ("Foliale <version>"; the build on hover) — muted, centred by the zone. */
.app-footer-version {
    color: var(--foliale-muted);
    cursor: default;
}

/* Footer left-cluster icon CONTROLS — the Home/Settings links AND the home-picker chevron button all
   read the same: muted, no button chrome, darken on hover/focus. (The chevron is a <button> so it can
   carry a delegated tooltip; data-bs-toggle="modal" would collide, so it opens via data-modal-open.) */
.app-footer-icon {
    color: var(--foliale-muted);
    text-decoration: none;
    background: none;
    border: 0;
    padding: 0;
    line-height: 1;
}
.app-footer-icon:hover,
.app-footer-icon:focus {
    color: var(--foliale-text);
}
/* The footer HOUSE with a default person set: the default person's green, hover and focus too. */
.app-footer-home--set,
.app-footer-home--set:hover,
.app-footer-home--set:focus {
    color: var(--foliale-home);
}

/* The LAUNCHER (`/`): a centred column of equal-width large buttons (~22rem; never wider than the centre). */
.launcher-actions {
    width: 22rem;
    max-width: 100%;
}

/* The footer BACK button (btn btn-outline-secondary btn-sm): a compact line-height and vertical padding, set
   through Bootstrap's own button variables, keep it inside the shared .app-bar height (a stock btn-sm would
   make the footer taller than the header it mirrors). */
.app-footer-back {
    --bs-btn-line-height: 1.2;
    --bs-btn-padding-y: 0.125rem;
}

/* The home-picker CARET pairs visually with the Home (house) icon = "home + change-home". The row's
   uniform gap-3 (1rem) is overridden ONLY on the caret: a negative left margin TIGHTENS it to the
   house (a pair), a positive right margin PUSHES it from Settings (separating the pair from settings).
   The Home/Settings icons' own alignment is untouched. */
.app-footer-chevron {
    margin-left: -0.65rem;   /* gap to Home ~0.35rem (tight pair) */
    margin-right: 0.4rem;    /* gap to Settings ~1.4rem (separated) */
}

/* Home-picker PICK button — the whole row is one full-width, left-aligned submit button with NO
   button chrome; hover/focus highlights it as a clickable "set as home" pick. */
.home-picker-pick {
    background: none;
    border: 0;
    color: inherit;
    border-radius: 0.375rem;
    padding-inline: 0.4rem;
}
.home-picker-pick:hover,
.home-picker-pick:focus {
    background: var(--foliale-row-active);
}

/* Centre column: min-width:0 lets it shrink instead of overflowing the row between the
   two fixed rails (Bootstrap 5.3 has no min-width-0 utility). It is a flex COLUMN
   (header / content / footer) via utilities in the markup; the content region fills +
   scrolls. */
.app-centre {
    min-width: 0;
}

/* THE SHELL HOLDS THE WINDOW (P3b fix). The shell is at least the viewport tall (100dvh where the browser has it —
   a phone's moving toolbars); the centre column fills it, so the footer sits at the window's bottom edge at the one
   48px bar height. The three SCROLLING regions are the containing block for anything absolutely positioned inside
   them: Bootstrap's .visually-hidden text is position: absolute, and with no positioned ancestor it was placed
   against the page itself — outside the centre's scroll box, unclipped — so on a long page in a short window
   (the person page's "Edit the marriage" label at 1280px in a 700px window) it stretched the DOCUMENT: the whole
   page scrolled, a white band showed under the footer and the rails stopped at the old window edge. */
.app-shell {
    min-height: 100vh;
    min-height: 100dvh;
}
.app-sidebar, .app-content, .app-rightpanel {
    position: relative;
}

/* === PAINTING P2 — THE CENTRE BLOCKS (DECISIONS Day 33 "Painting P2: the centre pattern") ==================
   Every centre page: the surface grey, 12px in from the rails; a white PAGE HEADER block; each section a
   .fo-heading on the grey (its actions right, 12px, teal) over white content; label / value sections as white
   ROWS 2px apart (a 120px label cell on --foliale-label, the value beside it); tabular data as white rows 2px apart
   under a .fo-heading header row, no borders; galleries / maps / grids as ONE white block. Links in the centre are
   the action teal; links to PEOPLE take the person's gender colour (.person-link--*). */
.app-content {
    background: var(--foliale-surface);
    --bs-link-color-rgb: var(--foliale-action-rgb);
    --bs-link-hover-color-rgb: var(--foliale-action-rgb);
}
#app-centre-content {
    padding: 12px;
}

/* The PAGE HEADER block: title, meta and the page's own controls, white. */
.fo-page-head {
    margin-bottom: 12px;
    background: var(--foliale-row);
    padding: 18px 20px;
}
/* Painting leftovers 1b: a confirm / notice page's explanation, warning and buttons sit IN the header block. */
.fo-page-head .alert {
    margin: 0.5rem 0 0;
}
.fo-page-head > :last-child,
.fo-page-head > form:last-child .fo-form-actions--bare {
    margin-bottom: 0;
}

/* A SECTION: its heading on the grey, the content one white block. The heading sits INSIDE the section (htmx swaps
   whole sections), so it is drawn on a surface band across the section's top. */
.fo-section {
    margin-top: 14px;
    padding: 0 20px 14px;
    background: var(--foliale-row);
}
.fo-section > .fo-section-title,
.fo-section > .fo-section-head {
    margin: 0 -20px 12px;
    padding: 0 0 6px;
    background: var(--foliale-surface);
}
/* A section whose content is ROWS (or a table of rows): the section itself stays on the grey; the rows are white. */
.fo-section:not(:has(> .fo-section-title, > .fo-section-head)) {
    padding-top: 14px;   /* a section with no heading of its own (the family view's couple) */
}
.fo-section--rows {
    padding: 0;
    background: transparent;
}
.fo-section--rows > .fo-section-title,
.fo-section--rows > .fo-section-head {
    margin: 0 0 0;
}
/* A heading with actions: .fo-heading left, the actions right — 12px, teal, as links (no button chrome). */
.fo-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.fo-head-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 12px;
    text-transform: none;
    letter-spacing: normal;
    font-weight: 400;
}
.fo-head-actions > a,
.fo-head-actions > .dropdown > .btn,
.fo-head-actions > .btn {
    --bs-btn-color: var(--foliale-action);
    --bs-btn-bg: transparent;
    --bs-btn-border-color: transparent;
    --bs-btn-hover-color: var(--foliale-action-hover);
    --bs-btn-hover-bg: transparent;
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-color: var(--foliale-action-press);
    --bs-btn-active-bg: transparent;
    --bs-btn-active-border-color: transparent;
    --bs-btn-padding-x: 0;
    --bs-btn-padding-y: 0;
    --bs-btn-font-size: 12px;
    color: var(--foliale-action);
    font-size: 12px;
    text-decoration: none;
}
/* …a TEXT ACTION (Painting P3a): hover underlines it in the hover teal. */
.fo-head-actions > a:hover,
.fo-head-actions > .dropdown > .btn:hover,
.fo-head-actions > .btn:hover {
    color: var(--foliale-action-hover);
    text-decoration: underline;
}

/* A heading that is also its section's COLLAPSE TOGGLE (the edit person page's Spouses / Partners and Parents): the
   .fo-heading look on a button; the chevron turns when the section is closed. */
.fo-heading-toggle {
    --bs-btn-color: var(--foliale-heading);
    --bs-btn-hover-color: var(--foliale-action);
    --bs-btn-active-color: var(--foliale-heading);
    --bs-btn-font-size: 13px;
    --bs-btn-font-weight: 600;
    --bs-btn-line-height: inherit;
    text-transform: uppercase;
    letter-spacing: .04em;
    vertical-align: baseline;
}
.fo-heading-toggle:hover {
    text-decoration: none;
}
.fo-heading-toggle .bi-chevron-down {
    display: inline-block;
    transition: transform 100ms ease-in-out;
}
.fo-heading-toggle.collapsed .bi-chevron-down {
    transform: rotate(-90deg);
}

/* ONE WHITE BLOCK with the centre blocks' padding — a gallery's grid (the title and "Showing x–y of N" stay on the grey above). */
.fo-block {
    background: var(--foliale-row);
    padding: 18px 20px;
}

/* A white ROW-BLOCK with no label column (a Stars fragment, a lone person): 2px of the surface between. */
.fo-card {
    background: var(--foliale-row);
    padding: 8px 12px;
    margin-bottom: 2px;
}

/* LABEL / VALUE ROWS: each row white, 2px of the surface between rows; the label cell 120px on --foliale-label. */
.fo-row {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    background: var(--foliale-row);
    margin-bottom: 2px;
}
.fo-row > .fo-row-label {
    background: var(--foliale-label);
    color: var(--foliale-heading);
    font-size: 14px;
    font-weight: 400;
    padding: 8px 10px;
}
.fo-row > .fo-row-value {
    padding: 8px 12px;
    color: var(--foliale-text);
    min-width: 0;
}

/* FORMS AS ROWS (Painting P3b): every field of an edit / add form is a .fo-row — its name in the grey label cell (a
   <label> there needs no margin), its control in the value cell, the help text muted 12px under the control. Groups
   of fields sit under .fo-heading section headings on the grey; the buttons close the form in a final white row
   (.fo-form-actions), right-aligned with the primary last (a danger opener, when there is one, at the left). */
.fo-row > label.fo-row-label,
.fo-row > legend.fo-row-label {
    margin: 0;
    float: none;
    width: auto;
}
.fo-row > .fo-row-value > .form-text,
.fo-row > .fo-row-value .fo-help {
    font-size: 12px;
    color: var(--foliale-muted);
    margin-top: 4px;
}
.fo-row > .fo-row-value > .form-check {
    margin-bottom: 0;
}
fieldset.fo-row {
    min-width: 0;
    border: 0;
    padding: 0;
}
.fo-form-group {
    margin-top: 14px;
}
.fo-form-group > .fo-heading {
    margin-bottom: 6px;
}
.fo-form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    background: var(--foliale-row);
    padding: 10px 12px;
    margin-top: 2px;
}
.fo-form-actions > .fo-form-actions-start {
    margin-right: auto;
}
/* ONE LABEL COLUMN PER BLOCK (P3b fix): a block that uses the label column has ONE grey column, unbroken from its top
   row to its bottom — so an actions row in a block of rows carries the grey band in its first 120px too. */
.fo-form-actions:not(.fo-form-actions--bare) {
    padding-left: calc(120px + 12px);
    background: linear-gradient(to right, var(--foliale-label) 120px, var(--foliale-row) 120px);
}
/* BARE form pieces: a form INSIDE a value column (or inside a white block with no label column of its own) renders no
   label cell — its label, when one is needed, is a small muted line above the control — and its buttons sit plainly
   under it (.fo-form-actions--bare), right-aligned, primary last. */
.fo-bare-label {
    display: block;
    font-size: 12px;
    color: var(--foliale-muted);
    margin-bottom: 2px;
}
.fo-form-actions--bare {
    background: transparent;
    padding: 8px 0 0;
    margin-top: 0;
}
/* STICKY actions row (Painting P4, the Settings page): stays in view at the foot of the scrolling centre (main.app-content
   scrolls), a hairline above it while the page runs on beneath. */
.fo-form-actions--sticky {
    position: sticky;
    bottom: 0;
    z-index: 2;
    box-shadow: 0 -1px 0 var(--foliale-edge);
}
/* The notes rows' items: 8px apart, a surface hairline between. */
.person-notes .note-item + .note-item {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--foliale-surface);
}
/* A description list as label / value rows (place facts, a backup's facts). Bootstrap's .row / .col-* lose their
   grid widths here. */
dl.fo-dl {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    row-gap: 2px;
    margin: 0;
}
dl.fo-dl > dt,
dl.fo-dl > dd {
    width: auto;
    max-width: none;
    margin: 0;
}
dl.fo-dl > dt {
    background: var(--foliale-label);
    color: var(--foliale-heading);
    font-size: 14px;
    font-weight: 400;
    padding: 8px 10px;
}
dl.fo-dl > dd {
    background: var(--foliale-row);
    color: var(--foliale-text);
    padding: 8px 12px;
}

/* TABULAR DATA (census list, media, accounts, backups, Stars, Living, place events …): the columns kept, each body
   row white with 2px of the surface between rows, the header row in .fo-heading on the grey, no borders. A table
   that is ONE grid (the census transcript) opts out with .fo-grid and sits in a white block. */
.app-content .table:not(.fo-grid) {
    --bs-table-bg: var(--foliale-row);
    --bs-table-striped-bg: var(--foliale-row);
    border-collapse: separate;
    border-spacing: 0 2px;
    margin-top: -2px;
}
.app-content .table:not(.fo-grid) > :not(caption) > * > * {
    border-bottom-width: 0;
}
.app-content .table:not(.fo-grid) > thead > tr > th {
    --bs-table-bg: var(--foliale-surface);
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--foliale-heading);
    white-space: nowrap;
}
.app-content .table:not(.fo-grid) > tbody > tr > * {
    padding: 8px 10px;
}
/* A label column inside a table of label / value rows (a citation's fields). */
.app-content .table > tbody > tr > th.fo-cell-label {
    --bs-table-bg: var(--foliale-label);
    color: var(--foliale-heading);
    font-weight: 400;
    font-size: 14px;
    width: 120px;
}

/* Links to PEOPLE in the centre take the person's gender colour; unknown gender (and a living person hidden from
   this account) keeps the body text colour. Every other centre link is the action teal (above). */
.person-link {
    text-decoration: none;
}
.person-link:hover,
.person-link:focus-visible {
    text-decoration: underline;
}
.person-link--female {
    color: var(--foliale-female);
}
.person-link--male {
    color: var(--foliale-male);
}
.person-link--unknown {
    color: var(--foliale-text);
}
/* Surnames in upper case (name.surname_case = upper): the name helper (person_name) marks the surname alone; the capitals
   are drawn here, the text stays as written — a copy gives the name as written. */
.fo-surname {
    text-transform: uppercase;
}

/* A portrait's GENDER STRIP: 4px on its left (the person header; unknown and a hidden living person neutral). */
.fo-strip {
    border-left: 4px solid var(--foliale-unknown);
}
.fo-strip--female {
    border-left-color: var(--foliale-female);
}
.fo-strip--male {
    border-left-color: var(--foliale-male);
}
/* A find-a-person MATCH on the add pages (Painting leftovers 1): the 4px gender strip on its left, the radio inside it,
   matches 2px apart. */
.person-candidate.form-check {
    padding: 2px 0 2px calc(1.5em + 8px);
    margin: 0 0 2px;
}
.person-candidate .form-check-input {
    margin-left: -1.5em;
}

.app-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

/* Every left-rail entry is a plain 14px ROW across the rail: no underline, the body text colour; hover shows
   the active row's white. The ACTIVE entry (rail-index.js marks it .is-active from the URL; a spine link
   .is-current from the scroll-spy) is a white row with its label at 500. */
.app-nav-item > a,
.app-nav-item > span {
    display: flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    color: var(--foliale-text);
    text-decoration: none;
    line-height: 1.4;
}
.app-nav-item > a:hover,
.app-nav-item > a:focus-visible {
    background: var(--foliale-row);
}
.app-nav-item > a.is-active,
.app-nav-item > a.is-current,
.app-nav-item > a[aria-current="page"] {
    background: var(--foliale-row);
    font-weight: 500;
}

/* The CONSTANT NAVIGATION's icons: 17px in the heading grey; teal (the action colour) on the active entry. */
.app-nav-main .bi,
.app-nav-admin .bi {
    font-size: 17px;
    line-height: 1;
    color: var(--foliale-heading);
}
.app-nav-main a.is-active .bi,
.app-nav-admin a.is-active .bi {
    color: var(--foliale-action);
}
/* ADMIN (admins only): a toggle row like the others — shield icon, label, a chevron at the right end — that opens
   UPWARD: its sub-list (Settings, Accounts, Backups) sits above it, the rows indented. The chevron points up while
   closed (where it opens) and turns down when open. No hairline: Admin is one more row of the navigation. */
.app-nav-item > .app-nav-admin-toggle {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0.25rem 0.75rem;
    border: 0;
    background: none;
    color: var(--foliale-text);
    font: inherit;
    line-height: 1.4;
    text-align: left;
}
.app-nav-item > .app-nav-admin-toggle:hover,
.app-nav-item > .app-nav-admin-toggle:focus-visible {
    background: var(--foliale-row);
}
.app-nav-admin-toggle .app-nav-chevron {
    margin-left: auto;
    font-size: 12px;
    color: var(--foliale-muted);
    transition: transform 0.15s ease;
}
.app-nav-admin-toggle[aria-expanded="true"] .app-nav-chevron {
    transform: rotate(180deg);
}
.app-nav-admin .app-nav-item > a {
    padding-left: 1.75rem;
}

/* The rail's PAGE SPINE (P1a, rail-index.js): the current page's own index at the top of the rail — its
   heading (.fo-heading), then its sections as plain rows with no icons, the one in view marked (scroll-spy).
   Then, under a hairline, the PAGE ACTIONS ("Family chart") with their icons. A hairline closes the block
   before the constant navigation. A not-yet-built entry is muted and inert (its tooltip says when). */
.app-rail-index {
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--foliale-edge);
}
.app-rail-index-title {
    padding: 0 0.75rem;
    margin-bottom: 0.25rem;
}
.app-rail-index-charts {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--foliale-edge);
}
.app-rail-index-charts .bi {
    font-size: 17px;
    line-height: 1;
    color: var(--foliale-heading);
}
.app-rail-index-disabled {
    color: var(--foliale-muted);
    cursor: not-allowed;
}

/* An inert control that keeps its tooltip (a disabled .btn swallows pointer events, so the tooltip would
   never show): looks disabled, stays hoverable / focusable. */
.disabled-look {
    opacity: 0.65;
    cursor: not-allowed;
}

/* Right list region: fixed width, on the surface grey, a hairline on its centre-facing (left) edge. The
   region is a permanent column; flex-shrink-0 + width hold it at 23rem (empty or full), and each rail
   scrolls its own results — both via utilities in the markup. Horizontal padding is small and symmetric
   (box-sizing is border-box, so the padding eats into the 23rem); the lists carry .list-unstyled. */
.app-rightpanel {
    width: 23rem;
    padding: 0.75rem 0.5rem;
    background: var(--foliale-surface);
    border-left: 1px solid var(--foliale-edge);
}

/* The PORTRAIT FRAME — every portrait / avatar renders in a 7:9 frame (tokens above). A 7:9 image (a new
   portrait, an avatar) FILLS it (.portrait-fit-cover); anything else — an OLD square portrait, never
   migrated — is shown WHOLE inside the same frame (.portrait-fit-contain, on the frame background): never
   stretched. The size modifier sets the height; the width follows from the aspect. */
.portrait-frame {
    display: block;
    aspect-ratio: var(--foliale-portrait-aspect);
    height: var(--foliale-portrait-thumb-h);
    overflow: hidden;
    background: var(--foliale-frame);   /* behind an OLD square shown contained */
}

.portrait-frame--header {
    height: var(--foliale-portrait-header-h);
}

.portrait-frame--thumb {
    height: var(--foliale-portrait-thumb-h);
}

.portrait-frame--small {
    height: var(--foliale-portrait-small-h);
}

/* The FAMILY VIEW (/family/{id}, FV1): small boxes (grandparents, children) and the couple's panels. The text column
   may shrink (long names wrap, never push the page wide); the bio scrolls when long; the marriage heart uses its
   own token. The LAYOUT keys on the CENTRE's own width (a container query — the Census list's reflow), not the
   viewport: the centre sits between the rails, so a wide window can still give the page a narrow column. Wide:
   the parents row and the couple side by side, the children three across. At 700px or under everything stacks to
   one column; under 420px a couple panel puts its portrait above the text. */
.family-view {
    container-type: inline-size;
    container-name: familyview;
}
.fv-pair {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}
.fv-pair--tight {
    gap: 0.5rem;
}
.fv-pair-cell,
.fv-children-cell {
    min-width: 0;
}
.fv-panel-body {
    display: flex;
    flex-direction: row;
    gap: 1rem;
}
.fv-children {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}
@container familyview (max-width: 700px) {
    .fv-pair,
    .fv-children {
        grid-template-columns: minmax(0, 1fr);
    }
}
@container familyview (max-width: 420px) {
    .fv-panel-body {
        flex-direction: column;
    }
}
.fv-text {
    min-width: 0;
    overflow-wrap: anywhere;
}
.fv-bio {
    max-height: 12rem;
    overflow-y: auto;
    white-space: normal;
}
.fv-heart {
    color: var(--foliale-danger);
}
/* THE TILES (Painting P3b): grandparents, the marriage line, the couple and the children are plain white blocks on the
   grey, 2px apart, no borders; each person tile carries the 4px gender strip (.fo-strip) on its left edge. */
.fv-box,
.fv-panel,
.fv-marriage {
    background: var(--foliale-row);
}
/* Spacing (P3b fix): the father's side and the mother's side 16px apart at BOTH levels (the two grandparent couples;
   the two parents), so the four grandparents read as two pairs over the two parents; within a couple the tiles touch,
   2px; the children 2px apart. */
.fv-pair {
    gap: 16px;
}
.fv-pair.fv-pair--tight,
.fv-children {
    gap: 2px;
}
.fv-marriage {
    margin-bottom: 2px;
}
/* MARRIED BY: "by licence" is set in the size of the place text before it. Where that place is a place chain
   (.place-chain, 12px: the person page's marriage lines and the family view) the wording is 12px too, with or without a
   place; elsewhere the place is the line's own text and the wording inherits it. Its colour is .text-muted, the quiet
   colour those lines use for secondary text — never the place's link colour. */
.marriage-line .marriage-by,
.fv-marriage .marriage-by {
    font-size: 12px;
}
.fv-unknown {
    background: var(--foliale-row);
}
/* "ALSO MARRIED": a partner's other family under their card — one link per line, in the quiet secondary colour
   of .text-muted, the other partner's name (its span) in the link colour; underlined on hover. */
.fv-also {
    color: var(--bs-secondary-color);
    text-decoration: none;
}
.fv-also:hover {
    text-decoration: underline;
}
.fv-also > span {
    color: var(--bs-link-color);
}

.portrait-frame > img {
    display: block;
    width: 100%;
    height: 100%;
}

.portrait-fit-cover {
    object-fit: cover;
}

.portrait-fit-contain {
    object-fit: contain;
}

/* The RIGHT-RAIL HEADER (_rail-head.php) — the same block atop People, Places and Sources: the title
   (15px / 500) and its muted count on the left, the rail's actions as small WHITE outline buttons on the
   right; pinned above the search (only the rail's results region scrolls). */
.rail-head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.rail-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--foliale-text);
}
.rail-count {
    font-size: 12px;
    color: var(--foliale-muted);
    white-space: nowrap;
}
.rail-btn {
    --bs-btn-bg: var(--foliale-row);
    --bs-btn-color: var(--foliale-text);
    --bs-btn-border-color: var(--foliale-edge);
    --bs-btn-hover-bg: var(--foliale-row-active);
    --bs-btn-hover-color: var(--foliale-text);
    --bs-btn-hover-border-color: var(--foliale-edge);
    --bs-btn-active-bg: var(--foliale-row-active);
    --bs-btn-active-color: var(--foliale-text);
    --bs-btn-active-border-color: var(--foliale-edge);
}

/* The rail's SEARCH box, full width beneath the head: every part white with a 1px edge border (the
   magnifier, the input, the clear button, People's status menu). */
.rail-search {
    flex-shrink: 0;
    margin-bottom: 0.5rem;
}
.rail-search .input-group-text,
.rail-search .form-control,
.rail-search .btn {
    background: var(--foliale-row);
    border-color: var(--foliale-edge);
    color: var(--foliale-text);
}
.rail-search .input-group-text,
.rail-search .btn {
    color: var(--foliale-muted);
}

/* A rail's ROWS: white, touching, a 1px surface-grey hairline between rows of one group; 14px text. The
   open row (rail-index.js marks it .is-open from the URL) is --foliale-row-active, its name at 500. */
.rail-row {
    background: var(--foliale-row);
    font-size: 14px;
    line-height: 1.4;
}
.rail-row + .rail-row {
    border-top: 1px solid var(--foliale-surface);
}
/* The results region runs the rail's full width (Painting P2 fold-in): the surname bands and the rows touch both
   edges, no inset; the head and the search keep the rail's padding. */
.people-results,
.places-results,
.sources-rail-results {
    margin-inline: -0.5rem;
}
.rail-row.is-open {
    background: var(--foliale-row-active);
}

/* === Sources (Sources arc S2): the list (sources.php) + the source page (source.php) ===========
   Colours are Bootstrap variables only (no raw hex). */

/* Source TYPE chip (Original / Derivative / Authored): a neutral badge (Painting P3a — the badge roles below). */

/* The list's code + name links read as table text, underlined on hover. */
.sources-table a {
    color: inherit;
    text-decoration: none;
}
.sources-table a:hover,
.sources-table a:focus-visible {
    text-decoration: underline;
}
.sources-code {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.source-notes {
    white-space: normal;
    color: var(--foliale-text);
}

/* A citation row: thumbnail slot + text, the whole row one link. */
.source-citation {
    background: var(--foliale-row);   /* Painting P2: each citation a white row, 2px of the surface between */
    margin-bottom: 2px;
    padding: 0 12px;
}
.source-citation-link {
    padding: 0.5rem 0;
    color: inherit;
    text-decoration: none;
}
.source-citation-link:hover .source-citation-locator,
.source-citation-link:focus-visible .source-citation-locator {
    text-decoration: underline;
}

/* The 64x48 PAGE-THUMBNAIL slot (_page-thumb.php — source rows, citation Page images; kept even when
   empty, so rows line up). The image is the fit-inside page thumbnail, shown WHOLE (contain — never
   cropped: a census page stays a page); a PDF without a rendered page shows a centred file icon. */
.page-thumb {
    width: 64px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--bs-border-radius-sm);
    overflow: hidden;
}
.page-thumb-img {
    width: 64px;
    height: 48px;
    object-fit: contain;
}
.page-thumb-doc {
    font-size: 1.75rem;
    color: var(--bs-secondary-color);
}

/* The EDIT-PHOTO modal's photo (_photo-edit.php): shown large but WHOLE — fit inside ~70% of the viewport
   height, never cropped or upscaled past its width. */
.photo-edit-img {
    display: block;
    max-width: 100%;
    max-height: 70vh;
    margin: 0 auto;
    object-fit: contain;
}
.photo-edit-doc {
    font-size: 2.5rem;
    color: var(--bs-secondary-color);
}

/* === Citation page (S3): page images, cited facts, the media viewer ============================= */

.citation-source a {
    text-decoration: none;
}
.citation-page-row,
.citation-fact {
    padding: 8px 12px;
    background: var(--foliale-row);   /* Painting P2: white rows, 2px of the surface between */
    margin-bottom: 2px;
}
.citation-page-open {
    --bs-btn-border-color: var(--foliale-edge);
    --bs-btn-hover-border-color: var(--foliale-action);
    --bs-btn-bg: var(--foliale-surface);
}
.citation-page-label {
    min-width: 0;   /* lets the filename truncate inside the flex row */
}
/* Page images' title and description (16 Nov 2026): the title under "Page N" in the page's own text colour, the
   editor's pencil beside "Page N"; the viewer's page-image title under the locator heading. */
.citation-page-title {
    color: var(--foliale-text);
}
.citation-page-edit,
.census-image-edit {
    margin-left: 4px;
}
.media-viewer-page-title {
    font-size: 0.875rem;
    color: var(--foliale-text);
}

/* Field marker ("date only" / "place only"), the three classification chips (.evidence-chip) and a source KIND
   (.source-kind-chip, 0032): neutral badges (Painting P3a). The citation page's fields table: label column narrow
   and muted, values wrap. */
.citation-fields {
    max-width: 40rem;
}
.citation-field-label {
    width: 12rem;
    white-space: nowrap;
}
.citation-field-value {
    overflow-wrap: anywhere;
}

/* The viewer: an image fills the modal width at its own aspect (the scrollable body handles a tall
   page); a PDF gets the browser's own viewer, as tall as the capped body allows. */
.media-viewer-body {
    text-align: center;
}
.media-viewer-img {
    max-width: 100%;
    height: auto;
}
/* Zoomed (any level but Fit; media-viewer.js sets the width): the image leaves the width cap and the
   body scrolls BOTH ways. A block with auto margins centres while it fits and starts at the left edge
   once it is wider, so the whole page stays reachable by scrolling. */
.media-viewer-body {
    overflow: auto;
}
.media-viewer-img.is-zoomed {
    display: block;
    max-width: none;
    margin: 0 auto;
}
.media-viewer-pdf {
    width: 100%;
    height: 75vh;
    border: 0;
}

/* === Event page Sources box (S4) ================================================================ */
.event-source {
    padding: 0.35rem 0;
}
.event-source + .event-source {
    border-top: 1px solid var(--foliale-edge);
}
.event-source-cite {
    text-decoration: none;
}
.citation-pick-options,
.source-pick-options {
    max-height: 16rem;
    overflow-y: auto;
}
/* "Last used" (.citation-last-used, a neutral badge) and "unattached" (.source-unattached — evidence no fact cites,
   the orphan policy; a warning badge): the classes are hooks, the colours the badge roles' (Painting P3a). */

/* L2 — the SIGN-IN pages (/login, /setup): outside the frame, one centred card (layout-plain.php). */
.auth-page {
    background-color: var(--foliale-surface);   /* Painting P2: the surface grey, the white card on it */
}
.auth-card {
    --bs-card-bg: var(--foliale-row);
    --bs-card-border-color: var(--foliale-edge);
    width: 100%;
    max-width: 24rem;
}
/* MULTI-TREE brick 4a-2 — the tree pages in the plain shell (the tree list, Create, the earlier save): the card wider, no
   rails. The list's description is cut short (the whole text on hover, its title). */
.auth-card--wide {
    max-width: 64rem;
}
.trees-table {
    --bs-table-bg: transparent;
}
.trees-description-text {
    max-width: 16rem;
    vertical-align: bottom;
}
/* MULTI-TREE brick 7 — the Delete page: the sentences and labels of the way chosen only. Unticked, the KEEP wording; ticked
   ("Also delete all N backups"), the ALL wording ("This cannot be undone.", the name to type). No script: the tick box's
   own state; a browser without :has shows both (the server decides by the tick). */
@supports selector(:has(*)) {
    .tree-delete-form .tree-delete-when-all {
        display: none;
    }
    .tree-delete-form:has(.tree-delete-all:checked) .tree-delete-when-all {
        display: revert;
    }
    .tree-delete-form:has(.tree-delete-all:checked) .tree-delete-when-keep {
        display: none;
    }
}
/* The header's tree menu (the admin's; _header-tree.php): the name as a quiet link-like button, muted as the plain name.
   With no tree open, the admin's "Trees" link to the tree list sits in the same place and looks the same. */
.app-header-tree-toggle,
.app-header-tree-list {
    --bs-btn-color: var(--foliale-muted);
    --bs-btn-hover-color: var(--foliale-text);
    --bs-btn-active-color: var(--foliale-text);
    max-width: 100%;
    text-decoration: none;
}
/* The shell's one line when Foliale is paused (unavailable.js, an htmx 503): fixed at the top, the danger role's colours. */
.app-unavailable {
    position: fixed;
    top: 0.75rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1090;   /* above a modal (1055) and its backdrop: a banner, never a modal of its own */
    max-width: calc(100% - 2rem);
    background-color: var(--foliale-row);
    color: var(--foliale-danger);
    border: 1px solid var(--foliale-danger);
}
/* L2 — footer RIGHT: the signed-in account's name (truncated when long) + Sign out. */
.app-footer-user {
    max-width: 12rem;
}

/* The person header's "Living" badge (person.living = 1) — a success badge (Painting P3a), a 14px pill beside the 24px name
   (P3b), centred on it. */
.person-living-badge {
    --bs-badge-font-size: 14px;
    vertical-align: middle;
}

/* The media viewer's heading: the title over its size caption ("2500 × 1173 · 620 KB"). min-width 0 lets both
   truncate inside the flex header beside the zoom toolbar (Bootstrap has no min-width utility). */
.media-viewer-heading {
    min-width: 0;
    flex: 1 1 auto;
}

/* === THE LARGE MAP (_map-modal.php; leaflet-map.js moves the live map in and out) ============================ */
/* the expand control in a map's top-right corner: a Leaflet bar button, the size and look of the zoom buttons */
.leaflet-bar.map-expand-control .map-expand {
    display: block;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 2px;
    background: var(--foliale-row);
    color: var(--foliale-text);
    font-size: 0.9rem;
    line-height: 30px;
    text-align: center;
    cursor: pointer;
}
.leaflet-bar.map-expand-control .map-expand:hover { background: var(--foliale-surface); }
/* nearly the whole window from the small breakpoint up (below it modal-fullscreen-sm-down fills the screen) */
@media (min-width: 576px) {
    .map-modal .map-modal-dialog {
        max-width: none;
        width: 95vw;
        height: 95vh;
        margin: 2.5vh auto;
    }
    .map-modal .modal-content { height: 100%; }
}
/* the body: a column the map fills; the rest of a moved block (the numbered list, an editor's forms) sits under it */
.map-modal .map-modal-body {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: auto;
    padding: 0.75rem;
    --bs-link-color-rgb: var(--foliale-action-rgb);         /* its links as the centre's: the action teal */
    --bs-link-hover-color-rgb: var(--foliale-action-rgb);
}
.map-modal-body > :not(.leaflet-container) {
    display: flex;
    flex-direction: column;
    flex: 1 0 auto;
    margin: 0;
}
.map-modal-body > * > *,
.map-modal-body .spine-body > * { flex: 0 0 auto; }
.map-modal-body .spine-row--block,
.map-modal-body .spine-body {
    display: flex;
    flex-direction: column;
    flex: 1 0 auto;
}
.map-modal-body .leaflet-container {
    flex: 1 0 auto;
    height: auto;
    max-height: none;
    min-height: 50vh;
}
/* the modal's title names it: the block's own heading and label column, and the expand control, are not shown in it */
.map-modal-body .fo-section-title,
.map-modal-body .spine-row.spine-head,
.map-modal-body .spine-label,
.map-modal-body .map-expand-control { display: none; }
.map-modal-body .person-map-list {
    max-height: 22vh;
    overflow: auto;
}
