:root {
    --bg: #efe7db;
    --bg-soft: #f8f4ed;
    --surface: rgba(255, 252, 248, 0.9);
    --surface-strong: #fffdfa;
    --border: rgba(77, 64, 43, 0.12);
    --text: #1f2933;
    --muted: #607080;
    --accent: #0f766e;
    --accent-deep: #134e4a;
    --danger: #9f2d2d;
    --shadow: 0 16px 38px rgba(31, 41, 51, 0.1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background:
        radial-gradient(circle at top left, rgba(194, 106, 61, 0.15), transparent 28rem),
        radial-gradient(circle at top right, rgba(15, 118, 110, 0.16), transparent 26rem),
        linear-gradient(180deg, #f6f1e8 0%, var(--bg) 50%, #ece2d5 100%);
}

body {
    margin: 0;
    color: var(--text);
    font-family: "Trebuchet MS", "Gill Sans", sans-serif;
    line-height: 1.45;
}

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

.shell {
    width: min(1180px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 0.85rem 0 1.8rem;
}

.site-header,
.site-footer,
.panel,
.flash,
.hero,
.profile-hero {
    backdrop-filter: blur(18px);
}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1rem;
    margin-top: 1rem;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: rgba(255, 252, 248, 0.72);
    box-shadow: var(--shadow);
}

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

.brand strong,
h1,
h2,
h3 {
    font-family: "Palatino Linotype", "Book Antiqua", Georgia, serif;
    letter-spacing: -0.03em;
}

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

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 2.35rem;
    height: 2.35rem;
    border-radius: 12px;
    background: linear-gradient(135deg, #c26a3d, #e7a36f);
    color: #fff;
    font-weight: 700;
}

.site-nav a {
    color: var(--muted);
    font-weight: 700;
}


.workspace-topbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.65rem;
    width: 100%;
    padding: 0.38rem 0.6rem;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 252, 248, 0.94);
    backdrop-filter: blur(16px);
}

.workspace-topbar-brand {
    min-width: 0;
}

.workspace-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
}

.workspace-brand .brand-mark {
    width: 1.9rem;
    height: 1.9rem;
    border-radius: 9px;
    font-size: 0.86rem;
}

.workspace-brand strong {
    font-size: 0.95rem;
}

.workspace-brand small {
    font-size: 0.7rem;
    line-height: 1.1;
}

.workspace-topbar-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.35rem;
    flex-wrap: nowrap;
    margin-left: auto;
}

.workspace-topbar .inline-form {
    display: inline-flex;
}

.workspace-topbar .button-ghost {
    min-height: 1.7rem;
    padding: 0.28rem 0.5rem;
    font-size: 0.76rem;
    line-height: 1.1;
}

.workspace-user-chip {
    display: inline-flex;
    align-items: center;
    min-height: 1.7rem;
    padding: 0.28rem 0.5rem;
    border: 1px solid rgba(77, 64, 43, 0.12);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.78);
    color: var(--muted);
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
}
.page-content {
    margin-top: 1.5rem;
}

