/* V5 keeps the V4 controls above one native 2560x1440 video artboard. */
.fantasy-tree-visual-version[data-tree-visual-version-switcher="v5"] {
    grid-template-columns: repeat(4, 38px);
    grid-template-rows: 36px;
    grid-auto-flow: column;
}

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

body.fantasy-tree-v5-active
    .fantasy-tree-v5-root
    .fantasy-tree-v4-scene::before,
body.fantasy-tree-v5-active
    .fantasy-tree-v5-root
    .fantasy-tree-v4-scene.has-fantasy-tree-v5-artboard::before {
    content: none !important;
    display: none !important;
    background: none !important;
    background-image: none !important;
}

body.fantasy-tree-v5-active
    .fantasy-tree-v5-root
    .fantasy-tree-v4-backdrop,
body.fantasy-tree-v5-active
    .fantasy-tree-v5-root
    .fantasy-tree-v4-viewport,
body.fantasy-tree-v5-active
    .fantasy-tree-v5-root
    .fantasy-tree-v4-hud-layer {
    opacity: 0;
    pointer-events: none;
    visibility: hidden;
}

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

body.fantasy-tree-v5-active
    .fantasy-tree-v5-root
    .fantasy-tree-v4-preview {
    visibility: hidden;
    pointer-events: none;
}

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

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

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

.fantasy-tree-v5-base,
.fantasy-tree-v5-video,
.fantasy-tree-v5-alpha-static,
.fantasy-tree-v5-flow-canvas {
    position: absolute;
    inset: 0;
    width: 2560px;
    height: 1440px;
    pointer-events: none;
}

.fantasy-tree-v5-base {
    z-index: 1;
    display: block;
    max-width: none;
    object-fit: fill;
    user-select: none;
}

.fantasy-tree-v5-video {
    z-index: 1;
    display: block;
    max-width: none;
    object-fit: cover;
    object-position: center;
    background: #01030d;
    user-select: none;
}

.fantasy-tree-v5-alpha-static {
    z-index: 2;
    display: none !important;
    max-width: none;
    object-fit: fill;
    opacity: 0;
    mix-blend-mode: screen;
    user-select: none;
}

.fantasy-tree-v5-flow-canvas {
    z-index: 3;
    display: none !important;
    max-width: none;
    opacity: 0.96;
    mix-blend-mode: screen;
    image-rendering: auto;
}

/* V5 now renders the supplied video alone. Keep old alpha/flow layers in
   the DOM only for compatibility, but never let them bleed into the video. */
.fantasy-tree-v5-artboard[data-v5-legacy-effects="hidden"]
    .fantasy-tree-v5-alpha-static,
.fantasy-tree-v5-artboard[data-v5-legacy-effects="hidden"]
    .fantasy-tree-v5-flow-canvas {
    display: none !important;
    opacity: 0 !important;
    filter: none !important;
}

.fantasy-tree-v5-flow-canvas-2d {
    z-index: 4;
    opacity: 0;
}

.fantasy-tree-v5-artboard[data-v5-flow-fallback="canvas2d-loading"]
    .fantasy-tree-v5-alpha-static {
    opacity: 0.14;
}

.fantasy-tree-v5-artboard[data-v5-flow-fallback="canvas2d-loading"]
    .fantasy-tree-v5-flow-canvas,
.fantasy-tree-v5-artboard[data-v5-flow-fallback="canvas2d"]
    [data-fantasy-tree-v5-flow-canvas] {
    opacity: 0;
}

.fantasy-tree-v5-artboard[data-v5-flow-fallback="canvas2d"]
    [data-fantasy-tree-v5-flow-canvas-2d] {
    opacity: 0.82;
    filter:
        drop-shadow(0 0 4px rgba(184, 255, 255, 0.74))
        drop-shadow(0 0 9px rgba(0, 214, 255, 0.44));
}

/* The alpha texture is the calibrated shape; the old hand-drawn SVG is kept
   in JS only for compatibility with older diagnostics and is not rendered. */
.fantasy-tree-v5-energy {
    display: none !important;
}

.fantasy-tree-v5-artboard[data-v5-flow-fallback="static"] .fantasy-tree-v5-alpha-static,
.fantasy-tree-v5-artboard[data-v5-reduced-motion="true"] .fantasy-tree-v5-alpha-static {
    opacity: 0.18;
}

.fantasy-tree-v5-artboard[data-v5-flow-fallback="static"] .fantasy-tree-v5-flow-canvas,
.fantasy-tree-v5-artboard[data-v5-reduced-motion="true"] .fantasy-tree-v5-flow-canvas {
    opacity: 0;
}

.fantasy-tree-v5-energy-group {
    --v5-energy-core: rgba(242, 255, 255, 1);
    --v5-energy-tail: rgba(126, 249, 255, 0.98);
    --v5-energy-glow: rgba(0, 236, 255, 0.84);
    --v5-energy-rest: rgba(112, 230, 255, 0.62);
    --v5-rest-width: 1.35;
    --v5-bloom-width: 10;
    --v5-tail-width: 4.2;
    --v5-head-width: 2.6;
}

