:root {
  --bg: #0f1115;
  --panel: #161923;
  --panel-2: #1d2130;
  --border: #2a2f3f;
  --text: #e8eaf0;
  --text-dim: #9aa0b4;
  --accent: #7c9eff;
  --accent-dim: #3a4670;
  --user-bubble: #2c3a63;
  --bot-bubble: #1d2130;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.app {
  max-width: 780px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

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

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.lang-toggle {
  display: flex;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.lang-btn {
  background: var(--panel-2);
  color: var(--text-dim);
  border: none;
  padding: 6px 12px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.lang-btn:first-child {
  border-right: 1px solid var(--border);
}

.lang-btn.active {
  background: var(--accent);
  color: #0f1115;
}

.header-title h1 {
  font-size: 1.15rem;
  margin: 0;
  font-weight: 600;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 8px #4ade80;
  flex-shrink: 0;
}

.header-sub {
  margin: 6px 0 0;
  color: var(--text-dim);
  font-size: 0.85rem;
}

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

.msg {
  max-width: 85%;
  padding: 12px 14px;
  border-radius: 14px;
  line-height: 1.5;
  font-size: 0.95rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.msg.user {
  align-self: flex-end;
  background: var(--user-bubble);
  border-bottom-right-radius: 4px;
}

.msg.bot {
  align-self: flex-start;
  background: var(--bot-bubble);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.msg.pending {
  color: var(--text-dim);
  font-style: italic;
}

.sources {
  align-self: flex-start;
  max-width: 85%;
  margin-top: -8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sources-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: 2px;
}

.source-chip {
  font-size: 0.75rem;
  color: var(--text-dim);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
}

.source-chip .source-doc {
  color: var(--accent);
  font-weight: 600;
}

.composer {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--panel);
}

.composer input {
  flex: 1;
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--text);
  font-size: 0.95rem;
}

.composer input:focus {
  outline: none;
  border-color: var(--accent);
}

.composer button {
  background: var(--accent);
  color: #0f1115;
  border: none;
  border-radius: 10px;
  padding: 0 20px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}

.composer button:disabled {
  opacity: 0.5;
  cursor: default;
}

.app-footer {
  padding: 12px 20px 20px;
  font-size: 0.75rem;
  color: var(--text-dim);
  line-height: 1.5;
  border-top: 1px solid var(--border);
}
