.crowd-feature {
    --crowd-panel: rgba(9, 15, 27, 0.82);
    --crowd-panel-border: rgba(148, 163, 184, 0.16);
    --crowd-text: #e5eefc;
    --crowd-muted: #93a4bc;
    --crowd-accent: #38bdf8;
    width: 100%;
    max-width: 1520px;
    margin: 0 auto;
    color: var(--crowd-text);
    font-family: "Space Grotesk", "Inter", sans-serif;
}

.crowd-feature[hidden] {
    display: none;
}

.crowd-feature button,
.crowd-feature input {
    font: inherit;
}

.crowd-feature-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 10px;
}

.crowd-feature-title {
    margin: 0;
    color: var(--crowd-text);
    font-size: clamp(1.2rem, 2vw, 1.65rem);
    line-height: 1.1;
}

.crowd-feature-title span {
    color: var(--crowd-accent);
}

.crowd-feature-subtitle {
    margin: 6px 0 0;
    color: var(--crowd-muted);
    font-size: 0.88rem;
}

.crowd-method-switch {
    display: flex;
    flex: 0 1 auto;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    padding: 4px;
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 18px;
    background: rgba(8, 15, 30, 0.72);
}

.crowd-method-btn {
    border: 1px solid transparent;
    border-radius: 13px;
    padding: 7px 10px;
    background: transparent;
    color: var(--crowd-muted);
    cursor: pointer;
    font-size: 0.78rem;
    white-space: nowrap;
}

.crowd-method-btn:hover {
    color: var(--crowd-text);
    background: rgba(148, 163, 184, 0.1);
}

.crowd-method-btn.active {
    border-color: rgba(56, 189, 248, 0.42);
    background: linear-gradient(135deg, rgba(56, 189, 248, 0.22), rgba(167, 139, 250, 0.16));
    color: var(--crowd-text);
}

.crowd-method-btn[disabled] {
    opacity: 0.48;
    cursor: wait;
}

.crowd-workspace {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(340px, 410px);
    gap: 14px;
}

.crowd-canvas-card,
.crowd-panel {
    background: var(--crowd-panel);
    border: 1px solid var(--crowd-panel-border);
    border-radius: 24px;
    backdrop-filter: blur(16px);
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.28);
}

.crowd-canvas-card {
    min-width: 0;
    padding: 10px;
}

.crowd-canvas-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-bottom: 8px;
}

.crowd-tool-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.crowd-toolbar-actions {
    margin-left: auto;
    justify-content: flex-end;
}

.crowd-tool-btn,
.crowd-section-toggle {
    border: 1px solid rgba(148, 163, 184, 0.18);
    border-radius: 999px;
    padding: 7px 12px;
    background: rgba(15, 23, 42, 0.72);
    color: var(--crowd-text);
    cursor: pointer;
    transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.crowd-tool-btn:hover,
.crowd-section-toggle:hover {
    transform: translateY(-1px);
    border-color: rgba(148, 163, 184, 0.4);
}

.crowd-tool-btn.active {
    border-color: rgba(56, 189, 248, 0.42);
    background: rgba(56, 189, 248, 0.16);
}

.crowd-tool-btn.accent {
    border-color: rgba(249, 115, 22, 0.45);
    background: rgba(249, 115, 22, 0.18);
}

.crowd-canvas-stack {
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.14);
    border-radius: 20px;
    background: #040912;
}

#crowdNavigationCanvas {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    aspect-ratio: 22 / 15;
    touch-action: none;
    cursor: crosshair;
}

.crowd-failure-overlay {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: grid;
    place-content: center;
    gap: 8px;
    text-align: center;
    background: rgba(3, 8, 15, 0.68);
    cursor: pointer;
}

.crowd-failure-overlay[hidden] {
    display: none;
}

.crowd-failure-overlay h2,
.crowd-failure-overlay p {
    margin: 0;
}

.crowd-failure-overlay h2 {
    font-size: 1.3rem;
}

.crowd-failure-overlay p {
    color: #fecaca;
}

.crowd-failure-overlay:focus-visible,
.crowd-feature button:focus-visible,
.crowd-feature input:focus-visible {
    outline: 2px solid #7dd3fc;
    outline-offset: 2px;
}

.crowd-failure-overlay:focus-visible {
    outline-offset: -4px;
}

.crowd-canvas-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-top: 6px;
}

.crowd-canvas-footer p {
    flex: 1 1 320px;
    margin: 0;
    max-width: 760px;
    color: var(--crowd-muted);
    font-size: 0.86rem;
}

.crowd-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 7px 12px;
    color: var(--crowd-muted);
    font-size: 0.74rem;
    white-space: nowrap;
}

.crowd-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.crowd-legend span::before {
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: currentColor;
    box-shadow: 0 0 8px currentColor;
    content: "";
}

.crowd-legend-graph {
    color: #a78bfa;
}

.crowd-legend-qp {
    color: #ef4444;
}

.crowd-legend-user {
    color: #fb923c;
}

.crowd-footer-stats {
    display: flex;
    flex: 0 0 auto;
    gap: 18px;
    color: var(--crowd-muted);
    font: 500 0.82rem "IBM Plex Mono", monospace;
}

.crowd-sidebar {
    display: flex;
    flex-direction: column;
    justify-self: end;
    gap: 10px;
    width: 100%;
    max-width: 410px;
}

.crowd-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 11px;
}

.crowd-panel h2 {
    margin: 0;
    font-size: 1rem;
}

.crowd-panel-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.crowd-panel-body {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.crowd-panel-body[hidden] {
    display: none;
}

.crowd-control-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.crowd-control {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 8px 14px;
}

.crowd-control span {
    color: var(--crowd-muted);
}

.crowd-control strong {
    color: var(--crowd-text);
    font: 500 0.9rem "IBM Plex Mono", monospace;
}

.crowd-control input[type="range"] {
    grid-column: 1 / -1;
    width: 100%;
    accent-color: var(--crowd-accent);
}

.crowd-stats-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.crowd-stat-card {
    min-width: 0;
    padding: 9px;
    border: 1px solid rgba(148, 163, 184, 0.12);
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.72);
}

.crowd-stat-label {
    color: var(--crowd-muted);
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.crowd-stat-value {
    overflow-wrap: anywhere;
    margin-top: 6px;
    color: var(--crowd-text);
    font: 500 0.88rem "IBM Plex Mono", monospace;
}

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

    .crowd-sidebar {
        max-width: none;
        justify-self: stretch;
    }

    .crowd-toolbar-actions {
        margin-left: 0;
        justify-content: flex-start;
    }
}

@media (max-width: 720px) {
    .crowd-feature-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .crowd-method-switch {
        justify-content: flex-start;
        width: 100%;
    }

    .crowd-method-btn {
        flex: 1 1 42%;
    }

    .crowd-canvas-footer {
        align-items: flex-start;
        flex-direction: column;
    }

    .crowd-legend {
        justify-content: flex-start;
    }

    .crowd-stats-grid {
        grid-template-columns: 1fr;
    }
}
