:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --surface-2: #243044;
  --border: #2d3a4f;
  --text: #e8edf4;
  --text-muted: #94a3b8;
  --primary: #0078d4;
  --primary-hover: #106ebe;
  --success: #22c55e;
  --warning: #f59e0b;
  --error: #ef4444;
  --assistant-bg: #1e293b;
  --user-bg: #0d4a7a;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

code {
  background: var(--surface-2);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.85em;
}

/* Login */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background:
    radial-gradient(circle at 20% 20%, rgba(0, 120, 212, 0.15), transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(34, 197, 94, 0.08), transparent 40%),
    var(--bg);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.brand {
  text-align: center;
  margin-bottom: 1.75rem;
}

.brand-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), #005a9e);
  border-radius: 14px;
  font-weight: 700;
  font-size: 1.1rem;
}

.brand-icon.small {
  width: 32px;
  height: 32px;
  font-size: 0.75rem;
  border-radius: 8px;
  margin: 0;
}

.brand h1 {
  font-size: 1.5rem;
  font-weight: 600;
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 0.25rem;
}

.login-form label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
}

.login-form input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  margin-bottom: 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
}

.login-form input:focus {
  outline: none;
  border-color: var(--primary);
}

.demo-hint {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
}

.demo-hint .sep {
  margin: 0 0.35rem;
  opacity: 0.5;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}

.btn-primary {
  width: 100%;
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.full-width {
  width: 100%;
}

/* Alerts */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.alert-error {
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

/* Chat layout */
.chat-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-title {
  font-weight: 600;
}

.status-pill {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-muted);
}

.status-pill.ok {
  background: rgba(34, 197, 94, 0.15);
  color: #86efac;
}

.status-pill.warn {
  background: rgba(245, 158, 11, 0.15);
  color: #fcd34d;
}

.status-pill.error {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.user-badge {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.chat-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  padding: 1.25rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.sidebar h2 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.suggestions {
  list-style: none;
  margin-bottom: 1.25rem;
}

.suggestion {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.75rem;
  margin-bottom: 0.4rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.suggestion:hover {
  border-color: var(--primary);
  background: rgba(0, 120, 212, 0.1);
}

.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.message {
  display: flex;
  gap: 0.75rem;
  max-width: min(95%, 960px);
}

.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--primary), #005a9e);
}

.message.user .avatar {
  background: var(--surface-2);
  color: var(--text-muted);
}

.bubble {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  background: var(--assistant-bg);
  border: 1px solid var(--border);
  font-size: 0.95rem;
}

.message.user .bubble {
  background: var(--user-bg);
  border-color: rgba(0, 120, 212, 0.4);
}

.bubble p {
  margin-bottom: 0.5rem;
}

.bubble p:last-child {
  margin-bottom: 0;
}

.bubble.loading {
  color: var(--text-muted);
  font-style: italic;
}

.bubble .markdown-content > :first-child {
  margin-top: 0;
}

.bubble .markdown-content > :last-child {
  margin-bottom: 0;
}

.bubble .markdown-content p {
  margin-bottom: 0.5rem;
}

.bubble .markdown-content p:last-child {
  margin-bottom: 0;
}

.bubble .markdown-content ul,
.bubble .markdown-content ol {
  margin: 0.5rem 0;
  padding-left: 1.25rem;
}

.bubble .markdown-content li {
  margin-bottom: 0.25rem;
}

.bubble .markdown-content h1,
.bubble .markdown-content h2,
.bubble .markdown-content h3 {
  margin: 0.75rem 0 0.5rem;
  font-size: 1rem;
  font-weight: 600;
}

.bubble .markdown-content code {
  background: var(--surface-2);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}

.bubble .markdown-content pre {
  margin: 0.5rem 0;
  padding: 0.75rem;
  background: var(--surface-2);
  border-radius: 8px;
  overflow-x: auto;
}

.bubble .markdown-content pre code {
  background: none;
  padding: 0;
}

.bubble .markdown-content table {
  width: 100%;
  margin: 0.75rem 0;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.bubble .markdown-content th,
.bubble .markdown-content td {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  text-align: left;
}

.bubble .markdown-content th {
  background: var(--surface-2);
  font-weight: 600;
}

.bubble .markdown-content tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

.bubble .markdown-content blockquote {
  margin: 0.5rem 0;
  padding-left: 0.75rem;
  border-left: 3px solid var(--primary);
  color: var(--text-muted);
}

.bubble .markdown-content strong {
  font-weight: 600;
}

.bubble .markdown-content em {
  color: var(--text-muted);
}

.composer {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.composer textarea {
  flex: 1;
  resize: none;
  padding: 0.75rem 1rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.4;
}

.composer textarea:focus {
  outline: none;
  border-color: var(--primary);
}

.composer .btn-primary {
  width: auto;
  align-self: flex-end;
  min-width: 88px;
}

.composer-alert {
  margin: 0 1.25rem 1rem;
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
}