.hero,
.profile-hero,
.panel {
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.hero {
    display: grid;
    grid-template-columns: 1.4fr 1fr;
    gap: 1.5rem;
    padding: 1.45rem;
}

.hero h1,
.profile-hero h1 {
    margin: 0;
    font-size: clamp(1.75rem, 4.2vw, 3.3rem);
    line-height: 0.95;
}

.lede {
    max-width: 60ch;
    color: #3f5061;
    font-size: 0.96rem;
}

.eyebrow {
    margin: 0 0 0.45rem;
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.16em;
    font-size: 0.68rem;
    font-weight: 700;
}

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

.stat-card,
.summary-pill {
    padding: 0.9rem;
    border-radius: 16px;
    background: linear-gradient(180deg, var(--surface-strong), var(--bg-soft));
    border: 1px solid rgba(15, 118, 110, 0.12);
}

.stat-card strong,
.summary-pill strong {
    display: block;
    font-size: 1.65rem;
    font-family: "Palatino Linotype", Georgia, serif;
}

.grid-two {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.panel {
    padding: 1.05rem;
}

.panel-heading {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.panel h2,
.relation-group h3 {
    margin: 0;
}

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

.form-grid label {
    display: grid;
    gap: 0.45rem;
    color: var(--muted);
    font-size: 0.88rem;
}

.full-width {
    grid-column: 1 / -1;
}

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

input,
select,
textarea {
    width: 100%;
    padding: 0.68rem 0.8rem;
    border-radius: 12px;
    border: 1px solid rgba(77, 64, 43, 0.14);
    background: #fff;
    color: var(--text);
}

textarea {
    resize: vertical;
}

.button-primary {
    justify-self: start;
    padding: 0.55rem 0.72rem;
    border: 0;
    border-radius: 7px;
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 14px 30px rgba(15, 118, 110, 0.22);
}

.button-danger {
    justify-self: start;
    padding: 0.55rem 0.72rem;
    border: 0;
    border-radius: 7px;
    background: linear-gradient(135deg, #b63a3a, #8f2626);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 14px 30px rgba(159, 45, 45, 0.18);
}
.person-list {
    display: grid;
    gap: 0.85rem;
}


.person-list.compact {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.person-card,
.note-card,
.empty-state {
    padding: 0.65rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(247, 242, 234, 0.9));
}

.person-card {
    display: grid;
    gap: 0.2rem;
    transition: transform 140ms ease, box-shadow 140ms ease;
}

.person-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 14px 30px rgba(31, 41, 51, 0.08);
}

.person-card span,
.person-card small,
.muted,
.meta-row {
    color: var(--muted);
}

.profile-hero {
    display: grid;
    grid-template-columns: 1.5fr 0.9fr;
    gap: 1.5rem;
    padding: 1.35rem;
}

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

.meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    margin-top: 1rem;
}

.relation-blocks {
    display: grid;
    gap: 1.1rem;
}

.note-list {
    display: grid;
    gap: 0.85rem;
    margin-top: 1rem;
}

.note-card small {
    display: block;
    margin-bottom: 0.55rem;
}

.flash {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-top: 1rem;
    padding: 0.8rem 0.95rem;
    border-radius: 14px;
    border: 1px solid var(--border);
}

.flash-success {
    background: rgba(217, 241, 238, 0.95);
}

.flash-error {
    background: rgba(247, 225, 225, 0.96);
    color: var(--danger);
}

.flash button {
    border: 0;
    background: transparent;
    cursor: pointer;
    color: inherit;
}

.site-footer {
    margin-top: 1.5rem;
    padding: 0.8rem 1rem;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: rgba(255, 252, 248, 0.72);
    color: var(--muted);
}

@media (max-width: 920px) {
    .hero,
    .profile-hero,
    .grid-two {
        grid-template-columns: 1fr;
    }

    .form-grid,
    .profile-summary,
    .hero-stats {
        grid-template-columns: 1fr;
    }

    .shell {
        width: min(100% - 1rem, 1180px);
    }
}

.button-secondary,
.button-ghost,
.toolbar-button,
.chip-button {
    border: 1px solid rgba(77, 64, 43, 0.16);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.85);
    color: var(--text);
    cursor: pointer;
    transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.button-secondary,
.button-ghost,
.toolbar-button {
    padding: 0.65rem 0.85rem;
}

.button-secondary:hover,
.button-ghost:hover,
.toolbar-button:hover,
.button-danger:hover,
.chip-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(31, 41, 51, 0.08);
}

.button-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.tree-stage {
    padding: 1rem;
}

.tree-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1.5rem;
    margin-bottom: 1.35rem;
}

.tree-lede {
    max-width: 72ch;
}

.tree-toolbar-actions {
    display: grid;
    grid-template-columns: minmax(280px, 340px) minmax(260px, 1fr);
    align-items: start;
    gap: 1rem;
    min-width: 620px;
}

