/**
 * DeepRoots — unified design tokens & shared UI
 * Load before frontend.css, dashboard.css, or admin.css
 */
:root {
    /* Logo palette — forest, teal, lime, cream */
    --dr-forest-deep: #052e24;
    --dr-forest: #0a4d3f;
    --dr-primary-dark: #0d5c4a;
    --dr-primary: #0f766e;
    --dr-primary-hover: #14b8a6;
    --dr-teal: #0d9488;
    --dr-teal-light: #2dd4bf;
    --dr-cyan: #5eead4;
    --dr-lime: #a3e635;
    --dr-lime-dark: #84cc16;
    --dr-lime-muted: #ecfccb;
    --dr-cream: #fefce8;
    --dr-gold: #fde047;

    --dr-bg: #eef8f4;
    --dr-surface: #ffffff;
    --dr-surface-2: #f4fbf8;
    --dr-surface-3: #e6f4ef;
    --dr-text: #0c2922;
    --dr-text-muted: #4b6b61;
    --dr-text-subtle: #6b8f83;
    --dr-primary-light: #ccfbf1;
    --dr-primary-muted: #e6fffa;
    --dr-accent: #ca8a04;
    --dr-accent-lime: var(--dr-lime);
    --dr-border: #c5e8dc;
    --dr-border-strong: #9fd4c4;
    --dr-danger: #dc2626;
    --dr-success: #15803d;
    --dr-shadow-xs: 0 1px 2px rgba(10, 77, 63, 0.06);
    --dr-shadow: 0 1px 3px rgba(10, 77, 63, 0.08), 0 4px 16px rgba(10, 77, 63, 0.06);
    --dr-shadow-lg: 0 12px 40px rgba(10, 77, 63, 0.12), 0 2px 8px rgba(10, 77, 63, 0.06);
    --dr-radius: 12px;
    --dr-radius-sm: 8px;
    --dr-radius-lg: 16px;
    --dr-radius-pill: 999px;
    --dr-font: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
    --dr-gradient: linear-gradient(135deg, #0f766e 0%, #0a4d3f 100%);
    --dr-gradient-soft: linear-gradient(135deg, #14b8a6 0%, #0f766e 45%, #0a4d3f 100%);
    --dr-gradient-header: linear-gradient(135deg, #0a4d3f 0%, #0f766e 50%, #0d9488 100%);
    --dr-gradient-hero: linear-gradient(128deg, #052e24 0%, #0a4d3f 22%, #0f766e 48%, #0d9488 72%, #0d5c4a 100%);
    --dr-gradient-login: linear-gradient(145deg, #052e24 0%, #0a4d3f 28%, #0f766e 52%, #0d9488 78%, #0d5c4a 100%);
    --dr-gradient-lime-accent: linear-gradient(90deg, #0f766e 0%, #a3e635 100%);
    --dr-bg-pattern:
        radial-gradient(ellipse 90% 70% at 0% 0%, rgba(163, 230, 53, 0.09) 0%, transparent 52%),
        radial-gradient(ellipse 80% 60% at 100% 100%, rgba(15, 118, 110, 0.1) 0%, transparent 55%);
    --dr-focus-ring: 0 0 0 3px rgba(15, 118, 110, 0.32);
    --dr-nav-h: clamp(64px, 11vw, 80px);
    --dr-space-1: 4px;
    --dr-space-2: 8px;
    --dr-space-3: 12px;
    --dr-space-4: 16px;
    --dr-space-5: 20px;
    --dr-space-6: 24px;
    --dr-text-xs: 0.75rem;
    --dr-text-sm: 0.8125rem;
    --dr-text-base: 0.875rem;
    --dr-text-lg: 1rem;
    --dr-text-xl: 1.25rem;
    --dr-text-2xl: 1.5rem;
    --dr-leading: 1.5;
    --dr-modal-overlay: rgba(5, 46, 36, 0.48);
    --dr-z-dropdown: 100002;
    --dr-z-modal: 100050;
    --dr-z-modal-nested: 100070;
    --dr-z-modal-top: 100080;
}

/* Branded page backgrounds (logo greens + lime glow) */
body.deeproots-theme,
body.deeproots-dashboard-page,
body.dr-dashboard-body,
body.deeproots-login-page,
body.deeproots-family-tree-page,
body.page-slug-family-tree,
body.deeproots-showcase-page {
    background-color: var(--dr-bg);
    background-image: var(--dr-bg-pattern);
    background-attachment: fixed;
}

/* Shared primary button (tree modals, inline HTML) */
.deeproots-theme .btn.dr-btn-primary,
.dr-btn-primary,
.btn.dr-btn-primary {
    background: var(--dr-primary) !important;
    color: #fff !important;
    border: none !important;
    border-radius: var(--dr-radius-sm) !important;
    font-weight: 600;
    transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
}

.deeproots-theme .btn.dr-btn-primary:hover,
.dr-btn-primary:hover {
    background: var(--dr-primary-hover) !important;
}

/* Modals & forms (about, login, public pages) */
.deeproots-modal {
    display: none;
    position: fixed;
    z-index: 100000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--dr-modal-overlay);
    backdrop-filter: blur(4px);
}

.deeproots-modal.is-open,
.deeproots-modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow-y: auto;
}

.deeproots-modal-content {
    background: var(--dr-surface);
    margin-left: auto;
    margin-right: auto;
    padding: 32px;
    border-radius: var(--dr-radius);
    max-width: 440px;
    width: 100%;
    box-sizing: border-box;
    box-shadow: var(--dr-shadow-lg);
    position: relative;
    border: 1px solid var(--dr-border);
}

.deeproots-modal-close {
    position: absolute;
    right: 16px;
    top: 12px;
    font-size: 28px;
    font-weight: 300;
    color: var(--dr-text-muted);
    cursor: pointer;
    line-height: 1;
}

.deeproots-modal-close:hover {
    color: var(--dr-text);
}

.deeproots-form-group {
    margin-bottom: 18px;
}

.deeproots-form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
    color: var(--dr-text);
}

.deeproots-form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--dr-border);
    border-radius: var(--dr-radius-sm);
    font-size: 15px;
    font-family: var(--dr-font);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.deeproots-form-group input:focus {
    outline: none;
    border-color: var(--dr-primary);
    box-shadow: var(--dr-focus-ring);
}

.deeproots-submit-btn {
    width: 100%;
    padding: 12px 20px;
    background: var(--dr-gradient);
    color: #fff;
    border: none;
    border-radius: var(--dr-radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--dr-font);
    transition: opacity 0.2s, transform 0.15s;
}

.deeproots-submit-btn:hover {
    opacity: 0.95;
    transform: translateY(-1px);
}

.deeproots-message {
    padding: 10px 12px;
    border-radius: var(--dr-radius-sm);
    margin-bottom: 12px;
    font-size: 14px;
    display: none;
}

.deeproots-message.error {
    display: block;
    background: #fef2f2;
    color: var(--dr-danger);
    border: 1px solid #fecaca;
}

.deeproots-message.success {
    display: block;
    background: #ecfdf5;
    color: var(--dr-success);
    border: 1px solid #a7f3d0;
}

/* Public about / marketing sections */
.deeproots-about-page {
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    font-family: var(--dr-font);
    color: var(--dr-text);
}

.deeproots-hero {
    text-align: center;
    padding: 88px 24px;
    background: var(--dr-gradient);
    color: #fff;
    position: relative;
    overflow: hidden;
}

.deeproots-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><defs><pattern id="grid" width="100" height="100" patternUnits="userSpaceOnUse"><path d="M 100 0 L 0 0 0 100" fill="none" stroke="rgba(255,255,255,0.06)" stroke-width="1"/></pattern></defs><rect width="100" height="100" fill="url(%23grid)"/></svg>');
    opacity: 0.4;
    pointer-events: none;
}

.deeproots-hero > * {
    position: relative;
    z-index: 1;
}

.deeproots-hero h1 {
    font-size: clamp(2rem, 5vw, 3.5rem);
    margin: 0 0 16px;
    font-weight: 700;
    line-height: 1.2;
}

.hero-subtitle {
    font-size: clamp(1rem, 2.2vw, 1.35rem);
    opacity: 0.95;
    margin: 0 auto 32px;
    max-width: 640px;
    line-height: 1.6;
}

.deeproots-login-button {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    padding: 14px 32px;
    border-radius: var(--dr-radius-pill);
    font-size: 1.05rem;
    font-weight: 600;
    border: 2px solid rgba(255, 255, 255, 0.45);
    cursor: pointer;
    font-family: inherit;
    transition: all 0.25s ease;
    backdrop-filter: blur(8px);
}

.deeproots-login-button:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

.deeproots-login-button-light {
    background: var(--dr-gradient);
    border-color: transparent;
    box-shadow: var(--dr-shadow);
}

.deeproots-about-section {
    background: var(--dr-surface);
    padding: 56px 32px;
    border-bottom: 1px solid var(--dr-border);
}

.deeproots-about-section h2 {
    font-size: clamp(1.5rem, 3vw, 2rem);
    margin: 0 0 20px;
    color: var(--dr-text);
}

.deeproots-about-section h2::after {
    content: '';
    display: block;
    width: 56px;
    height: 4px;
    background: var(--dr-gradient);
    border-radius: 2px;
    margin-top: 12px;
}

/* Standalone shell */
body.deeproots-standalone {
    margin: 0;
    font-family: var(--dr-font);
    background: var(--dr-bg);
}

.deeproots-standalone-wrapper {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.deeproots-header,
.deeproots-footer {
    background: var(--dr-gradient-header);
    color: #fff;
}

.deeproots-header {
    padding: 10px 0;
    box-shadow: var(--dr-shadow);
}

body.deeproots-standalone .deeproots-header.dr-showcase-site-header {
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

.deeproots-header-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.deeproots-header h1 {
    margin: 0;
    font-size: clamp(1.25rem, 2.5vw, 1.75rem);
    font-weight: 700;
}

.deeproots-header nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

.deeproots-header nav a {
    color: #fff;
    text-decoration: none;
    padding: 8px 14px;
    border-radius: var(--dr-radius-sm);
    font-weight: 500;
    transition: background 0.2s;
}

.deeproots-header nav a:not(.deeproots-login-link):hover {
    background: rgba(255, 255, 255, 0.12);
}

.deeproots-header .dr-brand--logo {
    flex-shrink: 0;
}

.deeproots-header nav .deeproots-login-link {
    background: rgba(255, 255, 255, 0.18);
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: var(--dr-radius-pill);
    font-weight: 600;
}

.deeproots-main {
    flex: 1;
    width: 100%;
}

.deeproots-footer {
    padding: 40px 0;
    margin-top: auto;
}

.deeproots-footer-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    text-align: center;
}

.deeproots-footer p {
    margin: 6px 0;
    opacity: 0.9;
    font-size: 0.95rem;
}

/* Member login page */
body.deeproots-login-page {
    font-family: var(--dr-font);
    background: var(--dr-gradient-login);
    background-image: var(--dr-gradient-login), var(--dr-bg-pattern);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
}

.deeproots-login-page .login-container {
    background: var(--dr-surface);
    padding: 40px;
    border-radius: var(--dr-radius);
    box-shadow: var(--dr-shadow-lg);
    max-width: 420px;
    width: 90%;
    border: 1px solid var(--dr-border-strong);
    border-top: 3px solid var(--dr-lime);
}

.deeproots-login-page .login-container h1,
.dr-login-brand {
    margin-bottom: 20px;
    color: var(--dr-text);
    font-size: 1.5rem;
}

.dr-login-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
}

.deeproots-header .dr-login-brand {
    margin-bottom: 0;
    color: #fff;
    font-size: 1.35rem;
}

.deeproots-header .dr-login-brand .dr-brand-icon {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: none;
}

.deeproots-login-page .form-group input:focus {
    border-color: var(--dr-primary);
    box-shadow: var(--dr-focus-ring);
}

.deeproots-login-page .btn-login {
    width: 100%;
    padding: 12px;
    background: var(--dr-primary);
    color: #fff;
    border: none;
    border-radius: var(--dr-radius-sm);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.deeproots-login-page .btn-login:hover {
    background: var(--dr-primary-hover);
}

/* ==========================================================================
   DeepRoots App Shell — shared across Dashboard & Family Tree
   ========================================================================== */

.dr-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--dr-text);
    font-weight: 700;
    font-size: var(--dr-text-lg);
    letter-spacing: -0.02em;
}

