:root {
    color-scheme: dark;
    --cv-bg: #070914;
    --cv-surface: rgba(17, 24, 39, 0.82);
    --cv-surface-strong: rgba(15, 23, 42, 0.94);
    --cv-border: rgba(255, 255, 255, 0.11);
    --cv-text-muted: #a7b0c4;
    --cv-brand: #ff2d55;
    --cv-brand-2: #16d9e3;
    --cv-brand-3: #7c3aed;
}

* { box-sizing: border-box; }

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 15% 10%, rgba(22, 217, 227, 0.18), transparent 30%),
        radial-gradient(circle at 85% 15%, rgba(255, 45, 85, 0.20), transparent 34%),
        radial-gradient(circle at 50% 85%, rgba(124, 58, 237, 0.15), transparent 36%),
        var(--cv-bg);
    color: #f8fafc;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: #8bdcff; }
a:hover { color: #b8efff; }

.fw-black { font-weight: 900; }

.text-secondary,
.text-secondary-emphasis { color: var(--cv-text-muted) !important; }

.glass-nav {
    background: rgba(7, 9, 20, 0.76);
    border-bottom: 1px solid var(--cv-border);
    backdrop-filter: blur(18px);
}

.brand-mark {
    width: 38px;
    height: 38px;
    display: inline-grid;
    place-items: center;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--cv-brand), var(--cv-brand-2));
    color: #fff;
    box-shadow: 0 12px 34px rgba(22, 217, 227, 0.25);
}

.brand-link {
    color: #fff;
    font-size: 1.25rem;
    font-weight: 800;
    text-decoration: none;
}

.btn-brand {
    --bs-btn-color: #fff;
    --bs-btn-bg: transparent;
    --bs-btn-border-color: transparent;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: transparent;
    --bs-btn-hover-border-color: transparent;
    --bs-btn-active-bg: transparent;
    --bs-btn-active-border-color: transparent;
    background-image: linear-gradient(135deg, var(--cv-brand), var(--cv-brand-2));
    box-shadow: 0 14px 30px rgba(255, 45, 85, 0.22);
    border: 0;
    font-weight: 800;
}

.btn-brand:hover { transform: translateY(-1px); filter: brightness(1.05); }

.hero-section { min-height: 100vh; }
.hero-glow { position: absolute; width: 420px; height: 420px; border-radius: 999px; filter: blur(40px); opacity: 0.22; }
.hero-glow-one { background: var(--cv-brand); top: 10%; left: -150px; }
.hero-glow-two { background: var(--cv-brand-2); bottom: 6%; right: -160px; }

.hero-card,
.auth-card,
.panel-card,
.feature-card,
.step-card,
.stat-card {
    background: var(--cv-surface);
    border: 1px solid var(--cv-border);
    border-radius: 28px;
    backdrop-filter: blur(18px);
}

.hero-card,
.auth-card,
.panel-card { box-shadow: 0 24px 80px rgba(0, 0, 0, 0.34); }

.metric-card,
.stat-card {
    padding: 1.1rem;
    display: grid;
    gap: 0.35rem;
}

