/* ============================================
   JUNIPER - Modern Advanced UI
   Clean, Spacious, User-Friendly Design
   ============================================ */

:root {
    /* Colors */
    --primary: #667eea;
    --primary-dark: #5568d3;
    --primary-light: #8b9bff;
    --gradient-start: #667eea;
    --gradient-end: #764ba2;

    /* Neutrals - Light */
    --bg: #f5f7fa;
    --surface: #ffffff;
    --surface-hover: #f8f9fc;
    --border: #e1e8ed;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --text-tertiary: #a0aec0;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);

    /* Spacing */
    --space-xs: 0.5rem;
    --space-sm: 0.75rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;

    /* Radius */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;

    /* Transitions */
    --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg: #0f1419;
    --surface: #1a1f2e;
    --surface-hover: #242b3d;
    --border: #2d3748;
    --text-primary: #e2e8f0;
    --text-secondary: #a0aec0;
    --text-tertiary: #718096;
}

/* ============================================
   BASE STYLES
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    transition: background var(--transition), color var(--transition);
}

/* ============================================
   ANIMATED BACKGROUND
   ============================================ */

.bg-animation {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.3;
    animation: float 20s ease-in-out infinite;
}

.orb-1 {
    width: 400px;
    height: 400px;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    top: -200px;
    right: -200px;
    animation-delay: 0s;
}

.orb-2 {
    width: 300px;
    height: 300px;
    background: linear-gradient(225deg, #f093fb, #f5576c);
    bottom: -150px;
    left: -150px;
    animation-delay: 7s;
}

.orb-3 {
    width: 350px;
    height: 350px;
    background: linear-gradient(315deg, #4facfe, #00f2fe);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: 14s;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -30px) scale(1.1); }
    66% { transform: translate(-20px, 20px) scale(0.9); }
}

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

.app-layout {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
    width: 280px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    transition: all var(--transition);
    z-index: 100;
}

.sidebar-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.brand-icon {
    flex-shrink: 0;
}

.brand-name {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
}

.brand-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0;
}

.sidebar-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.sidebar-close:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.sidebar-body {
    flex: 1;
    padding: var(--space-lg);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: var(--space-xl);
}

.sidebar-body::-webkit-scrollbar {
    width: 6px;
}

.sidebar-body::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-body::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

.info-box {
    display: flex;
    align-items: start;
    gap: var(--space-md);
    padding: var(--space-md);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.08), rgba(118, 75, 162, 0.08));
    border: 1px solid rgba(102, 126, 234, 0.2);
    border-radius: var(--radius-md);
}

.info-box svg {
    color: var(--primary);
    flex-shrink: 0;
    margin-top: 2px;
}

.info-box strong {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 2px;
}

.info-box p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.action-btn {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.action-btn:hover {
    background: var(--surface-hover);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.action-btn.primary {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    border-color: transparent;
    color: white;
}

.action-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Chat History */
.chat-history {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.chat-history h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    max-height: 200px;
    overflow-y: auto;
}

.history-list::-webkit-scrollbar {
    width: 4px;
}

.history-list::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.empty-history {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-lg);
    text-align: center;
    color: var(--text-tertiary);
}

.empty-history svg {
    opacity: 0.5;
}

.empty-history p {
    margin: 0;
    font-size: 0.8125rem;
}

.history-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    font-size: 0.8125rem;
}

.history-item:hover {
    background: var(--surface-hover);
    border-color: var(--primary);
    transform: translateX(2px);
}

.history-item.active {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
    border-color: var(--primary);
}

.history-item svg {
    color: var(--primary);
    flex-shrink: 0;
}

.history-item-content {
    flex: 1;
    min-width: 0;
}