.dr-brand-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--dr-radius-sm);
    background: var(--dr-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: var(--dr-shadow-xs);
}

.dr-brand-icon svg {
    width: 18px;
    height: 18px;
    color: #fff;
}

.dr-brand-text {
    background: var(--dr-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Official logo image (DEEPROOTS_OFFICIAL_LOGO_URL / deeproots_logo_url()) */
.dr-logo {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    object-fit: contain;
}

.dr-logo-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border-radius: var(--dr-radius-sm);
    line-height: 0;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 10px rgba(15, 118, 110, 0.18));
}

.dr-logo--nav {
    height: 48px;
    width: auto;
    max-width: 52px;
}

.dr-logo-wrap--nav {
    padding: 4px 8px;
}

.dr-logo--tree {
    height: 92px;
    width: 92px;
    max-width: 92px;
    object-fit: contain;
    object-position: center;
    border-radius: 50%;
}

.dr-logo-wrap--tree {
    padding: 0;
    background: transparent;
    border-radius: 50%;
}

.dr-logo--login {
    height: 140px;
    width: auto;
    max-width: min(280px, 78vw);
}

.dr-logo-wrap--login {
    padding: 8px 12px;
    border-radius: var(--dr-radius);
}

.dr-logo--hero {
    height: 112px;
    width: auto;
    max-width: 120px;
    opacity: 0.95;
}

.dr-logo-wrap--hero {
    padding: 4px 6px;
    background: #fff;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.1);
}

/* Dashboard hero: double disc (outer ring in dashboard.css + inner wrap) */
.dr-hero-mark .dr-logo-wrap--hero {
    background: #fff;
}

.dr-logo--security {
    height: 72px;
    width: auto;
    max-width: 80px;
}

.dr-security-modal__brand {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}

.dr-logo--admin {
    height: 56px !important;
    width: auto !important;
    max-width: 64px !important;
    max-height: 56px !important;
    object-fit: contain;
}

.dr-logo-wrap--admin {
    display: inline-flex;
    padding: 0;
    margin: 0 0 8px;
    background: transparent !important;
}

.dr-admin-brand-compact {
    display: block;
    margin-bottom: 10px;
    line-height: 0;
}

.dr-logo--standalone {
    height: auto;
    width: auto;
    max-height: 52px;
    max-width: min(280px, 55vw);
    object-fit: contain;
    object-position: left center;
}

.dr-logo-wrap--standalone {
    padding: 6px 12px;
}

/* Dark app headers — slim bar, large logo overlapping below (family tree reference) */
body.deeproots-theme,
body.deeproots-dashboard-page,
body.page-slug-deeproots-dashboard,
body.deeproots-family-tree-page,
body.page-slug-family-tree,
body.deeproots-standalone {
    --dr-header-bar-h: 56px;
    --dr-header-logo-h: clamp(104px, 16vw, 128px);
    --dr-header-logo-overhang: max(14px, calc((var(--dr-header-logo-h) - var(--dr-header-bar-h)) / 2));
    --dr-nav-h: calc(var(--dr-header-bar-h) + var(--dr-header-logo-overhang) + 12px);
}

/* Dark headers: full emblem, no pill — transparent PNG only */
.dr-logo--header-bar {
    height: var(--dr-header-logo-h, clamp(104px, 16vw, 128px));
    width: auto;
    max-width: min(320px, 68vw);
    max-height: var(--dr-header-logo-h, 128px);
    object-fit: contain;
    object-position: left center;
    filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.35));
}

/* Unified app headers (tree, dashboard, standalone top bar) */
.dr-brand--header,
.dr-brand--header-overlap,
.deeproots-header .dr-brand--header,
.deeproots-header .dr-brand--header-overlap {
    display: inline-flex;
    align-items: center;
    padding: 0;
    margin: 0;
    background: transparent;
    border-radius: 0;
    line-height: 0;
    max-width: min(320px, 68vw);
    text-decoration: none;
    flex-shrink: 0;
    z-index: 3;
}

.dr-app-header .dr-brand--header,
.dr-app-header .dr-brand--header-overlap {
    transform: none !important;
}

.dr-brand--header-overlap,
.dr-brand--header.dr-brand--header-overlap {
    align-self: center;
    transform: translateY(var(--dr-header-logo-overhang, 16px));
}

.dr-brand--header .dr-logo-wrap,
.dr-brand--header .dr-logo-wrap--standalone,
.dr-brand--header .dr-logo-wrap--nav,
.dr-brand--header .dr-logo-wrap--tree,
.dr-brand--header-overlap .dr-logo-wrap {
    background: transparent !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    filter: none;
}

.dr-brand--header .dr-logo--header-bar,
.dr-brand--header-overlap .dr-logo--header-bar,
header.modern-header .dr-brand--header .dr-logo--header-bar,
header.modern-header .brand-link .dr-logo--header-bar,
.dr-nav .dr-brand--header .dr-logo--header-bar,
.deeproots-header .dr-brand--header .dr-logo--header-bar {
    height: var(--dr-header-logo-h, clamp(104px, 16vw, 128px)) !important;
    width: auto !important;
    max-width: min(320px, 68vw) !important;
    max-height: var(--dr-header-logo-h, 128px) !important;
    border-radius: 0 !important;
    object-fit: contain !important;
    object-position: left center !important;
    filter: drop-shadow(0 2px 10px rgba(0, 0, 0, 0.35)) !important;
}