.tree-toolbar-controls {
    display: grid;
    gap: 1rem;
    min-width: 260px;
}

.tree-depth-picker {
    display: grid;
    gap: 0.45rem;
    color: var(--muted);
}

.tree-person-search {
    position: relative;
    min-width: 280px;
}

.tree-search-picker {
    min-width: 100%;
}

.tree-search-input {
    width: 100%;
}

.tree-search-results {
    position: absolute;
    top: calc(100% + 0.45rem);
    left: 0;
    right: 0;
    z-index: 30;
    display: grid;
    gap: 0.15rem;
    padding: 0.35rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255, 252, 247, 0.98);
    box-shadow: 0 18px 36px rgba(31, 41, 51, 0.12);
}

.tree-search-result {
    display: grid;
    gap: 0.12rem;
    padding: 0.55rem 0.65rem;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.tree-search-result:hover,
.tree-search-result.is-active {
    background: rgba(94, 143, 200, 0.12);
}

.tree-search-result-name {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text);
}

.tree-search-result-meta {
    font-size: 0.78rem;
    color: var(--muted);
}

.tree-search-empty {
    padding: 0.55rem 0.65rem;
    font-size: 0.8rem;
    color: var(--muted);
}

.tree-nav-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.tree-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.9fr);
    gap: 1.25rem;
    align-items: stretch;
}

.tree-canvas-shell {
    position: relative;
    min-height: 720px;
    border: 1px solid var(--border);
    border-radius: 18px;
    overflow: hidden;
    background:
        radial-gradient(circle at top, rgba(15, 118, 110, 0.08), transparent 26rem),
        linear-gradient(180deg, rgba(255, 253, 250, 0.96), rgba(245, 239, 229, 0.96));
}

.tree-canvas-shell::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(15, 23, 42, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 23, 42, 0.035) 1px, transparent 1px);
    background-size: 38px 38px;
    pointer-events: none;
}

.tree-canvas {
    position: absolute;
    inset: 0;
    z-index: 1;
}

.tree-canvas-hint {
    position: absolute;
    left: 1rem;
    bottom: 1rem;
    z-index: 2;
    padding: 0.5rem 0.72rem;
    border-radius: 7px;
    background: rgba(255, 252, 248, 0.9);
    border: 1px solid rgba(77, 64, 43, 0.12);
    color: var(--muted);
    font-size: 0.82rem;
}

.tree-sidebar {
    display: grid;
    gap: 1rem;
}

.tree-selection-card,
.tree-quick-panel {
    padding: 0.9rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(247, 242, 234, 0.92));
}

.tree-selection-card h2,
.tree-quick-panel h2 {
    margin: 0;
}

.tree-selection-life {
    margin: 0.35rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.tree-meta-list {
    display: grid;
    gap: 0.45rem;
    margin-top: 1rem;
    color: var(--muted);
    font-size: 0.88rem;
}

.tree-summary-text {
    margin: 0.75rem 0 0;
    color: #455468;
}

.tree-selection-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.compact-heading {
    margin-bottom: 0.85rem;
}

.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-bottom: 1rem;
}

.chip-button {
    padding: 0.55rem 0.72rem;
    font-weight: 700;
}

.chip-button.is-active {
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    color: #fff;
    border-color: transparent;
    box-shadow: 0 12px 24px rgba(15, 118, 110, 0.2);
}

.compact-form {
    grid-template-columns: 1fr 1fr;
}

.tree-detail-grid {
    align-items: start;
}

@media (max-width: 1160px) {
    .tree-workspace {
        grid-template-columns: 1fr;
    }

    .tree-canvas-shell {
        min-height: 620px;
    }
}