.metric-card {
    min-height: 122px;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.metric-card i,
.stat-card i,
.feature-card > i {
    color: var(--cv-brand-2);
    font-size: 1.4rem;
}

.metric-card strong,
.stat-card span {
    font-size: clamp(1.8rem, 4vw, 2.75rem);
    font-weight: 900;
    line-height: 1;
}

.metric-card small,
.stat-card small {
    color: var(--cv-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.72rem;
}

.activity-preview { display: grid; gap: 0.85rem; }
.preview-item {
    display: flex;
    gap: 0.85rem;
    align-items: center;
    padding: 1rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.preview-item p { margin: 0; color: var(--cv-text-muted); }

.icon-bubble {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    border-radius: 16px;
    display: inline-grid;
    place-items: center;
    color: #fff;
    background: rgba(22, 217, 227, 0.13);
    border: 1px solid rgba(22, 217, 227, 0.24);
}

.feature-card,
.step-card {
    padding: 1.5rem;
}
.feature-card h3,
.step-card h3 { font-size: 1.15rem; margin: 1rem 0 0.5rem; }
.feature-card p,
.step-card p { color: var(--cv-text-muted); margin-bottom: 0; }
.step-card span { color: var(--cv-brand-2); font-weight: 900; letter-spacing: 0.08em; }

.auth-page {
    background:
        radial-gradient(circle at top left, rgba(22, 217, 227, 0.16), transparent 32%),
        radial-gradient(circle at bottom right, rgba(255, 45, 85, 0.18), transparent 30%),
        var(--cv-bg);
}

.form-control,
.input-group-text {
    background-color: rgba(2, 6, 23, 0.78);
    border-color: rgba(255, 255, 255, 0.12);
    color: #fff;
}
.form-control:focus {
    background-color: rgba(2, 6, 23, 0.92);
    color: #fff;
    border-color: rgba(22, 217, 227, 0.65);
    box-shadow: 0 0 0 0.25rem rgba(22, 217, 227, 0.12);
}
.input-group-text { color: var(--cv-text-muted); }

.dashboard-page .container-fluid { max-width: 1440px; }
.status { color: #b8f7d4; }
.stat-card { min-height: 156px; }

.feed {
    display: grid;
    gap: 0.75rem;
    max-height: 520px;
    min-height: 260px;
    overflow: auto;
    padding-right: 0.2rem;
}

.item {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    padding: 0.9rem 1rem;
}
.item strong { color: #fff; }
.item small { color: var(--cv-text-muted); display: block; margin-top: 0.35rem; }

.pulse-dot { font-size: 0.55rem; }

@media (max-width: 991.98px) {
    .hero-section .min-vh-100 { min-height: auto !important; padding-top: 7rem !important; }
}

@media (max-width: 575.98px) {
    .display-3 { font-size: 2.6rem; }
    .hero-card,
    .auth-card,
    .panel-card,
    .feature-card,
    .step-card,
    .stat-card { border-radius: 22px; }
}

/* Polished dashboard shell */
.app-shell {
    background:
        radial-gradient(circle at 8% 10%, rgba(22, 217, 227, 0.16), transparent 25%),
        radial-gradient(circle at 85% 0%, rgba(255, 45, 85, 0.18), transparent 28%),
        linear-gradient(180deg, #070914 0%, #0b1020 100%);
}

.dashboard-layout {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 292px minmax(0, 1fr);
}

.dashboard-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    background: rgba(5, 8, 18, 0.88);
    border-right: 1px solid var(--cv-border);
    backdrop-filter: blur(20px);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #fff;
    text-decoration: none;
    font-size: 1.35rem;
    font-weight: 900;
    padding: 0.35rem 0.25rem 1rem;
}

.sidebar-nav {
    display: grid;
    gap: 0.45rem;
}

.sidebar-nav a {
    color: var(--cv-text-muted);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    border-radius: 18px;
    border: 1px solid transparent;
    font-weight: 700;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.075);
    border-color: rgba(255, 255, 255, 0.09);
}

.sidebar-nav i {
    width: 20px;
    color: var(--cv-brand-2);
}

.sidebar-account {
    margin-top: auto;
    padding: 1rem;
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.09);
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.avatar-circle {
    width: 46px;
    height: 46px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--cv-brand), var(--cv-brand-2));
    color: #fff;
    font-weight: 900;
    box-shadow: 0 14px 30px rgba(22, 217, 227, 0.18);
}

.sidebar-account strong,
.sidebar-account small {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-account small { color: var(--cv-text-muted); }

.dashboard-main {
    min-width: 0;
}

.dashboard-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    min-height: 86px;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: rgba(7, 9, 20, 0.76);
    border-bottom: 1px solid var(--cv-border);
    backdrop-filter: blur(18px);
}

.dashboard-content {
    max-width: 1520px;
    margin: 0 auto;
    padding: 1.5rem;
}

.eyebrow {
    color: var(--cv-brand-2);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.72rem;
    font-weight: 900;
}

.ls-wide { letter-spacing: 0.1em; }

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.55rem 0.85rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.06);
    color: var(--cv-text-muted);
    font-size: 0.86rem;
    font-weight: 800;
}
.status-ready { color: #b8f7d4; border-color: rgba(43, 255, 159, 0.24); background: rgba(43, 255, 159, 0.08); }
.status-error { color: #ff9ab0; border-color: rgba(255, 45, 85, 0.24); background: rgba(255, 45, 85, 0.08); }
.status-connecting { color: #ffe5a3; border-color: rgba(255, 193, 7, 0.25); background: rgba(255, 193, 7, 0.08); }

.dashboard-hero {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(340px, 0.85fr);
    gap: 1.25rem;
    align-items: stretch;
}

.hero-copy,
.connection-card,
.dashboard-panel {
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.88), rgba(15, 23, 42, 0.78));
    border: 1px solid var(--cv-border);
    border-radius: 30px;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(18px);
}

.hero-copy { padding: clamp(1.4rem, 4vw, 2.35rem); }
.connection-card { padding: 1.4rem; }

.connection-orb {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border-radius: 22px;
    color: #fff;
    background: linear-gradient(135deg, var(--cv-brand), var(--cv-brand-2));
    box-shadow: 0 16px 34px rgba(255, 45, 85, 0.2);
}

.connect-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.status-banner {
    padding: 0.95rem 1rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid rgba(255, 255, 255, 0.09);
    color: #b8f7d4;
    font-weight: 700;
}

.pro-stat {
    position: relative;
    overflow: hidden;
    min-height: 168px;
    padding: 1.25rem;
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.9), rgba(15, 23, 42, 0.72));
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
}
.pro-stat::after {
    content: '';
    position: absolute;
    width: 120px;
    height: 120px;
    right: -50px;
    bottom: -55px;
    border-radius: 999px;
    background: rgba(22, 217, 227, 0.12);
}
.stat-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 16px;
    background: rgba(22, 217, 227, 0.1);
    border: 1px solid rgba(22, 217, 227, 0.18);
}

