:root {
    color-scheme: light;
    --bg: #f5efe8;
    --bg-soft: #fcf8f2;
    --surface: rgba(255, 252, 247, 0.82);
    --surface-strong: #fffdf9;
    --surface-muted: rgba(255, 246, 234, 0.74);
    --surface-border: rgba(120, 88, 54, 0.14);
    --text: #2c221b;
    --muted: #76604d;
    --primary: #ac6438;
    --primary-strong: #91512a;
    --accent: #e8c89a;
    --success: #2f7a4e;
    --danger: #bb4d3f;
    --danger-strong: #a53a30;
    --shadow: 0 20px 45px rgba(107, 74, 44, 0.12);
    --bg-spot-a: rgba(232, 200, 154, 0.55);
    --bg-spot-b: rgba(172, 100, 56, 0.14);
    --glow-left: rgba(232, 200, 154, 0.95);
    --glow-right: rgba(172, 100, 56, 0.48);
    --radius-xl: 30px;
    --radius-lg: 24px;
    --radius-md: 18px;
    --radius-sm: 12px;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #171412;
    --bg-soft: #211c18;
    --surface: rgba(31, 27, 23, 0.88);
    --surface-strong: #2a241f;
    --surface-muted: rgba(48, 39, 32, 0.86);
    --surface-border: rgba(239, 214, 179, 0.1);
    --text: #f5ede2;
    --muted: #cebca8;
    --primary: #f0a56b;
    --primary-strong: #f6bf90;
    --accent: #6f5440;
    --success: #79d09b;
    --danger: #ff8e81;
    --danger-strong: #ff7a6b;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.34);
    --bg-spot-a: rgba(111, 84, 64, 0.28);
    --bg-spot-b: rgba(240, 165, 107, 0.24);
    --glow-left: rgba(111, 84, 64, 0.42);
    --glow-right: rgba(240, 165, 107, 0.34);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, var(--bg-spot-a), transparent 28%),
        radial-gradient(circle at right 20%, var(--bg-spot-b), transparent 24%),
        linear-gradient(180deg, var(--bg), var(--bg-soft));
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    display: block;
    max-width: 100%;
}

[hidden] {
    display: none !important;
}

button,
input,
select,
textarea {
    font: inherit;
}

.page-glow {
    position: fixed;
    width: 20rem;
    height: 20rem;
    border-radius: 50%;
    filter: blur(58px);
    opacity: 0.18;
    pointer-events: none;
    z-index: 0;
}

.page-glow-left {
    top: -7rem;
    left: -5rem;
    background: var(--glow-left);
}

.page-glow-right {
    right: -6rem;
    bottom: -6rem;
    background: var(--glow-right);
}