@media (max-width: 920px) {
    .tree-toolbar,
    .tree-selection-actions,
    .tree-nav-buttons,
    .chip-group {
        flex-direction: column;
        align-items: stretch;
    }

    .tree-toolbar-actions {
        min-width: 0;
        width: 100%;
    }

    .tree-canvas-shell {
        min-height: 460px;
    }

    .tree-canvas-hint {
        right: 1rem;
        left: 1rem;
        border-radius: 14px;
    }

    .compact-form {
        grid-template-columns: 1fr;
    }
}

.shell {
    width: min(100vw - 1rem, 1680px);
}

.page-content {
    margin-top: 1rem;
}

.tree-stage-full {
    padding: 0.65rem;
    min-height: calc(100vh - 11rem);
}

.tree-main-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 1rem;
    min-height: calc(100vh - 13rem);
}

.tree-main-pane {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    min-height: 0;
}

.tree-toolbar-full {
    margin-bottom: 0.9rem;
    padding: 0.2rem 0.2rem 0;
}

.tree-canvas-shell-full {
    min-height: 0;
    height: 100%;
}

.tree-sidebar-docked {
    display: grid;
    gap: 0.85rem;
    max-height: calc(100vh - 13rem);
    overflow: auto;
    padding-right: 0.1rem;
}

.tree-sidebar-docked::-webkit-scrollbar {
    width: 10px;
}

.tree-sidebar-docked::-webkit-scrollbar-thumb {
    border-radius: 7px;
    background: rgba(77, 64, 43, 0.2);
}

.tree-quick-panel,
.tree-selection-card {
    box-shadow: 0 10px 30px rgba(31, 41, 51, 0.05);
}

.compact-form {
    grid-template-columns: 1fr 1fr;
}

.compact-form .full-width,
.compact-form button {
    grid-column: 1 / -1;
}

@media (max-width: 1280px) {
    .tree-main-layout {
        grid-template-columns: minmax(0, 1fr) 330px;
    }
}