.dashboard-panel {
    padding: 1.2rem;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.btn-soft {
    --bs-btn-color: #dbeafe;
    --bs-btn-bg: rgba(255, 255, 255, 0.075);
    --bs-btn-border-color: rgba(255, 255, 255, 0.1);
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: rgba(255, 255, 255, 0.12);
    --bs-btn-hover-border-color: rgba(255, 255, 255, 0.16);
}

.pro-feed {
    max-height: 600px;
    min-height: 440px;
    padding: 0.15rem 0.15rem 0.15rem 0;
}
.compact-feed {
    max-height: 600px;
    min-height: 440px;
}

.empty-state {
    height: 100%;
    min-height: 260px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 0.5rem;
    text-align: center;
    color: var(--cv-text-muted);
    border: 1px dashed rgba(255, 255, 255, 0.13);
    border-radius: 22px;
    background: rgba(255, 255, 255, 0.035);
}
.empty-state i { font-size: 2rem; color: var(--cv-brand-2); }
.empty-state strong { color: #fff; }
.empty-state span { max-width: 280px; }

.feed:not(.empty-feed) .empty-state { display: none; }

.item {
    display: grid;
    gap: 0.2rem;
    position: relative;
    padding-left: 1.15rem;
}
.item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 1rem;
    width: 4px;
    height: calc(100% - 2rem);
    border-radius: 999px;
    background: linear-gradient(180deg, var(--cv-brand-2), var(--cv-brand));
}

.detail-list {
    display: grid;
    gap: 0.75rem;
}
.detail-list div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.9rem 1rem;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid rgba(255, 255, 255, 0.08);
}
.detail-list span { color: var(--cv-text-muted); }
.detail-list strong { text-align: right; overflow-wrap: anywhere; }

.tip-list {
    list-style: none;
    display: grid;
    gap: 0.85rem;
    padding-left: 0;
    color: var(--cv-text-muted);
}
.tip-list li {
    display: flex;
    gap: 0.75rem;
    align-items: flex-start;
}
.tip-list i {
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 999px;
    background: rgba(22, 217, 227, 0.12);
    color: var(--cv-brand-2);
    font-size: 0.75rem;
}

@media (max-width: 1199.98px) {
    .dashboard-layout { grid-template-columns: 88px minmax(0, 1fr); }
    .dashboard-sidebar { padding: 1rem 0.75rem; align-items: center; }
    .sidebar-brand span:not(.brand-mark),
    .sidebar-nav span,
    .sidebar-account .min-w-0 { display: none; }
    .sidebar-nav a { justify-content: center; padding: 0.95rem; }
    .sidebar-account { padding: 0.6rem; }
    .dashboard-hero { grid-template-columns: 1fr; }
}

@media (max-width: 767.98px) {
    .dashboard-layout { display: block; }
    .dashboard-sidebar {
        position: static;
        height: auto;
        flex-direction: row;
        justify-content: space-between;
        border-right: 0;
        border-bottom: 1px solid var(--cv-border);
    }
    .sidebar-nav,
    .sidebar-account { display: none; }
    .dashboard-topbar { position: static; align-items: flex-start; flex-direction: column; }
    .dashboard-content { padding: 1rem; }
    .connect-actions .btn { width: 100%; }
    .panel-header { align-items: flex-start; flex-direction: column; }
    .detail-list div { align-items: flex-start; flex-direction: column; }
    .detail-list strong { text-align: left; }
}

/* Chat viewer pages */
.viewer-main {
    min-width: 0;
}

.viewer-content {
    width: 100%;
    max-width: none;
}

.viewer-grid {
    width: 100%;
    margin-left: 0;
    margin-right: 0;
}

