/* ===== RESET & BASE ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    /* Light theme (default per spec) */
    --bg-main: #FFFFFF;
    --bg-sidebar: #F8F9FA;
    --bg-card: #FFFFFF;
    --bg-input: #FFFFFF;
    --border-color: #E8E8E8;
    --text-main: #1F1F1F;
    --text-muted: #5E5E5E;
    --accent: #0B57D0;
    --accent-bg: #D3E3FD;
    --accent-hover: #0947A8;
    --error: #DC2626;
    --success: #16A34A;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.05);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.08);
    --radius-pill: 9999px;
    --radius-card: 12px;
    --radius-input: 32px;
    --radius-circle: 50%;
    --transition: 0.2s ease;
    --base-font-size: 14px;
    --sidebar-width: 260px;
    --search-width: 650px;
}

html { font-size: var(--base-font-size); }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    overflow: hidden;
    font-size: 1rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== DARK THEME ===== */
[data-theme="dark"] {
    --bg-main: #0B0F19;
    --bg-sidebar: #111827;
    --bg-card: #1A1F2E;
    --bg-input: #1A1F2E;
    --border-color: #2D3748;
    --text-main: #F9FAFB;
    --text-muted: #9CA3AF;
    --accent: #38BDF8;
    --accent-bg: #1E3A5F;
    --accent-hover: #0EA5E9;
    --error: #F87171;
    --success: #4ADE80;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
}

/* ===== MATRIX THEME ===== */
[data-theme="matrix"] {
    --bg-main: #000000;
    --bg-sidebar: #0A0F0D;
    --bg-card: #0D140E;
    --bg-input: #0D140E;
    --border-color: #004400;
    --text-main: #00FF00;
    --text-muted: #009900;
    --accent: #33FF33;
    --accent-bg: #003300;
    --accent-hover: #66FF66;
    --error: #FF3344;
    --success: #00FF00;
}

/* ===== HYDROGEN THEME ===== */
[data-theme="hydrogen"] {
    --bg-main: #030712;
    --bg-sidebar: #0F172A;
    --bg-card: #1E293B;
    --bg-input: #1E293B;
    --border-color: #00D2FF;
    --text-main: #FFFFFF;
    --text-muted: #93C5FD;
    --accent: #00D2FF;
    --accent-bg: #083344;
    --accent-hover: #22D3EE;
    --error: #EF4444;
    --success: #22C55E;
}

/* ===== LOGIN OVERLAY ===== */
.login-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: var(--bg-main);
}

.login-card {
    width: 100%;
    max-width: 380px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    padding: 40px 32px;
    box-shadow: var(--shadow-lg);
}

.login-header { text-align: center; margin-bottom: 32px; }
.login-logo { width: 48px; height: 48px; color: var(--accent); margin-bottom: 16px; }
.login-header h1 { font-size: 1.75rem; font-weight: 700; color: var(--text-main); margin-bottom: 4px; letter-spacing: -0.02em; }
.login-subtitle { color: var(--text-muted); font-size: 0.9rem; }

.input-group { margin-bottom: 16px; }
.input-group label { display: block; font-size: 0.75rem; font-weight: 500; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; }
.input-group input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.input-group input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.input-group input::placeholder { color: var(--text-muted); opacity: 0.6; }

.login-error { min-height: 18px; color: var(--error); font-size: 0.8rem; margin-bottom: 16px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; border: 1px solid var(--border-color); background: transparent; color: var(--text-main); font-family: inherit; font-size: 0.8rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; cursor: pointer; border-radius: var(--radius-pill); transition: all var(--transition); }
.btn:hover { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: #FFFFFF; }
.btn-full { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 0.7rem; }
.icon-button { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-circle); background: transparent; border: 1px solid transparent; color: var(--text-muted); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--transition); }
.icon-button:hover { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }
.icon-button svg { width: 18px; height: 18px; }

/* ===== APP LAYOUT ===== */
.app-screen { display: flex; height: 100vh; width: 100vw; overflow: hidden; }

/* LEFT SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    overflow: hidden; /* Sidebar handles its own scroll */
}

