/* V9 keeps the V4 control surface and replaces only its visual background. */
.fantasy-tree-visual-version[data-tree-visual-version-switcher="v4"] {
    grid-template-columns: repeat(4, 38px);
    grid-template-rows: 36px;
    grid-auto-flow: column;
}
.fantasy-tree-visual-version[data-tree-visual-version-switcher="v7"] {
    grid-template-columns: repeat(7, 38px);
    grid-template-rows: 36px;
    grid-auto-flow: column;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage
    > .fantasy-tree-v9-root {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-root {
    position: relative;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    background: #000;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-root
    .fantasy-tree-v4-scene {
    position: relative;
    overflow: hidden;
    isolation: isolate;
    background: #000;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-root
    :is(
        .fantasy-tree-v4-backdrop,
        .fantasy-tree-v4-viewport,
        .fantasy-tree-v4-hud-layer
    ) {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-root
    :is(
        .fantasy-tree-v4-backdrop *,
        .fantasy-tree-v4-viewport *,
        .fantasy-tree-v4-hud-layer *
    ) {
    animation: none !important;
}

/* The V4 graph stays mounted for shared controls, but its old hit areas and preview
   must never participate while V9 owns the stage. */
body.fantasy-tree-v9-active
    .fantasy-tree-v9-root
    :is(
        .fantasy-tree-v4-node,
        .fantasy-tree-v4-node-hit,
        .fantasy-tree-v4-preview,
        .fantasy-tree-v4-preview-connector
    ) {
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-artboard {
    position: absolute;
    z-index: 1;
    inset: 0;
    overflow: hidden;
    contain: layout paint;
    pointer-events: none;
    background: #000;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-viewport {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-scene-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 2560px;
    height: 1440px;
    overflow: hidden;
    transform-origin: 0 0;
    will-change: transform;
    pointer-events: none;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-video {
    position: absolute;
    z-index: 1;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border: 0;
    outline: 0;
    background: #000;
    width: 2560px;
    height: 1440px;
    object-fit: fill;
    object-position: center;
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    will-change: transform;
    user-select: none;
    pointer-events: none;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-editor-panel {
    position: absolute;
    z-index: 24;
    top: 18px;
    left: 18px;
    display: flex;
    flex-direction: column;
    width: min(300px, calc(100% - 36px));
    box-sizing: border-box;
    max-height: calc(100% - 36px);
    overflow: hidden;
    color: rgba(224, 250, 255, 0.92);
    border: 1px solid rgba(94, 246, 255, 0.28);
    background: linear-gradient(180deg, rgba(4, 16, 34, 0.94), rgba(3, 9, 22, 0.90));
    box-shadow: 0 0 26px rgba(0, 0, 0, 0.38), 0 0 20px rgba(94, 246, 255, 0.08);
    pointer-events: auto;
    backdrop-filter: blur(12px);
    transition: transform 180ms ease, opacity 180ms ease;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-artboard.is-panel-collapsed
    .fantasy-tree-v9-editor-panel {
    width: 34px;
    min-width: 34px;
    max-width: 34px;
    height: 42px;
    max-height: 42px;
    overflow: hidden;
    transform: none;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-artboard.is-panel-collapsed
    .fantasy-tree-v9-editor-panel > :not(.fantasy-tree-v9-editor-header) {
    display: none;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-artboard.is-panel-collapsed
    .fantasy-tree-v9-editor-header {
    height: 42px;
    box-sizing: border-box;
    justify-content: flex-end;
    padding: 7px 3px;
    border-bottom: 0;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-artboard.is-panel-collapsed
    .fantasy-tree-v9-editor-header > div {
    display: none;
}

.fantasy-tree-v9-editor-header,
.fantasy-tree-v9-editor-meta,
.fantasy-tree-v9-editor-actions {
    flex: 0 0 auto;
}

.fantasy-tree-v9-editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 13px 11px 9px;
    border-bottom: 1px solid rgba(157, 124, 255, 0.18);
}

.fantasy-tree-v9-editor-header > div {
    display: grid;
    gap: 4px;
}

.fantasy-tree-v9-editor-kicker {
    color: rgba(255, 83, 199, 0.78);
    font-size: 9px;
    letter-spacing: 0.12em;
}

.fantasy-tree-v9-editor-header strong {
    color: rgba(239, 255, 255, 0.96);
    font-size: 14px;
    font-weight: 650;
}

.fantasy-tree-v9-editor-collapse,
.fantasy-tree-v9-editor-actions button,
.fantasy-tree-v9-editor-life-header,
.fantasy-tree-v9-editor-node {
    border: 0;
    font: inherit;
}

.fantasy-tree-v9-editor-collapse {
    display: grid;
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    place-items: center;
    color: rgba(176, 222, 235, 0.76);
    background: rgba(255, 255, 255, 0.045);
    cursor: pointer;
}

.fantasy-tree-v9-editor-collapse:hover,
.fantasy-tree-v9-editor-collapse:focus-visible {
    color: #e9ffff;
    background: rgba(94, 246, 255, 0.16);
    outline: none;
}

.fantasy-tree-v9-editor-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 11px;
    color: rgba(169, 210, 223, 0.72);
    font-size: 10px;
}

.fantasy-tree-v9-editor-meta span:last-child {
    color: rgba(94, 246, 255, 0.88);
}

.fantasy-tree-v9-editor-meta span.is-saving {
    color: rgba(255, 221, 141, 0.92);
}

.fantasy-tree-v9-editor-meta span.is-conflict,
.fantasy-tree-v9-editor-meta span.is-error {
    color: rgba(255, 110, 196, 0.94);
}

.fantasy-tree-v9-editor-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 0 11px 9px;
}

.fantasy-tree-v9-editor-actions button {
    min-height: 30px;
    padding: 0 8px;
    color: rgba(197, 237, 246, 0.82);
    border: 1px solid rgba(94, 246, 255, 0.20);
    background: rgba(7, 25, 44, 0.74);
    cursor: pointer;
    font-size: 10px;
}

.fantasy-tree-v9-editor-actions button:hover,
.fantasy-tree-v9-editor-actions button:focus-visible,
.fantasy-tree-v9-editor-actions button[aria-pressed="true"] {
    color: #efffff;
    border-color: rgba(94, 246, 255, 0.68);
    background: linear-gradient(90deg, rgba(0, 212, 255, 0.18), rgba(157, 124, 255, 0.20));
    outline: none;
}

.fantasy-tree-v9-editor-actions button:disabled {
    opacity: 0.44;
    cursor: default;
}

.fantasy-tree-v9-editor-actions button i {
    margin-right: 5px;
    color: rgba(255, 83, 199, 0.78);
}

.fantasy-tree-v9-editor-lives {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 7px 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(94, 246, 255, 0.48) transparent;
}

.fantasy-tree-v9-editor-life {
    margin: 0 0 5px;
    border: 1px solid rgba(94, 246, 255, 0.11);
    background: rgba(4, 15, 31, 0.58);
}

.fantasy-tree-v9-editor-life.is-selected {
    border-color: rgba(94, 246, 255, 0.58);
    box-shadow: inset 2px 0 0 rgba(94, 246, 255, 0.92), 0 0 14px rgba(94, 246, 255, 0.08);
}

.fantasy-tree-v9-editor-life.is-current {
    border-right-color: rgba(255, 83, 199, 0.62);
}

.fantasy-tree-v9-editor-life-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 8px;
    padding: 9px 9px 8px 10px;
    color: rgba(224, 250, 255, 0.90);
    text-align: left;
    background: transparent;
    cursor: pointer;
}

.fantasy-tree-v9-editor-life-header:hover,
.fantasy-tree-v9-editor-life-header:focus-visible {
    background: rgba(94, 246, 255, 0.08);
    outline: none;
}

.fantasy-tree-v9-editor-life-main {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.fantasy-tree-v9-editor-life-main strong {
    overflow: hidden;
    color: rgba(239, 255, 255, 0.94);
    font-size: 11px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fantasy-tree-v9-editor-life-main small {
    color: rgba(155, 207, 220, 0.70);
    font-size: 9px;
}

.fantasy-tree-v9-editor-life-title {
    min-width: 0;
    color: rgba(224, 250, 255, 0.90);
    font-size: 11px;
    line-height: 1.5;
    white-space: normal;
    overflow-wrap: anywhere;
}

.fantasy-tree-v9-editor-life-header > i {
    flex-shrink: 0;
    color: rgba(157, 124, 255, 0.78);
    font-size: 9px;
}

.fantasy-tree-v9-editor-node-list {
    display: grid;
    gap: 2px;
    padding: 0 5px 5px 10px;
}

.fantasy-tree-v9-editor-node {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 26px;
    padding: 0 7px;
    color: rgba(179, 220, 230, 0.78);
    border-left: 1px solid rgba(157, 124, 255, 0.26);
    background: rgba(10, 27, 48, 0.48);
    cursor: pointer;
    font-size: 10px;
    text-align: left;
}

.fantasy-tree-v9-editor-node:hover,
.fantasy-tree-v9-editor-node:focus-visible,
.fantasy-tree-v9-editor-node.is-selected {
    color: #f1ffff;
    border-left-color: rgba(255, 83, 199, 0.86);
    background: linear-gradient(90deg, rgba(94, 246, 255, 0.14), rgba(157, 124, 255, 0.16));
    outline: none;
}

.fantasy-tree-v9-editor-node i {
    color: rgba(94, 246, 255, 0.58);
    font-size: 9px;
}

.fantasy-tree-v9-editor-node.is-material {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto 16px;
    gap: 7px;
    min-height: 30px;
    cursor: grab;
    touch-action: none;
    user-select: none;
}

.fantasy-tree-v9-artboard:not(.is-editing) .fantasy-tree-v9-editor-node.is-material,
.fantasy-tree-v9-artboard.is-readonly .fantasy-tree-v9-editor-node.is-material {
    cursor: pointer;
    touch-action: auto;
}

.fantasy-tree-v9-editor-node.is-material > span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fantasy-tree-v9-editor-node-status {
    color: rgba(122, 211, 229, 0.58);
    font-size: 8px;
    white-space: nowrap;
}

.fantasy-tree-v9-editor-node.is-material.is-dragging {
    color: #fff;
    border-left-color: rgba(255, 83, 199, 0.96);
    background: linear-gradient(90deg, rgba(27, 215, 255, 0.22), rgba(157, 124, 255, 0.28));
    cursor: grabbing;
}

.fantasy-tree-v9-editor-root-material {
    display: grid;
    gap: 5px;
    margin: 0 0 8px;
    padding: 7px;
    border-bottom: 1px solid rgba(157, 124, 255, 0.22);
    background: rgba(7, 23, 42, 0.58);
}

.fantasy-tree-v9-editor-root-label {
    color: rgba(255, 83, 199, 0.72);
    font-size: 9px;
}

.fantasy-tree-v9-editor-root-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 8px;
    padding: 8px 9px;
    color: rgba(218, 250, 255, 0.82);
    border-bottom: 1px solid rgba(157, 124, 255, 0.18);
    background: rgba(7, 23, 42, 0.44);
    font-size: 10px;
}

.fantasy-tree-v9-editor-root-status small,
.fantasy-tree-v9-editor-life-complete {
    color: rgba(94, 246, 255, 0.62);
    font-size: 9px;
}

.fantasy-tree-v9-editor-life-complete {
    display: flex;
    align-items: center;
    gap: 6px;
    min-height: 28px;
    padding: 0 8px;
    border-left: 1px solid rgba(94, 246, 255, 0.22);
    background: rgba(7, 25, 44, 0.42);
}

.fantasy-tree-v9-material-drag-ghost {
    position: fixed;
    z-index: 10020;
    min-width: 88px;
    padding: 7px 10px;
    color: #f4ffff;
    border: 1px solid rgba(94, 246, 255, 0.78);
    background: rgba(4, 18, 38, 0.94);
    box-shadow: 0 0 16px rgba(94, 246, 255, 0.34), 0 0 28px rgba(157, 124, 255, 0.18);
    font-size: 10px;
    pointer-events: none;
    transform: translate3d(0, 0, 0);
}

.fantasy-tree-v9-editor-empty {
    padding: 20px 10px;
    color: rgba(169, 210, 223, 0.68);
    font-size: 11px;
    text-align: center;
}

.fantasy-tree-v9-node-layer {
    position: absolute;
    z-index: 4;
    inset: 0;
    width: 2560px;
    height: 1440px;
    overflow: visible;
    pointer-events: none;
}

.fantasy-tree-v9-node {
    --v9-node-angle: 0deg;
    --v9-node-scale: 1;
    --v9-node-cyan: rgba(94, 246, 255, 0.92);
    --v9-node-violet: rgba(157, 124, 255, 0.58);
    --v9-node-magenta: rgba(255, 83, 199, 0.72);
    --v9-node-warm: rgba(255, 239, 184, 0.62);
    position: absolute;
    width: 48px;
    height: 48px;
    margin: 0;
    padding: 0;
    transform: translate(-50%, -50%);
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #dfffff;
    cursor: pointer;
    pointer-events: auto;
    isolation: isolate;
    -webkit-tap-highlight-color: transparent;
}

.fantasy-tree-v9-node-core {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 14px;
    height: 10px;
    transform: translate(-50%, -50%) rotate(var(--v9-node-angle)) scale(var(--v9-node-scale));
    border: 0;
    border-radius: 68% 32% 68% 32% / 56% 44% 56% 44%;
    background:
        radial-gradient(circle at 48% 50%, #fff 0 11%, #eaffff 18%, #9bfbff 35%, #37d8f3 55%, rgba(20, 123, 185, 0.38) 72%, transparent 76%);
    box-shadow:
        0 0 4px rgba(246, 255, 255, 0.98),
        0 0 10px rgba(94, 246, 255, 0.82),
        0 0 18px rgba(31, 150, 255, 0.30);
    transform-origin: 50% 50%;
    transition:
        transform 160ms cubic-bezier(0.22, 1, 0.36, 1),
        filter 160ms cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.fantasy-tree-v9-node-core::before,
.fantasy-tree-v9-node-core::after,
.fantasy-tree-v9-node-ring {
    position: absolute;
    pointer-events: none;
}

.fantasy-tree-v9-node-core::before {
    content: "";
    right: calc(100% - 2px);
    top: 50%;
    width: 10px;
    height: 1px;
    transform: translateY(-50%);
    border-radius: 999px;
    background: linear-gradient(90deg, transparent, rgba(94, 246, 255, 0.18) 20%, var(--v9-node-cyan));
    box-shadow: 0 0 5px rgba(94, 246, 255, 0.54);
}

.fantasy-tree-v9-node-core::after {
    content: "";
    left: 50%;
    top: 50%;
    width: 3px;
    height: 3px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: #fff;
    box-shadow:
        0 0 4px rgba(255, 255, 255, 0.98),
        0 0 8px rgba(255, 239, 184, 0.48);
}

.fantasy-tree-v9-node-ring.is-inner {
    inset: -4px -5px;
    border: 1px solid transparent;
    border-top-color: rgba(238, 255, 255, 0.80);
    border-right-color: rgba(94, 246, 255, 0.48);
    border-bottom-color: rgba(255, 239, 184, 0.26);
    border-radius: 64% 36% 64% 36% / 54% 46% 54% 46%;
    transform: rotate(-16deg);
    filter: drop-shadow(0 0 3px rgba(94, 246, 255, 0.46));
    transition:
        opacity 160ms cubic-bezier(0.22, 1, 0.36, 1),
        filter 160ms cubic-bezier(0.22, 1, 0.36, 1),
        transform 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.fantasy-tree-v9-node-ring.is-outer {
    inset: -8px -10px;
    border-radius: 50%;
    background: conic-gradient(
        from 18deg,
        transparent 0 16%,
        rgba(94, 246, 255, 0.54) 18% 25%,
        transparent 27% 48%,
        rgba(157, 124, 255, 0.40) 50% 57%,
        transparent 59% 78%,
        rgba(255, 239, 184, 0.34) 80% 86%,
        transparent 88% 100%
    );
    -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 1px), #000 calc(100% - 1px));
    mask: radial-gradient(farthest-side, transparent calc(100% - 1px), #000 calc(100% - 1px));
    opacity: 0.32;
    filter: drop-shadow(0 0 4px rgba(94, 246, 255, 0.26));
    transform: rotate(12deg);
    transition:
        opacity 160ms cubic-bezier(0.22, 1, 0.36, 1),
        filter 160ms cubic-bezier(0.22, 1, 0.36, 1),
        transform 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.fantasy-tree-v9-node.is-fork .fantasy-tree-v9-node-core,
.fantasy-tree-v9-node.is-leaf .fantasy-tree-v9-node-core {
    width: 16px;
    height: 11px;
}

.fantasy-tree-v9-node.is-fork .fantasy-tree-v9-node-ring.is-inner {
    inset: -5px -7px;
    transform: rotate(-22deg) scaleY(1.12);
}

.fantasy-tree-v9-node.is-fork .fantasy-tree-v9-node-ring.is-outer {
    opacity: 0.64;
}

.fantasy-tree-v9-node.is-leaf .fantasy-tree-v9-node-core::before {
    right: calc(100% - 3px);
    width: 15px;
    background: linear-gradient(90deg, transparent, rgba(94, 246, 255, 0.22) 24%, rgba(238, 255, 255, 0.92));
}

.fantasy-tree-v9-node.is-leaf .fantasy-tree-v9-node-ring.is-outer {
    opacity: 0.72;
    filter: drop-shadow(0 0 5px rgba(94, 246, 255, 0.40));
}

.fantasy-tree-v9-node.is-current .fantasy-tree-v9-node-core {
    --v9-node-scale: 1.08;
    width: 17px;
    height: 12px;
    box-shadow:
        0 0 6px #fff,
        0 0 15px rgba(94, 246, 255, 0.96),
        0 0 28px rgba(157, 124, 255, 0.48);
}

.fantasy-tree-v9-node.is-current .fantasy-tree-v9-node-ring.is-outer,
.fantasy-tree-v9-node.is-selected .fantasy-tree-v9-node-ring.is-outer {
    opacity: 0.96;
    background: conic-gradient(
        from 18deg,
        transparent 0 12%,
        rgba(94, 246, 255, 0.86) 14% 24%,
        transparent 26% 46%,
        rgba(255, 83, 199, 0.78) 48% 59%,
        transparent 61% 78%,
        rgba(157, 124, 255, 0.74) 80% 89%,
        transparent 91% 100%
    );
    filter: drop-shadow(0 0 5px rgba(255, 83, 199, 0.42));
}

.fantasy-tree-v9-node.is-selected .fantasy-tree-v9-node-core {
    --v9-node-scale: 1.12;
}

.fantasy-tree-v9-node:focus-visible {
    outline: none;
}

.fantasy-tree-v9-node:hover .fantasy-tree-v9-node-core,
.fantasy-tree-v9-node:focus-visible .fantasy-tree-v9-node-core {
    --v9-node-scale: 1.12;
    filter: brightness(1.12);
}

.fantasy-tree-v9-node:focus-visible .fantasy-tree-v9-node-ring.is-outer {
    opacity: 0.92;
    filter: drop-shadow(0 0 5px rgba(94, 246, 255, 0.62));
}

.fantasy-tree-v9-node.is-dimmed {
    opacity: 1;
}

.fantasy-tree-v9-node.is-life-highlighted .fantasy-tree-v9-node-core {
    --v9-node-scale: 1.14;
    filter: brightness(1.56) saturate(1.18);
    box-shadow:
        0 0 7px rgba(255, 255, 255, 1),
        0 0 18px rgba(94, 246, 255, 1),
        0 0 34px rgba(157, 124, 255, 0.62);
}

.fantasy-tree-v9-node.is-life-highlighted .fantasy-tree-v9-node-core::after {
    box-shadow:
        0 0 5px rgba(255, 255, 255, 1),
        0 0 12px rgba(214, 255, 255, 0.96),
        0 0 18px rgba(94, 246, 255, 0.74);
}

.fantasy-tree-v9-node.is-life-highlighted .fantasy-tree-v9-node-ring.is-inner {
    opacity: 1;
    filter:
        drop-shadow(0 0 5px rgba(94, 246, 255, 0.92))
        drop-shadow(0 0 10px rgba(157, 124, 255, 0.44));
}

.fantasy-tree-v9-node.is-life-highlighted .fantasy-tree-v9-node-ring.is-outer {
    opacity: 1;
    filter:
        drop-shadow(0 0 7px rgba(94, 246, 255, 0.86))
        drop-shadow(0 0 13px rgba(157, 124, 255, 0.54));
}

.fantasy-tree-v9-node.is-selected .fantasy-tree-v9-node-core {
    --v9-node-scale: 1.30;
    filter: brightness(1.92) saturate(1.24);
    background:
        radial-gradient(
            circle at 48% 50%,
            #fff 0 14%,
            #f9ffff 22%,
            #bffcff 38%,
            #ff9cdd 56%,
            rgba(157, 124, 255, 0.72) 72%,
            transparent 80%
        );
    box-shadow:
        0 0 10px rgba(255, 255, 255, 1),
        0 0 22px rgba(94, 246, 255, 1),
        0 0 38px rgba(255, 83, 199, 0.88),
        0 0 54px rgba(157, 124, 255, 0.58);
}

.fantasy-tree-v9-node.is-selected .fantasy-tree-v9-node-core::after {
    width: 4px;
    height: 4px;
    background: #fff;
    box-shadow:
        0 0 6px #fff,
        0 0 14px rgba(255, 255, 255, 1),
        0 0 24px rgba(255, 83, 199, 0.92);
}

.fantasy-tree-v9-node.is-selected .fantasy-tree-v9-node-ring.is-inner {
    opacity: 1;
    border-top-color: rgba(255, 255, 255, 1);
    border-right-color: rgba(94, 246, 255, 0.98);
    border-bottom-color: rgba(255, 83, 199, 0.92);
    filter:
        drop-shadow(0 0 6px rgba(94, 246, 255, 1))
        drop-shadow(0 0 12px rgba(255, 83, 199, 0.82));
}

.fantasy-tree-v9-node.is-selected .fantasy-tree-v9-node-ring.is-outer {
    opacity: 1;
    transform: rotate(12deg) scale(1.14);
    filter:
        drop-shadow(0 0 8px rgba(255, 83, 199, 1))
        drop-shadow(0 0 16px rgba(157, 124, 255, 0.86))
        drop-shadow(0 0 24px rgba(94, 246, 255, 0.68));
}

.fantasy-tree-v9-node.is-dragging {
    z-index: 5;
    cursor: grabbing;
}

.fantasy-tree-v9-node.is-dragging .fantasy-tree-v9-node-core {
    --v9-node-scale: 1.28;
    filter: brightness(1.16);
    box-shadow: 0 0 8px #fff, 0 0 20px rgba(94, 246, 255, 1), 0 0 34px rgba(255, 83, 199, 0.52);
}

.fantasy-tree-v9-node.is-pending .fantasy-tree-v9-node-ring.is-outer {
    opacity: 0.48;
    background: repeating-conic-gradient(
        from 12deg,
        rgba(94, 246, 255, 0.48) 0 8deg,
        transparent 8deg 24deg
    );
}

.fantasy-tree-v9-node.status-failed .fantasy-tree-v9-node-core,
.fantasy-tree-v9-node.status-error .fantasy-tree-v9-node-core {
    background: radial-gradient(circle at 48% 50%, #fff 0 10%, #ffd4ef 18%, #ff53c7 42%, rgba(157, 64, 216, 0.48) 68%, transparent 76%);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.92), 0 0 16px rgba(255, 83, 199, 0.90), 0 0 26px rgba(157, 124, 255, 0.38);
}

.fantasy-tree-v9-node.status-failed .fantasy-tree-v9-node-ring.is-outer,
.fantasy-tree-v9-node.status-error .fantasy-tree-v9-node-ring.is-outer {
    opacity: 0.82;
    background: conic-gradient(from 12deg, transparent 0 18%, rgba(255, 83, 199, 0.84) 20% 34%, transparent 36% 62%, rgba(157, 124, 255, 0.72) 64% 77%, transparent 79% 100%);
}

.fantasy-tree-v9-node.is-root .fantasy-tree-v9-node-core {
    background: radial-gradient(circle at 48% 50%, #fff 0 11%, #fff5cc 20%, #9bf9ff 40%, #36d8ee 58%, rgba(197, 165, 79, 0.30) 72%, transparent 76%);
    box-shadow: 0 0 5px #fff, 0 0 13px rgba(255, 239, 184, 0.74), 0 0 24px rgba(94, 246, 255, 0.44);
}

.fantasy-tree-v9-node.is-root .fantasy-tree-v9-node-ring.is-outer {
    opacity: 0.68;
    background: conic-gradient(from 18deg, transparent 0 14%, rgba(255, 239, 184, 0.68) 16% 26%, transparent 28% 51%, rgba(94, 246, 255, 0.56) 53% 65%, transparent 67% 84%, rgba(157, 124, 255, 0.42) 86% 92%, transparent 94% 100%);
}

.fantasy-tree-v9-node.is-compact {
    --v9-node-scale: 0.88;
}

.fantasy-tree-v9-node-context-menu {
    position: absolute;
    z-index: 35;
    min-width: 112px;
    padding: 4px;
    border: 1px solid rgba(94, 246, 255, 0.34);
    background: rgba(3, 12, 28, 0.97);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.54), 0 0 18px rgba(157, 124, 255, 0.18);
    pointer-events: auto;
}

.fantasy-tree-v9-node-context-menu[hidden] {
    display: none;
}

.fantasy-tree-v9-node-context-menu button {
    display: flex;
    align-items: center;
    width: 100%;
    min-height: 30px;
    gap: 7px;
    padding: 0 9px;
    color: rgba(227, 253, 255, 0.9);
    border: 0;
    background: transparent;
    cursor: pointer;
    font-size: 10px;
    text-align: left;
}

.fantasy-tree-v9-node-context-menu button:hover,
.fantasy-tree-v9-node-context-menu button:focus-visible {
    color: #fff;
    background: linear-gradient(90deg, rgba(94, 246, 255, 0.14), rgba(255, 83, 199, 0.16));
    outline: none;
}

.fantasy-tree-v9-node-context-menu i {
    color: rgba(255, 83, 199, 0.82);
}

body.fantasy-tree-v9-active .fantasy-tree-stage-image-preview,
body.fantasy-tree-v9-active .fantasy-tree-v9-stage-preview,
body.fantasy-tree-v9-active #fantasy-tree-stage-image-preview {
    --v9-preview-cyan: #37e8ff;
    --v9-preview-magenta: #ff45d6;
    --v9-preview-violet: #a767ff;
    box-sizing: border-box;
    z-index: 44;
    width: min(380px, calc(100% - 24px));
    max-height: calc(100% - 24px);
    padding: 24px !important;
    overflow: visible !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    background-color: transparent !important;
    box-shadow: none !important;
    outline: none !important;
    contain: layout style;
    will-change: transform, opacity;
    transform: translate3d(0, 0, 0);
    filter: none !important;
    transition:
        opacity 180ms cubic-bezier(0.4, 0, 1, 1),
        transform 180ms cubic-bezier(0.4, 0, 1, 1),
        filter 180ms cubic-bezier(0.4, 0, 1, 1),
        visibility 0s linear 180ms;
}

body.fantasy-tree-v9-active .fantasy-tree-stage-image-preview.visible,
body.fantasy-tree-v9-active .fantasy-tree-v9-stage-preview.visible,
body.fantasy-tree-v9-active #fantasy-tree-stage-image-preview.visible,
body.fantasy-tree-v9-active .fantasy-tree-stage-image-preview.pinned,
body.fantasy-tree-v9-active .fantasy-tree-v9-stage-preview.pinned,
body.fantasy-tree-v9-active #fantasy-tree-stage-image-preview.pinned {
    background: transparent !important;
    background-color: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
    outline: none !important;
    border-radius: 0 !important;
    contain: layout style;
    will-change: transform, opacity;
    transform: translate3d(0, 0, 0);
    filter: none !important;
    transition:
        opacity 230ms cubic-bezier(0.16, 1, 0.3, 1),
        transform 240ms cubic-bezier(0.16, 1, 0.3, 1),
        visibility 0s linear 0s;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview-content {
    position: relative;
    z-index: 2;
    box-sizing: border-box;
    display: grid;
    width: 100%;
    max-height: min(580px, calc(100dvh - 96px));
    min-height: 0;
    overflow: hidden auto;
    scrollbar-gutter: stable;
    clip-path: polygon(
        0 15px,
        15px 0,
        calc(100% - 38px) 0,
        100% 38px,
        100% calc(100% - 17px),
        calc(100% - 17px) 100%,
        31px 100%,
        0 calc(100% - 31px)
    );
    padding: 16px 18px 18px;
    border: 0;
    background:
        linear-gradient(rgba(0, 231, 255, 0.034) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 231, 255, 0.034) 1px, transparent 1px),
        radial-gradient(circle at 7% 8%, rgba(0, 231, 255, 0.16), transparent 34%),
        radial-gradient(circle at 94% 86%, rgba(250, 54, 216, 0.14), transparent 38%),
        linear-gradient(
            135deg,
            rgba(5, 24, 42, 0.90),
            rgba(2, 10, 20, 0.93) 48%,
            rgba(12, 7, 26, 0.91)
        );
    background-size: 20px 20px, 20px 20px, auto, auto, auto;
    box-shadow:
        inset 0 0 0 1px rgba(127, 244, 255, 0.38),
        inset -1px 0 0 rgba(250, 54, 216, 0.28),
        inset 0 0 36px rgba(0, 231, 255, 0.06),
        inset 0 -22px 42px rgba(40, 10, 77, 0.12),
        0 0 0 1px rgba(1, 8, 18, 0.84);
    contain: content;
    transform: translate3d(0, 0, 0);
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview-crystal {
    position: absolute;
    z-index: 1;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
    filter: drop-shadow(0 0 8px rgba(61, 217, 235, 0.45))
            drop-shadow(0 18px 36px rgba(0, 0, 0, 0.72));
    transform: translateZ(0);
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview-crystal-outline {
    opacity: 0.88;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview-crystal-inner {
    opacity: 0.66;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview-crystal-facets polygon {
    stroke-width: 0.88;
    opacity: 0.82;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview-crystal-rim polygon {
    stroke-width: 0.84;
    opacity: 0.8;
    filter:
        drop-shadow(0 0 2px rgba(241, 255, 255, 0.68))
        drop-shadow(0 0 6px rgba(66, 216, 234, 0.28));
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview-crystal-rim polygon:nth-child(3n),
body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview-crystal-shards polygon:nth-child(2n) {
    filter:
        drop-shadow(0 0 2px rgba(244, 240, 255, 0.68))
        drop-shadow(0 0 7px rgba(143, 103, 198, 0.24));
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview-crystal-rim-cuts {
    opacity: 0.76;
    mix-blend-mode: screen;
    filter: drop-shadow(0 0 3px rgba(214, 249, 255, 0.42));
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview-crystal-shards polygon {
    stroke-width: 0.86;
    opacity: 0.78;
    filter:
        drop-shadow(0 0 2px rgba(238, 255, 255, 0.58))
        drop-shadow(0 0 7px rgba(56, 209, 228, 0.24));
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview-crystal-planes {
    mix-blend-mode: screen;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview-crystal-rays {
    opacity: 0.76;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview-crystal-powerline {
    stroke-dasharray: 1;
    stroke-dashoffset: 1;
    opacity: 0;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview.visible
    .fantasy-tree-v9-stage-preview-crystal-powerline {
    animation: fantasyFxV9StagePreviewCrystalEnergize 520ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes fantasyFxV9StagePreviewCrystalEnergize {
    0% { stroke-dashoffset: 1; opacity: 0; }
    16% { opacity: 0.92; }
    72% { opacity: 0.66; }
    100% { stroke-dashoffset: 0; opacity: 0; }
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview-crystal-beam,
body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview-crystal-beam-secondary {
    pointer-events: none;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
    mix-blend-mode: screen;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview-crystal-beam-base {
    stroke: rgba(55, 232, 255, 0.5);
    stroke-width: 0.92;
    opacity: 0.4;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview-crystal-beam-trail,
body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview-crystal-beam-core,
body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview-crystal-beam-head,
body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview-crystal-beam-trail-secondary,
body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview-crystal-beam-core-secondary,
body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview-crystal-beam-head-secondary {
    animation-play-state: paused;
    will-change: auto;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview.visible
    .fantasy-tree-v9-stage-preview-crystal-beam-trail {
    stroke: url(#fantasyTreeV9StagePreviewCrystalBeamGradient);
    stroke-width: 4.6;
    stroke-dasharray: 46 54;
    opacity: 0.64;
    filter:
        blur(1.8px)
        drop-shadow(0 0 7px rgba(55, 232, 255, 0.7))
        drop-shadow(0 0 12px rgba(167, 103, 255, 0.38));
    animation: fantasyBorderBeamTrace 4.8s linear -0.9s infinite;
    will-change: stroke-dashoffset;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview.visible
    .fantasy-tree-v9-stage-preview-crystal-beam-core {
    stroke: url(#fantasyTreeV9StagePreviewCrystalBeamGradient);
    stroke-width: 1.85;
    stroke-dasharray: 46 54;
    opacity: 0.98;
    filter:
        drop-shadow(0 0 3px rgba(55, 232, 255, 0.9))
        drop-shadow(0 0 7px rgba(255, 69, 214, 0.36));
    animation: fantasyBorderBeamTrace 4.8s linear -0.9s infinite;
    will-change: stroke-dashoffset;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview.visible
    .fantasy-tree-v9-stage-preview-crystal-beam-head {
    stroke: #f8ffff;
    stroke-width: 3;
    stroke-dasharray: 1.25 98.75;
    opacity: 1;
    filter:
        drop-shadow(0 0 3px rgba(255, 255, 255, 0.98))
        drop-shadow(0 0 7px rgba(255, 69, 214, 0.74))
        drop-shadow(0 0 11px rgba(55, 232, 255, 0.58));
    animation: fantasyBorderBeamTrace 4.8s linear -0.9s infinite;
    will-change: stroke-dashoffset;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview.visible
    .fantasy-tree-v9-stage-preview-crystal-beam-trail-secondary {
    stroke: url(#fantasyTreeV9StagePreviewCrystalBeamGradient);
    stroke-width: 4.2;
    stroke-dasharray: 46 54;
    opacity: 0.58;
    filter:
        blur(1.8px)
        drop-shadow(0 0 6px rgba(55, 232, 255, 0.58))
        drop-shadow(0 0 10px rgba(255, 69, 214, 0.3));
    animation: fantasyBorderBeamTrace 4.8s linear -3.3s infinite;
    will-change: stroke-dashoffset;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview.visible
    .fantasy-tree-v9-stage-preview-crystal-beam-core-secondary {
    stroke: url(#fantasyTreeV9StagePreviewCrystalBeamGradient);
    stroke-width: 1.7;
    stroke-dasharray: 46 54;
    opacity: 0.84;
    filter:
        drop-shadow(0 0 3px rgba(55, 232, 255, 0.78))
        drop-shadow(0 0 6px rgba(255, 69, 214, 0.3));
    animation: fantasyBorderBeamTrace 4.8s linear -3.3s infinite;
    will-change: stroke-dashoffset;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview.visible
    .fantasy-tree-v9-stage-preview-crystal-beam-head-secondary {
    stroke: #f8ffff;
    stroke-width: 2.4;
    stroke-dasharray: 1.4 98.6;
    opacity: 0.86;
    filter:
        drop-shadow(0 0 3px rgba(255, 255, 255, 0.9))
        drop-shadow(0 0 6px rgba(255, 69, 214, 0.62))
        drop-shadow(0 0 9px rgba(55, 232, 255, 0.5));
    animation: fantasyBorderBeamTrace 4.8s linear -3.3s infinite;
    will-change: stroke-dashoffset;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-stage-preview.pinned
    .fantasy-tree-v9-stage-preview-crystal {
    filter:
        drop-shadow(0 0 8px rgba(61, 217, 235, 0.52))
        drop-shadow(0 0 18px rgba(114, 88, 184, 0.26))
        drop-shadow(0 0 32px rgba(255, 69, 214, 0.16));
}

/* Stop the decorative beam layers whenever the life simulator is not foregrounded. */
#fantasy-workbench.fantasy-fx-page-hidden
    .fantasy-tree-v9-stage-preview-crystal-powerline,
#fantasy-workbench.fantasy-fx-page-hidden
    .fantasy-tree-v9-stage-preview
    :is(
        .fantasy-tree-v9-stage-preview-crystal-beam-trail,
        .fantasy-tree-v9-stage-preview-crystal-beam-core,
        .fantasy-tree-v9-stage-preview-crystal-beam-head,
        .fantasy-tree-v9-stage-preview-crystal-beam-trail-secondary,
        .fantasy-tree-v9-stage-preview-crystal-beam-core-secondary,
        .fantasy-tree-v9-stage-preview-crystal-beam-head-secondary
    ) {
    animation-play-state: paused !important;
    will-change: auto !important;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-video::-webkit-media-controls {
    display: none !important;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-root
    :is(
        .fantasy-tree-v4-toolbar,
        .fantasy-tree-v4-version,
        .fantasy-tree-v4-more,
        .fantasy-tree-v4-timeline,
        .fantasy-tree-v4-preview,
        .fantasy-tree-v4-jobs,
    .fantasy-story-drawer
    ) {
    z-index: 30;
}

body.fantasy-tree-v9-active
    .fantasy-tree-v9-editor-panel {
    z-index: 28;
}

@media (max-width: 860px), (hover: none), (pointer: coarse) {
    .fantasy-tree-visual-version[data-tree-visual-version-switcher="v4"],
.fantasy-tree-visual-version[data-tree-visual-version-switcher="v7"] {
        grid-template-columns: repeat(4, 32px);
        grid-template-rows: 32px;
    }

    body.fantasy-tree-v9-active
        .fantasy-tree-v9-root
        .fantasy-tree-v4-scene {
        min-height: min(58vw, 72vh);
    }

    body.fantasy-tree-v9-active
        .fantasy-tree-v9-editor-panel {
        top: 10px;
        left: 10px;
        width: min(286px, calc(100% - 20px));
        max-height: min(68vh, calc(100% - 20px));
    }

    body.fantasy-tree-v9-active .fantasy-tree-stage-image-preview,
    body.fantasy-tree-v9-active .fantasy-tree-v9-stage-preview,
    body.fantasy-tree-v9-active #fantasy-tree-stage-image-preview {
        z-index: 90;
        width: min(360px, calc(100vw - 24px));
        padding: 18px !important;
    }

    body.fantasy-tree-v9-active
        .fantasy-tree-v9-stage-preview-content {
        max-height: min(68dvh, calc(100dvh - 112px));
    }

    body.fantasy-tree-v9-active
        .fantasy-tree-v9-stage-preview.visible
        :is(
            .fantasy-tree-v9-stage-preview-crystal-beam-trail,
            .fantasy-tree-v9-stage-preview-crystal-beam-core,
            .fantasy-tree-v9-stage-preview-crystal-beam-head
        ) {
        animation-duration: 5.4s;
    }

    body.fantasy-tree-v9-active
        .fantasy-tree-v9-stage-preview.visible
        :is(
            .fantasy-tree-v9-stage-preview-crystal-beam-trail-secondary,
            .fantasy-tree-v9-stage-preview-crystal-beam-core-secondary,
            .fantasy-tree-v9-stage-preview-crystal-beam-head-secondary
        ) {
        animation: fantasyBorderBeamTrace 5.4s linear -3.6s infinite;
    }

    body.fantasy-tree-v9-active
        .fantasy-tree-v9-stage-preview.visible
        .fantasy-tree-v9-stage-preview-crystal-beam-trail {
        stroke-width: 3.8;
        opacity: 0.48;
        filter:
            blur(1.2px)
            drop-shadow(0 0 5px rgba(55, 232, 255, 0.48));
    }

    body.fantasy-tree-v9-active
        .fantasy-tree-v9-stage-preview.visible
        .fantasy-tree-v9-stage-preview-crystal-beam-trail-secondary {
        stroke-width: 3.4;
        opacity: 0.36;
        filter:
            blur(1.1px)
            drop-shadow(0 0 5px rgba(55, 232, 255, 0.4));
    }
}

@media (prefers-reduced-motion: reduce) {
    body.fantasy-tree-v9-active
        .fantasy-tree-v9-video {
        animation: none;
    }

    .fantasy-tree-v9-node-core,
    .fantasy-tree-v9-node-core::before,
    .fantasy-tree-v9-node-core::after,
    .fantasy-tree-v9-node-ring {
        animation: none;
        transition: none;
    }

    body.fantasy-tree-v9-active
        .fantasy-tree-v9-stage-preview-crystal-powerline {
        animation: none !important;
        opacity: 0;
        stroke-dashoffset: 0;
    }

    body.fantasy-tree-v9-active
        .fantasy-tree-v9-stage-preview
        :is(
            .fantasy-tree-v9-stage-preview-crystal-beam-trail,
            .fantasy-tree-v9-stage-preview-crystal-beam-core,
            .fantasy-tree-v9-stage-preview-crystal-beam-head,
            .fantasy-tree-v9-stage-preview-crystal-beam-trail-secondary,
            .fantasy-tree-v9-stage-preview-crystal-beam-core-secondary,
            .fantasy-tree-v9-stage-preview-crystal-beam-head-secondary
        ) {
        animation: none !important;
        opacity: 0 !important;
        filter: none !important;
        will-change: auto !important;
    }

    body.fantasy-tree-v9-active
        .fantasy-tree-v9-stage-preview-crystal-beam-base {
        opacity: 0.3;
    }
}

body.fantasy-tree-v9-active .fantasy-tree-stage-image {
    background:
        linear-gradient(rgba(0, 231, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 231, 255, 0.04) 1px, transparent 1px),
        rgba(2, 14, 28, 0.58) !important;
    background-size: 14px 14px, 14px 14px, auto !important;
    border: 1px solid rgba(0, 231, 255, 0.28) !important;
    box-shadow: inset 0 0 16px rgba(0, 231, 255, 0.08) !important;
}

body.fantasy-tree-v9-active .fantasy-tree-stage-summary-skeleton i {
    background: linear-gradient(90deg, rgba(0, 231, 255, 0.06) 25%, rgba(0, 231, 255, 0.2) 50%, rgba(0, 231, 255, 0.06) 75%) !important;
}