/* Shells: slim bar, room for logo overhang; controls stay vertically centered */
.dr-nav,
body.deeproots-family-tree-page header.modern-header,
body.page-slug-family-tree header.modern-header,
body.deeproots-standalone .deeproots-header:not(.dr-showcase-site-header) {
    overflow: visible !important;
    padding-bottom: var(--dr-header-logo-overhang, 16px) !important;
}

.dr-nav-inner,
body.deeproots-family-tree-page header.modern-header,
body.page-slug-family-tree header.modern-header,
body.deeproots-standalone .deeproots-header-content {
    min-height: var(--dr-header-bar-h, 56px) !important;
    height: auto !important;
    max-height: none !important;
    align-items: center !important;
    overflow: visible !important;
}

/* Dashboard: fixed bar height; no extra green padding under controls */
body.deeproots-dashboard-page .dr-nav.dr-dash-header,
body.page-slug-deeproots-dashboard .dr-nav.dr-dash-header {
    padding-bottom: 0 !important;
}

body.deeproots-dashboard-page .dr-nav.dr-dash-header .dr-nav-inner,
body.deeproots-dashboard-page .dr-nav.dr-dash-header .dr-dash-header__inner,
body.page-slug-deeproots-dashboard .dr-nav.dr-dash-header .dr-nav-inner,
body.page-slug-deeproots-dashboard .dr-nav.dr-dash-header .dr-dash-header__inner {
    height: var(--dr-header-bar-h, 44px) !important;
    max-height: var(--dr-header-bar-h, 44px) !important;
    align-items: center !important;
}

/* Family tree: same slim bar — stats + tools centered; logo hangs separately */
body.deeproots-family-tree-page header.modern-header.dr-tree-dash-header,
body.page-slug-family-tree header.modern-header.dr-tree-dash-header {
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

body.deeproots-family-tree-page header.modern-header.dr-tree-dash-header .dr-tree-header__inner,
body.page-slug-family-tree header.modern-header.dr-tree-dash-header .dr-tree-header__inner {
    height: var(--dr-header-bar-h, 44px) !important;
    max-height: var(--dr-header-bar-h, 44px) !important;
    align-items: center !important;
}

body.deeproots-family-tree-page header.modern-header.dr-tree-dash-header .dr-tree-header__toolbar,
body.page-slug-family-tree header.modern-header.dr-tree-dash-header .dr-tree-header__toolbar,
body.deeproots-family-tree-page header.modern-header.dr-tree-dash-header .action-buttons,
body.page-slug-family-tree header.modern-header.dr-tree-dash-header .user-menu {
    align-self: center !important;
}

body.deeproots-standalone .deeproots-header.dr-showcase-site-header {
    padding-bottom: 0 !important;
}

body.deeproots-standalone .deeproots-header-content.dr-showcase-header__inner {
    height: var(--dr-header-bar-h, 44px) !important;
    max-height: var(--dr-header-bar-h, 44px) !important;
    align-items: center !important;
}

.dr-nav-quick,
.dr-nav-actions,
.dr-nav-toggle,
.dr-nav .dr-user-chip,
header.modern-header .header-actions-section,
header.modern-header .header-controls-section,
body.deeproots-standalone .deeproots-header nav {
    align-self: center !important;
}

@media (max-width: 768px) {
    body.deeproots-theme,
    body.deeproots-dashboard-page,
    body.page-slug-deeproots-dashboard,
    body.deeproots-family-tree-page,
    body.page-slug-family-tree,
    body.deeproots-standalone {
        --dr-header-bar-h: 52px;
        --dr-header-logo-h: clamp(88px, 20vw, 108px);
    }

    .dr-brand--header .dr-logo--header-bar,
    .dr-brand--header-overlap .dr-logo--header-bar,
    header.modern-header .dr-brand--header .dr-logo--header-bar,
    .dr-nav .dr-brand--header .dr-logo--header-bar {
        max-width: min(248px, 52vw) !important;
        max-height: var(--dr-header-logo-h, 108px) !important;
    }
}

@media (max-width: 640px) {
    body.deeproots-theme,
    body.deeproots-dashboard-page,
    body.page-slug-deeproots-dashboard,
    body.deeproots-family-tree-page,
    body.page-slug-family-tree,
    body.deeproots-standalone {
        --dr-header-bar-h: 48px;
        --dr-header-logo-h: clamp(80px, 18vw, 100px);
    }

    .dr-brand--header .dr-logo--header-bar,
    .dr-brand--header-overlap .dr-logo--header-bar,
    header.modern-header .dr-brand--header .dr-logo--header-bar,
    .dr-nav .dr-brand--header .dr-logo--header-bar {
        max-width: min(220px, 58vw) !important;
        max-height: var(--dr-header-logo-h, 100px) !important;
    }
}

.dr-brand--logo {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    line-height: 0;
    flex-shrink: 0;
}

.dr-brand--logo:hover {
    opacity: 0.92;
}

.dr-login-brand--logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    text-align: center;
}

.dr-login-brand--logo .dr-logo--header-bar,
.deeproots-modal-brand.dr-login-brand--logo .dr-logo--header-bar {
    height: clamp(56px, 12vw, 88px);
    max-width: min(320px, 85vw);
    max-height: 88px;
    margin: 0 auto;
    object-fit: contain;
    object-position: center;
}

.dr-login-brand-caption {
    margin: 0;
    font-size: var(--dr-text-lg);
    font-weight: 700;
    color: var(--dr-text);
}

.deeproots-header .dr-login-brand--logo .dr-login-brand-caption {
    color: #fff;
}

.deeproots-hero .dr-hero-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 12px;
}

.dr-icon-btn,
.action-btn.dr-icon-btn,
header.modern-header .action-btn {
    width: 36px;
    height: 36px;
    min-width: 36px;
    padding: 0;
    border: 1px solid var(--dr-border);
    border-radius: var(--dr-radius-sm);
    background: var(--dr-surface);
    color: var(--dr-text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s;
    position: relative;
    font-size: 0;
    line-height: 0;
}

.dr-icon-btn svg,
.action-btn.dr-icon-btn svg,
header.modern-header .action-btn svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.dr-icon-btn:hover,
.action-btn.dr-icon-btn:hover,
header.modern-header .action-btn:hover {
    background: var(--dr-primary-muted);
    border-color: var(--dr-cyan);
    color: var(--dr-primary);
    transform: none;
    box-shadow: var(--dr-shadow-xs);
}

.dr-badge-dot {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid var(--dr-surface);
    display: none;
}

.dr-badge-dot.is-visible {
    display: block;
}

/* Unified modals (tree + dashboard) */
.modal,
.dr-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: var(--dr-z-modal);
    background: var(--dr-modal-overlay);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    padding: var(--dr-space-6);
    overflow: hidden;
    align-items: center;
    justify-content: center;
}

.modal[style*="display: block"],
.modal.is-open {
    display: flex !important;
}

/* Stacked modals (e.g. calendar event detail above calendar) */
#calendarEventDetailModal,
.modal.modal--nested {
    z-index: var(--dr-z-modal-nested) !important;
}

.modal.modal--nested-top {
    z-index: var(--dr-z-modal-top) !important;
}

.modal.is-underlay {
    z-index: calc(var(--dr-z-modal) - 10) !important;
}

.modal-content,
.dr-modal__panel {
    background: var(--dr-surface);
    margin: auto;
    width: 100%;
    max-width: 560px;
    max-height: min(85vh, 720px);
    border-radius: var(--dr-radius-lg);
    border: 1px solid var(--dr-border);
    box-shadow: var(--dr-shadow-lg);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: drModalIn 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-content--wide,
.dr-modal__panel--wide {
    max-width: 720px;
}

.modal-content--calendar,
.dr-modal__panel--calendar {
    max-width: 640px;
}

@keyframes drModalIn {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Accent bar — full rules in modals-ui.css */

.modal .close,
.dr-modal__close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    float: none;
    border: none;
    border-radius: var(--dr-radius-sm);
    background: var(--dr-surface-2);
    color: var(--dr-text-muted);
    font-size: 20px;
    font-weight: 400;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: background 0.15s, color 0.15s;
}

.modal .close::before,
.dr-modal__close::before {
    display: none;
}

.modal .close:hover,
.dr-modal__close:hover {
    background: var(--dr-border);
    color: var(--dr-text);
    transform: none;
}

/* Modal / dialog headings — close btn is absolute, so titles are truly centered */
.dr-modal__header,
.modal-content > h2,
.deeproots-modal-content > h2 {
    padding: 18px 48px 14px;
    margin: 0;
    font-size: var(--dr-text-lg);
    font-weight: 700;
    color: var(--dr-text);
    border-bottom: 1px solid var(--dr-border);
    letter-spacing: -0.02em;
    line-height: 1.3;
    text-align: center;
    flex-shrink: 0;
}

.dr-modal-toolbar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.75rem;
    padding: 18px 48px 14px;
    margin: 0;
    border-bottom: 1px solid var(--dr-border);
    position: relative;
}

