body {
    margin: 0;
    font-family: Georgia, "Times New Roman", Times, serif;
    background-color: white;
}

div.content {
    width: 500px;
    text-align: center;
    background-color: white;
    vertical-align: middle;
    position: absolute;
    left: 0; right: 0;
    top: 0; bottom: 0;
    margin: auto;
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 30px;
    max-width: 100%;
    max-height: 100%;
    overflow: auto;
    height: fit-content;
}

div.content .subtitle {
    font-size: 16px;
    color: #555;
    margin: 0.5rem 0 1.5rem;
}

header.site {
    display: flex;
    align-items: center;
    padding: 1.25rem 2rem;
    border-bottom: 1px solid #ddd;
    gap: 1.5rem;
}

header.site .brand {
    /* Pushes everything else (nav, then the auth slot auth.js injects
       after it) to the right as one group with a consistent gap between
       them, regardless of how many things end up on the right -- plain
       justify-content: space-between only works cleanly for exactly two
       children. */
    margin-right: auto;
    font-size: 1.2rem;
    letter-spacing: 0.1em;
    text-decoration: none;
    color: #222;
    font-weight: bold;
}

header.site nav {
    display: flex;
    gap: 1.5rem;
    font-size: 18px;
}

header.site nav a {
    color: #555;
    text-decoration: none;
}

header.site nav a:hover {
    text-decoration: underline;
}

/* Injected by auth.js as the last child of header.site, after nav. */
.auth-slot {
    display: flex;
    align-items: center;
}

.auth-button {
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 1.05rem;
    padding: 0.65rem 1.3rem;
    border: 1px solid #ececec;
    border-radius: 8px;
    background: #fff;
    color: #555;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.auth-button:hover {
    border-color: #c15c6e;
    color: #c15c6e;
}

.auth-button-ghost {
    border: none;
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
    color: #999;
}

.auth-button-ghost:hover {
    color: #c15c6e;
    background: none;
}

.auth-user {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #555;
}

.auth-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
}

.page {
    max-width: 100%;
    margin: 2.5rem auto 1.5rem;
    padding: 0 1.5rem;
    text-align: center;
}

.page h1 {
    font-size: 1.6rem;
    font-weight: normal;
    letter-spacing: 0.02em;
    margin-bottom: 0.4rem;
    color: #222;
}

.page .subtitle {
    font-size: 14px;
    font-style: italic;
    color: #999;
}

/* Shared article/story page bits (Historie's story pages) -- the "back"
   link, the small uppercase meta label under the title, and the source
   footnote at the bottom. Used instead of each story page redefining the
   same three things slightly differently. */