@media (max-width: 1080px) {
    .shell {
        width: min(100vw - 0.6rem, 1680px);
    }

    .tree-stage-full {
        min-height: auto;
    }

    .tree-main-layout {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .tree-main-pane {
        min-height: auto;
    }

    .tree-canvas-shell-full {
        min-height: 68vh;
    }

    .tree-sidebar-docked {
        max-height: none;
        overflow: visible;
    }
}

html,
body.layout-workspace {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
}

body.layout-workspace .shell {
    display: flex;
    flex-direction: column;
    width: 100vw;
    max-width: none;
    margin: 0;
    padding: 0;
    height: 100dvh;
    min-height: 100dvh;
}

body.layout-workspace .flash {
    position: fixed;
    top: 1rem;
    right: 1rem;
    left: auto;
    z-index: 50;
    max-width: min(520px, calc(100vw - 2rem));
    margin-top: 0;
}

body.layout-workspace .page-content {
    display: flex;
    flex: 1 1 auto;
    width: 100%;
    margin-top: 0;
    min-height: 0;
    overflow: hidden;
}

body.layout-workspace .tree-stage-workspace {
    display: flex;
    flex: 1 1 auto;
    width: 100%;
    height: auto;
    padding: 0;
    min-height: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

body.layout-workspace .tree-main-layout {
    display: grid;
    flex: 1 1 auto;
    gap: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    align-items: stretch;
    overflow: hidden;
    grid-template-columns: minmax(0, 1fr) 360px;
}

body.layout-workspace .tree-main-pane {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    height: 100%;
    min-height: 0;
    overflow: hidden;
    background: linear-gradient(180deg, rgba(255, 253, 250, 0.7), rgba(245, 239, 229, 0.72));
}

body.layout-workspace .tree-toolbar-full {
    flex: 0 0 auto;
    padding: 0.75rem 0.75rem 0;
    margin-bottom: 0.5rem;
}

body.layout-workspace .tree-canvas-shell-full {
    height: 100%;
    min-height: 0;
    border-radius: 0;
    border-top: 1px solid var(--border);
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
    box-shadow: none;
}

body.layout-workspace .tree-sidebar-docked {
    gap: 0.85rem;
    min-height: 0;
    height: 100%;
    max-height: none;
    align-self: stretch;
    overflow: auto;
    padding: 0.65rem;
    background: rgba(255, 252, 248, 0.9);
    border-left: 1px solid var(--border);
}

body.layout-workspace .tree-selection-card,
body.layout-workspace .tree-quick-panel {
    box-shadow: 0 10px 30px rgba(31, 41, 51, 0.05);
}

@media (max-width: 1080px) {
    body.layout-workspace {
        overflow: auto;
    }

    .workspace-topbar {
        flex-wrap: wrap;
        align-items: center;
        gap: 0.45rem;
    }

    .workspace-topbar-actions {
        margin-left: 0;
        flex-wrap: wrap;
    }

    body.layout-workspace .tree-main-layout {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    body.layout-workspace .tree-main-pane {
        min-height: auto;
    }

    body.layout-workspace .tree-canvas-shell-full {
        height: 68vh;
        min-height: 68vh;
    }

    body.layout-workspace .tree-sidebar-docked {
        max-height: none;
        overflow: visible;
        border-left: 0;
        border-top: 1px solid var(--border);
    }
}





.tree-selection-header {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 0.8rem;
    align-items: center;
    margin-bottom: 0.7rem;
}

.tree-selection-copy {
    min-width: 0;
}

.person-photo-shell {
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid rgba(77, 64, 43, 0.12);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.72);
}

.person-photo-shell-large {
    width: 72px;
    height: 72px;
}

.person-photo-shell-inline {
    width: 84px;
    height: 84px;
    margin-bottom: 0.55rem;
}

.person-photo {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.person-photo-empty {
    padding: 0.7rem;
    font-size: 0.76rem;
    text-align: center;
    color: var(--muted);
}

.photo-upload-block {
    display: grid;
    gap: 0.45rem;
}

.field-label {
    display: block;
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text);
}

.checkbox-row {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.76rem;
    color: var(--muted);
}

.checkbox-row input {
    width: auto;
    margin: 0;
}


.person-photo-button {
    appearance: none;
    padding: 0;
    cursor: zoom-in;
}

.person-photo-button:disabled {
    cursor: default;
}

.image-modal {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: grid;
    place-items: center;
    padding: 1.25rem;
}

.image-modal[hidden] {
    display: none;
}

.image-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(3px);
}

.image-modal-dialog {
    position: relative;
    z-index: 1;
    display: grid;
    gap: 0.75rem;
    width: min(92vw, 980px);
    max-height: calc(100vh - 2.5rem);
    padding: 0.95rem;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 12px;
    background: rgba(255, 252, 248, 0.98);
    box-shadow: 0 20px 60px rgba(15, 23, 42, 0.28);
}

.image-modal-close {
    justify-self: end;
    appearance: none;
    border: 1px solid var(--border);
    border-radius: 7px;
    background: #fff;
    color: var(--text);
    padding: 0.5rem 0.7rem;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.image-modal-title {
    margin: 0;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text);
}

.image-modal-image {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 10rem);
    margin: 0 auto;
    border-radius: 10px;
    object-fit: contain;
    background: #f8f5ef;
}

body.has-image-modal {
    overflow: hidden;
}


.node-action-modal-dialog {
    width: min(96vw, 1040px);
    max-width: 1040px;
}

.node-editor-modal-dialog {
    display: flex;
    flex-direction: column;
    height: min(920px, calc(100vh - 1.5rem));
    max-height: calc(100vh - 1.5rem);
    overflow: hidden;
}

.node-action-modal-title {
    margin: 0.15rem 0 0;
    font-size: 1.2rem;
}

.node-action-modal-text {
    margin: 0.55rem 0 0;
    color: var(--muted);
}

.node-editor-header {
    display: grid;
    gap: 0.9rem;
    position: relative;
    z-index: 1;
}