.viewer-page {
    background:
        radial-gradient(circle at 10% 10%, rgba(22, 217, 227, 0.13), transparent 28%),
        radial-gradient(circle at 88% 0%, rgba(255, 45, 85, 0.12), transparent 24%),
        var(--viewer-bg, #050816);
    color: var(--viewer-text, #f8fafc);
}

.viewer-topbar {
    gap: 1rem;
}

.viewer-panel,
.viewer-preview-shell .viewer-panel {
    color: var(--viewer-text, #f8fafc);
    background: rgba(var(--viewer-panel-rgb, 17, 24, 39), var(--viewer-panel-opacity, 0.88));
    border: 1px solid color-mix(in srgb, var(--viewer-accent, #16d9e3) 20%, transparent);
    border-radius: calc(var(--viewer-radius, 18px) + 12px);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.3);
}

.viewer-panel-header .text-info,
.viewer-page .text-info {
    color: var(--viewer-accent, #16d9e3) !important;
}

.viewer-feed {
    gap: var(--viewer-gap, 12px);
    max-height: calc(100vh - 250px);
    min-height: calc(100vh - 250px);
    font-size: var(--viewer-font-size, 16px);
}

.viewer-feed .item {
    border-radius: var(--viewer-radius, 18px);
    color: var(--viewer-text, #f8fafc);
    background: rgba(255, 255, 255, 0.065);
    border-color: color-mix(in srgb, var(--viewer-accent, #16d9e3) 16%, transparent);
}

.viewer-feed .item::before {
    background: var(--viewer-accent, #16d9e3);
}

.viewer-feed .item strong,
.viewer-feed .empty-state strong {
    color: var(--viewer-text, #f8fafc);
}

.viewer-feed .item span,
.viewer-feed .item small,
.viewer-feed .empty-state span {
    color: color-mix(in srgb, var(--viewer-text, #f8fafc) 72%, transparent);
}

.viewer-feed .empty-state {
    min-height: calc(100vh - 300px);
    border-color: color-mix(in srgb, var(--viewer-accent, #16d9e3) 22%, transparent);
}

.viewer-feed .empty-state i {
    color: var(--viewer-accent, #16d9e3);
}

.compact-status {
    width: 100%;
}

.viewer-settings-form .form-label {
    color: #e2e8f0;
    font-weight: 800;
}

.viewer-settings-form .form-range::-webkit-slider-thumb {
    background: var(--cv-brand-2);
}

.viewer-settings-form .form-range::-moz-range-thumb {
    background: var(--cv-brand-2);
}

.code-textarea {
    min-height: 240px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 0.9rem;
}

.viewer-preview-shell {
    padding: 1rem;
    border-radius: 28px;
    border: 1px solid var(--cv-border);
    background: var(--viewer-bg, #050816);
    overflow: hidden;
}

.preview-panel {
    padding: 1rem;
    height: 100%;
}

.preview-feed {
    min-height: 360px;
    max-height: 360px;
}

@media (min-width: 1200px) {
    .viewer-content {
        padding: 1.25rem 1.5rem 1.5rem;
    }

    .viewer-grid > .col-xl-8 {
        width: 66.66666667%;
    }

    .viewer-grid > .col-xl-4 {
        width: 33.33333333%;
    }
}

@media (max-width: 767.98px) {
    .viewer-feed,
    .viewer-feed .empty-state {
        min-height: 420px;
        max-height: 420px;
    }

    .viewer-topbar .status-pill {
        width: 100%;
        justify-content: center;
    }
}

.chart-wrap {
    position: relative;
    min-height: 340px;
    height: 42vh;
    max-height: 480px;
    padding: 0.75rem;
}

.stats-empty {
    min-height: 340px;
}

.stats-detail-list.detail-list {
    gap: .75rem;
}

.stats-detail-list.detail-list div {
    background: rgba(255, 255, 255, .045);
    border: 1px solid rgba(255, 255, 255, .08);
    border-radius: 1.1rem;
    padding: .95rem 1rem;
}

.stats-detail-list strong {
    font-size: 1.15rem;
}

/* Standalone Open Chat View: no dashboard shell, no sidebar, no nav. */
.open-chat-standalone {
    min-height: 100vh;
    overflow: hidden;
}

.open-chat-stage {
    width: 100vw;
    min-height: 100vh;
    padding: 1rem;
}

.open-chat-grid {
    width: 100%;
    min-height: calc(100vh - 2rem);
    margin: 0;
}

.open-chat-column {
    min-height: calc(100vh - 2rem);
}

.open-chat-standalone .viewer-panel {
    min-height: calc(100vh - 2rem);
}

.open-chat-standalone .viewer-feed {
    min-height: calc(100vh - 130px);
    max-height: calc(100vh - 130px);
}

.open-chat-standalone .viewer-feed .empty-state {
    min-height: calc(100vh - 180px);
}

@media (min-width: 1200px) {
    .open-chat-grid > .col-xl-8 {
        flex: 0 0 auto;
        width: 66.66666667%;
    }

    .open-chat-grid > .col-xl-4 {
        flex: 0 0 auto;
        width: 33.33333333%;
    }
}

@media (max-width: 1199.98px) {
    .open-chat-standalone {
        overflow: auto;
    }

    .open-chat-column,
    .open-chat-standalone .viewer-panel {
        min-height: 560px;
    }

    .open-chat-standalone .viewer-feed,
    .open-chat-standalone .viewer-feed .empty-state {
        min-height: 430px;
        max-height: 430px;
    }
}