.dr-modal-toolbar h2 {
    grid-column: 2;
    margin: 0;
    padding: 0 0.5rem;
    font-size: var(--dr-text-lg);
    font-weight: 700;
    color: var(--dr-text);
    letter-spacing: -0.02em;
    line-height: 1.3;
    text-align: center;
    justify-self: center;
}

.dr-modal-toolbar .dr-btn,
.dr-modal-toolbar .dr-btn-primary {
    grid-column: 3;
    justify-self: end;
}

.modal-content--security .dr-security-modal__brand {
    padding: 1rem 1.5rem 0;
    margin-bottom: 0;
}

.modal-content--security > h2,
.modal-content--security #totpSetupTitle {
    text-align: center;
    padding: 0.5rem 1.5rem 0.25rem;
    border-bottom: none;
}

/* App shells flush to viewport top (no theme gap above header/nav) */
html:has(body.deeproots-dashboard-page),
html:has(body.page-slug-deeproots-dashboard),
html:has(body.deeproots-family-tree-page),
html:has(body.page-slug-family-tree),
html:has(body.deeproots-showcase-page),
html.admin-bar:has(body.deeproots-dashboard-page),
html.admin-bar:has(body.deeproots-family-tree-page) {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

body.deeproots-dashboard-page,
body.page-slug-deeproots-dashboard,
body.deeproots-family-tree-page,
body.page-slug-family-tree,
body.deeproots-showcase-page {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

body.deeproots-dashboard-page :is(#page, .site, .site-inner, #wrapper, .content-area, .site-content, #content, main, article, .hentry, .entry-content, .wp-block-post-content, .wp-block-group, .wp-block-group__inner-container),
body.page-slug-deeproots-dashboard :is(#page, .site, .site-inner, #wrapper, .content-area, .site-content, #content, main, article, .hentry, .entry-content, .wp-block-post-content, .wp-block-group, .wp-block-group__inner-container),
body.deeproots-family-tree-page :is(#page, .site, .site-inner, #wrapper, .content-area, .site-content, #content, main, article, .hentry, .entry-content, .wp-block-post-content, .wp-block-group, .wp-block-group__inner-container, .alignwide, .alignfull),
body.page-slug-family-tree :is(#page, .site, .site-inner, #wrapper, .content-area, .site-content, #content, main, article, .hentry, .entry-content, .wp-block-post-content, .wp-block-group, .wp-block-group__inner-container, .alignwide, .alignfull),
body.deeproots-family-app-page :is(#page, .site, .site-inner, #wrapper, .content-area, .site-content, #content, main, article, .hentry, .entry-content, .wp-block-post-content, .wp-block-group, .wp-block-group__inner-container) {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

body.deeproots-family-tree-page.admin-bar,
body.page-slug-family-tree.admin-bar {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

.dr-modal__body,
#modalBody,
#dashboardBody,
#calendarBody,
#feedBody,
#storiesBody,
#memorialBody,
#giftsBody,
#galleryBody,
#historyBody,
#notificationsBody,
#messagesBody,
#settingsBody,
#filtersBody,
#relationshipBody,
#legendBody,
#timelineBody,
#submitChangeBody,
#exportBody {
    padding: var(--dr-space-4) var(--dr-space-5) var(--dr-space-5);
    overflow-x: hidden;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    font-size: var(--dr-text-base);
    line-height: var(--dr-leading);
    scrollbar-width: thin;
    scrollbar-color: var(--dr-teal) var(--dr-surface-3);
}

.dr-modal__body::-webkit-scrollbar,
#settingsBody::-webkit-scrollbar,
#filtersBody::-webkit-scrollbar,
#relationshipBody::-webkit-scrollbar,
#legendBody::-webkit-scrollbar,
#dashboardBody::-webkit-scrollbar,
#calendarBody::-webkit-scrollbar,
#feedBody::-webkit-scrollbar,
#memorialBody::-webkit-scrollbar,
#notificationsBody::-webkit-scrollbar,
#messagesBody::-webkit-scrollbar {
    width: 8px;
}

.dr-modal__body::-webkit-scrollbar-track,
#settingsBody::-webkit-scrollbar-track,
#filtersBody::-webkit-scrollbar-track,
#relationshipBody::-webkit-scrollbar-track,
#legendBody::-webkit-scrollbar-track,
#dashboardBody::-webkit-scrollbar-track,
#calendarBody::-webkit-scrollbar-track,
#feedBody::-webkit-scrollbar-track,
#memorialBody::-webkit-scrollbar-track,
#notificationsBody::-webkit-scrollbar-track,
#messagesBody::-webkit-scrollbar-track {
    background: var(--dr-surface-3);
    border-radius: 4px;
}

.dr-modal__body::-webkit-scrollbar-thumb,
#settingsBody::-webkit-scrollbar-thumb,
#filtersBody::-webkit-scrollbar-thumb,
#relationshipBody::-webkit-scrollbar-thumb,
#legendBody::-webkit-scrollbar-thumb,
#dashboardBody::-webkit-scrollbar-thumb,
#calendarBody::-webkit-scrollbar-thumb,
#feedBody::-webkit-scrollbar-thumb,
#memorialBody::-webkit-scrollbar-thumb,
#notificationsBody::-webkit-scrollbar-thumb,
#messagesBody::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #14b8a6 0%, #0f766e 100%);
    border-radius: 4px;
}

.dr-modal__body::-webkit-scrollbar-thumb:hover,
#settingsBody::-webkit-scrollbar-thumb:hover,
#filtersBody::-webkit-scrollbar-thumb:hover,
#relationshipBody::-webkit-scrollbar-thumb:hover {
    background: #2dd4bf;
}

.dr-empty {
    text-align: center;
    padding: var(--dr-space-6) var(--dr-space-4);
    color: var(--dr-text-muted);
    font-size: var(--dr-text-base);
}

.dr-empty__icon {
    width: 48px;
    height: 48px;
    margin: 0 auto var(--dr-space-3);
    border-radius: 50%;
    background: var(--dr-surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--dr-text-subtle);
}

.dr-empty__title {
    font-weight: 600;
    color: var(--dr-text);
    margin: 0 0 var(--dr-space-2);
}

.dr-empty p {
    margin: 0;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

/* Dropdown menus */
.features-dropdown,
.controls-dropdown,
.user-dropdown,
.dr-menu {
    background: var(--dr-surface);
    border: 1px solid var(--dr-border);
    border-radius: var(--dr-radius);
    box-shadow: var(--dr-shadow-lg);
    min-width: 200px;
    padding: var(--dr-space-2);
    z-index: var(--dr-z-dropdown);
}

.dropdown-item,
.dr-menu__item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 12px;
    border: none;
    border-radius: var(--dr-radius-sm);
    background: transparent;
    color: var(--dr-text);
    font-size: var(--dr-text-sm);
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
    font-family: var(--dr-font);
    transition: background 0.12s;
}

.dropdown-item:hover,
.dr-menu__item:hover {
    background: var(--dr-surface-2);
    color: var(--dr-primary);
}

.dropdown-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--dr-text-subtle);
    padding: 8px 12px 4px;
    position: static;
    top: auto;
    z-index: auto;
}

.dropdown-divider {
    height: 1px;
    background: var(--dr-border);
    margin: var(--dr-space-2) 0;
}

.logout-item {
    color: var(--dr-danger) !important;
}

.logout-item:hover {
    background: #fef2f2 !important;
    color: var(--dr-danger) !important;
}

/* Buttons */
.dr-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: var(--dr-radius-sm);
    font-size: var(--dr-text-sm);
    font-weight: 600;
    font-family: var(--dr-font);
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background 0.15s, box-shadow 0.15s, transform 0.12s;
    line-height: 1.2;
    white-space: nowrap;
}

.dr-btn svg,
.dr-btn__icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.dr-btn__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 0;
}

.dr-btn-primary {
    background: var(--dr-primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(15, 118, 110, 0.25);
}

.dr-btn-primary:hover {
    background: var(--dr-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 118, 110, 0.3);
}

.dr-btn-ghost {
    background: var(--dr-surface);
    color: var(--dr-text-muted);
    border: 1px solid var(--dr-border);
}

.dr-btn-ghost:hover {
    background: var(--dr-surface-2);
    color: var(--dr-text);
}

.dr-btn-outline-light {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.35);
}

.dr-btn-outline-light:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Form controls in app */
.control-select,
.dr-select {
    height: 36px;
    padding: 0 32px 0 12px;
    border: 1px solid var(--dr-border);
    border-radius: var(--dr-radius-sm);
    background: var(--dr-surface);
    color: var(--dr-text);
    font-size: var(--dr-text-sm);
    font-weight: 500;
    font-family: var(--dr-font);
    cursor: pointer;
    min-width: 120px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
}

.control-select:hover,
.dr-select:hover {
    border-color: var(--dr-border-strong);
}

.control-select:focus,
.dr-select:focus {
    outline: none;
    border-color: var(--dr-primary);
    box-shadow: var(--dr-focus-ring);
}