.fantasy-tree-v5-energy-group.is-violet {
    --v5-energy-core: rgba(238, 252, 255, 1);
    --v5-energy-tail: rgba(174, 165, 255, 0.96);
    --v5-energy-glow: rgba(126, 98, 255, 0.80);
    --v5-energy-rest: rgba(145, 128, 255, 0.56);
}

.fantasy-tree-v5-energy-group[data-v5-energy-tier="0"] {
    --v5-rest-width: 2;
    --v5-bloom-width: 17;
    --v5-tail-width: 7.2;
    --v5-head-width: 3.8;
}

.fantasy-tree-v5-energy-group[data-v5-energy-tier="1"] {
    --v5-rest-width: 2.3;
    --v5-bloom-width: 20;
    --v5-tail-width: 8.2;
    --v5-head-width: 4.2;
}

.fantasy-tree-v5-energy-group[data-v5-energy-tier="2"] {
    --v5-rest-width: 1.6;
    --v5-bloom-width: 14;
    --v5-tail-width: 5.8;
    --v5-head-width: 3;
}

.fantasy-tree-v5-energy-group[data-v5-energy-tier="3"] {
    --v5-rest-width: 1;
    --v5-bloom-width: 8.5;
    --v5-tail-width: 3.6;
    --v5-head-width: 2;
}

.fantasy-tree-v5-energy-line {
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.fantasy-tree-v5-energy-line.is-rest {
    stroke: var(--v5-energy-rest);
    stroke-width: var(--v5-rest-width);
    opacity: 0.075;
}

.fantasy-tree-v5-energy-line.is-bloom,
.fantasy-tree-v5-energy-line.is-tail,
.fantasy-tree-v5-energy-line.is-head {
    opacity: 0;
    will-change: opacity, stroke-dashoffset;
}

.fantasy-tree-v5-energy-line.is-bloom {
    stroke: var(--v5-energy-glow);
    stroke-width: var(--v5-bloom-width);
    stroke-dasharray: 26 100;
    stroke-dashoffset: 30;
    filter: url("#fantasy-tree-v5-bloom-filter");
}

.fantasy-tree-v5-energy-line.is-tail {
    stroke: var(--v5-energy-tail);
    stroke-width: var(--v5-tail-width);
    stroke-dasharray: 18 100;
    stroke-dashoffset: 22;
    filter: url("#fantasy-tree-v5-head-filter");
}

.fantasy-tree-v5-energy-line.is-head {
    stroke: var(--v5-energy-core);
    stroke-width: var(--v5-head-width);
    stroke-dasharray: 6 100;
    stroke-dashoffset: 5;
    filter: url("#fantasy-tree-v5-head-filter");
}

.fantasy-tree-v5-junction,
.fantasy-tree-v5-tip {
    transform-box: fill-box;
    transform-origin: center;
    pointer-events: none;
    opacity: 0;
    will-change: opacity, transform;
}

.fantasy-tree-v5-junction {
    fill: rgba(226, 255, 255, 0.92);
    filter:
        drop-shadow(0 0 4px rgba(216, 255, 255, 0.9))
        drop-shadow(0 0 10px rgba(0, 234, 255, 0.7));
}

.fantasy-tree-v5-tip {
    fill: rgba(216, 255, 255, 0.94);
    filter: drop-shadow(0 0 5px rgba(0, 234, 255, 0.78));
}

.fantasy-tree-v5-tip.is-violet {
    fill: rgba(220, 246, 255, 0.96);
    filter:
        drop-shadow(0 0 5px rgba(121, 94, 255, 0.85))
        drop-shadow(0 0 9px rgba(255, 47, 166, 0.42));
}

@media (max-width: 860px), (hover: none), (pointer: coarse) {
    .fantasy-tree-v5-flow-canvas {
        opacity: 0.78;
    }

    .fantasy-tree-v5-artboard[data-v5-flow-fallback="canvas2d"]
        [data-fantasy-tree-v5-flow-canvas-2d] {
        opacity: 0.68;
        filter: drop-shadow(0 0 4px rgba(0, 214, 255, 0.38));
    }

    .fantasy-tree-v5-artboard[data-v5-flow-fallback="static"] .fantasy-tree-v5-alpha-static,
    .fantasy-tree-v5-artboard[data-v5-reduced-motion="true"] .fantasy-tree-v5-alpha-static {
        opacity: 0.13;
    }

    .fantasy-tree-v5-energy-group[data-v5-energy-tier="0"] {
        --v5-bloom-width: 9;
        --v5-tail-width: 4.2;
    }

    .fantasy-tree-v5-energy-group[data-v5-energy-tier="1"] {
        --v5-bloom-width: 11;
        --v5-tail-width: 4.8;
    }

    .fantasy-tree-v5-energy-group[data-v5-energy-tier="2"] {
        --v5-bloom-width: 7.5;
        --v5-tail-width: 3.4;
    }

    .fantasy-tree-v5-energy-group[data-v5-energy-tier="3"] {
        --v5-bloom-width: 5;
        --v5-tail-width: 2.3;
    }

    .fantasy-tree-v5-energy-line.is-bloom {
        filter: none;
    }

    .fantasy-tree-v5-energy-line.is-tail {
        filter: none;
    }

    .fantasy-tree-v5-junction,
    .fantasy-tree-v5-tip {
        filter: drop-shadow(0 0 4px rgba(0, 234, 255, 0.66));
    }
}

@media (prefers-reduced-motion: reduce) {
    .fantasy-tree-v5-flow-canvas {
        opacity: 0;
    }

    .fantasy-tree-v5-alpha-static {
        opacity: 0.12;
    }
}
/* V5 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-v5-active
    .fantasy-tree-v5-stage {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

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

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

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

body.fantasy-tree-v5-active
    .fantasy-tree-v5-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-v5-active
    .fantasy-tree-v5-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 V5 owns the stage. */
body.fantasy-tree-v5-active
    .fantasy-tree-v5-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-v5-active
    .fantasy-tree-v5-artboard {
    position: absolute;
    z-index: 1;
    inset: 0;
    overflow: hidden;
    contain: layout paint;
    pointer-events: none;
    background: #000;
}

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

body.fantasy-tree-v5-active
    .fantasy-tree-v5-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-v5-active
    .fantasy-tree-v5-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;
    user-select: none;
    pointer-events: none;
}