.sidebar-section { flex: 1; display: flex; flex-direction: column; padding: 16px; overflow: hidden; }
.sidebar-top { flex: 0 0 auto; }
.sidebar-middle { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-bottom: 16px; }
.sidebar-bottom { flex: 0 0 auto; border-top: 1px solid var(--border-color); padding-top: 12px; }

.pill-button { display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 12px 16px; background: var(--accent-bg); color: var(--text-main); border: none; border-radius: var(--radius-pill); font-family: inherit; font-size: 0.85rem; font-weight: 500; cursor: pointer; transition: all var(--transition); }
.pill-button:hover { background: var(--accent); color: #FFFFFF; transform: translateY(-1px); box-shadow: var(--shadow-md); }
.pill-button .icon { width: 18px; height: 18px; flex-shrink: 0; }

/* Sidebar Tabs */
.sidebar-tabs { display: flex; gap: 4px; margin-bottom: 16px; }
.sidebar-tab { flex: 1; padding: 8px 12px; background: transparent; border: 1px solid transparent; border-radius: 8px; color: var(--text-muted); font-family: inherit; font-size: 0.75rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.05em; cursor: pointer; transition: all var(--transition); }
.sidebar-tab:hover { background: var(--accent-bg); color: var(--accent); border-color: var(--accent-bg); }
.sidebar-tab.active { background: var(--accent); color: #FFFFFF; }

.sidebar-content { flex: 1; overflow-y: auto; }
.sidebar-list { display: flex; flex-direction: column; gap: 4px; }
.sidebar-item-wrapper { display: flex; align-items: center; gap: 2px; border-radius: 8px; transition: all var(--transition); }
.sidebar-item-wrapper:hover { background: var(--accent-bg); }
.sidebar-item-wrapper.active { background: var(--accent); }
.sidebar-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: transparent; border: none; border-radius: 8px; color: var(--text-main); font-family: inherit; font-size: 0.85rem; text-align: left; flex: 1; min-width: 0; overflow: hidden; cursor: pointer; transition: all var(--transition); }
.sidebar-item-wrapper:hover .sidebar-item { color: var(--accent); }
.sidebar-item-wrapper.active .sidebar-item { color: #FFFFFF; }
.sidebar-item .icon { width: 18px; height: 18px; color: var(--text-muted); flex-shrink: 0; }
.sidebar-item-wrapper:hover .sidebar-item .icon, .sidebar-item-wrapper.active .sidebar-item .icon { color: currentColor; }
.sidebar-item-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-item-meta { font-size: 0.65rem; color: var(--text-muted); opacity: 0.7; flex-shrink: 0; white-space: nowrap; }
.sidebar-item-wrapper.active .sidebar-item-meta { color: rgba(255,255,255,0.7); }
.sidebar-item-delete { width: 28px; height: 28px; padding: 0; background: transparent; border: none; border-radius: 6px; color: var(--text-muted); cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all var(--transition); margin-right: 4px; opacity: 0.4; }
.sidebar-item-delete svg { width: 14px; height: 14px; }
.sidebar-item-wrapper:hover .sidebar-item-delete { opacity: 1; }
.sidebar-item-wrapper.active .sidebar-item-delete { color: rgba(255,255,255,0.8); opacity: 0.7; }
.sidebar-item-wrapper.active .sidebar-item-delete:hover { color: #FFFFFF; background: rgba(220, 38, 38, 0.25); }
.sidebar-item-delete:hover { opacity: 1; background: rgba(220, 38, 38, 0.15); color: var(--error); }

.empty-state { padding: 24px 12px; text-align: center; color: var(--text-muted); font-size: 0.8rem; line-height: 1.5; }

/* User Profile */
.user-profile { display: flex; align-items: center; gap: 12px; }
.user-avatar { width: 40px; height: 40px; border-radius: var(--radius-circle); background: var(--accent); color: #FFFFFF; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 1rem; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.user-name { font-weight: 600; font-size: 0.85rem; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* RIGHT MAIN CONTENT */
.main-content {
    flex: 1;
    height: 100%;
    background: var(--bg-main);
    display: flex;
    flex-direction: row;
    position: relative;
    overflow: hidden;
}

/* Main content inner wrapper for independent scroll */
.main-content-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    position: relative;
}

/* PDF side panel */
.pdf-panel {
    display: none;
    flex-direction: column;
    border-left: 1px solid var(--border-color);
    background: var(--bg-card);
    animation: slideInRight 0.25s ease;
    overflow: hidden;
}
.pdf-panel.open {
    display: flex;
    width: min(600px, 50vw);
}

.pdf-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-sidebar);
    flex-shrink: 0;
}
.pdf-panel-filename {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.pdf-panel-actions {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}
.pdf-close-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-circle);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    font-family: inherit;
    line-height: 1;
    transition: all var(--transition);
}
.pdf-close-btn:hover {
    background: var(--error);
    color: #FFFFFF;
    border-color: var(--error);
}