.history-item-title {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item-time {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.history-item-delete {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    opacity: 0;
    transition: all var(--transition);
}

.history-item:hover .history-item-delete {
    opacity: 1;
}

.history-item-delete:hover {
    background: rgba(245, 101, 101, 0.1);
    color: #f56565;
}

.features {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.features h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    margin-bottom: var(--space-xs);
}

.feature {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.feature svg {
    color: var(--primary);
    flex-shrink: 0;
}

.sidebar-footer {
    padding: var(--space-lg);
    border-top: 1px solid var(--border);
}

.status {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #48bb78;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.topbar {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-lg) var(--space-xl);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.menu-btn:hover {
    background: var(--surface-hover);
}

.page-title {
    flex: 1;
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.model-tag {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-md);
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.notice {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin: var(--space-lg) var(--space-xl) 0;
    padding: var(--space-md) var(--space-lg);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05), rgba(118, 75, 162, 0.05));
    border: 1px solid rgba(102, 126, 234, 0.15);
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.notice svg {
    color: var(--primary);
    flex-shrink: 0;
}

/* ============================================
   CHAT AREA
   ============================================ */

.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-xl);
    scroll-behavior: smooth;
}

.chat-area::-webkit-scrollbar {
    width: 8px;
}

.chat-area::-webkit-scrollbar-track {
    background: transparent;
}

.chat-area::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

/* Welcome Screen */
.welcome {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--space-2xl) 0;
    text-align: center;
    animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.welcome-icon {
    margin: 0 auto var(--space-xl);
    animation: float 3s ease-in-out infinite;
}

.welcome h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: var(--space-sm);
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.welcome p {
    font-size: 1.125rem;
    color: var(--text-secondary);
    margin-bottom: var(--space-2xl);
}

.query-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-2xl);
}

.query-card {
    display: flex;
    align-items: start;
    gap: var(--space-md);
    padding: var(--space-lg);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-align: left;
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
}