body.fantasy-tree-v5-active
    .fantasy-tree-v5-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-v5-active
    .fantasy-tree-v5-artboard.is-panel-collapsed
    .fantasy-tree-v5-editor-panel {
    width: 34px;
    min-width: 34px;
    max-width: 34px;
    height: 42px;
    max-height: 42px;
    overflow: hidden;
    transform: none;
}

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

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

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

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

.fantasy-tree-v5-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-v5-editor-header > div {
    display: grid;
    gap: 4px;
}

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

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

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

.fantasy-tree-v5-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-v5-editor-collapse:hover,
.fantasy-tree-v5-editor-collapse:focus-visible {
    color: #e9ffff;
    background: rgba(94, 246, 255, 0.16);
    outline: none;
}

.fantasy-tree-v5-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-v5-editor-meta span:last-child {
    color: rgba(94, 246, 255, 0.88);
}

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

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

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

.fantasy-tree-v5-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-v5-editor-actions button:hover,
.fantasy-tree-v5-editor-actions button:focus-visible,
.fantasy-tree-v5-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-v5-editor-actions button:disabled {
    opacity: 0.44;
    cursor: default;
}

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

.fantasy-tree-v5-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-v5-editor-life {
    margin: 0 0 5px;
    border: 1px solid rgba(94, 246, 255, 0.11);
    background: rgba(4, 15, 31, 0.58);
}

.fantasy-tree-v5-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-v5-editor-life.is-current {
    border-right-color: rgba(255, 83, 199, 0.62);
}

.fantasy-tree-v5-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-v5-editor-life-header:hover,
.fantasy-tree-v5-editor-life-header:focus-visible {
    background: rgba(94, 246, 255, 0.08);
    outline: none;
}

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

.fantasy-tree-v5-editor-life-heading {
    display: flex;
    align-items: baseline;
    min-width: 0;
    gap: 7px;
}

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