.pdf-panel-body {
    flex: 1;
    overflow: hidden;
    position: relative;
}
.pdf-panel-body .pdf-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: var(--bg-main);
}

@keyframes slideInRight {
    from { width: 0; opacity: 0; }
    to { width: min(600px, 50vw); opacity: 1; }
}

/* Top Right Controls */
.top-right-controls { position: absolute; top: 20px; right: 20px; z-index: 5; }

.theme-toggle .icon-button { width: 40px; height: 40px; background: var(--bg-card); border: 1px solid var(--border-color); box-shadow: var(--shadow-md); }
.theme-toggle .icon-button:hover { background: var(--accent-bg); border-color: var(--accent); }
.theme-toggle .theme-icon { display: none; }
[data-theme="light"] .theme-toggle .theme-icon.sun,
[data-theme="dark"] .theme-toggle .theme-icon.moon,
[data-theme="matrix"] .theme-toggle .theme-icon.terminal,
[data-theme="hydrogen"] .theme-toggle .theme-icon.hydrogen { display: block; }

/* Center Area */
.center-area { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: flex-start;
    padding: 20px; 
    position: relative; 
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    overflow: hidden;
    min-height: 0;
}

/* Glow Blob */
.glow-blob {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    width: 400px;
    height: 400px;
    background: radial-gradient(circle at center, #E8F0FE 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
}
[data-theme="dark"] .glow-blob { background: radial-gradient(circle at center, rgba(56,189,248,0.15) 0%, transparent 70%); }
[data-theme="matrix"] .glow-blob { background: radial-gradient(circle at center, rgba(51,255,51,0.1) 0%, transparent 70%); }
[data-theme="hydrogen"] .glow-blob { background: radial-gradient(circle at center, rgba(0,210,255,0.15) 0%, transparent 70%); }

.welcome-state, .chat-state {
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: relative;
    z-index: 1;
    flex: 1;
    overflow-y: auto;
}

/* Welcome Content — Gemini-style centered with gradient */
.welcome-state { background: linear-gradient(180deg, #EBF5FF 0%, #F2F8FF 40%, #FFFFFF 100%); }
[data-theme="dark"] .welcome-state { background: linear-gradient(180deg, #0B0F19 0%, #0B0F19 100%); }
[data-theme="matrix"] .welcome-state { background: linear-gradient(180deg, #000000 0%, #000000 100%); }
[data-theme="hydrogen"] .welcome-state { background: linear-gradient(180deg, #001824 0%, #001824 100%); }
.welcome-content { text-align: center; width: 100%; max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; padding: 0 24px; }
.welcome-title { font-size: 2.75rem; font-weight: 400; color: var(--text-main); letter-spacing: -0.02em; margin-bottom: 8px; line-height: 1.15; }
.welcome-subtitle { color: var(--text-muted); font-size: 1.1rem; margin-bottom: 32px; font-weight: 400; }

/* Task Selector Row — hidden in welcome, shown in chat */
.task-selector-row { display: none; }
#chat-task-selector-row { display: flex; gap: 8px; justify-content: center; margin-bottom: 12px; flex-wrap: wrap; }
.task-chip { padding: 8px 16px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-pill); color: var(--text-muted); font-family: inherit; font-size: 0.75rem; font-weight: 500; cursor: pointer; transition: all var(--transition); white-space: nowrap; }
.task-chip:hover { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }
.task-chip.active { background: var(--accent); border-color: var(--accent); color: #FFFFFF; }

/* Search Bar Container — floating card with shadow (Gemini-style) */
.search-bar-container { width: 100%; max-width: 720px; background: var(--bg-card); border: none; border-radius: 28px; box-shadow: 0 2px 12px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.06); padding: 4px; transition: all 0.2s ease; }
.search-bar-container:focus-within { box-shadow: 0 4px 20px rgba(0,0,0,0.12), 0 0 0 1px var(--accent); }
.search-bar { display: flex; align-items: center; gap: 8px; width: 100%; }
.search-input, .chat-input { flex: 1; padding: 14px 20px; background: transparent; border: none; color: var(--text-main); font-family: inherit; font-size: 1rem; outline: none; }
.search-input::placeholder, .chat-input::placeholder { color: var(--text-muted); opacity: 0.6; }
.circle-button { width: 44px; height: 44px; border-radius: var(--radius-circle); background: var(--accent); border: none; color: #FFFFFF; cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all var(--transition); flex-shrink: 0; }
.circle-button:hover { background: var(--accent-hover); transform: scale(1.04); }
.circle-button svg { width: 20px; height: 20px; }

.welcome-hints { display: flex; gap: 16px; justify-content: center; margin-top: 24px; flex-wrap: wrap; }
.hint { padding: 6px 12px; background: var(--bg-sidebar); border: 1px solid var(--border-color); border-radius: var(--radius-pill); font-size: 0.75rem; color: var(--text-muted); cursor: pointer; transition: all var(--transition); }
.hint:hover { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }

/* Chat State */
.chat-state { 
    height: 100%; 
    display: flex; 
    flex-direction: column; 
    gap: 0; 
}

.chat-header { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    width: 100%; 
    padding: 16px 56px 12px 0; 
    border-bottom: 1px solid var(--border-color); 
    margin-bottom: 16px;
    flex-shrink: 0;
}

.chat-title { 
    font-size: 1.1rem; 
    font-weight: 600; 
    color: var(--text-main);
    text-transform: capitalize; /* Auto-capitalize first letter */
}

.chat-actions { display: flex; gap: 4px; }

.chat-messages { 
    flex: 1; 
    overflow-y: auto; 
    width: 100%; 
    padding: 0 4px 16px; 
    display: flex; 
    flex-direction: column; 
    gap: 16px;
    max-width: 100%; /* Remove max-width constraint */
}

.chat-message { display: flex; gap: 12px; max-width: 95%; animation: fadeInUp 0.3s ease; }
.chat-message.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-message.assistant { align-self: flex-start; }
.chat-message .avatar { width: 32px; height: 32px; border-radius: var(--radius-circle); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 600; }
.chat-message.user .avatar { background: var(--accent); color: #FFFFFF; }
.chat-message.assistant .avatar { background: var(--accent-bg); color: var(--accent); }
.chat-bubble { padding: 12px 16px; border-radius: 16px; font-size: 0.9rem; line-height: 1.65; max-width: 100%; position: relative; }
.chat-message.user .chat-bubble { background: var(--accent); color: #FFFFFF; border-bottom-right-radius: 4px; }
.chat-message.assistant .chat-bubble { background: var(--bg-card); border: 1px solid var(--border-color); color: var(--text-main); border-bottom-left-radius: 4px; box-shadow: var(--shadow-sm); }
.chat-bubble .formatted-answer { line-height: 1.65; }
.chat-bubble .formatted-answer code { background: rgba(0,0,0,0.1); padding: 1px 6px; border-radius: 4px; font-family: 'Fira Code', monospace; font-size: 0.85em; }
.chat-message.user .chat-bubble .formatted-answer code { background: rgba(255,255,255,0.2); }
.chat-bubble .formatted-answer strong { font-weight: 600; }
.chat-bubble .formatted-answer table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 0.85rem; }
.chat-bubble .formatted-answer th, .chat-bubble .formatted-answer td { border: 1px solid var(--border-color); padding: 8px 12px; text-align: left; }
.chat-bubble .formatted-answer th { background: var(--bg-sidebar); font-weight: 600; color: var(--accent); }
.chat-bubble .formatted-answer tr:nth-child(even) td { background: var(--bg-sidebar); }

/* Highlight styling - subtle */
.chat-bubble .formatted-answer mark,
.chat-bubble .formatted-answer .highlight {
    background: rgba(255, 243, 186, 0.3);
    padding: 0 2px;
    border-radius: 2px;
}

/* ===== STICKY INPUT BAR WITH GRADIENT MASK ===== */
.chat-input-bar { 
    width: 100%; 
    padding-top: 16px; 
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    background: linear-gradient(to top, var(--bg-main) 0%, transparent 100%);
    padding-bottom: 20px;
    margin-top: auto;
}

.chat-task-selector-row { margin-bottom: 12px; }

.chat-input-form {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-card);
    border: none;
    border-radius: 28px;
    padding: 4px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.06);
}
.chat-input-form:focus-within {
    box-shadow: 0 4px 20px rgba(0,0,0,0.12), 0 0 0 1px var(--accent);
}
.chat-input { padding: 12px 16px; }

/* Version Badge */
.version-badge { position: fixed; bottom: 12px; right: 16px; font-size: 0.85rem; font-family: 'Courier New', monospace; color: var(--text-muted); opacity: 0.7; letter-spacing: 0.05em; z-index: 100; pointer-events: none; user-select: none; font-weight: 600; }
.model-info { position: fixed; bottom: 12px; left: 16px; font-size: 0.7rem; font-family: 'Courier New', monospace; color: var(--text-muted); opacity: 0.5; letter-spacing: 0.03em; z-index: 100; pointer-events: none; user-select: none; }

/* Modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; animation: fadeIn 0.2s ease; }
.modal-content { background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-card); max-width: 95vw; width: 900px; max-height: 90vh; overflow: hidden; box-shadow: var(--shadow-lg); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border-color); background: var(--bg-sidebar); }
.modal-header h3 { font-size: 1rem; font-weight: 600; color: var(--text-main); }
.modal-close { width: 32px; height: 32px; border-radius: var(--radius-circle); background: transparent; border: 1px solid transparent; color: var(--text-muted); cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; transition: all var(--transition); }
.modal-close:hover { background: var(--accent-bg); color: var(--accent); border-color: var(--accent); }
.modal-body { padding: 20px; max-height: 65vh; overflow-y: auto; }
.pdf-iframe { width: 100%; height: 70vh; border: none; background: var(--bg-main); border-radius: 8px; }

/* Copy Button */
.copy-answer-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; font-size: 0.7rem; font-family: inherit; font-weight: 500; background: var(--bg-sidebar); border: 1px solid var(--border-color); border-radius: 6px; color: var(--text-main); cursor: pointer; transition: all var(--transition); }
.copy-answer-btn:hover { background: var(--accent); color: #FFFFFF; border-color: var(--accent); }
.copy-answer-btn.copied { background: var(--success); color: #FFFFFF; border-color: var(--success); }

/* Answer actions row */
.answer-actions-row { display: flex; gap: 8px; margin-top: 12px; }

/* Confidence indicator */
.confidence-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 500;
    background: var(--bg-sidebar);
    border: 1px solid var(--border-color);
}
.confidence-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.confidence-high .confidence-dot { background: var(--success); }
.confidence-medium .confidence-dot { background: #F59E0B; }
.confidence-low .confidence-dot { background: var(--error); }

/* Animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); border-radius: 4px; border: 2px solid transparent; background-clip: content-box; }

/* Responsive */
@media (max-width: 1024px) {
    .sidebar { width: 72px; }
    .pill-button span, .sidebar-tabs, .sidebar-list, .user-info { display: none; }
    .pill-button { justify-content: center; padding: 12px; }
    .user-profile { justify-content: center; }
}
@media (max-width: 640px) {
    .welcome-title { font-size: 2rem; }
    .search-bar-container, .chat-input-form { border-radius: 24px; }
    .circle-button { width: 40px; height: 40px; }
    .chat-message { max-width: 100%; }
    .task-selector-row { gap: 6px; }
    .task-chip { padding: 6px 12px; font-size: 0.7rem; }
}

/* ===== ADMIN PAGE ===== */
.admin-page { display: flex; flex-direction: row; height: 100vh; background: var(--bg-main); overflow: hidden; }
.admin-page-inner { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }
.admin-header { display: flex; align-items: center; gap: 16px; padding: 20px 24px; border-bottom: 1px solid var(--border-color); }
.admin-header h1 { font-size: 1.5rem; font-weight: 700; color: var(--text-main); }
.admin-content { flex: 1; overflow-y: auto; padding: 24px; max-width: 1200px; margin: 0 auto; width: 100%; display: flex; flex-direction: column; gap: 32px; scrollbar-gutter: stable; align-self: center; }

/* PDF preview panel inside admin page */
.admin-pdf-panel {
    display: none;
    flex-direction: column;
    width: min(600px, 50vw);
    border-left: 1px solid var(--border-color);
    background: var(--bg-card);
    animation: slideInRight 0.25s ease;
    overflow: hidden;
    flex-shrink: 0;
}
.admin-pdf-panel.open { display: flex; }

.upload-section h2, .documents-table-section h2 { font-size: 1.1rem; font-weight: 600; color: var(--text-main); margin-bottom: 16px; }

.upload-dropzone { border: 2px dashed var(--border-color); border-radius: var(--radius-card); padding: 48px 24px; text-align: center; background: var(--bg-card); transition: all var(--transition); cursor: pointer; }
.upload-dropzone:hover, .upload-dropzone.dragover { border-color: var(--accent); background: var(--accent-bg); }
.upload-dropzone p { color: var(--text-muted); margin-bottom: 16px; font-size: 1rem; }
.upload-dropzone input[type="file"] { display: none; }

.upload-progress { display: flex; flex-direction: column; gap: 12px; }
.upload-progress-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 8px; }
.upload-progress-item .file-name { flex: 1; font-size: 0.9rem; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-progress-item .progress-bar { flex: 2; max-width: 300px; height: 6px; background: var(--bg-sidebar); border-radius: 3px; overflow: hidden; }
.upload-progress-item .progress-fill,
.progress-fill { height: 100%; background: var(--accent); border-radius: 3px; transition: width 0.3s ease; }
.upload-progress-item .progress-status { font-size: 0.75rem; color: var(--text-muted); min-width: 80px; text-align: right; }

.table-wrapper { overflow-x: auto; border: 1px solid var(--border-color); border-radius: var(--radius-card); background: var(--bg-card); }
.doc-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.doc-table th, .doc-table td { padding: 14px 16px; text-align: left; border-bottom: 1px solid var(--border-color); }
.doc-table th { background: var(--bg-sidebar); color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; font-size: 0.7rem; white-space: nowrap; }
.doc-table td { color: var(--text-main); }
.doc-table tr:last-child td { border-bottom: none; }
.doc-table tr:hover td { background: var(--bg-sidebar); }
.doc-table .filename { font-family: 'Fira Code', monospace; font-size: 0.8rem; max-width: 350px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-table .status-badge { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--radius-pill); font-size: 0.7rem; font-weight: 500; }
.doc-table .status-badge.ready { background: rgba(22, 163, 74, 0.15); color: var(--success); }
.doc-table .status-badge.processing { background: rgba(217, 119, 6, 0.15); color: #D97706; }
.doc-table .status-badge.error { background: rgba(220, 38, 38, 0.15); color: var(--error); }
.doc-table .actions { display: flex; gap: 8px; }
.doc-table .icon-button { width: 32px; height: 32px; }
.doc-table .icon-button.delete:hover { background: rgba(220, 38, 38, 0.15); color: var(--error); border-color: var(--error); }

/* Width constraints for table-layout:auto — prevents column shifting */
.doc-table th:nth-child(5), .doc-table td:nth-child(5) { width: 180px; max-width: 180px; }
.doc-table th:nth-child(6), .doc-table td:nth-child(6) { width: 130px; white-space: nowrap; }
.doc-table th:nth-child(1), .doc-table td:nth-child(1) { max-width: 350px; }

.admin-page .empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }

/* Manage KB button in sidebar */
.manage-kb-btn { background: var(--bg-card); color: var(--text-main); border: 1px solid var(--border-color); }
.manage-kb-btn:hover { background: var(--accent-bg); border-color: var(--accent); color: var(--accent); }

/* ===== DOCUMENT TAGS & TYPE ===== */
.doc-tag {
    display: inline-block;
    padding: 2px 8px;
    margin: 1px;
    background: var(--accent-bg);
    color: var(--accent);
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 500;
    white-space: nowrap;
}
.doc-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.doc-type-badge.type-norm { background: rgba(59,130,246,0.15); color: #3B82F6; }
.doc-type-badge.type-regulation { background: rgba(139,92,246,0.15); color: #8B5CF6; }
.doc-type-badge.type-report { background: rgba(16,185,129,0.15); color: #10B981; }
.doc-type-badge.type-specification { background: rgba(245,158,11,0.15); color: #F59E0B; }
.doc-type-badge.type-manual { background: rgba(236,72,153,0.15); color: #EC4899; }
.text-muted { color: var(--text-muted); }

/* ===== EXPLORE MODAL ===== */
.explore-doc-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition);
}
.explore-doc-item:hover { background: var(--accent-bg); }
.explore-doc-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: var(--accent-bg);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.explore-doc-info { flex: 1; min-width: 0; }
.explore-doc-name { font-weight: 600; font-size: 0.9rem; color: var(--text-main); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.explore-doc-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }
.explore-doc-tags { margin-top: 4px; display: flex; gap: 4px; flex-wrap: wrap; }

/* ===== TASK TEMPLATES ===== */
/* Task templates — hidden in welcome state (Gemini-style minimalism) */
.welcome-state .task-templates-section { display: none; }
.task-templates-section { margin-top: 20px; }
.task-templates-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-top: 8px; }
.task-template-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
    font-family: inherit;
    color: var(--text-main);
}
.task-template-card:hover { background: var(--accent-bg); border-color: var(--accent); }
.task-template-card .template-icon { font-size: 1.5rem; }
.task-template-card .template-title { font-weight: 600; font-size: 0.85rem; }
.task-template-card .template-desc { font-size: 0.75rem; color: var(--text-muted); }

/* ===== RAW SNIPPETS BLOCK (sources preview) ===== */
.raw-snippets-block { 
    margin-bottom: 16px; 
    padding: 12px; 
    background: var(--bg-sidebar); 
    border: 1px solid var(--border-color); 
    border-radius: var(--radius-card); 
    animation: fadeIn 0.2s ease-out;
}
.raw-snippets-label { 
    font-size: 0.75rem; 
    font-weight: 600; 
    color: var(--accent); 
    text-transform: uppercase; 
    letter-spacing: 0.05em; 
    margin-bottom: 8px; 
    padding-bottom: 8px; 
    border-bottom: 1px solid var(--border-color); 
}
.raw-snippets-content { 
    max-height: 300px; 
    overflow-y: auto; 
    display: flex; 
    flex-direction: column; 
    gap: 8px; 
}
.raw-snippet { 
    padding: 10px 12px; 
    background: var(--bg-card); 
    border: 1px solid var(--border-color); 
    border-radius: 8px; 
    font-size: 0.8rem; 
    line-height: 1.5; 
    transition: all var(--transition);
}
.raw-snippet:hover { 
    border-color: var(--accent); 
    background: var(--accent-bg); 
}
.snippet-meta { 
    display: block; 
    font-size: 0.65rem; 
    color: var(--text-muted); 
    font-family: 'Fira Code', monospace; 
    margin-bottom: 4px; 
}
.snippet-text { 
    color: var(--text-main); 
    white-space: pre-wrap; 
    word-break: break-word; 
    line-height: 1.5; 
}

/* Scrollbar for snippets content */
.raw-snippets-content::-webkit-scrollbar { width: 6px; }
.raw-snippets-content::-webkit-scrollbar-track { background: transparent; }
.raw-snippets-content::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 3px; }
.raw-snippets-content::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== CITATION BADGES [1] ===== */
.citation-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 4px;
    background: var(--accent-bg);
    color: var(--accent);
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 4px;
    cursor: pointer;
    transition: all var(--transition);
    vertical-align: super;
    line-height: 1;
    font-family: 'Fira Code', monospace;
}
.citation-badge:hover {
    background: var(--accent);
    color: #FFFFFF;
}

/* ===== SOURCES FOOTER ===== */
.answer-sources {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}
.answer-sources-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.source-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    cursor: pointer;
    border-radius: 6px;
    transition: all var(--transition);
    font-size: 0.8rem;
}
.source-entry:hover {
    background: var(--accent-bg);
}
.source-num {
    font-weight: 600;
    color: var(--accent);
    font-family: 'Fira Code', monospace;
    min-width: 24px;
    font-size: 0.75rem;
}
.source-ref {
    color: var(--text-main);
}
/* ===== INFO PANEL (BSR HyAirport project info) ===== */
.info-project-card { padding: 16px 14px; display: flex; flex-direction: column; gap: 14px; }
.info-project-title { font-size: 0.95rem; font-weight: 700; color: var(--text-main); line-height: 1.3; margin: 0; }
.info-project-desc { font-size: 0.78rem; line-height: 1.5; color: var(--text-muted); margin: 0; }
.info-confidential { display: flex; gap: 8px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; background: var(--accent-bg); border: 1px solid var(--border-color); font-size: 0.72rem; line-height: 1.45; color: var(--text-main); }
.info-confidential strong { color: var(--accent); }
.info-lock { flex-shrink: 0; font-size: 0.9rem; line-height: 1.45; }
.info-stats { display: flex; gap: 10px; }
.info-stat { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 12px 8px; border-radius: 8px; background: var(--bg-card); border: 1px solid var(--border-color); }
.info-stat-value { font-size: 1.3rem; font-weight: 700; color: var(--accent); }
.info-stat-label { font-size: 0.65rem; text-align: center; color: var(--text-muted); line-height: 1.3; }
.info-examples { display: flex; flex-direction: column; gap: 6px; }
.info-examples-title { font-size: 0.75rem; font-weight: 600; color: var(--text-main); margin: 0; }
.info-examples-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.info-examples-list li { font-size: 0.72rem; line-height: 1.4; color: var(--text-muted); padding-left: 12px; position: relative; }
.info-examples-list li::before { content: '›'; position: absolute; left: 0; color: var(--accent); font-weight: 700; }

/* Chunk settings inline (admin header) */
.chunk-settings-inline { display: flex; align-items: center; gap: 4px; }
.chunk-settings-inline label { font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; }
.chunk-settings-inline input { padding: 6px 8px; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: 6px; color: var(--text-main); font-family: inherit; font-size: 0.8rem; outline: none; }
.chunk-settings-inline input:focus { border-color: var(--accent); }

/* ===== T7: CHUNKS BUTTON IN PDF PANEL HEADER ===== */
.pdf-chunks-btn {
    padding: 4px 10px;
    border-radius: 6px;
    background: var(--accent, #2563eb);
    color: white;
    border: none;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all var(--transition);
    white-space: nowrap;
}
.pdf-chunks-btn:hover {
    background: var(--accent-hover, #1d4ed8);
    transform: translateY(-1px);
}

/* Chunk text modal */
#chunk-text-content h3 {
    margin-top: 16px;
    margin-bottom: 8px;
    font-size: 1rem;
    color: var(--text-main, #1f2937);
}
#chunk-text-content h3:first-child {
    margin-top: 0;
}
#chunk-text-content pre {
    background: var(--bg-secondary, #f3f4f6);
    padding: 12px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 12px 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--text-main);
}
#chunk-text-content .chunk-section-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    margin-bottom: -4px;
}
