/* =============================================================================
   COSMIC SURVIVORS v10.0 — INTERACTIVE EVOLUTION TREE LAB (css/tree.css)
   Panzoom-powered blueprint stage + calm right telemetry inspector
   ============================================================================= */

.tree-app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Ship Selector Subbar */
.tree-ship-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.72rem 1.5rem;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    flex-wrap: wrap;
}

.ship-tabs-scroll {
    display: flex;
    align-items: center;
    gap: 0.48rem;
    flex-wrap: wrap;
}

.ship-pill-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.44rem 0.78rem;
    border-radius: 9px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.ship-pill-btn:hover {
    background: var(--bg-card-hover);
    color: var(--text-primary);
}

.ship-pill-btn.active {
    background: #162238;
    border-color: var(--border-active);
    color: var(--text-primary);
    font-weight: 600;
}

.ship-pill-btn img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.tree-legend-strip {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--text-secondary);
}

.legend-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    margin-right: 0.32rem;
}

/* Main Lab Workspace */
.tree-workspace {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 370px;
    min-height: calc(100vh - 125px);
}

/* Left Interactive Panzoom Blueprint Stage */
.tree-viewport {
    position: relative;
    overflow: hidden;
    background-color: var(--bg-void);
    background-image:
        radial-gradient(circle at 30% 25%, rgba(56, 189, 248, 0.06), transparent 52%),
        linear-gradient(rgba(148, 163, 184, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(148, 163, 184, 0.04) 1px, transparent 1px);
    background-size: auto, 38px 38px, 38px 38px;
    min-height: 660px;
    cursor: grab;
    user-select: none;
}

.tree-viewport:active {
    cursor: grabbing;
}

.tree-toolbar {
    position: absolute;
    top: 14px;
    left: 14px;
    right: 14px;
    z-index: 25;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.55rem;
    pointer-events: none;
}

.tree-zoom-group,
.tree-search-wrap {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem;
    border-radius: 10px;
    background: rgba(13, 19, 32, 0.9);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-subtle);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.32);
}

.tree-tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.42rem 0.68rem;
    border-radius: 7px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 12.5px;
    font-weight: 500;
}

.tree-tool-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-medium);
}

.tree-zoom-readout {
    padding: 0 0.45rem;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--text-secondary);
}

/* Fuse.js Fuzzy Blueprint Search */
.tree-search-wrap {
    position: relative;
    min-width: 280px;
    max-width: 390px;
    flex: 1 1 280px;
    padding: 0.35rem 0.55rem;
}

.tree-search-icon {
    width: 15px;
    height: 15px;
    color: var(--accent-sky);
    flex-shrink: 0;
}

.tree-search-input {
    width: 100%;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13px;
}

.tree-search-input::placeholder {
    color: var(--text-muted);
}

.tree-search-count {
    padding: 0.12rem 0.42rem;
    border-radius: 999px;
    background: rgba(56, 189, 248, 0.14);
    border: 1px solid rgba(56, 189, 248, 0.35);
    color: var(--accent-sky);
    font-size: 11px;
    white-space: nowrap;
}

.tree-search-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
}

.tree-search-clear:hover {
    color: var(--text-primary);
    border-color: var(--border-medium);
}

.tree-search-clear svg {
    width: 12px;
    height: 12px;
}

.tree-search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 310px;
    overflow-y: auto;
    padding: 0.35rem;
    border-radius: 10px;
    background: rgba(11, 17, 29, 0.97);
    border: 1px solid var(--border-medium);
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    z-index: 40;
}

.tree-search-results[hidden] {
    display: none;
}

.tree-search-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.48rem 0.6rem;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    transition: background var(--t-fast), border-color var(--t-fast);
}

.tree-search-item:hover,
.tree-search-item.is-active {
    background: rgba(56, 189, 248, 0.12);
    border-color: rgba(56, 189, 248, 0.36);
}