.fantasy-tree-v5-editor-life-title {
    min-width: 0;
    overflow: hidden;
    color: rgba(132, 229, 242, 0.82);
    font-size: 10px;
    font-weight: 520;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

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

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

.fantasy-tree-v5-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-v5-editor-node:hover,
.fantasy-tree-v5-editor-node:focus-visible,
.fantasy-tree-v5-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-v5-editor-node i {
    color: rgba(94, 246, 255, 0.58);
    font-size: 9px;
}

.fantasy-tree-v5-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-v5-artboard:not(.is-editing) .fantasy-tree-v5-editor-node.is-material,
.fantasy-tree-v5-artboard.is-readonly .fantasy-tree-v5-editor-node.is-material {
    cursor: pointer;
    touch-action: auto;
}

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

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

.fantasy-tree-v5-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-v5-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-v5-editor-root-label {
    color: rgba(255, 83, 199, 0.72);
    font-size: 9px;
}

.fantasy-tree-v5-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-v5-editor-root-status small,
.fantasy-tree-v5-editor-life-complete {
    color: rgba(94, 246, 255, 0.62);
    font-size: 9px;
}

.fantasy-tree-v5-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-v5-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-v5-editor-empty {
    padding: 20px 10px;
    color: rgba(169, 210, 223, 0.68);
    font-size: 11px;
    text-align: center;
}

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

.fantasy-tree-v5-node {
    --v5-node-angle: 0deg;
    --v5-node-scale: 1;
    --v5-node-cyan: rgba(94, 246, 255, 0.92);
    --v5-node-violet: rgba(157, 124, 255, 0.58);
    --v5-node-magenta: rgba(255, 83, 199, 0.72);
    --v5-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-v5-node-core {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 14px;
    height: 10px;
    transform: translate(-50%, -50%) rotate(var(--v5-node-angle)) scale(var(--v5-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-v5-node-core::before,
.fantasy-tree-v5-node-core::after,
.fantasy-tree-v5-node-ring {
    position: absolute;
    pointer-events: none;
}

.fantasy-tree-v5-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(--v5-node-cyan));
    box-shadow: 0 0 5px rgba(94, 246, 255, 0.54);
}

.fantasy-tree-v5-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-v5-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-v5-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-v5-node.is-fork .fantasy-tree-v5-node-core,
.fantasy-tree-v5-node.is-leaf .fantasy-tree-v5-node-core {
    width: 16px;
    height: 11px;
}

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

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

.fantasy-tree-v5-node.is-leaf .fantasy-tree-v5-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-v5-node.is-leaf .fantasy-tree-v5-node-ring.is-outer {
    opacity: 0.72;
    filter: drop-shadow(0 0 5px rgba(94, 246, 255, 0.40));
}

.fantasy-tree-v5-node.is-current .fantasy-tree-v5-node-core {
    --v5-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-v5-node.is-current .fantasy-tree-v5-node-ring.is-outer,
.fantasy-tree-v5-node.is-selected .fantasy-tree-v5-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-v5-node.is-selected .fantasy-tree-v5-node-core {
    --v5-node-scale: 1.12;
}

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

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

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

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

.fantasy-tree-v5-node.is-life-highlighted .fantasy-tree-v5-node-core {
    --v5-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-v5-node.is-life-highlighted .fantasy-tree-v5-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-v5-node.is-life-highlighted .fantasy-tree-v5-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-v5-node.is-life-highlighted .fantasy-tree-v5-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-v5-node.is-selected .fantasy-tree-v5-node-core {
    --v5-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-v5-node.is-selected .fantasy-tree-v5-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-v5-node.is-selected .fantasy-tree-v5-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-v5-node.is-selected .fantasy-tree-v5-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-v5-node.is-dragging {
    z-index: 5;
    cursor: grabbing;
}

.fantasy-tree-v5-node.is-dragging .fantasy-tree-v5-node-core {
    --v5-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-v5-node.is-pending .fantasy-tree-v5-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-v5-node.status-failed .fantasy-tree-v5-node-core,
.fantasy-tree-v5-node.status-error .fantasy-tree-v5-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-v5-node.status-failed .fantasy-tree-v5-node-ring.is-outer,
.fantasy-tree-v5-node.status-error .fantasy-tree-v5-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-v5-node.is-root .fantasy-tree-v5-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-v5-node.is-root .fantasy-tree-v5-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-v5-node.is-compact {
    --v5-node-scale: 0.88;
}

/* V5 uses a compact stardust orb grown into the bright celestial branches.
   This is intentionally V5-only; V9 keeps its own node language. */
.fantasy-tree-v5-node {
    --v5-star-branch: rgba(93, 211, 242, 0.62);
    --v5-star-frost: rgba(208, 245, 255, 0.86);
    --v5-star-lilac: rgba(151, 126, 239, 0.60);
    --v5-star-gold: rgba(244, 195, 104, 0.68);
    --v5-star-rose: rgba(236, 104, 195, 0.72);
}

.fantasy-tree-v5-node-core {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    clip-path: none;
    background:
        radial-gradient(circle at 50% 50%, rgba(239, 253, 255, 0.94) 0 8%, rgba(158, 226, 255, 0.94) 18%, rgba(88, 120, 225, 0.88) 39%, rgba(42, 43, 133, 0.78) 59%, rgba(19, 26, 82, 0.34) 74%, transparent 84%),
        radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.54) 0 4%, transparent 17%),
        radial-gradient(circle at 70% 72%, rgba(236, 158, 255, 0.38) 0 5%, transparent 26%);
    box-shadow:
        inset 0 0 0 1px rgba(173, 235, 255, 0.62),
        0 0 0 1px rgba(29, 38, 107, 0.46),
        0 0 9px rgba(76, 194, 244, 0.58),
        0 0 18px rgba(113, 93, 223, 0.30);
}

.fantasy-tree-v5-node-core::before {
    right: calc(100% - 2px);
    width: 15px;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(58, 169, 224, 0.16) 25%, var(--v5-star-branch) 76%, rgba(196, 241, 252, 0.58));
    box-shadow: 0 0 4px rgba(57, 178, 229, 0.32);
}

.fantasy-tree-v5-node-core::after {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: radial-gradient(circle, #fff 0 24%, rgba(220, 249, 255, 0.96) 46%, rgba(123, 216, 246, 0.66) 72%, transparent 76%);
    box-shadow:
        0 0 4px rgba(255, 255, 255, 0.92),
        0 0 9px rgba(157, 232, 255, 0.72);
}

.fantasy-tree-v5-node-ring.is-inner {
    inset: auto;
    inset: -5px;
    width: auto;
    height: auto;
    border: 1px solid rgba(166, 226, 255, 0.26);
    border-radius: 50%;
    background: radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.20) 0 5%, transparent 18%);
    opacity: 0.66;
    filter: drop-shadow(0 0 5px rgba(100, 205, 248, 0.36));
    transform: rotate(-14deg);
}

.fantasy-tree-v5-node-ring.is-inner::before,
.fantasy-tree-v5-node-ring.is-inner::after {
    content: "";
    display: block;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    clip-path: none;
    background: var(--v5-star-gold);
    box-shadow: 0 0 4px rgba(244, 195, 104, 0.64);
}

.fantasy-tree-v5-node-ring.is-inner::before {
    left: auto;
    right: -4px;
    top: 1px;
    transform: scale(0.72);
}

.fantasy-tree-v5-node-ring.is-inner::after {
    left: -4px;
    top: 10px;
    transform: scale(0.56);
}

.fantasy-tree-v5-node-ring.is-outer {
    inset: -9px;
    border-radius: 50%;
    -webkit-mask: none;
    mask: none;
    background:
        radial-gradient(circle at 17% 23%, var(--v5-star-gold) 0 2px, transparent 3px),
        radial-gradient(circle at 84% 16%, rgba(248, 209, 122, 0.66) 0 1.5px, transparent 2.5px),
        radial-gradient(circle at 92% 73%, rgba(157, 222, 250, 0.62) 0 1.5px, transparent 2.5px),
        radial-gradient(circle at 13% 78%, rgba(168, 141, 242, 0.58) 0 1px, transparent 2px);
    opacity: 0.52;
    filter: drop-shadow(0 0 4px rgba(62, 174, 225, 0.26));
    transform: rotate(6deg);
}

.fantasy-tree-v5-node.is-fork .fantasy-tree-v5-node-core,
.fantasy-tree-v5-node.is-leaf .fantasy-tree-v5-node-core {
    width: 19px;
    height: 13px;
}

.fantasy-tree-v5-node.is-fork .fantasy-tree-v5-node-ring.is-inner {
    inset: -6px;
    transform: rotate(-28deg) scale(1.12);
}

.fantasy-tree-v5-node.is-fork .fantasy-tree-v5-node-ring.is-outer {
    opacity: 0.84;
}

.fantasy-tree-v5-node.is-leaf .fantasy-tree-v5-node-core::before {
    width: 19px;
    background: linear-gradient(90deg, transparent, rgba(74, 173, 223, 0.20) 22%, rgba(148, 226, 247, 0.72));
}

.fantasy-tree-v5-node.is-leaf .fantasy-tree-v5-node-ring.is-outer {
    opacity: 1;
    filter:
        drop-shadow(0 0 5px rgba(118, 231, 255, 0.72))
        drop-shadow(0 0 10px rgba(175, 151, 255, 0.48));
}

.fantasy-tree-v5-node.is-current .fantasy-tree-v5-node-core {
    --v5-node-scale: 1.08;
    width: 20px;
    height: 14px;
    background:
        radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.96) 0 10%, rgba(177, 239, 255, 0.98) 23%, rgba(98, 135, 238, 0.94) 46%, rgba(58, 48, 149, 0.86) 67%, transparent 84%);
    box-shadow:
        inset 0 0 0 1px rgba(173, 244, 255, 0.94),
        0 0 13px rgba(76, 208, 244, 0.78),
        0 0 26px rgba(130, 101, 238, 0.50);
}

.fantasy-tree-v5-node.is-current .fantasy-tree-v5-node-ring.is-outer,
.fantasy-tree-v5-node.is-selected .fantasy-tree-v5-node-ring.is-outer {
    opacity: 1;
}

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

.fantasy-tree-v5-node:focus-visible .fantasy-tree-v5-node-ring.is-outer {
    opacity: 1;
    filter: drop-shadow(0 0 6px rgba(123, 231, 255, 0.82));
}

.fantasy-tree-v5-node.is-life-highlighted .fantasy-tree-v5-node-core {
    --v5-node-scale: 1.14;
    filter: brightness(1.24) saturate(1.18);
    box-shadow:
        inset 0 0 0 1px rgba(177, 243, 255, 0.94),
        0 0 15px rgba(91, 219, 249, 0.88),
        0 0 30px rgba(134, 115, 247, 0.52);
}

.fantasy-tree-v5-node.is-life-highlighted .fantasy-tree-v5-node-ring.is-inner,
.fantasy-tree-v5-node.is-life-highlighted .fantasy-tree-v5-node-ring.is-outer {
    opacity: 1;
    filter:
        drop-shadow(0 0 6px rgba(116, 237, 255, 0.92))
        drop-shadow(0 0 11px rgba(163, 143, 255, 0.46));
}

.fantasy-tree-v5-node.is-selected .fantasy-tree-v5-node-core {
    --v5-node-scale: 1.30;
    filter: brightness(1.34) saturate(1.28);
    background:
        radial-gradient(circle at 50% 50%, #fff 0 12%, rgba(206, 246, 255, 0.98) 24%, rgba(126, 163, 246, 0.96) 44%, rgba(225, 101, 202, 0.90) 64%, rgba(70, 40, 146, 0.78) 76%, transparent 86%);
    box-shadow:
        inset 0 0 0 1px rgba(218, 247, 255, 0.98),
        0 0 18px rgba(105, 224, 250, 0.92),
        0 0 34px rgba(255, 106, 209, 0.76),
        0 0 48px rgba(163, 131, 255, 0.54);
}

.fantasy-tree-v5-node.is-selected .fantasy-tree-v5-node-ring.is-inner {
    opacity: 1;
    background:
        radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.56) 0 6%, transparent 18%),
        linear-gradient(155deg, rgba(94, 81, 183, 0.64), rgba(136, 225, 247, 0.72) 48%, rgba(239, 108, 198, 0.58));
    filter:
        drop-shadow(0 0 6px rgba(111, 237, 255, 1))
        drop-shadow(0 0 12px rgba(255, 104, 209, 0.82));
}