.node-editor-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.node-editor-tab {
    appearance: none;
    border: 1px solid rgba(77, 64, 43, 0.14);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
    padding: 0.55rem 0.75rem;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

.node-editor-tab.is-active {
    border-color: rgba(94, 143, 200, 0.34);
    background: rgba(216, 233, 251, 0.85);
}

.node-editor-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 0.2rem 0.15rem 0 0;
    position: relative;
    z-index: 1;
    background: rgba(255, 252, 248, 0.99);
    border-top: 1px solid rgba(77, 64, 43, 0.08);
}

.node-editor-body::-webkit-scrollbar {
    width: 10px;
}

.node-editor-body::-webkit-scrollbar-thumb {
    border-radius: 7px;
    background: rgba(77, 64, 43, 0.2);
}

.node-editor-panel {
    box-shadow: none;
    position: relative;
    z-index: 1;
    background: #fffaf7;
}

.node-editor-panel[hidden] {
    display: none;
}


.node-editor-danger-form {
    display: grid;
    gap: 0.7rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(77, 64, 43, 0.12);
}

.node-editor-danger-copy {
    display: grid;
    gap: 0.35rem;
}

.node-editor-danger-copy p {
    margin: 0;
    color: var(--muted);
    font-size: 0.84rem;
}
.node-editor-modal-dialog .chip-group {
    margin-bottom: 0.85rem;
}

body.has-node-action-modal {
    overflow: hidden;
}

@media (max-width: 640px) {
    .node-editor-tabs {
        display: grid;
        grid-template-columns: 1fr;
    }
}

.layout-nav-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
}

.inline-form {
    display: inline-flex;
    margin: 0;
}

body.layout-auth {
    min-height: 100vh;
}

body.layout-auth .shell {
    width: min(100vw - 1rem, 860px);
}

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

.auth-card {
    width: min(100%, 560px);
    padding: 1.35rem;
}

.auth-card h1 {
    margin: 0;
}

.auth-lede {
    margin-bottom: 1.2rem;
}

.auth-form {
    margin-top: 1rem;
}

.auth-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.7rem;
    margin-top: 1rem;
    color: var(--muted);
}

.auth-state-card {
    display: grid;
    gap: 0.9rem;
    margin-top: 1rem;
}

.tree-toolbar-actions-compact {
    min-width: 0;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
}

.empty-tree-shell {
    display: grid;
    place-items: center;
}

.empty-root-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.95rem;
    min-width: 320px;
    padding: 1.1rem 1.35rem;
    border: 1px dashed rgba(77, 64, 43, 0.22);
    border-radius: 10px;
    background: rgba(255, 252, 247, 0.86);
    color: var(--text);
    box-shadow: 0 18px 40px rgba(31, 41, 51, 0.08);
    cursor: pointer;
    transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease;
}

.empty-root-pill:hover {
    transform: translateY(-2px);
    border-color: rgba(94, 143, 200, 0.48);
    box-shadow: 0 22px 44px rgba(31, 41, 51, 0.12);
}

.empty-root-pill-plus {
    display: inline-grid;
    place-items: center;
    width: 2.2rem;
    height: 2.2rem;
    border-radius: 7px;
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
    color: #fff;
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1;
}

.empty-root-pill-text {
    font-weight: 700;
    font-size: 1rem;
}

.tree-selection-copy-alone {
    display: grid;
    gap: 0.2rem;
}

.account-settings-grid {
    margin-top: 0;
}






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

.tree-linked-list {
    display: grid;
    gap: 0.35rem;
    max-height: 260px;
    overflow: auto;
    padding-right: 0.1rem;
}

.tree-linked-item {
    display: grid;
    gap: 0.08rem;
    width: 100%;
    padding: 0.48rem 0.58rem;
    border: 1px solid rgba(77, 64, 43, 0.1);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.72);
    text-align: left;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

.tree-linked-item:hover {
    transform: translateY(-1px);
    background: rgba(255, 255, 255, 0.92);
    border-color: rgba(94, 143, 200, 0.32);
}

