:root {
    --bg: #0b0f14;
    --panel: rgba(255, 255, 255, 0.06);
    --stroke: rgba(255, 255, 255, 0.12);
    --text: #e5e7eb;
    --muted: #94a3b8;
    --accent: #60a5fa;
    --green: #22c55e;
    --yellow: #eab308;
    --pink: #f472b6;
    --orange: #fb923c;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    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.10), 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 LAYOUT */
.header {
    padding: 16px 18px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.headerTop {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.leftHead {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex: 1 1 auto;
}

.rightHead {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.homeBtn {
    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;
}

.statsBtn {
    width: 40px;
    height: 40px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .12);
    color: #2dff00;
    flex: 0 0 auto;
    transition: all .15s ease;
}

.homeBtn: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;
    line-height: 1.2;
}

.subtitle {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 12px;
    max-width: 900px;
    line-height: 1.4;
}

/* SEARCH */
.searchWrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 14px;
    border: 1px solid var(--stroke);
    background: rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(6px);
    min-width: 0;
}

.searchWrap svg {
    opacity: 0.9;
    flex: 0 0 auto;
}

#q {
    width: 320px;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 14px;
    min-width: 0;
}

#clearBtn {
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    border-radius: 10px;
    padding: 6px 10px;
    cursor: pointer;
    flex: 0 0 auto;
}

#clearBtn:hover {
    background: rgba(255, 255, 255, 0.10);
}

/* INFO */
.infoWrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
}

.infoBtn {
    width: 28px;
    height: 28px;
    border-radius: 999px;
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}

.infoBtn:hover {
    background: rgba(96, 165, 250, 0.18);
    border-color: rgba(96, 165, 250, 0.45);
}

.infoPopover {
    position: absolute;
    top: 38px;
    right: 0;
    width: min(420px, 85vw);
    padding: 14px 14px 12px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(10, 14, 20, 0.96);
    backdrop-filter: blur(12px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.42);
    z-index: 20;
}

.infoPopover.is-hidden {
    display: none;
}

.infoTitle {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
}

.infoPopover p {
    margin: 0 0 10px;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text);
}

.infoPopover p:last-child {
    margin-bottom: 0;
}

/* FILTER ROW */
.headerFilters {
    width: 100%;
    min-width: 0;
}

.hintPills {
    display: flex;
    flex-wrap: nowrap;
    /* single row */
    gap: 12px;
    align-items: stretch;
    overflow: hidden;
    /* 🚫 remove scrollbar */
}

.hintPills::-webkit-scrollbar {
    height: 6px;
}

.hintPills::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.16);
    border-radius: 999px;
}

/* prevent shrinking */
.pillGroup {
    display: flex;
    flex-wrap: nowrap;
    gap: 4px;
    align-items: center;
    padding: 8px 10px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    background: rgba(255, 255, 255, 0.035);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
    position: relative;
    flex: 0 0 auto;
    white-space: nowrap;
}

/* GROUP LABEL */
.pillGroup::before {
    content: attr(data-label);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

/* ACTIVE GROUP HIGHLIGHT */
.pillGroup:has(.pillBtn.is-active) {
    border-color: rgba(96, 165, 250, 0.18);
    background: rgba(255, 255, 255, 0.05);
}

/* PILLS */
.pillBtn {
    font-size: 12px;
    color: var(--muted);
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.04);
    border-radius: 999px;
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.pillBtn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.08);
}

.pillBtn.is-active {
    color: var(--text);
    border-color: rgba(96, 165, 250, 0.45);
    background: rgba(96, 165, 250, 0.18);
}

/* MAIN PANEL */
.wrap {
    padding: 0 18px 18px;
    height: calc(100vh - 124px);
}

.panel {
    height: 100%;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.10);
    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);
    overflow: hidden;
    position: relative;
}

#viz {
    width: 100%;
    height: 100%;
}

/* TOOLTIP */
.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);
}

.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 */
.legend {
    position: absolute;
    left: 12px;
    bottom: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    pointer-events: none;
}

.legend .chip {
    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;
}

/* DETAIL CARD */
.detailCard {
    position: absolute;
    top: 14px;
    right: 14px;
    width: min(420px, calc(100% - 28px));
    max-height: calc(100% - 28px);
    overflow: auto;
    border-radius: 18px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(10, 14, 20, 0.92);
    backdrop-filter: blur(12px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.42);
    z-index: 5;
}

.detailCard.is-hidden {
    display: none;
}

.detailInner {
    padding: 18px 18px 16px;
}

.detailClose {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
}

.detailEyebrow {
    color: var(--muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}

.detailCard h2 {
    margin: 0;
    font-size: 20px;
    line-height: 1.25;
    padding-right: 36px;
}

.detailStats {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.statPill {
    font-size: 12px;
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.06);
    border-radius: 999px;
    padding: 6px 10px;
    color: var(--text);
}

.detailSequenceLabel,
.metaLabel {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
}

.detailSequenceLabel {
    margin-top: 16px;
    margin-bottom: 8px;
}

.detailSequence {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.seqTune {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border-radius: 999px;
    border: 1px solid var(--stroke);
    background: rgba(255, 255, 255, 0.06);
    padding: 7px 10px;
    font-size: 12px;
    color: var(--text);
    text-decoration: none;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
    transition: all 0.15s ease;
}

.seqTune:hover {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.seqArrow {
    color: var(--muted);
    font-size: 14px;
}

.detailMetaGrid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-top: 18px;
}

.metaValue {
    margin-top: 6px;
    font-size: 13px;
    line-height: 1.4;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    word-break: break-all;
}

/* ========================= */
/* TABLET: allow wrapping    */
/* ========================= */
@media (max-width: 1400px) {
    .hintPills {
        flex-wrap: wrap;
        /* ✅ wrap instead of scroll */
        gap: 10px;
    }

    .pillGroup {
        flex-wrap: wrap;
    }
}

/* RESPONSIVE */
@media (max-width: 1100px) {
    .headerTop {
        flex-wrap: wrap;
    }

    .rightHead {
        width: 100%;
        justify-content: flex-start;
    }

    #q {
        width: min(420px, 58vw);
    }
}

@media (max-width: 720px) {


    .legend {
        display: none;
    }

    .subtitle {
        display: none;
    }

    .headerFilters {
        display: none;
    }

    .infoBtn {
        display: none;
    }

    .wrap {
        height: calc(100vh - 170px);
    }

    .leftHead {
        align-items: flex-start;
    }

    .rightHead {
        flex-wrap: wrap;
        gap: 8px;
    }

    .searchWrap {
        width: 100%;
    }

    #q {
        width: 100%;
    }

    .detailCard {
        left: 12px;
        right: 12px;
        width: auto;
    }
}

.navBtns {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sliderGroup {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 220px;
}

.sliderLabel {
    font-size: 13px;
    color: var(--muted);
}

.rangeSlider {
    width: 100%;
}

.signatureBtn {
    display: inline-flex;
    align-items: center;
    gap: 8px;

    padding: 8px 14px;
    border-radius: 999px;

    border: 1px solid rgba(96, 165, 250, 0.5);
    background: rgba(96, 165, 250, 0.18);

    color: var(--text);
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;

    cursor: pointer;
    transition: all 0.15s ease;
}

.signatureBtn::before {
    content: "▶";
    font-size: 11px;
    opacity: 0.9;
}

.signatureBtn:hover {
    background: rgba(96, 165, 250, 0.28);
    border-color: rgba(96, 165, 250, 0.8);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(96, 165, 250, 0.25);
}

#quickFilters {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;

}

#colorByFilters {
    margin-left: auto;
}