.fantasy-tree-v5-node.is-selected .fantasy-tree-v5-node-ring.is-outer {
    transform: rotate(2deg) scale(1.16);
    filter:
        drop-shadow(0 0 8px rgba(255, 103, 210, 1))
        drop-shadow(0 0 16px rgba(159, 129, 255, 0.86))
        drop-shadow(0 0 24px rgba(111, 235, 255, 0.68));
}

.fantasy-tree-v5-node.is-dragging .fantasy-tree-v5-node-core {
    --v5-node-scale: 1.28;
    filter: brightness(1.26);
    box-shadow: inset 0 0 0 1px rgba(192, 243, 255, 0.92), 0 0 18px rgba(92, 217, 246, 0.88), 0 0 32px rgba(164, 132, 255, 0.50);
}

.fantasy-tree-v5-node.is-pending .fantasy-tree-v5-node-ring.is-outer {
    opacity: 0.48;
    background: radial-gradient(ellipse at 12% 52%, rgba(159, 241, 255, 0.76) 0 3%, transparent 8%), radial-gradient(ellipse at 86% 21%, rgba(178, 157, 255, 0.64) 0 3%, transparent 8%);
}

.fantasy-tree-v5-node.status-failed .fantasy-tree-v5-node-core,
.fantasy-tree-v5-node.status-error .fantasy-tree-v5-node-core {
    background: linear-gradient(100deg, rgba(79, 38, 127, 0.96), rgba(166, 74, 184, 0.92) 30%, rgba(244, 147, 216, 0.92) 48%, rgba(196, 61, 154, 0.94) 66%, rgba(86, 37, 132, 0.96));
    box-shadow: inset 0 0 0 1px rgba(255, 184, 233, 0.88), 0 0 14px rgba(255, 105, 206, 0.76), 0 0 24px rgba(166, 121, 255, 0.42);
}