.search-input,
.dr-search-input {
    height: 36px;
    width: 200px;
    padding: 0 32px 0 12px;
    border: 1px solid var(--dr-border);
    border-radius: var(--dr-radius-sm);
    background: var(--dr-surface-2);
    color: var(--dr-text);
    font-size: var(--dr-text-sm);
    font-family: var(--dr-font);
    transition: border-color 0.15s, box-shadow 0.15s, width 0.2s, background 0.15s;
}

.search-input::placeholder {
    color: var(--dr-text-subtle);
}

.search-input:focus {
    outline: none;
    width: 240px;
    background: var(--dr-surface);
    border-color: var(--dr-primary);
    box-shadow: var(--dr-focus-ring);
}

/* Menu item icons */
.dr-menu__icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--dr-text-muted);
}

.dr-menu__icon svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.dropdown-item:hover .dr-menu__icon,
.dr-menu__item:hover .dr-menu__icon {
    color: var(--dr-primary);
}

.dr-menu__label {
    flex: 1;
    min-width: 0;
}

/* Calendar component */
.dr-calendar {
    padding: var(--dr-space-2) 0;
}

.dr-calendar__body {
    min-height: 280px;
}

.dr-calendar__nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--dr-space-3);
    margin-bottom: var(--dr-space-4);
}

.dr-calendar__title {
    margin: 0;
    font-size: var(--dr-text-lg);
    font-weight: 700;
    color: var(--dr-text);
    letter-spacing: -0.02em;
}

.dr-calendar__nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: var(--dr-radius-sm);
    background: var(--dr-primary);
    color: #fff;
    font-size: var(--dr-text-sm);
    font-weight: 600;
    font-family: var(--dr-font);
    cursor: pointer;
    transition: background 0.15s, transform 0.12s;
}

.dr-calendar__nav-btn:hover {
    background: var(--dr-primary-hover);
}

.dr-calendar__nav-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2.5;
}

.dr-calendar__grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.dr-calendar__weekday {
    text-align: center;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--dr-text-muted);
    padding: 8px 4px;
    background: var(--dr-surface-2);
    border-radius: var(--dr-radius-sm);
}

.dr-calendar__day {
    min-height: 72px;
    padding: 6px;
    background: var(--dr-surface);
    border: 1px solid var(--dr-border);
    border-radius: var(--dr-radius-sm);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.dr-calendar__day--empty {
    background: var(--dr-surface-2);
    border-color: transparent;
    min-height: 0;
    padding: 0;
}

.dr-calendar__day--today {
    background: var(--dr-primary-muted);
    border-color: var(--dr-primary);
    box-shadow: inset 0 0 0 1px rgba(15, 118, 110, 0.15);
}

.dr-calendar__day-num {
    font-size: var(--dr-text-sm);
    font-weight: 700;
    color: var(--dr-text);
    line-height: 1.2;
}

.dr-calendar__day--today .dr-calendar__day-num {
    color: var(--dr-primary-dark);
}

.dr-calendar__events {
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    min-height: 0;
}

.dr-calendar-event {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 4px 6px;
    border: none;
    border-left: 3px solid var(--dr-primary);
    border-radius: 4px;
    background: var(--dr-primary-muted);
    color: var(--dr-text);
    font-size: 11px;
    font-weight: 500;
    font-family: var(--dr-font);
    text-align: left;
    cursor: pointer;
    transition: filter 0.12s, transform 0.12s;
    line-height: 1.3;
}

.dr-calendar-event:hover {
    filter: brightness(0.97);
    transform: translateY(-1px);
}

.dr-calendar-event--birthday {
    background: #fff7ed;
    border-left-color: #ea580c;
}

.dr-calendar-event--anniversary {
    background: #fdf4ff;
    border-left-color: #a855f7;
}

.dr-calendar-event--event {
    background: #ecfdf5;
    border-left-color: var(--dr-primary);
}

.dr-calendar-event__badge {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 9px;
    font-weight: 800;
    line-height: 1;
    color: #fff;
}

.dr-calendar-event__badge--birthday { background: #ea580c; }
.dr-calendar-event__badge--anniversary { background: #a855f7; }
.dr-calendar-event__badge--event { background: var(--dr-primary); }

.dr-calendar-event__badge svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.dr-calendar-event__label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dr-calendar__list {
    margin-top: var(--dr-space-5);
    padding-top: var(--dr-space-4);
    border-top: 1px solid var(--dr-border);
}

.dr-calendar__list-title {
    margin: 0 0 var(--dr-space-3);
    font-size: var(--dr-text-base);
    font-weight: 700;
    color: var(--dr-text);
}

.dr-calendar__list-items {
    display: flex;
    flex-direction: column;
    gap: var(--dr-space-2);
}

.dr-calendar-list-item {
    display: block;
    width: 100%;
    padding: var(--dr-space-3);
    border: 1px solid var(--dr-border);
    border-left-width: 4px;
    border-radius: var(--dr-radius-sm);
    background: var(--dr-surface);
    cursor: pointer;
    text-align: left;
    font-family: var(--dr-font);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.dr-calendar-list-item:hover {
    box-shadow: var(--dr-shadow-xs);
}

.dr-calendar-list-item--birthday { border-left-color: #ea580c; }
.dr-calendar-list-item--anniversary { border-left-color: #a855f7; }
.dr-calendar-list-item--event { border-left-color: var(--dr-primary); }

.dr-calendar-list-item__row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--dr-space-3);
}

.dr-calendar-list-item__title {
    font-weight: 600;
    font-size: var(--dr-text-sm);
    color: var(--dr-text);
}

.dr-calendar-list-item__meta {
    font-size: var(--dr-text-xs);
    color: var(--dr-text-muted);
    margin-top: 2px;
}

.dr-calendar-list-item__date {
    font-size: var(--dr-text-xs);
    color: var(--dr-text-muted);
    flex-shrink: 0;
}

.dr-event-detail__badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: var(--dr-radius-pill);
    font-size: 11px;
    font-weight: 600;
    margin-bottom: var(--dr-space-2);
}

.dr-event-detail__badge--birthday { background: #fff7ed; color: #9a3412; }
.dr-event-detail__badge--anniversary { background: #fdf4ff; color: #7e22ce; }
.dr-event-detail__badge--event { background: var(--dr-primary-muted); color: var(--dr-primary-dark); }

.dr-event-detail__avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--dr-border);
    flex-shrink: 0;
}

.dr-event-detail__avatar--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--dr-surface-2);
    color: var(--dr-primary);
}

.dr-event-detail__avatar--placeholder svg {
    width: 28px;
    height: 28px;
    stroke: currentColor;
    fill: none;
    stroke-width: 1.75;
}

.modal-content--event-detail {
    max-width: 440px;
}

.dr-event-detail__head {
    display: flex;
    gap: var(--dr-space-4);
    align-items: flex-start;
    margin-bottom: 0;
}

.dr-event-detail__meta {
    flex: 1;
    min-width: 0;
}

.dr-event-detail__name {
    margin: 0 0 var(--dr-space-1);
    font-size: 16px;
    font-weight: 600;
    color: var(--dr-text);
    line-height: 1.35;
}

.dr-event-detail__date {
    margin: 0;
    font-size: 14px;
    color: var(--dr-text-muted);
    line-height: 1.45;
}

.dr-event-detail__note,
.dr-event-detail__desc {
    margin: var(--dr-space-2) 0 0;
    font-size: 14px;
    color: var(--dr-text-muted);
    line-height: 1.5;
}

.dr-event-detail__desc {
    margin-top: var(--dr-space-4);
    padding-top: var(--dr-space-3);
    border-top: 1px solid var(--dr-border);
}

.dr-event-detail__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--dr-space-2);
    margin-top: var(--dr-space-5);
    padding-top: var(--dr-space-4);
    border-top: 1px solid var(--dr-border);
}

.dr-event-detail__actions .dr-btn {
    flex: 1 1 auto;
    min-width: 140px;
    justify-content: center;
}

/* Forms (modals, submit change) */
.dr-form-stack {
    display: flex;
    flex-direction: column;
    gap: var(--dr-space-3);
}

.dr-form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--dr-text);
}

.dr-form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--dr-border);
    border-radius: var(--dr-radius-md);
    font: inherit;
    color: var(--dr-text);
    background: var(--dr-surface);
    box-sizing: border-box;
}

.dr-form-control:focus {
    outline: none;
    border-color: var(--dr-primary);
    box-shadow: 0 0 0 3px var(--dr-primary-muted);
}

.dr-form-hint {
    margin: 0 0 var(--dr-space-2);
    font-size: 14px;
    color: var(--dr-text-muted);
    line-height: 1.5;
}

.dr-form-required {
    color: #dc2626;
    font-weight: 600;
}

.dr-form-checkbox {
    display: flex;
    align-items: flex-start;
    gap: var(--dr-space-2);
    font-size: 14px;
    color: var(--dr-text);
    cursor: pointer;
}

.dr-form-checkbox input {
    margin-top: 3px;
    accent-color: var(--dr-primary);
}

