:root {
  --bg: #0c0f14;
  --bg-elevated: #121722;
  --border: #1e2636;
  --text: #e8ecf4;
  --muted: #8b95a8;
  --accent: #3b82f6;
  --accent-dim: #2563eb;
  --user-bubble: #1a2332;
  --assistant-bubble: #0f1624;
  --ring: rgba(59, 130, 246, 0.35);
  --radius: 12px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

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

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 10% -10%, #152036 0%, transparent 55%),
    radial-gradient(900px 500px at 90% 0%, #0f1c2e 0%, transparent 50%), var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.page {
  min-height: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.header {
  padding-top: 0.25rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.875rem;
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--accent), #1d4ed8);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08) inset, 0 8px 24px var(--ring);
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 0.15rem 0 0;
  font-size: 0.875rem;
  color: var(--muted);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
}

.intro p {
  margin: 0;
  font-size: 0.95rem;
  color: #c5cddc;
}

.intro strong {
  color: var(--text);
  font-weight: 600;
}

.chat {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 420px;
}

.messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 0.25rem 0.15rem 0.5rem;
  max-height: min(52vh, 480px);
  scroll-behavior: smooth;
}

.msg {
  max-width: 92%;
  padding: 0.65rem 0.85rem;
  border-radius: 10px;
  font-size: 0.9375rem;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.msg.assistant {
  align-self: flex-start;
  background: var(--assistant-bubble);
  border: 1px solid #243044;
  font-family: var(--mono);
  font-size: 0.875rem;
}

.msg .role {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.35rem;
  font-family: var(--font);
}

.error {
  color: #fca5a5;
  font-size: 0.875rem;
  padding: 0.35rem 0;
}

.composer {
  padding-top: 0.25rem;
  border-top: 1px solid var(--border);
}

.composer-bar {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0a0d12;
  overflow: hidden;
}

.composer-bar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--ring);
}

.composer-bar textarea {
  flex: 1;
  min-width: 0;
  resize: vertical;
  min-height: 44px;
  max-height: 160px;
  padding: 0.6rem 0.75rem;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9375rem;
}

.composer-bar textarea:focus {
  outline: none;
}

.composer-bar .btn-primary {
  flex-shrink: 0;
  min-width: 92px;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 0;
  border-left: 1px solid var(--border);
  background: linear-gradient(180deg, var(--accent), var(--accent-dim));
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
  align-self: stretch;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.footer {
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (min-width: 640px) {
  .page {
    padding: 2rem 1.5rem;
  }

  .brand h1 {
    font-size: 1.5rem;
  }
}