.fantasy-tree-v5-node.status-failed .fantasy-tree-v5-node-ring.is-outer,
.fantasy-tree-v5-node.status-error .fantasy-tree-v5-node-ring.is-outer {
    opacity: 0.82;
    background: radial-gradient(ellipse at 12% 52%, rgba(255, 177, 232, 0.90) 0 4%, transparent 9%), radial-gradient(ellipse at 86% 21%, rgba(255, 88, 191, 0.82) 0 3%, transparent 9%), radial-gradient(ellipse at 89% 81%, rgba(178, 130, 255, 0.76) 0 3%, transparent 9%);
}

.fantasy-tree-v5-node.is-root .fantasy-tree-v5-node-core {
    background:
        radial-gradient(circle at 50% 50%, rgba(255, 240, 179, 0.98) 0 10%, rgba(244, 195, 104, 0.92) 24%, rgba(103, 162, 231, 0.86) 48%, rgba(49, 52, 139, 0.72) 68%, transparent 84%);
    box-shadow: inset 0 0 0 1px rgba(255, 225, 156, 0.84), 0 0 12px rgba(229, 177, 83, 0.60), 0 0 22px rgba(81, 189, 233, 0.42);
}

.fantasy-tree-v5-node.is-root .fantasy-tree-v5-node-ring.is-outer {
    opacity: 0.68;
    background: radial-gradient(ellipse at 12% 52%, rgba(255, 239, 181, 0.92) 0 4%, transparent 9%), radial-gradient(ellipse at 86% 21%, rgba(239, 252, 255, 0.78) 0 3%, transparent 9%), radial-gradient(ellipse at 89% 81%, rgba(176, 158, 255, 0.58) 0 3%, transparent 9%);
}

@media (prefers-reduced-motion: reduce) {
    .fantasy-tree-v5-node-core,
    .fantasy-tree-v5-node-ring.is-inner,
    .fantasy-tree-v5-node-ring.is-outer {
        transition: none;
    }
}