/* Dashboard event cards (modal) */
.dr-dashboard-panel__title {
    margin: 0 0 var(--dr-space-1);
    font-size: var(--dr-text-lg);
    font-weight: 600;
    color: var(--dr-text);
}

.dr-dashboard-panel__date {
    margin: 0;
    font-size: 14px;
    color: var(--dr-text-muted);
}

.dr-dashboard-panel__head--spaced {
    margin-top: var(--dr-space-6);
    padding-top: var(--dr-space-4);
    border-top: 1px solid var(--dr-border);
}

.dr-event-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--dr-space-4);
}

.dr-event-card {
    padding: var(--dr-space-4);
    background: var(--dr-surface);
    border: 1px solid var(--dr-border);
    border-radius: var(--dr-radius-lg);
    border-left: 4px solid var(--dr-primary);
}

.dr-event-card--birthday { border-left-color: #ea580c; }
.dr-event-card--anniversary { border-left-color: #a855f7; }

.dr-event-card__head {
    display: flex;
    gap: var(--dr-space-3);
    align-items: center;
    margin-bottom: var(--dr-space-2);
}

.dr-event-card__photo {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.dr-event-card__photo--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--dr-primary-muted);
}

.dr-event-card__title {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 600;
}

.dr-event-card__member {
    margin: 0;
    font-size: 13px;
    color: var(--dr-text-muted);
}

.dr-event-card__meta {
    margin: 0 0 var(--dr-space-2);
    font-size: 13px;
    color: var(--dr-text-muted);
}

.dr-event-card__rsvp {
    width: 100%;
    margin-top: var(--dr-space-2);
}

.dr-event-card--compact .dr-event-card__row {
    display: flex;
    justify-content: space-between;
    gap: var(--dr-space-3);
    align-items: flex-start;
}

.dr-event-card__when {
    text-align: right;
    flex-shrink: 0;
}

.dr-event-card__when-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--dr-text);
}

.dr-event-card__when-date {
    display: block;
    font-size: 11px;
    color: var(--dr-text-muted);
}

.dr-dashboard-panel__footer {
    margin-top: var(--dr-space-4);
    text-align: center;
}

/* Modal panels (memorial, feed, timeline) */
.dr-modal-panel {
    padding: var(--dr-space-2) 0;
}

.dr-modal-panel__body {
    margin-bottom: var(--dr-space-4);
}

.dr-memorial-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--dr-space-4);
}

.dr-memorial-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--dr-space-4);
    background: var(--dr-surface);
    border: 1px solid var(--dr-border);
    border-radius: var(--dr-radius-lg);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    font: inherit;
    color: inherit;
    width: 100%;
}

.dr-memorial-card:hover {
    border-color: var(--dr-primary);
    box-shadow: var(--dr-shadow-sm);
}

.dr-memorial-card__photo {
    width: 88px;
    height: 88px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: var(--dr-space-3);
    border: 2px solid var(--dr-border);
}

.dr-memorial-card__photo--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--dr-primary-muted);
    color: var(--dr-primary-dark);
    font-size: 28px;
    font-weight: 700;
}

.dr-memorial-card__name {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: var(--dr-space-2);
}

.dr-memorial-card__meta {
    font-size: 13px;
    color: var(--dr-text-muted);
    margin-bottom: 4px;
}

.dr-memorial-card__action {
    margin-top: var(--dr-space-3);
    font-size: 13px;
    font-weight: 600;
    color: var(--dr-primary);
}

.dr-condolence-list {
    display: grid;
    gap: var(--dr-space-3);
}

.dr-condolence-card {
    padding: var(--dr-space-4);
    background: var(--dr-surface);
    border: 1px solid var(--dr-border);
    border-radius: var(--dr-radius-md);
    border-left: 3px solid var(--dr-text-muted);
}

.dr-condolence-card__head {
    display: flex;
    gap: var(--dr-space-3);
    margin-bottom: var(--dr-space-2);
}

.dr-condolence-card__avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.dr-condolence-card__avatar--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--dr-surface-2);
    color: var(--dr-text-muted);
    font-weight: 600;
}

.dr-condolence-card__author {
    font-weight: 600;
    font-size: 14px;
}

.dr-condolence-card__meta,
.dr-condolence-card__date {
    font-size: 12px;
    color: var(--dr-text-muted);
}

.dr-condolence-card__message {
    margin: 0;
    font-size: 14px;
    line-height: 1.55;
    color: var(--dr-text);
}

.dr-feed-toolbar {
    margin-bottom: var(--dr-space-4);
}

.dr-feed-toolbar__btn {
    width: 100%;
}

.dr-feed-list {
    max-height: 60vh;
    overflow-y: auto;
    display: grid;
    gap: var(--dr-space-4);
}

.dr-feed-post {
    padding: var(--dr-space-4);
    background: var(--dr-surface);
    border: 1px solid var(--dr-border);
    border-radius: var(--dr-radius-lg);
}

.dr-feed-post__head {
    display: flex;
    gap: var(--dr-space-3);
    align-items: center;
    margin-bottom: var(--dr-space-3);
}

.dr-feed-post__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--dr-surface-2);
    flex-shrink: 0;
}

.dr-feed-post__author {
    display: block;
    font-size: 14px;
}

.dr-feed-post__date {
    font-size: 12px;
    color: var(--dr-text-muted);
}

.dr-feed-post__title {
    margin: 0 0 var(--dr-space-2);
    font-size: 16px;
}

.dr-feed-post__content {
    font-size: 14px;
    line-height: 1.55;
    color: var(--dr-text);
    margin-bottom: var(--dr-space-3);
    white-space: pre-wrap;
}

.dr-feed-post__actions {
    display: flex;
    gap: var(--dr-space-3);
    padding-top: var(--dr-space-2);
    border-top: 1px solid var(--dr-border);
}

.dr-feed-post__action {
    background: none;
    border: none;
    padding: 0;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--dr-primary);
    cursor: pointer;
}

.dr-feed-post__action:hover {
    text-decoration: underline;
}

.dr-feed-comments {
    margin-top: var(--dr-space-3);
    padding-top: var(--dr-space-3);
    border-top: 1px solid var(--dr-border);
}

.dr-feed-comments[hidden] {
    display: none !important;
}

.dr-feed-comments__form {
    display: flex;
    gap: var(--dr-space-2);
    margin-top: var(--dr-space-2);
}

.dr-feed-comments__form .dr-form-control {
    flex: 1;
}

.dr-feed-comment {
    margin: 0 0 var(--dr-space-2);
    font-size: 13px;
}

/* Family stories */
.dr-stories-list,
.dr-gifts-list {
    max-height: 60vh;
    overflow-y: auto;
    display: grid;
    gap: var(--dr-space-4);
}

.dr-story-card {
    padding: var(--dr-space-4);
    background: var(--dr-surface);
    border: 1px solid var(--dr-border);
    border-radius: var(--dr-radius-lg);
    border-left: 4px solid var(--dr-primary);
}

.dr-story-card__avatar--placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    color: var(--dr-primary);
}

.dr-story-card__type {
    display: inline-block;
    margin-top: 4px;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--dr-primary);
    background: var(--dr-primary-muted);
    border-radius: var(--dr-radius-sm);
}

.dr-story-card__title {
    margin: 0 0 var(--dr-space-2);
    font-size: 17px;
    font-weight: 600;
    color: var(--dr-text);
    line-height: 1.35;
}

.dr-story-card__content {
    font-size: 14px;
    line-height: 1.55;
    color: var(--dr-text);
    white-space: pre-wrap;
}

/* Gift registry */
.dr-gift-card {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--dr-space-3);
    padding: var(--dr-space-4);
    background: var(--dr-surface);
    border: 1px solid var(--dr-border);
    border-radius: var(--dr-radius-lg);
}

.dr-gift-card--purchased {
    opacity: 0.72;
    background: var(--dr-surface-2);
}

.dr-gift-card__main {
    flex: 1;
    min-width: 0;
}

.dr-gift-card__name {
    margin: 0 0 var(--dr-space-1);
    font-size: 16px;
    font-weight: 600;
    color: var(--dr-text);
}

.dr-gift-card__desc {
    margin: 0 0 var(--dr-space-2);
    font-size: 14px;
    color: var(--dr-text-muted);
    line-height: 1.5;
}

.dr-gift-card__category {
    display: inline-block;
    margin-right: var(--dr-space-2);
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    color: var(--dr-text-muted);
    background: var(--dr-surface-2);
    border-radius: var(--dr-radius-sm);
}

.dr-gift-card__link {
    display: inline-block;
    font-size: 13px;
    font-weight: 600;
    color: var(--dr-primary);
    text-decoration: none;
}

.dr-gift-card__link:hover {
    text-decoration: underline;
}

.dr-gift-card__status {
    margin: var(--dr-space-2) 0 0;
    font-size: 13px;
    font-weight: 600;
    color: #16a34a;
}

/* Photo gallery */
.dr-gallery-header,
.dr-history-header {
    margin-bottom: var(--dr-space-4);
}

.dr-gallery-header__title,
.dr-history-header__title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    color: var(--dr-text);
}

