/* ═══════════════════════════════════════════════════════════
   Excel Tutor — Premium Dark UI
   God-tier aesthetics: glassmorphism, ambient orbs,
   micro-animations, gradients, and a living interface.
   ═══════════════════════════════════════════════════════════ */

/* ── Design Tokens ────────────────────────────────────── */
:root {
    /* Backgrounds */
    --bg-void: #06080d;
    --bg-primary: #0b0e17;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2035;
    --bg-hover: #1f2a42;
    --bg-active: #253352;

    /* Glassmorphism surfaces */
    --glass: rgba(17, 24, 39, 0.65);
    --glass-heavy: rgba(17, 24, 39, 0.85);
    --glass-light: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.06);
    --glass-shine: rgba(255, 255, 255, 0.08);

    /* Text */
    --text-primary: #f0f2f5;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-dim: #475569;

    /* Accent palette */
    --accent: #6366f1;
    --accent-light: #818cf8;
    --accent-lighter: #a5b4fc;
    --accent-glow: rgba(99, 102, 241, 0.2);
    --accent-subtle: rgba(99, 102, 241, 0.08);

    --cyan: #22d3ee;
    --cyan-glow: rgba(34, 211, 238, 0.15);

    --green: #34d399;
    --green-glow: rgba(52, 211, 153, 0.12);
    --green-bg: rgba(52, 211, 153, 0.08);

    --amber: #fbbf24;
    --amber-glow: rgba(251, 191, 36, 0.12);

    --rose: #f43f5e;
    --rose-glow: rgba(244, 63, 94, 0.15);

    /* Gradients */
    --gradient-brand: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    --gradient-emerald: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    --gradient-sunset: linear-gradient(135deg, #f43f5e 0%, #fb923c 100%);
    --gradient-ocean: linear-gradient(135deg, #6366f1 0%, #22d3ee 100%);
    --gradient-mesh: radial-gradient(ellipse at 20% 50%, rgba(99, 102, 241, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(34, 211, 238, 0.05) 0%, transparent 50%),
        radial-gradient(ellipse at 40% 80%, rgba(168, 85, 247, 0.05) 0%, transparent 50%);

    /* Borders & Shadows */
    --border: rgba(255, 255, 255, 0.06);
    --border-light: rgba(255, 255, 255, 0.1);
    --border-accent: rgba(99, 102, 241, 0.3);

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 20px rgba(99, 102, 241, 0.15);
    --shadow-send: 0 4px 16px rgba(99, 102, 241, 0.4);

    /* Radii */
    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 16px;
    --r-xl: 20px;
    --r-2xl: 24px;
    --r-full: 999px;

    /* Layout */
    --sidebar-w: 310px;
    --topbar-h: 64px;

    /* Typography */
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;

    /* Animation */
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --ease-in: cubic-bezier(0.4, 0, 1, 1);
    --ease-out: cubic-bezier(0, 0, 0.2, 1);
    --bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --dur: 0.25s;
    --dur-slow: 0.5s;
}

/* ── Reset ────────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg-void);
    color: var(--text-primary);
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: var(--accent-light);
    text-decoration: none;
    transition: color var(--dur);
}

a:hover {
    color: var(--accent-lighter);
    text-decoration: underline;
}

::selection {
    background: var(--accent);
    color: #fff;
}

::-webkit-scrollbar {
    width: 5px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ═══════════ AMBIENT BACKGROUND ═══════════ */
.ambient-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.4;
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.3), transparent 70%);
    top: -100px;
    left: -100px;
    animation-duration: 25s;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(34, 211, 238, 0.2), transparent 70%);
    bottom: -50px;
    right: -50px;
    animation-duration: 30s;
    animation-delay: -5s;
}

.orb-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.2), transparent 70%);
    top: 40%;
    left: 50%;
    animation-duration: 22s;
    animation-delay: -10s;
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    25% {
        transform: translate(40px, -30px) scale(1.05);
    }

    50% {
        transform: translate(-20px, 40px) scale(0.95);
    }

    75% {
        transform: translate(30px, 20px) scale(1.02);
    }
}

.grid-overlay {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
    background-size: 60px 60px;
    mask-image: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.4) 0%, transparent 70%);
    -webkit-mask-image: radial-gradient(ellipse at center, rgba(0, 0, 0, 0.4) 0%, transparent 70%);
}