.fantasy-tree-v5-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-v5-node-context-menu[hidden] {
    display: none;
}

.fantasy-tree-v5-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-v5-node-context-menu button:hover,
.fantasy-tree-v5-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;
}

@media (max-width: 760px), (hover: none), (pointer: coarse) {
    body.fantasy-tree-v5-active .fantasy-tree-v5-editor-panel {
        top: 10px;
        left: 10px;
        width: min(300px, calc(100% - 20px));
        max-height: min(62dvh, calc(100% - 20px));
    }
}

/* V5 stage previews reuse the planet/V9 crystal language without sharing IDs or selectors. */
body.fantasy-tree-v5-active .fantasy-tree-stage-image-preview,
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview,
body.fantasy-tree-v5-active #fantasy-tree-stage-image-preview {
    --v5-preview-cyan: #37e8ff;
    --v5-preview-magenta: #ff45d6;
    --v5-preview-violet: #a767ff;
    box-sizing: border-box;
    z-index: 44;
    width: min(380px, calc(100% - 24px));
    max-height: calc(100% - 24px);
    /* Reserve space for the SVG crystal rim around the content panel. */
    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-v5-active .fantasy-tree-stage-image-preview.visible,
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview.visible,
body.fantasy-tree-v5-active #fantasy-tree-stage-image-preview.visible,
body.fantasy-tree-v5-active .fantasy-tree-stage-image-preview.pinned,
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview.pinned,
body.fantasy-tree-v5-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-v5-active .fantasy-tree-v5-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);
    backdrop-filter: blur(14px) saturate(1.12);
    -webkit-backdrop-filter: blur(14px) saturate(1.12);
}

body.fantasy-tree-v5-active .fantasy-tree-v5-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));
}

body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview-crystal-outline { opacity: 0.88; }
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview-crystal-inner { opacity: 0.66; }
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview-crystal-facets polygon,
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview-crystal-rim polygon,
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview-crystal-shards polygon {
    stroke-width: 0.88;
    opacity: 0.82;
}
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview-crystal-rim-cuts,
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview-crystal-planes,
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview-crystal-rays {
    opacity: 0.68;
}
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview-crystal-highlight {
    opacity: 0.42;
    mix-blend-mode: screen;
}
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview-crystal-powerline {
    fill: none;
    stroke: url(#fantasyTreeV5StagePreviewCrystalBeamGradient);
    stroke-width: 1.1;
    stroke-dasharray: 2 8;
    opacity: 0.46;
}

body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview-crystal-beam,
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview-crystal-beam-secondary {
    fill: none;
    pathLength: 100;
    pointer-events: none;
}
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview-crystal-beam-base {
    stroke: rgba(55, 232, 255, 0.5);
    stroke-width: 0.92;
    opacity: 0.4;
}
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview.visible
    .fantasy-tree-v5-stage-preview-crystal-beam-trail,
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview.visible
    .fantasy-tree-v5-stage-preview-crystal-beam-core,
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview.visible
    .fantasy-tree-v5-stage-preview-crystal-beam-head,
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview.visible
    .fantasy-tree-v5-stage-preview-crystal-beam-trail-secondary,
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview.visible
    .fantasy-tree-v5-stage-preview-crystal-beam-core-secondary,
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview.visible
    .fantasy-tree-v5-stage-preview-crystal-beam-head-secondary {
    stroke: url(#fantasyTreeV5StagePreviewCrystalBeamGradient);
    stroke-dasharray: 46 54;
    animation: fantasyBorderBeamTrace 4.8s linear infinite;
    will-change: stroke-dashoffset;
}
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview.visible
    .fantasy-tree-v5-stage-preview-crystal-beam-trail {
    stroke-width: 4.6;
    opacity: 0.64;
    filter: blur(1.8px) drop-shadow(0 0 7px rgba(55, 232, 255, 0.7));
    animation-delay: -0.9s;
}
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview.visible
    .fantasy-tree-v5-stage-preview-crystal-beam-core {
    stroke-width: 1.85;
    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-delay: -0.9s;
}
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview.visible
    .fantasy-tree-v5-stage-preview-crystal-beam-head {
    stroke: #f8ffff;
    stroke-width: 3;
    stroke-dasharray: 1.25 98.75;
    opacity: 1;
    filter: drop-shadow(0 0 3px #fff) drop-shadow(0 0 7px rgba(255, 69, 214, 0.74));
    animation-delay: -0.9s;
}
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview.visible
    .fantasy-tree-v5-stage-preview-crystal-beam-trail-secondary {
    stroke-width: 4.2;
    opacity: 0.58;
    filter: blur(1.8px) drop-shadow(0 0 6px rgba(55, 232, 255, 0.58));
    animation-delay: -3.3s;
}
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview.visible
    .fantasy-tree-v5-stage-preview-crystal-beam-core-secondary {
    stroke-width: 1.7;
    opacity: 0.84;
    filter: drop-shadow(0 0 3px rgba(55, 232, 255, 0.78));
    animation-delay: -3.3s;
}
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview.visible
    .fantasy-tree-v5-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 #fff) drop-shadow(0 0 6px rgba(255, 69, 214, 0.62));
    animation-delay: -3.3s;
}
body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview.pinned
    .fantasy-tree-v5-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));
}