.dr-gallery-toolbar {
    margin-bottom: var(--dr-space-4);
}

.dr-gallery-albums {
    max-height: 58vh;
    overflow-y: auto;
}

.dr-gallery-album {
    margin-bottom: var(--dr-space-5);
}

.dr-gallery-album__title {
    margin: 0 0 var(--dr-space-3);
    font-size: 15px;
    font-weight: 600;
    color: var(--dr-text);
}

.dr-gallery-album__count {
    font-weight: 500;
    color: var(--dr-text-muted);
}

.dr-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--dr-space-3);
}

.dr-gallery-item {
    margin: 0;
}

.dr-gallery-item__trigger {
    display: block;
    width: 100%;
    padding: 0;
    border: none;
    border-radius: var(--dr-radius-md);
    overflow: hidden;
    cursor: pointer;
    background: var(--dr-surface-2);
}

.dr-gallery-item__img {
    display: block;
    width: 100%;
    height: 140px;
    object-fit: cover;
}

.dr-gallery-item__caption {
    margin-top: var(--dr-space-1);
    font-size: 12px;
    color: var(--dr-text-muted);
    text-align: center;
}

/* Change history */
.dr-history-list {
    max-height: 58vh;
    overflow-y: auto;
    display: grid;
    gap: var(--dr-space-3);
}

.dr-history-card {
    padding: var(--dr-space-4);
    background: var(--dr-surface);
    border: 1px solid var(--dr-border);
    border-radius: var(--dr-radius-lg);
    border-left: 4px solid var(--dr-border);
}

.dr-history-card--add { border-left-color: #16a34a; }
.dr-history-card--edit { border-left-color: var(--dr-primary); }
.dr-history-card--delete { border-left-color: #dc2626; }

.dr-history-card__head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: var(--dr-space-2);
    margin-bottom: var(--dr-space-2);
}

.dr-history-card__type {
    font-size: 13px;
    font-weight: 700;
    color: var(--dr-text);
}

.dr-history-card--add .dr-history-card__type { color: #16a34a; }
.dr-history-card--edit .dr-history-card__type { color: var(--dr-primary); }
.dr-history-card--delete .dr-history-card__type { color: #dc2626; }

.dr-history-card__date {
    font-size: 12px;
    color: var(--dr-text-muted);
}

.dr-history-card__summary {
    margin: 0 0 var(--dr-space-2);
    font-size: 14px;
    color: var(--dr-text);
    line-height: 1.5;
}

.dr-history-card__meta {
    margin: 0;
    font-size: 12px;
    color: var(--dr-text-muted);
}

/* Export modal */
.dr-export-hint {
    margin: 0 0 var(--dr-space-3);
    padding: var(--dr-space-3);
    font-size: 13px;
    line-height: 1.5;
    color: var(--dr-text-muted);
    background: var(--dr-surface);
    border: 1px solid var(--dr-border);
    border-radius: var(--dr-radius-md);
}

.dr-export-png-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--dr-space-2) var(--dr-space-3);
    margin-bottom: var(--dr-space-4);
    padding: var(--dr-space-3);
    background: var(--dr-primary-muted);
    border: 1px solid var(--dr-border);
    border-radius: var(--dr-radius-lg);
}

.dr-export-png-row__label {
    font-size: 13px;
    font-weight: 600;
    color: var(--dr-text);
    flex: 0 0 auto;
}

.dr-export-png-row__select {
    flex: 1 1 200px;
    min-width: 0;
    max-width: 100%;
}

.dr-export-png-row__btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

.dr-export-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: var(--dr-space-3);
    padding: var(--dr-space-2) 0 var(--dr-space-1);
}

.dr-export-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: var(--dr-space-2);
    padding: var(--dr-space-4) var(--dr-space-3);
    background: var(--dr-surface);
    border: 1px solid var(--dr-border);
    border-radius: var(--dr-radius-lg);
    cursor: pointer;
    font: inherit;
    color: var(--dr-text);
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.dr-export-card:hover {
    border-color: var(--dr-primary);
    background: var(--dr-primary-muted);
    box-shadow: var(--dr-shadow);
}

.dr-export-card__icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--dr-primary-muted);
    color: var(--dr-primary);
}

.dr-export-card__icon svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.dr-export-card__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--dr-text);
}

.dr-export-card__desc {
    font-size: 12px;
    color: var(--dr-text-muted);
    line-height: 1.4;
}

/* RSVP modal */
.dr-rsvp-meta {
    display: flex;
    align-items: center;
    gap: var(--dr-space-2);
    margin: 0 0 var(--dr-space-4);
    padding: 0 var(--dr-space-5);
    font-size: 14px;
    color: var(--dr-text-muted);
}

.modal-content > .dr-rsvp-meta {
    padding-left: 20px;
    padding-right: 20px;
}

.dr-rsvp-meta__icon {
    display: flex;
    color: var(--dr-primary);
    flex-shrink: 0;
}

.dr-rsvp-meta__icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.modal-content form.dr-form-stack {
    padding: 0 var(--dr-space-5) var(--dr-space-5);
}

/* Help / legend panel — scroll on #legendBody, not nested */
.dr-help {
    max-height: none;
    overflow: visible;
}

.dr-help-section {
    margin-bottom: var(--dr-space-5);
}

.dr-help-section:last-child {
    margin-bottom: 0;
}

.dr-help-section__title {
    margin: 0 0 var(--dr-space-3);
    padding-bottom: var(--dr-space-2);
    font-size: 15px;
    font-weight: 600;
    color: var(--dr-text);
    border-bottom: 2px solid var(--dr-primary);
}

.dr-help-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--dr-space-3);
}

.dr-help-card {
    display: flex;
    gap: var(--dr-space-3);
    align-items: flex-start;
    padding: var(--dr-space-3);
    background: var(--dr-surface-2);
    border-radius: var(--dr-radius-md);
}

.dr-help-card__swatch {
    width: 40px;
    height: 40px;
    border-radius: var(--dr-radius-sm);
    border: 2px solid transparent;
    flex-shrink: 0;
}

.dr-help-card__swatch--outline {
    background: var(--dr-surface);
    border-width: 3px;
}

.dr-help-card__body strong {
    display: block;
    font-size: 14px;
    margin-bottom: 4px;
}

.dr-help-card__body p {
    margin: 0;
    font-size: 12px;
    color: var(--dr-text-muted);
    line-height: 1.45;
}

.dr-help-kbd-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--dr-space-2);
}

.dr-help-kbd {
    display: flex;
    align-items: center;
    gap: var(--dr-space-2);
    padding: var(--dr-space-2) var(--dr-space-3);
    background: var(--dr-surface-2);
    border-radius: var(--dr-radius-sm);
    font-size: 13px;
}

.dr-help-kbd kbd {
    padding: 2px 6px;
    font-size: 12px;
    font-family: inherit;
    background: var(--dr-surface);
    border: 1px solid var(--dr-border);
    border-radius: 4px;
}

.dr-help-list {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--dr-text-muted);
    line-height: 1.75;
    font-size: 14px;
}

.dr-help-text {
    margin: 0;
    font-size: 14px;
    color: var(--dr-text-muted);
    line-height: 1.6;
}

/* Inner form layout inside modal body (no nested scroll) */
.dr-modal-form-inner {
    padding: 0;
    overflow: visible;
}

.dr-modal-form-inner h3 {
    margin: 0 0 var(--dr-space-3);
    font-size: 16px;
    font-weight: 600;
    color: var(--dr-text);
}

/* Settings modal sections */
.dr-settings-section__title {
    margin: 0 0 var(--dr-space-3);
    font-size: 16px;
    font-weight: 600;
    color: var(--dr-text);
}

.dr-settings-section__btn {
    width: 100%;
}

/* Share modal */
.dr-share-form {
    padding: 0 var(--dr-space-5) var(--dr-space-5);
}

.dr-share-link-row {
    display: flex;
    gap: var(--dr-space-2);
    align-items: stretch;
}

.dr-share-link-row .dr-form-control {
    flex: 1;
    min-width: 0;
}

.dr-share-includes {
    padding: var(--dr-space-3);
    background: var(--dr-surface-2);
    border-radius: var(--dr-radius-md);
}

.dr-share-includes__title {
    margin: 0 0 var(--dr-space-2);
    font-size: 13px;
    font-weight: 600;
    color: var(--dr-text);
}

.dr-share-includes__list {
    margin: 0;
    padding-left: 1.15rem;
    font-size: 13px;
    color: var(--dr-text-muted);
    line-height: 1.65;
}

.dr-share-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--dr-space-2);
}

.dr-share-actions .dr-btn {
    flex: 1;
    min-width: 120px;
}

.dr-timeline {
    max-height: 65vh;
    overflow-y: auto;
    padding: var(--dr-space-2) 0 var(--dr-space-2) var(--dr-space-4);
    border-left: 2px solid var(--dr-border);
}

.dr-timeline__year {
    margin-bottom: var(--dr-space-5);
    position: relative;
}