.tree-linked-name {
    font-size: 0.84rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

.tree-linked-meta,
.tree-linked-empty {
    font-size: 0.75rem;
    color: var(--muted);
    line-height: 1.2;
}
.tree-linked-list {
    gap: 0.16rem;
}

.tree-linked-item {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.32rem 0.12rem;
    border: 0;
    border-bottom: 1px solid rgba(77, 64, 43, 0.08);
    border-radius: 0;
    background: transparent;
    transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.tree-linked-item:hover {
    transform: none;
    background: rgba(94, 143, 200, 0.06);
    border-color: rgba(94, 143, 200, 0.2);
}

.tree-linked-name {
    min-width: 0;
    font-size: 0.81rem;
}

.tree-linked-meta,
.tree-linked-empty {
    font-size: 0.72rem;
}

.tree-linked-meta {
    flex: 0 0 auto;
    white-space: nowrap;
}

.tree-linked-list {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 0.28rem;
}

.tree-linked-item {
    display: inline-flex;
    align-items: baseline;
    justify-content: flex-start;
    align-self: flex-start;
    flex-wrap: wrap;
    width: auto;
    max-width: 100%;
    gap: 0.5rem;
    padding: 0.26rem 0.46rem;
    border: 1px solid rgba(77, 64, 43, 0.10);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.7);
}

.tree-linked-item:hover {
    background: rgba(94, 143, 200, 0.08);
    border-color: rgba(94, 143, 200, 0.24);
}

.tree-linked-name {
    flex: 0 1 auto;
    min-width: 0;
}

.tree-linked-meta {
    flex: 0 0 auto;
    white-space: nowrap;
}

.tree-info-card {
    align-content: start;
}

#selected-children-list.tree-linked-list {
    display: grid;
    align-content: start;
    justify-items: stretch;
    gap: 0.28rem;
}

#selected-children-list .tree-linked-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    width: 100%;
    min-height: 2.35rem;
    padding: 0.36rem 0.52rem;
    border: 1px solid rgba(77, 64, 43, 0.1);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.72);
}

#selected-children-list .tree-linked-item:hover {
    transform: none;
    background: rgba(94, 143, 200, 0.08);
    border-color: rgba(94, 143, 200, 0.24);
}

#selected-children-list .tree-linked-name {
    min-width: 0;
    font-size: 0.81rem;
}

#selected-children-list .tree-linked-meta {
    white-space: nowrap;
    font-size: 0.72rem;
}

#selected-children-list.tree-linked-list {
    width: 100%;
    justify-items: stretch;
}

#selected-children-list .tree-linked-item {
    width: 100%;
    max-width: none;
    justify-self: stretch;
    align-self: stretch;
    grid-template-columns: minmax(0, 1fr) auto;
}

.tree-selection-card.tree-info-card {
    align-content: start !important;
}

#selected-children-list.tree-linked-list {
    display: grid !important;
    width: 100% !important;
    align-content: start !important;
    justify-items: stretch !important;
    justify-content: start !important;
}

#selected-children-list.tree-linked-list > .tree-linked-item {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: center !important;
    justify-content: stretch !important;
    justify-self: stretch !important;
    align-self: stretch !important;
    width: 100% !important;
    max-width: none !important;
    min-height: 2.35rem !important;
    box-sizing: border-box !important;
}

#selected-children-list.tree-linked-list {
    display: grid !important;
    width: 100% !important;
    align-content: start !important;
    justify-items: stretch !important;
    gap: 0.28rem !important;
}

#selected-children-list > .tree-linked-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    width: 100%;
    min-height: 2.35rem;
    box-sizing: border-box;
    padding: 0.36rem 0.52rem;
    border: 1px solid rgba(77, 64, 43, 0.1);
    border-radius: 7px;
    background: rgba(255, 255, 255, 0.72);
    color: inherit;
    text-decoration: none;
}