.site-shell {
    position: relative;
    z-index: 1;
    width: min(1240px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 1rem 0 2.4rem;
}

.topbar,
.section-card,
.hero-card,
.auth-card,
.stat-card,
.person-card,
.editor-card,
.profile-card,
.tree-panel,
.tree-summary,
.empty-state,
.alert {
    background: var(--surface);
    border: 1px solid var(--surface-border);
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
}

.topbar {
    position: sticky;
    top: 1rem;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.2rem;
    border-radius: var(--radius-xl);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.9rem;
    min-width: 0;
}

.brand strong,
.brand small {
    display: block;
}

.brand strong {
    font-size: 1rem;
}

.brand small {
    color: var(--muted);
}

.brand > span:last-child,
.hero-copy,
.section-head,
.workspace-header,
.context-banner,
.person-card-content,
.profile-hero-content,
.tree-summary,
.mini-card,
.stat-card,
.admin-user-card,
.register-family-card,
.term-card,
.theme-card,
.editor-card,
.profile-card {
    min-width: 0;
}

.brand-mark {
    width: 2.8rem;
    height: 2.8rem;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
}

.brand-mark-image {
    padding: 0.2rem;
    background: rgba(255, 255, 255, 0.9);
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 14px;
}

.topbar-actions,
.main-nav,
.toolbar,
.hero-actions,
.action-cluster,
.card-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.main-nav a {
    padding: 0.72rem 0.95rem;
    border-radius: 999px;
    color: var(--muted);
    transition: 0.18s ease;
}

.main-nav a:hover,
.main-nav a.is-active {
    background: rgba(172, 100, 56, 0.12);
    color: var(--primary);
}

.welcome-chip {
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    background: rgba(232, 200, 154, 0.18);
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}

.welcome-chip strong {
    padding: 0.22rem 0.55rem;
    border-radius: 999px;
    background: rgba(172, 100, 56, 0.16);
    color: var(--primary);
    font-size: 0.78rem;
}

.theme-toggle,
.btn {
    border-radius: 999px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.theme-toggle:hover,
.btn:hover {
    transform: translateY(-1px);
}

.theme-toggle {
    background: rgba(232, 200, 154, 0.16);
    color: var(--text);
    padding: 0.72rem 1rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.86rem 1.18rem;
    font-weight: 700;
    white-space: nowrap;
    min-height: 44px;
    text-align: center;
    line-height: 1.2;
}

.btn-block {
    width: 100%;
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    box-shadow: 0 12px 28px rgba(172, 100, 56, 0.26);
}

.btn-outline {
    color: var(--text);
    background: transparent;
    border-color: var(--surface-border);
}

.btn-danger {
    color: #fff;
    background: linear-gradient(135deg, var(--danger), var(--danger-strong));
    box-shadow: 0 12px 28px rgba(187, 77, 63, 0.22);
}

.page-content {
    padding-top: 1.5rem;
}

.site-footer {
    text-align: center;
    color: var(--muted);
    padding: 1.9rem 0 0.8rem;
}

.site-footer p {
    margin: 0;
}

.section-stack {
    display: grid;
    gap: 1.2rem;
}

.section-card,
.hero-card,
.auth-card {
    border-radius: var(--radius-xl);
    padding: clamp(1.2rem, 3vw, 1.7rem);
}

.section-card-hero,
.dashboard-hero,
.hero-card-home {
    display: grid;
    grid-template-columns: 1.2fr 0.95fr;
    gap: 1.4rem;
    align-items: stretch;
}

.hero-copy,
.hero-aside,
.hero-panel,
.hero-panel-home,
.workspace-card,
.profile-showcase {
    display: grid;
    gap: 1rem;
}

.hero-copy h1,
.section-head h1,
.section-head h2,
.auth-card h1,
.profile-hero h1,
.tree-summary h2 {
    margin: 0.35rem 0 0.55rem;
    line-height: 1.08;
}

.hero-copy h1 {
    font-size: 3.1rem;
}

.hero-copy,
.admin-inline-panel {
    align-content: start;
}

.hero-copy p,
.profile-hero-content p,
.tree-summary p {
    margin: 0;
}

.section-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.section-head p,
.hero-copy p,
.auth-card p,
.muted-text,
.field-help,
.field span,
.admin-user-card span {
    color: var(--muted);
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.36rem 0.74rem;
    border-radius: 999px;
    background: rgba(232, 200, 154, 0.2);
    color: var(--primary);
    font-size: 0.84rem;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.hero-aside,
.hero-panel,
.hero-panel-home {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.hero-stat,
.mini-card,
.detail-panel {
    border-radius: var(--radius-lg);
    padding: 1rem 1.05rem;
    background: var(--surface-muted);
    border: 1px solid var(--surface-border);
}

.hero-stat strong {
    display: block;
    font-size: 2rem;
    margin-bottom: 0.35rem;
}

.mini-card strong {
    display: block;
    margin-bottom: 0.35rem;
}

.mini-card-header {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 0.75rem;
}

.mini-card-empty {
    display: grid;
    gap: 0.8rem;
}

.auth-wrapper {
    min-height: calc(100vh - 10rem);
    display: grid;
    place-items: center;
}

.auth-wrapper-wide {
    align-items: start;
    padding: 1rem 0 2rem;
}

.auth-card {
    width: min(540px, 100%);
}

.auth-card-wide {
    width: min(1120px, 100%);
}

.auth-footer {
    margin-top: 1.1rem;
    color: var(--muted);
}

.auth-footer a,
.tree-summary a {
    color: var(--primary);
    font-weight: 700;
}

.form-grid,
.editor-grid,
.profile-grid,
.stats-grid,
.people-grid,
.admin-user-grid,
.tree-board {
    display: grid;
    gap: 1rem;
}

.editor-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
}

.register-family-grid,
.register-section,
.register-family-card,
.register-card-grid {
    display: grid;
    gap: 1rem;
}

.register-card-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.register-card-grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.register-family-card {
    padding: 1rem 1.05rem;
    border-radius: var(--radius-lg);
    background: var(--surface-muted);
    border: 1px solid var(--surface-border);
}

.register-family-card-head {
    margin-bottom: 0;
}

.stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.stat-card,
.profile-card,
.tree-summary {
    border-radius: var(--radius-lg);
    padding: 1.15rem;
}

.stat-card-link {
    color: inherit;
    text-decoration: none;
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.stat-card-link:hover {
    border-color: rgba(55, 125, 82, 0.34);
    box-shadow: 0 20px 44px rgba(37, 74, 51, 0.14);
    transform: translateY(-2px);
}

.stat-card strong {
    display: block;
    font-size: 2.1rem;
    margin-bottom: 0.35rem;
}

.admin-user-grid {
    grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
}

.terms-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.term-card {
    display: grid;
    gap: 0.9rem;
    border-radius: var(--radius-lg);
    padding: 1.05rem;
    background: var(--surface-muted);
    border: 1px solid var(--surface-border);
}

.term-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.8rem;
}

.term-card-head strong,
.term-card-head span {
    display: block;
}

.term-card-head span,
.term-card p {
    color: var(--muted);
}

.admin-user-card {
    border-radius: var(--radius-lg);
    padding: 1.05rem;
    background: var(--surface-muted);
    border: 1px solid var(--surface-border);
    display: grid;
    gap: 0.9rem;
}

.admin-user-card.is-selected {
    outline: 2px solid rgba(172, 100, 56, 0.28);
    background: linear-gradient(180deg, rgba(232, 200, 154, 0.2), var(--surface-muted));
}

.theme-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.theme-card {
    border-radius: var(--radius-lg);
    padding: 1.1rem;
    background: var(--surface-muted);
    border: 1px solid var(--surface-border);
    display: grid;
    gap: 1rem;
}

.theme-card.is-active {
    outline: 2px solid rgba(172, 100, 56, 0.28);
    background: linear-gradient(180deg, rgba(232, 200, 154, 0.2), var(--surface-muted));
}

.theme-preview-stack,
.theme-preview-card,
.color-palette-section {
    display: grid;
    gap: 0.85rem;
}

.theme-preview-card {
    border-radius: 22px;
    padding: 0.95rem;
    border: 1px solid var(--surface-border);
}

.theme-preview-card strong,
.theme-preview-card span {
    display: block;
}

.theme-preview-card span {
    opacity: 0.88;
}

.swatch-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.color-swatch {
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    border: 2px solid rgba(255, 255, 255, 0.78);
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.color-editor-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.color-palette-section {
    border-radius: var(--radius-lg);
    padding: 1rem;
    background: var(--surface-muted);
    border: 1px solid var(--surface-border);
}

.color-input-grid {
    display: grid;
    gap: 0.85rem;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.color-input {
    display: grid;
    gap: 0.45rem;
}

.color-input input[type="color"] {
    width: 100%;
    min-height: 3.3rem;
    padding: 0.35rem;
    border-radius: 16px;
    border: 1px solid var(--surface-border);
    background: var(--surface-strong);
    cursor: pointer;
}

.color-code {
    font-family: Consolas, "Courier New", monospace;
    color: var(--muted);
    font-size: 0.84rem;
}

.admin-user-main,
.admin-user-meta,
.workspace-header,
.context-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.selection-badge,
.pill,
.role-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 800;
}

.selection-badge,
.pill {
    background: rgba(232, 200, 154, 0.18);
    color: var(--primary);
}

.role-admin {
    background: rgba(172, 100, 56, 0.16);
    color: var(--primary);
}

.role-user {
    background: rgba(232, 200, 154, 0.18);
    color: var(--muted);
}

.context-banner {
    border-radius: var(--radius-lg);
    padding: 1rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    box-shadow: var(--shadow);
}

.workspace-card {
    gap: 1.2rem;
}

.family-events-section {
    display: grid;
    gap: 1rem;
}

.family-events-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.25fr) minmax(300px, 0.85fr);
    gap: 1rem;
    align-items: start;
}

.event-card {
    display: grid;
    gap: 1rem;
    padding: 1rem;
    border-radius: var(--radius-lg);
    background: var(--surface-muted);
    border: 1px solid var(--surface-border);
    min-width: 0;
}

.event-card-featured {
    grid-row: span 2;
}

.event-gallery-card {
    grid-column: 2;
}

.event-card-head,
.event-block-title,
.confirmed-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
    flex-wrap: wrap;
    min-width: 0;
}

.event-card-head h3 {
    margin: 0.25rem 0 0;
    font-size: 1.45rem;
    line-height: 1.15;
}

.event-status,
.event-date-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: max-content;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 900;
}

.event-status {
    padding: 0.32rem 0.7rem;
    color: var(--primary);
    background: rgba(232, 200, 154, 0.2);
}

.event-status-upcoming {
    color: var(--success);
    background: rgba(47, 122, 78, 0.12);
}

.event-date-pill {
    min-height: 38px;
    padding: 0.45rem 0.85rem;
    color: var(--text);
    background: var(--surface-strong);
    border: 1px solid var(--surface-border);
}

