* { box-sizing: border-box; margin: 0; padding: 0; }
      
:root {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #60a5fa;
  --secondary: #8b5cf6;
  --success: #10b981;
  --background: #0f172a;
  --surface: #1e293b;
  --surface-light: #334155;
  --border: #334155;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --shadow: rgba(0, 0, 0, 0.3);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: var(--text);
  line-height: 1.6;
}

.container {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Layout */
.layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 4px 0 12px var(--shadow);
}

.brand {
  padding: 24px 20px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 32px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-5px); }
}

.brand-text h2 {
  font-size: 24px;
  font-weight: 700;
  color: white;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.brand-text span {
  color: rgba(255,255,255,0.9);
  font-size: 13px;
  font-weight: 500;
}

.tabs {
  display: flex;
  padding: 16px 12px 8px;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.tab-btn {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
  position: relative;
}

.tab-btn:hover {
  background: var(--surface-light);
  color: var(--text);
}

.tab-btn.active {
  background: var(--primary);
  color: white;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
}

.sidebar-content::-webkit-scrollbar { width: 6px; }
.sidebar-content::-webkit-scrollbar-track { background: var(--surface); }
.sidebar-content::-webkit-scrollbar-thumb { background: var(--surface-light); border-radius: 3px; }

.tab-panel[hidden] { display: none; }

.tab-panel h3 {
  font-size: 16px;
  margin-bottom: 12px;
  color: var(--primary-light);
}

.tab-panel p {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 16px;
  line-height: 1.5;
}

.bullets {
  list-style: none;
  margin: 16px 0;
}

.bullets li {
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--surface-light);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-muted);
  border-left: 3px solid var(--primary);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  padding: 12px 14px;
  background: var(--surface-light);
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.history-item.active {
  background: var(--primary);
  border-color: var(--primary-light);
}

.history-item::before {
  content: '💬';
  font-size: 16px;
}

.history-title {
  flex: 1;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Content area */
.content {
  display: flex;
  flex-direction: column;
  background: var(--background);
  overflow: hidden;
}

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

.header h1 {
  font-size: 28px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 4px;
}

.header p {
  color: var(--text-muted);
  font-size: 13px;
}

.header code {
  background: var(--surface-light);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--primary-light);
}

.session-actions .ghost {
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.session-actions .ghost:hover {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* Chat area */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  gap: 16px;
  overflow: hidden;
}

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

.messages::-webkit-scrollbar { width: 8px; }
.messages::-webkit-scrollbar-track { background: var(--surface); border-radius: 4px; }
.messages::-webkit-scrollbar-thumb { background: var(--surface-light); border-radius: 4px; }

.msg {
  display: flex;
  animation: slideIn 0.3s ease;
}

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

.msg.user { justify-content: flex-end; }
.msg.bot { justify-content: flex-start; }

.msg .bubble {
  max-width: 70%;
  padding: 14px 18px;
  border-radius: 16px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: 0 2px 8px var(--shadow);
}

.msg.user .bubble {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.msg.bot .bubble {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg.bot.thinking .bubble {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: #1e293b;
  animation: pulse 1.5s ease-in-out infinite;
}

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

.sources {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

.chat-form {
  display: flex;
  gap: 12px;
  background: var(--surface);
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px var(--shadow);
}

.chat-form input[type="text"] {
  flex: 1;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-light);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: all 0.2s ease;
}

.chat-form input[type="text"]:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.chat-form input[type="text"]::placeholder {
  color: var(--text-muted);
}

.chat-form button {
  padding: 14px 28px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.chat-form button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

.chat-form button:active {
  transform: translateY(0);
}

.primary {
  width: 100%;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(59, 130, 246, 0.4);
}

footer {
  padding: 16px 24px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}

footer code {
  background: var(--surface-light);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--primary-light);
}

.muted {
  color: var(--text-muted);
  font-size: 12px;
  display: block;
  margin-top: 12px;
  padding: 8px;
  background: var(--surface-light);
  border-radius: 6px;
}

/* Responsive */
@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .sidebar {
    display: none;
  }
}