/* ============================================================================
   Tree of Life — responsive styles for desktop, laptop, tablet and phone.

   Layout (unchanged): fixed header of 16% of the screen height, access menu on
   the left of every page, chat boxes docked bottom-right.

   Look: botanical-engraving theme. The drawings in /img/art are monochrome SVG
   line art used as CSS *masks*; each one is painted with var(--art-ink), so a
   change of theme recolours every ornament on the page at once. All colours
   come from css/themes.css — nothing below hard-codes one.

   How to place an ornament:
       .someblock::before { ... ; -webkit-mask: var(--m-wreath); mask: var(--m-wreath);
                            background: var(--art-ink); opacity: var(--art-op); }
   ========================================================================== */

/* ------------------------------------------------------------------ masks */
:root {
    --art: url("../img/art/");
    --m-canopy:  url("../img/art/canopy.svg")     no-repeat center top / 100% 100%;
    --m-roots:   url("../img/art/roots.svg")      no-repeat center bottom / 100% 100%;
    --m-corner:  url("../img/art/corner.svg")     no-repeat center / contain;
    --m-wreath:  url("../img/art/wreath.svg")     no-repeat center / contain;
    --m-vine:    url("../img/art/vine.svg")       no-repeat center / 100% 100%;
    --m-sprig:   url("../img/art/sprig.svg")      no-repeat center / contain;
    --m-fern:    url("../img/art/fern.svg")       no-repeat center / contain;
    --m-hatch:   url("../img/art/hatch.svg")      repeat left top / 34px 34px;
    --m-seal:    url("../img/art/seal.svg")       no-repeat center / contain;
    --m-arch:    url("../img/art/arch.svg")       no-repeat center top / 100% 100%;
    --m-leaf:    url("../img/art/leafmark.svg")   no-repeat center / contain;
    --m-emblem:  url("../img/art/emblem.svg")     no-repeat center / contain;
    --m-tree:    url("../img/art/empty-tree.svg") no-repeat center / contain;
    --m-grove:   url("../img/art/grove.svg")      no-repeat center bottom / contain;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    position: relative;
    transition: background-color .25s ease, color .25s ease;
}

/* ---- page-wide artwork: engraved paper grain + a grove along the bottom --- */
body::before,
body::after {
    content: ""; position: fixed; pointer-events: none; z-index: 0;
    background-color: var(--art-ink);
}
body::before {                                   /* hatching = paper texture */
    inset: 0;
    -webkit-mask: var(--m-hatch); mask: var(--m-hatch);
    opacity: var(--paper-op);
}
body::after {                                    /* grove standing on the fold */
    left: 0; right: 0; bottom: 0; height: min(24vh, 210px);
    -webkit-mask: var(--m-grove); mask: var(--m-grove);
    -webkit-mask-size: auto 100%; mask-size: auto 100%;
    -webkit-mask-position: center bottom; mask-position: center bottom;
    -webkit-mask-repeat: repeat-x; mask-repeat: repeat-x;
    opacity: calc(var(--art-op) * .55);
}
/* everything real sits above the artwork */
.topbar, .layout, .chatdock, .toast, .dropdown { position: relative; z-index: 1; }

/* --------------------------- reusable ornaments --------------------------
   Drop <span class="art art-wreath"></span> (or i-sprig, i-seal ...) anywhere
   in a page and it inherits the theme colour automatically.                */
.art {
    display: inline-block; background-color: var(--art-ink);
    opacity: var(--art-op-strong); vertical-align: middle; flex: none;
}
.art-leaf   { width: 1em;    height: 1em;    -webkit-mask: var(--m-leaf);   mask: var(--m-leaf); }
.art-sprig  { width: 34px;   height: 34px;   -webkit-mask: var(--m-sprig);  mask: var(--m-sprig); }
.art-seal   { width: 56px;   height: 56px;   -webkit-mask: var(--m-seal);   mask: var(--m-seal); }
.art-wreath { width: 120px;  height: 120px;  -webkit-mask: var(--m-wreath); mask: var(--m-wreath); }
.art-vine   { width: 100%;   height: 26px;   -webkit-mask: var(--m-vine);   mask: var(--m-vine); }
.art-tree   { width: 190px;  height: 200px;  -webkit-mask: var(--m-tree);   mask: var(--m-tree); }
.art-emblem { width: 96px;   height: 96px;   -webkit-mask: var(--m-emblem); mask: var(--m-emblem); }
.art.solid  { opacity: 1; }

/* a vine rule used as a section separator */
.rule { display: block; height: 26px; margin: 18px auto; max-width: 620px;
        background: var(--art-ink); opacity: var(--art-op-strong);
        -webkit-mask: var(--m-vine); mask: var(--m-vine); }

/* illustrated empty state: a bare tree waiting to be filled in */
.artempty { text-align: center; padding: 26px 16px 30px; color: var(--muted); }
.artempty .art-tree { display: block; margin: 0 auto 10px; opacity: var(--art-op-strong); }
.artempty p { margin: 4px 0; }