.query-card:hover {
    background: var(--surface-hover);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.query-card svg {
    color: var(--primary);
    flex-shrink: 0;
    margin-top: 2px;
}

.query-card strong {
    display: block;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.query-card span {
    display: block;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.caps {
    display: flex;
    justify-content: center;
    gap: var(--space-xl);
    flex-wrap: wrap;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.caps div {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.caps svg {
    color: var(--primary);
}

/* Messages */
.message {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    max-width: 800px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    margin-left: auto;
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: white;
}

.message.assistant .message-avatar {
    background: var(--surface-hover);
    color: var(--primary);
    border: 1px solid var(--border);
}

.message-content {
    flex: 1;
}

.message-header {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-xs);
}

.message.user .message-header {
    flex-direction: row-reverse;
}

.message-sender {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.message-time {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.message-text {
    padding: var(--space-md) var(--space-lg);
    border-radius: var(--radius-lg);
    font-size: 0.9375rem;
    line-height: 1.7;
    background: var(--surface-hover);
    border: 1px solid var(--border);
}

.message.user .message-text {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: white;
    border: none;
}

.message-sources-wrap {
    margin-top: var(--space-md);
}

.sources-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    opacity: 0.8;
    margin-bottom: var(--space-xs);
}

.message-sources {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.source-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 4px var(--space-sm);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    transition: border-color 0.15s ease, color 0.15s ease;
}

a.source-badge:hover {
    border-color: var(--primary, #6366f1);
    color: var(--primary, #6366f1);
}

.source-title {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-relevance {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 999px;
    background: var(--primary, #6366f1);
    color: #fff;
    opacity: 0.85;
}

/* Markdown-rendered answers */
.markdown-body p {
    margin: 0 0 0.6em 0;
    line-height: 1.6;
}
.markdown-body p:last-child {
    margin-bottom: 0;
}
.markdown-body strong {
    font-weight: 700;
    color: var(--text-primary, inherit);
}
.markdown-body ul,
.markdown-body ol {
    margin: 0.3em 0 0.7em 0;
    padding-left: 1.3em;
}
.markdown-body li {
    margin: 0.2em 0;
    line-height: 1.55;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
    font-size: 0.95rem;
    font-weight: 700;
    margin: 0.8em 0 0.4em 0;
}
.markdown-body a {
    color: var(--primary, #6366f1);
    text-decoration: underline;
}
.markdown-body code {
    background: var(--surface, rgba(127,127,127,0.12));
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.85em;
}
.markdown-body blockquote {
    border-left: 3px solid var(--primary, #6366f1);
    margin: 0.5em 0;
    padding: 0.2em 0 0.2em 0.9em;
    opacity: 0.9;
}

/* Streaming cursor while the answer is being generated */
.message-text.streaming::after {
    content: '▋';
    display: inline-block;
    margin-left: 2px;
    color: var(--primary, #6366f1);
    animation: blink 1s step-start infinite;
}
@keyframes blink {
    50% { opacity: 0; }
}

/* Follow-up suggestion chips */
.message-suggestions {
    margin-top: var(--space-md);
}
.suggestions-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    opacity: 0.8;
    margin-bottom: var(--space-xs);
}
.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}
.suggestion-chip {
    font-family: inherit;
    font-size: 0.8rem;
    padding: 6px var(--space-md);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    text-align: left;
}
.suggestion-chip:hover {
    background: var(--primary, #6366f1);
    border-color: var(--primary, #6366f1);
    color: #fff;
}

/* Typing Indicator */
.typing {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.typing .message-avatar {
    background: var(--surface-hover);
    color: var(--primary);
    border: 1px solid var(--border);
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: var(--space-md) var(--space-lg);
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-8px); opacity: 1; }
}

/* ============================================
   INPUT BOX
   ============================================ */

.input-box {
    padding: var(--space-lg) var(--space-xl);
    background: var(--surface);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.04);
}

.input-container {
    display: flex;
    align-items: flex-end;
    gap: var(--space-sm);
    padding: var(--space-sm);
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-xl);
    transition: all var(--transition);
}

.input-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--text-primary);
    max-height: 150px;
    outline: none;
}

#messageInput::placeholder {
    color: var(--text-tertiary);
}

.language-selector {
    display: flex;
    gap: 4px;
    background: var(--surface-hover);
    padding: 4px;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.lang-btn {
    padding: 6px 10px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: calc(var(--radius-md) - 2px);
    transition: all var(--transition);
    font-family: inherit;
}

.lang-btn:hover {
    background: var(--bg);
    color: var(--text-primary);
}

.lang-btn.active {
    background: var(--primary);
    color: white;
}

.voice-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: none;
    background: var(--surface-hover);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
    position: relative;
}

.voice-btn:hover:not(:disabled) {
    background: var(--primary-light);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.voice-btn .mic-icon {
    display: block;
}

.voice-btn .mic-recording {
    display: none;
}

.voice-btn.recording {
    background: #ef4444;
    color: white;
    animation: pulse-recording 1.5s ease-in-out infinite;
}

.voice-btn.recording .mic-icon {
    display: none;
}

.voice-btn.recording .mic-recording {
    display: block;
}

@keyframes pulse-recording {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
}

#sendBtn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: none;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

#sendBtn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

#sendBtn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.input-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: var(--space-sm);
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.char-count {
    font-weight: 500;
}

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

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        height: 100%;
        z-index: 1000;
    }

    .sidebar.active {
        left: 0;
    }

    .sidebar-close {
        display: block;
    }

    .menu-btn {
        display: block;
    }

    .topbar {
        padding: var(--space-md) var(--space-lg);
    }

    .page-title {
        font-size: 1rem;
    }

    .notice {
        margin: var(--space-md) var(--space-lg) 0;
        padding: var(--space-sm) var(--space-md);
        font-size: 0.8125rem;
    }

    .chat-area {
        padding: var(--space-lg);
    }

    .welcome h2 {
        font-size: 1.5rem;
    }

    .welcome p {
        font-size: 1rem;
    }

    .query-grid {
        grid-template-columns: 1fr;
    }

    .input-box {
        padding: var(--space-md) var(--space-lg);
    }

    .caps {
        gap: var(--space-md);
    }
}

/* ============================================
   AUTHENTICATION MODAL
   ============================================ */

.modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition);
}

.modal.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    max-width: 420px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: var(--space-2xl);
    position: relative;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-close {
    position: absolute;
    top: var(--space-lg);
    right: var(--space-lg);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-xs);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.modal-close:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.auth-form h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.auth-subtitle {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: var(--space-xl);
}

.form-group {
    margin-bottom: var(--space-lg);
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.form-group input {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9375rem;
    color: var(--text-primary);
    transition: all var(--transition);
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.form-error {
    color: #f56565;
    font-size: 0.875rem;
    margin-bottom: var(--space-md);
    min-height: 1.2rem;
}

.auth-btn {
    width: 100%;
    padding: var(--space-md);
    border: none;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    margin-top: var(--space-sm);
}

.auth-btn.primary {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: white;
}

.auth-btn.primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.auth-btn:not(.primary) {
    background: var(--surface-hover);
    color: var(--text-primary);
}

.auth-btn:not(.primary):hover {
    background: var(--bg);
}

.auth-switch {
    text-align: center;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-top: var(--space-lg);
}

.auth-switch button {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-weight: 600;
    padding: 0;
    text-decoration: underline;
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--space-lg);
    padding: var(--space-xl);
    background: var(--bg);
    border-radius: var(--radius-lg);
    margin: var(--space-xl) 0;
}

.user-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.user-details h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-details p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    word-break: break-all;
}

/* ============================================
   UTILITIES
   ============================================ */

.hidden {
    display: none !important;
}
