:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #2454ff;
  --primary-dark: #173bbf;
  --bot: #eef2ff;
  --user: #2454ff;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top left, #e8edff, transparent 32%), var(--bg);
  color: var(--text);
}

.page {
  min-height: 100vh;
  padding: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-card {
  width: min(980px, 100%);
  height: min(860px, calc(100vh - 56px));
  background: var(--card);
  border: 1px solid rgba(226, 232, 240, .9);
  border-radius: 28px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .13);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chat-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  font-weight: 900;
  letter-spacing: -.04em;
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
}

p {
  margin: 5px 0 0;
  color: var(--muted);
}

.ghost-btn {
  border: 1px solid var(--line);
  background: #fff;
  color: #334155;
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 700;
}

.ghost-btn:hover { background: #f8fafc; }

.intro-panel {
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: #fbfcff;
}

.intro-panel strong {
  display: block;
  margin-bottom: 10px;
  font-size: 14px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chips button {
  border: 1px solid #dbe3ff;
  background: #eef2ff;
  color: var(--primary);
  border-radius: 999px;
  padding: 8px 11px;
  cursor: pointer;
  font-weight: 700;
}

.chips button:hover { background: #e0e7ff; }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.message {
  max-width: 80%;
  padding: 14px 16px;
  border-radius: 18px;
  font-size: 15px;
  line-height: 1.48;
  white-space: pre-wrap;
  word-break: break-word;
}

.message.bot {
  align-self: flex-start;
  background: var(--bot);
  color: #1e293b;
  border-bottom-left-radius: 7px;
}

.message.user {
  align-self: flex-end;
  background: var(--user);
  color: #fff;
  border-bottom-right-radius: 7px;
}

.message.error {
  align-self: flex-start;
  background: var(--danger-bg);
  color: var(--danger-text);
}

.message.loading {
  opacity: .8;
}

.chat-form {
  padding: 16px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 12px;
  align-items: flex-end;
  background: #fff;
}

.chat-form textarea {
  flex: 1;
  max-height: 160px;
  resize: none;
  border: 1px solid #d1d5db;
  border-radius: 18px;
  padding: 13px 15px;
  font: inherit;
  line-height: 1.35;
  outline: none;
}

.chat-form textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(36, 84, 255, .12);
}

.chat-form button {
  border: 0;
  background: var(--primary);
  color: #fff;
  min-height: 48px;
  border-radius: 16px;
  padding: 0 22px;
  cursor: pointer;
  font-weight: 900;
}

.chat-form button:hover { background: var(--primary-dark); }
.chat-form button:disabled { opacity: .55; cursor: not-allowed; }

@media (max-width: 680px) {
  .page { padding: 0; }
  .chat-card { height: 100vh; border-radius: 0; }
  .chat-header { align-items: flex-start; flex-direction: column; }
  .message { max-width: 92%; }
  .chat-form { gap: 8px; }
  .chat-form button { padding: 0 16px; }
}

.message a {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.message.bot a {
  color: var(--primary-dark);
}

.message.user a {
  color: #fff;
}

.message.bot strong {
  display: inline-block;
  margin-top: 4px;
  color: #0f172a;
}

.message.bot a {
  display: inline-block;
  margin-left: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #c7d2fe;
  color: var(--primary-dark);
  text-decoration: none;
  font-weight: 800;
  white-space: nowrap;
}

.message.bot a:hover {
  background: #e0e7ff;
}