/* ═══════════ SIDEBAR ═══════════ */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--glass-heavy);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 100;
    position: relative;
    transition: transform 0.35s var(--ease);
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 1px;
    height: 100%;
    background: linear-gradient(to bottom, var(--accent-glow), transparent 30%, transparent 70%, var(--cyan-glow));
}

.sidebar-header {
    padding: 22px 18px 16px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.logo-icon-wrap {
    position: relative;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon {
    font-size: 28px;
    position: relative;
    z-index: 1;
}

.logo-pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--accent-glow);
    animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.4;
    }

    50% {
        transform: scale(1.3);
        opacity: 0;
    }
}

.logo h1 {
    font-size: 1.2rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    background: var(--gradient-ocean);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-tagline {
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--r-md);
    border: none;
    font-family: var(--font);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--dur) var(--ease);
    letter-spacing: 0.01em;
}

.btn-new {
    width: 100%;
    justify-content: center;
    background: var(--glass-light);
    color: var(--accent-light);
    border: 1px dashed rgba(99, 102, 241, 0.3);
    position: relative;
    overflow: hidden;
}

.btn-new::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gradient-brand);
    opacity: 0;
    transition: opacity var(--dur);
}

.btn-new:hover {
    border-color: var(--accent);
    border-style: solid;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.btn-new:hover::before {
    opacity: 0.15;
}

.btn-new svg,
.btn-new span {
    position: relative;
    z-index: 1;
}

/* Sidebar sections */
.sidebar-section {
    padding: 14px 18px 8px;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.sidebar-section-progress {
    flex: 0;
    border-top: 1px solid var(--border);
    padding-top: 14px;
}

.sidebar-title {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sidebar-title svg {
    opacity: 0.5;
}

/* Session list */
.session-list {
    list-style: none;
}

.session-list li {
    padding: 10px 12px;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: all var(--dur) var(--ease);
    font-size: 0.82rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    position: relative;
}

.session-list li:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.session-list li.active {
    background: var(--accent-subtle);
    color: var(--text-primary);
    border-left: 2px solid var(--accent);
}

.session-list .empty-state {
    color: var(--text-dim);
    font-style: italic;
    font-size: 0.78rem;
    cursor: default;
    padding: 12px;
}

.session-list .empty-state:hover {
    background: none;
}

.session-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.session-delete {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 2px 6px;
    border-radius: 6px;
    opacity: 0;
    transition: all var(--dur);
}

.session-list li:hover .session-delete {
    opacity: 1;
}

.session-delete:hover {
    background: var(--rose-glow);
    color: var(--rose);
}

/* Course list */
.course-list {
    list-style: none;
}

.course-item {
    padding: 10px 12px;
    border-radius: var(--r-sm);
    cursor: pointer;
    transition: all var(--dur) var(--ease);
    margin-bottom: 2px;
    border: 1px solid transparent;
}

.course-item:hover {
    background: var(--bg-hover);
    border-color: var(--glass-border);
}

.course-item-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}

.course-item-meta {
    font-size: 0.68rem;
    color: var(--text-dim);
    margin-top: 2px;
    text-transform: capitalize;
}

.course-lessons {
    list-style: none;
    margin-left: 12px;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.4s var(--ease);
    margin-top: 0;
}

.course-item.expanded .course-lessons {
    max-height: 500px;
    margin-top: 6px;
}

.lesson-item {
    padding: 7px 10px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--dur) var(--ease);
    display: flex;
    align-items: center;
    gap: 8px;
}

.lesson-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.lesson-item .check {
    color: var(--text-dim);
    font-size: 0.8rem;
    transition: color var(--dur);
}

.lesson-item .check.done {
    color: var(--green);
}

/* Progress widget — ring style */
.progress-widget {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 4px 0;
}

.progress-ring-wrap {
    position: relative;
    width: 64px;
    height: 64px;
    flex-shrink: 0;
}

.progress-ring {
    transform: rotate(-90deg);
}

.progress-ring-bg {
    fill: none;
    stroke: var(--bg-tertiary);
    stroke-width: 4;
}

.progress-ring-fill {
    fill: none;
    stroke: url(#progressGradient);
    stroke-width: 4;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s var(--ease);
    filter: drop-shadow(0 0 4px rgba(99, 102, 241, 0.3));
    stroke: var(--accent-light);
}

.progress-percent {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
}

.progress-details {
    flex: 1;
    min-width: 0;
}

.progress-text {
    font-size: 0.72rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.progress-bar-track {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-tertiary);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--gradient-ocean);
    transition: width 0.8s var(--ease);
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.3);
}

