:root {
  --bg: #0f0f11;
  --surface: #18181b;
  --surface-hover: #27272a;
  --border: #3f3f46;
  --text: #fafafa;
  --text-muted: #a1a1aa;
  --accent: #22d3ee;
  --accent-dim: #0891b2;
  --user-bubble: #2d2d32;
  --bot-bubble: #1e1e22;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --font-sans: "DM Sans", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app {
  flex: 1;
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto;
  width: 100%;
  padding: 0 16px;
  min-height: 100vh;
}

.header {
  flex-shrink: 0;
  padding: 24px 0 16px;
  border-bottom: 1px solid var(--border);
}

.header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 4px 0 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 16px 0 24px;
}

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

.message {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  animation: messageIn 0.25s ease-out;
}

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

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

.message__avatar {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: var(--font-mono);
}

.message--bot .message__avatar {
  background: var(--accent-dim);
  color: var(--bg);
}

.message--user .message__avatar {
  background: var(--border);
  color: var(--text-muted);
}

.message__bubble {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.95rem;
}

.message--bot .message__bubble {
  background: var(--bot-bubble);
  border: 1px solid var(--border);
}

.message--user .message__bubble {
  background: var(--user-bubble);
  border: 1px solid var(--border);
}

.message__bubble p {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.message__bubble p + p {
  margin-top: 8px;
}

.message__sources {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.message__sources span {
  font-weight: 500;
  color: var(--text);
}

.message--loading .message__bubble {
  color: var(--text-muted);
}

.message--error .message__bubble {
  border-color: #b91c1c;
  color: #fca5a5;
}

.input-row {
  flex-shrink: 0;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 12px 0 0;
  border-top: 1px solid var(--border);
}

.input {
  flex: 1;
  min-height: 48px;
  max-height: 160px;
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input::placeholder {
  color: var(--text-muted);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15);
}

.input:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-send {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  font-size: 1.25rem;
}

.btn-send:hover:not(:disabled) {
  background: #06b6d4;
}

.btn-send:active:not(:disabled) {
  transform: scale(0.97);
}

.btn-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-send__icon {
  line-height: 1;
}
