/* Visual refresh. Presentation only: existing IDs and behaviour stay intact. */
:root {
    --bg-color: #f7f2e9; --bg-panel: #fffdf9; --text-primary: #17243c;
    --text-secondary: #687278; --accent-color: #0f8588; --accent-hover: #086f72;
    --accent-light: #e6f2ef; --army-green: #4b5320; --node-border: #e8dfd3;
    --line-color: #93bab5; --line-active: #0f8588;
    --shadow-sm: 0 2px 8px rgb(47 38 27 / .06);
    --shadow-md: 0 10px 28px rgb(47 38 27 / .10);
    --shadow-lg: 0 24px 60px rgb(47 38 27 / .15);
    --header-height: 80px; --sidebar-width: 390px;
    --footer-base-height: 42px;
    --footer-height: calc(var(--footer-base-height) + env(safe-area-inset-bottom, 0px));
    --trans-fast: 180ms ease;
}

html { background: #e9e0d3; }
body { font-family: 'DM Sans', system-ui, sans-serif; background: var(--bg-color); letter-spacing: -.01em; }
button, input, select { font-family: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
    outline: 3px solid rgb(15 133 136 / .22); outline-offset: 2px;
}

/* Header */
.app-header {
    height: var(--header-height); padding: 0 30px; gap: 28px;
    background: rgb(255 253 249 / .92); border-bottom: 1px solid #e8ded0;
    box-shadow: 0 8px 30px rgb(77 58 38 / .05);
}
.app-header::after {
    content: ''; position: absolute; inset: auto 0 0; height: 3px;
    background: linear-gradient(90deg, var(--army-green) 0 12%, #7f8955 12% 18%, transparent 18%); opacity: .7;
}
.logo {
    width: 235px; min-width: 235px; display: flex; align-items: center; gap: 12px;
    padding-right: 24px; border-right: 1px solid var(--node-border);
    color: inherit; text-decoration: none; cursor: pointer;
}
.logo-mark, .logo-copy { transition: transform var(--trans-fast), opacity var(--trans-fast); }
.logo:hover .logo-mark, .logo:hover .logo-copy { transform: translateY(-1px); opacity: .82; }
.logo-mark { flex: 0 0 34px; width: 34px; height: 64px; color: var(--army-green); display: grid; place-items: center; }
.logo-mark img {
    width: auto; height: 64px; display: block;
}
.logo-copy { display: flex; flex-direction: column; }
.logo-name {
    font: 400 1.22rem/1.2 'Cormorant Garamond', Georgia, serif; color: var(--text-primary);
    letter-spacing: .04em; text-transform: uppercase;
}
.logo-family {
    color: var(--army-green); font-size: .67rem; font-weight: 700;
    letter-spacing: .22em; text-transform: uppercase; margin-top: 4px;
}
body[data-mode="merina"] .logo-family { display: none; }
.search-container { max-width: 330px; }
.search-container::after {
    content: ''; position: absolute; right: 17px; top: 50%; width: 15px; height: 15px;
    border: 1.8px solid #687278; border-radius: 50%; transform: translateY(-58%); pointer-events: none;
}
.search-container::before {
    content: ''; position: absolute; right: 14px; top: calc(50% + 6px); width: 7px; height: 1.8px;
    background: #687278; transform: rotate(45deg); z-index: 1; pointer-events: none;
}
.search-container input {
    min-height: 46px; padding: .72rem 45px .72rem 18px; border-color: #dfd4c5;
    border-radius: 13px; background: #fffdfa; box-shadow: inset 0 1px 1px rgb(70 50 30 / .03);
}
.search-container input::placeholder { color: #999a96; }
.search-container input:focus { box-shadow: 0 0 0 4px rgb(15 133 136 / .10); }
.search-results { border-color: #e4d9ca; border-radius: 14px; padding: 6px; }
.search-results li { border: 0; border-radius: 9px; }
.search-results li:hover { background: var(--accent-light); }
/* Keep the field and its results aligned while the active search expands. */
body .search-container input,
body .search-container .search-results {
    width: 100%;
    transition: width 240ms ease, transform 240ms ease;
}
body .app-header .search-container.dynasty-search-expanded {
    z-index: 1100;
}
body .app-header .search-container.dynasty-search-expanded input,
body .app-header .search-container.dynasty-search-expanded .search-results {
    width: var(--expanded-search-width);
    transform: translateX(var(--expanded-search-offset));
}
body .dynasty-search-expanded::before,
body .dynasty-search-expanded::after {
    visibility: hidden;
}
@media (prefers-reduced-motion: reduce) {
    body .search-container input,
    body .search-container .search-results { transition: none; }
}
.family-tree-filter {
    position: relative; display: flex; align-items: center; gap: 10px; min-width: max-content;
    color: var(--army-green); font-size: .62rem; font-weight: 700;
    letter-spacing: .12em; text-transform: uppercase;
}
.family-tree-filter > span {
    flex: 0 0 auto;
}
.family-tree-filter select {
    min-width: 210px; min-height: 46px; padding: .65rem 34px .65rem 12px;
    color: var(--text-primary); border: 1px solid #dfd4c5; border-radius: 12px;
    background: #fffdfa; font-size: .78rem; font-weight: 600; letter-spacing: 0;
    text-transform: none; cursor: pointer;
}
.family-tree-filter select:hover { border-color: #aeb68a; }
.family-tree-dropdown-toggle,
.family-tree-dropdown { display: none; }
.header-action, .primary-btn {
    background: linear-gradient(135deg, #198e90, #087679); box-shadow: 0 8px 18px rgb(15 133 136 / .18);
}
.header-action { min-height: 46px; padding: .7rem 1.3rem; border-radius: 12px; font-weight: 600; }
.header-action:hover, .primary-btn:hover { background: var(--accent-hover); transform: translateY(-1px); }
.header-actions, .header-actions-menu { display: flex; align-items: center; gap: 9px; }
.add-person-nav-btn { min-width: 40px; padding-inline: .65rem; }
.add-person-nav-btn .material-symbols-rounded { font-size: 20px; }
.user-menu { position: relative; flex: 0 0 auto; }
#user-menu-initials { display: none; }
.user-menu-toggle {
    min-height: 46px; display: inline-flex; align-items: center; gap: 8px; padding: .65rem .8rem;
    border: 1px solid #d8d3c8; border-radius: 12px; background: #fffdfa; color: var(--text-primary);
    font: inherit; font-size: .82rem; font-weight: 700; cursor: pointer;
}
.user-menu-toggle:hover, .user-menu-toggle[aria-expanded="true"] { border-color: var(--accent-color); background: var(--accent-light); }
.user-menu-toggle > .material-symbols-rounded:first-child,
.user-menu-avatar { color: var(--accent-color); font-size: 25px; line-height: 1; flex-shrink: 0; }
.user-menu-avatar.hidden { display: none !important; }
.user-menu-photo {
    width: 26px; height: 26px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
    border: 1.5px solid var(--accent-color); box-shadow: 0 1px 3px rgb(0 0 0 / .12);
    background: #e9e8e4;
}
.user-menu-photo.hidden { display: none !important; }
.user-menu-chevron { color: var(--text-secondary); font-size: 18px; transition: transform var(--trans-fast); }
.user-menu-toggle[aria-expanded="true"] .user-menu-chevron { transform: rotate(180deg); }
.user-menu-dropdown {
    position: absolute; top: calc(100% + 9px); right: 0; z-index: 50; width: 220px; padding: 7px;
    border: 1px solid #dfd7ca; border-radius: 13px; background: #fffdfa; box-shadow: var(--shadow-lg);
}
.user-menu-dropdown[hidden] { display: none; }
.user-menu-identity { display: grid; gap: 2px; margin: 2px 3px 7px; padding: 9px 10px 11px; border-bottom: 1px solid #ece5da; }
.user-menu-identity[hidden] { display: none; }
.user-menu-identity strong { overflow: hidden; text-overflow: ellipsis; font-size: .84rem; }
.user-menu-identity span { color: var(--text-secondary); font-size: .7rem; }
.user-menu-dropdown button {
    width: 100%; padding: 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text-primary);
    font: inherit; font-size: .8rem; font-weight: 650; text-align: left; cursor: pointer;
}
.user-menu-dropdown :is(#album-mode-btn, #admin-mode-btn, #user-dynasty-mode-btn, #user-map-mode-btn, #database-export-btn, #user-settings-btn) { display: flex; align-items: center; gap: 9px; }
.user-menu-dropdown :is(#album-mode-btn, #admin-mode-btn, #user-dynasty-mode-btn, #user-map-mode-btn, #database-export-btn, #user-settings-btn) .material-symbols-rounded { color: var(--accent-color); font-size: 19px; }
.user-menu-dropdown button:hover { background: var(--accent-light); color: var(--accent-hover); }
.user-menu-dropdown button[hidden] { display: none; }
/* Account dialogs */
.person-editor.user-login-dialog, .person-editor.registration-dialog {
    overflow: hidden; padding: 0; border: 1px solid rgb(223 212 197 / .88); border-radius: 26px;
    background:
        radial-gradient(circle at 100% 0, rgb(220 241 235 / .72), transparent 31%),
        var(--bg-panel);
    box-shadow: 0 30px 90px rgb(23 36 60 / .24), 0 2px 5px rgb(63 48 31 / .08);
}
.user-login-dialog { width: min(480px, calc(100% - 28px)); }
.user-login-dialog.registration-mode { width: min(590px, calc(100% - 28px)); }
.registration-dialog { width: min(590px, calc(100% - 28px)); }
.person-editor.user-login-dialog::backdrop, .person-editor.registration-dialog::backdrop {
    background: rgb(18 31 47 / .52); backdrop-filter: blur(8px) saturate(.85);
}
.person-editor.user-login-dialog form, .person-editor.registration-dialog form { padding: 0; }
.user-login-dialog[open], .registration-dialog[open] { animation: auth-dialog-in 240ms cubic-bezier(.2, .8, .2, 1); }
@keyframes auth-dialog-in {
    from { opacity: 0; transform: translateY(14px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.auth-dialog-heading {
    position: relative; min-height: 118px; gap: 20px; margin: 0; padding: 26px 30px 22px;
    overflow: hidden; border-bottom: 1px solid rgb(225 218 207 / .85);
}
.auth-dialog-heading::after {
    content: ''; position: absolute; right: -35px; bottom: -54px; width: 150px; height: 150px;
    border: 1px solid rgb(15 133 136 / .12); border-radius: 50%; box-shadow: 0 0 0 24px rgb(15 133 136 / .035);
    pointer-events: none;
}
.auth-heading-copy { display: flex; min-width: 0; align-items: center; gap: 15px; }
.auth-heading-icon {
    display: grid; flex: 0 0 46px; width: 46px; height: 46px; place-items: center;
    border: 1px solid rgb(15 133 136 / .16); border-radius: 14px; background: rgb(230 242 239 / .86);
    color: var(--accent-color); box-shadow: inset 0 1px rgb(255 255 255 / .85); font-size: 24px;
}
.auth-dialog-heading .editor-eyebrow {
    display: block; margin-bottom: 3px; color: var(--accent-hover); font-size: .66rem; font-weight: 800;
    letter-spacing: .14em; text-transform: uppercase;
}
.auth-dialog-heading h2 { margin: 0; font: 700 2rem/1 'Cormorant Garamond', Georgia, serif; letter-spacing: -.02em; }
.auth-dialog-heading .close-btn {
    position: relative; z-index: 2; flex: 0 0 40px; width: 40px; height: 40px; padding: 0;
    border-color: rgb(15 133 136 / .18); background: rgb(255 253 249 / .82); color: #637071;
    font-size: 1.35rem; line-height: 1;
}
.auth-dialog-heading .close-btn:hover { border-color: rgb(15 133 136 / .34); background: #fff; color: var(--accent-hover); transform: rotate(5deg); }
.user-login-dialog .login-panel { display: grid; gap: 17px; padding: 23px 30px 28px; }
.auth-dialog-intro { margin: 0; color: #58666b; font-size: .94rem; line-height: 1.55; }
.user-login-dialog .login-panel > label, .registration-step > label {
    display: grid; gap: 7px; color: #4f5d61; font-size: .75rem; font-weight: 750; letter-spacing: .015em;
}
.login-person-field { display: grid; gap: 7px; }
.login-person-field > label { color: #4f5d61; font-size: .75rem; font-weight: 750; letter-spacing: .015em; }
.login-person-field[hidden] { display: none; }
.remembered-profiles[hidden], .login-preferences[hidden], .login-preferences [hidden] { display: none; }
.remembered-profiles h3 { margin: 0 0 10px; color: #4f5d61; font-size: .8rem; }
.remembered-profiles ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 230px; overflow-y: auto; }
.remembered-profiles li { display: flex; border: 1px solid var(--node-border); border-radius: 12px; background: white; }
.remembered-profiles button { cursor: pointer; font: inherit; }
.remembered-profile-select { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 10px; border: 0; border-radius: 12px; text-align: left; color: var(--text-primary); background: transparent; }
.remembered-profile-select > span:last-child { overflow-wrap: anywhere; font-size: .88rem; }
.remembered-profile-initials { display: grid; place-items: center; flex: 0 0 36px; height: 36px; border-radius: 50%; background: #e8f5f3; color: #07878b; font-weight: 700; }
.remembered-profile-forget { align-self: center; min-width: 44px; min-height: 44px; border: 0; background: transparent; color: #627276; font-size: 1.35rem !important; }
.remembered-profile-select:hover, .remembered-profile-forget:hover { background: #f0f8f6; }
.remembered-profiles button:focus-visible { outline: 2px solid #07878b; outline-offset: -2px; }
.remembered-profiles > .auth-text-action { margin-top: 10px; }
.login-preferences { display: grid; gap: 6px; }
.person-editor .login-preferences label, .user-login-dialog .login-preferences label {
    display: flex; flex-direction: row; align-items: center; gap: 9px; cursor: pointer;
    line-height: 1.35; min-height: 0; margin: 0; padding: 0;
}
.person-editor .login-preferences input, .user-login-dialog .login-preferences input {
    width: 17px; height: 17px; min-height: 0; flex: 0 0 17px; padding: 0; margin: 0;
    border: 1px solid #c0c7c8; border-radius: 4px; box-shadow: none; accent-color: #07878b; cursor: pointer;
}
.login-preferences small { margin: -1px 0 2px 26px; color: #627276; font-size: .72rem; line-height: 1.35; }
.user-login-dialog #user-login-password-field[hidden] { display: none; }
.login-registration-fields { display: grid; gap: 15px; }
.login-registration-fields.hidden { display: none; }
.login-registration-fields > label {
    display: grid; gap: 7px; color: #4f5d61; font-size: .75rem; font-weight: 750; letter-spacing: .015em;
}
.login-registration-fields .registration-password-help { margin: -9px 0 0 !important; color: var(--text-secondary); }
.auth-text-action { justify-self: end; margin-top: -10px; padding: 0; border: 0; background: transparent; color: var(--accent-hover); font: inherit; font-size: .78rem; font-weight: 750; cursor: pointer; }
.auth-text-action:hover { text-decoration: underline; text-underline-offset: 3px; }
.auth-input-field, .password-field { position: relative; display: block; width: 100%; }
.auth-input-field > .material-symbols-rounded {
    position: absolute; z-index: 1; top: 50%; left: 15px; color: #768282; font-size: 20px; transform: translateY(-50%); pointer-events: none;
}
.auth-input-field > input { width: 100%; padding-left: 44px !important; }
.person-editor.user-login-dialog input:not([type="checkbox"]), .person-editor.registration-dialog input:not([type="checkbox"]) {
    width: 100%; min-height: 52px; padding: .78rem .95rem; border: 1px solid #ddd2c3; border-radius: 13px;
    background: rgb(255 254 251 / .94); color: var(--text-primary); font: inherit;
    box-shadow: inset 0 1px 2px rgb(70 50 30 / .025); transition: border-color var(--trans-fast), box-shadow var(--trans-fast), background var(--trans-fast);
}
.person-editor.user-login-dialog input:not([type="checkbox"])::placeholder, .person-editor.registration-dialog input:not([type="checkbox"])::placeholder { color: #9a9f9e; }
.person-editor.user-login-dialog input:not([type="checkbox"]):hover, .person-editor.registration-dialog input:not([type="checkbox"]):hover { border-color: #c8bbab; background: #fff; }
.person-editor.user-login-dialog input:not([type="checkbox"]):focus, .person-editor.registration-dialog input:not([type="checkbox"]):focus {
    border-color: var(--accent-color); outline: 0; background: #fff; box-shadow: 0 0 0 4px rgb(15 133 136 / .11);
}
.user-login-dialog .editor-actions, .registration-dialog .editor-actions {
    display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: 10px;
}
.user-login-dialog .editor-actions { margin-top: 1px; }
.user-login-dialog .editor-actions .primary-btn, .registration-dialog .editor-actions .primary-btn { grid-column: 2; grid-row: 1; }
.user-login-dialog .editor-actions .secondary-btn, .registration-dialog .editor-actions .secondary-btn { grid-column: 1; grid-row: 1; }
.user-login-dialog .editor-actions button, .registration-dialog .editor-actions button, .registration-success .primary-btn {
    min-height: 48px; border-radius: 13px; font-weight: 700; transition: transform var(--trans-fast), box-shadow var(--trans-fast), background var(--trans-fast);
}
.user-login-dialog .primary-btn, .registration-dialog .primary-btn { box-shadow: 0 10px 24px rgb(15 133 136 / .2); }
.user-login-dialog .secondary-btn, .registration-dialog .secondary-btn { border: 1px solid #e4dbcf; background: #f1ece4; color: #566064; }
.user-login-dialog .secondary-btn:hover, .registration-dialog .secondary-btn:hover { background: #e9e2d8; transform: translateY(-1px); }
.user-login-dialog #user-login-message { min-height: 1.2em; margin: -5px 0 -3px; color: #b42318; font-size: .76rem; }
.login-person-search { display: block; }
.login-person-search .registration-results {
    position: absolute; top: 100%; right: 0; left: 0; margin-top: 7px;
}
.login-search-message { min-height: 1.2em; margin: -10px 0 -8px; color: var(--text-secondary); font-size: .76rem; }
.login-search-message:empty { display: none; }
.registration-invitation {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 5px; margin-top: 2px; padding-top: 18px;
    border-top: 1px solid #ebe3d8; color: var(--text-secondary); font-size: .95rem;
}
.registration-invitation button, .registration-back {
    padding: 0; border: 0; background: transparent; color: var(--accent-hover); font: inherit; font-weight: 750; cursor: pointer;
}
.registration-invitation button:hover, .registration-back:hover { text-decoration: underline; text-underline-offset: 3px; }
.registration-step { display: grid; gap: 15px; padding: 23px 30px 29px; }
.registration-step.hidden { display: none; }
.registration-step > p { margin: 0; color: var(--text-secondary); }
.registration-search { position: relative; }
.registration-search > .material-symbols-rounded {
    position: absolute; z-index: 1; top: 15px; left: 15px; color: #748080; font-size: 22px;
}
.person-editor.user-login-dialog .registration-search input,
.person-editor.registration-dialog .registration-search input {
    padding-left: 48px;
}
.person-editor.user-login-dialog .login-person-search input {
    padding-right: 44px;
}
.login-person-clear {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    min-height: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #e8e2d7;
    color: #556264;
    cursor: pointer;
    transition: background-color var(--trans-fast), color var(--trans-fast), transform var(--trans-fast);
}
.login-person-clear:hover {
    background: #ded6c9;
    color: #1e2628;
    transform: scale(1.06);
}
.login-person-clear:focus-visible {
    outline: 2px solid var(--accent-color);
    outline-offset: 1px;
}
.login-person-clear .material-symbols-rounded {
    font-size: 17px;
}
.login-person-clear[hidden] {
    display: none;
}
.registration-results {
    position: relative; z-index: 20; max-height: 245px; margin: 7px 0 0; overflow-y: auto;
    padding: 7px; border: 1px solid #ddd2c3; border-radius: 14px; background: #fffefa; box-shadow: var(--shadow-lg); list-style: none;
    overscroll-behavior: contain; scrollbar-width: thin; scrollbar-color: #b9b0a5 transparent;
}
.registration-results li + li { border-top: 1px solid #eee8df; }
.registration-results button { width: 100%; padding: 10px; border: 0; border-radius: 8px; background: transparent; color: var(--text-primary); font: inherit; text-align: left; cursor: pointer; }
.registration-results button:hover, .registration-results button:focus-visible { background: var(--accent-light); }
.registration-results small { display: block; margin-top: 2px; color: var(--text-secondary); font-size: .68rem; }
.registration-message { min-height: 1.2em; color: #b42318 !important; font-size: .78rem; }
.registration-back { display: inline-flex; width: max-content; align-items: center; gap: 4px; }
.registration-back .material-symbols-rounded { font-size: 18px; }
.registration-selected-person { display: flex; align-items: center; gap: 12px; padding: 14px; border: 1px solid #cee3dd; border-radius: 14px; background: var(--accent-light); }
.registration-selected-person > .material-symbols-rounded { color: var(--accent-color); font-size: 30px; }
.registration-selected-person small, .registration-selected-person strong { display: block; }
.registration-selected-person small { color: var(--text-secondary); font-size: .68rem; }
.registration-selected-person strong { margin-top: 2px; }
.registration-password-help { margin-top: -9px !important; font-size: .7rem; }
.registration-email-help { display: flex; align-items: start; gap: 7px; margin-top: -8px !important; padding: 10px; border-radius: 10px; background: var(--accent-light); color: #436362 !important; font-size: .72rem; line-height: 1.45; }
.registration-email-help .material-symbols-rounded { color: var(--accent-color); font-size: 18px; }
.recovery-alternative { margin-top: 4px; padding-top: 16px; border-top: 1px solid #ebe3d8; text-align: center; }
.recovery-alternative p { margin: 0 0 7px; color: var(--text-secondary); font-size: .78rem; }
.recovery-alternative button { padding: 0; border: 0; background: transparent; color: var(--accent-hover); font: inherit; font-weight: 750; cursor: pointer; }
.recovery-alternative button:hover { text-decoration: underline; text-underline-offset: 3px; }
.registration-dialog .editor-actions { flex-direction: row-reverse; }
.registration-success { justify-items: center; padding-block: 36px; text-align: center; }
.registration-success > .material-symbols-rounded { color: var(--accent-color); font-size: 48px; }
.registration-success h3 { margin: 0; font-family: 'Cormorant Garamond', Georgia, serif; font-size: 1.6rem; }
.registration-success strong { padding: 9px 16px; border-radius: 9px; background: #f0ebe2; font-size: 1rem; letter-spacing: .03em; }

@media (max-width: 520px) {
    .user-login-dialog, .registration-dialog { width: calc(100% - 18px); max-height: calc(100dvh - 18px); border-radius: 21px; }
    .person-editor.user-login-dialog form, .person-editor.registration-dialog form { max-height: calc(100dvh - 18px); }
    .auth-dialog-heading { min-height: 100px; padding: 20px 19px 17px; }
    .auth-heading-copy { gap: 11px; }
    .auth-heading-icon { flex-basis: 40px; width: 40px; height: 40px; border-radius: 12px; font-size: 21px; }
    .auth-dialog-heading h2 { font-size: 1.72rem; }
    .auth-dialog-heading .close-btn { flex-basis: 36px; width: 36px; height: 36px; }
    .user-login-dialog .login-panel, .registration-step { padding: 19px; }
    .auth-dialog-intro { font-size: .86rem; }
    .user-login-dialog .editor-actions, .registration-dialog .editor-actions { grid-template-columns: 1fr 1.2fr; }
    .registration-invitation { font-size: .78rem; }
}

@media (prefers-reduced-motion: reduce) {
    .user-login-dialog[open], .registration-dialog[open] { animation: none; }
}

/* Administration dashboard */
body[data-mode="admin"] .app-header {
    justify-content: flex-start;
    gap: 10px;
}
body[data-mode="admin"] .header-actions { margin-left: 0; }
body[data-mode="admin"] .user-menu { margin-left: auto; }
body[data-mode="admin"] :is(#home-btn, #relationship-mode-btn) {
    min-height: 46px;
    height: 46px;
    padding: 0 1.3rem;
    border-radius: 12px;
    font-size: .875rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}
body[data-mode="admin"] :is(#home-btn, #relationship-mode-btn) .material-symbols-rounded {
    font-size: 20px;
}

.admin-view { flex: 1; min-width: 0; overflow: auto; background: #f4f1eb; font-family: inherit; }
.admin-shell { width: min(1240px, calc(100% - 40px)); margin: 0 auto; padding: 38px 0 56px; }
.admin-heading { margin-bottom: 26px; }
.admin-eyebrow, .admin-section-heading > div > span { color: var(--accent-color); font-size: .7rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.admin-heading h1 { margin: 4px 0 6px; font-family: inherit; font-size: clamp(2rem, 4vw, 3.1rem); line-height: 1; }
.admin-heading p { margin: 0; color: var(--text-secondary); }
.admin-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 28px; }
.admin-summary article { display: flex; align-items: center; gap: 14px; padding: 18px; border: 1px solid #e4ddd2; border-radius: 16px; background: #fffefa; box-shadow: 0 8px 24px rgb(58 46 31 / .06); }
.admin-summary article > .material-symbols-rounded { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 12px; background: var(--accent-light); color: var(--accent-color); }
.admin-summary article.has-warning > .material-symbols-rounded { background: #fff0d8; color: #b45309; }
.admin-summary strong, .admin-summary span { display: block; }
.admin-summary strong { font-size: 1.45rem; }
.admin-summary div span { color: var(--text-secondary); font-size: .78rem; }
.admin-section { margin-top: 28px; }
.admin-section-heading { display: flex; align-items: end; justify-content: space-between; margin-bottom: 13px; }
.admin-section-heading h2 { margin: 3px 0 0; font-family: inherit; font-size: 1.55rem; }
.admin-recovery-card { border: 1px solid #ded7ca; border-radius: 16px; background: #fffefa; overflow: hidden; }
.admin-recovery-card > p { margin: 0; padding: 15px 18px; border-bottom: 1px solid #eee8df; color: var(--text-secondary); font-size: .78rem; }
.admin-recovery-card ul { margin: 0; padding: 0; list-style: none; }
.admin-recovery-card li { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 18px; border-bottom: 1px solid #f0ebe4; }
.admin-recovery-card li > div:first-child { display: grid; gap: 3px; }
.admin-recovery-card li span, .admin-recovery-card li small, .admin-recovery-card li a { color: var(--text-secondary); font-size: .72rem; }
.admin-recovery-decision { display: flex; align-items: center; justify-content: end; gap: 7px; }
.admin-recovery-decision button { padding: 7px 11px; border: 1px solid #d9d1c5; border-radius: 9px; background: #fff; color: var(--text-primary); font: inherit; font-size: .72rem; font-weight: 700; cursor: pointer; }
.admin-recovery-decision button[data-decision="approved"] { border-color: var(--accent-color); color: var(--accent-hover); }
.recovery-status { padding: 5px 9px; border-radius: 999px; font-weight: 700; }
.recovery-status-pending { background: #fff0d8; color: #9a5709 !important; }
.recovery-status-approved { background: var(--accent-light); color: var(--accent-hover) !important; }
.recovery-status-refused { background: #f5e8e6; color: #9f3028 !important; }

/* Albums photo */
.albums-view { flex: 1; min-width: 0; overflow: auto; background: linear-gradient(145deg, #f5f1ea 0%, #eef6f3 100%); }
.albums-shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 42px 0 64px; }
.albums-heading, .album-detail-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.albums-eyebrow, .album-detail-heading > div > span { color: var(--accent-color); font-size: .7rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.albums-heading h1, .album-detail-heading h1 { margin: 4px 0 7px; font: 700 clamp(2.2rem, 5vw, 3.5rem)/.95 'Cormorant Garamond', Georgia, serif; }
.albums-heading p, .album-detail-heading p { max-width: 620px; margin: 0; color: var(--text-secondary); }
.albums-heading .primary-btn, .album-upload .primary-btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 46px; white-space: nowrap; }
.albums-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.album-card { padding: 0; overflow: hidden; border: 1px solid #ded6c9; border-radius: 20px; background: #fffefa; color: var(--text-primary); text-align: left; box-shadow: 0 12px 34px rgb(52 45 35 / .08); cursor: pointer; transition: transform .2s ease, box-shadow .2s ease; }
.album-card:hover { transform: translateY(-4px); box-shadow: 0 20px 42px rgb(52 45 35 / .14); }
.album-card-cover { position: relative; display: grid; aspect-ratio: 4 / 3; place-items: center; overflow: hidden; background: linear-gradient(145deg, #dcece8, #eee6d8); }
.album-card-cover > img { width: 100%; height: 100%; object-fit: cover; transition: transform .35s ease; }
.album-card:hover .album-card-cover > img { transform: scale(1.035); }
.album-card-cover > .material-symbols-rounded { color: #78938e; font-size: 58px; }
.album-card-cover small { position: absolute; right: 12px; bottom: 12px; padding: 6px 10px; border-radius: 999px; background: rgb(20 33 35 / .74); color: #fff; font-size: .68rem; backdrop-filter: blur(8px); }
.album-card-copy { display: grid; gap: 4px; padding: 17px 18px 19px; }
.album-card-copy > span { color: var(--accent-color); font-size: .65rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.album-card-copy strong { font: 700 1.4rem/1.1 'Cormorant Garamond', Georgia, serif; }
.album-card-copy small { color: var(--text-secondary); font-size: .72rem; }
.albums-empty, .album-loading { display: grid; grid-column: 1 / -1; min-height: 260px; place-items: center; align-content: center; gap: 8px; padding: 36px; border: 1px dashed #cfc5b7; border-radius: 20px; background: rgb(255 254 250 / .7); color: var(--text-secondary); text-align: center; }
.albums-empty > .material-symbols-rounded { color: var(--accent-color); font-size: 48px; }
.albums-empty p { margin: 0; }
.album-detail-heading { align-items: center; }
.album-detail-heading > button { display: inline-flex; align-items: center; gap: 5px; padding: 0; border: 0; background: transparent; color: var(--accent-hover); font: inherit; font-size: .78rem; font-weight: 750; cursor: pointer; }
.album-detail-heading > div:nth-child(2) { flex: 1; }
.album-owner-actions { display: flex; gap: 8px; }
.secondary-btn.danger { color: #a13931; }
.album-upload { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 12px; margin-bottom: 24px; padding: 18px; border: 1px solid #cfe1dc; border-radius: 18px; background: rgb(240 249 246 / .9); }
.album-upload > div { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 2px 10px; }
.album-upload > div > .material-symbols-rounded { grid-row: 1 / 3; color: var(--accent-color); font-size: 32px; }
.album-upload small { color: var(--text-secondary); font-size: .68rem; }
.album-upload label { cursor: pointer; }
.album-upload input[type="file"] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.album-upload > p { grid-column: 1 / -1; margin: 0; color: #a13931; font-size: .75rem; }
.album-photo-feed { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 20px; }
.album-photo { overflow: hidden; border: 1px solid #ded7ca; border-radius: 20px; background: #fffefa; box-shadow: 0 12px 34px rgb(52 45 35 / .07); }
.album-photo-image { display: block; width: 100%; padding: 0; overflow: hidden; border: 0; background: #e7e2da; cursor: zoom-in; }
.album-photo-image img { display: block; width: 100%; max-height: 620px; object-fit: cover; }
.album-photo-body { padding: 16px 17px 18px; }
.album-photo-meta { display: flex; align-items: start; justify-content: space-between; gap: 12px; padding-bottom: 14px; border-bottom: 1px solid #eee8df; }
.album-photo-meta p { margin: 0 0 3px; font-weight: 650; }
.album-photo-meta small { color: var(--text-secondary); font-size: .67rem; }
.album-photo-meta > div:last-child { display: flex; gap: 3px; }
.album-photo-meta button { display: grid; width: 32px; height: 32px; padding: 0; place-items: center; border: 0; border-radius: 9px; background: transparent; color: #72807f; cursor: pointer; }
.album-photo-meta button:hover { background: var(--accent-light); color: var(--accent-hover); }
.album-photo-meta button .material-symbols-rounded { font-size: 18px; }
.photo-comments h3 { display: flex; align-items: center; gap: 6px; margin: 14px 0 10px; font-size: .76rem; }
.photo-comments h3 .material-symbols-rounded { color: var(--accent-color); font-size: 17px; }
.photo-comments ul { display: grid; gap: 11px; max-height: 300px; margin: 0; padding: 0; overflow-y: auto; list-style: none; }
.photo-comments li { display: grid; grid-template-columns: 30px 1fr; gap: 9px; }
.photo-comment-avatar { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 50%; background: var(--accent-light); color: var(--accent-hover); font-size: .7rem; font-weight: 800; }
.photo-comments li header { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px; }
.photo-comments li header strong { font-size: .74rem; }
.photo-comments li time { color: var(--text-secondary); font-size: .6rem; }
.photo-comments li p { margin: 3px 0 0; white-space: pre-wrap; color: #485557; font-size: .76rem; line-height: 1.45; }
.photo-comments li footer { display: flex; gap: 9px; margin-top: 4px; }
.photo-comments li footer button { padding: 0; border: 0; background: transparent; color: var(--accent-hover); font: inherit; font-size: .62rem; font-weight: 700; cursor: pointer; }
.photo-comments-empty { display: block !important; padding: 12px; border-radius: 10px; background: #f7f3ed; color: var(--text-secondary); font-size: .7rem; text-align: center; }
.photo-comment-form { display: grid; grid-template-columns: 1fr 38px; gap: 7px; margin-top: 13px; }
.photo-comment-form input { min-width: 0; padding: 10px 12px; border: 1px solid #ddd2c3; border-radius: 12px; background: #fff; font: inherit; font-size: .76rem; }
.photo-comment-form button { display: grid; place-items: center; border: 0; border-radius: 11px; background: var(--accent-color); color: #fff; cursor: pointer; }
.photo-comment-form .material-symbols-rounded { font-size: 18px; }
.photo-comment-login { margin: 12px 0 0; color: var(--text-secondary); font-size: .7rem; text-align: center; }
.photo-lightbox { width: min(1100px, calc(100% - 24px)); max-width: none; padding: 0; overflow: visible; border: 0; background: transparent; }
.photo-lightbox::backdrop { background: rgb(8 15 18 / .9); backdrop-filter: blur(8px); }
.photo-lightbox form { position: absolute; z-index: 2; top: -15px; right: -5px; padding: 0; }
.photo-lightbox form button { width: 42px; height: 42px; border: 1px solid rgb(255 255 255 / .25); border-radius: 50%; background: rgb(10 16 18 / .8); color: #fff; font-size: 1.5rem; cursor: pointer; }
.photo-lightbox figure { display: grid; max-height: 90dvh; margin: 0; place-items: center; }
.photo-lightbox img { max-width: 100%; max-height: 84dvh; border-radius: 14px; object-fit: contain; box-shadow: 0 20px 80px #000; }
.photo-lightbox figcaption { margin-top: 10px; color: #fff; text-align: center; }
.album-editor-dialog { width: min(560px, calc(100% - 24px)); padding: 0; overflow: hidden; border: 1px solid #ddd4c7; border-radius: 22px; background: #fffefa; box-shadow: 0 30px 90px rgb(16 29 35 / .28); }
.album-editor-dialog::backdrop { background: rgb(18 31 47 / .56); backdrop-filter: blur(7px); }
.album-editor-dialog form { display: grid; gap: 16px; padding: 0 24px 24px; }
.album-editor-dialog header { display: flex; align-items: center; justify-content: space-between; margin: 0 -24px; padding: 22px 24px 18px; border-bottom: 1px solid #e8e0d5; background: var(--accent-light); }
.album-editor-dialog header span { color: var(--accent-color); font-size: .66rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.album-editor-dialog h2 { margin: 2px 0 0; font: 700 2rem/1 'Cormorant Garamond', Georgia, serif; }
.album-editor-dialog header button { width: 38px; height: 38px; border: 1px solid #cbded8; border-radius: 50%; background: #fff; color: #566; font-size: 1.3rem; cursor: pointer; }
.album-editor-dialog label { display: grid; gap: 7px; color: #4f5d61; font-size: .75rem; font-weight: 750; }
.album-editor-dialog label[hidden] { display: none; }
.album-editor-dialog input, .album-editor-dialog textarea, .album-editor-dialog select { width: 100%; padding: 12px 13px; border: 1px solid #d9d0c4; border-radius: 12px; background: #fff; color: var(--text-primary); font: inherit; resize: vertical; }
.album-editor-dialog input:focus, .album-editor-dialog textarea:focus, .album-editor-dialog select:focus { border-color: var(--accent-color); outline: 0; box-shadow: 0 0 0 4px rgb(15 133 136 / .1); }
.album-editor-dialog footer { display: flex; justify-content: end; gap: 9px; padding-top: 3px; }

@media (max-width: 820px) {
    .albums-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .album-photo-feed { grid-template-columns: 1fr; }
    .album-upload { grid-template-columns: 1fr 1fr; }
    .album-upload > div { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
    .albums-shell { width: min(100% - 22px, 1180px); padding: 25px 0 42px; }
    .albums-heading, .album-detail-heading { display: grid; gap: 14px; }
    .albums-grid { grid-template-columns: 1fr; gap: 13px; }
    .album-card { display: grid; grid-template-columns: 42% 1fr; border-radius: 16px; }
    .album-card-cover { height: 100%; aspect-ratio: 1; }
    .album-card-copy { align-content: center; padding: 13px; }
    .album-owner-actions { grid-row: 3; }
    .album-upload { grid-template-columns: 1fr; }
    .album-upload > div, .album-upload > p { grid-column: 1; }
    .album-photo { border-radius: 16px; }
    .album-photo-body { padding: 14px; }
}
.admin-family-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.admin-family-card { padding: 18px; border: 1px solid #e4ddd2; border-radius: 16px; background: #fffefa; }
.admin-family-card h3 { min-height: 2.5em; margin: 0 0 8px; font-size: .92rem; }
.admin-family-total { font-family: inherit; font-size: 2.25rem; line-height: 1; }
.admin-family-card > span { margin-left: 5px; color: var(--text-secondary); font-size: .72rem; }
.admin-family-card ul { display: grid; gap: 6px; margin: 15px 0 0; padding: 12px 0 0; border-top: 1px solid #eee8df; list-style: none; }
.admin-family-card li { display: flex; justify-content: space-between; gap: 10px; color: var(--text-secondary); font-size: .75rem; }
.admin-family-card li strong { color: var(--text-primary); }
.admin-birthday-card { min-width: 0; border: 1px solid #ded7ca; border-radius: 16px; background: #fffefa; overflow: hidden; box-shadow: 0 8px 24px rgb(58 46 31 / .05); }
.admin-birthday-card header { display: flex; align-items: center; gap: 11px; padding: 16px 18px; background: var(--accent-light); border-bottom: 1px solid #e8e0d4; }
.admin-birthday-card header > .material-symbols-rounded { color: var(--accent-color); }
.admin-birthday-card h3, .admin-birthday-card p { margin: 0; }
.admin-birthday-card h3 { font-size: .92rem; }
.admin-birthday-card p { margin-top: 2px; color: var(--text-secondary); font-size: .7rem; }
.admin-birthday-card ul { display: grid; grid-template-columns: 1fr; margin: 0; padding: 0; list-style: none; }
.admin-birthday-card li { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 13px 18px; border-bottom: 1px solid #f0ebe4; }
.admin-birthday-card li div span, .admin-birthday-card li small { display: block; color: var(--text-secondary); font-size: .72rem; }
.admin-birthday-card li div span { margin-top: 3px; text-transform: capitalize; }
.admin-birthday-card li small { flex: 0 0 auto; }
.admin-birthday-card .admin-empty { display: block; grid-column: 1 / -1; padding: 28px; color: var(--text-secondary); text-align: center; }
.admin-birthday-card footer { padding: 13px 18px; background: #fffefa; text-align: center; }
.admin-birthday-more { padding: 9px 18px; border: 1px solid var(--accent-color); border-radius: 999px; background: transparent; color: var(--accent-color); font: inherit; font-size: .78rem; font-weight: 700; cursor: pointer; }
.admin-birthday-more:hover { background: var(--accent-light); }
.admin-birthday-more:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 2px; }
.admin-anomaly-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.admin-anomaly-card { min-width: 0; border: 1px solid #ead9c7; border-radius: 16px; background: #fffefa; overflow: hidden; }
.admin-anomaly-card header { display: flex; align-items: center; gap: 11px; padding: 16px 18px; background: #fff8ed; border-bottom: 1px solid #eee2d5; }
.admin-anomaly-card header > .material-symbols-rounded { color: #b45309; }
.admin-anomaly-card h3, .admin-anomaly-card p { margin: 0; }
.admin-anomaly-card h3 { font-size: .92rem; }
.admin-anomaly-card p { margin-top: 2px; color: var(--text-secondary); font-size: .7rem; }
.admin-anomaly-card ul { max-height: 360px; margin: 0; padding: 0; overflow: auto; list-style: none; }
.admin-anomaly-card li { display: flex; align-items: start; justify-content: space-between; gap: 14px; padding: 12px 18px; border-bottom: 1px solid #f0ebe4; font-size: .78rem; }
.admin-anomaly-card li:last-child { border-bottom: 0; }
.admin-anomaly-card li span, .admin-anomaly-card li small { display: block; }
.admin-anomaly-card li small { color: var(--text-secondary); text-align: right; }
.admin-anomaly-card li div span { margin-top: 3px; color: var(--text-secondary); }
.admin-person-link { appearance: none; margin: 0; padding: 0; border: 0; background: none; color: var(--text-primary); font: inherit; text-align: left; cursor: pointer; }
.admin-person-link:hover { color: var(--accent-color); text-decoration: underline; }
.admin-person-link:focus-visible { border-radius: 3px; outline: 2px solid var(--accent-color); outline-offset: 3px; }
.admin-access-links { display: grid; gap: 14px; }
.access-link-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; padding: 18px; border: 1px solid #ded7ca; border-radius: 16px; background: #fffefa; }
.access-link-form > label { display: grid; align-content: start; gap: 6px; color: var(--text-secondary); font-size: .75rem; font-weight: 700; }
.access-link-form input, .access-link-form select { box-sizing: border-box; width: 100%; padding: 10px 11px; border: 1px solid #d9d1c5; border-radius: 10px; background: #fff; color: var(--text-primary); font: inherit; }
.access-link-roots, .access-link-form fieldset, .access-link-presets, .access-link-form-message { grid-column: 1 / -1; }
.access-link-roots select { min-height: 132px; }
.access-link-roots small { font-weight: 400; }
.access-link-form fieldset { margin: 0; padding: 12px; border: 1px solid #e4ddd2; border-radius: 12px; }
.access-link-form legend { padding: 0 6px; font-size: .78rem; font-weight: 750; }
.access-link-permissions { display: flex; flex-wrap: wrap; gap: 10px 18px; }
.access-link-permissions label { font-size: .76rem; }
.access-link-permissions input { width: auto; }
.access-link-presets { display: flex; flex-wrap: wrap; gap: 7px; }
.access-link-presets button, .access-link-meta button, .access-link-result button { padding: 8px 11px; border: 1px solid #d9d1c5; border-radius: 9px; background: #fff; color: var(--text-primary); font: inherit; font-size: .73rem; font-weight: 700; cursor: pointer; }
.access-link-presets button.is-selected { border-color: var(--accent-color); background: var(--accent-light); color: var(--accent-hover); }
.access-link-form-message { min-height: 1.2em; margin: 0; color: #9f3028; font-size: .76rem; }
.access-link-form > .primary-btn { justify-self: start; }
.access-link-result { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 15px 18px; border: 1px solid #86bbb4; border-radius: 14px; background: var(--accent-light); }
.access-link-result strong, .access-link-result small { grid-column: 1 / -1; }
.access-link-result input { min-width: 0; padding: 9px; border: 1px solid #aaccc7; border-radius: 8px; background: white; }
.access-link-copy { display: inline-grid; min-width: 38px; place-items: center; }
.access-link-copy .material-symbols-rounded { font-size: 19px; }
.access-link-url { display: block; width: min(100%, 620px); box-sizing: border-box; margin: 8px 0; padding: 7px 9px; border: 1px solid #ded7cd; border-radius: 8px; background: #fff; color: var(--text-secondary); font: inherit; font-size: .72rem; }
.access-link-lists { display: grid; grid-template-columns: 1.5fr 1fr; gap: 14px; }
.access-link-lists article { min-width: 0; border: 1px solid #ded7ca; border-radius: 16px; background: #fffefa; overflow: hidden; }
.access-link-lists h3 { margin: 0; padding: 15px 18px; border-bottom: 1px solid #eee8df; font-size: .92rem; }
.access-audit-header { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-right: 18px; border-bottom: 1px solid #eee8df; }
.access-audit-header h3 { border-bottom: 0; }
.access-audit-header button { padding: 6px 10px; border: 1px solid #d9d1c5; border-radius: 9px; background: #fff; color: var(--text-primary); font: inherit; font-size: .73rem; font-weight: 700; cursor: pointer; }
.access-audit-header button:hover:not(:disabled) { background: var(--accent-light); border-color: var(--accent-color); }
.access-audit-header button:disabled { opacity: .5; cursor: default; }
.access-link-lists ul { max-height: 480px; margin: 0; padding: 0; overflow: auto; list-style: none; }
.access-link-lists li { display: flex; justify-content: space-between; gap: 14px; padding: 13px 18px; border-bottom: 1px solid #f0ebe4; }
.access-link-lists li > div { display: grid; gap: 3px; min-width: 0; }
.access-link-lists li span, .access-link-lists li small { color: var(--text-secondary); font-size: .7rem; }
.access-link-meta { flex: 0 0 auto; justify-items: end; text-align: right; }
.access-link-actions { display: flex !important; grid-auto-flow: column; gap: 6px !important; }
.access-status { width: fit-content; padding: 4px 8px; border-radius: 999px; font-weight: 750; }
.access-status-active { background: var(--accent-light); color: var(--accent-hover) !important; }
.access-status-revoked, .access-status-expired, .access-status-consumed { background: #f5e8e6; color: #9f3028 !important; }
@media (max-width: 760px) {
    .access-link-form, .access-link-lists, .access-link-result { grid-template-columns: 1fr; }
    .access-link-result strong, .access-link-result small { grid-column: 1; }
    .access-link-lists li { flex-direction: column; }
    .access-link-meta { justify-items: start; text-align: left; }
}
.admin-anomaly-card li div span .admin-person-link { color: inherit; }
.admin-anomaly-card .admin-empty { justify-content: center; padding: 28px; color: var(--text-secondary); }
.debug-data-source {
    min-height: 32px; display: inline-flex; align-items: center; gap: 7px; padding: 6px 10px;
    color: #596164; border: 1px solid #d9d7cf; border-radius: 9px; background: #f8f7f2;
    font-size: .64rem; line-height: 1.15; white-space: nowrap;
}
.debug-data-source strong { color: inherit; font-weight: 700; }
.debug-data-source-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #9aa0a2; }
.debug-data-source[data-source="mariadb"] { color: #236343; border-color: #b9dac7; background: #edf8f1; }
.debug-data-source[data-source="mariadb"] .debug-data-source-dot { background: #2d9a61; }
.debug-data-source[data-source="json"] { color: #855719; border-color: #ead2a8; background: #fff7e8; }
.debug-data-source[data-source="json"] .debug-data-source-dot { background: #d88a22; }
.user-menu-dropdown .debug-data-source {
    width: calc(100% - 6px); justify-content: flex-start; margin: 0 3px 7px;
}
.mobile-menu-toggle, .mobile-menu-backdrop, .drawer-header { display: none; }
.drawer-separator, .drawer-nav-section { display: none; }
.mobile-search-toggle, .mobile-family-toggle { display: none; }
.landscape-search-toggle { display: none; }
.mobile-relationship-back-btn { display: none; }

@media (min-width: 769px) {
    .search-container { margin-right: auto; }
    .header-action {
        min-height: 46px;
        font-size: .875rem;
        line-height: 1.2;
    }
    .mode-switch {
        flex: 0 0 auto;
        height: 46px;
        padding-block: 0;
        white-space: nowrap;
    }
}
.mode-switch {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    color: #344315; border: 1px solid #cfd4b9; background: #f4f4e8; box-shadow: none;
}
.mode-switch:hover { color: #fff; border-color: var(--army-green); background: var(--army-green); }
.mode-switch[aria-pressed="true"] { color: #fff; border-color: var(--army-green); background: var(--army-green); }
.mode-switch:disabled { opacity: .55; cursor: wait; transform: none; }

/* Tree canvas */
/* Custom family backgrounds, keyed by the Taranaka selector person ID. */
body[data-taranaka-person-id="p001"] {
    --taranaka-background: url('../images/rova.png');
}

.tree-container {
    background-color: #faf6ef;
    background-image: linear-gradient(rgb(255 250 241 / .28), rgb(255 250 241 / .28)),
        var(--taranaka-background, url('../images/madagascar-tree-background.webp'));
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
}
.tree-container::before {
    content: ''; position: absolute; inset: 0;
    background: linear-gradient(90deg, rgb(255 252 246 / .12), transparent 22% 78%, rgb(255 252 246 / .12));
    pointer-events: none;
}
.merina-source-note {
    position: absolute; top: 26px; right: 28px; z-index: 9; width: min(270px, calc(100% - 56px));
    padding: 14px 16px; border: 1px solid #d8cfad; border-radius: 14px;
    background: rgb(255 253 244 / .88); box-shadow: var(--shadow-sm); backdrop-filter: blur(10px);
    display: none; gap: 3px; color: #5f633c;
}
.merina-source-note span { color: var(--army-green); font-size: .62rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.merina-source-note strong { color: var(--text-primary); font: 700 .82rem/1.4 'Cormorant Garamond', Georgia, serif; }
.merina-source-note a { color: var(--accent-hover); font-size: .7rem; font-weight: 700; text-decoration: none; }
.merina-source-note a:hover { text-decoration: underline; }
body[data-mode="merina"] .tree-container {
    background-color: #f4f0e2;
    background-image: linear-gradient(rgb(250 247 237 / .58), rgb(250 247 237 / .58)), url('../images/madagascar-tree-background.webp');
}
.tree-lines path {
    stroke: #276f70;
    stroke-width: 2.5px;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: none;
}
.tree-lines path.line-halo {
    stroke: #fff5dc;
    stroke-width: 6.5px;
}
.tree-lines path.active-path {
    stroke: var(--accent-color);
    stroke-width: 3.5px;
}
.person-node {
    width: 164px; min-height: 0; padding: 17px 13px 15px; border-color: #e9e1d6;
    border-radius: 15px; background: rgb(255 254 251 / .97);
    box-shadow: 0 8px 24px rgb(58 46 31 / .09), 0 1px 2px rgb(58 46 31 / .04);
}
.person-node:hover { box-shadow: 0 16px 32px rgb(58 46 31 / .14); }
.person-node.active {
    z-index: 4;
    border-color: #008bbf;
    box-shadow:
        0 0 0 1px rgb(211 242 255 / .95),
        0 0 0 4px rgb(0 139 191 / .22),
        0 0 18px 5px rgb(0 139 191 / .24),
        0 18px 38px rgb(0 75 112 / .24);
    animation: selected-card-glow 3.2s ease-in-out infinite;
}
.person-node.active::before,
.person-node.active::after {
    content: '';
    position: absolute;
    pointer-events: none;
    border-radius: inherit;
}
.person-node.active::before {
    inset: -3px;
    border: 2px solid rgb(0 139 191 / .76);
    box-shadow:
        inset 0 0 8px rgb(145 220 250 / .42),
        0 0 8px rgb(0 139 191 / .62);
}
.person-node.active::after {
    inset: -8px;
    border: 1px solid rgb(0 139 191 / .24);
    box-shadow: 0 0 22px 6px rgb(0 139 191 / .18);
    opacity: .82;
}
.person-node.active:hover {
    animation: none;
    box-shadow:
        0 0 0 1px rgb(221 244 255 / 1),
        0 0 0 4px rgb(0 139 191 / .28),
        0 0 22px 6px rgb(0 139 191 / .30),
        0 22px 42px rgb(0 75 112 / .26);
}
.tree-container.selection-moving .person-node.active {
    box-shadow:
        0 0 0 1px rgb(211 242 255 / .95),
        0 0 0 4px rgb(0 139 191 / .22),
        0 0 18px 5px rgb(0 139 191 / .24),
        0 18px 38px rgb(0 75 112 / .24);
}
@keyframes selected-card-glow {
    0%, 100% {
        box-shadow:
            0 0 0 1px rgb(211 242 255 / .92),
            0 0 0 4px rgb(0 139 191 / .18),
            0 0 15px 4px rgb(0 139 191 / .20),
            0 18px 38px rgb(0 75 112 / .22);
    }
    50% {
        box-shadow:
            0 0 0 1px rgb(221 244 255 / 1),
            0 0 0 5px rgb(0 139 191 / .27),
            0 0 22px 7px rgb(0 139 191 / .29),
            0 20px 42px rgb(0 75 112 / .26);
    }
}
.node-avatar {
    width: 58px; height: 58px; margin-bottom: 10px; border: 4px solid #f2eee7;
    background: linear-gradient(145deg, #e9e8e4, #d7dbd9);
}
.node-name {
    width: 100%; max-width: none; margin-bottom: 7px;
    font: 700 .78rem/1.38 'Cormorant Garamond', Georgia, serif;
    overflow: visible;
}
.node-first-name, .node-last-name, .node-birth-name {
    display: block;
    max-width: 100%;
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
}
.node-birth-name {
    font-size: .9em;
    font-style: italic;
    font-weight: 500;
}
.node-year {
    position: absolute;
    top: 6px;
    color: var(--accent-color);
    font-size: .58rem;
    font-weight: 600;
    letter-spacing: .02em;
    line-height: 1;
}
.node-birth-year { left: 8px; }
.node-death-year { right: 8px; text-align: center; }
.node-death-year::after {
    content: '\271D';
    display: block;
    margin-top: 3px;
    color: currentColor;
    font-size: .72rem;
    line-height: 1;
}
.historical-node {
    min-height: 0; padding: 20px 16px 18px; border-top: 4px solid #8a7c37;
    background: rgb(255 254 246 / .98); justify-content: center;
}
.historical-node .node-name {
    overflow: visible; text-overflow: clip;
}
.expand-toggle, .spouse-toggle {
    background: #fffdf8; border-color: #d5e3df; color: var(--accent-color);
    box-shadow: 0 3px 9px rgb(31 66 61 / .14);
}
.expand-toggle { width: 25px; height: 25px; bottom: -13px; }
.spouse-toggle { width: 27px; height: 27px; top: -10px; right: -10px; }
.couple-children-toggle {
    width: 30px; height: 30px; border-color: var(--accent-color); background: #fffdf8;
    box-shadow: 0 3px 10px rgb(31 66 61 / .2);
}

.generation-actions {
    position: absolute; z-index: 20; right: 12px; bottom: 18px; display: flex; flex-direction: column;
    align-items: flex-end; gap: 8px; max-width: calc(100% - 24px);
}
.generation-actions.hidden { display: none; }
.next-generation-button {
    display: grid; width: 42px; height: 42px; place-items: center; padding: 0;
    border: 1px solid rgb(216 208 194 / .9); border-radius: 50%; background: rgb(255 253 249 / .88);
    box-shadow: 0 4px 12px rgb(50 39 28 / .1); color: var(--accent-color); line-height: 1;
    cursor: pointer; backdrop-filter: blur(8px); transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}
.next-generation-button .material-symbols-rounded { font-size: 27px; }
.next-generation-button { position: relative; }
.next-generation-tooltip {
    position: absolute; top: 50%; right: calc(100% + 13px); height: 42px; padding: 0 19px 0 15px;
    display: flex; align-items: center; gap: 9px; transform: translateY(-50%);
    border: 1px solid rgb(118 157 180 / .42); border-radius: 999px;
    background: radial-gradient(circle at 22% 0%, rgb(75 111 137 / .28), transparent 48%), linear-gradient(145deg, #0d2940, #071b2d);
    box-shadow: 0 8px 20px rgb(4 20 33 / .32), inset 0 1px 0 rgb(255 255 255 / .2), inset 0 -1px 0 rgb(0 0 0 / .16);
    color: #fff; font-family: var(--font-body, sans-serif); font-size: 13px; font-variation-settings: normal;
    font-weight: 700; line-height: 1.3; letter-spacing: .005em; white-space: nowrap; pointer-events: auto; cursor: pointer;
    transition: box-shadow var(--trans-fast), transform var(--trans-fast);
}
.next-generation-tooltip::after {
    content: ''; position: absolute; top: 50%; right: -8px; width: 16px; height: 16px;
    transform: translateY(-50%) rotate(45deg); border-top: 1px solid rgb(118 157 180 / .3);
    border-right: 1px solid rgb(118 157 180 / .3); background: #0a2135; pointer-events: none;
}
.next-generation-tooltip-icon.material-symbols-rounded {
    position: relative; z-index: 1; color: #35bfd1; font-size: 22px;
    font-variation-settings: 'FILL' 0, 'wght' 650, 'GRAD' 0, 'opsz' 24;
    filter: drop-shadow(0 1px 2px rgb(0 0 0 / .22));
}
.next-generation-button:hover .next-generation-tooltip,
.next-generation-button:focus-visible .next-generation-tooltip {
    transform: translate(-3px, -50%);
    box-shadow: 0 10px 24px rgb(4 20 33 / .36), inset 0 1px 0 rgb(255 255 255 / .23);
}
.next-generation-button:hover, .next-generation-button:focus-visible {
    border-color: #8fc2bd; background: rgb(255 253 249 / .98); box-shadow: 0 6px 16px rgb(31 66 61 / .18);
}
/* Keep the bulk descendant action above the person sheet. Without this
   offset, the 15vh summary sheet covers the button as soon as a Taranaka
   person is selected, and the generation-2 action appears to be missing. */
.app-main:has(.person-details:not(.hidden)) .generation-actions { bottom: calc(15vh + var(--footer-height) + 18px); }
.app-main:has(.person-details.expanded) .generation-actions { bottom: calc(50vh + var(--footer-height) + 18px); }

/* Floating controls */
.tree-controls {
    top: 16px; right: 16px; bottom: auto; left: auto; transform: none; flex-direction: column; gap: 0; padding: 4px;
    border: 1px solid #e5dccf; border-radius: 15px; background: rgb(255 253 249 / .92);
    box-shadow: 0 12px 30px rgb(50 39 28 / .13); backdrop-filter: blur(12px);
}
.control-btn {
    min-height: 34px; padding: .4rem .6rem; border: 0; border-radius: 9px;
    background: transparent; box-shadow: none; color: #46525b; font-size: .75rem;
}
.zoom-control-btn {
    justify-content: center; width: 34px; height: 34px; padding: 0;
    color: var(--accent-color); font-size: 1.35rem; line-height: 1;
}
.zoom-control-btn .material-symbols-rounded { font-size: 21px; }
.control-btn + .control-btn { border-top: 1px solid #ece4d8; }
.control-btn:hover { background: var(--accent-light); box-shadow: none; transform: none; }
.control-btn svg { width: 17px; height: 17px; color: var(--accent-color); }
.focused-spouse-picker {
    width: 100%; margin: 0 0 11px; color: var(--text-secondary); font-size: .62rem;
    font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
}
.spouse-picker-node {
    min-width: 180px;
    padding-top: 10px;
    padding-bottom: 10px;
    background: #fffdf9;
}
.spouse-picker-node.has-selected-spouse { cursor: pointer; }
.focused-spouse-previews {
    display: flex; gap: 8px; width: 100%; margin: 6px 0 3px;
    padding: 2px;
    letter-spacing: normal; text-transform: none;
}
.focused-spouse-preview {
    display: flex; flex: 0 0 auto; flex-direction: column; align-items: center;
    gap: 4px; min-width: 0; padding: 6px 8px; text-align: center;
    border: 1px solid #cbded9; border-radius: 10px;
    box-sizing: border-box; background: #fffdf9; cursor: pointer;
    font: inherit; letter-spacing: normal; text-transform: none;
}
.focused-spouse-preview:hover { background: #f0f7f4; border-color: var(--accent-color); }
.focused-spouse-preview.is-selected {
    background: #eaf5f1; border-color: var(--accent-color);
    box-shadow: inset 0 0 0 1px var(--accent-color);
}
.focused-spouse-preview:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 1px; }
.focused-spouse-avatar {
    position: relative; display: grid; place-items: center; flex-shrink: 0;
    width: 34px; height: 34px; overflow: hidden; border-radius: 50%;
    background: #eeece7; color: #92958f;
    border: 3px solid #f2eee7;
}
.focused-spouse-avatar img {
    position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.focused-spouse-name {
    font: 700 .78rem/1.35 'Cormorant Garamond', Georgia, serif;
    color: var(--text-primary);
    white-space: nowrap;
}
.focused-spouse-last-name, .focused-spouse-first-name { display: block; }
.focused-spouse-first-name { font-weight: 500; }
.spouse-picker-node .focused-spouse-picker {
    margin-bottom: 0;
    padding-right: 0;
}
.spouse-picker-node .gender-icon {
    top: 14px;
    left: auto;
    right: 12px;
    bottom: auto;
    transform: none;
}
.focused-spouse-select {
    width: 100%; margin-top: 5px; padding: 6px 24px 6px 7px; border: 1px solid #cbded9;
    border-radius: 8px; background: #f7fbf9; color: var(--text-primary); font-size: .68rem;
    font-weight: 600; letter-spacing: 0; text-transform: none; cursor: pointer;
}

/* Person sheet */
.person-details {
    position: fixed; inset: auto 0 var(--footer-height); width: 100%; max-width: none;
    height: max(15vh, 126px); min-height: 0; flex: none;
    border: 0; border-top: 1px solid rgb(0 143 144 / .3); border-radius: 22px 22px 0 0;
    background-color: #fffdf8;
    background-image:
        linear-gradient(90deg, rgb(255 253 248 / .68), rgb(255 253 248 / .84) 28%, rgb(255 253 248 / .76) 70%, rgb(255 253 248 / .55)),
        url('../images/person-panel-background.webp');
    background-position: center;
    background-size: 100% 100%;
    background-repeat: no-repeat;
    box-shadow: 0 -14px 38px rgb(35 48 43 / .14), inset 0 1px rgb(255 255 255 / .88); overflow: visible;
    transform: translateY(0);
    transition: height var(--trans-normal), transform var(--trans-normal), visibility var(--trans-normal);
}
.person-details.expanded { height: 50vh; }
.person-details::before {
    content: 'expand_circle_up'; position: absolute; inset: 0 auto auto 50%;
    width: 28px; height: 28px; color: #a99f92; transform: translate(-50%, -50%);
    font: 400 28px/1 'Material Symbols Rounded';
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 28;
    pointer-events: none;
}
.person-details.expanded::before { content: 'expand_circle_down'; }
.person-details.hidden {
    visibility: hidden;
    pointer-events: none;
    transform: translateY(calc(100% + var(--footer-height)));
}
.close-btn {
    top: 18px; right: 18px; width: 40px; height: 40px; border: 1px solid rgb(0 143 144 / .18);
    background: rgb(255 253 248 / .78); box-shadow: 0 5px 18px rgb(37 57 51 / .08);
    backdrop-filter: blur(8px); z-index: 2;
}
.details-content {
    width: 100%; height: 100%; margin: 0; padding: 28px 24px 10px;
    display: flex; flex-direction: column; align-items: stretch; gap: 14px;
    overflow-x: hidden; overflow-y: auto; scroll-snap-type: y proximity;
    scrollbar-width: thin; scrollbar-color: #cfc3b3 transparent;
}
.detail-summary {
    display: contents;
}
.person-details:not(.expanded) .details-content > :not(.detail-summary),
.person-details:not(.expanded) .detail-summary > :not(.detail-header) {
    display: none;
}
.detail-header {
    display: grid; grid-template-columns: auto minmax(0, 1fr);
    flex: 0 0 auto; gap: 16px; align-items: center;
    margin: 0; text-align: left; scroll-snap-align: start;
    padding-right: 48px;
}
.detail-header:not(:has(.detail-avatar)) { grid-template-columns: 1fr; text-align: center; padding-left: 48px; }
.detail-avatar-button {
    display: block; margin: 0; padding: 0; border: 0; border-radius: 50%; background: transparent;
    line-height: 0; cursor: default;
}
.person-details.expanded .detail-avatar-button { cursor: zoom-in; }
.person-details.expanded .detail-avatar-button:focus-visible {
    outline: 3px solid rgb(0 143 144 / .3); outline-offset: 4px;
}
.detail-identity { min-width: 0; }
.detail-name-row { display: flex; align-items: center; justify-content: center; gap: 8px; }
.detail-header:has(.detail-avatar) .detail-name-row { justify-content: flex-start; }
.detail-avatar {
    width: clamp(54px, calc(15vh - 34px), 82px); height: clamp(54px, calc(15vh - 34px), 82px);
    margin: 0; padding: 3px; border: 2px solid var(--accent-color);
    background: rgb(240 245 241 / .86); box-shadow: 0 7px 18px rgb(16 74 70 / .12), 0 0 0 4px rgb(255 253 248 / .7);
}
.detail-name { min-width: 0; margin: 0 0 4px; font: 700 clamp(.95rem, 1.8vw, 1.35rem)/1.2 'Cormorant Garamond', Georgia, serif; }
.detail-edit-btn {
    flex: 0 0 auto; display: grid; width: 32px; height: 32px; place-items: center; padding: 0;
    border: 1px solid rgb(0 143 144 / .28); border-radius: 50%; background: rgb(255 253 248 / .78);
    color: var(--accent-color); cursor: pointer; transition: background var(--trans-fast), transform var(--trans-fast);
}
.detail-edit-btn:hover { background: var(--accent-light); transform: translateY(-1px); }
.detail-edit-btn:focus-visible { outline: 3px solid rgb(0 143 144 / .25); outline-offset: 2px; }
.detail-edit-btn .material-symbols-rounded { font-size: 18px; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 2px 6px; color: var(--text-secondary); font-size: .875rem; }
.detail-meta-separator { color: #b5aaa0; }
.detail-podcast-container {
    display: block;
}
.detail-podcast-content { display: flex; align-items: center; gap: 12px; }
.detail-podcast-badge { display: flex; align-items: center; gap: 7px; min-width: 0; flex: 0 1 auto; }
.detail-podcast-icon { font-size: 20px; color: var(--accent-color); flex-shrink: 0; }
.detail-podcast-title { font-size: .8rem; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.detail-podcast-player { flex: 1 1 180px; min-width: 130px; height: 32px; border-radius: 8px; outline: none; }
@media (max-width: 640px) {
    .detail-podcast-content { flex-direction: column; align-items: stretch; gap: 6px; }
    .detail-podcast-title { max-width: none; }
    .detail-podcast-player { width: 100%; min-width: 0; }
}
.detail-section {
    flex: 0 0 auto;
    margin: 0; padding: 9px 12px; overflow: visible; scroll-snap-align: start;
    scrollbar-width: none;
    border: 1px solid #eee6da; border-radius: 12px; background: #fffefa;
}
.detail-section::-webkit-scrollbar { display: none; }
.detail-section h3 {
    color: var(--accent-color); border-bottom-color: #e6ddd0; padding-bottom: 5px;
    margin-bottom: 6px; font-size: .62rem; letter-spacing: .1em;
}
.detail-row { flex-direction: row; gap: 9px; margin-bottom: 4px; line-height: 1.2; }
.detail-row:last-child { margin-bottom: 0; }
.detail-label { flex: 0 0 72px; color: #7e8587; font-size: .7rem; }
.detail-value { min-width: 0; font-size: .74rem; }
.detail-section a {
    padding: 9px 11px; border-radius: 9px; background: #f2f7f4;
    transition: background var(--trans-fast), transform var(--trans-fast);
}
.detail-section a:hover { background: var(--accent-light); transform: translateX(2px); }
.relative-groups { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 10px; }
.relative-group { grid-column: span 3; min-width: 0; padding: 8px; border: 1px solid #e8eee9; border-radius: 10px; background: rgb(247 250 247 / .72); }
.relative-group-children { grid-column: span 6; }
.relative-group-title {
    display: flex; align-items: center; gap: 6px; margin: 0 0 6px; color: #65716d;
    font-size: .64rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}
.relative-count {
    display: inline-grid; min-width: 19px; height: 19px; place-items: center; padding: 0 5px;
    border-radius: 10px; background: #dfeee9; color: var(--accent-hover); font-size: .62rem; letter-spacing: 0;
}
.relative-links { display: flex; flex-flow: row wrap; gap: 5px; }
.relative-links .relative-person {
    display: inline-flex; max-width: 100%; align-items: center; gap: 5px; padding: 5px 8px;
    border: 1px solid #e2ece7; border-radius: 999px; background: #fffefa; color: var(--accent-color);
    font-size: .7rem; line-height: 1.2; text-decoration: none;
}
.relative-links .relative-person:hover { border-color: #c8dfd7; background: var(--accent-light); transform: none; }
.relative-role { color: #77817e; font-size: .61rem; font-weight: 700; text-transform: uppercase; }
.relative-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted-detail { color: var(--text-secondary); font-size: .82rem; }
.biography-text {
    display: -webkit-box; margin: 0 0 4px; overflow: hidden; color: var(--text-primary);
    font-size: .7rem; line-height: 1.25; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
.biography-section > a {
    display: inline-flex; color: var(--accent-hover); font-size: .76rem;
    font-weight: 700; text-decoration: none;
}
.source-note { margin-top: 10px; color: var(--text-secondary); font-size: .72rem; line-height: 1.5; }
.source-section > a { display: inline-flex; color: var(--accent-hover); font-weight: 700; text-decoration: none; }
.back-to-tree-btn {
    flex: 0 0 auto; width: auto; min-width: 150px; margin: 0; padding: .65rem .85rem;
    border-radius: 11px; background: linear-gradient(135deg, #198e90, #087679);
    box-shadow: 0 10px 22px rgb(15 133 136 / .18);
}
.detail-actions {
    display: inline-grid;
    width: max-content;
    max-width: 100%;
    align-self: center;
    gap: 9px;
}
.detail-actions .back-to-tree-btn { width: 100%; margin: 0; }
.edit-person-btn { background: #fffdfa; color: var(--accent-color); border: 1px solid var(--accent-color); box-shadow: none; }
.edit-person-btn:hover { background: var(--accent-light); }

/* Inline person editor in the bottom sheet */
.inline-person-editor-host {
    width: 100%;
    flex: 0 0 auto;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.inline-editor-card, .inline-person-form {
    border: 1px solid #e3d8c9; border-radius: 14px; background: rgb(255 254 250 / .94);
    box-shadow: 0 10px 26px rgb(35 48 43 / .08);
}
.inline-editor-card { display: grid; width: 100%; max-width: 520px; gap: 10px; margin: 0 auto; padding: 16px; }
.inline-person-form { display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; max-width: 1160px; margin-inline: auto; gap: 16px; padding: 20px; }
.person-field-group { grid-column: 1 / -1; min-width: 0; margin: 0; padding: 14px 0 0; border: 0; border-top: 1px solid #e8dfd3; }
.person-field-group legend { padding: 0 10px 0 0; color: var(--accent-color); font-size: .78rem; font-weight: 700; }
.person-field-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 16px; }
.person-field-row + .person-field-row { margin-top: 12px; }
.person-field-row > label { flex: 1 1 240px; min-width: 0; max-width: 100%; }
.person-field-row > .person-field-nickname { flex: 1 1 180px; }
.person-field-row > .person-field-gender { flex: 0 1 180px; }
.person-field-row > .person-field-rank { flex: 0 1 128px; }
.person-field-row > .person-field-avatar { flex: 0 1 280px; }
.person-field-row > .person-field-photo-upload { flex: 1 1 320px; }
.person-field-photo-upload[hidden] { display: none; }
.person-field-photo-upload small { color: #786f68; font-size: .72rem; font-weight: 500; line-height: 1.35; }
.person-field-row > .person-field-id { flex: 0 1 200px; }
.person-field-id input[readonly] { background: #f0ebe4; color: #8a8078; border-color: #e0d8ce; cursor: default; user-select: all; font-family: 'Roboto Mono', monospace; font-size: .8rem; letter-spacing: .02em; }
.person-field-row > .person-field-date { flex: 0 1 180px; }
.person-field-row > .person-field-year { flex: 0 1 250px; }
.person-field-row > .person-field-place { flex: 1 1 280px; }
.person-field-row > .person-field-status { flex: 0 1 260px; }
.person-field-row > .person-field-spouses { flex: 1 1 320px; max-width: 560px; }
.person-field-row input, .person-field-row select { min-width: 0; }
.editor-fields .person-field-row > label { min-width: 0; }
.inline-editor-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.inline-editor-heading strong { display: block; font: 700 1.05rem/1.2 'Cormorant Garamond', Georgia, serif; }
.inline-editor-heading .editor-eyebrow { display: block; margin-bottom: 2px; color: var(--accent-color); font-size: .62rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.inline-editor-card label, .inline-person-form label {
    display: flex; min-width: 0; flex-direction: column; gap: 5px; color: var(--text-secondary);
    font-size: .72rem; font-weight: 600;
}
.inline-person-form label.checkbox-field { flex-direction: row; align-items: center; align-self: end; min-height: 44px; }
.inline-person-form label.checkbox-field input { width: auto; }
.inline-editor-card input, .inline-person-form input, .inline-person-form select, .inline-person-form textarea {
    width: 100%; min-height: 38px; padding: 7px 9px; border: 1px solid #dfd4c5; border-radius: 9px;
    background: #fffefa; color: var(--text-primary); font: inherit;
}
.inline-person-form select[multiple] { min-height: 112px; }
.inline-editor-card input:focus, .inline-person-form input:focus, .inline-person-form select:focus, .inline-person-form textarea:focus {
    border-color: var(--accent-color); outline: 3px solid rgb(0 143 144 / .12);
}
.password-field { position: relative; display: block; width: 100%; }
.password-field > input { padding-right: 2.75rem !important; }
.password-toggle {
    position: absolute; top: 50%; right: .35rem; display: grid; width: 2rem; height: 2rem; min-height: 0;
    translate: 0 -50%; place-items: center; padding: 0; border: 0; border-radius: 50%;
    background: transparent; color: #66716f; cursor: pointer;
}
.password-toggle:hover { background: var(--accent-light); color: var(--accent-hover); }
.password-toggle:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 1px; }
.password-toggle .material-symbols-rounded { font-size: 20px; }
.inline-editor-close { display: grid; width: 34px; height: 34px; place-items: center; padding: 0; border: 0; border-radius: 50%; background: #eee7dc; color: #4d5558; cursor: pointer; }
.inline-editor-close .material-symbols-rounded { font-size: 19px; }
.inline-editor-help, .inline-editor-status { margin: 0; color: var(--text-secondary); font-size: .78rem; }
.inline-editor-message { min-height: 18px; margin: 0; color: #a32626; font-size: .75rem; }
.inline-editor-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.inline-editor-actions.person-form-actions { justify-content: center; }
.inline-editor-actions > div { display: flex; gap: 8px; }
.inline-editor-actions button { min-height: 38px; padding: .55rem .8rem; }
.spouse-picker-ui { display: grid; gap: 8px; }
.selected-spouses { display: flex; min-height: 30px; flex-wrap: wrap; align-items: center; gap: 6px; }
.spouse-picker-empty { color: #8a918f; font-size: .72rem; font-weight: 500; font-style: italic; }
.selected-spouse-chip {
    display: inline-flex; max-width: 100%; align-items: center; gap: 4px; padding: 4px 5px 4px 9px;
    border: 1px solid #c9e0d8; border-radius: 999px; background: #edf6f2; color: var(--accent-hover);
    font-size: .72rem; font-weight: 600;
}
.selected-spouse-chip > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.selected-spouse-chip button {
    display: grid; width: 22px; height: 22px; min-height: 0; place-items: center; padding: 0; border: 0;
    border-radius: 50%; background: transparent; color: #6f7d78; cursor: pointer;
}
.selected-spouse-chip button:hover { background: #d7ebe4; color: #315f56; }
.selected-spouse-chip .material-symbols-rounded { font-size: 15px; }
.spouse-candidate-select { width: 100%; min-height: 38px; }
.parent-combobox { position: relative; min-width: 0; }
.parent-combobox-input { padding-right: 2.25rem !important; }
.parent-combobox::after {
    content: 'search'; position: absolute; top: 50%; right: .7rem; translate: 0 -50%; color: #66716f;
    font: 20px/1 'Material Symbols Rounded'; pointer-events: none;
}
.parent-combobox:has(.parent-combobox-results:not(.hidden))::after { top: 19px; }
.parent-combobox-results {
    position: absolute; z-index: 50; top: calc(100% + 6px); right: 0; left: 0; max-height: 230px; margin: 0;
    padding: 6px; overflow-y: auto; list-style: none; border: 1px solid #dfd4c5; border-radius: 12px;
    background: #fffefa; box-shadow: 0 12px 30px rgb(35 48 43 / .16);
}
.parent-combobox-results li { padding: 9px 10px; border-radius: 8px; color: var(--text-primary); font-size: .82rem; cursor: pointer; }
.parent-combobox-results li:hover, .parent-combobox-results li.is-active { background: var(--accent-light); color: var(--accent-hover); }
.parent-combobox-results .parent-combobox-empty { color: var(--text-secondary); cursor: default; }

/* Full-size portrait viewer */
.media-viewer {
    width: 100vw; max-width: none; height: 100vh; max-height: none; margin: 0; padding: 64px 24px 28px;
    border: 0; background: rgb(12 20 22 / .94); color: white; overflow: hidden;
}
.media-viewer[open] { display: grid; place-items: center; }
.media-viewer::backdrop { background: rgb(5 10 12 / .72); backdrop-filter: blur(8px); }
.media-viewer figure { display: grid; gap: 14px; place-items: center; max-width: 100%; max-height: 100%; margin: 0; }
.media-viewer img {
    display: block; max-width: min(92vw, 1100px); max-height: calc(100vh - 130px); width: auto; height: auto;
    object-fit: contain; border-radius: 8px; box-shadow: 0 24px 70px rgb(0 0 0 / .48);
}
.media-viewer figcaption { max-width: 90vw; font: 600 1rem/1.3 'DM Sans', sans-serif; text-align: center; }
.media-viewer-close {
    position: fixed; z-index: 1; top: 18px; right: 18px; display: grid; width: 46px; height: 46px;
    place-items: center; padding: 0; border: 1px solid rgb(255 255 255 / .4); border-radius: 50%;
    background: rgb(20 30 32 / .7); color: white; cursor: pointer;
}
.media-viewer-close:hover { background: rgb(255 255 255 / .16); }
.media-viewer-close:focus-visible { outline: 3px solid rgb(255 255 255 / .7); outline-offset: 3px; }

/* PDF export choice */
.pdf-export-dialog {
    position: fixed; inset: 0; width: min(760px, calc(100% - 2rem)); max-height: calc(100dvh - 2rem);
    margin: auto; padding: 0; border: 1px solid #ded4c6; border-radius: 22px;
    background: #fffdf8; color: var(--text-primary); box-shadow: 0 26px 80px rgb(23 36 59 / .28);
}
.pdf-export-dialog::backdrop { background: rgb(15 30 42 / .58); backdrop-filter: blur(4px); }
.pdf-export-dialog form { max-height: calc(100dvh - 2rem); padding: 26px; overflow-y: auto; }
.pdf-export-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.pdf-export-heading h2 { margin: 3px 0 5px; font: 700 1.8rem/1.05 'Cormorant Garamond', Georgia, serif; color: #164f55; }
.pdf-export-heading p { margin: 0; color: var(--text-secondary); font-size: .88rem; }
.pdf-export-close {
    display: grid; flex: 0 0 36px; width: 36px; height: 36px; place-items: center; padding: 0;
    border: 1px solid #e3d9cc; border-radius: 50%; background: #fff; color: #58636a; font-size: 1.45rem; cursor: pointer;
}
.pdf-export-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-top: 23px; }
.pdf-export-option {
    position: relative; display: grid; grid-template-rows: 116px auto; min-width: 0; overflow: hidden;
    border: 1px solid #ddd5c9; border-radius: 16px; background: #fff; cursor: pointer;
    transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}
.pdf-export-option:hover { transform: translateY(-2px); border-color: #89b9b5; box-shadow: 0 10px 26px rgb(31 66 61 / .12); }
.pdf-export-option:has(input:checked) { border-color: #078b8c; box-shadow: 0 0 0 3px rgb(7 139 140 / .14); }
.pdf-export-option input { position: absolute; top: 12px; right: 12px; z-index: 2; width: 18px; height: 18px; accent-color: #078b8c; }
.pdf-export-preview { position: relative; display: block; overflow: hidden; border-bottom: 1px solid #ece5da; background: #f5f0e8; }
.pdf-export-preview::before, .pdf-export-preview::after { content: ''; position: absolute; background: #80aaa7; }
.pdf-export-preview::before { left: 50%; top: 23px; width: 1px; height: 58px; }
.pdf-export-preview::after { left: 24%; right: 24%; top: 55px; height: 1px; }
.pdf-export-preview span { position: absolute; z-index: 1; border: 1px solid #c9bda9; border-radius: 5px; background: #fffdf8; box-shadow: 0 2px 5px rgb(50 39 28 / .08); }
.pdf-export-preview-illustrated span { width: 43px; height: 29px; }
.pdf-export-preview-illustrated span::before { content: ''; position: absolute; top: 4px; left: 50%; width: 9px; height: 9px; border-radius: 50%; background: #d9d4ca; transform: translateX(-50%); }
.pdf-export-preview-illustrated span::after { content: ''; position: absolute; right: 7px; bottom: 5px; left: 7px; height: 3px; border-radius: 4px; background: #b8a98e; }
.pdf-export-preview-illustrated span:nth-child(1) { top: 9px; left: calc(50% - 21px); }
.pdf-export-preview-illustrated span:nth-child(2) { top: 69px; left: 20%; }
.pdf-export-preview-illustrated span:nth-child(3) { top: 69px; left: calc(40% - 5px); }
.pdf-export-preview-illustrated span:nth-child(4) { top: 69px; right: calc(40% - 5px); }
.pdf-export-preview-illustrated span:nth-child(5) { top: 69px; right: 20%; }
.pdf-export-preview-compact { background: #edf5f3; }
.pdf-export-preview-compact::before { top: 50%; right: 12%; bottom: auto; left: 12%; width: auto; height: 1px; }
.pdf-export-preview-compact::after { top: 18%; bottom: 18%; left: 43%; right: auto; width: 1px; height: auto; }
.pdf-export-preview-compact span { width: 34px; height: 14px; }
.pdf-export-preview-compact span::after { content: ''; position: absolute; inset: 5px 5px auto; height: 3px; border-radius: 3px; background: #3d7e7b; }
.pdf-export-preview-compact span:nth-child(1) { top: 44%; left: 4%; }
.pdf-export-preview-compact span:nth-child(2) { top: 20%; left: 29%; }
.pdf-export-preview-compact span:nth-child(3) { top: 68%; left: 29%; }
.pdf-export-preview-compact span:nth-child(4) { top: 7%; left: 55%; }
.pdf-export-preview-compact span:nth-child(5) { top: 35%; left: 55%; }
.pdf-export-preview-compact span:nth-child(6) { top: 63%; left: 76%; }
.pdf-export-preview-compact span:nth-child(7) { top: 82%; left: 76%; }
.pdf-export-option-copy { display: grid; gap: 5px; padding: 16px 17px 17px; }
.pdf-export-option-copy strong { font: 700 1.08rem/1.1 'Cormorant Garamond', Georgia, serif; color: #173f44; }
.pdf-export-option-copy > span { color: #4f5a61; font-size: .79rem; line-height: 1.45; }
.pdf-export-option-copy small { margin-top: 3px; color: #087b7d; font-size: .69rem; font-weight: 700; }
.pdf-export-summary { min-height: 1.25em; margin: 17px 0 0; color: #566167; font-size: .76rem; text-align: center; }
.pdf-export-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

#database-export-form { display: grid; gap: 16px; }
#database-export-form p { margin: 0; color: var(--text-secondary); font-size: .88rem; }
#database-export-status:empty { display: none; }
#database-export-format { width: 100%; padding: 12px; border: 1px solid #b7cdcd; border-radius: 8px; background: white; color: #173f44; font: inherit; }
.database-export-actions { display: flex; justify-content: center; gap: 10px; }
.database-export-actions button { padding: 12px 22px; border: 1px solid #b7cdcd; border-radius: 8px; background: white; color: #173f44; font: inherit; cursor: pointer; }
#database-export-form [type="submit"] { border-color: #164f55; background: #164f55; color: white; }
#database-export-form [type="submit"]:disabled { opacity: .6; cursor: wait; }

@media (max-width: 620px) {
    .pdf-export-dialog form { padding: 20px; }
    .pdf-export-options { grid-template-columns: 1fr; }
    .pdf-export-option { grid-template-columns: 116px 1fr; grid-template-rows: auto; }
    .pdf-export-preview { min-height: 125px; border-right: 1px solid #ece5da; border-bottom: 0; }
    .pdf-export-heading h2 { font-size: 1.55rem; }
}

/* Administration dialog */
.person-editor {
    border: 1px solid #e5d9c9; border-radius: 20px; background: var(--bg-panel);
    color: var(--text-primary); box-shadow: var(--shadow-lg);
}
.person-editor::backdrop { background: rgb(23 36 60 / .38); backdrop-filter: blur(5px); }
#person-editor {
    max-height: calc(100dvh - 2rem);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-gutter: stable;
    scrollbar-width: thin;
    scrollbar-color: #82aaa5 #f3eee6;
}
#person-editor > form { max-height: none; overflow: visible; }
#person-editor::-webkit-scrollbar { width: 8px; }
#person-editor::-webkit-scrollbar-track { background: #f3eee6; border-radius: 10px; }
#person-editor::-webkit-scrollbar-thumb {
    background: #82aaa5; border: 2px solid #f3eee6; border-radius: 10px;
}
#person-editor::-webkit-scrollbar-thumb:hover { background: var(--accent-color); }
#person-editor::-webkit-scrollbar-button { display: none; }
.editor-heading { border-bottom-color: #e8dfd3; }
.editor-heading h2 { font-family: 'Cormorant Garamond', Georgia, serif; }
.editor-fields input, .editor-fields select, .login-panel input {
    border-color: #dfd4c5; border-radius: 10px; background: #fffefa;
}
.editor-fields input:focus, .editor-fields select:focus, .login-panel input:focus { border-color: var(--accent-color); }
.secondary-btn { background: #eee7dc; color: #4d5558; }
.secondary-btn.danger,
#delete-person-btn {
    border: 1px solid #f1c7c3;
    background: #fdf5f4;
    color: #a13931;
    font-weight: 600;
}
#delete-person-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0.65rem 1rem;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color var(--trans-fast), border-color var(--trans-fast), color var(--trans-fast), transform var(--trans-fast);
}
#delete-person-btn .material-symbols-rounded {
    font-size: 19px;
}
#delete-person-btn:hover {
    background: #fce8e6;
    border-color: #e8aba5;
    color: #852e28;
    transform: translateY(-1px);
}
#delete-person-btn:active {
    transform: translateY(0);
}
#delete-person-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Enhanced Gender dropdown */
.gender-select-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
    min-width: 0;
    border-radius: 10px;
    background: #fffefa;
    border: 1px solid #dfd4c5;
    box-shadow: 0 1px 2px rgb(20 30 25 / .04);
    transition: border-color var(--trans-fast), box-shadow var(--trans-fast), background-color var(--trans-fast);
}
.gender-select-wrapper:hover {
    border-color: #c9bdae;
}
.gender-select-wrapper:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgb(0 143 144 / .14);
}
.gender-select-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    font-size: 20px;
    color: var(--text-secondary);
    pointer-events: none;
    transition: color var(--trans-fast), transform var(--trans-fast);
}
.gender-select-wrapper[data-gender="M"] .gender-select-icon,
.gender-select-icon.gender-male {
    color: #1e6fa0;
}
.gender-select-wrapper[data-gender="F"] .gender-select-icon,
.gender-select-icon.gender-female {
    color: #c0436f;
}
.gender-select-wrapper[data-gender="X"] .gender-select-icon,
.gender-select-icon.gender-other {
    color: #557571;
}
.gender-select-wrapper select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 100% !important;
    min-width: 0;
    min-height: 42px;
    padding: 8px 34px 8px 38px !important;
    border: 0 !important;
    border-radius: 10px;
    background: transparent !important;
    color: var(--text-primary);
    font-size: .88rem;
    font-weight: 600;
    cursor: pointer;
    outline: none !important;
    box-shadow: none !important;
}
.gender-select-arrow {
    position: absolute;
    right: 9px;
    top: 50%;
    transform: translateY(-50%);
    color: #72807f;
    font-size: 22px;
    pointer-events: none;
    transition: color var(--trans-fast), transform var(--trans-fast);
}
.gender-select-wrapper:focus-within .gender-select-arrow {
    color: var(--accent-color);
}

@media (max-width: 1000px) {
    .app-header { gap: 15px; padding: 0 18px; }
    .logo { width: auto; min-width: auto; padding-right: 16px; }
    .logo-copy { display: none; }
    .logo-mark { flex-basis: 29px; width: 29px; height: 60px; }
    .logo-mark img { height: 60px; }
    .search-container { max-width: 270px; }
    .family-tree-filter select { min-width: 180px; }
}
.detail-summary .detail-section { margin-bottom: 0; }

@media (max-width: 768px) {
    :root { --header-height: 64px; }
    #user-menu-name { display: none; }
    #user-menu-initials { display: inline; }
    .app-header {
        position: fixed; padding: 0 10px; gap: 9px; background: rgb(255 253 249 / .88);
        border-bottom: 1px solid #e8ded0;
    }
    .app-header::after { height: 2px; }
    .logo { display: none; }
    .logo-mark { flex-basis: 21px; width: 21px; height: 44px; }
    .logo-mark img { height: 44px; }
    .search-container { display: none; max-width: none; }
    .search-container input { min-height: 40px; font-size: .72rem; }
    .family-tree-filter { flex: 1 1 auto; min-width: 0; }
    .family-tree-filter > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
    .family-tree-filter select { width: 100%; min-width: 0; min-height: 40px; padding: .5rem 30px .5rem 10px; font-size: .68rem; }
    .family-tree-filter select option { font-size: .78rem; }
    .mobile-search-toggle, .mobile-family-toggle {
        flex: 0 0 42px; width: 42px; height: 42px; place-items: center; padding: 0;
        color: var(--army-green); border: 1px solid #dcd7ca; border-radius: 12px;
        background: #fffdfa; cursor: pointer;
    }
    .mobile-search-toggle { display: grid; }
    .mobile-family-toggle .material-symbols-rounded,
    .mobile-search-toggle .material-symbols-rounded { font-size: 21px; }
    .mobile-search-open .family-tree-filter, .mobile-search-open .mobile-search-toggle { display: none; }
    .mobile-search-open .mobile-family-toggle { display: grid; }
    .mobile-search-open .search-container { display: block; flex: 1 1 auto; min-width: 0; }
    body[data-mode="map"] .mobile-search-toggle,
    body[data-mode="map"] .mobile-family-toggle,
    body[data-mode="relationship"] .mobile-search-toggle,
    body[data-mode="relationship"] .mobile-family-toggle,
    body[data-mode="admin"] .mobile-search-toggle,
    body[data-mode="admin"] .mobile-family-toggle,
    body[data-mode="albums"] .mobile-search-toggle,
    body[data-mode="albums"] .mobile-family-toggle { display: none !important; }
    .admin-view,
    .albums-view {
        position: fixed;
        inset: var(--header-height) 0 0;
        -webkit-overflow-scrolling: touch;
    }
    .header-action { min-height: 40px; padding: .55rem .75rem; font-size: .75rem; }
    .header-actions { position: relative; margin-left: auto; }
    body[data-mode="relationship"] .header-actions { margin-left: 0; }
    body[data-mode="relationship"] .mobile-relationship-back-btn {
        display: none !important;
    }
    .mobile-relationship-back-btn .material-symbols-rounded { font-size: 19px; }
    .mobile-relationship-back-btn:active { transform: scale(.97); }
    .mobile-relationship-back-btn:disabled { opacity: .55; cursor: wait; }
    .mobile-menu-toggle {
        width: 42px; height: 42px; display: grid; place-items: center; padding: 0; color: var(--army-green);
        border: 1px solid #dcd7ca; border-radius: 12px; background: #f7f6ed; cursor: pointer;
        transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
    }
    .mobile-menu-toggle:active { transform: scale(0.91); }
    .mobile-menu-toggle:hover, .mobile-menu-toggle[aria-expanded="true"] { color: white; border-color: var(--accent-color); background: var(--accent-color); }
    .mobile-menu-toggle:focus-visible { outline: 3px solid rgb(15 139 143 / .22); outline-offset: 2px; }
    .mobile-menu-toggle .hamburger-icon { overflow: visible; display: block; }
    .mobile-menu-toggle .hamburger-icon .line {
        transform-origin: 12px 12px;
        transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1),
                    opacity 0.22s ease,
                    stroke 0.25s ease;
    }
    .mobile-menu-toggle[aria-expanded="true"] .hamburger-icon .line-top {
        transform: translateY(5px) rotate(45deg);
    }
    .mobile-menu-toggle[aria-expanded="true"] .hamburger-icon .line-middle {
        opacity: 0;
        transform: scaleX(0);
    }
    .mobile-menu-toggle[aria-expanded="true"] .hamburger-icon .line-bottom {
        transform: translateY(-5px) rotate(-45deg);
    }
    .mode-switch { width: 40px; padding: .5rem; }
    .mode-switch span { display: none; }
    .merina-source-note { top: 76px; right: 10px; width: auto; max-width: 235px; padding: 10px 12px; }
    @media (orientation: portrait) {
        .merina-source-note { right: auto; left: 10px; }
    }
    .merina-source-note strong { font-size: .72rem; }
    .historical-node { min-height: 0; padding: 15px 10px 14px; }
    .person-node.active { padding-top: .5rem; }
    .person-node.active::before { display: block; }
    .tree-controls {
        top: auto;
        right: auto;
        bottom: calc(15vh + var(--footer-height) + 12px);
        left: 50%;
        transform: translateX(-50%);
        flex-direction: row;
        padding: 4px;
        gap: 2px;
    }
    .app-main:has(.person-details.hidden) .tree-controls { bottom: calc(var(--footer-height) + 12px); }
    .app-main:has(.person-details.expanded) .tree-controls { bottom: calc(50vh + var(--footer-height) + 12px); }
    .control-btn { width: 34px; height: 34px; min-height: 34px; padding: .4rem; }
    .control-btn + .control-btn { border-top: 0; border-radius: 9px; }
    .person-details {
        height: 15vh;
        min-height: 0;
        border-radius: 18px 18px 0 0;
    }
    .person-details::before {
        inset: 0 auto auto 50%;
        width: 28px;
        height: 28px;
    }
    .person-details .close-btn { top: 14px; right: 14px; }
    .details-content {
        padding: 27px 12px max(6px, env(safe-area-inset-bottom)) 12px;
        scroll-padding-top: 27px;
        gap: 9px;
    }
    .detail-header { grid-template-columns: auto minmax(0, 1fr); flex-basis: auto; gap: 9px; padding-right: 44px; }
    .detail-header:not(:has(.detail-avatar)) { grid-template-columns: 1fr; padding-left: 44px; }
    .detail-section { flex-basis: auto; max-height: none; padding: 7px 9px; }
    .detail-meta { font-size: .7rem; }
}

@media (max-width: 768px) and (orientation: portrait) {
    .orientation-toggle-btn { display: flex; }
    body .app-header > .header-actions {
        order: -1;
        flex: 0 0 auto;
        margin-inline: 0;
        justify-content: flex-start;
    }
    .header-actions-menu {
        right: auto;
        left: 0;
    }
    /* Match the fixed person sheet's viewport, even when browser chrome
       makes the tree's 100vh taller than the visible mobile viewport. */
    .generation-actions {
        position: fixed;
        right: max(12px, env(safe-area-inset-right));
        transition: bottom var(--trans-normal);
    }
    .person-details:not(.expanded) .details-content {
        padding-top: 15px;
        scroll-snap-type: none;
    }
}

@media (max-width: 900px) {
    .relative-group { grid-column: span 6; }
    .relative-group-children { grid-column: 1 / -1; }
}
@media (max-width: 640px) {
    .admin-shell { width: min(100% - 24px, 1240px); padding-top: 24px; }
    .admin-summary, .admin-family-grid, .admin-anomaly-grid, .admin-birthday-card ul { grid-template-columns: 1fr; }
    .admin-birthday-card li:nth-child(odd) { border-right: 0; }
    .admin-anomaly-card li { flex-direction: column; }
    .admin-anomaly-card li small { text-align: left; }
    .inline-person-form { grid-template-columns: 1fr; padding: 12px; }
    .inline-person-form .full-field { grid-column: 1; }
    .person-editor {
        width: min(720px, calc(100% - 16px));
        max-height: calc(100dvh - 16px);
        border-radius: 18px;
        box-sizing: border-box;
    }
    #person-editor {
        max-height: calc(100dvh - 16px);
        scrollbar-gutter: auto;
        overflow-x: hidden;
    }
    .person-editor form,
    #person-editor > form {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        padding: 16px 14px;
        box-sizing: border-box;
        overflow-x: hidden;
    }
    .editor-heading {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
        gap: 10px;
        margin-bottom: 1rem;
    }
    .editor-heading h2 {
        font-size: 1.35rem;
        min-width: 0;
    }
    .editor-fields, .parents-fields {
        grid-template-columns: minmax(0, 1fr);
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
        gap: 12px;
    }
    .person-field-group {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
        padding-top: 12px;
    }
    .person-field-row {
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
        gap: 10px;
    }
    .person-field-row + .person-field-row { margin-top: 10px; }
    .person-field-row > label {
        flex: 1 1 100%;
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }
    .person-field-row > label[class] {
        flex: 1 1 100%;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    .person-field-row > label.person-field-gender {
        flex: 1 1 100%;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    .person-field-row > label.person-field-rank {
        flex: 1 1 100%;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    .gender-select-wrapper {
        min-height: 48px;
        border-radius: 12px;
        background: #ffffff;
        border: 1.5px solid #dcd4c7;
        box-shadow: 0 1px 3px rgb(30 40 35 / .06);
    }
    .gender-select-wrapper select {
        min-height: 48px;
        font-size: 16px !important;
        font-weight: 600;
        padding: 11px 38px 11px 44px !important;
        color: var(--text-primary);
    }
    .gender-select-icon {
        left: 12px;
        font-size: 24px;
        width: 26px;
        height: 26px;
    }
    .gender-select-arrow {
        right: 11px;
        font-size: 24px;
    }
    .person-field-row > label.person-field-date,
    .person-field-row > label.person-field-year,
    .person-field-row > label.person-field-place,
    .person-field-row > label.person-field-avatar,
    .person-field-row > label.person-field-id,
    .person-field-row > label.person-field-spouses,
    .person-field-row > label.person-field-parent,
    .person-field-row > label.person-field-name,
    .person-field-row > label.person-field-nickname,
    .person-field-row > label.person-field-status {
        flex: 1 1 100%;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    .person-field-row input,
    .person-field-row select,
    .editor-fields input,
    .editor-fields select {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }
    .editor-actions {
        display: flex;
        flex-direction: column-reverse;
        align-items: stretch;
        gap: 10px;
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
    }
    .editor-submit-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        width: 100%;
        min-width: 0;
    }
    .parents-fields .editor-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        flex-direction: row;
    }
    .editor-actions button,
    .editor-submit-actions button {
        width: 100%;
        min-height: 42px;
    }
    #delete-person-btn {
        min-height: 44px;
        font-size: .92rem;
        border-radius: 12px;
    }
    .inline-editor-actions { align-items: stretch; flex-direction: column-reverse; }
    .inline-editor-actions > div { display: grid; grid-template-columns: 1fr 1fr; }
    .inline-editor-actions > button { width: 100%; }
    .relative-groups { grid-template-columns: 1fr; }
    .relative-group, .relative-group-children { grid-column: 1; }
}

/* Compact navigation for phones held in landscape, including wider devices. */
@media (orientation: landscape) and (max-width: 1180px) and (max-height: 820px) {
    :root { --header-height: 0px; }
    #user-menu-name { display: none; }
    #user-menu-initials { display: inline; }
    .app-header {
        position: fixed; top: max(10px, env(safe-area-inset-top)); right: auto; bottom: auto;
        left: calc(max(10px, env(safe-area-inset-left)) + 52px); right: max(10px, env(safe-area-inset-right));
        width: auto; height: auto; padding: 0; gap: 8px;
        background: transparent; border: 0; box-shadow: none;
        backdrop-filter: none; -webkit-backdrop-filter: none;
    }
    body[data-mode="map"] .app-header,
    body[data-mode="relationship"] .app-header,
    body[data-mode="admin"] .app-header,
    body[data-mode="albums"] .app-header {
        left: max(10px, env(safe-area-inset-left));
    }
    .app-header::after, .logo, .mobile-search-toggle, .mobile-family-toggle { display: none; }
    body .app-header > .header-actions {
        position: relative;
        order: -1;
        flex: 0 0 auto;
        margin: 0;
        justify-content: flex-start;
    }
    .mobile-menu-toggle {
        width: 42px; height: 42px; display: grid; place-items: center; padding: 0; color: var(--army-green);
        border: 1px solid #dcd7ca; border-radius: 12px; background: #f7f6ed; cursor: pointer;
    }
    .mobile-menu-toggle:hover, .mobile-menu-toggle[aria-expanded="true"] {
        color: white; border-color: var(--accent-color); background: var(--accent-color);
    }
    .app-header .family-tree-filter:not(.hidden) {
        display: flex; flex: 1 1 180px; min-width: 0; max-width: 200px;
    }
    .app-header .family-tree-filter > span {
        position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0);
    }
    /* Search bar is hidden by default in landscape; the landscape toggle opens it. */
    .app-header .search-container:not(.hidden) { display: none; }
    .app-header .search-container input { width: 100%; min-width: 0; min-height: 42px; }

    /* Landscape search toggle */
    .landscape-search-toggle:not(.tree-controls *) {
        display: grid;
        position: fixed;
        top: calc(max(10px, env(safe-area-inset-top)) + 52px);
        left: max(10px, env(safe-area-inset-left));
        z-index: var(--z-header);
        width: 42px; height: 42px;
        place-items: center; padding: 0;
        color: var(--army-green);
        border: 1px solid #dcd7ca; border-radius: 12px;
        background: #f7f6ed; cursor: pointer;
        transition: all var(--trans-fast);
    }
    .landscape-search-toggle .material-symbols-rounded { font-size: 21px; }
    .landscape-search-toggle:hover,
    .landscape-search-toggle[aria-expanded="true"] {
        color: white; border-color: var(--accent-color); background: var(--accent-color);
    }
    body[data-mode="map"] .landscape-search-toggle,
    body[data-mode="relationship"] .landscape-search-toggle,
    body[data-mode="admin"] .landscape-search-toggle,
    body[data-mode="albums"] .landscape-search-toggle { display: none; }

    /* Floating search bar that opens to the right of the magnifying glass */
    .landscape-search-open .app-header .search-container:not(.hidden) {
        display: block;
        position: fixed;
        top: var(--landscape-search-top, calc(max(10px, env(safe-area-inset-top)) + 40px));
        left: var(--landscape-search-left, calc(max(10px, env(safe-area-inset-left)) + 52px));
        z-index: var(--z-header);
        width: min(280px, calc(100vw - max(10px, env(safe-area-inset-left)) - 72px));
        max-width: none;
        margin: 0;
        animation: landscape-search-slide-in 200ms ease-out;
    }
    .landscape-search-open .app-header .search-container input {
        min-height: 36px;
        height: 36px;
        padding-top: 0;
        padding-bottom: 0;
        font-size: .8rem;
        border-radius: 11px;
        box-shadow: 0 6px 24px rgb(30 42 45 / .18);
    }
    .landscape-search-open .app-header .search-container .search-results:not(.hidden) {
        max-height: min(260px, calc(100vh - max(10px, env(safe-area-inset-top)) - 90px));
    }

    @keyframes landscape-search-slide-in {
        from { opacity: 0; transform: translateX(-12px); }
        to { opacity: 1; transform: translateX(0); }
    }
    .header-actions-menu .header-action { width: 100%; min-height: 40px; justify-content: flex-start; gap: 10px; }
    .header-actions-menu .mode-switch { padding: .55rem .75rem; }
    .header-actions-menu .mode-switch span { display: inline; }
    .header-actions-menu #relationship-mode-btn { order: 1; width: 100%; padding: .55rem .75rem; }
    .header-actions-menu #relationship-mode-btn span { display: inline; }
    .header-actions-menu #map-mode-btn { display: none; }
    .header-actions-menu #dynasty-mode-btn { order: 3; }
    .header-actions-menu #manage-persons-btn { display: flex; }

    .merina-source-note {
        top: max(10px, env(safe-area-inset-top));
        right: auto;
        left: calc(max(10px, env(safe-area-inset-left)) + 52px);
        width: auto;
        max-width: min(235px, calc(100% - 80px));
        padding: 8px 12px;
    }
    .merina-source-note strong { font-size: .72rem; }

    /* Unified parent frame grouping all action buttons on mobile landscape */
    .tree-controls,
    .app-main:has(.person-details.hidden) .tree-controls,
    .app-main:has(.person-details.expanded) .tree-controls {
        z-index: calc(var(--z-details) + 1);
        top: max(10px, env(safe-area-inset-top));
        right: auto;
        bottom: auto;
        left: max(10px, env(safe-area-inset-left));
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0;
        width: 42px;
        padding: 4px;
        box-sizing: border-box;
        border: 1px solid #dcd7ca;
        border-radius: 14px;
        background: #f7f6ed;
        box-shadow: 0 10px 26px rgb(50 39 28 / .14);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        transform: none;
    }
    .tree-controls .control-btn,
    .tree-controls .mobile-menu-toggle,
    .tree-controls .landscape-search-toggle {
        width: 34px;
        height: 34px;
        min-height: 34px;
        padding: 0;
        margin: 0 auto;
        display: grid;
        place-items: center;
        border: 0;
        border-radius: 9px;
        background: transparent;
        color: var(--accent-color);
        box-shadow: none;
        cursor: pointer;
        position: static;
        flex: 0 0 34px;
        transition: background-color var(--trans-fast), color var(--trans-fast);
    }
    .tree-controls > button + button {
        border-top: 1px solid #ece4d8;
        border-radius: 0;
        margin-top: 2px;
        padding-top: 2px;
    }
    .tree-controls .control-btn:hover,
    .tree-controls .mobile-menu-toggle:hover,
    .tree-controls .landscape-search-toggle:hover {
        background: var(--accent-light);
        color: var(--accent-hover);
        border-radius: 9px;
        box-shadow: none;
        transform: none;
    }
    .tree-controls .mobile-menu-toggle[aria-expanded="true"],
    .tree-controls .landscape-search-toggle[aria-expanded="true"] {
        background: var(--accent-color);
        color: #ffffff;
        border-radius: 9px;
    }
    .tree-controls .mobile-menu-toggle[aria-expanded="true"] .hamburger-icon {
        color: #ffffff;
    }
    .tree-controls .mobile-menu-toggle .hamburger-icon {
        width: 20px;
        height: 20px;
        color: var(--accent-color);
    }
    .tree-controls .control-btn .material-symbols-rounded,
    .tree-controls .landscape-search-toggle .material-symbols-rounded {
        display: inline-block;
        font-size: 20px;
    }
    .orientation-toggle-btn { display: flex; }
}

@media (max-width: 560px) {
    .mobile-search-open .search-container { flex: 1; max-width: none; }
    .person-node.active { padding-top: .375rem; }
    .historical-node { min-height: 0; }
    .detail-section { padding: 7px 9px; }
}

@media (max-width: 380px) {
    .logo { display: none; }
    .header-action { padding-inline: .62rem; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
    .person-node.active { animation: none; }
}

/* Interactive royal residences map */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.royal-map-view { flex: 1; min-width: 0; display: grid; grid-template-columns: 370px minmax(0, 1fr); background: #e8ebe7; overflow: hidden; }
.map-sidebar { position: relative; z-index: 3; display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 28px 22px 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-color: #b9c0bd transparent; scrollbar-width: thin; background: #fffdf9; border-right: 1px solid #ddd8ce; box-shadow: 12px 0 35px rgb(24 35 45 / .08); }
.map-sidebar::-webkit-scrollbar { width: 8px; }
.map-sidebar::-webkit-scrollbar-thumb { border: 2px solid transparent; border-radius: 999px; background: #b9c0bd; background-clip: padding-box; }
.map-sidebar-heading { padding: 0 4px 20px; }
.map-eyebrow { display: block; margin-bottom: 7px; color: var(--army-green); font-size: .64rem; font-weight: 800; letter-spacing: .17em; text-transform: uppercase; }
.map-sidebar h2 { color: var(--text-primary); font: 700 1.42rem/1.25 'Cormorant Garamond', Georgia, serif; letter-spacing: -.025em; }
.map-sidebar-heading p { margin-top: 9px; color: var(--text-secondary); font-size: .79rem; line-height: 1.55; }
.map-search { position: relative; display: flex; align-items: center; margin: 0 4px 13px; }
.map-search svg { position: absolute; left: 13px; z-index: 1; color: #7d8688; pointer-events: none; }
.map-search input { width: 100%; height: 43px; padding: 0 12px 0 39px; color: var(--text-primary); border: 1px solid #ddd9d0; border-radius: 11px; outline: 0; background: #faf9f5; font-size: .78rem; transition: border-color var(--trans-fast), box-shadow var(--trans-fast); }
.map-search input:focus { border-color: #268ad6; box-shadow: 0 0 0 3px rgb(38 138 214 / .12); background: white; }
.map-search-results { position:absolute; z-index:1000; top:128px; right:26px; left:26px; max-height:310px; margin:0; padding:6px; overflow:auto; list-style:none; border:1px solid #ddd8ce; border-radius:12px; background:white; box-shadow:0 14px 35px rgb(25 35 45/.18); }
.map-search-results button { width:100%; display:grid; gap:2px; min-height:52px; padding:8px 10px; text-align:left; border:0; border-radius:8px; background:transparent; cursor:pointer; }
.map-search-results button:is(:hover,.active,:focus-visible) { background:#edf7ff; }
.map-search-results strong { color:#223246; font:.78rem 'Cormorant Garamond',serif; }.map-search-results span,.map-search-results small { color:#718086; font-size:.61rem; }.map-search-results small { color:#a05d24; }
.map-era-filters { display: flex; gap: 5px; padding: 0 4px 15px; overflow-x: auto; scrollbar-width: none; }
.map-era-filters::-webkit-scrollbar { display: none; }
.map-era-filters button { flex: 0 0 auto; padding: 6px 9px; color: #667175; border: 1px solid #deddd7; border-radius: 999px; background: white; font-size: .64rem; font-weight: 700; cursor: pointer; transition: all var(--trans-fast); }
.map-era-filters button:hover { border-color: #9fc5e5; color: #1879c5; }
.map-era-filters button.active { color: white; border-color: #1879c5; background: #1879c5; box-shadow: 0 4px 10px rgb(24 121 197 / .2); }
.map-time-modes,.map-layer-controls { display:flex; gap:5px; margin:0 4px 9px; }
.map-time-modes button,.map-layer-controls button { flex:1; min-height:34px; padding:5px 7px; color:#5f6b70; border:1px solid #d9ddd9; border-radius:8px; background:white; font-size:.61rem; font-weight:700; cursor:pointer; }
.map-time-modes button.active,.map-layer-controls button.active { color:#086eb9; border-color:#9fcbe9; background:#edf7ff; }
.map-date-filter { margin: 0 4px 14px; padding: 11px 12px 8px; border: 1px solid #e2dfd7; border-radius: 11px; background: #faf9f5; }
.map-date-heading, .map-date-bounds { display: flex; align-items: center; justify-content: space-between; }
.map-date-heading label { color: #526065; font-size: .65rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.map-date-stepper { display: flex; align-items: center; gap: 5px; }
.map-date-heading output { min-width: 34px; color: #147abb; font-size: .7rem; font-weight: 800; font-variant-numeric: tabular-nums; text-align: center; }
.map-date-heading input { width:68px; height:30px; padding:2px 5px; color:#147abb; text-align:center; border:1px solid #cbdde9; border-radius:7px; background:white; font-size:.72rem; font-weight:800; }
.map-date-filter > small { display:block; margin-top:3px; color:#788184; font-size:.54rem; }
.map-date-marks { position:absolute; inset:8px 8px auto; height:12px; pointer-events:none; }.map-date-marks i { position:absolute; width:1px; height:6px; background:#6f8fa5; }
.map-sidebar-actions { display:flex; justify-content:space-between; gap:6px; margin:0 4px 8px; }.map-sidebar-actions button,.map-expand-btn { min-height:36px; padding:6px 9px; color:#286580; border:1px solid #cbdde9; border-radius:8px; background:white; font-size:.61rem; font-weight:700; cursor:pointer; }.map-sidebar-actions #map-panel-toggle { display:none; }
.map-period-summary { margin:0 5px 5px; color:#374c55; font-size:.68rem; font-weight:700; }
.map-date-stepper button { width: 25px; height: 25px; display: grid; place-items: center; padding: 0; color: #147abb; border: 1px solid #cbdde9; border-radius: 7px; background: white; cursor: pointer; transition: color var(--trans-fast), border-color var(--trans-fast), background var(--trans-fast); }
.map-date-stepper button:hover:not(:disabled) { color: white; border-color: #147abb; background: #147abb; }
.map-date-stepper button:focus-visible { outline: 3px solid rgb(33 135 207 / .22); outline-offset: 1px; }
.map-date-stepper button:disabled { color: #aeb7ba; border-color: #e1e3e1; background: #f3f3f0; cursor: default; }
.map-date-stepper .material-symbols-rounded { font-size: 18px; }
.map-date-slider { position: relative; height: 28px; margin-top: 4px; touch-action: none; }
.map-date-track { position: absolute; top: 12px; right: 0; left: 0; height: 4px; overflow: visible; border-radius: 999px; background: #d7d9d6; }
.map-date-track span { position: absolute; top: 0; bottom: 0; border-radius: inherit; background: #2187cf; left: 0; pointer-events: none; }
.map-date-filter input[type="range"] { position: absolute; top: 5px; left: 0; width: 100%; height: 18px; margin: 0; appearance: none; -webkit-appearance: none; outline: none; background: transparent; cursor: pointer; }
.map-date-filter input[type="range"]::-webkit-slider-thumb { width: 17px; height: 17px; appearance: none; -webkit-appearance: none; border: 3px solid white; border-radius: 50%; background: #147abb; box-shadow: 0 0 0 1px #147abb, 0 2px 5px rgb(20 87 135 / .3); cursor: ew-resize; pointer-events: auto; }
.map-date-filter input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border: 3px solid white; border-radius: 50%; background: #147abb; box-shadow: 0 0 0 1px #147abb, 0 2px 5px rgb(20 87 135 / .3); cursor: ew-resize; pointer-events: auto; }
.map-date-filter input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgb(33 135 207 / .22); }
.map-date-bounds { margin-top: -2px; color: #919697; font-size: .56rem; font-variant-numeric: tabular-nums; }
.map-results-count { padding: 0 5px 10px; color: #8b9192; font-size: .65rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.map-ruler-list { flex: 0 0 auto; min-height: 0; margin: 0 -4px; padding: 0 4px 28px; overflow: visible; }
.map-ruler-card { width: 100%; display: grid; grid-template-columns: 38px 1fr 16px; align-items: center; gap: 11px; min-height: 66px; margin-bottom: 6px; padding: 9px 10px; color: var(--text-primary); text-align: left; border: 1px solid transparent; border-radius: 12px; background: transparent; cursor: pointer; transition: all var(--trans-fast); }
.map-ruler-card:hover { border-color: #e4e0d7; background: white; box-shadow: 0 5px 15px rgb(34 41 48 / .07); transform: translateX(2px); }
.map-ruler-card.selected { border-color: #bdd9ee; background: #edf7ff; }
.map-ruler-card > svg { color: #a0a7a8; }
.ruler-initial { width: 38px; height: 38px; display: grid; place-items: center; color: white; border-radius: 50%; background: linear-gradient(145deg, #248fdc, #086eb9); box-shadow: 0 4px 9px rgb(21 120 192 / .23); font: 700 .9rem/1 'Cormorant Garamond', serif; }
.ruler-copy { min-width: 0; display: grid; }
.ruler-copy strong { overflow: hidden; color: #223246; font: 700 .78rem/1.35 'Cormorant Garamond', Georgia, serif; text-overflow: ellipsis; white-space: nowrap; }
.ruler-copy small { overflow: hidden; margin-top: 2px; color: #7d8588; font-size: .62rem; text-overflow: ellipsis; white-space: nowrap; }
.ruler-copy span { margin-top: 3px; color: #1678bd; font-size: .65rem; font-weight: 700; }
.map-empty { display: grid; justify-items: center; gap: 5px; padding: 45px 20px; color: var(--text-secondary); text-align: center; }
.map-empty strong { color: var(--text-primary); font-family: 'Cormorant Garamond', serif; }
.map-empty span { font-size: .75rem; }
.map-canvas-wrap { position: relative; min-width: 0; min-height: 0; }
.royal-map { position: absolute; inset: 0; z-index: 1; background: #dfe8ea; }
.map-legend { position: absolute; z-index: 500; top: 22px; right: 22px; display: grid; grid-template-columns: 16px 1fr; column-gap: 9px; width: 260px; max-height:45%; overflow:auto; padding: 12px 14px; color: #253447; border: 1px solid rgb(216 224 226 / .9); border-radius: 12px; background: rgb(255 255 255 / .92); box-shadow: 0 8px 22px rgb(21 36 46 / .12); backdrop-filter: blur(10px); }
#map-territory-legend { grid-column:1/-1; display:grid; gap:5px; margin-top:9px; padding-top:8px; border-top:1px solid #e2e7e6; }#map-territory-legend span { display:flex; gap:7px; align-items:center; font-size:.58rem; }#map-territory-legend i { width:13px; height:8px; flex:none; border:2px solid var(--territory); background:repeating-linear-gradient(45deg,transparent 0 2px,var(--territory) 2px 3px); }#map-territory-legend small { font-size:.55rem; line-height:1.4; }
.map-expand-btn { display:none; position:absolute; z-index:500; bottom:12px; left:50%; transform:translateX(-50%); box-shadow:0 5px 15px rgb(20 30 40/.15); }
.royal-marker.selected { background:#c06718; box-shadow:0 0 0 4px rgb(192 103 24/.28); }
.map-person-detail { position:absolute; z-index:5; inset:auto 12px 12px; max-height:52%; padding:16px; overflow:auto; border:1px solid #ddd8ce; border-radius:14px; background:white; box-shadow:0 15px 35px rgb(20 30 40/.18); }.map-person-detail h3 { margin:3px 28px 5px 0; font:700 1.2rem 'Cormorant Garamond',serif; }.map-person-detail p { margin:7px 0; color:#5f696c; font-size:.68rem; line-height:1.5; }.map-person-detail img,.map-detail-placeholder { width:54px; height:54px; float:left; margin:0 11px 7px 0; object-fit:cover; border-radius:50%; }.map-detail-placeholder { display:grid; place-items:center; background:#edf2ef; font-size:1.5rem; }.map-detail-close { position:absolute; top:8px; right:8px; width:44px; height:44px; border:0; background:transparent; font-size:1.3rem; cursor:pointer; }.map-detail-sites { clear:both; display:grid; gap:3px; margin:9px 0; color:#286580; font-size:.62rem; }.map-genealogy-link { width:100%; min-height:44px; color:white; border:0; border-radius:9px; background:#167fc7; font-size:.68rem; font-weight:700; cursor:pointer; }
.legend-dot { grid-row: 1 / 3; align-self: center; width: 13px; height: 13px; border: 3px solid white; border-radius: 50%; background: #1688dc; box-shadow: 0 0 0 2px #1688dc, 0 2px 7px rgb(13 106 175 / .35); }
.map-legend strong { font-size: .7rem; }
.map-legend small { margin-top: 2px; color: #788184; font-size: .58rem; line-height: 1.4; }
.map-fit-btn { position: absolute; z-index: 500; top: 22px; left: 22px; width: 42px; height: 42px; display: grid; place-items: center; color: #354657; border: 1px solid #d5dee0; border-radius: 10px; background: white; box-shadow: 0 6px 18px rgb(21 36 46 / .14); cursor: pointer; }
.map-fit-btn:hover { color: #127bc7; background: #f6fbff; }
.royal-marker-wrap { background: none; border: 0; }
.royal-marker { position: relative; width: 24px; height: 24px; display: grid; place-items: center; border: 3px solid white; border-radius: 50%; background: #1688dc; box-shadow: 0 2px 8px rgb(10 82 139 / .45), 0 0 0 2px rgb(22 136 220 / .28); transition: transform 160ms ease; }
.royal-marker::after { content: ''; position: absolute; inset: -8px; border: 1px solid rgb(22 136 220 / .25); border-radius: 50%; }
.royal-marker span { width: 6px; height: 6px; border-radius: 50%; background: white; }
.royal-marker .royal-marker-count { width: auto; height: auto; color: #0869aa; background: transparent; font-size: .65rem; font-weight: 800; line-height: 1; }
.royal-marker.grouped { width: 30px; height: 30px; color: #0869aa; border-color: #1688dc; background: white; }
.royal-marker-wrap:hover .royal-marker { transform: scale(1.18); background: #076cb8; }
.royal-marker-wrap:hover .royal-marker-count { color: white; }
.royal-ruler-label { padding: 6px 9px; border: 1px solid rgb(22 136 220 / .2); border-radius: 8px; background: rgb(255 255 255 / .94); color: #17283d; box-shadow: 0 3px 12px rgb(23 36 48 / .16); }
.royal-ruler-label::before { border-right-color: rgb(255 255 255 / .94); }
.royal-ruler-label-names { display: block; min-width: max-content; }
.royal-ruler-label-names strong { display: block; width: max-content; max-width: 190px; overflow: hidden; color: #17283d; font: 700 .69rem/1.25 'Cormorant Garamond', Georgia, serif; text-overflow: ellipsis; white-space: nowrap; }
.royal-ruler-label-names strong + strong { margin-top: 2px; }
.royal-history-tooltip { max-width: 360px; padding: 0; white-space: normal; border: 0; border-radius: 12px; box-shadow: 0 12px 32px rgb(23 36 48 / .2); }
.royal-history-tooltip::before { border-top-color: white; }
.history-tooltip-card { max-height: 320px; padding: 12px 14px; overflow-y: auto; background: white; border-radius: 12px; }
.history-tooltip-card > small { display: block; margin-bottom: 7px; color: #147abb; font-size: .58rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.history-tooltip-person { display: grid; gap: 3px; }
.history-tooltip-person + .history-tooltip-person { margin-top: 9px; padding-top: 9px; border-top: 1px solid #e6edf1; }
.history-tooltip-person strong { color: #17283d; font: 700 .72rem/1.3 'Cormorant Garamond', Georgia, serif; }
.history-tooltip-person span { color: #59666c; font-size: .65rem; line-height: 1.45; }
.royal-popup .leaflet-popup-content-wrapper { padding: 0; overflow: hidden; border-radius: 15px; box-shadow: 0 18px 45px rgb(23 36 48 / .22); }
.royal-popup .leaflet-popup-content { width: min(350px, calc(100vw - 60px)) !important; margin: 0; }
.royal-popup .leaflet-popup-tip { box-shadow: 3px 3px 8px rgb(23 36 48 / .1); }
.map-popup-card { padding: 19px; background: white; }
.popup-kicker { color: #147abb; font-size: .61rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.map-popup-card h3 { margin: 4px 0 2px; color: #17283d; font: 700 1.12rem/1.3 'Cormorant Garamond', Georgia, serif; }
.popup-reign { color: #788184; font-size: .68rem; }
.popup-place { display: flex; gap: 9px; margin: 14px 0; padding: 11px; border-radius: 10px; background: #f3f8fb; }
.popup-pin { color: #1688dc; font-size: .7rem; }
.popup-place div { display: grid; gap: 2px; }
.popup-place strong { color: #26394b; font-size: .72rem; }
.popup-place small { color: #758184; font-size: .62rem; }
.map-popup-card button { width: 100%; display: flex; justify-content: space-between; padding: 9px 11px; color: white; border: 0; border-radius: 9px; background: #167fc7; font-size: .68rem; font-weight: 700; cursor: pointer; }
.map-popup-card button:hover { background: #0869aa; }
.popup-person-list { display: grid; gap: 8px; max-height: 310px; margin: 14px 0 0; padding: 0; overflow-y: auto; list-style: none; }
.popup-person-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; background: #f3f8fb; }
.popup-person-list li > div { min-width: 0; display: grid; gap: 2px; }
.popup-person-list strong { color: #26394b; font-size: .72rem; }
.popup-person-list span, .popup-person-list small { color: #758184; font-size: .61rem; }
.popup-person-list small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.map-popup-card .popup-person-list button { width: auto; gap: 8px; padding: 7px 9px; }
.map-load-error { height: 100%; display: grid; place-items: center; padding: 30px; color: #5f686b; text-align: center; }
.leaflet-control-attribution { font-size: 9px !important; }

body[data-mode="map"] .app-header::after { background: linear-gradient(90deg, #167fc7 0 16%, #6cb1df 16% 21%, transparent 21%); }
body[data-mode="map"] .mode-switch[aria-pressed="true"] { color: white; border-color: #167fc7; background: #167fc7; }

/* Relationship finder */
.relationship-view {
    flex: 1; min-width: 0; overflow: auto; padding: clamp(28px, 5vw, 64px);
    background:
        radial-gradient(circle at 12% 18%, rgb(15 133 136 / .08), transparent 24%),
        radial-gradient(circle at 88% 78%, rgb(75 83 32 / .08), transparent 28%),
        #f8f4ed;
}
.relationship-shell { width: min(1180px, 100%); margin: 0 auto; }
.relationship-view.has-relationship-result { overflow: hidden; padding: 16px; }
.relationship-view.has-relationship-result .relationship-shell { width: 100%; height: 100%; display: flex; flex-direction: column; }
.relationship-view.has-relationship-result .relationship-heading { display: none; }
.relationship-view.has-relationship-result .relationship-form { flex: 0 0 auto; padding: 14px; }
.relationship-view.has-relationship-result .relationship-output {
    min-height: 0; flex: 1 1 auto; display: flex; flex-direction: column; margin-top: 12px;
}
.relationship-view.has-relationship-result .relationship-tree-frame { min-height: 0; flex: 1 1 auto; }
.relationship-heading { max-width: 650px; margin: 0 auto 28px; text-align: center; }
.relationship-eyebrow {
    display: block; margin-bottom: 8px; color: var(--accent-color); font-size: .66rem; font-weight: 800;
    letter-spacing: .18em; text-transform: uppercase;
}
.relationship-heading h1 { color: var(--text-primary); font: 700 clamp(2rem, 4vw, 3rem)/1.05 'Cormorant Garamond', Georgia, serif; }
.relationship-heading p { margin: 10px 0 0; color: var(--text-secondary); font-size: .86rem; line-height: 1.55; }
.relationship-form {
    position: relative; z-index: 5; display: grid; grid-template-columns: minmax(220px, 1fr) 34px minmax(220px, 1fr) auto;
    align-items: end; gap: 14px; padding: 22px; border: 1px solid #e4dbcf; border-radius: 20px;
    background: rgb(255 253 249 / .96); box-shadow: 0 18px 50px rgb(47 38 27 / .10);
}
.relationship-search { position: relative; min-width: 0; }
.relationship-search > label {
    display: block; margin: 0 0 7px 3px; color: #596366; font-size: .68rem; font-weight: 800;
    letter-spacing: .06em; text-transform: uppercase;
}
.relationship-input-wrap { position: relative; }
.relationship-input-wrap .material-symbols-rounded {
    position: absolute; top: 50%; left: 14px; color: #849091; font-size: 20px; transform: translateY(-50%); pointer-events: none;
}
.relationship-input-wrap input {
    width: 100%; height: 50px; padding: 0 40px 0 43px; color: var(--text-primary); border: 1px solid #dcd5ca;
    border-radius: 12px; outline: 0; background: #fbfaf7; font-size: .8rem; transition: all var(--trans-fast);
}
.relationship-input-wrap input:focus { border-color: var(--accent-color); background: white; box-shadow: 0 0 0 4px rgb(15 133 136 / .10); }
.relationship-input-wrap input.has-selection { border-color: #87bdb8; background: #f0f8f6; font-weight: 700; }
.relationship-divider { height: 50px; display: grid; place-items: center; }
.relationship-divider span { width: 26px; height: 2px; position: relative; background: #b9cbc7; }
.relationship-divider span::before, .relationship-divider span::after {
    content: ''; position: absolute; top: 50%; width: 6px; height: 6px; border: 2px solid var(--accent-color); border-radius: 50%;
    background: white; transform: translateY(-50%);
}
.relationship-divider span::before { left: -2px; }
.relationship-divider span::after { right: -2px; }
.relationship-submit {
    height: 50px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 18px;
    color: white; white-space: nowrap; border: 0; border-radius: 12px; background: linear-gradient(135deg, #198e90, #087679);
    box-shadow: 0 8px 18px rgb(15 133 136 / .18); font-size: .75rem; font-weight: 800; cursor: pointer;
}
.relationship-submit:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); }
.relationship-submit:disabled { color: #a8aeac; background: #ecece8; box-shadow: none; cursor: not-allowed; }
.relationship-submit .material-symbols-rounded { font-size: 19px; }
.relationship-results {
    position: absolute; z-index: 30; top: calc(100% + 7px); right: 0; left: 0; max-height: 310px; margin: 0; padding: 6px;
    overflow-y: auto; list-style: none; border: 1px solid #dfd8cd; border-radius: 13px; background: white;
    box-shadow: 0 16px 34px rgb(34 42 40 / .15);
}
.relationship-results li + li { margin-top: 2px; }
.relationship-results button { width: 100%; display: grid; gap: 3px; padding: 10px 11px; text-align: left; border: 0; border-radius: 9px; background: transparent; cursor: pointer; }
.relationship-results button:hover, .relationship-results button:focus-visible { background: var(--accent-light); }
.relationship-results strong { overflow: hidden; color: var(--text-primary); font: 700 .83rem/1.25 'Cormorant Garamond', Georgia, serif; text-overflow: ellipsis; white-space: nowrap; }
.relationship-results small, .relationship-result-empty { color: var(--text-secondary); font-size: .63rem; }
.relationship-result-empty { padding: 12px; text-align: center; }
.relationship-output {
    min-height: 340px; margin-top: 22px; padding: 28px; border: 1px solid #e4dbcf; border-radius: 20px;
    background: rgb(255 253 249 / .78); box-shadow: 0 12px 35px rgb(47 38 27 / .06);
}
.relationship-placeholder, .relationship-empty { min-height: 282px; display: grid; place-content: center; justify-items: center; text-align: center; color: var(--text-secondary); }
.relationship-placeholder > .material-symbols-rounded, .relationship-empty > .material-symbols-rounded { margin-bottom: 10px; color: #a6b7b2; font-size: 42px; }
.relationship-placeholder strong, .relationship-empty strong { color: var(--text-primary); font: 700 1.25rem/1.3 'Cormorant Garamond', Georgia, serif; }
.relationship-placeholder p, .relationship-empty p { margin: 6px 0 0; font-size: .72rem; }
.relationship-result-heading { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 32px; text-align: left; }
.relationship-result-heading > .material-symbols-rounded { color: var(--accent-color); font-size: 27px; }
.relationship-result-heading strong { color: var(--text-primary); font-size: .8rem; }
.relationship-result-heading p { margin: 2px 0 0; color: var(--text-secondary); font-size: .66rem; }
.relationship-path { display: flex; align-items: center; min-width: max-content; width: max-content; margin: 0 auto; padding: 10px 4px 24px; }
.relationship-output:has(.relationship-path) { overflow-x: auto; }
.relationship-person {
    width: 164px; min-height: 112px; display: grid; justify-items: center; align-content: center; gap: 8px; padding: 15px 12px;
    text-align: center; border: 1px solid #dcd9d0; border-radius: 15px; background: #fff; box-shadow: var(--shadow-md);
}
.relationship-person.endpoint { border-color: var(--accent-color); box-shadow: 0 0 0 3px rgb(15 133 136 / .12), var(--shadow-md); }
.relationship-person img { width: 48px; height: 48px; object-fit: cover; border: 2px solid #edf1ed; border-radius: 50%; background: #e6e9e7; }
.relationship-person div { min-width: 0; display: grid; gap: 3px; }
.relationship-person strong { color: var(--text-primary); font: 700 .78rem/1.2 'Cormorant Garamond', Georgia, serif; }
.relationship-person small { color: var(--text-secondary); font-size: .58rem; }
.relationship-connector { position: relative; width: 96px; height: 34px; display: grid; place-items: center; }
.relationship-connector > span { width: 100%; height: 3px; border-radius: 999px; background: var(--accent-color); }
.relationship-connector > span::after {
    content: ''; position: absolute; top: 50%; right: -1px; width: 8px; height: 8px; border-top: 3px solid var(--accent-color);
    border-right: 3px solid var(--accent-color); transform: translateY(-50%) rotate(45deg);
}
.relationship-connector small {
    position: absolute; top: calc(50% + 8px); padding: 3px 6px; color: var(--accent-hover); white-space: nowrap;
    border-radius: 999px; background: #eaf5f2; font-size: .56rem; font-weight: 800;
}
body[data-mode="relationship"] .app-header::after { background: linear-gradient(90deg, var(--accent-color) 0 18%, #75b4ad 18% 23%, transparent 23%); }
body[data-mode="relationship"] #relationship-mode-btn {
    display: none !important;
}

body[data-mode="relationship"] #home-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex: 0 0 auto;
    min-height: 46px;
    height: 46px;
    padding: .7rem 1.3rem;
    border-radius: 12px;
    font-size: .875rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    color: #fff;
    background: var(--accent-color);
    border: 1px solid var(--accent-color);
    box-shadow: 0 4px 14px rgb(0 143 144 / .18);
    cursor: pointer;
    transition: background var(--trans-fast), border-color var(--trans-fast), transform var(--trans-fast), box-shadow var(--trans-fast);
}

body[data-mode="relationship"] #home-btn:hover {
    color: #fff;
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgb(0 143 144 / .26);
}

body[data-mode="relationship"] #home-btn:active {
    transform: translateY(0);
}

body[data-mode="relationship"] #home-btn .material-symbols-rounded {
    color: #fff;
    font-size: 20px;
}

@media (min-width: 769px) and (max-width: 1250px) {
    body[data-mode="relationship"] #home-btn,
    #relationship-mode-btn { width: 46px; padding-inline: .7rem; }
    body[data-mode="relationship"] #home-btn > span:last-child,
    #relationship-mode-btn span { display: none; }
}

@media (max-width: 768px) {
    body[data-mode="relationship"] #home-btn {
        min-height: 40px;
        height: 40px;
        padding: .55rem .75rem;
        font-size: .75rem;
    }
}

@media (max-width: 900px) {
    .relationship-form { grid-template-columns: minmax(0, 1fr) 30px minmax(0, 1fr); }
    .relationship-submit { grid-column: 1 / -1; width: 100%; }
}

@media (max-width: 768px) {
    body[data-mode="relationship"] .mobile-search-toggle,
    body[data-mode="relationship"] .mobile-family-toggle { display: none; }
    .relationship-view { position: fixed; inset: var(--header-height) 0 0; padding: 22px 14px 36px; }
    .relationship-heading { margin-bottom: 18px; }
    .relationship-heading h1 { font-size: 2rem; }
    .relationship-heading p { font-size: .75rem; }
    .relationship-form { grid-template-columns: 1fr; gap: 12px; padding: 15px; border-radius: 16px; }
    .relationship-divider { display: none; }
    .relationship-input-wrap input, .relationship-submit { height: 46px; }
    .relationship-output { min-height: 300px; margin-top: 14px; padding: 20px 14px; border-radius: 16px; }
    .relationship-placeholder, .relationship-empty { min-height: 258px; }
    .relationship-result-heading { margin-bottom: 20px; }
    .relationship-path { min-width: 0; width: 100%; flex-direction: column; padding: 3px 0 18px; }
    .relationship-person { width: min(260px, 90%); grid-template-columns: auto minmax(0, 1fr); justify-items: start; min-height: 86px; text-align: left; }
    .relationship-person img { grid-row: 1; }
    .relationship-person div { align-self: center; }
    .relationship-connector { width: 42px; height: 68px; }
    .relationship-connector > span { width: 3px; height: 100%; }
    .relationship-connector > span::after { top: auto; right: 50%; bottom: -1px; transform: translateX(50%) rotate(135deg); }
    .relationship-connector small { top: 50%; left: calc(50% + 10px); transform: translateY(-50%); }
    .relationship-output:has(.relationship-path) { overflow-x: visible; }
}

/* The connection result uses the same generational grammar as the main tree. */
.relationship-output:has(.relationship-tree-viewport) { padding: 0; overflow: hidden; }
.relationship-output:has(.relationship-tree-viewport) .relationship-result-heading {
    position: relative; z-index: 4; margin: 0; padding: 20px 24px; border-bottom: 1px solid rgb(228 219 207 / .9);
    background: rgb(255 253 249 / .92); backdrop-filter: blur(8px);
}
.relationship-tree-viewport {
    width: 100%; height: 100%; overflow: hidden; overscroll-behavior: contain;
    cursor: grab; touch-action: none; user-select: none;
}
.relationship-tree-viewport:active { cursor: grabbing; }
.relationship-tree-frame { position: relative; min-height: 320px; background: #e9ddc9; }
.relationship-tree-stage { position: absolute; inset: 0; overflow: hidden; }
.relationship-tree {
    position: relative; isolation: isolate; overflow: hidden;
    background-color: #e9ddc9;
    background-image:
        linear-gradient(rgb(255 248 236 / .28), rgb(255 248 236 / .28)),
        url('../images/madagascar-tree-background.webp');
    background-position: center; background-repeat: no-repeat; background-size: cover;
    transform-origin: 0 0;
}
.relationship-tree::before {
    content: ''; position: absolute; z-index: 0; inset: 0;
    background: radial-gradient(circle at center, transparent 25%, rgb(255 250 240 / .24) 100%);
    pointer-events: none;
}
.relationship-tree-lines { position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.relationship-tree-lines path {
    fill: none; stroke: var(--accent-color); stroke-width: 4px; stroke-linecap: round;
    filter: drop-shadow(0 1px 0 rgb(255 255 255 / .65));
}
.relationship-tree-lines path.relation-spouse { stroke-dasharray: 8 6; }
.relationship-tree .relationship-person {
    position: absolute; z-index: 2; display: grid; grid-template-columns: 1fr; justify-items: center; align-content: center;
    gap: 8px; margin: 0; padding: 15px 12px 18px; transform: translate(-50%, -50%); text-align: center;
    border-color: rgb(218 209 196 / .95); background: rgb(255 253 249 / .94); backdrop-filter: blur(4px);
}
.relationship-tree .relationship-person.endpoint {
    border-width: 2px; border-color: var(--accent-color);
    box-shadow: 0 0 0 4px rgb(15 133 136 / .15), 0 16px 34px rgb(47 38 27 / .18);
}
.relationship-tree .relationship-person img { width: 56px; height: 56px; }
.relationship-tree .relationship-person strong { display: block; font-size: .82rem; }
.relationship-tree .relationship-person small { display: block; margin-top: 4px; font-size: .59rem; }
.relationship-tree .relationship-person.is-interactive { cursor: pointer; }
.relationship-tree .relationship-person.is-interactive:hover,
.relationship-tree .relationship-person.is-interactive:focus-visible {
    border-color: var(--accent-color); box-shadow: 0 0 0 4px rgb(15 133 136 / .15), 0 16px 34px rgb(47 38 27 / .18);
    outline: none;
}
.relationship-gender {
    position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%); font-size: 16px;
    font-variation-settings: 'FILL' 1, 'wght' 650, 'GRAD' 0, 'opsz' 20;
}
.relationship-zoom-controls {
    position: absolute; z-index: 8; top: 14px; right: 14px; display: grid; gap: 4px; padding: 4px;
    border: 1px solid rgb(213 207 197 / .92); border-radius: 12px; background: rgb(255 253 249 / .92);
    box-shadow: 0 8px 22px rgb(47 38 27 / .14); backdrop-filter: blur(8px);
}
.relationship-zoom-controls button {
    width: 36px; height: 36px; display: grid; place-items: center; padding: 0; color: var(--text-primary);
    border: 0; border-radius: 8px; background: transparent; cursor: pointer;
}
.relationship-zoom-controls button:hover:not(:disabled) { color: white; background: var(--accent-color); }
.relationship-zoom-controls button:disabled { color: #b9bcba; cursor: not-allowed; }
.relationship-zoom-controls .material-symbols-rounded { font-size: 20px; }

@media (max-width: 768px) {
    .relationship-view.has-relationship-result { padding: 8px; }
    .relationship-view.has-relationship-result .relationship-form { gap: 8px; padding: 10px; }
    .relationship-view.has-relationship-result .relationship-search > label { display: none; }
    .relationship-view.has-relationship-result .relationship-input-wrap input,
    .relationship-view.has-relationship-result .relationship-submit { height: 40px; }
    .relationship-view.has-relationship-result .relationship-output { margin-top: 8px; }
    .relationship-view.has-relationship-result .relationship-result-heading { padding: 9px 12px; }
    .relationship-view.has-relationship-result .relationship-result-heading p { display: none; }
    .relationship-output:has(.relationship-tree-viewport) { margin-inline: -1px; }
    .relationship-output:has(.relationship-tree-viewport) .relationship-result-heading { padding: 14px 16px; }
    .relationship-tree .relationship-person {
        grid-template-columns: 1fr; justify-items: center; min-height: 132px; text-align: center;
    }
    .relationship-tree .relationship-person img { grid-row: auto; }
    .relationship-zoom-controls { top: 9px; right: 9px; display: flex; }
    .relationship-zoom-controls button { width: 34px; height: 34px; }
}

@media (min-width: 769px) and (max-width: 1050px) {
    .royal-map-view { grid-template-columns: 320px minmax(0, 1fr); }
    .app-header { gap: 15px; padding-inline: 18px; }
    .logo { width: 205px; min-width: 205px; padding-right: 15px; }
    .header-action { padding-inline: .9rem; }
}
@media (max-width: 768px) {
    .royal-map-view { position: fixed; inset: var(--header-height) 0 0; grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
    .map-canvas-wrap { grid-row: 1; }
    .map-sidebar { grid-row: 2; max-height:36vh; padding: 10px 12px env(safe-area-inset-bottom); border: 0; border-top: 1px solid #ddd8ce; box-shadow: 0 -8px 25px rgb(24 35 45 / .09); transition:max-height .2s ease; }
    .royal-map-view[data-panel="expanded"] .map-sidebar { max-height:72vh; }.royal-map-view[data-panel="compact"] .map-sidebar { max-height:150px; overflow:hidden; }
    .map-sidebar-heading { padding-bottom: 10px; }
    .map-sidebar-heading p, .map-eyebrow { display: none; }
    .map-sidebar h2 { font-size: 1rem; }
    .map-search { position: absolute; top: 9px; right: 10px; width: min(52%, 260px); margin: 0; }.map-search-results { top:50px; right:10px; left:auto; width:min(88vw,320px); }
    .map-search input { height: 35px; font-size: .68rem; }
    .map-era-filters { padding: 0 0 8px; }
    .map-date-filter { margin: 0 0 7px; padding: 7px 10px 4px; }
    .map-date-slider { height: 23px; margin-top: 1px; }
    .map-date-track { top: 10px; }
    .map-date-filter input[type="range"] { top: 3px; }
    .map-date-bounds { display: none; }
    .map-results-count { padding-bottom: 5px; }
    .map-time-modes,.map-layer-controls { margin-bottom:5px; }.map-time-modes button,.map-layer-controls button,.map-sidebar-actions button { min-height:44px; }.map-sidebar-actions #map-panel-toggle { display:block; }.map-expand-btn { display:block; }.royal-map-view[data-panel="expanded"] .map-expand-btn { display:none; }
    .map-ruler-card { min-height: 56px; margin-bottom: 3px; padding-block: 6px; }
    .map-legend { top: 10px; right: 10px; width: auto; max-width: 175px; padding: 9px 10px; }
    .map-legend small { display: none; }
    .map-fit-btn { top: 10px; left: 10px; }
    body[data-mode="map"] .logo { display: none; }
    body[data-mode="map"] .header-actions { margin-left: auto; }
    body[data-mode="map"] #dynasty-mode-btn { display: none; }
}
@media (max-width: 480px) {
    .royal-map-view { grid-template-rows: minmax(0, 55%) minmax(0, 45%); }
    body[data-mode="map"] .header-actions { width: auto; justify-content: flex-end; }
    body[data-mode="map"] #map-mode-btn { width: 100%; padding-inline: 12px; }
    body[data-mode="map"] #map-mode-btn span { display: inline; }
    .map-sidebar h2 { font-size: .88rem; }
    .map-search { width: 55%; }
    .map-era-filters button { padding-inline: 8px; }
}

/* Use the same polished Taranaka picker on phones in either orientation. */
@media (max-width: 768px) and (orientation: portrait),
       (orientation: landscape) and (max-width: 1180px) and (max-height: 820px) {
    .family-tree-filter select { display: none; }
    .family-tree-dropdown-toggle {
        width: 100%; min-width: 0; min-height: 42px; display: flex; align-items: center; justify-content: space-between;
        gap: 8px; padding: .55rem 8px .55rem 12px; color: var(--text-primary); border: 1px solid #d7d0c4;
        border-radius: 12px; background: rgb(255 253 250 / .94); font: 600 .7rem/1.2 'DM Sans', sans-serif;
        cursor: pointer; box-shadow: inset 0 1px 1px rgb(70 50 30 / .03);
    }
    .family-tree-dropdown-toggle > :first-child {
        min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .family-tree-dropdown-toggle .material-symbols-rounded {
        flex: 0 0 auto; font-size: 19px; transition: transform var(--trans-fast);
    }
    .family-tree-dropdown-toggle[aria-expanded="true"] {
        border-color: var(--accent-color); box-shadow: 0 0 0 3px rgb(15 133 136 / .11);
    }
    .family-tree-dropdown-toggle[aria-expanded="true"] .material-symbols-rounded { transform: rotate(180deg); }
    .family-tree-dropdown:not([hidden]) {
        position: absolute; z-index: 1100; top: calc(100% + 7px); right: 0; width: min(100%, 300px);
        max-height: min(320px, calc(100vh - 90px)); overflow-y: auto; overscroll-behavior: contain;
        display: grid; gap: 4px; padding: 6px; border: 1px solid #ddd5c8; border-radius: 14px;
        background: rgb(255 253 249 / .98); box-shadow: 0 14px 35px rgb(30 42 45 / .2); backdrop-filter: blur(12px);
    }
    .family-tree-dropdown-option {
        width: 100%; min-height: 42px; display: flex; align-items: center; justify-content: space-between;
        gap: 10px; padding: 9px 10px; color: var(--text-primary); border: 0; border-radius: 9px;
        background: transparent; font: 600 .72rem/1.25 'DM Sans', sans-serif; text-align: left; cursor: pointer;
    }
    .family-tree-dropdown-option .material-symbols-rounded { color: transparent; font-size: 18px; }
    .family-tree-dropdown-option:is(:hover, :focus-visible),
    .family-tree-dropdown-option.is-selected { color: var(--accent-hover); background: var(--accent-light); }
    .family-tree-dropdown-option.is-selected .material-symbols-rounded { color: var(--accent-color); }
}

/* Portrait-specific tree controls. */
@media (max-width: 768px) and (orientation: portrait) {
    .tree-controls,
    .app-main:has(.person-details.hidden) .tree-controls,
    .app-main:has(.person-details.expanded) .tree-controls {
        top: calc(var(--header-height) + 12px);
        right: max(12px, env(safe-area-inset-right));
        bottom: auto;
        left: auto;
        transform: none;
        flex-direction: column;
        gap: 2px;
    }
    .tree-controls .control-btn .material-symbols-rounded { display: inline-block; }
}

/* Mobile navigation drawer, shared by portrait and compact landscape. */
@media (max-width: 768px), (orientation: landscape) and (max-width: 1180px) and (max-height: 820px) {
    #zoom-in-btn,
    #zoom-out-btn,
    #fullscreen-btn {
        display: none;
    }

    .app-header:has(.header-actions-menu.is-open) {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
    .mobile-menu-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 999;
        background: radial-gradient(circle at 10% 50%, rgba(18, 28, 32, 0.52), rgba(18, 28, 32, 0.42));
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        touch-action: none;
        transition: opacity 0.38s cubic-bezier(0.16, 1, 0.3, 1),
                    backdrop-filter 0.38s ease,
                    visibility 0.38s;
    }
    .header-actions:has(.header-actions-menu.is-open) .mobile-menu-backdrop,
    .mobile-menu-backdrop.is-open,
    body.mobile-menu-open .mobile-menu-backdrop {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }
    .header-actions-menu {
        display: flex !important;
        position: fixed;
        inset: 0 auto 0 0;
        width: min(295px, calc(100vw - 52px));
        min-width: 245px;
        height: 100dvh;
        max-height: 100dvh;
        padding: max(18px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
        overflow-y: auto;
        overscroll-behavior: contain;
        background: linear-gradient(175deg, rgba(255, 254, 250, 0.96) 0%, rgba(247, 244, 237, 0.98) 100%);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        border: 0;
        border-right: 1px solid rgba(220, 214, 201, 0.85);
        border-radius: 0 24px 24px 0;
        box-shadow: 20px 0 50px -10px rgba(18, 30, 33, 0.26), 6px 0 16px -4px rgba(18, 30, 33, 0.1);
        z-index: 1000;
        align-items: stretch;
        flex-direction: column;
        gap: 8px;

        /* Ultra-smooth slide-in transition from the left */
        transform: translate3d(-102%, 0, 0);
        opacity: 0.6;
        visibility: hidden;
        pointer-events: none;
        transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                    opacity 0.32s ease,
                    visibility 0.4s;
        will-change: transform, opacity;
    }
    .header-actions-menu.is-open {
        transform: translate3d(0, 0, 0);
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* Drawer Header */
    .drawer-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding-bottom: 14px;
        margin-bottom: 6px;
        border-bottom: 1px solid rgba(225, 220, 209, 0.7);
    }
    .drawer-brand {
        display: flex;
        align-items: center;
        gap: 10px;
    }
    .drawer-logo-mark {
        width: 32px;
        height: 32px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 10px;
        background: #f4efe6;
        padding: 4px;
        box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06), 0 2px 4px rgba(0, 0, 0, 0.04);
    }
    .drawer-logo-mark img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }
    .drawer-title-group {
        display: flex;
        flex-direction: column;
    }
    .drawer-title {
        font-family: 'Cormorant Garamond', Georgia, serif;
        font-size: 1.25rem;
        font-weight: 700;
        line-height: 1.1;
        color: var(--army-green);
        letter-spacing: -0.01em;
    }
    .drawer-subtitle {
        font-size: 0.68rem;
        font-weight: 600;
        color: #8c8270;
        letter-spacing: 0.05em;
        text-transform: uppercase;
    }
    .drawer-close-btn {
        width: 32px;
        height: 32px;
        border-radius: 10px;
        border: 1px solid rgba(220, 214, 201, 0.8);
        background: #fffdf9;
        color: #6b6357;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        padding: 0;
        transition: transform 0.18s ease, background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
    }
    .drawer-close-btn:hover {
        background: #f0ebe1;
        color: var(--army-green);
        border-color: #cbbeab;
    }
    .drawer-close-btn:active {
        transform: scale(0.91);
    }
    .drawer-close-btn .material-symbols-rounded {
        font-size: 18px;
    }

    /* Staggered entrance animation for drawer children */
    @keyframes drawerItemIn {
        0% {
            opacity: 0;
            transform: translate3d(-20px, 0, 0);
        }
        100% {
            opacity: 1;
            transform: translate3d(0, 0, 0);
        }
    }

    .header-actions-menu.is-open > * {
        animation: drawerItemIn 0.38s cubic-bezier(0.16, 1, 0.3, 1) both;
    }
    .header-actions-menu.is-open > .drawer-header { animation-delay: 0.04s; }
    .header-actions-menu.is-open > *:nth-child(2) { animation-delay: 0.09s; }
    .header-actions-menu.is-open > *:nth-child(3) { animation-delay: 0.13s; }
    .header-actions-menu.is-open > *:nth-child(4) { animation-delay: 0.17s; }
    .header-actions-menu.is-open > *:nth-child(5) { animation-delay: 0.21s; }
    .header-actions-menu.is-open > *:nth-child(6) { animation-delay: 0.25s; }

    /* Polished items inside the drawer */
    .header-actions-menu .header-action {
        width: 100%;
        min-height: 44px;
        justify-content: flex-start;
        gap: 12px;
        padding: 0.65rem 0.95rem;
        border-radius: 12px;
        font-size: 0.82rem;
        font-weight: 600;
        color: var(--army-green);
        border: 1px solid rgba(216, 209, 196, 0.9);
        background: #fffdfa;
        box-shadow: 0 2px 6px rgba(40, 55, 38, 0.04);
        transition: transform 0.18s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
    }
    .header-actions-menu .header-action:hover {
        background: #ffffff;
        border-color: var(--accent-color);
        box-shadow: 0 4px 12px rgba(15, 139, 143, 0.12);
    }
    .header-actions-menu .header-action:active {
        transform: scale(0.97);
    }
    .header-actions-menu .header-action.active,
    .header-actions-menu .header-action[aria-pressed="true"] {
        background: var(--army-green);
        color: #ffffff;
        border-color: var(--army-green);
    }
    .header-actions-menu .mode-switch {
        color: var(--army-green);
        background: #fffdfa;
        padding: 0.65rem 0.95rem;
    }
    .header-actions-menu .mode-switch span {
        display: inline;
        color: inherit;
        font-weight: 600;
    }
    .header-actions-menu .mode-switch svg,
    .header-actions-menu .mode-switch .material-symbols-rounded {
        color: inherit;
    }
    .header-actions-menu .mode-switch:hover {
        color: #ffffff;
        background: var(--accent-color);
        border-color: var(--accent-color);
    }
    .header-actions-menu .mode-switch[aria-pressed="true"] {
        color: #ffffff;
        background: var(--army-green);
        border-color: var(--army-green);
    }
    .header-actions-menu .family-tree-filter { flex: 0 0 auto; }

    /* Drawer section separators */
    .drawer-separator {
        display: block;
        height: 1px;
        background: linear-gradient(90deg, transparent, rgba(220, 214, 201, 0.7) 20%, rgba(220, 214, 201, 0.7) 80%, transparent);
        margin: 4px 8px;
        flex-shrink: 0;
    }

    /* Drawer nav sections */
    .drawer-nav-section {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    .drawer-section-label {
        font-size: 0.65rem;
        font-weight: 700;
        color: #9b9285;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        padding: 4px 12px 2px;
    }

    /* Drawer nav items */
    .drawer-nav-item {
        display: flex;
        align-items: center;
        gap: 12px;
        width: 100%;
        min-height: 42px;
        padding: 0.55rem 0.95rem;
        border-radius: 12px;
        font-family: 'DM Sans', sans-serif;
        font-size: 0.8rem;
        font-weight: 600;
        color: var(--army-green);
        background: transparent;
        border: 1px solid transparent;
        cursor: pointer;
        transition: transform 0.18s ease, background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
    }
    .drawer-nav-item .material-symbols-rounded {
        font-size: 20px;
        color: #8c8270;
        transition: color 0.2s ease;
    }
    .drawer-nav-item:hover {
        background: #ffffff;
        border-color: var(--accent-color);
        box-shadow: 0 4px 12px rgba(15, 139, 143, 0.1);
    }
    .drawer-nav-item:hover .material-symbols-rounded {
        color: var(--accent-color);
    }
    .drawer-nav-item:active {
        transform: scale(0.97);
    }

    /* Footer links section (smaller, softer styling) */
    .drawer-footer-links {
        margin-top: auto;
        padding-top: 4px;
    }
    .drawer-footer-links .drawer-nav-item {
        min-height: 38px;
        padding: 0.45rem 0.95rem;
        font-size: 0.76rem;
        font-weight: 500;
        color: #7a7165;
    }
    .drawer-footer-links .drawer-nav-item .material-symbols-rounded {
        font-size: 18px;
        color: #a39889;
    }
    .drawer-footer-links .drawer-nav-item:hover {
        color: var(--army-green);
        background: rgba(255, 255, 255, 0.7);
        border-color: rgba(216, 209, 196, 0.7);
        box-shadow: none;
    }
    .drawer-footer-links .drawer-nav-item:hover .material-symbols-rounded {
        color: var(--army-green);
    }

    /* Extend staggered animation for new children */
    .header-actions-menu.is-open > *:nth-child(7) { animation-delay: 0.29s; }
    .header-actions-menu.is-open > *:nth-child(8) { animation-delay: 0.32s; }
    .header-actions-menu.is-open > *:nth-child(9) { animation-delay: 0.35s; }
    .header-actions-menu.is-open > *:nth-child(10) { animation-delay: 0.38s; }
    .header-actions-menu.is-open > *:nth-child(11) { animation-delay: 0.41s; }
}

@media (prefers-reduced-motion: reduce) {
    .header-actions-menu,
    .mobile-menu-backdrop,
    .mobile-menu-toggle,
    .mobile-menu-toggle .hamburger-icon .line,
    .header-actions-menu.is-open > * {
        transition: none !important;
        animation: none !important;
    }
}

/* Give the limited vertical space back to the content on phones in landscape. */
@media (orientation: landscape) and (max-width: 932px) and (max-height: 600px) {
    /* Keep the collapsed person summary readable in the shallow landscape sheet. */
    .person-details:not(.expanded) .details-content {
        justify-content: center; padding: 6px 12px; overflow: hidden;
    }
    .person-details:not(.expanded) .detail-header {
        grid-template-columns: auto minmax(0, 1fr); gap: 9px; min-height: 0;
    }
    .person-details:not(.expanded) .detail-header:not(:has(.detail-avatar)) {
        grid-template-columns: minmax(0, 1fr); text-align: left;
    }
    .person-details:not(.expanded) .detail-avatar {
        width: clamp(34px, 11vh, 48px); height: clamp(34px, 11vh, 48px); padding: 2px;
    }
    .person-details:not(.expanded) .detail-identity {
        display: flex; align-items: baseline; gap: 8px; overflow: hidden; white-space: nowrap;
    }
    .person-details:not(.expanded) .detail-name {
        flex: 1 1 auto; min-width: 0; margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    }
    .person-details:not(.expanded) .detail-meta {
        flex: 0 0 auto; flex-wrap: nowrap; gap: 5px; white-space: nowrap;
    }
    .person-details:not(.expanded) .detail-gender,
    .person-details:not(.expanded) .detail-gender + .detail-meta-separator {
        display: none;
    }
}
.admin-people-card { padding: 20px; border: 1px solid #e4ddd2; border-radius: 16px; background: #fffefa; }
.admin-people-card > label { display: block; margin-bottom: 8px; font-weight: 600; }
.admin-people-toolbar { display: flex; justify-content: center; margin-bottom: 16px; }
.admin-people-create { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border: 0; border-radius: 10px; background: var(--accent-color); color: white; font: inherit; font-weight: 600; cursor: pointer; }
.admin-people-create:hover { background: var(--accent-hover); }
.admin-people-card > input { width: 100%; box-sizing: border-box; padding: 12px 14px; border: 1px solid #d7d1c7; border-radius: 10px; font: inherit; background: white; }
.admin-people-count, .admin-people-message { color: var(--text-secondary); font-size: .85rem; }
.admin-people-message:empty { display: none; }
.admin-people-list { list-style: none; padding: 0; margin: 0; max-height: 440px; overflow: auto; }
.admin-people-list li { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0; border-bottom: 1px solid #eee8df; font-size: .82rem; cursor: pointer; }
.admin-people-list li:hover { background: #f8f5ef; }
.admin-people-list li > strong { overflow-wrap: anywhere; }
.admin-people-list li > div { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.admin-people-list button:not(.admin-people-edit):not(.admin-account-delete), .admin-people-list select { padding: 8px 12px; border: 1px solid #d7d1c7; border-radius: 8px; background: white; color: var(--text-primary); font: inherit; }
.admin-people-list button { cursor: pointer; }
.admin-people-list button.danger { border-color: #d8aaa5; color: #a13931; }
.admin-people-list button.danger:hover { background: #fff2f0; border-color: #a13931; }
.admin-people-list select:disabled { opacity: .65; }
.admin-people-list small { color: var(--text-secondary); }
.admin-people-edit { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 8px; border: 1px solid #c7d7d2; border-radius: 9px; background: #f4faf7; color: var(--accent-color); cursor: pointer; }
.admin-people-edit:hover { background: var(--accent-light); border-color: var(--accent-color); }

.admin-delete-dialog {
    width: min(460px, calc(100% - 28px)); margin: auto; padding: 0; overflow: hidden;
    border: 1px solid #e4d7cc; border-radius: 24px; background: #fffdfa; color: var(--text-primary);
    box-shadow: 0 30px 90px rgb(23 36 60 / .28), 0 2px 6px rgb(63 48 31 / .08);
}
.admin-delete-dialog[open] { display: grid; grid-template-columns: auto 1fr; gap: 18px; padding: 27px 28px 0; animation: admin-delete-in 220ms cubic-bezier(.2, .8, .2, 1); }
.admin-delete-dialog::backdrop { background: rgb(18 31 47 / .55); backdrop-filter: blur(7px) saturate(.85); }
@keyframes admin-delete-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.admin-delete-icon {
    display: grid; width: 50px; height: 50px; place-items: center; border: 1px solid #efd0cc;
    border-radius: 16px; background: #fff0ee; color: #a13931;
}
.admin-delete-icon .material-symbols-rounded { font-size: 26px; }
.admin-delete-copy { min-width: 0; }
.admin-delete-eyebrow { color: #a13931; font-size: .65rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.admin-delete-dialog h3 { margin: 5px 0 9px; font: 700 1.75rem/1.08 'Cormorant Garamond', Georgia, serif; }
.admin-delete-dialog p { margin: 0; color: var(--text-secondary); font-size: .78rem; line-height: 1.55; }
.admin-delete-dialog p strong { color: var(--text-primary); font-weight: 700; }
.admin-delete-warning { display: flex; align-items: center; gap: 6px; margin-top: 13px !important; color: #8a4943 !important; font-weight: 700; }
.admin-delete-warning .material-symbols-rounded { font-size: 17px; }
.admin-delete-actions {
    display: flex; grid-column: 1 / -1; justify-content: flex-end; gap: 10px; margin: 7px -28px 0;
    padding: 17px 28px; border-top: 1px solid #eee5dc; background: #faf7f2;
}
.admin-delete-actions button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-width: 105px; padding: 10px 16px; border: 1px solid #d8d0c7; border-radius: 10px; background: #fff; color: var(--text-primary); font: inherit; font-weight: 700; cursor: pointer; }
.admin-delete-actions button:hover { background: #f4efe8; }
.admin-delete-actions .confirm-danger { border-color: #a13931; background: #a13931; color: #fff; box-shadow: 0 6px 16px rgb(161 57 49 / .2); }
.admin-delete-actions .confirm-danger:hover { border-color: #852e28; background: #852e28; }
.admin-delete-actions .material-symbols-rounded { font-size: 18px; }
.admin-delete-actions button:focus-visible { outline: 3px solid rgb(15 133 136 / .22); outline-offset: 2px; }

@media (max-width: 520px) {
    .admin-delete-dialog[open] { grid-template-columns: 1fr; gap: 12px; padding: 23px 22px 0; }
    .admin-delete-icon { width: 44px; height: 44px; }
    .admin-delete-actions { grid-column: 1; margin: 7px -22px 0; padding: 15px 22px; }
    .admin-delete-actions button { flex: 1; min-width: 0; }
}

.admin-accounts-card { border: 1px solid #e4ddd2; border-radius: 16px; background: #fffefa; overflow: hidden; box-shadow: 0 8px 24px rgb(58 46 31 / .05); }
.admin-accounts-toolbar { display: grid; grid-template-columns: minmax(220px, 420px) 1fr; align-items: end; gap: 7px 18px; padding: 18px; border-bottom: 1px solid #eee8df; }
.admin-accounts-toolbar label { grid-column: 1; font-weight: 600; }
.admin-accounts-toolbar input { grid-column: 1; width: 100%; box-sizing: border-box; padding: 11px 13px; border: 1px solid #d7d1c7; border-radius: 10px; background: white; color: var(--text-primary); font: inherit; }
.admin-accounts-count { grid-column: 2; grid-row: 2; margin: 0; color: var(--text-secondary); font-size: .8rem; text-align: right; }
.admin-accounts-table-wrap { max-height: 440px; overflow: auto; }
.admin-accounts-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.admin-accounts-table th { position: sticky; top: 0; z-index: 1; padding: 11px 16px; background: #f8f4ed; color: var(--text-secondary); font-size: .7rem; letter-spacing: .04em; text-align: left; text-transform: uppercase; }
.admin-accounts-table td { padding: 13px 16px; border-top: 1px solid #f0ebe4; vertical-align: middle; }
.admin-accounts-table td:first-child strong, .admin-accounts-table td:first-child small { display: block; }
.admin-accounts-table td:first-child small { margin-top: 3px; color: var(--text-secondary); }
.admin-accounts-table .account-status-active { color: #28734f; font-weight: 700; }
.admin-accounts-table .account-status-inactive { color: #a33b2f; font-weight: 700; }
.admin-accounts-empty { padding: 28px !important; color: var(--text-secondary); text-align: center !important; }
.admin-account-row { cursor: pointer; }
.admin-account-row:hover, .admin-account-row:focus-within { background: #f4f8f5; }
.admin-account-open { padding: 0; border: 0; background: transparent; color: inherit; font: inherit; font-weight: 700; text-align: left; cursor: pointer; }
.admin-account-open:focus-visible { outline: 2px solid var(--accent-color); outline-offset: 4px; border-radius: 3px; }
.admin-account-dialog { width: min(520px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); margin: auto; box-sizing: border-box; padding: 24px; overflow-y: auto; border: 1px solid #e4ddd2; border-radius: 18px; background: #fffefa; color: var(--text-primary); box-shadow: 0 24px 80px rgb(18 31 47 / .25); }
.admin-account-dialog::backdrop { background: rgb(18 31 47 / .55); backdrop-filter: blur(4px); }
.admin-account-dialog form { display: grid; gap: 14px; }
.admin-account-dialog header, .admin-account-dialog footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.admin-account-dialog h2 { margin: 0; font-size: 1.25rem; }
.admin-account-dialog p { margin: 0; font-size: .85rem; line-height: 1.6; overflow-wrap: anywhere; }
.admin-account-dialog label { font-weight: 700; }
.admin-account-dialog select, .admin-account-dialog button { padding: 10px 14px; border: 1px solid #d7d1c7; border-radius: 9px; background: white; color: inherit; font: inherit; }
.admin-account-dialog button { cursor: pointer; }
.admin-account-dialog footer { justify-content: flex-end; padding-top: 8px; }
.admin-account-dialog button[type="submit"] { background: var(--accent-color); border-color: var(--accent-color); color: white; }
.admin-account-dialog :disabled { opacity: .55; cursor: default; }
.admin-account-feedback { color: var(--text-secondary); }
.admin-account-actions { text-align: center; }
.admin-account-delete { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; padding: 8px; border: 1px solid #edd2cc; border-radius: 9px; background: #fff8f6; color: #a33b2f; cursor: pointer; }
.admin-account-delete:hover:not(:disabled) { background: #fbe8e3; border-color: #a33b2f; }
.admin-account-delete:focus-visible { outline: 2px solid #a33b2f; outline-offset: 3px; }
.admin-account-delete:disabled { opacity: .4; cursor: default; }
.admin-account-dialog button.admin-account-delete-confirm { background: #a33b2f; border-color: #a33b2f; }
@media (max-width: 700px) {
    .admin-account-actions .admin-account-delete { justify-self: end; }
}

@media (max-width: 600px) {
    .admin-people-list li { align-items: flex-start; flex-direction: column; }
    .admin-accounts-toolbar { grid-template-columns: 1fr; }
    .admin-accounts-count { grid-column: 1; grid-row: auto; text-align: left; }
    .admin-accounts-table { min-width: 720px; }
}

/* Dashboard administration : hiérarchie, navigation et regroupements */
.admin-database-tabs { position: sticky; top: 0; z-index: 6; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: -10px 0 16px; padding: 8px; border: 1px solid #d8d0c4; border-radius: 16px; background: rgb(255 254 250 / .96); box-shadow: 0 10px 28px rgb(58 46 31 / .09); backdrop-filter: blur(12px); }
.admin-database-tabs button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 10px 16px; border: 0; border-radius: 11px; background: transparent; color: var(--text-secondary); font: inherit; font-size: .84rem; font-weight: 800; cursor: pointer; transition: background var(--trans-fast), color var(--trans-fast), box-shadow var(--trans-fast); }
.admin-database-tabs button .material-symbols-rounded { font-size: 20px; }
.admin-database-tabs button:hover, .admin-database-tabs button:focus-visible { background: var(--accent-light); color: var(--accent-hover); outline: 0; }
.admin-database-tabs button[aria-selected="true"] { background: var(--accent-color); color: #fff; box-shadow: 0 5px 14px rgb(7 135 139 / .22); }
#admin-dashboard-content:not(.is-merina-database) #admin-merina-management,
#admin-dashboard-content:not(.is-merina-database) #admin-merina-anomalies { display: none; }
#admin-dashboard-content:not(.is-merina-database) #admin-family-anomalies { grid-column: 1 / -1; }
.admin-subnav [data-admin-target="admin-merina-management"] { display: none; }
#admin-dashboard-content.is-merina-database .admin-subnav,
#admin-dashboard-content.is-merina-database .admin-overview,
#admin-dashboard-content.is-merina-database > .admin-section:not(#admin-actions):not(#admin-merina-management) { display: none; }
#admin-dashboard-content.is-merina-database #admin-actions > .admin-section-heading,
#admin-dashboard-content.is-merina-database #admin-actions .admin-recovery-card,
#admin-dashboard-content.is-merina-database #admin-actions #admin-family-anomalies { display: none; }
#admin-dashboard-content.is-merina-database #admin-actions { margin-top: 18px; }
#admin-dashboard-content.is-merina-database .admin-priority-grid { display: block; }
#admin-dashboard-content.is-merina-database #admin-merina-anomalies { display: block; }
.admin-subnav { position: sticky; top: 70px; z-index: 4; display: flex; gap: 6px; margin: 0 0 30px; padding: 8px; border: 1px solid #e3ddd3; border-radius: 14px; background: rgb(255 254 250 / .94); box-shadow: 0 8px 22px rgb(58 46 31 / .06); backdrop-filter: blur(10px); }
.admin-subnav button { flex: 1; padding: 9px 12px; border: 0; border-radius: 9px; background: transparent; color: var(--text-secondary); font: inherit; font-size: .78rem; font-weight: 750; text-align: center; cursor: pointer; }
.admin-subnav button:hover, .admin-subnav button:focus-visible { background: var(--accent-light); color: var(--accent-hover); outline: 0; }
.admin-overview, .admin-section { scroll-margin-top: 76px; }
.admin-overview .admin-section-heading { margin-bottom: 13px; }
.admin-summary { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 0; }
.admin-summary article, .admin-summary-action { box-sizing: border-box; display: flex; align-items: center; gap: 14px; min-width: 0; padding: 18px; border: 1px solid #e4ddd2; border-radius: 16px; background: #fffefa; color: var(--text-primary); text-decoration: none; }
.admin-summary-action:hover { border-color: #cbbfb0; box-shadow: 0 8px 24px rgb(58 46 31 / .07); }
.admin-summary-action > .material-symbols-rounded { display: grid; width: 42px; height: 42px; flex: 0 0 auto; place-items: center; border-radius: 12px; background: var(--accent-light); color: var(--accent-color); }
.admin-summary-action.has-warning > .material-symbols-rounded { background: #fff0d8; color: #b45309; }
.admin-priority-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }
.admin-priority-grid .admin-recovery-card { grid-column: 1 / -1; }
.admin-recovery-card header { display: flex; align-items: center; gap: 11px; padding: 16px 18px; background: #fff8ed; border-bottom: 1px solid #eee2d5; }
.admin-recovery-card header > .material-symbols-rounded { color: #b45309; }
.admin-recovery-card header h3, .admin-recovery-card header p { margin: 0; }
.admin-recovery-card header h3 { font-size: .92rem; }
.admin-recovery-card header p { margin-top: 2px; color: var(--text-secondary); font-size: .7rem; }
.admin-recovery-card ul, .admin-priority-grid .admin-anomaly-card ul { max-height: 360px; overflow: auto; }
.admin-card-tabs, .admin-main-tabs { display: flex; gap: 5px; padding: 8px; border-bottom: 1px solid #eee8df; background: #faf7f1; }
.admin-card-tabs button, .admin-main-tabs button { padding: 9px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--text-secondary); font: inherit; font-size: .75rem; font-weight: 750; cursor: pointer; }
.admin-card-tabs button[aria-selected="true"], .admin-main-tabs button[aria-selected="true"] { background: #fff; color: var(--accent-hover); box-shadow: 0 1px 5px rgb(58 46 31 / .12); }
.admin-card-tabs button span { margin-left: 4px; color: inherit; }
.admin-management-card { border: 1px solid #e4ddd2; border-radius: 16px; background: #fffefa; overflow: hidden; }
.admin-main-tabs { padding: 10px 12px; }
.admin-main-tabs button { min-width: 120px; }
.admin-management-card > .admin-people-card, .admin-management-card > .admin-accounts-card { border: 0; border-radius: 0; box-shadow: none; }
.admin-merina-card { border: 1px solid #e4ddd2; border-radius: 16px; background: #fffefa; overflow: hidden; }
.admin-merina-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: #e8e0d5; }
.admin-merina-summary article { display: grid; gap: 3px; padding: 17px 19px; background: #fffefa; }
.admin-merina-summary strong { font-size: 1.45rem; }
.admin-merina-summary span { color: var(--text-secondary); font-size: .72rem; }
.admin-merina-summary .has-warning strong { color: #b45309; }
.admin-merina-tabs { display: flex; gap: 5px; padding: 9px 12px; border-block: 1px solid #eee8df; background: #faf7f1; }
.admin-merina-tabs button { padding: 9px 12px; border: 0; border-radius: 8px; background: transparent; color: var(--text-secondary); font: inherit; font-size: .75rem; font-weight: 750; cursor: pointer; }
.admin-merina-tabs button[aria-selected="true"] { background: #fff; color: var(--accent-hover); box-shadow: 0 1px 5px rgb(58 46 31 / .12); }
.admin-merina-panel { padding: 16px; }
.admin-merina-panel > label { display: block; margin-bottom: 6px; color: var(--text-secondary); font-size: .72rem; font-weight: 700; }
.admin-merina-panel > input { box-sizing: border-box; width: min(100%, 520px); padding: 10px 12px; border: 1px solid #d9d1c5; border-radius: 10px; background: #fff; font: inherit; }
.admin-merina-count { margin: 9px 0; color: var(--text-secondary); font-size: .7rem; }
.admin-merina-list, .admin-merina-issues { max-height: 430px; margin: 0; padding: 0; overflow: auto; border-top: 1px solid #eee8df; list-style: none; }
.admin-merina-list li, .admin-merina-issues li { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 11px 4px; border-bottom: 1px solid #f0ebe4; font-size: .78rem; }
.admin-merina-list li div span, .admin-merina-issues li div span { display: block; margin-top: 3px; color: var(--text-secondary); }
.admin-merina-list a { display: inline-flex; align-items: center; gap: 3px; color: var(--accent-color); font-size: .7rem; }
.admin-merina-list a .material-symbols-rounded { font-size: 14px; }
.admin-merina-list small, .admin-merina-issues small { color: var(--text-secondary); text-align: right; }
.admin-merina-actions { display: inline-flex; align-items: center; gap: 7px; flex-shrink: 0; }
.admin-merina-actions .admin-people-edit, .admin-merina-actions .admin-account-delete { width: 34px; height: 34px; padding: 6px; border-radius: 8px; }
.admin-merina-actions .admin-people-edit .material-symbols-rounded, .admin-merina-actions .admin-account-delete .material-symbols-rounded { font-size: 18px; }
.admin-anomaly-detail-wrap { display: flex; align-items: center; gap: 10px; }
.admin-merina-loading { display: flex; align-items: center; justify-content: center; gap: 9px; min-height: 150px; color: var(--text-secondary); }
.admin-merina-loading.is-error { color: #9f3028; }
.admin-merina-dialog { width: min(520px, calc(100% - 28px)); padding: 0; overflow: hidden; border: 1px solid #e4ddd2; border-radius: 20px; background: #fffefa; color: var(--text-primary); box-shadow: 0 24px 80px rgb(23 36 60 / .26), 0 2px 6px rgb(63 48 31 / .08); }
.admin-merina-dialog[open] { display: grid; animation: admin-dialog-in 200ms cubic-bezier(.2, .8, .2, 1); }
.admin-merina-dialog::backdrop { background: rgb(18 31 47 / .55); backdrop-filter: blur(6px); }
@keyframes admin-dialog-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.admin-merina-form-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; background: #faf7f1; border-bottom: 1px solid #eee8df; }
.admin-merina-eyebrow { color: var(--accent-color); font-size: .68rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.admin-merina-form-header h3 { margin: 3px 0 0; font-size: 1.15rem; }
.admin-merina-close-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border: 1px solid #ded7ca; border-radius: 50%; background: #fff; color: var(--text-secondary); cursor: pointer; }
.admin-merina-close-btn:hover { color: var(--accent-hover); border-color: var(--accent-color); }
.admin-merina-form-body { display: grid; gap: 13px; padding: 18px 22px; max-height: 60vh; overflow-y: auto; }
.admin-merina-form-row { display: grid; gap: 5px; }
[data-geography-editor], [data-geography-editor] fieldset, [data-geography-editor] fieldset > div { display: grid; gap: 12px; min-width: 0; }
[data-geography-editor] fieldset { margin: 0; padding: 12px; border: 1px solid #d7d1c7; border-radius: 10px; }
[data-geography-editor] legend { font-weight: 700; font-size: .9rem; padding: 0 5px; }
[data-geography-editor] p { margin: 0; color: var(--text-secondary); font-size: .8rem; line-height: 1.5; }
[data-geography-editor] label { font-size: .8rem; color: var(--text-secondary); }
[data-geography-editor] button { justify-self: start; padding: 7px 12px; border: 1px solid #d7d1c7; border-radius: 8px; cursor: pointer; }
[data-geography-editor] input[type="color"] { min-height: 40px; padding: 4px; }
.admin-merina-form-row label { font-size: .78rem; font-weight: 700; color: var(--text-secondary); }
.admin-merina-form-row input, .admin-merina-form-row select, .admin-merina-form-row textarea { box-sizing: border-box; width: 100%; padding: 9px 12px; border: 1px solid #d7d1c7; border-radius: 10px; background: #fff; color: var(--text-primary); font: inherit; font-size: .84rem; }
.admin-merina-form-row input:focus, .admin-merina-form-row select:focus, .admin-merina-form-row textarea:focus { border-color: var(--accent-color); outline: 0; box-shadow: 0 0 0 3px rgb(7 135 139 / .12); }
.admin-merina-form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.admin-merina-edit-message { min-height: 1.2em; margin: 0 22px; color: #a33b2f; font-size: .76rem; }
.admin-merina-edit-message:empty { display: none; }
.admin-merina-form-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 15px 22px; background: #faf7f1; border-top: 1px solid #eee8df; }
.admin-merina-form-footer .primary-btn { display: inline-flex; align-items: center; gap: 6px; }
.admin-merina-form-footer .primary-btn .material-symbols-rounded { font-size: 18px; }
.admin-merina-form-section { display: grid; gap: 10px; margin-top: 4px; padding: 14px 16px; border: 1px solid #e2ddd3; border-radius: 14px; background: #faf8f3; }
.admin-merina-form-section legend { display: inline-flex; align-items: center; gap: 6px; padding: 0 6px; font-size: .82rem; font-weight: 800; color: var(--accent-color); }
.admin-merina-form-section legend .material-symbols-rounded { font-size: 18px; }
.admin-merina-form-section input[type="file"] { min-height: 48px; padding: 5px 7px; border: 1px solid #d7d1c7; border-radius: 12px; background: #fff; color: var(--text-secondary); font: inherit; font-size: .8rem; cursor: pointer; transition: border-color var(--trans-fast), box-shadow var(--trans-fast), background var(--trans-fast); }
.admin-merina-form-section input[type="file"]::file-selector-button { min-height: 36px; margin-right: 11px; padding: 8px 14px 8px 36px; border: 0; border-radius: 8px; background-color: var(--accent-color); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4'/%3E%3Cpolyline points='17 8 12 3 7 8'/%3E%3Cline x1='12' y1='3' x2='12' y2='15'/%3E%3C/svg%3E"); background-position: 13px center; background-repeat: no-repeat; color: #fff; font: inherit; font-weight: 750; cursor: pointer; transition: background-color var(--trans-fast), transform var(--trans-fast), box-shadow var(--trans-fast); }
.admin-merina-form-section input[type="file"]:hover { border-color: rgb(7 135 139 / .55); background: #fbfefd; }
.admin-merina-form-section input[type="file"]:hover::file-selector-button { background-color: var(--accent-hover); box-shadow: 0 3px 9px rgb(7 135 139 / .2); }
.admin-merina-form-section input[type="file"]:focus-visible { border-color: var(--accent-color); outline: 0; box-shadow: 0 0 0 3px rgb(7 135 139 / .14); }
.admin-merina-form-section input[type="file"]:active::file-selector-button { transform: translateY(1px); }
.admin-merina-podcast-current { padding: 10px 12px; border: 1px solid rgb(0 143 144 / .25); border-radius: 10px; background: #edf7f5; }
.admin-merina-podcast-preview { display: flex; align-items: center; gap: 12px; }
.admin-podcast-preview-icon { font-size: 26px; color: var(--accent-color); flex-shrink: 0; }
.admin-merina-podcast-meta { display: grid; gap: 5px; min-width: 0; flex: 1 1 auto; }
.admin-merina-podcast-meta strong { font-size: .82rem; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-merina-podcast-meta audio { width: 100%; height: 30px; }
.admin-podcast-remove-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; flex-shrink: 0; padding: 0; border: 1px solid rgb(185 28 28 / .2); border-radius: 8px; background: #fee2e2; color: #b91c1c; cursor: pointer; transition: background var(--trans-fast), transform var(--trans-fast); }
.admin-podcast-remove-btn:hover { background: #fecaca; transform: translateY(-1px); }
.admin-podcast-remove-btn .material-symbols-rounded { font-size: 18px; }
.admin-field-hint { font-size: .74rem; color: var(--text-secondary); line-height: 1.35; }
.admin-merina-podcast-chip { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 7px; background: rgb(0 143 144 / .12); color: var(--accent-color); flex-shrink: 0; }
.admin-merina-podcast-chip .material-symbols-rounded { font-size: 16px; }
.access-link-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 16px 18px; border: 1px solid #ded7ca; border-radius: 16px; background: #fffefa; }
.access-link-toolbar > div { display: grid; gap: 3px; }
.access-link-toolbar span { color: var(--text-secondary); font-size: .75rem; }
.access-link-toolbar .primary-btn { display: inline-flex; align-items: center; gap: 7px; flex: 0 0 auto; }
.access-link-toolbar .primary-btn .material-symbols-rounded { color: inherit; font-size: 18px; }
#access-link-form-panel[hidden], [data-management-panel][hidden], [data-anomaly-panel][hidden] { display: none; }
.admin-insights-grid { display: grid; grid-template-columns: minmax(270px, .8fr) minmax(0, 2fr); align-items: start; gap: 14px; }
.admin-family-panel { min-width: 0; padding: 16px 18px 18px; border: 1px solid #ded7ca; border-radius: 16px; background: #fffefa; }
.admin-family-panel > h3 { margin: 0 0 14px; font-size: .92rem; }
.admin-family-panel .admin-family-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.admin-family-panel .admin-family-card { padding: 14px; border-color: #eee8df; background: #fff; }

@media (max-width: 900px) {
    .admin-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .admin-priority-grid, .admin-insights-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .admin-database-tabs { position: static; grid-template-columns: 1fr; }
    .admin-database-tabs button { justify-content: flex-start; }
    .admin-subnav { margin-bottom: 24px; overflow-x: auto; }
    .admin-subnav button[data-admin-target="admin-overview"] { display: none; }
    .admin-subnav button { min-width: max-content; }
    .admin-summary, .admin-family-panel .admin-family-grid { grid-template-columns: 1fr; }
    .admin-priority-grid { gap: 12px; }
    .admin-main-tabs button { flex: 1; min-width: 0; }
    .admin-merina-summary { grid-template-columns: 1fr; }
    .admin-merina-list li, .admin-merina-issues li { align-items: start; flex-direction: column; }
    .admin-merina-list small, .admin-merina-issues small { text-align: left; }
    .access-link-toolbar { align-items: stretch; flex-direction: column; }
    .access-link-toolbar .primary-btn { justify-content: center; }
    .admin-management-card .admin-accounts-table-wrap { max-height: 520px; padding: 10px; }
    .admin-management-card .admin-accounts-table { min-width: 0; }
    .admin-management-card .admin-accounts-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
    .admin-management-card .admin-accounts-table tbody, .admin-management-card .admin-accounts-table tr, .admin-management-card .admin-accounts-table td { display: block; }
    .admin-management-card .admin-accounts-table tr { margin-bottom: 10px; padding: 12px; border: 1px solid #eee8df; border-radius: 12px; background: #fff; }
    .admin-management-card .admin-accounts-table td { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 10px; padding: 7px 0; border: 0; overflow-wrap: anywhere; }
    .admin-management-card .admin-accounts-table td::before { content: attr(data-label); color: var(--text-secondary); font-size: .68rem; font-weight: 750; letter-spacing: .04em; text-transform: uppercase; }
    .admin-management-card .admin-accounts-table td.admin-accounts-empty { display: block; }
    .admin-management-card .admin-accounts-table td.admin-accounts-empty::before { content: none; }
}
/* People search landing page */
.home-page { display: none; }
.home-open { --header-height: 80px; }
.home-open .app-header { position: fixed; inset: 0 0 auto; width: 100%; height: 80px; pointer-events: auto; }
.home-open .app-main { position: fixed; inset: 80px 0 0; width: 100%; height: calc(100dvh - 80px); }
.home-open .app-header .logo { display: flex; }
.home-button { pointer-events: auto; }
.home-open .app-main > :not(.home-page) { display: none !important; }
.home-open .home-page { display: block; width: 100%; height: 100%; overflow-y: auto; background: radial-gradient(ellipse at 50% 0, #e6f2ef, transparent 65%), var(--bg-color); }
.home-content { width: min(880px, calc(100% - 40px)); margin: 0 auto; padding: clamp(20px, 4vh, 40px) 0 48px; text-align: center; }
.home-hero { --home-card-button-width: 280px; margin-top: 0; }
.home-page.has-search-results .home-hero { display: none; }
.home-history-section {
    margin-top: 32px; padding: 24px 16px 16px; text-align: left;
    background: var(--accent-light); border: 1px solid var(--node-border); border-radius: 24px;
}
.home-history-header { padding: 0 8px 4px; }
.home-history-header h2 { margin: 0 0 6px; color: var(--text-primary); font: 600 30px/1.15 'DM Sans', system-ui, sans-serif; }
.home-history-header p { margin: 0; color: var(--text-secondary); font-size: 13px; line-height: 1.5; }
.home-dynasty-card {
    display: grid; grid-template-columns: auto minmax(0, 1fr) var(--home-card-button-width, 280px); align-items: center; gap: 20px;
    margin: 16px auto 0; padding: 22px 24px; text-align: left;
    color: var(--text-primary); background: var(--bg-panel); border: 1px solid var(--node-border);
    border-radius: 20px; box-shadow: var(--shadow-sm);
    cursor: pointer;
    user-select: none;
    transition: transform var(--trans-fast), box-shadow var(--trans-fast), border-color var(--trans-fast);
}
.home-hero > .home-dynasty-card:first-child {
    margin-top: 38px;
}
.home-dynasty-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 28px rgb(47 38 27 / .09);
    border-color: var(--line-color);
}
.home-dynasty-card:active {
    transform: translateY(0);
}
.home-dynasty-card:focus-within {
    border-color: #a8cfc6;
    box-shadow: 0 0 0 3px rgb(15 133 136 / .15), var(--shadow-md);
}
.home-dynasty-icon {
    width: 52px; height: 52px; display: grid; place-items: center; border-radius: 16px;
    color: var(--accent-hover); background: var(--accent-light); font-size: 27px;
    transition: transform var(--trans-fast);
}
.home-dynasty-card:hover .home-dynasty-icon {
    transform: scale(1.04);
}
.home-dynasty-copy { min-width: 0; }
.home-dynasty-eyebrow { margin: 0 0 5px; color: var(--accent-hover); font-size: 10px; font-weight: 800; letter-spacing: .15em; }
.home-dynasty-copy h2, .home-dynasty-copy h3 { margin: 0 0 5px; font: 600 25px/1.15 'DM Sans', system-ui, sans-serif; }
.home-dynasty-copy > p:last-child { margin: 0; color: var(--text-secondary); font-size: 13px; line-height: 1.5; }
.home-dynasty-button {
    width: 100%; min-height: 46px; height: 46px; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 0 16px; border: 0; border-radius: 12px; white-space: nowrap; cursor: pointer;
    color: #fff; background: var(--accent-hover); font-family: inherit; font-size: .84rem; font-weight: 700;
    box-shadow: 0 8px 18px rgb(15 133 136 / .18); transition: transform var(--trans-fast), background var(--trans-fast), box-shadow var(--trans-fast);
}
.home-dynasty-button:hover,
.home-dynasty-card:hover .home-dynasty-button {
    background: #075e61;
    transform: translateY(-1px);
    box-shadow: 0 10px 22px rgb(15 133 136 / .26);
}
.home-dynasty-button:active,
.home-dynasty-card:active .home-dynasty-button {
    transform: translateY(0);
    box-shadow: 0 4px 10px rgb(15 133 136 / .2);
}
.home-dynasty-button:disabled { opacity: .65; cursor: wait; transform: none; }
.home-dynasty-button .material-symbols-rounded { font-size: 19px; transition: transform var(--trans-fast); }
.home-dynasty-card:hover .home-dynasty-button .material-symbols-rounded { transform: translateX(3px); }
.home-search-box { display: flex; align-items: center; gap: 14px; padding: 0 22px; background: var(--bg-panel); border: 1px solid var(--line-color); border-radius: 32px; box-shadow: var(--shadow-md); color: var(--accent-hover); }
.home-search-box:focus-within { outline: 3px solid #0f858822; }
.home-search-box input { width: 100%; min-width: 0; height: 62px; border: 0; background: transparent; outline: none; font-size: 16px; color: var(--text-primary); }
.home-search-status { margin: 20px 0; color: var(--text-secondary); font-size: 13px; }
.home-search-results { list-style: none; padding: 0; margin: 0; text-align: left; display: grid; gap: 10px; }
.home-search-results button { width: 100%; text-align: left; padding: 18px 24px; border: 1px solid var(--node-border); border-radius: 16px; background: var(--bg-panel); color: var(--text-primary); cursor: pointer; }
.home-search-results button:hover { border-color: var(--accent-color); background: var(--accent-light); }
.home-search-results strong { display: block; font-size: 17px; }
.home-search-results span { display: block; margin-top: 5px; color: var(--text-secondary); font-size: 13px; }
.home-button { display: flex; align-items: center; gap: 6px; flex-shrink: 0; border: 1px solid var(--node-border); border-radius: 20px; padding: 8px 12px; background: var(--bg-panel); color: var(--accent-hover); cursor: pointer; }
.home-open .family-tree-filter, .home-open .mobile-family-toggle, .home-open .search-container, .home-open .mobile-search-toggle, .home-open .landscape-search-toggle, .home-open #home-btn, .home-open #logo-family, .home-open #relationship-mode-btn { display: none !important; }
.home-open .app-header .logo { margin-right: auto; }
.home-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-width: 768px) {
    .home-button { padding: 8px; }
    .home-button > span:last-child { display: none; }
    .home-content { width: calc(100% - 32px); }
    .home-history-section { padding: 20px 10px 10px; }
    .home-dynasty-card { grid-template-columns: auto minmax(0, 1fr); gap: 14px; padding: 18px; }
    .home-dynasty-button { grid-column: 1 / -1; width: 100%; }
}

/* Global site footer */
.site-footer {
    position: fixed;
    inset: auto 0 0;
    z-index: 9;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    min-height: var(--footer-height);
    padding: 5px clamp(12px, 2vw, 28px) max(5px, env(safe-area-inset-bottom));
    border-top: 1px solid rgb(216 195 162 / .7);
    background: rgb(255 253 249 / .9);
    box-shadow: 0 -4px 18px rgb(31 45 48 / .06);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}
.site-footer-credit {
    grid-column: 2;
    color: var(--text-secondary);
    font-size: .72rem;
    font-weight: 650;
    letter-spacing: .02em;
    text-decoration: none;
    transition: color var(--trans-fast);
}
.site-footer-credit:hover,
.site-footer-credit:focus-visible { color: var(--accent-hover); }
.site-footer-legal { grid-column: 1; justify-self: start; color: var(--text-secondary); font-size: .7rem; font-weight: 650; text-decoration: underline; text-decoration-color: rgb(15 133 136 / .35); text-underline-offset: 3px; transition: color var(--trans-fast); }
.site-footer-legal:hover,
.site-footer-legal:focus-visible { color: var(--accent-hover); }
.site-footer-whatsapp {
    grid-column: 3;
    justify-self: end;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    color: #188b46;
    font-size: .7rem;
    font-weight: 700;
    text-decoration: none;
    transition: transform var(--trans-fast), color var(--trans-fast);
}
.site-footer-whatsapp:hover { color: #137239; transform: translateY(-1px); }
.site-footer-whatsapp:focus-visible { outline: 3px solid rgb(37 211 102 / .3); outline-offset: 2px; }
.site-footer-whatsapp svg {
    width: 32px;
    height: 32px;
    padding: 5px;
    border-radius: 50%;
    color: #fff;
    background: #25d366;
    box-shadow: 0 4px 12px rgb(37 211 102 / .25);
}
.site-footer-whatsapp:hover svg { background: #1ebe5b; }
.legal-notice-dialog { width: min(640px, calc(100% - 28px)); max-height: calc(100dvh - 32px); margin: auto; padding: 0; overflow: hidden; border: 1px solid #ddd4c7; border-radius: 22px; background: #fffefa; color: var(--text-primary); box-shadow: 0 30px 90px rgb(16 29 35 / .28); }
.legal-notice-dialog::backdrop { background: rgb(18 31 47 / .56); backdrop-filter: blur(7px); }
.legal-notice-dialog form { display: grid; max-height: calc(100dvh - 32px); }
.legal-notice-dialog header { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 24px 18px; border-bottom: 1px solid #e8e0d5; background: var(--accent-light); }
.legal-notice-dialog header span { color: var(--accent-color); font-size: .66rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.legal-notice-dialog h2 { margin: 2px 0 0; font: 700 2rem/1 'Cormorant Garamond', Georgia, serif; }
.legal-notice-dialog header button { flex: 0 0 auto; width: 38px; height: 38px; border: 1px solid #cbded8; border-radius: 50%; background: #fff; color: #566; font-size: 1.3rem; cursor: pointer; }
.legal-notice-content { display: grid; gap: 18px; padding: 24px; overflow-y: auto; }
.legal-notice-content section { display: grid; gap: 6px; }
.legal-notice-content h3 { margin: 0; color: var(--accent-hover); font-size: .85rem; }
.legal-notice-content p { margin: 0; color: var(--text-secondary); font-size: .8rem; line-height: 1.65; }
.legal-notice-content ul { margin: 0; padding-left: 1.2em; color: var(--text-secondary); font-size: .8rem; line-height: 1.65; }
.legal-notice-content li { margin-bottom: 4px; }
.legal-notice-dialog > form > footer { display: flex; justify-content: flex-end; padding: 16px 24px; border-top: 1px solid #e8e0d5; background: #faf7f1; }
.app-main { margin-bottom: var(--footer-height); }
.home-open .app-main { bottom: var(--footer-height); height: calc(100dvh - var(--header-height) - var(--footer-height)); }

@media (max-width: 768px) {
    .app-main { bottom: var(--footer-height); height: auto; margin-bottom: 0; }
    .site-footer { min-height: var(--footer-height); }
    .site-footer-legal { font-size: .64rem; }
    .legal-notice-dialog header, .legal-notice-content, .legal-notice-dialog > form > footer { padding-left: 18px; padding-right: 18px; }
}

/* ==========================================================================
   Fenêtre modale Paramètres (Settings Dialog)
   ========================================================================== */
.settings-dialog {
    width: min(840px, calc(100% - 32px));
    height: min(700px, calc(100dvh - 36px));
    box-sizing: border-box;
    margin: auto;
    padding: 0;
    overflow: hidden;
    border: 1px solid #ddd3c5;
    border-radius: 24px;
    background: #fffefa;
    color: var(--text-primary);
    box-shadow: 0 35px 95px rgb(18 31 47 / .32), 0 2px 8px rgb(0 0 0 / .08);
}

.settings-dialog::backdrop {
    background: rgb(18 31 47 / .58);
    backdrop-filter: blur(8px) saturate(.9);
}

.settings-dialog[open] {
    animation: auth-dialog-in 240ms cubic-bezier(.2, .8, .2, 1);
}

.settings-dialog-shell {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.settings-dialog-header {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 26px 18px;
    border-bottom: 1px solid #e8e0d5;
    background:
        radial-gradient(circle at 100% 0, rgb(220 241 235 / .65), transparent 45%),
        var(--accent-light);
}

.settings-dialog-title-group {
    display: flex;
    align-items: center;
    gap: 14px;
}

.settings-dialog-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid #c9ded9;
    color: var(--accent-color);
    font-size: 24px;
    box-shadow: 0 2px 8px rgb(15 133 136 / .12);
}

.settings-dialog-eyebrow {
    display: block;
    color: var(--accent-color);
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.settings-dialog h2 {
    margin: 2px 0 0;
    font: 700 1.85rem/1.1 'Cormorant Garamond', Georgia, serif;
    color: var(--text-primary);
}

.settings-close-btn {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border: 1px solid #cbded8;
    border-radius: 50%;
    background: #fff;
    color: #556666;
    font-size: 1.4rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--trans-fast);
}

.settings-close-btn:hover {
    background: #f0f7f5;
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.settings-dialog-body {
    display: grid;
    flex: 1 1 auto;
    grid-template-columns: 210px 1fr;
    min-height: 0;
    overflow: hidden;
}

.settings-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 18px 12px;
    background: #fbf9f5;
    border-right: 1px solid #ebe4d8;
    overflow-y: auto;
}

.settings-nav-item {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 10px 14px;
    border: 0;
    border-radius: 12px;
    background: transparent;
    color: #4a585c;
    font: inherit;
    font-size: .84rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: all var(--trans-fast);
}

.settings-nav-item .material-symbols-rounded {
    font-size: 20px;
    color: #788a8d;
    transition: color var(--trans-fast);
}

.settings-nav-item:hover {
    background: #f0ede6;
    color: var(--text-primary);
}

.settings-nav-item:hover .material-symbols-rounded {
    color: var(--accent-color);
}

.settings-nav-item.is-active {
    background: var(--accent-light);
    color: var(--accent-hover);
    font-weight: 700;
}

.settings-nav-item.is-active .material-symbols-rounded {
    color: var(--accent-color);
}

.settings-content {
    overflow-y: auto;
    padding: 24px 28px;
    background: #fffefa;
}

.settings-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Preserve hidden state even when a settings component uses flex or grid. */
.settings-dialog [hidden] {
    display: none !important;
}

.settings-panel-header {
    border-bottom: 1px solid #ebe4d8;
    padding-bottom: 14px;
}

.settings-panel-header h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.settings-panel-header p {
    margin: 4px 0 0;
    color: var(--text-secondary);
    font-size: .82rem;
}

/* Profil Card */
.settings-profile-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 18px;
    border: 1px solid #e6ded3;
    border-radius: 16px;
    background: #fbf9f4;
}

.settings-avatar-wrap {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    overflow: hidden;
    background: #e9f3f0;
    border: 2px solid var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.settings-avatar-icon {
    font-size: 42px;
    color: var(--accent-color);
}

.settings-avatar-photo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.settings-avatar-photo.hidden { display: none; }

.settings-profile-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow: hidden;
}

.settings-profile-name-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.settings-account-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.settings-account-username {
    font-size: .8rem;
    color: var(--text-secondary);
}

.settings-role-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: .68rem;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.settings-role-badge.role-admin {
    background: #e0f2fe;
    color: #0369a1;
    border: 1px solid #bae6fd;
}

.settings-role-badge.role-member {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #bbf7d0;
}

/* Item cards */
.settings-item-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    border: 1px solid #e6ded3;
    border-radius: 14px;
    background: #fdfcf9;
}

.settings-item-copy strong {
    display: block;
    font-size: .88rem;
    margin-bottom: 2px;
}

.settings-item-copy p {
    margin: 0;
    font-size: .78rem;
    color: var(--text-secondary);
}

.settings-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    font-size: .8rem;
}

.settings-alert-info {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 13px 16px;
    border-radius: 12px;
    background: #eef7f6;
    border: 1px solid #cce5e2;
    color: #174e50;
    font-size: .82rem;
}

.settings-alert-info .material-symbols-rounded {
    color: var(--accent-color);
    font-size: 22px;
    flex-shrink: 0;
}

.settings-alert-info p {
    margin: 2px 0 0;
    line-height: 1.5;
}

/* Form sections */
.settings-form-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 18px;
    border: 1px solid #e8e1d5;
    border-radius: 16px;
    background: #fff;
}

.settings-form-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.settings-form-heading h4 {
    margin: 0;
    font-size: .92rem;
    font-weight: 700;
}

.settings-badge-neutral {
    font-size: .7rem;
    padding: 2px 8px;
    border-radius: 12px;
    background: #f0eee9;
    color: #6a7679;
}

.settings-badge-success {
    font-size: .7rem;
    padding: 2px 8px;
    border-radius: 12px;
    background: #dcfce7;
    color: #166534;
}

.settings-field-hint {
    margin: 0;
    font-size: .76rem;
    color: var(--text-secondary);
}

.settings-form-row {
    display: flex;
    gap: 10px;
}

.settings-form-row input {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid #ddd3c5;
    border-radius: 9px;
    background: #fbf9f5;
    font: inherit;
    font-size: .84rem;
}

.settings-form-row input:focus {
    outline: none;
    border-color: var(--accent-color);
    background: #fff;
    box-shadow: 0 0 0 3px rgb(15 133 136 / .14);
}

.settings-form-grid {
    display: grid;
    gap: 12px;
}

.settings-input-label {
    display: grid;
    gap: 5px;
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-primary);
}

.settings-input-label input {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #ddd3c5;
    border-radius: 9px;
    background: #fbf9f5;
    font: inherit;
    font-size: .84rem;
}

.settings-input-label input:focus {
    outline: none;
    border-color: var(--accent-color);
    background: #fff;
    box-shadow: 0 0 0 3px rgb(15 133 136 / .14);
}

.settings-form-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: 4px;
}

.settings-form-msg {
    margin: 4px 0 0;
    font-size: .78rem;
    min-height: 18px;
}

.settings-form-msg.is-error {
    color: #dc2626;
    font-weight: 600;
}

.settings-form-msg.is-success {
    color: #15803d;
    font-weight: 600;
}

.settings-form-msg.is-loading {
    color: var(--text-secondary);
    font-style: italic;
}

/* Danger / Session zone */
.settings-danger-zone {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 18px;
    border: 1px solid #fed7aa;
    background: #fffbf7;
    border-radius: 14px;
}

.settings-danger-zone strong {
    display: block;
    font-size: .84rem;
    color: #9a3412;
}

.settings-danger-zone p {
    margin: 2px 0 0;
    font-size: .76rem;
    color: #9a3412;
}

.settings-logout-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border: 1px solid #fca5a5;
    border-radius: 10px;
    background: #fef2f2;
    color: #b91c1c;
    font: inherit;
    font-size: .78rem;
    font-weight: 650;
    cursor: pointer;
    transition: all var(--trans-fast);
}

.settings-logout-btn:hover {
    background: #fee2e2;
    border-color: #ef4444;
}

/* About body */
.settings-about-body {
    display: grid;
    gap: 20px;
    font-size: .84rem;
    line-height: 1.65;
    color: var(--text-secondary);
}

.settings-about-hero {
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 18px 20px;
    border: 1px solid #e4ddd1;
    border-radius: 16px;
    background:
        radial-gradient(circle at 100% 0, rgb(220 241 235 / .6), transparent 50%),
        #fbf9f4;
}

.settings-about-logo {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

.settings-about-hero h4 {
    margin: 0;
    font: 700 1.5rem/1 'Cormorant Garamond', Georgia, serif;
    color: var(--accent-hover);
}

.settings-about-version {
    margin: 3px 0 0;
    font-size: .76rem;
    color: var(--text-secondary);
    letter-spacing: .02em;
}

.settings-about-body h5 {
    margin: 0 0 6px;
    font-size: .88rem;
    font-weight: 700;
    color: var(--text-primary);
}

.settings-about-body p {
    margin: 0;
}

.settings-feature-list {
    margin: 6px 0 0;
    padding-left: 1.3em;
    display: grid;
    gap: 6px;
}

.settings-about-body a {
    color: var(--accent-color);
    text-decoration: underline;
    font-weight: 600;
}

/* WhatsApp Card */
.settings-contact-container {
    display: grid;
    gap: 18px;
}

.settings-whatsapp-card {
    padding: 24px;
    border: 1px solid #bbf7d0;
    border-radius: 20px;
    background:
        radial-gradient(circle at 100% 0, rgb(220 252 231 / .75), transparent 60%),
        #f7fef9;
    box-shadow: 0 4px 18px rgb(37 211 102 / .08);
}

.settings-whatsapp-badge {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 4px 11px;
    border-radius: 20px;
    background: #dcfce7;
    color: #15803d;
    font-size: .72rem;
    font-weight: 750;
    margin-bottom: 12px;
}

.whatsapp-icon {
    width: 15px;
    height: 15px;
    fill: #25d366;
}

.settings-whatsapp-card h4 {
    margin: 0 0 8px;
    font-size: 1.15rem;
    font-weight: 700;
    color: #166534;
}

.settings-whatsapp-card p {
    margin: 0 0 18px;
    font-size: .83rem;
    line-height: 1.6;
    color: #274735;
}

.settings-whatsapp-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.whatsapp-direct-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    border-radius: 12px;
    background: #25d366;
    color: #fff !important;
    font-size: .84rem;
    font-weight: 700;
    text-decoration: none !important;
    box-shadow: 0 4px 14px rgb(37 211 102 / .35);
    transition: all var(--trans-fast);
}

.whatsapp-direct-btn:hover {
    background: #1ebe5b;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgb(37 211 102 / .45);
}

.whatsapp-btn-icon {
    width: 18px;
    height: 18px;
    fill: #fff;
    flex-shrink: 0;
}

.settings-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .8rem;
}

.settings-copy-status {
    display: block;
    margin-top: 10px;
    font-size: .78rem;
    font-weight: 600;
    color: #166534;
    opacity: 0;
    transition: opacity var(--trans-fast);
}

.settings-copy-status.is-visible {
    opacity: 1;
}

.settings-contact-alt {
    padding: 14px 18px;
    border: 1px solid #e8e1d5;
    border-radius: 14px;
    background: #fff;
}

.settings-contact-alt-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-contact-alt-item .material-symbols-rounded {
    color: var(--accent-color);
    font-size: 24px;
}

.settings-contact-alt-item strong {
    display: block;
    font-size: .84rem;
}

.settings-contact-alt-item p {
    margin: 2px 0 0;
    font-size: .78rem;
}

.settings-contact-alt-item a {
    color: var(--accent-color);
    text-decoration: underline;
}

/* Legal body */
.settings-legal-body {
    display: grid;
    gap: 18px;
    font-size: .82rem;
    line-height: 1.65;
    color: var(--text-secondary);
}

.settings-legal-body h4 {
    margin: 0 0 5px;
    font-size: .88rem;
    font-weight: 700;
    color: var(--accent-hover);
}

.settings-legal-body p {
    margin: 0;
}

/* Mobile Responsiveness for Settings Dialog */
@media (max-width: 680px) {
    .settings-dialog {
        width: calc(100% - 20px);
        height: calc(100dvh - 20px);
        border-radius: 18px;
    }
    .settings-dialog-header {
        padding: 16px 18px;
    }
    .settings-dialog-body {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }
    .settings-nav {
        flex-direction: row;
        overflow-x: auto;
        border-right: 0;
        border-bottom: 1px solid #ebe4d8;
        padding: 8px 12px;
        gap: 6px;
    }
    .settings-nav-item {
        padding: 7px 12px;
        font-size: .78rem;
        white-space: nowrap;
        width: auto;
    }
    .settings-nav-item .material-symbols-rounded {
        font-size: 18px;
    }
    .settings-content {
        padding: 18px 16px;
    }
    .settings-form-row {
        flex-direction: column;
    }
    .settings-whatsapp-actions {
        flex-direction: column;
        align-items: stretch;
    }
}