/* Sidebar footer */
.sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid var(--border);
}

.sidebar-footer-inner {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 8px var(--green);
    }

    50% {
        opacity: 0.6;
        box-shadow: 0 0 16px var(--green);
    }
}

.sidebar-footer p {
    font-size: 0.65rem;
    color: var(--text-dim);
    font-weight: 500;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s var(--ease);
}

.sidebar-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ═══════════ MAIN AREA ═══════════ */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 1;
    background: var(--gradient-mesh);
}

/* Top bar */
.topbar {
    height: var(--topbar-h);
    min-height: var(--topbar-h);
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    background: var(--glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    gap: 12px;
    z-index: 10;
}

.topbar-center {
    flex: 1;
    min-width: 0;
}

.topbar-status {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 2px;
}

.status-indicator {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}

#topbarStatus {
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--green);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.chat-title {
    font-size: 0.95rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--r-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--dur) var(--ease);
    position: relative;
}

.btn-icon:hover {
    background: var(--glass-light);
    color: var(--text-primary);
    transform: scale(1.05);
}

.btn-icon.active {
    color: var(--accent-light);
    background: var(--accent-subtle);
}

.menu-toggle {
    display: none;
}

/* ═══════════ CHAT MESSAGES ═══════════ */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0;
    scroll-behavior: smooth;
}

/* ── Welcome screen ── */
.welcome {
    text-align: center;
    padding: 50px 24px 40px;
    max-width: 680px;
    margin: 0 auto;
    animation: fadeInUp 0.7s var(--ease);
    position: relative;
}

.welcome-glow {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    height: 300px;
    background: radial-gradient(ellipse, rgba(99, 102, 241, 0.12), transparent 60%);
    pointer-events: none;
}

.welcome-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 14px;
    border-radius: var(--r-full);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--accent-light);
    background: var(--accent-subtle);
    border: 1px solid rgba(99, 102, 241, 0.2);
    margin-bottom: 24px;
    position: relative;
}

.welcome-icon {
    position: relative;
    width: 96px;
    height: 96px;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.welcome-icon>span {
    font-size: 56px;
    position: relative;
    z-index: 1;
}

.welcome-icon-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid rgba(99, 102, 241, 0.2);
    animation: ringPulse 3s ease-in-out infinite;
}

.welcome-icon-ring.ring-2 {
    inset: -12px;
    border-color: rgba(34, 211, 238, 0.1);
    animation-delay: -1.5s;
    animation-duration: 4s;
}

@keyframes ringPulse {

    0%,
    100% {
        transform: scale(1);
        opacity: 0.6;
    }

    50% {
        transform: scale(1.15);
        opacity: 0;
    }
}

.welcome h2 {
    font-size: 1.75rem;
    font-weight: 800;
    margin-bottom: 12px;
    letter-spacing: -0.03em;
}

.gradient-text {
    background: var(--gradient-ocean);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome>p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 32px;
    font-size: 0.95rem;
    max-width: 440px;
    margin-left: auto;
    margin-right: auto;
}

/* Feature cards */
.feature-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 32px;
}

.feature-card {
    padding: 20px 14px;
    border-radius: var(--r-lg);
    background: var(--glass);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    transition: all 0.3s var(--ease);
    cursor: default;
}

.feature-card:hover {
    border-color: var(--border-accent);
    transform: translateY(-4px);
    box-shadow: var(--shadow-glow);
}

.feature-icon {
    font-size: 28px;
    margin-bottom: 10px;
}

