/* 1. Import JetBrains Mono */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500&display=swap');

:root {
    --bg-dark: #0a0a0c;
    --bg-sidebar: rgba(15, 15, 18, 0.85);
    --glass-bg: #16161a; /* Solid, no hologram */
    --glass-border: #2a2a2e;
    --text-primary: #f3f3f3;
    --text-secondary: #9ca3af;
    --accent: #00e5ff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background-color: var(--bg-dark);
    /* Subtle mesh gradient for depth, not glow */
background-image: 
        radial-gradient(circle at 50% -20%, rgba(0, 229, 255, 0.15), transparent 70%),
        radial-gradient(at 0% 0%, rgba(0, 229, 255, 0.05) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(0, 85, 255, 0.05) 0px, transparent 50%);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace; /* Unified Font */
    height: 100vh;
    display: flex;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* 2. Keep assistant content as the "Fluent Document" */
.assistant-message .message-content {
    background: transparent !important;
    border: none !important;
    padding: 0px !important;
    line-height: 1.8;
}
#chat-stream {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    overflow-y: auto;
    position: relative;
}

#welcome-screen {
    flex: 1; /* Takes up all available space */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
/* 1. Ensure the container is fixed and doesn't squish */
.avatar {
    width: 32px; /* Fixed size */
    height: 32px;
    flex-shrink: 0; /* Prevents the layout from breaking */
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 4px; /* Aligns with the first line of text */
}

/* 2. Force the image to fill the container perfectly */
.avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Ensures the logo isn't stretched/distorted */
    display: block;
}

#welcome-text {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 300;
    font-size: 1.5rem;
    color: var(--text-secondary); /* A bit lighter/softer than primary text */
    text-align: center;
}

/* Class to hide it smoothly when a message is sent */
/* Make sure .hidden is forceful */
.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}
/* Fluent, rounded tags */
/* 1. The Assistant: Your "Research Document" flow (Invisible container) */
.assistant-message .message-content {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    line-height: 1.8;
    color: var(--text-primary);
    max-width: 800px;
}

