:root {
    --surface-0: #08090c;
    --surface-1: #0e1018;
    --surface-2: #141722;
    --surface-3: #1a1e2e;
    --line: rgba(255, 255, 255, 0.07);
    --line-strong: rgba(255, 255, 255, 0.12);
    --txt: #edeef2;
    --txt-secondary: #8a8f9e;
    --txt-muted: #555a68;
    --brand-muted: rgba(0, 46, 192, 0.1);
    --brand-faint: rgba(0, 46, 192, 0.05);
    --card-bg: #0e1018;
    --card-border: rgba(255, 255, 255, 0.06);
    --card-hover-border: rgba(0, 46, 192, 0.25);
    --input-bg: #141722;
    --input-focus-bg: #0e1018;
    --hover-bg: rgba(255, 255, 255, 0.05);
    --sidebar-active-bg: #002EC0;
    --sidebar-active-hover: #0035d4;
    --msg-assistant-bg: #141722;
    --msg-assistant-color: #c5c9d4;
    --msg-assistant-border: rgba(255, 255, 255, 0.06);
    --noise-opacity: 0.018;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --overlay-bg: rgba(0, 0, 0, 0.85);
    --scrollbar-thumb: rgba(255, 255, 255, 0.06);
    --scrollbar-thumb-hover: rgba(255, 255, 255, 0.14);
    --table-header-bg: #111420;
    --sweep-assistant: rgba(0, 46, 192, 0.12);
    --sweep-user: rgba(255, 255, 255, 0.1);
}

:root.light {
    --surface-0: #f8f9fa;
    --surface-1: #ffffff;
    --surface-2: #f0f1f3;
    --surface-3: #e5e7eb;
    --line: rgba(0, 0, 0, 0.08);
    --line-strong: rgba(0, 0, 0, 0.13);
    --txt: #111827;
    --txt-secondary: #6b7280;
    --txt-muted: #9ca3af;
    --brand-muted: rgba(0, 46, 192, 0.08);
    --brand-faint: rgba(0, 46, 192, 0.04);
    --card-bg: #ffffff;
    --card-border: rgba(0, 0, 0, 0.08);
    --card-hover-border: rgba(0, 46, 192, 0.3);
    --input-bg: #f0f1f3;
    --input-focus-bg: #ffffff;
    --hover-bg: rgba(0, 0, 0, 0.04);
    --sidebar-active-bg: #002EC0;
    --sidebar-active-hover: #0035d4;
    --msg-assistant-bg: #f0f1f3;
    --msg-assistant-color: #374151;
    --msg-assistant-border: rgba(0, 0, 0, 0.06);
    --noise-opacity: 0;
    --shadow-color: rgba(0, 0, 0, 0.08);
    --overlay-bg: rgba(255, 255, 255, 0.85);
    --scrollbar-thumb: rgba(0, 0, 0, 0.1);
    --scrollbar-thumb-hover: rgba(0, 0, 0, 0.2);
    --table-header-bg: #f3f4f6;
    --sweep-assistant: rgba(0, 46, 192, 0.08);
    --sweep-user: rgba(255, 255, 255, 0.15);
}

body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none;
    opacity: var(--noise-opacity);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 200px 200px;
}

.theme-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 0.5rem;
    border: 1px solid var(--line-strong);
    background: var(--hover-bg);
    color: var(--txt-secondary);
    cursor: pointer;
    transition: all 200ms cubic-bezier(0.32, 0.72, 0, 1);
    flex-shrink: 0;
}

.theme-toggle-btn:hover {
    color: var(--txt);
    border-color: rgba(0, 46, 192, 0.3);
    background: var(--brand-muted);
}

.theme-icon-moon {
    display: none;
}

.theme-icon-sun {
    display: block;
}

:root.light .theme-icon-moon,
.light .theme-icon-moon {
    display: block;
}

:root.light .theme-icon-sun,
.light .theme-icon-sun {
    display: none;
}

@keyframes toastIn {
    from {
        opacity: 0;
        transform: translateX(16px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes toastOut {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
        max-height: 80px;
        margin-bottom: 8px;
    }

    to {
        opacity: 0;
        transform: translateX(16px) scale(0.96);
        max-height: 0;
        margin-bottom: 0;
    }
}

#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.8125rem;
    font-weight: 500;
    min-width: 260px;
    max-width: 380px;
    pointer-events: auto;
    animation: toastIn 350ms cubic-bezier(0.32, 0.72, 0, 1) both;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--line-strong);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.08),
        0 4px 16px rgba(0, 0, 0, 0.18),
        0 8px 32px rgba(0, 0, 0, 0.12);
    color: var(--txt);
}

.toast.toast--success {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.25);
}

.toast.toast--error {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.25);
}

.toast.toast--info {
    background: var(--card-bg);
}

.toast.toast--dismissing {
    animation: toastOut 300ms cubic-bezier(0.32, 0.72, 0, 1) forwards;
    overflow: hidden;
}

.toast-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
}

.toast--success .toast-icon {
    color: #22c55e;
}

.toast--error .toast-icon {
    color: #ef4444;
}

.toast--info .toast-icon {
    color: var(--txt-secondary);
}