.event-photo-stack {
    display: grid;
    grid-template-columns: 1.1fr 0.8fr 0.8fr;
    gap: 0.65rem;
    min-height: 150px;
}

.event-photo-thumb {
    display: block;
    min-height: 150px;
    border-radius: 18px;
    border: 1px solid var(--surface-border);
    background-size: cover;
    background-position: center;
    overflow: hidden;
}

.event-photo-thumb img,
.event-gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.event-photo-thumb-a {
    background:
        linear-gradient(135deg, rgba(47, 122, 78, 0.24), rgba(232, 200, 154, 0.18)),
        linear-gradient(45deg, #d9e8d6 0 25%, #f7f3ea 25% 50%, #bfd8c5 50% 75%, #f7f3ea 75%);
}

.event-photo-thumb-b {
    background:
        linear-gradient(135deg, rgba(172, 100, 56, 0.16), rgba(47, 122, 78, 0.16)),
        linear-gradient(45deg, #cfe2d1, #fff7eb);
}

.event-photo-thumb-c {
    background:
        linear-gradient(135deg, rgba(45, 105, 155, 0.16), rgba(232, 200, 154, 0.2)),
        linear-gradient(45deg, #e9f3ea, #d8e8de);
}

.event-meta-list {
    display: grid;
    gap: 0.4rem;
    color: var(--muted);
}

.event-meta-list span,
.event-card p,
.event-block-title a {
    overflow-wrap: anywhere;
}

.event-meta-list strong {
    color: var(--text);
}

.mini-map {
    position: relative;
    min-height: 138px;
    display: grid;
    place-items: end start;
    padding: 1rem;
    border-radius: 18px;
    overflow: hidden;
    isolation: isolate;
    background:
        linear-gradient(90deg, rgba(255, 255, 255, 0.4) 1px, transparent 1px),
        linear-gradient(rgba(255, 255, 255, 0.4) 1px, transparent 1px),
        linear-gradient(135deg, rgba(47, 122, 78, 0.14), rgba(232, 200, 154, 0.18));
    background-size: 28px 28px, 28px 28px, auto;
    border: 1px solid var(--surface-border);
}

.mini-map-compact {
    min-height: 112px;
}

.mini-map strong {
    position: relative;
    z-index: 2;
    padding: 0.36rem 0.7rem;
    border-radius: 999px;
    background: var(--surface-strong);
    border: 1px solid var(--surface-border);
    font-size: 0.82rem;
}

.map-road {
    position: absolute;
    z-index: 1;
    background: rgba(172, 100, 56, 0.16);
    border-radius: 999px;
}

.map-road-main {
    width: 145%;
    height: 18px;
    top: 50%;
    left: -20%;
    transform: rotate(-11deg);
}

.map-road-cross {
    width: 16px;
    height: 150%;
    top: -20%;
    left: 58%;
    transform: rotate(20deg);
}

.map-pin {
    position: absolute;
    z-index: 3;
    top: 38%;
    left: 55%;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 50% 50% 50% 0;
    transform: translate(-50%, -50%) rotate(-45deg);
    background: var(--primary);
    box-shadow: 0 10px 20px rgba(172, 100, 56, 0.26);
}

.map-pin::after {
    content: "";
    position: absolute;
    inset: 0.37rem;
    border-radius: 50%;
    background: var(--surface-strong);
}

.event-people-block,
.rsvp-panel {
    display: grid;
    gap: 0.75rem;
}

.event-block-title a {
    color: var(--primary);
    font-weight: 900;
}

.event-person-chips {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.event-person-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 38px;
    padding: 0.35rem 0.7rem 0.35rem 0.4rem;
    border-radius: 999px;
    color: var(--text);
    background: var(--surface-strong);
    border: 1px solid var(--surface-border);
    font-weight: 800;
    font-size: 0.86rem;
}

.event-person-chip span,
.confirmed-avatars span {
    display: inline-grid;
    place-items: center;
    width: 1.8rem;
    height: 1.8rem;
    border-radius: 999px;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--success));
    font-size: 0.72rem;
    font-weight: 900;
}

.rsvp-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.55rem;
}

.confirmed-summary {
    padding-top: 0.15rem;
    color: var(--muted);
}

.confirmed-summary strong {
    color: var(--text);
}

.confirmed-avatars {
    display: flex;
    align-items: center;
    padding-left: 0.45rem;
}

.confirmed-avatars span {
    margin-left: -0.45rem;
    border: 2px solid var(--surface-strong);
}

.event-gallery-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.6rem;
}

.event-gallery-grid-compact .event-gallery-thumb {
    min-height: 86px;
}

.event-gallery-thumb {
    min-height: 104px;
    display: grid;
    align-items: end;
    padding: 0.65rem;
    border-radius: 16px;
    overflow: hidden;
    color: #fff;
    border: 1px solid var(--surface-border);
    background-size: cover;
    background-position: center;
}

.event-gallery-thumb:has(img) {
    padding: 0;
    position: relative;
}

.event-gallery-thumb:has(img) span {
    position: absolute;
    left: 0.55rem;
    right: 0.55rem;
    bottom: 0.55rem;
}

.event-gallery-thumb span {
    font-size: 0.78rem;
    font-weight: 900;
    line-height: 1.2;
    text-shadow: 0 1px 8px rgba(0, 0, 0, 0.3);
}

.event-gallery-thumb-1 {
    background: linear-gradient(135deg, rgba(47, 122, 78, 0.92), rgba(232, 200, 154, 0.62));
}

.event-gallery-thumb-2 {
    background: linear-gradient(135deg, rgba(172, 100, 56, 0.86), rgba(47, 122, 78, 0.62));
}

.event-gallery-thumb-3 {
    background: linear-gradient(135deg, rgba(45, 105, 155, 0.86), rgba(232, 200, 154, 0.7));
}

.event-gallery-thumb-4 {
    background: linear-gradient(135deg, rgba(47, 122, 78, 0.78), rgba(245, 239, 232, 0.7));
}

.event-gallery-thumb-5 {
    background: linear-gradient(135deg, rgba(172, 100, 56, 0.78), rgba(245, 239, 232, 0.62));
}

.event-gallery-thumb-6 {
    background: linear-gradient(135deg, rgba(31, 42, 34, 0.78), rgba(47, 122, 78, 0.66));
}

.event-management-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.65rem;
    align-items: center;
}

.event-management-actions .btn,
.event-management-actions form,
.event-management-actions button {
    width: 100%;
}

.events-list-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
    gap: 1rem;
    align-items: stretch;
}

.event-management-card {
    align-content: start;
}

.event-editor-grid {
    grid-template-columns: minmax(0, 0.9fr) minmax(360px, 1.1fr);
}

.event-access-card,
.event-access-list {
    min-width: 0;
}