/* 2. The User: Your "Interaction Bubble" (Glass container) */
.user-message .message-content {
    background: rgba(255, 255, 255, 0.05) !important;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 12px !important;
    padding: 12px 20px !important;
    width: fit-content;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* 3. Keep the Tag style exactly as you have it */
.tag {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 0.70rem;
    font-weight: 500;
    text-transform: uppercase;
    background: rgba(0, 229, 255, 0.08);
    color: var(--accent);
    border: 1px solid rgba(0, 229, 255, 0.2);
    margin-right: 8px;
    margin-bottom: 12px;
}
/* The Observation Section (The visual separator) */
.message-content hr {
    border: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 24px 0;
}

/* Fix the list hierarchy */
.message-content ol, 
.message-content ul {
    margin: 15px 0 15px 25px; /* Adds space and indents the list */
    padding-left: 10px;
}

.message-content li {
    margin-bottom: 12px; /* Adds breathing room between points */
    padding-left: 5px;
    color: var(--text-primary);
}

/* Ensure user messages and assistant messages align well */
.message {
    display: flex;
    width: 100%;
}

/* Specific styling for Math/Code to fit inside the glass boxes */
.math-highlight-block, pre, code {
    background: rgba(0, 0, 0, 0.2) !important; /* Darker interior for contrast */
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    border-radius: 10px !important;
    padding: 16px !important;
}
/* Ensure all images/charts stay inside their container */
.message-content img, 
.message-content canvas {
    max-width: 100%;
    height: auto;
    border-radius: 8px; /* Smooth edges for the diagram */
    display: block;
    margin: 0 auto 20px auto; /* Center diagram and add breathing room below */
}

/* App Layout & Sidebar Animations */
.app-layout { display: flex; width: 100%; height: 100%; }
/* Smooth fade-and-slide entry for new messages */
.message {
    animation: messageReveal 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    opacity: 0;
}

@keyframes messageReveal {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.sidebar {
    width: 280px;
    background: rgba(12, 12, 16, 0.6) !important; /* Semi-transparent dark */
    backdrop-filter: blur(24px); /* The Fluent glass effect */
    -webkit-backdrop-filter: blur(24px);
    border-right: 1px solid rgba(255, 255, 255, 0.04) !important;
    display: flex;
    flex-direction: column;
    padding: 20px;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
    z-index: 100;
}

.sidebar.collapsed {
    transform: translateX(-100%);
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* Sidebar Header Layout */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: center; /* This forces the group into the exact middle */
    gap: 12px;
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 10px;
}
/* Constrain the logo specifically for the sidebar */
.sidebar-logo-wrapper {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-logo {
    width: 100%;
    height: 100%;
    object-fit: contain;
}


/* App Title Styling */
.app-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.brand { display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 16px; letter-spacing: 1px;}
.brand-icon { color: var(--accent); font-size: 24px; filter: drop-shadow(0 0 8px var(--accent-glow)); }

.new-chat-btn {
    /* Fluent Glass Base */
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    
    /* Layout */
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    margin: 0 20px 24px 20px; /* Aligns with sidebar padding */
    width: calc(100% - 40px);
}

.new-chat-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.new-chat-btn i {
    font-size: 0.85rem;
    color: var(--accent);
}
.history-list { flex: 1; overflow-y: auto; }
.history-list::-webkit-scrollbar { width: 0; }
.history-label { font-size: 11px; color: var(--text-secondary); margin-bottom: 12px; padding-left: 12px; text-transform: uppercase; letter-spacing: 1px;}

/* --- Sidebar History Actions --- */
.history-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    overflow: hidden;
}

.history-title {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
}

.history-title span {
    text-overflow: ellipsis;
    overflow: hidden;
}

.history-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.history-item:hover .history-actions {
    opacity: 1;
    transform: translateX(0);
}

.history-action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.history-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.history-action-btn.danger:hover {
    background: rgba(255, 85, 85, 0.15);
    color: #ff5555;
}

/* Main Content Area */
.main-content {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    overflow: hidden; /* Strict containment */
    position: relative;
}

.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    height: 64px;
    width: 100%;
    
    /* Fluent Glass Configuration */
    background: rgba(10, 10, 12, 0.6);        /* Dark, semi-transparent base */
    backdrop-filter: blur(20px);              /* The blur factor */
    -webkit-backdrop-filter: blur(20px);
    
    /* Subtle gloss/gradient top edge */
    background-image: linear-gradient(to bottom, rgba(255,255,255,0.03), transparent);
    
    /* Crisp glass border */
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    
    /* Positioning */
    z-index: 50;
    transition: background 0.3s ease;
}

.nav-title { font-size: 14px; font-weight: 500; color: var(--text-secondary); margin-left: 12px; }
.nav-left { 
    display: flex; 
    align-items: center; 
    gap: 12px; /* Adds space between the icon and the title chip */
}
/* Animated Chat Stream */
.chat-stream {
    flex: 1;
    overflow-y: auto;
    width: 100%;
    /* This ensures it doesn't overflow the parent */
    height: 100%; 
    padding-top: 20px;
    display: flex;
    flex-direction: column;
}
.chat-stream::-webkit-scrollbar { width: 0; }

/* The Message Slide-in Animation */
@keyframes slideUpFade {
    0% { opacity: 0; transform: translateY(20px) scale(0.98); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

.message {
    display: flex;
    gap: 20px;
    max-width: 850px;
    margin: 0 auto;
    width: 100%;
    animation: slideUpFade 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.user-message {
    justify-content: flex-end; /* Pushes user bubble to the right */
}


.avatar {
    width: 38px; height: 38px;
    border-radius: 12px;
    background: var(--glass-highlight);
    border: 1px solid var(--glass-border);
    display: flex; justify-content: center; align-items: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.assistant-message {
    justify-content: flex-start; /* Pushes assistant bubble to the left */
}

.assistant-message .avatar i { color: var(--accent); font-size: 18px; }

.message-content {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text-primary);
    padding-top: 6px;
    width: 100%;
    transition: opacity 0.2s ease;
    opacity: 1;
}

.user-message .message-content {
    background: rgba(255, 255, 255, 0.05);
    padding: 16px 24px;
    border-radius: 24px;
    border-bottom-right-radius: 6px;
    border: 1px solid var(--glass-border);
    max-width: 80%;
}

/* Markdown & Code Refinements */
.message-content p { margin-bottom: 16px; }
.message-content p:last-child { margin-bottom: 0; }

.message-content pre {
    background: #0d1117;
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    margin: 16px 0;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.message-content pre code {
    display: block; padding: 20px; overflow-x: auto;
    font-family: 'JetBrains Mono', monospace; font-size: 13px; line-height: 1.6;
}

.message-content p code {
    background: var(--glass-highlight);
    padding: 4px 8px; border-radius: 6px;
    font-family: 'JetBrains Mono', monospace; font-size: 13px; color: var(--accent);
}

/* Floating Fluent Input Dock */
.input-container {
    position: absolute; bottom: 0; left: 0; right: 0;
    background: linear-gradient(to top, var(--bg-dark) 80%, transparent);
    padding: 20px 20px 30px 20px;
    display: flex; flex-direction: column; align-items: center;
    pointer-events: none; /* Allows clicking behind it */
}

.glass-panel {
    pointer-events: auto;
    /* Gemini look: Solid dark grey, no transparency */
    background: #1f1f1f;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border: none;
    border-radius: 50px; /* Strong pill shape */
    width: 100%; 
    max-width: 850px;
    display: flex; 
    align-items: center;
    padding: 10px 12px 10px 20px;
    gap: 12px;
    box-shadow: none; /* Flat style */
    transition: background-color 0.2s ease;
}

.glass-panel:focus-within {
    /* Lighter grey background when active */
    background: #2b2b2b; 
    border: none;
    box-shadow: none;
}

textarea {
    flex: 1; background: transparent; border: none;
    color: var(--text-primary); font-family: 'Inter', sans-serif; font-size: 15px;
    resize: none; outline: none; padding: 12px 0; max-height: 200px;
}

textarea::placeholder { color: var(--text-secondary); }

.icon-btn {
    background: transparent; border: none; color: var(--text-secondary);
    font-size: 20px; cursor: pointer; padding: 10px;
    border-radius: 50%; transition: all 0.2s;
    display: flex; justify-content: center; align-items: center;
}

.icon-btn:hover { background: var(--glass-highlight); color: var(--text-primary); }

.send-btn {
    background: var(--text-primary); color: var(--bg-dark);
    border: none; width: 40px; height: 40px; border-radius: 50%;
    display: flex; justify-content: center; align-items: center;
    cursor: pointer; font-size: 18px; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.send-btn:hover { transform: scale(1.08); background: var(--accent); color: #000; box-shadow: 0 0 15px var(--accent-glow);}
.send-btn:active { transform: scale(0.95); }

.disclaimer { font-size: 11px; color: var(--text-secondary); margin-top: 16px; pointer-events: auto;}

/* Fluent Icon Animation */
#toggle-icon {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
}

/* Optional: Slight rotation effect when toggling */
#toggle-icon.rotate-in {
    transform: rotate(90deg) scale(0.8);
    opacity: 0;
}

/* --- Advanced Code Block Styling --- */
.code-block-wrapper {
    background: #0d1117;
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    margin: 16px 0;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid var(--glass-border);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    color: var(--text-secondary);
}

.code-lang { text-transform: lowercase; }

.copy-code-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: color 0.2s;
}

.copy-code-btn:hover { color: var(--text-primary); }
.copy-code-btn i { font-size: 14px; }

/* Remove previous pre borders since the wrapper handles it now */
.message-content pre { margin: 0; border: none; border-radius: 0; box-shadow: none; }

/* --- AI Message Action Row --- */
.message-actions {
    display: flex;
    gap: 12px;
    margin-top: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.assistant-message:hover .message-actions { opacity: 1; }

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 6px;
}

.action-btn:hover { background: var(--glass-highlight); color: var(--text-primary); }

/* Stop Button Animation */
.send-btn.stop-mode { background: #ff4d4d; color: #fff; box-shadow: 0 0 15px rgba(255, 77, 77, 0.3); }
.send-btn.stop-mode:hover { background: #ff3333; transform: scale(1.05); }


/* --- Fluent Glass Modal --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    width: 90%;
    max-width: 420px;
    padding: 24px;
    box-shadow: 0 24px 64px rgba(0,0,0,0.5);
    transform: translateY(20px) scale(0.95);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.modal-overlay.active .modal-content {
    transform: translateY(0) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header h3 i { color: var(--accent); font-size: 20px;}

.modal-body p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    line-height: 1.5;
}

#api-key-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 16px;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s, box-shadow 0.3s;
    margin-bottom: 24px;
}

#api-key-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
}

.btn-primary {
    background: var(--text-primary);
    color: var(--bg-dark);
    border: none;
    padding: 14px 28px;
    border-radius: 14px;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-primary:hover {
    background: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px var(--accent-glow);
}

/* Updated Fluent Sidebar Settings Button */
.settings-btn {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    margin-top: auto;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.settings-btn:hover {
    background: var(--glass-highlight);
    border-color: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

/* --- Smooth Glass Typing Indicator --- */
.typing-indicator {
    display: flex;
    gap: 6px;
    align-items: center;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    width: fit-content;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: glassFadeIn 0.3s ease forwards;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: var(--text-primary);
    border-radius: 50%;
    opacity: 0.2;
    animation: fluidPulse 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes fluidPulse {
    0%, 100% { transform: scale(0.8); opacity: 0.2; }
    50% { transform: scale(1.2); opacity: 0.8; mix-blend-mode: overlay; }
}

@keyframes glassFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Typewriter Streaming Smoothness --- */
.message-content {
    transition: all 0.2s ease;
    line-height: 1.6;
}

/* Smooth auto-scroll behavior wrapper */
#chat-stream {
    scroll-behavior: smooth;
}

/* Assumes your input container has a class like .input-container */
.input-container {
    position: relative;
    transition: all 0.3s ease;
}

.input-container::before {
    content: '';
    position: absolute;
    inset: -1px;
    border-radius: inherit;
    background: linear-gradient(90deg, transparent, var(--accent), transparent);
    z-index: -1;
    opacity: 0;
    transition: opacity 0.4s ease;
}

.input-container:focus-within::before {
    opacity: 0.3;
}

.input-container:focus-within {
    box-shadow: 0 0 24px rgba(0, 242, 254, 0.15); /* Sleek accent glow */
    border-color: rgba(255, 255, 255, 0.2);
}

/* --- Media Containers --- */
/* 1. Reset the chart wrapper so it doesn't act like a "box" */
.media-wrapper {
    margin: 20px -20px; /* Pulls the element out of the parent's padding */
    width: calc(100% + 40px); /* Expands width to match the box + padding */
    background: transparent !important; /* Removes the "holographic" box look */
    border: none !important; /* Removes the border */
    display: flex;
    justify-content: center;
    padding: 0 20px; /* Adds a tiny bit of space inside */
}

/* 2. Optional: If you want the chart to feel even more "floating" */
.media-wrapper canvas {
    width: 100% !important;
    height: auto !important;
    background: rgba(255, 255, 255, 0.02); /* Very subtle surface */
    border-radius: 12px;
}

.media-wrapper img, .media-wrapper iframe {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 20px;
}

.media-wrapper iframe {
    aspect-ratio: 16 / 9;
}

/* Loading skeleton for media */
.media-loading {
    padding: 40px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Ensure KaTeX math renders clearly inside the glass chat bubbles */
.katex {
    font-size: 1.1em !important;
}

.katex-display {
    overflow-x: auto;
    padding: 10px 0;
}

/* --- Fluent Math Highlights --- */
.math-highlight {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    padding: 2px 6px;
    margin: 0 4px;
    display: inline-block;
    backdrop-filter: blur(4px);
}

.math-highlight-block {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 16px;
    margin: 16px 0;
    text-align: center;
    backdrop-filter: blur(4px);
}
/* Ensure MathJax looks good in the dark theme */
.MathJax {
    color: white !important;
}
/* --- Export Modal Styling --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.3s ease;
}

.modal-content {
    background: rgba(15, 15, 15, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 30px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
    text-align: center;
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.hidden .modal-content {
    transform: translateY(20px);
}

.modal-title {
    font-family: 'JetBrains Mono', monospace;
    color: #fff;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.modal-subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 25px;
}

.export-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 25px;
}

.export-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.export-card i {
    font-size: 2rem;
    color: var(--accent);
}

.export-card:hover {
    background: rgba(0, 229, 255, 0.1);
    border-color: rgba(0, 229, 255, 0.3);
    transform: translateY(-2px);
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: 'JetBrains Mono', monospace;
    cursor: pointer;
}
.modal-close-btn:hover { color: #fff; }

.media-container {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 12px; /* Increased padding */
    margin: 16px 0;
    backdrop-filter: blur(12px);
    display: flex; /* Flex helps centering */
    justify-content: center;
    align-items: center;
    min-height: 200px;
    overflow: hidden;
}

.media-container img {
    max-width: 100%;
    max-height: 400px;
    object-fit: contain; /* Keeps aspect ratio */
    border-radius: 10px;
}

.media-container:hover {
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.media-container iframe {
    width: 100%;
    border-radius: 14px; /* Slightly softer corners for inner content */
    display: block;
}

.media-container iframe {
    aspect-ratio: 16 / 9; /* Perfect YouTube ratio */
}

/* Add this to style.css */
.message-content a {
    display: none !important; /* This hides any links if the AI accidentally generates one */
}

.audit-container {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
    backdrop-filter: blur(8px);
}

.audit-header {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.audit-header i {
    font-size: 14px;
}

/* Fluent Glass Title Chip */
.title-chip {
    background: rgba(255, 255, 255, 0.05); /* Soft glass tint */
    backdrop-filter: blur(16px);            /* Fluent blur */
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;                   /* Fluent rounded corners */
    padding: 6px 16px;                     /* Breathing room */
    max-width: 300px;                      /* Constrain width */
    
    /* Text Handling */
    white-space: nowrap;                   /* Keep on one line */
    overflow: hidden;                      /* Hide overflow */
    text-overflow: ellipsis;               /* Add "..." if too long */
    flex-shrink: 0; /* Prevents the bar from squishing the text */
    font-size: 0.9rem;
    font-weight: 500;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
    transition: all 0.3s ease;
    letter-spacing: 0.02em;
    opacity: 0.8;
}

.title-chip:hover {
    background: rgba(255, 255, 255, 0.08); /* Slight highlight on hover */
    border-color: rgba(255, 255, 255, 0.2);
}
.svg-wrapper {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 20px 0;
}

.svg-wrapper svg {
    max-width: 100%;
    height: auto;
    /* Ensure the physics vectors look sharp */
    stroke-width: 2px;
}

/* Apply this to your glass panels (.glass-panel, .sidebar, .modal-content) */
.glass-panel, .sidebar, .modal-content {
    /* Existing backdrop styles... */
    /* NEW: Inner shadow to mimic light hitting the edge of glass */
    box-shadow: 
        inset 0 1px 0 0 rgba(255, 255, 255, 0.1),
        0 10px 20px -5px rgba(0, 0, 0, 0.3);
}

/* Reactive Glass: Brightens when hovered or active */
.glass-panel:hover, .history-item:hover {
    background: rgba(255, 255, 255, 0.08) !important;
}

/* Subtle motion when opening sidebar */
.sidebar {
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), background 0.3s ease;
}
/* Add this to your text elements for a "polished" look */
.app-title, .history-label, .title-chip {
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    letter-spacing: 0.02em;
}
