:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #12121a;
  --bg-card: #16161f;
  --bg-elevated: #1c1c28;
  --bg-input: #1a1a26;
  --accent-1: #34d399;
  --accent-2: #06b6d4;
  --accent-glow: rgba(52, 211, 153, 0.15);
  --text-primary: #e8e8ed;
  --text-secondary: #8b8b9e;
  --text-muted: #5a5a6e;
  --text-accent: #34d399;
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(52, 211, 153, 0.25);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body { font-family: var(--font); background: var(--bg-primary); color: var(--text-primary); min-height: 100vh; overflow-x: hidden; }

.backdrop-glow { position: fixed; top: -200px; left: 50%; transform: translateX(-50%); width: 800px; height: 500px; background: radial-gradient(ellipse, rgba(52, 211, 153, 0.06) 0%, transparent 70%); pointer-events: none; z-index: 0; }
.app { position: relative; z-index: 1; max-width: 760px; margin: 0 auto; padding: 40px 24px 60px; }

/* Header */
.header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 36px; }
.logo { display: flex; align-items: center; gap: 14px; }
.logo-icon { width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--accent-1), var(--accent-2)); border-radius: var(--radius-md); color: #0a0a0f; box-shadow: 0 4px 20px rgba(52, 211, 153, 0.25); }
.header h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
.tagline { font-size: 0.85rem; color: var(--text-secondary); margin-top: 2px; }
.header-badge { display: flex; align-items: center; gap: 8px; padding: 6px 14px; background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: 999px; font-size: 0.78rem; color: var(--text-muted); white-space: nowrap; }
.badge-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted); flex-shrink: 0; }
.header-badge.active .badge-dot { background: var(--accent-1); box-shadow: 0 0 8px rgba(52, 211, 153, 0.5); animation: pulse-dot 2s ease-in-out infinite; }
.header-badge.active { color: var(--text-secondary); border-color: var(--border-accent); }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.header-actions { display: flex; align-items: center; gap: 12px; }
.new-chat-btn { display: flex; align-items: center; gap: 6px; padding: 6px 14px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border-subtle); border-radius: 999px; color: var(--text-primary); font-family: var(--font); font-size: 0.8rem; font-weight: 500; cursor: pointer; transition: all var(--transition); }
.new-chat-btn:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.15); transform: translateY(-1px); }
.new-chat-btn svg { opacity: 0.8; }

/* Upload */
.upload-card { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-xl); padding: 24px; box-shadow: var(--shadow-lg); }
.upload-dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 48px 24px; border: 2px dashed rgba(255, 255, 255, 0.08); border-radius: var(--radius-lg); cursor: pointer; transition: border-color var(--transition), background var(--transition); }
.upload-dropzone:hover, .upload-dropzone.drag-over { border-color: var(--accent-1); background: var(--accent-glow); }
.upload-icon-wrapper { width: 80px; height: 80px; display: flex; align-items: center; justify-content: center; background: rgba(52, 211, 153, 0.08); border-radius: 50%; margin-bottom: 16px; transition: transform var(--transition); }
.upload-dropzone:hover .upload-icon-wrapper { transform: translateY(-4px); }
.upload-icon { color: var(--accent-1); }
.upload-main-text { font-size: 1.05rem; font-weight: 600; margin-bottom: 6px; }
.upload-sub-text { font-size: 0.85rem; color: var(--text-muted); }
.upload-browse { color: var(--accent-1); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

.upload-file-info { display: flex; align-items: center; gap: 12px; margin-top: 16px; padding: 12px 16px; background: var(--bg-elevated); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); animation: fade-in 0.25s ease; }
.file-icon { color: var(--accent-1); flex-shrink: 0; }
.file-details { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.file-name { font-size: 0.9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 0.78rem; color: var(--text-muted); }
.file-remove { background: none; border: none; color: var(--text-muted); font-size: 1.3rem; cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm); transition: color var(--transition), background var(--transition); }
.file-remove:hover { color: #f87171; background: rgba(248, 113, 113, 0.1); }

.upload-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; margin-top: 16px; padding: 14px 24px; background: linear-gradient(135deg, var(--accent-1), var(--accent-2)); color: #0a0a0f; font-family: var(--font); font-size: 0.95rem; font-weight: 600; border: none; border-radius: var(--radius-md); cursor: pointer; transition: opacity var(--transition), transform var(--transition), box-shadow var(--transition); box-shadow: 0 4px 16px rgba(52, 211, 153, 0.2); }
.upload-btn:hover:not(:disabled) { opacity: 0.92; transform: translateY(-1px); box-shadow: 0 6px 24px rgba(52, 211, 153, 0.3); }
.upload-btn:disabled { opacity: 0.35; cursor: not-allowed; box-shadow: none; }

.progress-container { margin-top: 20px; animation: fade-in 0.3s ease; }
.progress-label { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 8px; }
.progress-bar-track { width: 100%; height: 6px; background: var(--bg-elevated); border-radius: 999px; overflow: hidden; }
.progress-bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent-1), var(--accent-2)); border-radius: 999px; transition: width 0.4s ease; }

