:root {
    --bg: #0b0f14;
    --panel: rgba(255, 255, 255, 0.06);
    --stroke: rgba(255, 255, 255, 0.12);
    --text: #e5e7eb;
    --muted: #94a3b8;
    --accent: #60a5fa;
    --accent2: #22c55e;
    --root: #f59e0b;
    --danger: #fca5a5;
}

* {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    color: var(--text);
    background:
        radial-gradient(1200px 800px at 20% -10%,
            rgba(96, 165, 250, 0.12),
            transparent 60%),
        radial-gradient(1200px 800px at 90% 10%,
            rgba(34, 197, 94, 0.1),
            transparent 55%),
        radial-gradient(900px 700px at 50% 120%,
            rgba(234, 179, 8, 0.08),
            transparent 60%),
        var(--bg);
    font-family:
        system-ui,
        -apple-system,
        Segoe UI,
        Roboto,
        sans-serif;
    overflow: hidden;
}

.header {
    flex: 0 0 auto;
    padding: 16px 18px 10px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    position: relative;
    z-index: 5;
}

.leftHead {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
}

.homeBtn,
.statsBtn {
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.06);
    color: #2dff00;
    text-decoration: none;
    transition: all 0.15s ease;
    flex: 0 0 auto;
}

.homeBtn:hover,
.statsBtn:hover {
    background: rgba(96, 165, 250, 0.22);
    border-color: rgba(96, 165, 250, 0.55);
    transform: translateY(-2px);
}

h1 {
    margin: 0;
    font-size: 20px;
    letter-spacing: 0.2px;
}

.sub {
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
    max-width: 900px;
    line-height: 1.45;
}

.rightHead {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.searchWrap {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 16px;
    border: 1px solid var(--stroke);
    background: rgba(0, 0, 0, 0.24);
    backdrop-filter: blur(8px);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.searchWrap:focus-within {
    border-color: rgba(96, 165, 250, 0.35);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.03),
        0 6px 20px rgba(0, 0, 0, 0.25);
}

.searchWrap svg {
    flex: 0 0 auto;
    color: var(--muted);
    opacity: 0.95;
}

#artistInput {
    width: 340px;
    height: 38px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    border-radius: 10px;
    padding: 0 12px;
    font-size: 14px;
    transition:
        border-color 0.15s ease,
        background 0.15s ease,
        box-shadow 0.15s ease;
}

#artistInput::placeholder {
    color: var(--muted);
}

#artistInput:hover {
    background: rgba(255, 255, 255, 0.06);
}

#artistInput:focus {
    outline: none;
    border-color: rgba(96, 165, 250, 0.75);
    background: rgba(255, 255, 255, 0.07);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.16);
}

#loadBtn {
    height: 38px;
    padding: 0 12px;
    border-radius: 10px;
    font-weight: 600;
    border: 1px solid rgba(96, 165, 250, 0.35);
    background: rgba(96, 165, 250, 0.18);
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s ease;
}

#loadBtn:hover {
    background: rgba(96, 165, 250, 0.26);
    border-color: rgba(96, 165, 250, 0.55);
}

.tree-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    align-items: center;
}

.tree-control {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 210px;
}

.tree-control label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
    min-width: 52px;
}

.tree-control input[type="range"] {
    flex: 1;
}

.tree-control span {
    min-width: 24px;
    text-align: right;
    font-weight: 600;
    color: var(--text);
}

.pageMain {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    padding: 0 18px 18px;
}

#viz {
    width: 100%;
    height: 100%;
    overflow: auto;
    position: relative;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: linear-gradient(180deg,
            rgba(255, 255, 255, 0.05),
            rgba(255, 255, 255, 0.03));
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    overscroll-behavior: contain;
}

#viz svg {
    display: block;
    max-width: none;
}