#selected-children-list > .tree-linked-row:hover {
    background: rgba(94, 143, 200, 0.08);
    border-color: rgba(94, 143, 200, 0.24);
}

#selected-children-list .tree-linked-row-name {
    min-width: 0;
    font-size: 0.81rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

#selected-children-list .tree-linked-row-meta {
    white-space: nowrap;
    font-size: 0.72rem;
    color: var(--muted);
    line-height: 1.2;
}

#selected-children-list.tree-linked-list {
    grid-template-columns: minmax(0, 1fr) !important;
}

.compact-form .death-date-field,
.form-grid .death-date-field {
    grid-column: auto;
}

.compact-form .inline-switch-field,
.form-grid .inline-switch-field {
    grid-column: auto;
    align-self: end;
    justify-self: start;
    margin-bottom: 0.12rem;
}

.inline-switch-field {
    display: inline-grid;
    gap: 0.32rem;
    color: var(--muted);
    font-size: 0.76rem;
}

.inline-switch-field input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 2.45rem;
    height: 1.4rem;
    margin: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(77, 64, 43, 0.18);
    position: relative;
    cursor: pointer;
    transition: background 140ms ease;
}

.inline-switch-field input[type="checkbox"]::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.2);
    transition: transform 140ms ease;
}

.inline-switch-field input[type="checkbox"]:checked {
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
}

.inline-switch-field input[type="checkbox"]:checked::after {
    transform: translateX(16px);
}
.inline-switch-field.checkbox-row {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: flex-end;
    gap: 0.55rem;
    align-self: end;
    justify-self: end;
    margin: 0 0 0.18rem 0;
}

.inline-switch-field.checkbox-row span {
    order: 1;
}

.inline-switch-field.checkbox-row input[type="checkbox"] {
    order: 2;
    appearance: none !important;
    -webkit-appearance: none !important;
    flex: 0 0 auto;
    width: 2.45rem;
    height: 1.4rem;
    margin: 0;
    border: 0 !important;
    outline: none;
    border-radius: 999px;
    background: rgba(77, 64, 43, 0.18) !important;
    position: relative;
    cursor: pointer;
    transition: background 140ms ease;
}

.inline-switch-field.checkbox-row input[type="checkbox"]::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.2);
    transition: transform 140ms ease;
}

.inline-switch-field.checkbox-row input[type="checkbox"]:checked {
    background: linear-gradient(135deg, var(--accent), var(--accent-deep)) !important;
}

.inline-switch-field.checkbox-row input[type="checkbox"]:checked::after {
    transform: translateX(16px);
}
.compact-form .death-date-field,
.form-grid .death-date-field,
.compact-form .inline-switch-field,
.form-grid .inline-switch-field {
    width: 100% !important;
    justify-self: stretch !important;
}

.inline-switch-field.checkbox-row {
    display: flex !important;
    width: 100% !important;
    min-height: 2.9rem;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 0.75rem;
    padding-top: 1.45rem;
    box-sizing: border-box;
}

.inline-switch-field.checkbox-row span {
    order: 1;
    flex: 1 1 auto;
}

.inline-switch-field.checkbox-row input[type="checkbox"] {
    order: 2;
    flex: 0 0 auto;
}
.death-date-field-inline {
    display: grid;
    gap: 0.35rem;
}

.death-date-field-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.switch-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--muted);
    font-size: 0.76rem;
}

.switch-inline-control {
    position: relative;
    display: inline-flex;
    width: 2.45rem;
    height: 1.4rem;
    flex: 0 0 auto;
}

.switch-inline-control input {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}

.switch-inline-slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: rgba(77, 64, 43, 0.18);
    transition: background 140ms ease;
}

.switch-inline-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.2);
    transition: transform 140ms ease;
}

.switch-inline-control input:checked + .switch-inline-slider {
    background: linear-gradient(135deg, var(--accent), var(--accent-deep));
}

.switch-inline-control input:checked + .switch-inline-slider::after {
    transform: translateX(16px);
}