:root {
  --bg: #0a0a0b;
  --surface: #141416;
  --surface-2: #1c1c20;
  --border: #2a2a30;
  --text: #e4e4e7;
  --text-muted: #71717a;
  --accent: #f97316;
  --accent-dim: #f9731620;
  --user-bg: #1a1a2e;
  --assistant-bg: #141416;
  --success: #22c55e;
  --error: #ef4444;
}

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

body {
  font-family: 'IBM Plex Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100vh;
  display: flex;
  overflow: hidden;
}

/* ---- Sidebar ---- */
.sidebar {
  width: 320px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  flex-shrink: 0;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: -0.5px;
}

.logo span { color: var(--text-muted); font-weight: 400; }

.tagline {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: 'IBM Plex Mono', monospace;
}

.upload-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.upload-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 500;
}

.upload-zone {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
}

.upload-zone:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.upload-zone.dragging {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.upload-icon { font-size: 24px; margin-bottom: 8px; }

.upload-text { font-size: 13px; color: var(--text-muted); }
.upload-text strong { color: var(--accent); }

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.title-input {
  width: 100%;
  margin-top: 10px;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-family: 'IBM Plex Sans', sans-serif;
  outline: none;
}

.title-input:focus { border-color: var(--accent); }

.upload-btn {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'IBM Plex Sans', sans-serif;
  transition: opacity 0.2s;
}

.upload-btn:hover { opacity: 0.9; }
.upload-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---- Papers list ---- */
.papers-section {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.papers-section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 500;
}

.paper-card {
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.paper-card:hover { border-color: var(--accent); }

.paper-card.active {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.paper-card-top {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin-bottom: 4px;
}

.paper-title {
  font-size: 13px;
  font-weight: 500;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.delete-paper-btn {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}

.paper-card:hover .delete-paper-btn { opacity: 1; }
.delete-paper-btn:hover { color: var(--error); }

.paper-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
  display: flex;
  gap: 8px;
  align-items: center;
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.ready { background: var(--success); }
.status-dot.processing { background: var(--accent); animation: pulse 1.5s infinite; }
.status-dot.failed { background: var(--error); }

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

.empty-state {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 20px;
}

/* ---- Chat Area ---- */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

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

.chat-header-title { font-size: 14px; font-weight: 500; }

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

.header-btn {
  padding: 6px 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  font-family: 'IBM Plex Sans', sans-serif;
  transition: all 0.2s;
}

.header-btn:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: flex;
  gap: 12px;
  max-width: 800px;
  animation: fadeIn 0.3s ease;
}

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

.message.user { align-self: flex-end; flex-direction: row-reverse; }

.avatar {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex-shrink: 0;
  font-family: 'IBM Plex Mono', monospace;
  font-weight: 600;
}

.message.user .avatar {
  background: var(--accent-dim);
  color: var(--accent);
}

.message.assistant .avatar {
  background: var(--surface-2);
  color: var(--text-muted);
}

.message-content {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.6;
}

.message.user .message-content {
  background: var(--user-bg);
  border: 1px solid #2a2a4a;
}

.message.assistant .message-content {
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.message-sources {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'IBM Plex Mono', monospace;
}

.welcome-message {
  text-align: center;
  padding: 60px 40px;
  max-width: 500px;
  margin: auto;
}

.welcome-icon { font-size: 40px; margin-bottom: 16px; }

.welcome-message h2 {
  font-size: 20px;
  font-weight: 500;
  margin-bottom: 8px;
}

.welcome-message p {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

/* ---- Input area ---- */
.input-area {
  padding: 16px 24px 24px;
  border-top: 1px solid var(--border);
}

.input-wrapper {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.input-wrapper textarea {
  flex: 1;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-family: 'IBM Plex Sans', sans-serif;
  resize: none;
  outline: none;
  min-height: 44px;
  max-height: 120px;
  line-height: 1.5;
}

.input-wrapper textarea:focus { border-color: var(--accent); }

.send-btn {
  padding: 12px 20px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'IBM Plex Sans', sans-serif;
  transition: opacity 0.2s;
  white-space: nowrap;
}

.send-btn:hover { opacity: 0.9; }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.powered-by {
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 10px;
  font-family: 'IBM Plex Mono', monospace;
}

.powered-by a { color: var(--accent); text-decoration: none; }

/* ---- Loading dots ---- */
.loading-dots span {
  animation: blink 1.4s infinite;
  font-size: 20px;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 100;
  animation: slideIn 0.3s ease;
}

.toast.success { background: #16a34a; color: #fff; }
.toast.error { background: #dc2626; color: #fff; }

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

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .sidebar { display: none; }
}
