* {
    box-sizing: border-box;
}


:root {
    --bg: #0b0f14;
    --surface: #111820;
    --surface-2: #151e28;
    --surface-3: #1a2530;

    --border: #25313d;
    --border-light: #30404e;

    --text: #edf2f7;
    --text-secondary: #9ba8b5;
    --text-muted: #667482;

    --accent: #5eead4;
    --accent-dark: #2dd4bf;

    --success: #4ade80;
    --danger: #f87171;
    --warning: #fbbf24;

    --radius: 12px;
}


html,
body {
    margin: 0;
    padding: 0;

    width: 100%;
    height: 100%;

    background: var(--bg);
    color: var(--text);

    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}


body {
    overflow: hidden;
}


button,
input,
textarea {
    font: inherit;
}


button {
    cursor: pointer;
}


.app-shell {
    display: flex;

    width: 100vw;
    height: 100vh;

    overflow: hidden;
}


.main-area {
    display: flex;
    flex-direction: column;

    min-width: 0;
    flex: 1;

    background:
        radial-gradient(
            circle at 80% 0%,
            rgba(45, 212, 191, 0.04),
            transparent 35%
        );
}


.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;

    min-height: 78px;

    padding: 0 28px;

    border-bottom:
        1px solid var(--border);
}


.topbar h1 {
    margin: 0;

    font-size: 18px;
    font-weight: 650;
}


.topbar p {
    margin: 5px 0 0;

    color: var(--text-muted);

    font-size: 12px;
}


.topbar-actions {
    display: flex;
    align-items: center;

    gap: 16px;
}


.connection-status {
    display: flex;
    align-items: center;

    gap: 7px;

    color: var(--text-secondary);

    font-size: 12px;
}


.status-dot {
    width: 8px;
    height: 8px;

    border-radius: 50%;

    background: var(--text-muted);
}


.status-dot.online {
    background: var(--success);

    box-shadow:
        0 0 10px
        rgba(74, 222, 128, 0.45);
}


.status-dot.offline {
    background: var(--danger);
}


.secondary-button {
    padding: 8px 12px;

    border:
        1px solid var(--border-light);

    border-radius: 8px;

    background: var(--surface-2);

    color: var(--text-secondary);

    font-size: 12px;
}


.secondary-button:hover {
    background: var(--surface-3);
    color: var(--text);
}


.view-switcher {
    display: inline-flex;

    flex-shrink: 0;

    gap: 3px;

    margin: 14px 16px 0;
    padding: 3px;

    border:
        1px solid var(--border);

    border-radius: 10px;

    background: var(--surface);
}


.view-tab {
    padding: 8px 16px;

    border: 0;
    border-radius: 7px;

    background: transparent;

    color: var(--text-secondary);

    font-size: 12px;
    font-weight: 600;
}


.view-tab:hover {
    color: var(--text);
}


.view-tab.active {
    background: rgba(94, 234, 212, 0.12);

    color: var(--accent);
}


.workspace {
    display: flex;

    min-height: 0;
    flex: 1;

    padding: 14px;
}


.chat-panel,
.graph-panel {
    display: flex;
    flex-direction: column;

    width: 100%;
    min-width: 0;
    min-height: 0;
    flex: 1;

    border:
        1px solid var(--border);

    border-radius: var(--radius);

    background: rgba(17, 24, 32, 0.82);

    overflow: hidden;
}


.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 15px 17px;

    border-bottom:
        1px solid var(--border);
}


.panel-header h2 {
    margin: 0;

    font-size: 13px;
    font-weight: 650;
}


.panel-header > div > span {
    display: block;

    margin-top: 3px;

    color: var(--text-muted);

    font-size: 10px;
}


.debug-bar {
    display: flex;

    gap: 28px;

    min-height: 34px;

    padding: 0 20px;

    align-items: center;

    border-top:
        1px solid var(--border);

    background: var(--surface);

    font-size: 10px;
}


