.graph-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    padding: 0;
    background: #03050c;
    color: #e2e8f0;
}

.graph-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-shrink: 0;
    padding: 8px 14px;
    min-height: 40px;
    background: rgba(6, 11, 24, 0.92);
    border-bottom: 1px solid rgba(56, 189, 248, 0.14);
}

.graph-header h1 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    letter-spacing: -0.2px;
    margin: 0;
    color: #e2e8f0;
    font-weight: 600;
}

.graph-header h1 svg {
    width: 17px;
    height: 17px;
    color: #38bdf8;
    filter: drop-shadow(0 0 6px rgba(56, 189, 248, 0.55));
}

.graph-header .icon-button {
    width: 28px;
    height: 28px;
    border-radius: 7px;
    color: #94a3b8;
    transition: background 0.15s, color 0.15s;
}

.graph-header .icon-button:hover {
    background: rgba(56, 189, 248, 0.14);
    color: #e0f2fe;
}

.graph-host {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.graph-stage {
    position: relative;
    flex: 1;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: #03050c;
}

.graph-stage > .graph-canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
    user-select: none;
    cursor: grab;
    background: transparent;
}

.graph-canvas:active {
    cursor: grabbing;
}

.graph-canvas:focus,
.graph-canvas:focus-visible {
    outline: none;
}

/* Floating Top-Left HUD: Search + Dropdown + Legend */
.graph-hud-top-left {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 4;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(340px, calc(100% - 24px));
    pointer-events: none;
}

.graph-hud-top-left > * {
    pointer-events: auto;
}

.graph-search-wrap {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.graph-search-icon {
    position: absolute;
    left: 10px;
    display: grid;
    place-items: center;
    color: #64748b;
    pointer-events: none;
}

.graph-search-icon svg {
    width: 14px;
    height: 14px;
}

.graph-search {
    width: 100%;
    min-width: 0;
    padding: 8px 30px 8px 32px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    border-radius: 10px;
    background: rgba(9, 15, 32, 0.78);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #f1f5f9;
    font-size: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.38);
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.graph-search:focus {
    outline: none;
    border-color: rgba(56, 189, 248, 0.65);
    background: rgba(9, 15, 32, 0.92);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.18), 0 8px 24px rgba(0, 0, 0, 0.45);
}

.graph-search::placeholder {
    color: #64748b;
}

.graph-search-clear {
    position: absolute;
    right: 6px;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    display: grid;
    place-items: center;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
}

.graph-search-clear:hover {
    background: rgba(148, 163, 184, 0.16);
    color: #f1f5f9;
}

.graph-search-clear svg {
    width: 13px;
    height: 13px;
}

.graph-search-clear[hidden] {
    display: none;
}

.graph-search-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 240px;
    overflow-y: auto;
    padding: 4px;
    border: 1px solid rgba(56, 189, 248, 0.24);
    border-radius: 10px;
    background: rgba(8, 14, 30, 0.94);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
    z-index: 10;
}

.graph-search-dropdown[hidden] {
    display: none;
}

.graph-search-empty {
    padding: 10px 12px;
    font-size: 11px;
    color: #94a3b8;
    text-align: center;
}

.graph-search-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #e2e8f0;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s;
}

.graph-search-item:hover,
.graph-search-item.is-active {
    background: rgba(56, 189, 248, 0.16);
}

.graph-search-item-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.graph-search-item-title {
    font-size: 12px;
    font-weight: 550;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.graph-search-item-path {
    font-size: 10px;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.graph-search-item-deg {
    font-size: 10px;
    font-weight: 600;
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.12);
    border-radius: 10px;
    padding: 2px 6px;
    flex-shrink: 0;
}

/* Floating Legend Chips (single horizontal row at bottom-left) */
.graph-legend {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
    margin: 0;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}

.graph-legend::-webkit-scrollbar {
    display: none;
}

.graph-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 999px;
    background: rgba(9, 15, 32, 0.78);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #cbd5e1;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.15s;
}

.graph-legend-item:hover {
    background: rgba(15, 23, 42, 0.9);
    border-color: rgba(148, 163, 184, 0.35);
    color: #f8fafc;
}

.graph-legend-item[aria-pressed="true"] {
    background: rgba(56, 189, 248, 0.18);
    border-color: rgba(56, 189, 248, 0.55);
    color: #e0f2fe;
    box-shadow: 0 0 12px rgba(56, 189, 248, 0.22);
}