.event-access-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.85rem;
    flex-wrap: wrap;
}

.event-access-head h2 {
    margin-bottom: 0.25rem;
}

.event-access-head p {
    margin: 0;
    color: var(--muted);
}

.event-access-list {
    display: grid;
    gap: 0.75rem;
    max-height: 740px;
    overflow: auto;
    padding-right: 0.15rem;
}

.event-access-row {
    display: grid;
    grid-template-columns: minmax(220px, 0.85fr) minmax(260px, 1fr);
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-lg);
    background: var(--surface-muted);
    border: 1px solid var(--surface-border);
}

.event-access-row.is-selected {
    border-color: rgba(47, 122, 78, 0.32);
    background: rgba(47, 122, 78, 0.07);
}

.event-access-person {
    display: grid;
    grid-template-columns: auto 52px minmax(0, 1fr);
    align-items: center;
    gap: 0.7rem;
    color: var(--text);
    cursor: pointer;
    min-width: 0;
}

.event-access-person input {
    width: auto;
}

.event-access-person img {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    object-fit: cover;
    background: rgba(232, 200, 154, 0.16);
}

.event-access-person strong,
.event-access-person small {
    display: block;
    overflow-wrap: anywhere;
}

.event-access-person small {
    margin-top: 0.2rem;
    color: var(--muted);
}

.event-access-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem;
}

.event-access-controls .field {
    gap: 0.35rem;
}

.event-access-controls .field > span {
    font-size: 0.78rem;
    font-weight: 800;
}

.event-access-controls select {
    min-height: 44px;
    padding: 0.7rem 0.8rem;
    border-radius: 12px;
}

.event-access-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0.35rem 0.8rem;
    border-radius: 999px;
    background: rgba(47, 122, 78, 0.12);
    color: var(--primary);
    font-weight: 900;
}

.event-photo-manage-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
}

.event-photo-manage-card {
    display: grid;
    gap: 0.55rem;
    padding: 0.65rem;
    border-radius: var(--radius-lg);
    background: var(--surface-muted);
    border: 1px solid var(--surface-border);
}

.event-photo-manage-card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    border-radius: 14px;
}

.event-photo-manage-card strong,
.event-photo-manage-card small {
    display: block;
    overflow-wrap: anywhere;
}

.event-photo-manage-card small {
    color: var(--muted);
}

.admin-inline-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}

.inline-manage {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.ghost-note {
    color: var(--muted);
    font-size: 0.85rem;
}

.filter-toolbar,
.search-bar,
.tree-filter {
    display: flex;
    align-items: end;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.field-grow {
    flex: 1;
    min-width: 280px;
}

.view-toggle {
    display: inline-flex;
    gap: 0.35rem;
    padding: 0.28rem;
    border-radius: 999px;
    background: var(--surface-muted);
    border: 1px solid var(--surface-border);
}

.view-toggle button {
    min-height: 38px;
    padding: 0.45rem 0.85rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font: inherit;
    font-weight: 900;
}

.view-toggle button.is-active {
    color: #fff;
    background: var(--success);
    box-shadow: 0 10px 22px rgba(47, 122, 78, 0.18);
}

.people-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    align-items: stretch;
}

.people-grid[data-view="list"],
.people-grid[data-view="details"] {
    grid-template-columns: 1fr;
}

.people-grid[data-view="list"] .person-card-modern {
    grid-template-columns: 64px minmax(0, 1fr) auto;
    min-height: 0;
    align-items: center;
}

.people-grid[data-view="list"] .person-card-modern img {
    width: 64px;
    height: 64px;
    border-radius: 18px;
}

.people-grid[data-view="list"] .person-card-content {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    width: 100%;
}

.people-grid[data-view="list"] .person-card-top {
    align-items: center;
}

.people-grid[data-view="list"] .person-card-reveal {
    display: none;
}

.people-grid[data-view="details"] .person-card-modern {
    grid-template-columns: 96px minmax(0, 1fr);
}

.people-grid[data-view="details"] .person-card-reveal {
    max-height: none;
    margin-top: 0.2rem;
    opacity: 1;
    overflow: visible;
    pointer-events: auto;
}

.person-card {
    border-radius: var(--radius-xl);
    overflow: visible;
}

.person-card-modern {
    position: relative;
    display: grid;
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 0.95rem;
    min-height: 188px;
    padding: 1rem;
    isolation: isolate;
}

.person-card-modern img,
.profile-hero img,
.tree-summary img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.person-card-modern img {
    width: 88px;
    height: 88px;
    min-height: 0;
    border-radius: 24px;
    background: var(--surface-muted);
    box-shadow: inset 0 0 0 1px var(--surface-border);
}

.person-card-content {
    display: grid;
    align-content: space-between;
    justify-items: start;
    gap: 0.8rem;
    min-width: 0;
    padding: 0;
}

.person-card-top {
    display: flex;
    align-items: start;
    justify-content: space-between;
    width: 100%;
    min-width: 0;
    gap: 0.7rem;
}

.person-card-top > div {
    min-width: 0;
}

.person-card-top .pill {
    flex: 0 0 auto;
    max-width: 42%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.person-card-content h3,
.tree-panel h2,
.profile-card h2 {
    margin: 0;
}

.person-card-content h3 {
    font-size: 1.05rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.person-card-toggle {
    width: max-content;
    min-height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--surface-border);
    border-radius: 999px;
    padding: 0 0.85rem;
    color: var(--primary);
    background: var(--surface-strong);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(31, 42, 34, 0.08);
}

.person-card-toggle::after {
    content: "+";
    margin-left: 0.5rem;
    font-weight: 900;
}

.person-card.is-open .person-card-toggle::after {
    content: "-";
}

.person-card-reveal {
    display: grid;
    align-content: start;
    gap: 0.85rem;
    width: 100%;
    grid-column: 1 / -1;
    max-height: 0;
    margin-top: 0;
    padding: 0;
    border: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    transition: max-height 0.22s ease, margin-top 0.22s ease, opacity 0.18s ease;
}

.person-card.is-open .person-card-reveal {
    max-height: 620px;
    margin-top: 0.2rem;
    opacity: 1;
    overflow: visible;
    pointer-events: auto;
}

.person-card-modern.is-open {
    grid-column: 1 / -1;
}

.profile-hero-content {
    display: grid;
    gap: 1rem;
    align-content: start;
}

.meta-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
}

.meta-cloud span {
    padding: 0.55rem 0.8rem;
    border-radius: 14px;
    background: rgba(232, 200, 154, 0.15);
    color: var(--muted);
}

.person-card-reveal .meta-cloud {
    display: grid;
    grid-template-columns: 1fr;
    align-content: start;
    gap: 0.5rem;
}

.person-card-reveal .meta-cloud span {
    overflow-wrap: anywhere;
}

.person-card-reveal .card-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
    gap: 0.55rem;
    width: 100%;
}