.dr-timeline__year::before {
    content: '';
    position: absolute;
    left: calc(-1 * var(--dr-space-4) - 5px);
    top: 6px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--dr-primary);
    border: 2px solid var(--dr-surface);
    box-shadow: 0 0 0 2px var(--dr-primary-muted);
}

.dr-timeline__year-label {
    margin: 0 0 var(--dr-space-3);
    font-size: 20px;
    font-weight: 700;
    color: var(--dr-text);
}

.dr-timeline__events {
    display: grid;
    gap: var(--dr-space-2);
    padding-left: var(--dr-space-2);
}

.dr-timeline__event {
    padding: var(--dr-space-3);
    border-radius: var(--dr-radius-md);
    border-left: 4px solid var(--dr-primary);
    background: var(--dr-surface);
    border: 1px solid var(--dr-border);
    border-left-width: 4px;
}

.dr-timeline__event--birth {
    border-left-color: #16a34a;
    background: #f0fdf4;
}

.dr-timeline__event--death {
    border-left-color: #dc2626;
    background: #fef2f2;
}

.dr-timeline__event--marriage {
    border-left-color: #ea580c;
    background: #fff7ed;
}

.dr-timeline__event-type {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--dr-text-muted);
    margin-bottom: 4px;
}

.dr-timeline__event-title {
    margin: 0 0 4px;
    font-size: 14px;
    font-weight: 600;
}

.dr-timeline__event-date {
    font-size: 12px;
    color: var(--dr-text-muted);
}

.modal-content--calendar {
    max-width: 720px !important;
}

@media (max-width: 768px) {
    .dr-calendar__day {
        min-height: 56px;
        padding: 4px;
    }

    .dr-calendar__nav-btn span {
        display: none;
    }

    .dr-calendar__nav-btn {
        padding: 8px 10px;
    }
}

/* Advanced display controls modal */
.modal-content.modal-content--display-controls {
    max-width: 560px;
    width: calc(100% - 32px);
}

#advancedControlsModal .close {
    border: 1px solid var(--dr-primary, #0f766e);
    background: #fff;
    color: var(--dr-primary, #0f766e);
    border-radius: 8px;
    font-size: 18px;
    line-height: 1;
}

#advancedControlsModal .close:hover {
    background: var(--dr-primary-muted, #f0fdfa);
    color: var(--dr-primary-dark, #134e4a);
}

.dr-display-controls {
    display: flex;
    flex-direction: column;
    gap: 22px;
    padding: 20px var(--dr-space-5) var(--dr-space-5);
}

.dr-display-control-block {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dr-display-control-block__label {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    color: var(--dr-text, #0f172a);
    letter-spacing: -0.01em;
}

.dr-display-range {
    width: 100%;
    height: 6px;
    margin: 4px 0 0;
    border-radius: 999px;
    accent-color: var(--dr-primary);
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
}

.dr-display-range::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 999px;
    background: var(--dr-border);
}

.dr-display-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    margin-top: -6px;
    border-radius: 50%;
    background: var(--dr-primary);
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(15, 118, 110, 0.4);
    cursor: pointer;
}

.dr-display-range::-moz-range-track {
    height: 6px;
    border-radius: 999px;
    background: var(--dr-border);
    border: none;
}

.dr-display-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--dr-primary);
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(15, 118, 110, 0.4);
    cursor: pointer;
}

.dr-display-range-labels {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--dr-text-muted);
    line-height: 1.3;
}

.dr-display-range-labels__value {
    font-size: 13px;
    font-weight: 700;
    color: var(--dr-primary, #0f766e);
}

.dr-display-line-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.dr-display-line-option {
    padding: 10px 12px;
    border: 1px solid var(--dr-border, #e2e8f0);
    border-radius: 8px;
    background: var(--dr-surface-2, #f8fafc);
    color: var(--dr-text, #0f172a);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
}

.dr-display-line-option:hover {
    border-color: var(--dr-primary, #0f766e);
    background: #f0fdfa;
}

.dr-display-line-option.is-active {
    background: linear-gradient(145deg, var(--dr-primary, #0f766e) 0%, var(--dr-primary-dark, #134e4a) 100%);
    border-color: var(--dr-primary-dark, #134e4a);
    color: #fff;
    box-shadow: 0 2px 8px rgba(15, 118, 110, 0.25);
}

.dr-display-bg-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
}

.dr-display-bg-btn {
    min-height: 52px;
    padding: 12px 8px;
    border: 2px solid var(--dr-border);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--dr-text, #0f172a);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-sizing: border-box;
}

.dr-display-bg-btn:hover {
    border-color: #cbd5e1;
}

.dr-display-bg-btn.is-active {
    border: 3px solid var(--dr-primary, #0f766e);
    box-shadow: 0 0 0 1px rgba(15, 118, 110, 0.12);
}

.dr-display-controls__actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
    padding-top: 20px;
    border-top: 1px solid var(--dr-border, #e2e8f0);
}

.dr-display-controls__actions .dr-btn {
    flex: 1;
    min-height: 44px;
    justify-content: center;
}

@media (max-width: 420px) {
    .dr-display-bg-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dr-display-line-grid {
        grid-template-columns: 1fr;
    }
}


/* Settings & Preferences modal */
.modal-content.modal-content--settings {
    max-width: 560px;
    width: calc(100% - 32px);
}

#settingsModal .close {
    border: 1px solid var(--dr-primary, #0f766e);
    background: #fff;
    color: var(--dr-primary, #0f766e);
    border-radius: 8px;
}

#settingsModal .close:hover {
    background: var(--dr-primary-muted, #f0fdfa);
    color: var(--dr-primary-dark, #134e4a);
}

#settingsBody {
    padding: 0;
}

.dr-settings-panel {
    display: flex;
    flex-direction: column;
}

.dr-settings-section {
    padding: 20px var(--dr-space-5, 20px);
    border-bottom: 1px solid var(--dr-border, #e2e8f0);
}

.dr-settings-section--link {
    background: linear-gradient(180deg, #f8fafc 0%, #fff 100%);
}

.dr-settings-section__title {
    margin: 0 0 4px;
    font-size: 15px;
    font-weight: 700;
    color: var(--dr-text, #0f172a);
}

.dr-settings-section__desc {
    margin: 0 0 14px;
    font-size: 13px;
    color: var(--dr-text-muted, #64748b);
    line-height: 1.45;
}

.dr-settings-field {
    margin-bottom: 16px;
}

.dr-settings-field:last-child {
    margin-bottom: 0;
}

.dr-settings-field__label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
    color: #334155;
}

.dr-settings-chip-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.dr-settings-chip-grid--triple {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.dr-settings-chip {
    padding: 10px 12px;
    border: 1px solid var(--dr-border, #e2e8f0);
    border-radius: 8px;
    background: var(--dr-surface-2, #f8fafc);
    color: var(--dr-text, #0f172a);
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
}

.dr-settings-chip:hover {
    border-color: var(--dr-primary, #0f766e);
    background: #f0fdfa;
}

.dr-settings-chip.is-active {
    background: linear-gradient(145deg, var(--dr-primary, #0f766e) 0%, var(--dr-primary-dark, #134e4a) 100%);
    border-color: var(--dr-primary-dark, #134e4a);
    color: #fff;
    box-shadow: 0 2px 8px rgba(15, 118, 110, 0.22);
}

.dr-settings-toggle {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    cursor: pointer;
    user-select: none;
    margin-top: 4px;
}

.dr-settings-toggle input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.dr-settings-toggle__box {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 1px;
    border: 2px solid var(--dr-border, #cbd5e1);
    border-radius: 5px;
    background: #fff;
    position: relative;
}

.dr-settings-toggle input:checked + .dr-settings-toggle__box {
    background: var(--dr-primary, #0f766e);
    border-color: var(--dr-primary, #0f766e);
}

.dr-settings-toggle input:checked + .dr-settings-toggle__box::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.dr-settings-toggle__text {
    font-size: 14px;
    color: var(--dr-text, #0f172a);
    line-height: 1.45;
}

.dr-settings-data-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.dr-settings-data-grid .dr-btn {
    min-height: 42px;
    font-size: 13px;
    justify-content: center;
}

.dr-settings-data-grid #resetPreferences {
    color: #b91c1c;
    border-color: #fecaca;
}

.dr-settings-data-grid #resetPreferences:hover {
    background: #fef2f2;
    border-color: #f87171;
}

.dr-settings-section__btn {
    width: 100%;
    min-height: 44px;
    justify-content: center;
}

.dr-settings-footer {
    display: flex;
    gap: 10px;
    padding: 16px var(--dr-space-5, 20px) 20px;
    border-top: 1px solid var(--dr-border, #e2e8f0);
}

.dr-settings-footer .dr-btn {
    flex: 1;
    min-height: 44px;
    justify-content: center;
}

@media (max-width: 480px) {
    .dr-settings-chip-grid,
    .dr-settings-data-grid {
        grid-template-columns: 1fr;
    }
    .dr-settings-chip-grid--triple {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