/* ---------- fixed header (16% of screen height) ---------- */
.topbar {
    position: fixed; top: 0; left: 0; right: 0;
    height: var(--header-h);
    display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
    gap: 10px;
    background:
        radial-gradient(120% 160% at 50% -40%, rgba(255,255,255,.12), transparent 60%),
        linear-gradient(180deg, var(--bar-1), var(--bar-2));
    color: var(--on-bar);
    padding: 0 18px;
    z-index: 90;
    box-shadow: 0 2px 14px rgba(var(--shadow), .30);
    /* NB: no overflow:hidden here — it would clip the header dropdowns.
       The canopy below is bounded by its own inset:0 box instead. */
}
/* foliage hanging into the header from above */
.topbar::before {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background-color: var(--on-bar);
    -webkit-mask: var(--m-canopy); mask: var(--m-canopy);
    -webkit-mask-size: 1400px 100%; mask-size: 1400px 100%;
    -webkit-mask-repeat: repeat-x; mask-repeat: repeat-x;
    opacity: .17;
}
/* engraved gold hairline along the bottom edge */
.topbar::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
    opacity: .75;
}
.tb-left, .tb-center, .tb-right { position: relative; z-index: 2; }
.tb-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--on-bar); text-decoration: none; min-width: 0; }
.brandlogo {
    height: calc(var(--header-h) - 6vh); max-height: 74px; min-height: 34px;
    width: calc(var(--header-h) - 6vh); max-width: 74px; min-width: 34px;
    background-color: var(--on-bar);
    -webkit-mask: var(--m-emblem); mask: var(--m-emblem);
    filter: drop-shadow(0 1px 2px rgba(0,0,0,.35));
}
.brandtext { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brandname {
    font-family: var(--font-display);
    font-weight: 600; font-size: clamp(1rem, 2.3vh, 1.55rem);
    white-space: nowrap; letter-spacing: .01em;
}
/* the sub-names under the brand: "Tree of Life · family tree" */
.brandsub { font-size: clamp(.62rem, 1.3vh, .8rem); opacity: .82; letter-spacing: .05em; white-space: nowrap; }
.tb-center {
    display: flex; align-items: center; gap: 12px; justify-content: center;
    cursor: pointer; min-width: 0;
}
.famlogo {
    height: calc(var(--header-h) - 6vh); max-height: 72px; min-height: 34px;
    border-radius: 14px; background: var(--card); object-fit: cover;
    aspect-ratio: 1; border: 2px solid rgba(255,255,255,.55);
    box-shadow: 0 2px 8px rgba(0,0,0,.28);
}
.fambrandname {
    font-family: var(--font-display);
    font-size: clamp(.95rem, 2.1vh, 1.4rem); font-weight: 600;
    color: color-mix(in srgb, var(--on-bar) 88%, transparent);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tb-right { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.tbbtn {
    position: relative; background: rgba(255,255,255,.14); color: var(--on-bar);
    border: 1px solid rgba(255,255,255,.16); border-radius: 11px;
    padding: 8px 12px; font-size: 1.05rem; cursor: pointer;
    display: inline-flex; align-items: center; gap: 8px;
    transition: background .15s ease, border-color .15s ease;
}
.tbbtn:hover { background: rgba(255,255,255,.26); border-color: rgba(255,255,255,.4); }
.userbtn .username { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .92rem; }
.badge-count {
    background: var(--danger); color: #fff; border-radius: 999px;
    font-size: .7rem; padding: 1px 6px; margin-left: 4px;
}
.tbbtn .badge-count { position: absolute; top: -5px; right: -5px; }
.langswitch {
    border-radius: 9px; border: 1px solid rgba(255,255,255,.2); padding: 6px 7px;
    background: rgba(255,255,255,.9); color: #1e2c23;
}
.hamburger { display: none; background: none; border: none; color: var(--on-bar); font-size: 1.5rem; cursor: pointer; }

/* header dropdowns */
.menuwrap { position: relative; }
.dropdown {
    position: absolute; right: 0; top: calc(100% + 8px);
    background: var(--card); color: var(--ink);
    border: 1px solid var(--line); border-radius: var(--radius);
    min-width: 280px; max-height: 60vh; overflow-y: auto;
    box-shadow: 0 12px 34px rgba(var(--shadow), .28); z-index: 120;
}
.dropdown a { display: block; padding: 10px 16px; color: var(--ink); text-decoration: none; }
.dropdown a:hover { background: var(--accent-tint); }
.dropdown-head {
    padding: 10px 16px; font-weight: 700; font-family: var(--font-display);
    border-bottom: 1px solid var(--line); color: var(--accent-dark);
}
.dropdown-foot { border-top: 1px solid var(--line); color: var(--accent-dark) !important; font-weight: 600; }
.dropdown-empty { padding: 14px 16px; color: var(--muted); }
.conv-item { display: flex !important; align-items: center; gap: 10px; }
.conv-item.active { background: var(--accent-tint); }
.conv-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.conv-last { color: var(--muted); font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: .75rem; color: var(--muted); white-space: nowrap; }

/* --------------------------- theme picker (header) ---------------------- */
.themepanel { padding: 6px 10px 12px; }
.themegrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.themeopt {
    display: flex; align-items: center; gap: 9px; cursor: pointer;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    padding: 8px 10px; background: var(--card-2); color: var(--ink);
    font-size: .87rem; text-align: left; width: 100%;
    transition: border-color .15s ease, transform .12s ease;
}
.themeopt:hover { border-color: var(--accent); transform: translateY(-1px); }
.themeopt[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 600; }
.swatch {
    width: 30px; height: 30px; border-radius: 50%; flex: none;
    border: 1px solid rgba(0,0,0,.18);
    background: linear-gradient(135deg, var(--sw-bg) 0 50%, var(--sw-accent) 50% 100%);
    position: relative; overflow: hidden;
}
.swatch::after {
    content: ""; position: absolute; inset: 3px;
    background-color: var(--sw-ink);
    -webkit-mask: var(--m-leaf); mask: var(--m-leaf);
    opacity: .8;
}
/* swatch colours are literal on purpose: a swatch must show the theme it
   offers, not the theme currently applied */
.sw-forest    { --sw-bg:#f3f6f1; --sw-accent:#2f7d52; --sw-ink:#1e5637; }
.sw-parchment { --sw-bg:#f6efe1; --sw-accent:#7a5323; --sw-ink:#573914; }
.sw-orchard   { --sw-bg:#faf4ea; --sw-accent:#b4622a; --sw-ink:#8a4518; }
.sw-bloom     { --sw-bg:#faf3f6; --sw-accent:#9c3d6b; --sw-ink:#74264d; }
.sw-azure     { --sw-bg:#eef3f7; --sw-accent:#1f6b8c; --sw-ink:#144a63; }
.sw-nightwood { --sw-bg:#121a15; --sw-accent:#6cc292; --sw-ink:#8fd9ae; }
.sw-midnight  { --sw-bg:#10131f; --sw-accent:#8f9df5; --sw-ink:#a7b2ff; }
.sw-ember     { --sw-bg:#191311; --sw-accent:#e0865a; --sw-ink:#f0a978; }

.artlevel { display: flex; gap: 6px; margin-top: 12px; }
.artlevel button {
    flex: 1; padding: 7px 4px; font-size: .82rem; cursor: pointer;
    border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--card-2); color: var(--ink);
}
.artlevel button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-tint); font-weight: 600; }

/* ---------- layout: sidebar + content ---------- */
.layout { display: flex; padding-top: var(--header-h); min-height: 100vh; }
.sidebar {
    position: fixed; top: var(--header-h); bottom: 0; left: 0;
    width: var(--sidebar-w);
    background: var(--card); border-right: 1px solid var(--line);
    overflow-y: auto; padding: 14px 0 200px; z-index: 60;
}
/* a fern growing up the sidebar behind the menu */
.sidebar::after {
    content: ""; position: absolute; left: 4px; bottom: 0; width: 130px; height: 320px;
    background-color: var(--art-ink); pointer-events: none;
    -webkit-mask: var(--m-fern); mask: var(--m-fern);
    -webkit-mask-position: left bottom; mask-position: left bottom;
    opacity: var(--art-op);
}
.side-title {
    font-family: var(--font-display); font-weight: 700; font-size: 1.05rem;
    padding: 4px 18px 10px; color: var(--accent-dark);
}
.side-section {
    padding: 12px 18px 4px; font-size: .76rem; text-transform: uppercase;
    letter-spacing: .08em; color: var(--muted);
    display: flex; align-items: center; gap: 6px;
}
.side-section::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.side-link {
    position: relative; display: block; padding: 8px 18px 8px 30px;
    color: var(--ink); text-decoration: none;
    border-left: 3px solid transparent;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: background .14s ease;
}
.side-link::before {                              /* engraved leaf bullet */
    content: ""; position: absolute; left: 12px; top: 50%;
    width: 12px; height: 12px; margin-top: -6px;
    background-color: var(--accent); opacity: 0;
    -webkit-mask: var(--m-leaf); mask: var(--m-leaf);
    transition: opacity .14s ease;
}
.side-link:hover, .side-link.active { background: var(--accent-tint); border-left-color: var(--accent); }
.side-link:hover::before, .side-link.active::before { opacity: .95; }
.content { flex: 1; padding: 18px 22px 60px; max-width: 1500px; position: relative; }
body.with-sidebar .content { margin-left: var(--sidebar-w); }
body.no-sidebar .content { margin: 0 auto; }

/* ---------- generic ---------- */
h1, h2, h3 { font-family: var(--font-display); }
h1 {
    font-size: 1.7rem; margin: 10px 0 16px; font-weight: 600;
    letter-spacing: .01em; display: flex; align-items: center; gap: 12px;
}
h1::after {                                       /* vine tail after the title */
    content: ""; flex: 1; height: 20px; max-width: 260px;
    background: var(--art-ink); opacity: var(--art-op-strong);
    -webkit-mask: var(--m-vine); mask: var(--m-vine);
    -webkit-mask-size: 100% 100%; mask-size: 100% 100%;
}
h2 { font-size: 1.22rem; font-weight: 600; }
h3 { font-size: 1.05rem; margin: 16px 0 6px; color: var(--accent-dark); font-weight: 600; }
h4 { margin: 8px 0 4px; color: var(--muted); font-weight: 600; }
a { color: var(--accent-dark); }
.hint { color: var(--muted); font-size: .88rem; }
.unknown { color: var(--muted); font-style: italic; }
.center { text-align: center; display: block; margin-left: auto; margin-right: auto; }

/* ------------------------------- buttons -------------------------------
   Buttons are little engraved plates: a hairline border, a warm plate fill
   and, on the primary one, a leaf pressed into the left edge.            */
.btn {
    position: relative; display: inline-flex; align-items: center; gap: 7px;
    border: 1px solid var(--line); background: var(--card); color: var(--ink);
    border-radius: var(--radius-sm); padding: 8px 15px; cursor: pointer;
    text-decoration: none; font-size: .95rem; font-family: inherit;
    transition: border-color .15s ease, background .15s ease,
                transform .12s ease, box-shadow .15s ease;
}
.btn:hover { border-color: var(--accent); box-shadow: 0 2px 10px rgba(var(--shadow), .12); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn.primary {
    background: linear-gradient(180deg, var(--accent), var(--accent-dark));
    border-color: var(--accent-dark); color: var(--on-accent);
    padding-left: 32px; font-weight: 600;
    box-shadow: 0 1px 0 rgba(255,255,255,.22) inset, 0 2px 8px rgba(var(--shadow), .18);
}
.btn.primary::before {
    content: ""; position: absolute; left: 10px; top: 50%;
    width: 15px; height: 15px; margin-top: -7px;
    background-color: var(--on-accent);
    -webkit-mask: var(--m-leaf); mask: var(--m-leaf);
    opacity: .85;
}
.btn.primary:hover { background: linear-gradient(180deg, var(--accent-dark), var(--accent-dark)); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 55%, transparent); }
.btn.warn { color: var(--warn); }
.btn.small { padding: 5px 11px; font-size: .85rem; }
.btn.small.primary { padding-left: 27px; }
.btn.small.primary::before { left: 8px; width: 13px; height: 13px; margin-top: -6px; }
.btn.icon { padding: 2px 8px; border: none; background: none; cursor: pointer; color: var(--muted); }
.btn.icon:hover { color: var(--danger); box-shadow: none; transform: none; }
.btn.active { outline: 2px solid var(--accent); outline-offset: 1px; }
.btnrow { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }

/* ------------------------------- forms --------------------------------- */
.stack label { display: block; margin-bottom: 12px; font-size: .9rem; color: var(--muted); }
.stack input, .stack select, .stack textarea {
    display: block; width: 100%; margin-top: 5px;
    padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
    font-size: 16px;              /* prevents zoom-on-focus on iPhone */
    font-family: inherit;
    background: var(--card-2); color: var(--ink);
    transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
.stack input:focus, .stack select:focus, .stack textarea:focus {
    outline: none; border-color: var(--accent); background: var(--card);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.stack input::placeholder, .stack textarea::placeholder { color: var(--muted); }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }

/* selection highlight follows the theme */
::selection { background: color-mix(in srgb, var(--accent) 30%, transparent); color: var(--ink); }

/* ------------------------------- cards ---------------------------------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(268px, 1fr)); gap: 16px; margin-bottom: 22px; }
.card {
    position: relative; overflow: hidden;
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 16px 18px;
    box-shadow: 0 1px 3px rgba(var(--shadow), .07);
    transition: border-color .16s ease, box-shadow .16s ease, transform .16s ease;
}
.card::before {                                   /* corner branch flourish */
    content: ""; position: absolute; right: -18px; top: -18px;
    width: 128px; height: 128px; pointer-events: none;
    background-color: var(--art-ink);
    -webkit-mask: var(--m-corner); mask: var(--m-corner);
    transform: scaleX(-1);
    opacity: var(--art-op);
}
.card:hover { border-color: var(--accent); box-shadow: 0 6px 20px rgba(var(--shadow), .13); transform: translateY(-2px); }
/* search results open on click: the tile carries the affordance the hover lift
   already implied, and is reachable from the keyboard like the button it now is */
.card.opens { cursor: pointer; }
.card.opens:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.card h3 { margin-top: 0; }
.card > * { position: relative; }

.panelbox {
    position: relative; overflow: hidden;
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 18px 20px; margin-bottom: 18px; max-width: 780px;
    box-shadow: 0 1px 3px rgba(var(--shadow), .07);
}
.panelbox::before {                               /* sprig in the top corner */
    content: ""; position: absolute; right: 12px; top: 10px;
    width: 46px; height: 46px; pointer-events: none;
    background-color: var(--art-ink);
    -webkit-mask: var(--m-sprig); mask: var(--m-sprig);
    opacity: var(--art-op-strong);
}
.panelbox > * { position: relative; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 9px 6px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-weight: 600; font-size: .84rem; text-transform: uppercase; letter-spacing: .04em; }
.table tbody tr:hover { background: var(--accent-tint); }

/* -------------------- sign-in / register: illustrated plate -------------- */
.authbox {
    position: relative; max-width: 420px; margin: 6vh auto 4vh;
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); padding: 56px 28px 26px;
    box-shadow: 0 12px 40px rgba(var(--shadow), .14);
    overflow: hidden;
}
.authbox::before {                                /* leafy arch over the form */
    content: ""; position: absolute; left: 0; right: 0; top: 0; height: 92px;
    background-color: var(--art-ink); pointer-events: none;
    -webkit-mask: var(--m-arch); mask: var(--m-arch);
    opacity: var(--art-op-strong);
}
.authbox::after {                                 /* roots along the bottom */
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 66px;
    background-color: var(--art-ink); pointer-events: none;
    -webkit-mask: var(--m-roots); mask: var(--m-roots);
    -webkit-mask-size: 140% 100%; mask-size: 140% 100%;
    opacity: var(--art-op);
}
.authbox > *, .authbox form { position: relative; z-index: 1; }
.authbox h1 { justify-content: center; font-size: 1.55rem; }
.authbox h1::after { display: none; }
.authbox-wide { max-width: 560px; }
.invite-family { font-weight: 700; font-size: 1.05rem; font-family: var(--font-display); }

/* the emblem crowning the sign-in plate */
.authmark { display: block; width: 74px; height: 74px; margin: -14px auto 6px;
            background: var(--accent-dark); opacity: .9;
            -webkit-mask: var(--m-emblem); mask: var(--m-emblem); }

/* ------------------------------- chips ---------------------------------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.chip {
    display: inline-flex; align-items: center; gap: 5px;
    background: var(--accent-tint); color: var(--accent-dark);
    border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
    border-radius: 999px; padding: 3px 11px; font-size: .8rem;
}
.chip::before {
    content: ""; width: 11px; height: 11px; flex: none;
    background: currentColor; opacity: .7;
    -webkit-mask: var(--m-leaf); mask: var(--m-leaf);
}
.chip.legend {
    background: color-mix(in srgb, var(--gold) 18%, transparent);
    color: color-mix(in srgb, var(--gold) 78%, var(--ink));
    border-color: color-mix(in srgb, var(--gold) 40%, transparent);
}
.pill { background: var(--danger); color: #fff; border-radius: 999px; padding: 0 7px; font-size: .75rem; }

/* ------------------------- avatars in leaf wreaths ----------------------- */
.avatar { border-radius: 50%; object-fit: cover; background: var(--bg-2); }
.avatar.small { width: 34px; height: 34px; }
/* the round picture before a name in a list; .noimg keeps the names aligned when
   a person has none */
.avatar.tiny { width: 28px; height: 28px; vertical-align: middle; margin-right: 8px; border: 1px solid var(--line); }
.avatar.tiny.noimg { display: inline-block; background: transparent; border-color: transparent; }
.photorow.tight { gap: 10px; margin-bottom: 6px; }
.photorow.tight h3 { margin: 0; }
.avatar.big { width: 118px; height: 118px; border: 2px solid var(--line); }
/* wrap an .avatar.big in <span class="framed"> for the laurel frame */
.framed { position: relative; display: inline-block; line-height: 0; }
.framed::before {
    content: ""; position: absolute; left: 50%; top: 50%;
    width: 168px; height: 168px; margin: -84px 0 0 -84px; pointer-events: none;
    background-color: var(--art-ink);
    -webkit-mask: var(--m-wreath); mask: var(--m-wreath);
    opacity: var(--art-op-strong);
}
.photorow { display: flex; align-items: center; gap: 22px; margin-bottom: 14px; flex-wrap: wrap; }
.profilegrid { max-width: 780px; }
.relline {
    background: var(--accent-tint); border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent); padding: 9px 13px;
}
.relpath p { font-size: .85rem; color: var(--muted); }
.userlink { margin: 8px 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.toast {
    position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
    background: var(--bar-2); color: var(--on-bar);
    border: 1px solid color-mix(in srgb, var(--on-bar) 22%, transparent);
    border-radius: var(--radius-sm);
    padding: 11px 22px; z-index: 300; box-shadow: 0 6px 24px rgba(var(--shadow), .3);
}
.toast.error { background: var(--danger); }

/* ---------- family pages ---------- */
.familyhead { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
/* the family header is already a flex row: no growing vine tail after the title */
.familyhead h1 { display: block; }
.familyhead h1::after { display: none; }
/* read-only notice for a non-member the family lets in (js/app.js showGuestBanner):
   a full-width strip between the title and the tab strip, in the accent tint so
   it reads as a note from the family rather than an error */
.guestbanner {
    flex-basis: 100%; display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap;
    padding: 10px 14px; margin: 2px 0 6px;
    background: var(--accent-tint); border: 1px solid var(--line);
    border-left: 4px solid var(--accent); border-radius: var(--radius-sm); color: var(--ink);
}
.guestbanner .art-leaf { width: 1.4em; height: 1.4em; margin-top: 2px; }
.guestbanner p { margin: 0; flex: 1 1 260px; }
.guestbanner p + p { flex-basis: 100%; }
.guestbanner .btn { margin-left: 6px; vertical-align: baseline; }
/* the login link that replaces the user menu for an anonymous reader */
.loginlink { text-decoration: none; white-space: nowrap; }
/* both set their own display, so the hidden attribute needs backing up */
.guestbanner[hidden], .loginlink[hidden] { display: none; }
/* an anonymous reader of a public tree (js/app.js anonymousShell): the access
   menu lists MY families and the hamburger only opens it, so neither is drawn */
body.anonymous .sidebar, body.anonymous .hamburger { display: none; }
.tabs { display: flex; gap: 4px; margin-bottom: 8px; border-bottom: 1px solid var(--line); }
.tabs a {
    text-decoration: none; color: var(--muted); padding: 8px 15px;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0; border: 1px solid transparent;
    border-bottom: none; margin-bottom: -1px;
}
.tabs a:hover { color: var(--accent-dark); background: var(--accent-tint); }
.tabs a.active {
    background: var(--card); color: var(--accent-dark);
    border-color: var(--line); font-weight: 600;
}

.toolbar { display: flex; align-items: center; gap: 12px; margin: 10px 0; flex-wrap: wrap; }
.toolbar input[type=search] {
    padding: 9px 13px; border: 1px solid var(--line); border-radius: var(--radius-sm);
    min-width: 220px; font-size: 16px; background: var(--card); color: var(--ink);
}
.toolbar input[type=search]:focus { outline: none; border-color: var(--accent); }
/* which way up the generations run - a label and its select on one line, so it sits
   in the toolbar row rather than stacking the way a bare <label> would */
.orientpick { display: inline-flex; align-items: center; gap: 7px;
    color: var(--muted); font-size: .92rem; white-space: nowrap; }
.orientpick select {
    padding: 7px 9px; border: 1px solid var(--line); border-radius: var(--radius-sm);
    background: var(--card); color: var(--ink); font-size: .95rem;
}
.orientpick select:focus { outline: none; border-color: var(--accent); }

.treelayout { display: flex; gap: 14px; position: relative; }
.treewrap {
    flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    height: calc(100vh - var(--header-h) - 190px); min-height: 360px; overflow: hidden; position: relative;
}
/* the canvas itself gets a faint grove so an empty tree never looks broken */
.treewrap::before {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 46%;
    background-color: var(--art-ink); pointer-events: none;
    -webkit-mask: var(--m-grove); mask: var(--m-grove);
    opacity: calc(var(--art-op) * .6);
}
.treesvg { width: 100%; height: 100%; touch-action: none; cursor: grab; position: relative; }
.treesvg:active { cursor: grabbing; }

/* tree nodes */
.personnode rect { fill: var(--unknown); stroke: var(--unknown-line); stroke-width: 1.2; cursor: pointer; }
.personnode.g-male rect { fill: var(--male); stroke: var(--male-line); }
.personnode.g-female rect { fill: var(--female); stroke: var(--female-line); }
.personnode.g-other rect { fill: var(--other); stroke: var(--other-line); }
.personnode:hover rect { stroke-width: 2.4; }
/* a person's picture in the tree box: clipped round, with a hairline ring */
.pthumb { pointer-events: none; }
.pring { fill: none; stroke: rgba(var(--shadow), .35); stroke-width: 1; pointer-events: none; }
.pname { font-size: 14px; font-weight: 600; fill: var(--ink); pointer-events: none; font-family: var(--font-display); }
.pyears { font-size: 11px; fill: var(--muted); pointer-events: none; }
.badge.verified { fill: var(--ok); font-size: 11px; }
.badge.disputed { fill: var(--warn); font-size: 11px; }
.edge { stroke: var(--unknown-line); stroke-width: 1.4; fill: none; }
.edge.spouse { stroke: var(--gold); }
.edge.spouse.ended { stroke-dasharray: 4 4; }
.edge.parent.step, .edge.parent.adoptive, .edge.parent.foster { stroke-dasharray: 5 4; }

/* person popup: one modal view shared by the tree, the members list and every
   "show this relative" link. The old right-hand drawer is gone. */
.personmodal .personbox { max-width: 940px; padding: 16px 20px 18px; }
/* the popup reads in two columns: who the person was on the left, how they
   connect on the right. The edit form uses the same split, so creating and
   reading a person feel like one screen. */
.personcols { display: grid; grid-template-columns: 1fr 1fr; gap: 0 26px; align-items: start; }
.personcols > .pcol { min-width: 0; }
.personcols > .pcol + .pcol { border-left: 1px solid var(--line-soft); padding-left: 26px; }
.personcols h3:first-child, .personcols h4:first-child { margin-top: 0; }
@media (max-width: 820px) {
    .personcols { grid-template-columns: 1fr; }
    .personcols > .pcol + .pcol { border-left: 0; padding-left: 0;
        border-top: 1px solid var(--line-soft); padding-top: 8px; margin-top: 8px; }
}
/* Title, close button and action bar ride together at the very top of the popup.
   top is 0, NOT var(--header-h): .modalback is the scrolling ancestor these stick
   to, and its padding-top already clears the fixed site header. Offsetting by the
   header a second time (which is what the old right-hand drawer needed, since it
   scrolled with the page) parked this block about a third of the way down the
   screen, floating over the person's details. */
.personbox .panelstick { position: sticky; top: 0; z-index: 2;
    background: var(--card); padding-top: 4px; margin: -4px 0 10px;
    border-bottom: 1px solid var(--line-soft); }
.personbox .panelstick .actionbar { padding-bottom: 10px; margin-bottom: 0; }
.panelhead { display: flex; justify-content: space-between; align-items: center; }
.panelhead h2 { margin: 4px 0; }
/* the picture at the top of the person popup */
.personphoto { text-align: center; margin: 0 0 12px; }
.pphoto {
    width: 168px; height: 168px; object-fit: cover; border-radius: 16px;
    border: 1px solid var(--line); background: var(--card-2);
    box-shadow: 0 4px 16px rgba(var(--shadow), .18);
    transition: transform .15s ease, box-shadow .15s ease;
}
.pphoto-link { display: inline-block; }
.pphoto-link:hover .pphoto { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(var(--shadow), .24); }
.photo-actions { justify-content: center; margin-top: 8px; }
.photo-hint { margin: 4px 0 0; }
.facts th { text-align: left; color: var(--muted); font-weight: 500; padding: 3px 12px 3px 0; vertical-align: top; white-space: nowrap; }
.facts td { padding: 3px 0; }
.placelist, .rellist, .verifylist { margin: 4px 0; padding-left: 20px; }
.rellist a { color: var(--accent-dark); }
.removerel { color: var(--danger); text-decoration: none; margin-left: 6px; }
.story {
    position: relative; border-left: 3px solid var(--line);
    padding-left: 14px; margin: 12px 0;
}
.story::before {
    content: ""; position: absolute; left: -9px; top: 0;
    width: 15px; height: 15px; background: var(--accent); opacity: .85;
    -webkit-mask: var(--m-leaf); mask: var(--m-leaf);
}
.story p { margin: 6px 0; white-space: pre-wrap; }
.inlineform { border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 12px; margin-top: 8px; background: var(--card-2); }
.listrow { display: flex; gap: 6px; margin-bottom: 6px; align-items: center; }
.listrow input {
    flex: 1; padding: 8px 9px; border: 1px solid var(--line); border-radius: 8px;
    font-size: 16px; min-width: 0; background: var(--card); color: var(--ink);
}
.placerow .from, .placerow .to { flex: 0 0 118px; }
.payload { background: var(--bg-2); border-radius: 8px; padding: 10px; overflow-x: auto; font-size: .8rem; }
.change .changehead { margin-bottom: 4px; }

/* ---------- message center: chats | thread | correspondent profile ---------- */
.msgcenter { display: grid; grid-template-columns: 296px 1fr 306px; gap: 14px; align-items: start; }
.mc-list, .mc-thread, .mc-profile { max-width: none; margin-bottom: 0; }
.mc-list { max-height: calc(100vh - var(--header-h) - 150px); overflow-y: auto; }
.mc-list .conv-item {
    display: flex; align-items: center; gap: 10px; padding: 9px 8px;
    border-radius: var(--radius-sm); text-decoration: none; color: var(--ink);
}
.mc-list .conv-item:hover { background: var(--accent-tint); }
.mc-msgs {
    height: calc(100vh - var(--header-h) - 300px); min-height: 260px;
    overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 6px 2px;
}
.mc-profile { position: sticky; top: calc(var(--header-h) + 12px); }

/* chat messages: OWN on the left, correspondent on the right */
.chat-msg { display: flex; flex-direction: column; max-width: 78%; }
.chat-msg.mine { align-self: flex-start; align-items: flex-start; }
.chat-msg.theirs { align-self: flex-end; align-items: flex-end; }
.bubble { padding: 9px 13px; border-radius: 15px; white-space: pre-wrap; word-break: break-word; }
.chat-msg.mine .bubble { background: var(--accent); color: var(--on-accent); border-bottom-left-radius: 4px; }
.chat-msg.theirs .bubble { background: var(--bg-2); color: var(--ink); border-bottom-right-radius: 4px; }
.stamp { font-size: .7rem; color: var(--muted); margin-top: 2px; }

.chat-form { display: flex; gap: 8px; margin-top: 10px; }
.chat-form input {
    flex: 1; padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px;
    font-size: 16px; min-width: 0; background: var(--card); color: var(--ink);
}
.chat-form input:focus { outline: none; border-color: var(--accent); }

/* ---------- chat boxes docked bottom-right ---------- */
.chatdock { position: fixed; right: 14px; bottom: 0; z-index: 150; display: flex; align-items: flex-end; gap: 10px; }
.chatbox {
    width: 306px; background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius) var(--radius) 0 0; box-shadow: 0 -4px 24px rgba(var(--shadow), .22);
    display: flex; flex-direction: column; overflow: hidden;
}
.chat-head {
    display: flex; align-items: center; gap: 8px;
    background: linear-gradient(180deg, var(--bar-1), var(--bar-2));
    color: var(--on-bar); padding: 9px 11px; cursor: pointer;
}
.chat-name { color: inherit; text-decoration: none; flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-head button { background: none; border: none; color: inherit; opacity: .78; font-size: 1rem; cursor: pointer; }
.chat-head button:hover { opacity: 1; }
.chat-msgs { height: 262px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 10px; }
.chatbox .chat-form { padding: 8px; margin: 0; border-top: 1px solid var(--line); }
.chatbox.minimized .chat-msgs, .chatbox.minimized .chat-form { display: none; }

/* ---------- responsive: tablet ---------- */
@media (max-width: 1200px) {
    .msgcenter { grid-template-columns: 250px 1fr; }
    .mc-profile { display: none; }
    .msgcenter.show-profile .mc-profile { display: block; grid-column: 1 / -1; position: static; }
}
@media (max-width: 1024px) {
    .placerow { flex-wrap: wrap; }
    .placerow .place, .placerow .note { flex: 1 1 100%; }
    .brandname, .brandsub { display: none; }
    .themegrid { grid-template-columns: repeat(2, 1fr); }
}

/* ------------------- public pages: home, how it works, about ---------------
   Readable without an account. They borrow the plate/card/ornament language of
   the app and add only what a landing page needs: a hero, three pillars, the
   numbered steps, and a prose column for the two text pages.              */
.pubnav { display: flex; align-items: center; gap: 10px; margin-right: 6px; }
.pubnav .textlink {
    color: var(--on-bar); text-decoration: none; font-weight: 600; font-size: .95rem;
    padding: 6px 4px; border-bottom: 2px solid transparent; white-space: nowrap;
}
.pubnav .textlink:hover { border-bottom-color: var(--gold); }
.pubnav .tbbtn { text-decoration: none; font-size: .95rem; white-space: nowrap; }
.pubnav .pub-register, .pubnav .pub-mytree { text-decoration: none; white-space: nowrap; }
.pubnav [hidden] { display: none; }

.btn.big { padding: 12px 22px; font-size: 1.05rem; }
.btn.big.primary { padding-left: 40px; }
.btn.big.primary::before { left: 14px; width: 17px; height: 17px; margin-top: -8px; }
.btn[hidden] { display: none; }

.landing { max-width: 1040px; margin: 0 auto; }
.landing section { margin: 0 0 44px; }
.hero {
    position: relative; text-align: center; padding: 34px 20px 26px; overflow: hidden;
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(var(--shadow), .12);
}
.hero::before {                                   /* leafy arch, as on the sign-in plate */
    content: ""; position: absolute; left: 0; right: 0; top: 0; height: 110px;
    background-color: var(--art-ink); pointer-events: none;
    -webkit-mask: var(--m-arch); mask: var(--m-arch);
    opacity: var(--art-op-strong);
}
.hero::after {                                    /* roots along the bottom */
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 74px;
    background-color: var(--art-ink); pointer-events: none;
    -webkit-mask: var(--m-roots); mask: var(--m-roots);
    -webkit-mask-size: 120% 100%; mask-size: 120% 100%;
    opacity: var(--art-op);
}
.hero > * { position: relative; z-index: 1; }
.hero-mark { display: block; width: 92px; height: 92px; margin: 8px auto 4px; background: var(--accent-dark); opacity: .9; }
.hero-wordmark {
    margin: 0 0 4px; font-family: var(--font-display); font-weight: 700;
    font-size: 1.35rem; letter-spacing: .02em; color: var(--accent-dark);
}
.hero-wordmark .hero-sub { display: block; font-family: var(--font-body); font-weight: 500; font-size: .9rem; color: var(--muted); letter-spacing: .06em; margin: 2px 0 14px; }
.kicker {
    margin: 0 0 6px; color: var(--accent-dark); font-weight: 700; letter-spacing: .12em;
    text-transform: uppercase; font-size: .8rem;
}
.hero-title, .pubhead h1 {
    display: block; font-size: clamp(1.7rem, 4vw, 2.6rem); margin: 4px 0 12px; line-height: 1.15;
}
.hero-title::after, .pubhead h1::after { display: none; }
.lead { font-size: 1.12rem; line-height: 1.6; color: var(--ink-soft); max-width: 700px; margin: 0 auto 18px; }
.lead.small { font-size: 1rem; }
.centered { text-align: center; }
h2.centered { display: block; margin-bottom: 18px; font-size: 1.45rem; }
.hero-cta { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 10px; padding-bottom: 20px; }

.cards.three { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.cards.two { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.card.pillar { text-align: center; padding: 26px 22px 22px; }
.card.pillar h3 { font-size: 1.15rem; margin: 10px 0 8px; }
.card.pillar p, .principles .card p { color: var(--ink-soft); line-height: 1.55; margin: 0; }
.pillar-icon { display: block; margin: 0 auto; width: 64px; height: 64px; background: var(--accent-dark); opacity: .85; }
.pillar-icon.small { width: 30px; height: 30px; margin: 0 0 6px; }
.principles .card { padding: 18px 20px; }
.principles .card h3 { margin: 0 0 6px; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 18px; }
.step { position: relative; padding: 18px 20px 18px 66px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.step h3 { margin: 0 0 6px; font-size: 1.1rem; }
.step p { margin: 0; color: var(--ink-soft); line-height: 1.55; }
.stepno {
    position: absolute; left: 18px; top: 18px; width: 34px; height: 34px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: linear-gradient(180deg, var(--accent), var(--accent-dark)); color: var(--on-accent);
    font-family: var(--font-display); font-weight: 700; font-size: 1.05rem;
    box-shadow: 0 1px 0 rgba(255,255,255,.22) inset, 0 2px 8px rgba(var(--shadow), .18);
}

.treecard { display: block; color: inherit; text-decoration: none; }
.treecard .photorow { gap: 12px; margin-bottom: 8px; }
.treecard .avatar { width: 52px; height: 52px; border-radius: 12px; }
.treecard h3 { margin: 0; }
.treecard .btn { margin-top: 6px; }

.closing { text-align: center; padding: 10px 16px 0; }
.closing-art { display: block; margin: 0 auto 6px; width: 150px; height: 158px; opacity: var(--art-op-strong); }
.closing .lead { margin-bottom: 14px; }

/* the two text pages */
.pubpage { max-width: 860px; margin: 0 auto; }
.pubhead { text-align: center; margin-bottom: 30px; }
.pubmark { display: block; margin: 10px auto 2px; width: 64px; height: 64px; background: var(--accent-dark); opacity: .9; }
.pubpage section { max-width: 720px; margin: 0 auto 30px; }
.pubpage .prose p { line-height: 1.65; font-size: 1.04rem; color: var(--ink-soft); margin: 0; }
.cards.principles { grid-template-columns: repeat(2, 1fr); }
.pubpage .closing { max-width: none; }            /* the buttons sit side by side */
.pubpage h2 { font-size: 1.32rem; margin: 0 0 8px; }
.tour { list-style: none; margin: 0 auto 30px; padding: 0; max-width: 760px; }
.tourstep { position: relative; display: flex; gap: 18px; align-items: flex-start; padding: 16px 0 18px 0; border-bottom: 1px solid var(--line); }
.tourstep:last-child { border-bottom: none; }
.tourstep .stepno { position: static; flex: none; margin-top: 2px; }
.tourstep h2 { margin: 2px 0 6px; }
.tourstep p { margin: 0; line-height: 1.6; color: var(--ink-soft); }

/* site footer: below the layout, above the grove drawn along the fold */
.sitefoot {
    position: relative; z-index: 1;
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 8px 18px;
    padding: 14px 22px 40px; color: var(--muted); font-size: .88rem;
}
body.with-sidebar .sitefoot { margin-left: var(--sidebar-w); }
body.anonymous .sitefoot { margin-left: 0; }
.sitefoot .art-leaf { width: 1.1em; height: 1.1em; }
.sitefoot-domain { color: var(--accent-dark); text-decoration: none; font-weight: 600; }
.sitefoot-nav { display: flex; gap: 14px; }
/* the name card on the About page */
.sitecard { margin-top: 12px !important; padding: 10px 14px; background: var(--accent-tint); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.sitecard .art-leaf { width: 1em; height: 1em; margin-right: 6px; }
.sitecard a { font-weight: 600; }
.sitefoot-nav a { color: var(--accent-dark); text-decoration: none; font-weight: 600; }
.sitefoot-nav a:hover { text-decoration: underline; }

/* ---------- responsive: phone ---------- */
@media (max-width: 760px) {
    :root { --header-h: 16vh; }
    .hamburger { display: block; }
    .sidebar { transform: translateX(-100%); transition: transform .18s ease; box-shadow: 6px 0 24px rgba(var(--shadow), .2); }
    .sidebar.open { transform: translateX(0); }
    body.with-sidebar .content { margin-left: 0; }
    .content { padding: 12px 12px 50px; }
    .topbar { padding: 0 10px; }
    .fambrandname { display: none; }
    .userbtn .username { display: none; }
    .treewrap { height: calc(100vh - var(--header-h) - 210px); min-height: 300px; }
    .cols2 { grid-template-columns: 1fr; }
    .zoomhint { display: none; }
    .familyhead { gap: 8px; }
    h1 { font-size: 1.3rem; }
    h1::after { max-width: 90px; }
    .btn, .tabs a, .side-link { min-height: 42px; display: inline-flex; align-items: center; }  /* touch targets */
    .side-link { display: flex; }
    .msgcenter { grid-template-columns: 1fr; }
    .mc-list { max-height: 30vh; }
    .mc-msgs { height: 40vh; min-height: 200px; }
    .chatdock { right: 0; left: 0; justify-content: center; }
    .chatbox { width: 100%; border-radius: 0; }
    .chat-msgs { height: 40vh; }
    .dropdown { position: fixed; left: 8px; right: 8px; top: var(--header-h); min-width: 0; }
    .authbox { margin: 3vh auto; padding: 48px 18px 22px; }
    /* public pages: the text links live in the footer too, so the header keeps
       only the login; the hero and the tour tighten up */
    .pubnav .textlink, .pubnav .pub-register { display: none; }
    .hero { padding: 26px 14px 18px; }
    .hero-cta .btn { flex: 1 1 100%; justify-content: center; }
    .tourstep { gap: 12px; }
    .cards.principles { grid-template-columns: 1fr; }
    body.with-sidebar .sitefoot { margin-left: 0; }
    body::after { height: 22vh; opacity: calc(var(--art-op) * .5); }
    .sidebar::after { opacity: calc(var(--art-op) * .7); }
}

/* ---------- large desktop ---------- */
@media (min-width: 1600px) {
    .msgcenter { grid-template-columns: 320px 1fr 340px; }
}

/* ---------- phase 3: administration, merge, discussions ---------- */
.panelbox.wide { max-width: 1020px; }
.mergedetail .pair { margin: 10px 0; }
.smalltable th, .smalltable td { font-size: .85rem; padding: 5px 6px; }
.smalltabs { margin-bottom: 10px; }
.smalltabs a { padding: 5px 10px; font-size: .9rem; }
.boardicon { font-size: 1.3rem; width: 34px; text-align: center; }
.chat-msg .author { font-size: .75rem; color: var(--accent-dark); font-weight: 600; margin-bottom: 1px; }
.badge.bridged { fill: var(--gold); font-size: 12px; }
#boardSearch {
    width: 100%; padding: 9px 11px; border: 1px solid var(--line);
    border-radius: var(--radius-sm); font-size: 16px; margin: 6px 0;
    background: var(--card); color: var(--ink);
}

/* ---------- v3.1: registration validation + person data ---------- */
.fielderr { display: block; color: var(--danger); font-size: .82rem; margin: 2px 0 6px; }
.regperson {
    border: 1px dashed var(--line); border-radius: var(--radius-sm);
    padding: 12px 15px; margin: 12px 0; background: var(--card-2);
}
.regperson summary { cursor: pointer; color: var(--accent-dark); font-weight: 600; }

/* per-contact visibility selector */
.contactrow .ckind { flex: 0 0 120px; }
.contactrow .cvis { flex: 0 0 170px; }
.contactrow select {
    padding: 8px 9px; border: 1px solid var(--line); border-radius: 7px;
    font-size: .9rem; min-width: 0; background: var(--card); color: var(--ink);
}
@media (max-width: 760px) { .contactrow { flex-wrap: wrap; } .contactrow .ckind, .contactrow .cvis { flex: 1 1 45%; } }

/* ---------- drag & drop relations in the tree ---------- */
.personnode.dragging rect { opacity: .55; stroke-dasharray: 4 3; }
.personnode.droptarget rect { stroke: var(--accent); stroke-width: 3.5; filter: drop-shadow(0 0 6px color-mix(in srgb, var(--accent) 55%, transparent)); }
.draglink { stroke: var(--accent); stroke-width: 2.5; stroke-dasharray: 6 4; pointer-events: none; }
/* step / adoptive / foster parent links are highlighted */
.edge.parent.step, .edge.parent.adoptive, .edge.parent.foster {
    stroke: var(--warn); stroke-width: 2.2; stroke-dasharray: 7 4;
}

/* ---------- v3.2: illustrated hero used on the sign-in and landing pages -- */
.hero {
    position: relative; text-align: center; padding: 26px 18px 150px;
    margin-bottom: 8px;
}
.hero::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 150px;
    background-color: var(--art-ink); pointer-events: none;
    -webkit-mask: var(--m-grove); mask: var(--m-grove);
    opacity: var(--art-op-strong);
}
.hero h1 { justify-content: center; font-size: clamp(1.6rem, 4.6vw, 2.5rem); margin-bottom: 6px; }
.hero h1::after { display: none; }
.hero p { color: var(--muted); max-width: 540px; margin: 0 auto; }

/* skip link for keyboard users */
.skip {
    position: absolute; left: -9999px; top: 0; z-index: 400;
    background: var(--bar-2); color: var(--on-bar); padding: 10px 16px; border-radius: 0 0 8px 0;
}
.skip:focus { left: 0; }

/* thin, theme-coloured scrollbars */
* { scrollbar-color: color-mix(in srgb, var(--accent) 55%, transparent) transparent; scrollbar-width: thin; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* printing: drop every ornament, keep the content */
@media print {
    body::before, body::after, .topbar, .sidebar, .chatdock, .toast { display: none !important; }
    body.with-sidebar .content { margin: 0; }
    .layout { padding-top: 0; }
    .card::before, .panelbox::before, .authbox::before, .authbox::after, h1::after { display: none; }
}

/* ---------- family home page: recently added / recent births & deaths (TOL-6) ---------- */
.homegrid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.homecol h3 { margin: 0 0 6px; font-size: .95rem; }
.announce-list li { background: var(--accent-tint); border-radius: var(--radius-sm); padding: 3px 8px; margin: 3px 0; list-style: none; }
#homeDeaths.announce-list li { background: var(--card-2); }
@media (max-width: 760px) {
    .homegrid { grid-template-columns: 1fr; }
}

/* ---------- family members tab: person list + duplicate merge dialog ---------- */
.mergebar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.mergebar input[type="search"] { flex: 0 1 260px; }
#personsTable tr.picked > td { background: var(--accent-tint); }
#personsTable td:first-child { width: 28px; }

/* the dialog is a plain overlay - no browser modal, so nothing can block the page */
.modalback {
    position: fixed; inset: 0; z-index: 300; display: flex;
    align-items: flex-start; justify-content: center;
    /* the site header (16vh, fixed) paints over this overlay, so the box must
       start below it or its top - title, close button, action bar - is hidden */
    padding: calc(var(--header-h) + 14px) 12px 4vh;
    background: rgba(var(--shadow), .45); overflow: auto;
}
.modalback[hidden] { display: none; }
.modalbox {
    background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(var(--shadow), .3);
    padding: 18px 20px 16px; width: 100%; max-width: 880px;
}
.modalbox .panelhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.modalbox .panelhead h2 { margin: 0; }

.mergetable { table-layout: fixed; }
.mergetable th:first-child { width: 26%; }
.mergetable thead th { vertical-align: bottom; }
/* every value cell is a choice: clicking it marks that side as the one to keep */
.mergetable td.mcell {
    cursor: pointer; border: 2px solid transparent; border-radius: var(--radius-sm);
    word-break: break-word;
}
.mergetable td.mcell:hover { background: var(--card-2); }
.mergetable td.mcell.chosen { background: var(--accent-tint); border-color: var(--accent); font-weight: 600; }
/* rows where both records agree need no attention */
.mergetable td.mcell.same { color: var(--muted); }
.mergefoot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.mergefoot #mergeSwap { margin-right: auto; }

@media (max-width: 620px) {
    .mergetable th:first-child { width: 34%; }
    .modalbox { padding: 14px; }
}


/* ---------- person discussion: one chronological thread per person ---------- */
.discussion { border-top: 1px solid var(--line-soft); margin-top: 18px; padding-top: 4px; }
.commentlist { list-style: none; margin: 8px 0; padding: 0; }
.comment {
    background: var(--card-2); border-radius: var(--radius-sm);
    padding: 8px 12px; margin: 8px 0;
}
/* the newest entry sits at the bottom, so mark it rather than the first */
.comment:last-child { background: var(--accent-tint); }
.commentmeta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 3px; }
.commentmeta .hint { font-size: .82rem; }
.commentmeta .removerel { margin-left: auto; }
.commentbody { white-space: pre-wrap; word-break: break-word; }
.commentform textarea { width: 100%; resize: vertical; }
.commentform .btnrow { justify-content: flex-end; }