.person-card-reveal .card-actions .btn,
.person-card-reveal .card-actions form {
    width: 100%;
}

.card-actions form,
.action-cluster form,
.admin-user-card form,
.workspace-header form {
    display: inline-flex;
}

.inline-card-actions {
    margin-top: 0.75rem;
}

.editor-card,
.profile-hero {
    border-radius: var(--radius-xl);
    padding: 1.2rem;
    background: var(--surface);
    border: 1px solid var(--surface-border);
    box-shadow: var(--shadow);
}

.editor-card h2 {
    margin-top: 0;
}

.editor-card-wide,
.profile-card-wide {
    grid-column: 1 / -1;
}

.field,
.field-row {
    display: grid;
    gap: 0.55rem;
}

.field-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field input,
.field textarea,
.field select {
    width: 100%;
    border: 1px solid var(--surface-border);
    border-radius: 16px;
    padding: 0.95rem 1rem;
    background: var(--surface-strong);
    color: var(--text);
    outline: none;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
    border-color: rgba(172, 100, 56, 0.42);
    box-shadow: 0 0 0 4px rgba(172, 100, 56, 0.11);
}

.field textarea {
    min-height: 170px;
    resize: vertical;
}

.field select[multiple] {
    min-height: 190px;
}

.biography-mode-control {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.55rem;
}

.biography-mode-control label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 44px;
    padding: 0.7rem 0.85rem;
    border-radius: 14px;
    border: 1px solid var(--surface-border);
    background: var(--surface-strong);
    color: var(--muted);
    cursor: pointer;
    text-align: center;
    font-weight: 800;
}

.biography-mode-control label:has(input:checked) {
    color: var(--primary);
    border-color: rgba(172, 100, 56, 0.34);
    background: rgba(232, 200, 154, 0.18);
}

.biography-mode-control input {
    width: auto;
}

.relation-auto-status {
    color: var(--primary);
    font-weight: 700;
}

.field-error,
.inline-error {
    color: var(--danger);
}

.inline-error {
    border-radius: 18px;
    padding: 0.95rem 1rem;
    background: rgba(187, 77, 63, 0.1);
    border: 1px solid rgba(187, 77, 63, 0.18);
}

.checkbox-line {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--muted);
}

.check-field {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--muted);
}

.check-field input {
    width: auto;
}

.check-field-card {
    align-self: end;
    min-height: 52px;
    padding: 0.9rem 1rem;
    border-radius: 16px;
    border: 1px solid var(--surface-border);
    background: var(--surface-strong);
}

.terms-acceptance-list {
    display: grid;
    gap: 0.9rem;
}

.terms-acceptance-item {
    display: grid;
    gap: 0.65rem;
    padding: 1rem;
    border-radius: var(--radius-lg);
    background: var(--surface-strong);
    border: 1px solid var(--surface-border);
}

.terms-acceptance-text {
    max-height: 170px;
    overflow: auto;
    padding: 0.85rem;
    border-radius: 14px;
    background: var(--surface-muted);
    color: var(--muted);
}

.photo-preview-card {
    width: min(260px, 100%);
    aspect-ratio: 1 / 1;
    border-radius: 24px;
    overflow: hidden;
    border: 1px dashed rgba(172, 100, 56, 0.28);
    background: rgba(232, 200, 154, 0.15);
}

.photo-preview-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attachment-list {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.attachment-item {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 0.75rem;
    align-items: center;
    padding: 0.8rem;
    border-radius: 18px;
    background: var(--surface-muted);
    border: 1px solid var(--surface-border);
}

.attachment-item img,
.attachment-file-icon,
.media-file-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    object-fit: cover;
    background: rgba(232, 200, 154, 0.18);
    border: 1px solid var(--surface-border);
}

.attachment-file-icon,
.media-file-icon {
    display: grid;
    place-items: center;
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 900;
}

.attachment-item-body {
    display: grid;
    gap: 0.25rem;
    min-width: 0;
}

.attachment-item-body strong,
.attachment-item-body small {
    overflow-wrap: anywhere;
}

.attachment-item .checkbox-line {
    grid-column: 1 / -1;
}

