:root {
  --bg: #1a1f24;
  --surface: #242b33;
  --border: #3a4550;
  --text: #e8eef2;
  --muted: #9aa7b2;
  --accent: #3d8b6e;
  --accent-hover: #4aa37f;
  --danger: #c45c5c;
  --user-bubble: #2d4a3e;
  --bot-bubble: #2a3139;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

a {
  color: var(--accent);
}

.page {
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.page-center {
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow: auto;
}

.card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem;
}

.card h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
  font-weight: 600;
}

.card .subtitle {
  margin: 0 0 1.5rem;
  color: var(--muted);
  font-size: 0.95rem;
}

label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.7rem 0.85rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1rem;
}

input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

button, .btn {
  display: inline-block;
  border: none;
  border-radius: 8px;
  padding: 0.7rem 1.1rem;
  font-size: 1rem;
  font-family: inherit;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
}

button:hover, .btn:hover {
  background: var(--accent-hover);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

button.secondary {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
}

button.secondary:hover {
  color: var(--text);
  background: var(--bg);
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 0 0 1rem;
  min-height: 1.2em;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

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

.chat-header .meta {
  color: var(--muted);
  font-size: 0.85rem;
  margin-right: 0.75rem;
}

.chat-header .actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

#messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.msg {
  max-width: min(85%, 560px);
  padding: 0.75rem 1rem;
  border-radius: 12px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}

.msg.user {
  align-self: flex-end;
  background: var(--user-bubble);
}

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

.msg.system {
  align-self: center;
  color: var(--muted);
  font-size: 0.85rem;
  background: transparent;
}

.composer {
  display: flex;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.composer textarea {
  flex: 1;
  resize: none;
  min-height: 44px;
  max-height: 140px;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.35;
}

.composer textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.composer button {
  align-self: flex-end;
}

.full-width {
  width: 100%;
}