.feature-card h3 {
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.feature-card p {
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Quick action chips */
.quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.chip {
    padding: 9px 18px;
    border-radius: var(--r-full);
    border: 1px solid var(--glass-border);
    background: var(--glass);
    backdrop-filter: blur(8px);
    color: var(--text-secondary);
    font-family: var(--font);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s var(--ease);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.chip-icon {
    font-size: 0.9rem;
}

.chip:hover {
    border-color: var(--accent);
    color: var(--accent-light);
    background: var(--accent-subtle);
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

/* ── Message Bubbles ── */
.message-row {
    display: flex;
    padding: 8px 28px;
    gap: 12px;
    animation: messageIn 0.4s var(--ease);
}

.message-row.user {
    justify-content: flex-end;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 2px;
    position: relative;
}

.message-row.assistant .message-avatar {
    background: var(--accent-subtle);
    border: 1px solid rgba(99, 102, 241, 0.2);
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.1);
}

.message-row.user .message-avatar {
    background: var(--green-bg);
    border: 1px solid rgba(52, 211, 153, 0.2);
}

.message-bubble {
    max-width: 720px;
    padding: 16px 20px;
    border-radius: var(--r-xl);
    line-height: 1.7;
    font-size: 0.9rem;
    position: relative;
}

.message-row.user .message-bubble {
    background: var(--gradient-brand);
    color: #fff;
    border-bottom-right-radius: 6px;
    box-shadow: var(--shadow-send);
}

.message-row.assistant .message-bubble {
    background: var(--glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-bottom-left-radius: 6px;
    box-shadow: var(--shadow-sm);
}

/* Bubble content */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3 {
    margin: 14px 0 6px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.message-bubble h1 {
    font-size: 1.1rem;
}

.message-bubble h2 {
    font-size: 1rem;
}

.message-bubble h3 {
    font-size: 0.92rem;
    color: var(--accent-lighter);
}

.message-bubble p {
    margin: 6px 0;
}

.message-bubble ul,
.message-bubble ol {
    margin: 6px 0;
    padding-left: 20px;
}

.message-bubble li {
    margin: 3px 0;
}

.message-bubble code {
    background: rgba(0, 0, 0, 0.35);
    padding: 3px 7px;
    border-radius: 5px;
    font-size: 0.83em;
    font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', Consolas, monospace;
    color: var(--cyan);
}

.message-bubble pre {
    background: rgba(0, 0, 0, 0.35);
    border-radius: var(--r-md);
    padding: 14px 18px;
    overflow-x: auto;
    margin: 10px 0;
    border: 1px solid var(--glass-border);
}

.message-bubble pre code {
    background: none;
    padding: 0;
    color: var(--text-primary);
}

.message-bubble table {
    border-collapse: collapse;
    margin: 10px 0;
    width: 100%;
    font-size: 0.82rem;
}

.message-bubble th,
.message-bubble td {
    padding: 8px 12px;
    border: 1px solid var(--border-light);
    text-align: left;
}

.message-bubble th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--accent-lighter);
}

.message-bubble strong {
    font-weight: 700;
    color: var(--text-primary);
}

.message-bubble blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 14px;
    margin: 10px 0;
    color: var(--text-secondary);
    font-style: italic;
}

/* Message meta */
.message-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    font-size: 0.68rem;
    color: var(--text-dim);
}

.source-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: var(--r-full);
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.source-badge.database {
    background: var(--green-bg);
    color: var(--green);
    border: 1px solid rgba(52, 211, 153, 0.15);
}

.source-badge.ai {
    background: var(--accent-subtle);
    color: var(--accent-light);
    border: 1px solid rgba(99, 102, 241, 0.15);
}

.suggestion-hint {
    margin-top: 12px;
    padding: 10px 14px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(34, 211, 238, 0.05));
    border-radius: var(--r-md);
    font-size: 0.8rem;
    color: var(--accent-lighter);
    border-left: 3px solid var(--accent);
    backdrop-filter: blur(4px);
}

/* ═══════════ TYPING INDICATOR ═══════════ */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 28px;
}

.typing-indicator.hidden {
    display: none;
}

.typing-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-subtle);
    border: 1px solid rgba(99, 102, 241, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.typing-bubble {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--r-xl);
    border-bottom-left-radius: 6px;
    backdrop-filter: blur(10px);
}

.typing-dots {
    display: flex;
    gap: 5px;
}

.typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent-light);
    animation: dotBounce 1.4s ease infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.15s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes dotBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

.typing-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* ═══════════ INPUT BAR ═══════════ */
.input-bar {
    padding: 14px 28px 18px;
    background: linear-gradient(to top, var(--bg-void) 0%, transparent 100%);
    position: relative;
}

.input-bar::before {
    content: '';
    position: absolute;
    top: -40px;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to top, var(--bg-void), transparent);
    pointer-events: none;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--r-xl);
    padding: 6px 8px 6px 20px;
    backdrop-filter: blur(16px);
    transition: all 0.3s var(--ease);
    position: relative;
}

.input-wrapper::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: var(--r-xl);
    background: var(--gradient-ocean);
    opacity: 0;
    transition: opacity 0.3s var(--ease);
    z-index: -1;
    padding: 1px;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
}

.input-wrapper:focus-within {
    border-color: transparent;
    box-shadow: 0 0 24px rgba(99, 102, 241, 0.12);
}