.selected-file-preview {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.selected-file-card {
    display: grid;
    gap: 0.45rem;
    padding: 0.65rem;
    border-radius: 18px;
    background: var(--surface-muted);
    border: 1px solid var(--surface-border);
}

.selected-file-card img,
.selected-file-icon {
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 14px;
    object-fit: cover;
    background: rgba(232, 200, 154, 0.18);
    border: 1px solid var(--surface-border);
}

.selected-file-icon {
    display: grid;
    place-items: center;
    color: var(--primary);
    font-weight: 900;
}

.selected-file-card strong {
    font-size: 0.86rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.photo-preview-logo {
    max-width: 220px;
    aspect-ratio: 1 / 1;
    display: grid;
    place-items: center;
    background: rgba(232, 200, 154, 0.12);
}

.logo-placeholder {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: #fff;
    font-size: 3rem;
    font-weight: 800;
}

.detail-panel {
    display: grid;
    gap: 0.4rem;
}

.relation-helper-panel {
    padding: 1rem 1.05rem;
    border-radius: var(--radius-lg);
    background: var(--surface-muted);
    border: 1px solid var(--surface-border);
}

.field-inline-actions {
    display: flex;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.form-actions-full {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    flex-wrap: wrap;
}

.profile-showcase {
    gap: 1rem;
}

.profile-hero {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 1.2rem;
}

.profile-hero img {
    aspect-ratio: 1 / 1;
    border-radius: 24px;
}

.profile-grid {
    display: block;
    columns: 320px 3;
    column-gap: 1rem;
}

.profile-card {
    display: inline-block;
    width: 100%;
    margin: 0 0 1rem;
    overflow: hidden;
    vertical-align: top;
    break-inside: avoid;
    page-break-inside: avoid;
}

.profile-card-wide {
    display: block;
    column-span: all;
}

.profile-card > p,
.profile-biography-card p {
    margin-bottom: 0;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

.profile-biography-card p {
    max-width: 100%;
}

.profile-story-card {
    display: block;
}

.profile-story-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: 1rem;
    align-items: start;
}

.profile-story-prose {
    display: grid;
    gap: 0.85rem;
    max-width: 82ch;
}

.profile-story-prose p {
    margin: 0;
    line-height: 1.72;
    font-size: 1rem;
}

.profile-story-sources {
    display: grid;
    gap: 0.45rem;
    padding: 0.9rem;
    border-radius: 18px;
    background: var(--surface-muted);
    border: 1px solid var(--surface-border);
    color: var(--muted);
}

.profile-story-sources strong {
    color: var(--text);
}

.source-avatar-row {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

.source-avatar-row img,
.source-avatar-row span {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    object-fit: cover;
    display: grid;
    place-items: center;
    color: var(--primary);
    background: var(--surface-strong);
    border: 1px solid var(--surface-border);
    font-size: 0.68rem;
    font-weight: 900;
}

.media-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fill, minmax(150px, 180px));
    align-items: start;
    justify-content: start;
}

.media-card {
    display: grid;
    gap: 0.55rem;
    padding: 0.65rem;
    border-radius: 18px;
    background: var(--surface-muted);
    border: 1px solid var(--surface-border);
}

.media-thumb {
    display: grid;
    place-items: center;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    border-radius: 14px;
    background: rgba(232, 200, 154, 0.15);
    border: 1px solid var(--surface-border);
}

.media-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-card-body {
    display: grid;
    gap: 0.18rem;
    min-width: 0;
}

.media-card-body strong {
    font-size: 0.86rem;
    line-height: 1.25;
}

.media-card-body strong,
.media-card-body small {
    overflow-wrap: anywhere;
}

.media-card-body span,
.media-card-body small {
    color: var(--muted);
    font-size: 0.78rem;
    line-height: 1.25;
}

.media-card .card-actions {
    gap: 0.45rem;
}

.media-card .btn {
    min-height: 36px;
    padding: 0.55rem 0.72rem;
    font-size: 0.84rem;
}

.media-card .media-file-icon {
    width: 48px;
    height: 48px;
    font-size: 0.72rem;
}

.relation-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.relation-chip {
    padding: 0.7rem 0.95rem;
    border-radius: 999px;
    background: rgba(232, 200, 154, 0.18);
}

.relation-empty {
    color: var(--muted);
}

.relation-card-grid {
    display: grid;
    gap: 0.85rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.relation-card {
    display: grid;
    gap: 0.75rem;
}

.tree-summary {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 1rem;
    align-items: center;
}

.tree-summary img {
    border-radius: 22px;
    aspect-ratio: 1 / 1;
}

.tree-summary-rich {
    background: var(--surface-muted);
}

.tree-board {
    grid-template-columns: 1fr;
}

.generation-panel {
    display: grid;
    gap: 1rem;
}

.generation-board {
    display: grid;
    gap: 1rem;
}

.generation-row {
    display: grid;
    grid-template-columns: 150px 1fr;
    gap: 1rem;
    align-items: stretch;
    padding: 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--surface-border);
    background: var(--surface-muted);
}

.generation-row-header {
    display: grid;
    align-content: start;
    gap: 0.35rem;
}

.generation-row-header strong {
    font-size: 1rem;
}

.generation-row-header span,
.generation-empty {
    color: var(--muted);
}

.generation-empty {
    display: grid;
    align-items: center;
    min-height: 120px;
}

.generation-people {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    align-items: stretch;
    overflow: visible;
    padding-bottom: 0;
}

.generation-people .tree-family-unit {
    min-width: 0;
}

.tree-panel {
    border-radius: var(--radius-xl);
    padding: 1.2rem;
}

.tree-panel h2 {
    margin-bottom: 1rem;
}

.ancestor-tree,
.descendant-tree {
    overflow-x: auto;
    padding-bottom: 0.75rem;
    -webkit-overflow-scrolling: touch;
}

.ancestor-node,
.descendant-node {
    display: grid;
    justify-items: center;
    gap: 1rem;
}

.ancestor-parents,
.tree-children {
    display: flex;
    gap: 1.2rem;
    justify-content: center;
    align-items: start;
    flex-wrap: nowrap;
}

.ancestor-branch,
.tree-child-branch {
    position: relative;
    padding-top: 0.65rem;
}

.ancestor-branch::before,
.tree-child-branch::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 0.8rem;
    transform: translateX(-50%);
    background: rgba(172, 100, 56, 0.22);
}

.tree-card {
    width: 100%;
    min-height: 188px;
    padding: 1rem;
    border-radius: 24px;
    border: 1px solid var(--surface-border);
    background: var(--surface-strong);
    box-shadow: var(--shadow);
    display: grid;
    justify-items: center;
    gap: 0.45rem;
    text-align: center;
}

.tree-family-unit {
    display: grid;
    align-items: stretch;
    justify-content: stretch;
    gap: 0.75rem;
    min-width: 0;
}

.tree-spouse-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0.55rem;
}

.tree-spouse-card {
    width: 100%;
    min-height: 112px;
    display: grid;
    justify-items: center;
    align-content: center;
    gap: 0.32rem;
    padding: 0.8rem;
    border-radius: 20px;
    border: 1px solid var(--surface-border);
    background: var(--surface-muted);
    text-align: center;
}

.tree-spouse-card img {
    width: 50px;
    height: 50px;
    border-radius: 15px;
    object-fit: cover;
}

.tree-spouse-card strong {
    font-size: 0.78rem;
    line-height: 1.25;
}

.tree-spouse-card small {
    color: var(--muted);
}

.tree-card-link {
    display: grid;
    justify-items: center;
    gap: 0.45rem;
}

.tree-card-toggle {
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    justify-self: center;
    border: 1px solid var(--surface-border);
    border-radius: 999px;
    padding: 0 0.85rem;
    color: var(--primary);
    background: var(--surface-strong);
    font: inherit;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 10px 22px rgba(31, 42, 34, 0.08);
}

.tree-card-toggle::after {
    content: "+";
    margin-left: 0.5rem;
    font-weight: 900;
}

.tree-card.is-open .tree-card-toggle::after {
    content: "-";
}

.tree-card-relations {
    width: 100%;
    display: grid;
    max-height: 0;
    gap: 0.22rem;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    transition: max-height 0.22s ease, opacity 0.18s ease;
}

.tree-card.is-open .tree-card-relations {
    max-height: 520px;
    opacity: 1;
    overflow: visible;
    pointer-events: auto;
}

.tree-card-relations small {
    line-height: 1.35;
    overflow-wrap: anywhere;
}

.tree-card-relations b {
    color: var(--text);
    font-weight: 700;
}

.tree-card img {
    width: 76px;
    height: 76px;
    border-radius: 18px;
    object-fit: cover;
}

.tree-card span,
.tree-card small {
    color: var(--muted);
}

.deceased-label {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: max-content;
    max-width: 100%;
    min-height: 28px;
    padding: 0.28rem 0.7rem;
    border-radius: 999px;
    background: rgba(187, 77, 63, 0.12);
    color: var(--danger) !important;
    font-size: 0.78rem;
    font-weight: 900;
    line-height: 1.1;
}