.tree-search-item-icon {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tree-search-item-body {
    flex: 1;
    min-width: 0;
}

.tree-search-item-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-search-item-sub {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tree-search-empty {
    padding: 0.7rem 0.8rem;
    font-size: 12.5px;
    color: var(--text-muted);
    text-align: center;
}

.tree-hint-pill {
    position: absolute;
    bottom: 14px;
    left: 14px;
    z-index: 20;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    background: rgba(13, 19, 32, 0.86);
    border: 1px solid var(--border-subtle);
    font-size: 12px;
    color: var(--text-secondary);
    pointer-events: none;
}

/* #treeCanvas sits inside #treeViewport for Panzoom */
.tree-canvas-stage {
    position: relative;
    display: inline-block;
    min-width: 1280px;
    padding: 3.75rem 2.5rem 3rem;
    transform-origin: 0 0;
}

.tree-svg-layer {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
    z-index: 1;
}

.tree-edge {
    fill: none;
    stroke: rgba(148, 163, 184, 0.16);
    stroke-width: 1.75;
    transition: stroke 180ms ease, stroke-width 180ms ease, opacity 180ms ease;
}

.tree-edge.is-dimmed {
    opacity: 0.22;
}

.tree-edge.is-highlighted {
    stroke: var(--accent-sky);
    stroke-width: 2.8;
    opacity: 1;
}

.tree-edge.is-mega {
    stroke: var(--accent-amber);
    stroke-width: 3;
    stroke-dasharray: 6 4;
    opacity: 1;
}

.tree-columns {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: 240px 265px 310px 270px;
    gap: 3.1rem;
    align-items: start;
}

.tree-col {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.tree-col-head {
    padding: 0.45rem 0.72rem;
    border-radius: 8px;
    background: rgba(13, 19, 32, 0.88);
    border: 1px solid var(--border-subtle);
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.tree-col-divider {
    margin: 0.45rem 0 0.15rem;
    font-family: var(--font-mono);
    font-size: 10.5px;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* Tree Node Cards */
.tree-node {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.68rem 0.82rem;
    border-radius: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: transform var(--transition-fast), border-color var(--transition-fast), background-color var(--transition-fast), opacity var(--transition-fast);
}

.tree-node:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-medium);
    transform: translateY(-1px);
}

.tree-node.is-signature {
    border-left: 3px solid var(--accent-sky);
}

.tree-node.is-mega {
    border-left: 3px solid var(--accent-amber);
}

.tree-node.is-dimmed {
    opacity: 0.34;
}

.tree-node.is-chain {
    border-color: rgba(56, 189, 248, 0.5);
    background: #172339;
}

.tree-node.is-selected {
    border-color: var(--accent-sky);
    background: #1a2942;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.24);
}

.tree-node.is-search-dim {
    opacity: 0.26;
}

.tree-node.is-search-match {
    opacity: 1;
    border-color: var(--accent-mint);
    background: #132833;
    box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.32), 0 0 18px rgba(45, 212, 191, 0.16);
}

.node-icon-box {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: rgba(7, 11, 18, 0.72);
    border: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.node-body {
    min-width: 0;
    flex: 1;
}

.node-name {
    font-family: var(--font-display);
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.node-sub {
    margin-top: 0.1rem;
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.node-tier-tag {
    font-family: var(--font-mono);
    font-size: 10.5px;
    font-weight: 600;
    padding: 0.14rem 0.42rem;
    border-radius: 5px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
}

/* Right Telemetry Inspector */
.tree-inspector {
    background: var(--bg-surface);
    border-left: 1px solid var(--border-subtle);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.05rem;
    overflow-y: auto;
}

.holo-preview-box {
    position: relative;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--bg-void);
    overflow: hidden;
}

#holoEffectCanvas {
    width: 100%;
    height: 175px;
    display: block;
}

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

.inspector-stat-cell {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 0.6rem 0.72rem;
}

.inspector-stat-cell span {
    display: block;
    font-size: 11px;
    color: var(--text-secondary);
}

.inspector-stat-cell strong {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-primary);
}

.chain-formula-box {
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 9px;
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.quick-synth-box {
    background: rgba(15, 23, 42, 0.72);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    padding: 0.95rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-top: auto;
}

.quick-synth-result {
    padding: 0.68rem 0.8rem;
    border-radius: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    font-size: 13px;
}

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

    .tree-viewport {
        min-height: 520px;
    }

    .tree-inspector {
        border-left: none;
        border-top: 1px solid var(--border-subtle);
    }
}

@media (max-width: 680px) {
    .tree-search-wrap {
        min-width: 0;
        max-width: none;
        flex: 1 1 100%;
    }
}

/* v12.0 Dark Neon Control Parity for Quick Synth Calculator & Tree Controls */
.ship-pill-btn,
.tree-tool-btn,
.tree-search-clear,
.tree-search-item,
.quick-synth-box button {
    appearance: none;
    -webkit-appearance: none;
    color-scheme: dark;
    font-family: inherit;
    cursor: pointer;
}

.quick-synth-box .cs-select,
.quick-synth-box select,
#calcWeaponSelect,
#calcTrinketSelect {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    color-scheme: dark;
    width: 100%;
    padding: 0.56rem 2.15rem 0.56rem 0.82rem;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(56, 189, 248, 0.3);
    background-color: #0e1526;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2338bdf8' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.7rem center;
    background-size: 14px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast), background-color var(--transition-fast);
}

.quick-synth-box .cs-select:hover,
#calcWeaponSelect:hover,
#calcTrinketSelect:hover {
    border-color: rgba(56, 189, 248, 0.54);
    background-color: #131c31;
}

.quick-synth-box .cs-select:focus-visible,
#calcWeaponSelect:focus-visible,
#calcTrinketSelect:focus-visible {
    outline: none;
    border-color: var(--accent-sky);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18);
}

.quick-synth-box .cs-select option,
#calcWeaponSelect option,
#calcTrinketSelect option {
    background-color: #0d1320;
    color: #f1f5f9;
}
