:root {
  color-scheme: light;
  --bg: #eef4ff;
  --bg-end: #dbe7ff;
  --panel: #ffffff;
  --ink: #14233d;
  --muted: #5b6b86;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --border: #d4e0f5;
  --soft: #f3f7ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-end) 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.page {
  width: min(760px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0;
}

.header {
  text-align: center;
  margin-bottom: 24px;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 5vw, 40px);
  letter-spacing: -0.03em;
  color: var(--accent-dark);
}

.subtitle {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.chat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 20px 50px rgba(37, 99, 235, 0.12);
  padding: 20px;
  display: grid;
  gap: 16px;
}

.messages {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 320px;
  max-height: 60vh;
  overflow-y: auto;
}

.message {
  border-radius: 16px;
  line-height: 1.55;
  padding: 12px 16px;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.user {
  background: var(--accent);
  color: white;
  justify-self: end;
  max-width: 85%;
}

.message.assistant {
  background: var(--soft);
  border: 1px solid var(--border);
  justify-self: start;
  max-width: 90%;
}

.message.error {
  background: #fff2f2;
  border: 1px solid #ffd1d1;
  color: #8b1d1d;
  justify-self: start;
  max-width: 90%;
}

.chat-form {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

input,
textarea,
button {
  font: inherit;
}

textarea {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 14px;
  min-height: 52px;
  max-height: 160px;
  padding: 14px;
  resize: vertical;
}

textarea:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(37, 99, 235, 0.16);
}

button {
  background: var(--accent);
  border: 0;
  border-radius: 14px;
  color: white;
  cursor: pointer;
  font-weight: 700;
  padding: 14px 22px;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

@media (max-width: 600px) {
  .message.user,
  .message.assistant {
    max-width: 100%;
  }
}
