/* ═══════════════════════════════════════════════════════════════════
   ProjectRoots Tree Editor Styles
   ═══════════════════════════════════════════════════════════════════ */

.tree-page-header.container {
    padding: 48px 20px 28px;
}

.tree-page-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    flex-wrap: wrap;
}

.tree-breadcrumb {
    display: inline-block;
    margin-bottom: 10px;
    color: var(--text-secondary);
    font-size: 0.74rem;
    letter-spacing: 0.16em;
}

.tree-page-kicker,
.tree-eyebrow {
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.74rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.tree-page-title {
    font-size: clamp(1.9rem, 5vw, 3.2rem);
    line-height: 1.05;
}

.tree-page-subtitle {
    margin-top: 10px;
    max-width: 56ch;
    font-size: 0.98rem;
}

.tree-status-pill,
.tree-inline-banner {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.tree-status-pill-demo {
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.tree-inline-banner {
    margin-top: 24px;
    border-radius: 18px;
    padding: 18px 20px;
}

.tree-page-section.container {
    padding: 0 20px 120px;
}

.tree-shell {
    display: flex;
    flex-direction: column;
    gap: 22px;
}

.tree-rail,
.tree-canvas,
.tree-inspector {
    border-radius: 26px;
}

.tree-rail {
    padding: 24px;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.06), transparent 34%),
        var(--glass-bg);
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.tree-rail-head {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.tree-rail-head h2 {
    font-size: clamp(1.15rem, 2.5vw, 1.6rem);
    max-width: 20ch;
}

.tree-rail-note {
    max-width: 30ch;
    font-size: 0.88rem;
}

.tree-tabs {
    display: flex;
    gap: 14px;
    overflow-x: auto;
    padding-bottom: 6px;
    scrollbar-width: thin;
}

.tree-tab-card,
.tree-tab-add {
    flex: 0 0 220px;
    min-width: 220px;
}

.tree-tab-card {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 12px;
    padding: 14px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.tree-tab-card.is-active {
    border-color: var(--branch-tab-border);
    background:
        linear-gradient(180deg, var(--branch-tab-bg), rgba(255, 255, 255, 0.02)),
        rgba(255, 255, 255, 0.02);
    box-shadow:
        0 18px 34px rgba(0, 0, 0, 0.16),
        inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.tree-tab-main {
    border: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tree-tab-label {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
}

.tree-tab-meta {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.tree-tab-controls {
    display: flex;
    gap: 8px;
}

.tree-icon-button,
.tree-tab-add,
.mode-chip,
.canvas-action,
.inspector-action,
.inspector-toggle,
.inspector-list-item {
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    font-family: var(--font-main);
    transition: transform 0.24s ease, border-color 0.24s ease, background 0.24s ease;
}

.tree-icon-button,
.mode-chip,
.canvas-action,
.inspector-action,
.inspector-toggle {
    padding: 11px 14px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 500;
}

.tree-icon-button:hover,
.tree-tab-add:hover,
.mode-chip:hover,
.canvas-action:hover,
.inspector-action:hover,
.inspector-toggle:hover,
.inspector-list-item:hover {
    transform: translateY(-1px);
    border-color: rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.06);
}

.tree-tab-add {
    padding: 18px;
    border-radius: 20px;
    cursor: pointer;
    text-align: left;
    font-size: 0.96rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.tree-icon-button:disabled,
.tree-tab-add:disabled,
.mode-chip:disabled,
.canvas-action:disabled,
.inspector-action:disabled,
.inspector-toggle:disabled,
.color-swatch:disabled {
    opacity: 0.42;
    cursor: not-allowed;
    transform: none;
}

.tree-rail-tools {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.color-picker-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.color-picker-label {
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.color-swatch-list {
    display: flex;
    gap: 10px;
}

.color-swatch {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    border: 2px solid transparent;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.color-swatch:hover {
    transform: scale(1.08);
}

.color-swatch.active {
    border-color: white;
    transform: scale(1.04);
}

.tree-mode-toggle {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.mode-chip.is-active {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.16);
}

.tree-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) 360px;
    gap: 22px;
    align-items: start;
}

.tree-canvas {
    padding: 28px;
    background:
        radial-gradient(circle at top center, rgba(255, 255, 255, 0.04), transparent 42%),
        var(--glass-bg);
}

.tree-canvas-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.tree-canvas-head h2 {
    font-size: clamp(1.35rem, 2.7vw, 1.9rem);
}

.tree-canvas-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.canvas-action-muted {
    color: var(--text-secondary);
}

.tree-container {
    --branch-accent: rgba(234, 134, 118, 0.92);
    --branch-strong: rgba(234, 134, 118, 0.78);
    --branch-line: rgba(234, 134, 118, 0.28);
    --branch-soft: rgba(234, 134, 118, 0.08);
    --branch-hover: rgba(234, 134, 118, 0.14);
}

.tree-scene {
    padding: 34px clamp(18px, 4vw, 38px) 42px;
    border-radius: 28px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    background:
        radial-gradient(circle at top center, var(--branch-soft), transparent 42%),
        rgba(255, 255, 255, 0.02);
}

.tree-root-card {
    width: min(100%, 500px);
    margin: 0 auto;
    padding: 24px;
    border-radius: 24px;
    border: 1px solid var(--branch-line);
    background: linear-gradient(180deg, var(--branch-soft), rgba(255, 255, 255, 0.02));
    display: flex;
    flex-direction: column;
    gap: 14px;
    text-align: center;
    color: var(--text-primary);
    cursor: pointer;
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.tree-root-card:hover,
.person-card:hover,
.relationship-block:hover {
    transform: translateY(-2px);
}

.tree-root-kicker {
    align-self: center;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--branch-accent);
    font-size: 0.74rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.tree-root-pair {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    font-family: var(--font-heading);
    font-size: clamp(1.15rem, 2vw, 1.65rem);
    font-weight: 600;
}

.tree-root-divider {
    width: 40px;
    height: 2px;
    border-radius: 999px;
    background: var(--branch-line);
}

.tree-root-note {
    color: var(--text-secondary);
    font-size: 0.84rem;
}

.tree-stem {
    width: 2px;
    height: 52px;
    margin: 0 auto 8px;
    background: linear-gradient(180deg, var(--branch-line), transparent);
}

.tree-member-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 18px;
    align-items: start;
}

.member-slot {
    position: relative;
    min-width: 0;
    padding-top: 24px;
}

.member-slot::before {
    content: '';
    position: absolute;
    left: 18px;
    right: 18px;
    top: 8px;
    height: 3px;
    border-radius: 999px;
    opacity: 0;
    transition: opacity 0.18s ease;
}

.member-slot.is-drop-before::before,
.member-slot.is-drop-after::before {
    opacity: 1;
    background: var(--branch-accent);
}

.member-slot.is-drop-after::before {
    top: auto;
    bottom: -8px;
}

.member-connector {
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 24px;
    transform: translateX(-50%);
    background: var(--branch-line);
}

.person-card {
    height: 100%;
    padding: 20px;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: linear-gradient(180deg, var(--branch-soft), rgba(255, 255, 255, 0.02));
    display: flex;
    flex-direction: column;
    gap: 16px;
    cursor: pointer;
    user-select: none;
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease, opacity 0.2s ease;
}

.person-card.is-dragging {
    opacity: 0.42;
}

.tree-root-card.is-selected,
.person-card.is-selected,
.relationship-block.is-selected {
    border-color: var(--branch-strong);
    box-shadow:
        0 0 0 1px var(--branch-line),
        0 20px 44px rgba(0, 0, 0, 0.18);
}

.person-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 14px;
}

.person-card-kicker {
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 0.72rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.person-name {
    font-size: 1.18rem;
    line-height: 1.15;
}

.person-card-badge {
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    font-size: 0.72rem;
    white-space: nowrap;
}

.relationship-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.relationship-block {
    padding: 14px;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: transform 0.24s ease, border-color 0.24s ease, background 0.24s ease;
}

.relationship-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.relationship-label,
.children-label,
.inspector-group-title {
    color: var(--text-secondary);
    font-size: 0.74rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.relationship-partner {
    font-size: 0.98rem;
    line-height: 1.2;
}

.relationship-children {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.children-chip-list {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.child-chip,
.children-empty {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    font-size: 0.78rem;
}

.children-empty {
    color: var(--text-secondary);
}

.person-note {
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    font-size: 0.84rem;
}

.expand-link {
    align-self: flex-start;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--branch-accent);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
}

.person-empty,
.tree-empty-state p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.tree-empty-state {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    justify-content: center;
    min-height: 240px;
    padding: 32px;
    border-radius: 22px;
    border: 1px dashed var(--branch-line);
    background: rgba(255, 255, 255, 0.02);
    text-align: center;
}

.tree-inspector {
    position: sticky;
    top: 24px;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background:
        radial-gradient(circle at top left, rgba(255, 255, 255, 0.05), transparent 30%),
        var(--glass-bg);
}

.inspector-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.inspector-head h3 {
    font-size: 1.28rem;
}

.inspector-head p {
    margin-top: 8px;
    font-size: 0.88rem;
}

.inspector-save-note,
.inspector-preview-note {
    padding: 12px 14px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.inspector-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.inspector-group {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.02);
}

.inspector-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.inspector-field span {
    font-size: 0.82rem;
    font-weight: 500;
}

.inspector-field small {
    color: var(--text-secondary);
    font-size: 0.76rem;
}

.inspector-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
    font-family: var(--font-main);
    font-size: 0.92rem;
    resize: vertical;
}

.inspector-input:focus {
    outline: 0;
    border-color: rgba(255, 255, 255, 0.18);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
}

.inspector-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.inspector-action-danger {
    color: #fca5a5;
    border-color: rgba(252, 165, 165, 0.24);
}

.inspector-stats {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.inspector-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.inspector-list-item {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    width: 100%;
    padding: 12px 14px;
    border-radius: 14px;
    cursor: pointer;
    text-align: left;
    font-size: 0.84rem;
}

.inspector-list-item span:last-child {
    color: var(--text-secondary);
    font-size: 0.78rem;
}

.tree-demo-cta.container {
    padding: 80px 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.tree-page-footer {
    padding: 40px 20px 144px;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 0.84rem;
}

.tree-page-footer p + p {
    margin-top: 8px;
    font-size: 0.76rem;
    opacity: 0.72;
}

[data-theme="light"] .tree-status-pill,
[data-theme="light"] .tree-inline-banner,
[data-theme="light"] .tree-tab-card,
[data-theme="light"] .tree-tab-add,
[data-theme="light"] .tree-canvas,
[data-theme="light"] .tree-inspector,
[data-theme="light"] .tree-scene,
[data-theme="light"] .person-card,
[data-theme="light"] .relationship-block,
[data-theme="light"] .inspector-group,
[data-theme="light"] .inspector-save-note,
[data-theme="light"] .inspector-preview-note {
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .tree-root-card,
[data-theme="light"] .person-card,
[data-theme="light"] .relationship-block,
[data-theme="light"] .inspector-input,
[data-theme="light"] .inspector-list-item,
[data-theme="light"] .tree-icon-button,
[data-theme="light"] .tree-tab-add,
[data-theme="light"] .mode-chip,
[data-theme="light"] .canvas-action,
[data-theme="light"] .inspector-action,
[data-theme="light"] .inspector-toggle {
    background: rgba(255, 255, 255, 0.7);
}

[data-theme="light"] .color-swatch.active {
    border-color: #111;
}

[data-theme="light"] .inspector-input:focus {
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.06);
}

@media (max-width: 1180px) {
    .tree-workspace {
        grid-template-columns: 1fr;
    }

    .tree-inspector {
        position: static;
    }
}

@media (max-width: 960px) {
    .tree-page-header.container {
        padding-top: 36px;
    }

    .tree-page-section.container {
        padding-bottom: 150px;
    }

    .tree-canvas {
        padding: 22px;
    }

    .tree-inspector {
        position: fixed;
        left: 12px;
        right: 12px;
        bottom: calc(92px + env(safe-area-inset-bottom, 0px));
        z-index: 1200;
        max-height: min(72vh, 560px);
        transform: translateY(calc(100% - 72px));
        transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
        box-shadow: 0 24px 44px rgba(0, 0, 0, 0.26);
    }

    .tree-inspector.is-open {
        transform: translateY(0);
    }

    .inspector-body {
        max-height: calc(min(72vh, 560px) - 110px);
        overflow-y: auto;
        padding-right: 4px;
    }
}

@media (max-width: 768px) {
    .tree-page-title {
        font-size: 1.8rem;
    }

    .tree-rail,
    .tree-canvas {
        padding: 18px;
    }

    .tree-tab-card,
    .tree-tab-add {
        flex-basis: 190px;
        min-width: 190px;
    }

    .tree-root-card {
        padding: 20px;
    }

    .tree-root-pair {
        flex-direction: column;
        gap: 10px;
    }

    .tree-root-divider {
        width: 2px;
        height: 26px;
    }

    .tree-scene {
        padding: 24px 16px 30px;
    }

    .tree-member-grid {
        grid-template-columns: 1fr;
    }

    .person-card-head {
        flex-direction: column;
    }

    .canvas-action,
    .inspector-action,
    .inspector-toggle,
    .tree-icon-button,
    .mode-chip {
        width: 100%;
        justify-content: center;
    }

    .tree-canvas-actions,
    .inspector-actions {
        flex-direction: column;
    }

    .tree-status-pill {
        width: 100%;
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tree-root-card,
    .person-card,
    .relationship-block,
    .tree-icon-button,
    .tree-tab-add,
    .mode-chip,
    .canvas-action,
    .inspector-action,
    .inspector-toggle,
    .inspector-list-item,
    .tree-inspector {
        transition-duration: 0.01ms;
    }
}