.graph-swatch {
    width: 8px;
    height: 8px;
    flex-shrink: 0;
    border-radius: 50%;
    background: #38bdf8;
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.85);
}

.graph-legend-isolated .graph-swatch,
.graph-swatch-isolated {
    background: #2dd4bf;
    box-shadow: 0 0 8px rgba(45, 212, 191, 0.85);
}

.graph-legend-missing .graph-swatch,
.graph-swatch-missing {
    background: #c084fc;
    box-shadow: 0 0 8px rgba(192, 132, 252, 0.85);
    outline: 1px dashed #a855f7;
    outline-offset: 2px;
}

/* Floating Top-Right Stats Badge */
.graph-hud-top-right {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 3;
    pointer-events: none;
}

.graph-count {
    display: inline-flex;
    align-items: center;
    padding: 6px 11px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 999px;
    background: rgba(9, 15, 32, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    font-size: 11px;
    font-weight: 500;
    color: #94a3b8;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

.graph-count:empty {
    display: none;
}

/* Floating Bottom-Left: Node Inspector + Horizontal Legend */
.graph-hud-bottom-left {
    position: absolute;
    left: 12px;
    bottom: 12px;
    z-index: 4;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    max-width: calc(100% - 72px);
    pointer-events: none;
}

.graph-hud-bottom-left > * {
    pointer-events: auto;
}

.graph-inspector {
    width: min(310px, 100%);
    padding: 11px 12px;
    border: 1px solid rgba(56, 189, 248, 0.28);
    border-radius: 12px;
    background: rgba(8, 15, 32, 0.86);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.graph-inspector[hidden] {
    display: none;
}

.graph-inspector-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.graph-inspector-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    background: rgba(56, 189, 248, 0.16);
    color: #7dd3fc;
}

.graph-badge-isolated {
    background: rgba(45, 212, 191, 0.16);
    color: #5eead4;
}

.graph-badge-missing {
    background: rgba(192, 132, 252, 0.18);
    color: #d8b4fe;
}

.graph-inspector-close {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    display: grid;
    place-items: center;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
}

.graph-inspector-close:hover {
    background: rgba(148, 163, 184, 0.16);
    color: #f1f5f9;
}

.graph-inspector-close svg {
    width: 13px;
    height: 13px;
}

.graph-inspector-title {
    font-size: 13px;
    font-weight: 600;
    color: #f8fafc;
    line-height: 1.35;
    word-break: break-word;
}

.graph-inspector-meta {
    font-size: 11px;
    color: #94a3b8;
    line-height: 1.4;
    word-break: break-all;
}

.graph-inspector-open {
    margin-top: 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 11px;
    border: 1px solid rgba(56, 189, 248, 0.45);
    border-radius: 8px;
    background: rgba(56, 189, 248, 0.18);
    color: #e0f2fe;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.graph-inspector-open:hover {
    background: rgba(56, 189, 248, 0.3);
    border-color: rgba(125, 211, 252, 0.8);
}

.graph-inspector-open svg {
    width: 13px;
    height: 13px;
}

/* Floating Bottom-Right Single Menu Trigger + Upward Popover */
.graph-menu-wrap {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.graph-menu-trigger {
    width: 38px;
    height: 38px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 11px;
    background: rgba(9, 15, 32, 0.84);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: #cbd5e1;
    display: grid;
    place-items: center;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
    transition: all 0.16s;
}

.graph-menu-trigger svg {
    width: 17px;
    height: 17px;
}

.graph-menu-trigger:hover {
    border-color: rgba(56, 189, 248, 0.55);
    color: #e0f2fe;
    background: rgba(12, 22, 46, 0.92);
}

.graph-menu-trigger[aria-expanded="true"] {
    border-color: rgba(56, 189, 248, 0.72);
    background: rgba(56, 189, 248, 0.2);
    color: #38bdf8;
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.28), 0 6px 20px rgba(0, 0, 0, 0.45);
}

.graph-settings-popover {
    width: 244px;
    padding: 12px;
    border: 1px solid rgba(56, 189, 248, 0.26);
    border-radius: 13px;
    background: rgba(7, 13, 28, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.58);
    display: flex;
    flex-direction: column;
    gap: 11px;
    animation: graphPopoverUp 0.15s ease-out;
}

.graph-settings-popover[hidden] {
    display: none;
}

@keyframes graphPopoverUp {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.graph-popover-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.graph-popover-title {
    font-size: 11px;
    font-weight: 650;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    color: #7dd3fc;
}

.graph-popover-reset {
    padding: 2px 7px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.14s;
}

.graph-popover-reset:hover {
    border-color: rgba(56, 189, 248, 0.5);
    background: rgba(56, 189, 248, 0.14);
    color: #e0f2fe;
}

.graph-popover-shape {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.graph-shape-group {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
    padding: 3px;
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: 9px;
    background: rgba(15, 23, 42, 0.65);
}

.graph-shape-btn {
    padding: 5px 6px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 550;
    cursor: pointer;
    transition: all 0.14s;
}

.graph-shape-btn:hover {
    color: #f1f5f9;
    background: rgba(56, 189, 248, 0.12);
}

.graph-shape-btn[aria-pressed="true"] {
    background: rgba(56, 189, 248, 0.24);
    color: #e0f2fe;
    box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.52);
}

.graph-popover-speed {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.graph-popover-speed-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.graph-popover-speed-label {
    font-size: 11.5px;
    color: #cbd5e1;
}

.graph-popover-speed-val {
    font-size: 11px;
    font-weight: 600;
    color: #38bdf8;
    background: rgba(56, 189, 248, 0.14);
    padding: 1px 7px;
    border-radius: 999px;
    font-variant-numeric: tabular-nums;
}

.graph-speed-slider {
    width: 100%;
    height: 4px;
    accent-color: #38bdf8;
    cursor: pointer;
}

.graph-popover-toggles {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.graph-popover-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #cbd5e1;
    font-size: 11.5px;
    cursor: pointer;
    text-align: left;
    transition: background 0.14s, color 0.14s;
}

.graph-popover-toggle:hover {
    background: rgba(56, 189, 248, 0.12);
    color: #f8fafc;
}

.graph-popover-toggle-icon {
    display: grid;
    place-items: center;
    color: #94a3b8;
    flex-shrink: 0;
}

.graph-popover-toggle[aria-pressed="true"] .graph-popover-toggle-icon {
    color: #38bdf8;
}

.graph-popover-toggle-icon svg {
    width: 14px;
    height: 14px;
}

.graph-popover-toggle-label {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.graph-switch-pill {
    position: relative;
    width: 28px;
    height: 16px;
    border-radius: 999px;
    background: rgba(148, 163, 184, 0.28);
    flex-shrink: 0;
    transition: background 0.16s;
}

.graph-switch-pill::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #cbd5e1;
    transition: transform 0.16s, background 0.16s;
}

.graph-popover-toggle[aria-pressed="true"] .graph-switch-pill {
    background: rgba(56, 189, 248, 0.45);
}

.graph-popover-toggle[aria-pressed="true"] .graph-switch-pill::after {
    transform: translateX(12px);
    background: #38bdf8;
}

.graph-popover-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(148, 163, 184, 0.16);
}

.graph-popover-action {
    height: 30px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.65);
    color: #cbd5e1;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all 0.14s;
}

.graph-popover-action svg {
    width: 15px;
    height: 15px;
}

.graph-popover-action:hover {
    border-color: rgba(56, 189, 248, 0.5);
    background: rgba(56, 189, 248, 0.18);
    color: #e0f2fe;
}

.graph-description {
    display: none;
}

.graph-empty {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(340px, 85%);
    text-align: center;
    font-size: 13px;
    line-height: 1.8;
    color: #94a3b8;
    pointer-events: none;
}

.graph-empty[hidden] {
    display: none;
}

@media (max-width: 760px) {
    .graph-header {
        padding: 6px 10px;
    }

    .graph-hud-top-left {
        top: 8px;
        left: 8px;
        max-width: calc(100% - 16px);
    }

    .graph-hud-top-right {
        display: none;
    }

    .graph-legend-item {
        font-size: 10px;
        padding: 3px 8px;
    }

    .graph-hud-bottom-left {
        left: 8px;
        bottom: 8px;
        max-width: calc(100% - 60px);
    }

    .graph-menu-wrap {
        right: 8px;
        bottom: 8px;
    }

    .graph-menu-trigger {
        width: 34px;
        height: 34px;
    }

    .graph-settings-popover {
        width: min(236px, calc(100vw - 24px));
    }
}