.treeSummary {
    padding: 10px 12px;
    position: sticky;
    top: 0;
    z-index: 3;
    background: linear-gradient(180deg,
            rgba(11, 15, 20, 0.95),
            rgba(11, 15, 20, 0.86));
    backdrop-filter: blur(6px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.treeSummaryRow {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.treeSummaryTitle {
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.summaryBadges {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    margin-left: auto;
}

.summaryBadges .pill {
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
}

.tree-link {
    fill: none;
    stroke-linecap: round;
}

.tree-link.artist-transition {
    stroke: url(#artist-pathway-grad);
    stroke-width: 2.8;
    opacity: 0.84;
}

.tree-link.transition-artist {
    stroke: rgba(34, 197, 94, 0.74);
    stroke-width: 1.7;
    stroke-dasharray: 6 5;
    opacity: 0.72;
}

.tree-node {
    cursor: pointer;
}

.node-card {
    fill: rgba(11, 15, 20, 0.9);
    stroke: rgba(255, 255, 255, 0.12);
    stroke-width: 1.2;
}

.node-card.is-root {
    stroke: color-mix(in srgb, var(--root) 68%, rgba(255, 255, 255, 0.14));
}

.node-card.is-transition {
    stroke: color-mix(in srgb, var(--accent) 48%, rgba(255, 255, 255, 0.1));
}

.node-card.is-related-artist {
    stroke: color-mix(in srgb, var(--accent2) 52%, rgba(255, 255, 255, 0.1));
}

.node-dot {
    stroke: rgba(255, 255, 255, 0.22);
    stroke-width: 1;
}

.node-dot.is-root {
    fill: var(--root);
}

.node-dot.is-transition {
    fill: var(--accent);
}

.node-dot.is-related-artist {
    fill: var(--accent2);
}

.node-type-bar {
    pointer-events: none;
    opacity: 0.95;
}

.node-type-bar.is-root {
    fill: var(--root);
}

.node-type-bar.is-transition {
    fill: var(--accent);
}

.node-type-bar.is-related-artist {
    fill: var(--accent2);
}

.tree-node:hover .node-card {
    filter: brightness(1.08);
    stroke: rgba(255, 255, 255, 0.32);
}

.tree-node:hover .node-dot {
    filter: brightness(1.14);
}

.node-label {
    font-size: 12px;
    fill: var(--text);
    pointer-events: none;
    font-weight: 650;
}

.node-meta {
    font-size: 11px;
    fill: var(--muted);
    pointer-events: none;
}

.node-hit {
    fill: transparent;
}

.emptyState,
.errorState,
.loadingState {
    padding: 28px 18px;
    color: var(--muted);
    font-size: 14px;
}

.errorState {
    color: var(--danger);
}

.tooltip {
    position: fixed;
    pointer-events: none;
    display: none;
    background: rgba(17, 24, 39, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 14px;
    padding: 10px 12px;
    max-width: 420px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
    z-index: 20;
}

.tooltip b {
    display: block;
    font-size: 13px;
}

.tooltip .meta {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

.tooltip .desc {
    margin-top: 8px;
    font-size: 12px;
    line-height: 1.35;
    opacity: 0.92;
}

.legend {
    position: absolute;
    left: 30px;
    bottom: 30px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    pointer-events: none;
    z-index: 3;
}

.legend .chip2 {
    pointer-events: none;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(0, 0, 0, 0.18);
    border-radius: 999px;
    padding: 5px 9px;
    backdrop-filter: blur(6px);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: #5b6b84 #1e2430;
}

/* Chrome / Edge / Safari */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: #1e2430;
    border-radius: 8px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, #5b6b84, #3e4b61);
    border-radius: 8px;
    border: 2px solid #1e2430;
}

::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, #7a8ca8, #55647d);
}

::-webkit-scrollbar-corner {
    background: #1e2430;
}

@media (max-width: 900px) {
    .header {
        padding: 14px 14px 10px;
    }

    .pageMain {
        padding: 0 14px 14px;
    }

    .rightHead,
    .searchWrap {
        width: 100%;
    }

    #artistInput {
        width: 100%;
    }

    .tree-controls {
        width: 100%;
    }

    .tree-control {
        min-width: 100%;
    }

    .treeSummaryRow {
        flex-wrap: wrap;
        align-items: flex-start;
    }

    .summaryBadges {
        margin-left: 0;
        justify-content: flex-start;
    }

    .treeSummaryTitle {
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
    }
}

@media (max-width: 700px) {
    body {
        overflow: auto;
    }

    .sub {
        display: none;
    }

    .treeSummary {
        display: none;
    }

    .legend {
        display: none;
    }

    .leftHead {
        min-width: 0;
    }

    .searchWrap {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 8px;
        padding: 10px;
    }

    .searchWrap svg {
        display: none;
    }

    #loadBtn {
        height: 36px;
        padding: 0 11px;
    }

    .pageMain {
        padding: 0 10px 10px;
    }

    #viz {
        border-radius: 14px;
    }

    .tooltip {
        max-width: min(280px, calc(100vw - 24px));
    }

    .node-label {
        font-size: 13px;
    }

    .node-meta {
        font-size: 12px;
    }
}

.autocompleteShell {
    position: relative;
    flex: 1 1 340px;
    min-width: 280px;
}

.autocompleteBox {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    z-index: 60;
    padding: 6px;
    background: rgba(15, 23, 32, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    box-shadow:
        0 18px 48px rgba(0, 0, 0, 0.42),
        inset 0 1px 0 rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    max-height: min(360px, 50vh);
    overflow-y: auto;
}

.autocompleteItem {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    color: #e5eef8;
    border: 0;
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
}

.autocompleteItem:hover,
.autocompleteItem.is-active {
    background: rgba(96, 165, 250, 0.16);
}

.autocompleteTitle {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
}

.autocompleteMeta {
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
}

.autocompleteEmpty {
    padding: 12px;
    font-size: 13px;
    color: var(--muted);
}

.treeSummaryHelp {
    margin-top: 4px;
    color: rgba(148, 163, 184, 0.88);
    font-size: 11px;
    line-height: 1.35;
}

.journeyTrail {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.journeyTrailLabel {
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    flex: 0 0 auto;
}

.journeyTrailPath {
    display: flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
    overflow-x: auto;
    padding-bottom: 2px;
}

.journeyTrailItem {
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 11px;
    cursor: pointer;
    white-space: nowrap;
}

.journeyTrailItem:hover {
    background: rgba(96, 165, 250, 0.18);
    border-color: rgba(96, 165, 250, 0.42);
}

.journeyTrailItem.is-current {
    border-color: rgba(245, 158, 11, 0.48);
    background: rgba(245, 158, 11, 0.14);
    color: #fde68a;
    cursor: default;
}

.journeyTrailSep {
    color: var(--muted);
    font-size: 12px;
    opacity: 0.75;
}

.columnLabel {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    pointer-events: none;
    opacity: 0.82;
}

.columnLabelRoot {
    fill: var(--root);
}

.columnLabelTransition {
    fill: var(--accent);
}

.columnLabelRelated {
    fill: var(--accent2);
}

.tooltipSmallTitle {
    display: block;
    margin-bottom: 5px;
    color: var(--muted);
    font-size: 11px !important;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.transitionIncipits {
    margin-top: 10px;
    display: grid;
    gap: 8px;
}

.transitionIncipitBlock {
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 7px;
    background: rgba(255, 255, 255, 0.04);
}

#tt .transitionIncipitBlock .incipitTitle {
    margin-bottom: 3px;
    color: #e5e7eb;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: none;
}

#tt .transitionIncipitBlock .incipitMeta {
    margin-bottom: 6px;
    color: #94a3b8;
    font-size: 11px;
}

.transitionArrow {
    text-align: center;
    color: #94a3b8;
    font-size: 14px;
    line-height: 1;
}

#tt .incipitMissing {
    color: #94a3b8;
    font-size: 11px;
    font-style: italic;
}

#tt .incipitFallback {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    line-height: 1.35;
    color: #111;
    white-space: normal;
    word-break: break-word;
}

.node-label,
.node-meta {
    max-width: 235px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.evidenceModal[hidden] {
    display: none !important;
}

.evidenceModal {
    position: fixed;
    inset: 0;
    z-index: 10010;
}

.evidenceBackdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.58);
    backdrop-filter: blur(3px);
}