/* Chat */
.chat-section { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: var(--radius-xl); padding: 20px; box-shadow: var(--shadow-lg); animation: slide-up 0.4s ease; }
.messages { min-height: 320px; max-height: 520px; overflow-y: auto; margin-bottom: 16px; display: flex; flex-direction: column; gap: 12px; padding: 8px 4px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.08) transparent; }
.messages::-webkit-scrollbar { width: 5px; }
.messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 999px; }

.message { padding: 12px 16px; border-radius: var(--radius-md); max-width: 82%; line-height: 1.6; font-size: 0.92rem; animation: fade-in 0.25s ease; word-wrap: break-word; }
.message.user { align-self: flex-end; background: linear-gradient(135deg, var(--accent-1), var(--accent-2)); color: #0a0a0f; font-weight: 500; border-bottom-right-radius: 4px; }
.message.assistant { align-self: flex-start; background: var(--bg-elevated); color: var(--text-primary); border: 1px solid var(--border-subtle); border-bottom-left-radius: 4px; }
.message.system { align-self: center; background: none; color: var(--text-muted); font-size: 0.82rem; font-style: italic; padding: 8px 0; }
.message.assistant.thinking { color: var(--text-muted); }
.message.assistant.thinking::after { content: ''; display: inline-block; width: 4px; height: 4px; background: var(--text-muted); border-radius: 50%; margin-left: 6px; animation: blink 1s step-end infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

.input-row { display: flex; gap: 10px; }
.input-wrapper { flex: 1; }
.input-wrapper input { width: 100%; padding: 13px 18px; background: var(--bg-input); border: 1px solid var(--border-subtle); border-radius: var(--radius-md); color: var(--text-primary); font-family: var(--font); font-size: 0.92rem; outline: none; transition: border-color var(--transition), box-shadow var(--transition); }
.input-wrapper input::placeholder { color: var(--text-muted); }
.input-wrapper input:focus { border-color: var(--accent-1); box-shadow: 0 0 0 3px var(--accent-glow); }

.ask-btn { width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, var(--accent-1), var(--accent-2)); color: #0a0a0f; border: none; border-radius: var(--radius-md); cursor: pointer; flex-shrink: 0; transition: opacity var(--transition), transform var(--transition); }
.ask-btn:hover { opacity: 0.9; transform: scale(1.04); }
.ask-btn:disabled { opacity: 0.3; cursor: not-allowed; transform: none; }

/* Animations */
@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slide-up { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }

/* Responsive */
@media (max-width: 640px) {
  .app { padding: 24px 16px 40px; }
  .header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .upload-dropzone { padding: 36px 16px; }
  .message { max-width: 92%; }
}