.article-back {
    display: inline-block;
    font-size: 0.8rem;
    color: #999;
    text-decoration: none;
    margin-bottom: 1.5rem;
}
.article-back:hover { color: #c15c6e; }

.article-meta {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #c15c6e;
    margin-bottom: 2rem;
}

.article-source {
    font-size: 0.8rem;
    color: #999;
    margin-top: 2rem;
}
.article-source a { color: #999; }
.article-source a:hover { color: #c15c6e; }

/* Shared "index of tiles" pattern -- Historie's story grid and Galleri's
   folder grid used to be two independently-styled card treatments (one
   bordered/white, one flat/tinted); both now use this one flat, tinted,
   borderless card so the whole site reads as one system instead of each
   page having invented its own version. */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 0.75rem;
    text-align: left;
}

.tile {
    display: block;
    padding: 1.5rem 1.25rem;
    border: none;
    border-radius: 14px;
    background: #f8f5f4;
    color: #555;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    font-family: Georgia, "Times New Roman", Times, serif;
}
.tile:hover { background: #f9eef0; color: #c15c6e; }

.tile .tile-meta {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #c15c6e;
    margin-bottom: 0.5rem;
}
.tile h2 {
    font-size: 1.05rem;
    font-weight: normal;
    margin: 0 0 0.4rem;
    color: #222;
}
.tile p {
    font-size: 0.85rem;
    color: #777;
    margin: 0;
    line-height: 1.5;
}

/* Icon-centered variant of .tile, for folder navigation (Galleri). */
.tile-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 1.75rem 1rem 1.25rem;
    text-align: center;
    font-size: 0.95rem;
}
.tile-icon .tile-icon-badge {
    width: 3rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: #fff;
    font-size: 1.5rem;
    line-height: 1;
}
.tile-icon .tile-name {
    line-height: 1.35;
    word-break: break-word;
}

/* Small uppercase tracked breadcrumb (Galleri's folder navigation) --
   reads as UI chrome, matching the family tree page's own sidebar section
   headers, rather than body-copy navigation. */
.crumb-nav {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #bbb;
    margin: 0 0 2rem;
    text-align: left;
}
.crumb-nav button {
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    background: none;
    border: none;
    color: #bbb;
    cursor: pointer;
    padding: 0;
    text-decoration: none;
}
.crumb-nav button:hover { color: #c15c6e; }
.crumb-nav button:last-child {
    color: #555;
    cursor: default;
}
.crumb-nav button:last-child:hover { color: #555; }
.crumb-nav .crumb-sep { color: #e2dcda; margin: 0 0.5rem; }

.tree-layout {
    max-width: 1500px;
    margin: 0 auto 4rem;
    padding: 0 1.5rem;
    display: flex;
    gap: 1.25rem;
    align-items: stretch;
}

.group-sidebar {
    flex: 0 0 200px;
    height: 85vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding-right: 0.25rem;
}

.group-sidebar button {
    text-align: left;
    padding: 0.6rem 0.9rem;
    border: 1px solid #ececec;
    border-radius: 10px;
    background: #fff;
    color: #555;
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 0.85rem;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.group-sidebar button:hover {
    border-color: #c15c6e;
    color: #c15c6e;
}

.group-sidebar button.active {
    background: #c15c6e;
    border-color: #c15c6e;
    color: #fff;
}

.tree-viewport {
    flex: 1 1 auto;
    min-width: 0;
    height: 85vh;
    border: 1px solid #ececec;
    border-radius: 16px;
    background:
        radial-gradient(circle at 1px 1px, rgba(0, 0, 0, 0.05) 1px, transparent 0) 0 0 / 26px 26px,
        linear-gradient(160deg, #fbf9f8, #f5f2f1);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.03);
    overflow: hidden;
    position: relative;
    cursor: grab;
}

.tree-viewport.dragging {
    cursor: grabbing;
}

.tree-controls {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.tree-controls button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid #e6e6e6;
    background: #fff;
    color: #666;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.tree-controls button:hover {
    border-color: #c15c6e;
    color: #c15c6e;
    transform: translateY(-1px);
}

.tree-page {
    position: absolute;
    top: 0;
    left: 0;
}

.tree-page.is-recentering {
    transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Per-card styling for the plain-SVG tree drawn by family-tree.js. */
.couple-box {
    fill: #fbf9f8;
    stroke: #e2d9d7;
    stroke-width: 1.5px;
    filter: drop-shadow(0 2px 6px rgba(60, 40, 40, 0.1));
}
.card-bg {
    stroke: #e9e3e2;
    stroke-width: 1px;
    filter: drop-shadow(0 2px 5px rgba(60, 40, 40, 0.12));
}
.card-bg.male { fill: #eef2f6; }
.card-bg.female { fill: #f8eef0; }
.card-avatar.male { fill: #8ca3b6; }
.card-avatar.female { fill: #cb9ea6; }
.card-initials {
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 18px;
    font-weight: bold;
    fill: #fff;
}
.card-name {
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 13px;
    font-weight: bold;
    fill: #2a2a2a;
}
.card-years {
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 11px;
    font-style: italic;
    letter-spacing: 0.02em;
    fill: #a09a97;
}
.glyph-star { font-size: 1.25em; fill: #c19a76; }
.glyph-dagger { font-size: 1.05em; fill: #9a8a95; }
.couple-heart {
    fill: #c15c6e;
    paint-order: stroke;
    stroke: #fbf9f8;
    stroke-width: 3px;
    stroke-linejoin: round;
}
.card-indi {
    cursor: pointer;
}
.explore-btn {
    cursor: pointer;
}
.explore-btn rect {
    fill: #fdf8f8;
    stroke: #c15c6e;
    stroke-width: 1.25px;
    filter: drop-shadow(0 1px 3px rgba(60, 40, 40, 0.18));
    transition: fill 0.15s ease;
}
.explore-btn text {
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 12px;
    font-weight: bold;
    fill: #c15c6e;
    transition: fill 0.15s ease;
}
.explore-btn:hover rect {
    fill: #c15c6e;
}
.explore-btn:hover text {
    fill: #fff;
}

.person-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.25);
    /* Above the family tree page's own floating search box/zoom controls
       (z-index: 50) -- those used to render on top of this overlay/panel
       instead of being covered by it. */
    z-index: 200;
}

.person-overlay.open {
    display: block;
}

.person-panel {
    position: fixed;
    top: 0;
    right: 0;
    height: 100%;
    width: 340px;
    min-width: 300px;
    max-width: 90vw;
    background: #fff;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.12);
    z-index: 201;
    padding: 2.5rem 2rem;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    overflow-y: auto;
}

.person-panel.open {
    transform: translateX(0);
}

/* Dragging while the panel is mid-transition (opening) fights the
   transform transition -- disabled the instant a drag starts (see the
   .resizing class toggled in JS) so width changes track the cursor
   immediately with no lag/rubber-banding. */
.person-panel.resizing {
    transition: none;
}

.person-panel-resize-handle {
    position: absolute;
    top: 0;
    /* left: 0 (not a negative offset) -- .person-panel's overflow-y: auto
       forces overflow-x to clip too (CSS's own rule: a non-"visible"
       overflow-y makes an unset overflow-x compute to "auto" instead of
       staying "visible"), so anything positioned outside the panel's own
       box, like a handle hanging off the left edge, was never actually
       hit-testable -- drags fell through to the overlay behind it and
       closed the panel instead of resizing it. */
    left: 0;
    width: 12px;
    height: 100%;
    cursor: ew-resize;
    /* Invisible hit-target wider than the visible line so it's easy to
       grab, with a thin visible line centered inside it. */
    background: transparent;
}

.person-panel-resize-handle::after {
    content: '';
    position: absolute;
    top: 0;
    left: 5px;
    width: 2px;
    height: 100%;
    background: rgba(0, 0, 0, 0.06);
}

.person-panel-resize-handle:hover::after,
.person-panel.resizing .person-panel-resize-handle::after {
    background: #c15c6e;
}

.person-panel-close {
    position: absolute;
    top: 1rem;
    right: 1.25rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: #999;
    cursor: pointer;
}

.person-panel-close:hover {
    color: #333;
}

.panel-avatar {
    width: 140px;
    height: 140px;
    margin: 0 auto 1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: Georgia, "Times New Roman", Times, serif;
    font-size: 2.6rem;
    font-weight: bold;
    color: #fff;
    overflow: hidden;
}

.panel-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.panel-avatar.gender-m {
    background: linear-gradient(150deg, #8ca3b6, #6c85a0);
}

.panel-avatar.gender-f {
    background: linear-gradient(150deg, #cb9ea6, #b06e7d);
}

.panel-name {
    font-size: 1.3rem;
    font-weight: bold;
    text-align: center;
    margin-bottom: 0.25rem;
}

.panel-years {
    font-size: 0.9rem;
    color: #888;
    text-align: center;
    margin-bottom: 1.5rem;
}

.panel-section {
    margin-bottom: 1.25rem;
}

.panel-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #aaa;
    margin-bottom: 0.35rem;
}

.panel-value {
    font-size: 0.95rem;
    color: #333;
    line-height: 1.5;
}

.panel-value.italic {
    font-style: italic;
    color: #555;
}

.panel-links a {
    display: block;
    color: #2b4c7e;
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.panel-links a:hover {
    text-decoration: underline;
}