.debug-item {
    display: flex;
    gap: 7px;
}


.debug-label {
    color: var(--text-muted);
}


.debug-value {
    color: var(--text-secondary);

    font-family:
        "SFMono-Regular",
        Consolas,
        monospace;
}


.hidden {
    display: none !important;
}


.loading-small,
.empty-state-small,
.error-small {
    padding: 10px;

    color: var(--text-muted);

    font-size: 11px;
}


.error-small {
    color: var(--danger);
}


.icon-button {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 30px;
    height: 30px;

    border:
        1px solid var(--border);

    border-radius: 7px;

    background: var(--surface-2);

    color: var(--text-secondary);

    font-size: 17px;
}


.icon-button:hover {
    color: var(--accent);
    border-color: var(--border-light);
}


.sidebar-toggle {
    display: none;

    margin-right: 12px;

    flex-shrink: 0;
}


.sidebar-backdrop {
    display: none;

    position: fixed;
    inset: 0;

    z-index: 1000;

    background: rgba(0, 0, 0, 0.5);
}


.sidebar-backdrop.visible {
    display: block;
}


/* =========================================
   RESPONSIVE LAYOUT
   ========================================= */

@media (max-width: 1100px) {

    /*
     * Only one panel (chat or graph) is ever shown at a time now,
     * via the view-switcher tabs, so there's no grid to collapse
     * here anymore. Kept as a hook in case panel-specific mobile
     * tweaks are needed later.
     */

}


/* =========================================
   MOBILE
   ========================================= */

@media (max-width: 760px) {

    html,
    body {
        width: 100%;
        height: 100%;
    }

    body {
        overflow: hidden;
    }

    .app-shell {
        width: 100%;
        height: 100dvh;
        min-height: 100dvh;

        overflow: hidden;
    }

    .main-area {
        width: 100%;
        min-width: 0;
        height: 100%;
    }


    /* -------------------------------
       TOP BAR
       ------------------------------- */

    .topbar {
        min-height: 64px;

        padding: 0 14px;

        flex-shrink: 0;
    }

    .topbar h1 {
        font-size: 16px;
    }

    .topbar p {
        font-size: 10px;
    }

    .topbar-actions {
        display: none;
    }

    .sidebar-toggle {
        display: flex;
    }

    .view-switcher {
        margin: 10px 8px 0;
    }


    /* -------------------------------
       WORKSPACE
       ------------------------------- */

    .workspace {
        display: flex;
        flex-direction: column;

        width: 100%;
        flex: 1;

        min-height: 0;

        padding: 8px;

        gap: 8px;

        overflow: hidden;
    }


    /* -------------------------------
       CHAT / GRAPH
       (only one is visible at a time,
       via the view-switcher tabs)
       ------------------------------- */

    .chat-panel,
    .graph-panel {
        flex: 1;

        width: 100%;
        min-height: 0;

        border-radius: 10px;
    }


    /* -------------------------------
       DEBUG BAR
       ------------------------------- */

    .debug-bar {
        width: 100%;

        min-height: 32px;

        padding: 0 14px;

        gap: 20px;

        overflow-x: auto;
        overflow-y: hidden;

        white-space: nowrap;

        flex-shrink: 0;
    }

    .debug-item {
        flex-shrink: 0;
    }

}

/* =========================================================
   CUSTOM SCROLLBARS
   ========================================================= */

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-light) transparent;
}


/* Chrome / Edge / Safari */
*::-webkit-scrollbar {
    width: 7px;
    height: 7px;
}


*::-webkit-scrollbar-track {
    background: transparent;
}


*::-webkit-scrollbar-thumb {
    background: var(--border-light);
    border-radius: 999px;
}


*::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}


/* Prevent scrollbar from looking too heavy on mobile */
@media (max-width: 760px) {

    * {
        scrollbar-width: thin;
    }

    *::-webkit-scrollbar {
        width: 4px;
        height: 4px;
    }

}