.input-wrapper:focus-within::before {
    opacity: 1;
}

.input-wrapper textarea {
    flex: 1;
    border: none;
    background: none;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
    line-height: 1.5;
    resize: none;
    outline: none;
    padding: 10px 0;
    max-height: 120px;
}

.input-wrapper textarea::placeholder {
    color: var(--text-dim);
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Mic button */
.mic-btn {
    color: var(--text-secondary);
    position: relative;
    overflow: visible;
}

.mic-waves {
    position: absolute;
    inset: -4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
}

.mic-waves span {
    position: absolute;
    border-radius: 50%;
    border: 2px solid var(--rose);
    width: 100%;
    height: 100%;
    animation: micWave 1.5s ease-out infinite;
}

.mic-waves span:nth-child(2) {
    animation-delay: 0.3s;
}

.mic-waves span:nth-child(3) {
    animation-delay: 0.6s;
}

@keyframes micWave {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }

    100% {
        transform: scale(2.2);
        opacity: 0;
    }
}

.mic-btn.recording {
    color: var(--rose);
}

.mic-btn.recording .mic-svg {
    animation: micPulse 1s ease infinite;
}

.mic-btn.recording .mic-waves {
    opacity: 1;
}

@keyframes micPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.15);
    }
}

/* Send button */
.btn-send {
    width: 40px;
    height: 40px;
    border-radius: var(--r-md);
    border: none;
    background: var(--gradient-brand);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s var(--ease);
    box-shadow: var(--shadow-send);
    position: relative;
    overflow: hidden;
}

.btn-send::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 0%, rgba(255, 255, 255, 0.15) 50%, transparent 100%);
    transform: translateX(-100%);
    transition: transform 0.5s;
}

.btn-send:hover:not(:disabled) {
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(99, 102, 241, 0.5);
}

.btn-send:hover:not(:disabled)::before {
    transform: translateX(100%);
}

.btn-send:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    box-shadow: none;
}

.input-hint {
    text-align: center;
    font-size: 0.65rem;
    color: var(--text-dim);
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

kbd {
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--glass-light);
    border: 1px solid var(--glass-border);
    font-family: var(--font);
    font-size: inherit;
    color: var(--text-muted);
}

/* ═══════════ MODAL ═══════════ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.25s var(--ease);
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--glass-heavy);
    backdrop-filter: blur(24px);
    border: 1px solid var(--glass-border);
    border-radius: var(--r-2xl);
    width: 92%;
    max-width: 640px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg), 0 0 60px rgba(99, 102, 241, 0.08);
    animation: modalIn 0.35s var(--bounce);
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-icon {
    font-size: 1.3rem;
}

.modal-header h3 {
    font-size: 1.05rem;
    font-weight: 700;
}

.btn-close {
    font-size: 1.5rem;
    color: var(--text-muted);
    width: 36px;
    height: 36px;
}

.btn-close:hover {
    background: var(--rose-glow);
    color: var(--rose);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    line-height: 1.75;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.modal-footer {
    display: flex;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    justify-content: flex-end;
}

.btn-primary {
    background: var(--gradient-brand);
    color: #fff;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.4);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-light);
}

.btn-outline:hover {
    background: var(--glass-light);
    color: var(--text-primary);
}

/* ═══════════ ANIMATIONS ═══════════ */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(24px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ═══════════ RESPONSIVE ═══════════ */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .menu-toggle {
        display: flex;
    }

    .message-row {
        padding: 6px 14px;
    }

    .input-bar {
        padding: 12px 14px 16px;
    }

    .input-hint {
        display: none;
    }

    .topbar {
        padding: 0 14px;
    }

    .welcome {
        padding: 36px 16px 30px;
    }

    .welcome h2 {
        font-size: 1.4rem;
    }

    .feature-cards {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .feature-card {
        padding: 14px 16px;
        text-align: left;
        display: flex;
        gap: 14px;
        align-items: center;
    }

    .feature-icon {
        font-size: 24px;
        margin-bottom: 0;
    }

    .feature-card h3 {
        margin-bottom: 0;
    }
}

@media (max-width: 480px) {
    .message-bubble {
        max-width: 92%;
        font-size: 0.85rem;
        padding: 13px 16px;
    }

    .quick-actions {
        flex-direction: column;
    }

    .chip {
        width: 100%;
        justify-content: center;
    }

    .modal {
        width: 96%;
        border-radius: var(--r-xl);
    }
}