.evidencePanel {
    position: relative;
    width: min(760px, calc(100vw - 24px));
    max-height: calc(100vh - 24px);
    overflow: auto;
    margin: 12px auto;
    background: #0f1720;
    color: #e5eef8;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
    padding: 16px 16px 20px;
}

.evidenceTop {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 12px;
}

.evidenceTitle {
    margin: 0 0 4px;
    font-size: 18px;
    line-height: 1.2;
}

.evidenceMeta {
    font-size: 13px;
    color: #9fb0c3;
    line-height: 1.35;
}

.evidenceCloseBtn {
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-radius: 10px;
    padding: 6px 10px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.evidenceStatus {
    font-size: 13px;
    color: #9fb0c3;
    margin-bottom: 10px;
}

.evidenceError {
    font-size: 13px;
    color: #fecaca;
    background: rgba(127, 29, 29, 0.25);
    border: 1px solid rgba(248, 113, 113, 0.35);
    padding: 10px 12px;
    border-radius: 10px;
    margin-bottom: 10px;
}

.evidenceSummary {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 14px;
}

.evidencePill {
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: #e5eef8;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
}

.artistEvidenceList {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.artistEvidenceCard {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(180px, auto);
    gap: 12px;
    align-items: center;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    padding: 12px;
}

.artistEvidenceRecording {
    font-size: 15px;
    font-weight: 800;
    color: #93c5fd;
}

.artistEvidenceMeta {
    margin-top: 4px;
    font-size: 12px;
    color: #94a3b8;
}

.artistEvidencePath {
    margin-top: 6px;
    font-size: 13px;
    color: #e5eef8;
    line-height: 1.35;
}

.artistEvidenceProviders {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.artistEvidenceProvider {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    max-width: 150px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: #e5eef8;
    border-radius: 999px;
    padding: 5px 9px 5px 5px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

.artistEvidenceProvider:hover {
    background: rgba(96, 165, 250, 0.18);
    border-color: rgba(96, 165, 250, 0.42);
    text-decoration: none;
}

.artistEvidenceProvider img {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    object-fit: cover;
    flex: 0 0 auto;
}

.artistEvidenceProvider span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.evidenceNoProviders,
.evidenceEmpty {
    color: #94a3b8;
    font-size: 13px;
    padding: 4px 0;
}

@media (max-width: 700px) {
    .evidencePanel {
        width: min(760px, calc(100vw - 14px));
        margin: 7px auto;
        padding: 12px 12px 16px;
    }

    .artistEvidenceCard {
        grid-template-columns: 1fr;
        align-items: flex-start;
    }

    .artistEvidenceProviders {
        justify-content: flex-start;
    }
}

.transition-evidence-icon {
    pointer-events: none;
}

.transition-evidence-icon-bg {
    fill: rgba(96, 165, 250, 0.16);
    stroke: rgba(96, 165, 250, 0.42);
    stroke-width: 1;
}

.transition-evidence-icon-text {
    fill: #bfdbfe;
    font-size: 13px;
    font-weight: 900;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
}

.tree-node:hover .transition-evidence-icon-bg {
    fill: rgba(96, 165, 250, 0.28);
    stroke: rgba(147, 197, 253, 0.72);
}

.artistEvidenceIntro {
    margin-bottom: 14px;
    font-size: 13px;
    line-height: 1.5;
    color: #9fb0c3;
}

.artistEvidenceRecordingLink {
    text-decoration: none;
}

.artistEvidenceRecordingLink:hover .artistEvidenceRecording {
    color: #bfdbfe;
}

.artistEvidenceActions {
    margin-top: 10px;
}

.artistEvidencePrimaryBtn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(96, 165, 250, 0.18);
    border: 1px solid rgba(96, 165, 250, 0.35);
    color: #dbeafe;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

.artistEvidencePrimaryBtn:hover {
    background: rgba(96, 165, 250, 0.28);
    border-color: rgba(147, 197, 253, 0.6);
    text-decoration: none;
}

.artistEvidenceProviderSection {
    margin-top: 12px;
}

.artistEvidenceProviderLabel {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 6px;
}