.death-info {
    color: var(--danger) !important;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.person-card-top .deceased-label,
.profile-hero-content .deceased-label,
.tree-summary .deceased-label {
    margin-top: 0.15rem;
}

.tree-card-actions {
    width: 100%;
    display: none;
    gap: 0.55rem;
    margin-top: 0.35rem;
}

.tree-card.is-open .tree-card-actions {
    display: grid;
}

.tree-card-actions form {
    display: grid;
}

.tree-card-actions .btn {
    width: 100%;
}

.tree-card-focus {
    outline: 3px solid rgba(172, 100, 56, 0.24);
}

.alert {
    border-radius: var(--radius-lg);
    padding: 1rem 1.1rem;
    margin-bottom: 1rem;
}

.alert-success {
    border-left: 4px solid var(--success);
}

.alert-error {
    border-left: 4px solid var(--danger);
}

.empty-state {
    border-radius: var(--radius-xl);
    padding: 2rem;
    text-align: center;
}

@media (max-width: 980px) {
    .topbar,
    .section-card-hero,
    .dashboard-hero,
    .hero-card-home,
    .profile-hero,
    .person-card-modern,
    .editor-grid,
    .register-card-grid-2,
    .register-card-grid-3,
    .tree-summary {
        grid-template-columns: 1fr;
    }

    .topbar {
        position: static;
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-actions {
        width: 100%;
        justify-content: space-between;
    }

    .section-head,
    .workspace-header,
    .context-banner,
    .person-card-top,
    .admin-inline-panel,
    .mini-card-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .field-row {
        grid-template-columns: 1fr;
    }

    .generation-row {
        grid-template-columns: 1fr;
    }

    .color-editor-grid {
        grid-template-columns: 1fr;
    }

    .family-events-grid,
    .profile-story-layout {
        grid-template-columns: 1fr;
    }

    .event-card-featured,
    .event-gallery-card {
        grid-column: auto;
        grid-row: auto;
    }

    .person-card-modern {
        grid-template-columns: 82px minmax(0, 1fr);
        min-height: 178px;
        padding: 0.9rem;
    }

    .person-card-modern img {
        width: 82px;
        height: 82px;
        min-height: 0;
    }

    .profile-hero img {
        width: 190px;
    }

    .tree-summary {
        text-align: center;
        justify-items: center;
    }

    .ancestor-parents,
    .tree-children {
        flex-direction: column;
        align-items: center;
    }

    .tree-family-unit {
        flex-direction: column;
    }

    .tree-spouse-list {
        width: 100%;
    }

    .tree-spouse-card {
        width: 220px;
    }
}

@media (max-width: 720px) {
    body {
        background: linear-gradient(180deg, var(--bg), var(--bg-soft));
    }

    .page-glow {
        display: none;
    }

    .site-shell {
        width: 100%;
        padding: 0.7rem 0.7rem 1.3rem;
    }

    .topbar {
        margin: -0.7rem -0.7rem 0;
        padding: 0.8rem;
        border-radius: 0 0 20px 20px;
        gap: 0.75rem;
    }

    .brand {
        width: 100%;
    }

    .brand strong,
    .brand small {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .brand-mark {
        flex: 0 0 auto;
        width: 2.45rem;
        height: 2.45rem;
        border-radius: 14px;
    }

    .brand-mark img {
        border-radius: 11px;
    }

    .topbar-actions {
        width: 100%;
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: stretch;
        gap: 0.55rem;
    }

    .main-nav {
        grid-column: 1 / -1;
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.45rem;
    }

    .main-nav a {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 42px;
        padding: 0.62rem 0.55rem;
        border: 1px solid var(--surface-border);
        border-radius: 14px;
        text-align: center;
        line-height: 1.2;
        white-space: normal;
    }

    .welcome-chip {
        grid-column: 1 / -1;
        justify-content: center;
        max-width: 100%;
        overflow-wrap: anywhere;
        border-radius: 14px;
    }

    .theme-toggle,
    .topbar-actions form,
    .topbar-actions form .btn {
        width: 100%;
    }

    .theme-toggle {
        min-height: 44px;
        padding: 0.7rem 0.8rem;
    }

    .page-content {
        padding-top: 0.85rem;
    }

    .section-stack {
        gap: 0.8rem;
    }

    .section-card,
    .hero-card,
    .auth-card,
    .editor-card,
    .profile-hero,
    .tree-panel,
    .empty-state {
        border-radius: 20px;
        padding: 1rem;
    }

    .hero-copy h1 {
        font-size: 2rem;
        line-height: 1.12;
    }

    .section-head h1,
    .section-head h2,
    .auth-card h1,
    .profile-hero h1,
    .tree-summary h2 {
        font-size: 1.55rem;
        line-height: 1.18;
    }

    .hero-actions,
    .action-cluster,
    .card-actions,
    .inline-manage,
    .field-inline-actions,
    .form-actions-full {
        display: grid;
        grid-template-columns: 1fr;
        width: 100%;
        align-items: stretch;
        gap: 0.6rem;
    }

    .view-toggle {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        width: 100%;
        border-radius: 16px;
    }

    .view-toggle button {
        padding: 0.58rem 0.5rem;
        border-radius: 12px;
        font-size: 0.86rem;
    }

    .btn {
        width: 100%;
        padding: 0.78rem 0.9rem;
        white-space: normal;
    }

    .section-head {
        gap: 0.75rem;
    }

    .section-head p,
    .hero-copy p,
    .auth-card p {
        line-height: 1.55;
    }

    .eyebrow {
        max-width: 100%;
        border-radius: 12px;
        overflow-wrap: anywhere;
    }

    .stats-grid,
    .admin-user-grid,
    .theme-grid,
    .profile-grid,
    .relation-card-grid,
    .people-grid {
        grid-template-columns: 1fr;
    }

    .profile-grid {
        columns: 1;
    }

    .hero-aside,
    .hero-panel,
    .hero-panel-home {
        grid-template-columns: 1fr;
    }

    .event-photo-stack,
    .event-gallery-grid {
        grid-template-columns: 1fr 1fr;
    }

    .event-card-head,
    .event-block-title,
    .confirmed-summary {
        align-items: flex-start;
        flex-direction: column;
    }

    .event-gallery-card .btn {
        width: 100%;
    }

    .event-access-list {
        max-height: none;
        overflow: visible;
        padding-right: 0;
    }

    .event-access-row,
    .event-access-controls {
        grid-template-columns: 1fr;
    }

    .event-access-person {
        grid-template-columns: auto 46px minmax(0, 1fr);
    }

    .event-access-person img {
        width: 46px;
        height: 46px;
        border-radius: 14px;
    }

    .hero-stat strong,
    .stat-card strong {
        font-size: 1.75rem;
    }

    .filter-toolbar,
    .search-bar,
    .tree-filter {
        display: grid;
        grid-template-columns: 1fr;
        align-items: stretch;
        width: 100%;
    }

    .field-grow {
        min-width: 0;
        width: 100%;
    }

    .field input,
    .field textarea,
    .field select {
        min-height: 44px;
        border-radius: 14px;
        padding: 0.82rem 0.9rem;
    }

    .field textarea {
        min-height: 135px;
    }

    .biography-mode-control {
        grid-template-columns: 1fr;
    }

    .person-card-modern {
        grid-template-columns: 76px minmax(0, 1fr);
        min-height: 170px;
        padding: 0.85rem;
    }

    .person-card-modern img {
        width: 76px;
        height: 76px;
        min-height: 0;
        aspect-ratio: 1;
    }

    .person-card-content {
        padding: 0;
    }

    .person-card-top {
        gap: 0.65rem;
    }

    .meta-cloud,
    .relation-list {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.55rem;
    }

    .person-card-reveal .card-actions {
        grid-template-columns: 1fr;
    }

    .people-grid[data-view="list"] .person-card-modern,
    .people-grid[data-view="details"] .person-card-modern {
        grid-template-columns: 76px minmax(0, 1fr);
    }

    .people-grid[data-view="list"] .person-card-content {
        grid-template-columns: 1fr;
        align-items: start;
    }

    .meta-cloud span,
    .relation-chip,
    .pill,
    .role-pill,
    .selection-badge {
        border-radius: 14px;
        overflow-wrap: anywhere;
    }

    .profile-hero img {
        width: min(220px, 100%);
        justify-self: center;
    }

    .tree-summary {
        gap: 0.75rem;
        padding: 1rem;
    }

    .tree-summary img {
        width: min(180px, 100%);
        height: auto;
    }

    .generation-row {
        padding: 0.8rem;
    }

    .generation-people {
        grid-template-columns: 1fr;
        gap: 0.75rem;
        margin-inline: 0;
        padding-inline: 0;
        scroll-snap-type: none;
    }

    .generation-people .tree-family-unit {
        scroll-snap-align: none;
    }

    .ancestor-tree,
    .descendant-tree {
        margin-inline: -0.45rem;
        padding-inline: 0.45rem;
    }

    .tree-card {
        width: 100%;
        min-height: auto;
        border-radius: 18px;
        padding: 0.85rem;
    }

    .tree-card img {
        width: 68px;
        height: 68px;
        border-radius: 16px;
    }

    .tree-spouse-card {
        width: 100%;
        min-height: 118px;
        border-radius: 18px;
    }

    .tree-card strong,
    .tree-spouse-card strong,
    .admin-user-card strong,
    .mini-card strong {
        overflow-wrap: anywhere;
    }

    .auth-wrapper {
        min-height: auto;
        place-items: stretch;
    }

    .auth-wrapper-wide {
        padding: 0;
    }

    .register-family-card,
    .color-palette-section,
    .theme-card,
    .admin-user-card,
    .stat-card,
    .profile-card,
    .tree-summary {
        padding: 0.9rem;
        border-radius: 18px;
    }
}

@media (max-width: 420px) {
    .site-shell {
        padding: 0.55rem 0.55rem 1.1rem;
    }

    .topbar {
        margin: -0.55rem -0.55rem 0;
        padding: 0.7rem;
    }

    .main-nav {
        grid-template-columns: 1fr;
    }

    .hero-copy h1 {
        font-size: 1.75rem;
    }

    .section-card,
    .hero-card,
    .auth-card,
    .editor-card,
    .profile-hero,
    .tree-panel,
    .empty-state {
        padding: 0.85rem;
    }

    .photo-preview-card {
        width: 100%;
    }
}

@media print {
    @page {
        size: A4 landscape;
        margin: 8mm;
    }

    html,
    body {
        background: #fff;
        color: #1f2a22;
        font-size: 9.5px;
        overflow: visible !important;
    }

    .page-glow,
    .topbar,
    .site-footer,
    .no-print,
    .alert {
        display: none !important;
    }

    .site-shell {
        width: 100%;
        max-width: none;
        padding: 0;
    }

    .page-content,
    .section-stack {
        display: block;
        padding: 0;
    }

    .tree-panel,
    .tree-card,
    .section-card,
    .tree-summary {
        box-shadow: none;
        background: #fff;
    }

    .section-card,
    .generation-panel,
    .tree-panel {
        width: 100%;
        max-width: none;
        border: 0;
        border-radius: 0;
        padding: 0;
    }

    .section-head {
        margin-bottom: 5mm;
    }

    .section-head h2 {
        margin: 0;
        font-size: 18px;
        line-height: 1.15;
    }

    .generation-board {
        display: grid;
        gap: 4mm;
    }

    .generation-row {
        display: grid;
        grid-template-columns: 24mm minmax(0, 1fr);
        gap: 4mm;
        align-items: start;
        padding: 3mm;
        border: 1px solid #d9e4dc;
        border-radius: 4mm;
        background: #fff;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .generation-row-header {
        gap: 1mm;
    }

    .generation-row-header strong {
        font-size: 11px;
    }

    .generation-row-header span,
    .generation-empty {
        font-size: 10px;
    }

    .generation-empty {
        min-height: 20mm;
    }

    .generation-people {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(42mm, 1fr));
        gap: 3mm;
        align-items: start;
        overflow: visible;
        padding: 0;
    }

    .generation-people .tree-family-unit,
    .tree-family-unit {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr;
        gap: 1.5mm;
        align-items: stretch;
        justify-content: stretch;
    }

    .tree-card,
    .tree-spouse-card {
        width: 100%;
        min-height: 0;
        padding: 2.4mm;
        border: 1px solid #d9e4dc;
        border-radius: 4mm;
        box-shadow: none;
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .tree-card {
        gap: 1.2mm;
    }

    .tree-card-link {
        gap: 1.2mm;
    }

    .tree-card img {
        width: 13mm;
        height: 13mm;
        border-radius: 3mm;
    }

    .tree-card strong,
    .tree-spouse-card strong {
        font-size: 10px;
        line-height: 1.18;
        overflow-wrap: anywhere;
    }

    .tree-card span,
    .tree-card small,
    .tree-spouse-card small {
        font-size: 8.5px;
        line-height: 1.18;
    }

    .tree-card-relations {
        max-height: none;
        gap: 0.6mm;
        opacity: 1;
        overflow: visible;
        pointer-events: auto;
    }

    .tree-spouse-list {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(26mm, 1fr));
        gap: 1.5mm;
    }

    .tree-spouse-card {
        align-content: center;
        gap: 0.8mm;
        padding: 1.8mm;
    }

    .tree-spouse-card img {
        width: 9mm;
        height: 9mm;
        border-radius: 2.4mm;
    }

    .tree-panel {
        margin-top: 6mm;
        break-before: page;
        page-break-before: always;
    }

    .tree-panel h2 {
        margin: 0 0 4mm;
        font-size: 16px;
    }

    .ancestor-tree,
    .descendant-tree {
        overflow: visible;
        padding: 0;
    }

    .ancestor-parents,
    .tree-children {
        flex-wrap: wrap;
        gap: 3mm;
    }

    .ancestor-node,
    .descendant-node {
        gap: 3mm;
    }
}