@media (max-width: 860px), (hover: none), (pointer: coarse) {
    body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview {
        z-index: 90;
        width: min(360px, calc(100vw - 24px));
        padding: 24px;
    }
    body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview-content {
        max-height: min(68dvh, calc(100dvh - 112px));
    }
}

@media (prefers-reduced-motion: reduce) {
    body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview-crystal-powerline,
    body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview
        :is(
            .fantasy-tree-v5-stage-preview-crystal-beam-trail,
            .fantasy-tree-v5-stage-preview-crystal-beam-core,
            .fantasy-tree-v5-stage-preview-crystal-beam-head,
            .fantasy-tree-v5-stage-preview-crystal-beam-trail-secondary,
            .fantasy-tree-v5-stage-preview-crystal-beam-core-secondary,
            .fantasy-tree-v5-stage-preview-crystal-beam-head-secondary
        ) {
        animation: none !important;
        opacity: 0 !important;
        filter: none !important;
        will-change: auto !important;
    }
    body.fantasy-tree-v5-active .fantasy-tree-v5-stage-preview-crystal-beam-base {
        opacity: 0.3;
    }
}

/* V5 node artwork is a real transparent bitmap; the button remains the 48px hit area. */
.fantasy-tree-v5-node-core {
    width: 17px !important;
    height: 17px !important;
    border-radius: 50%;
    background: transparent !important;
    box-shadow: none;
}

.fantasy-tree-v5-node-sprite {
    position: absolute;
    inset: -2.5px;
    display: block;
    border-radius: 50%;
    background: url("../assets/fantasy-tree-v5/life-tree-v5-node-stardust-orb-r1.png") center / contain no-repeat;
    opacity: 0.7 !important;
    filter: drop-shadow(0 0 4px rgba(113, 220, 255, 0.30));
    transform: rotate(calc(var(--v5-node-angle) * -1));
    transform-origin: 50% 50%;
    transition: filter 160ms cubic-bezier(0.22, 1, 0.36, 1), transform 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.fantasy-tree-v5-node-core::before,
.fantasy-tree-v5-node-core::after {
    display: none;
}

.fantasy-tree-v5-node-ring.is-inner {
    inset: -1.5px;
    opacity: 0.18;
}

.fantasy-tree-v5-node-ring.is-outer {
    inset: -1px;
    opacity: 0.12;
}

.fantasy-tree-v5-node.is-current .fantasy-tree-v5-node-sprite,
.fantasy-tree-v5-node.is-life-highlighted .fantasy-tree-v5-node-sprite {
    filter:
        brightness(1.10)
        saturate(1.08)
        drop-shadow(0 0 5px rgba(94, 246, 255, 0.62))
        drop-shadow(0 0 10px rgba(157, 124, 255, 0.28));
}

.fantasy-tree-v5-node.is-selected .fantasy-tree-v5-node-sprite,
.fantasy-tree-v5-node:hover .fantasy-tree-v5-node-sprite,
.fantasy-tree-v5-node:focus-visible .fantasy-tree-v5-node-sprite {
    filter:
        brightness(1.18)
        saturate(1.16)
        drop-shadow(0 0 5px rgba(255, 255, 255, 0.72))
        drop-shadow(0 0 11px rgba(255, 83, 199, 0.50));
}

.fantasy-tree-v5-node.is-selected .fantasy-tree-v5-node-ring.is-outer,
.fantasy-tree-v5-node.is-current .fantasy-tree-v5-node-ring.is-outer,
.fantasy-tree-v5-node.is-life-highlighted .fantasy-tree-v5-node-ring.is-outer {
    opacity: 0.38;
}

.fantasy-tree-v5-node.is-pending .fantasy-tree-v5-node-sprite {
    opacity: 0.58;
    filter: saturate(0.72) brightness(0.82) drop-shadow(0 0 5px rgba(94, 246, 255, 0.22));
}

.fantasy-tree-v5-node.status-failed .fantasy-tree-v5-node-sprite,
.fantasy-tree-v5-node.status-error .fantasy-tree-v5-node-sprite {
    filter:
        saturate(0.82)
        hue-rotate(292deg)
        brightness(1.04)
        drop-shadow(0 0 6px rgba(255, 83, 199, 0.66));
}

.fantasy-tree-v5-node.is-root .fantasy-tree-v5-node-sprite {
    filter:
        saturate(0.88)
        sepia(0.18)
        brightness(1.04)
        drop-shadow(0 0 5px rgba(255, 218, 146, 0.54));
}

@media (prefers-reduced-motion: reduce) {
    .fantasy-tree-v5-node-sprite {
        transition: none;
    }
}

body.fantasy-tree-v5-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;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

body.fantasy-tree-v5-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;
}
