:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #f7f8fc;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --muted: #737e91;
  --line: #e6e9f0;
  --accent: #5a5be7;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 15% 5%, rgba(109, 110, 240, .08), transparent 36rem),
    #f7f8fc;
}

button, textarea { font: inherit; }

.page-shell {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 36px 20px 20px;
}

.chat-card {
  display: flex;
  width: min(100%, 820px);
  height: min(760px, calc(100vh - 100px));
  min-height: 480px;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(226, 230, 239, .9);
  border-radius: 22px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(40, 48, 80, .10), 0 3px 12px rgba(40, 48, 80, .04);
}

.topbar {
  display: flex;
  min-height: 82px;
  align-items: center;
  gap: 13px;
  padding: 17px 23px;
  border-bottom: 1px solid var(--line);
}

.brand-mark, .avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  font-size: 12px;
  font-weight: 750;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: #eeefff;
  color: var(--accent);
  letter-spacing: -.04em;
}

.eyebrow {
  margin: 0 0 2px;
  color: #8a91a3;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .12em;
}

h1 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.02em; }

.status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
  color: #687488;
  font-size: 12px;
}

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #30b879; }

.messages {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 22px;
  overflow-y: auto;
  padding: 30px clamp(18px, 5vw, 44px);
  scroll-behavior: smooth;
}

.message { display: flex; max-width: 88%; align-items: flex-end; gap: 10px; }
.user-message { align-self: flex-end; flex-direction: row-reverse; }

.avatar {
  width: 30px;
  height: 30px;
  border: 1px solid #e7e9f1;
  border-radius: 11px;
  background: #fff;
  color: #7a8192;
  font-size: 10px;
}

.assistant-message .avatar { background: #f1f1ff; border-color: #e8e8ff; color: var(--accent); }
.user-message .avatar { background: #e9efff; border-color: #e0e8ff; color: #4e68b7; }

.bubble {
  max-width: 100%;
  border: 1px solid #eceef4;
  border-radius: 16px 16px 16px 5px;
  background: #fafbfe;
  color: #30394b;
  line-height: 1.65;
  overflow-wrap: anywhere;
  padding: 11px 15px;
  white-space: pre-wrap;
}

.bubble p { margin: 0; }
.user-message .bubble { border-color: #e0e3ff; border-radius: 16px 16px 5px 16px; background: #f0f1ff; }

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 10px;
  margin: 0 22px 20px;
  padding: 12px 12px 8px 16px;
  border: 1px solid #e3e6ef;
  border-radius: 17px;
  background: #fff;
  box-shadow: 0 5px 18px rgba(37, 45, 74, .045);
}

.composer:focus-within { border-color: #c9caff; box-shadow: 0 0 0 3px rgba(90, 91, 231, .08); }

textarea {
  width: 100%;
  max-height: 180px;
  min-height: 35px;
  resize: none;
  border: 0;
  outline: 0;
  padding: 7px 0;
  color: #222b3b;
  line-height: 1.5;
}

textarea::placeholder { color: #a0a6b4; }

.composer button {
  display: inline-flex;
  height: 38px;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 12px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  padding: 0 12px;
  transition: background .16s ease, transform .16s ease;
}

.composer button:hover:not(:disabled) { background: #494ad1; transform: translateY(-1px); }
.composer button:disabled { cursor: wait; opacity: .68; }
.composer button svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }

.composer-hint { grid-column: 1 / -1; margin: -3px 0 0; color: #a0a6b4; font-size: 10px; }
.page-note { margin: 13px 0 0; color: #9299a8; font-size: 11px; text-align: center; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; clip-path: inset(50%); }

.pending-bubble { display: flex; min-width: 64px; align-items: center; gap: 4px; }
.pending-bubble span { width: 6px; height: 6px; border-radius: 50%; background: #9da1ec; animation: pulse 1.1s infinite ease-in-out; }
.pending-bubble span:nth-child(2) { animation-delay: .15s; }
.pending-bubble span:nth-child(3) { animation-delay: .3s; }

@keyframes pulse { 0%, 60%, 100% { opacity: .38; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

@media (max-width: 600px) {
  .page-shell { justify-content: stretch; padding: 0; }
  .chat-card { width: 100%; height: 100dvh; min-height: 420px; border: 0; border-radius: 0; }
  .topbar { min-height: 72px; padding-inline: 17px; }
  .messages { padding: 22px 16px; }
  .message { max-width: 94%; }
  .composer { margin: 0 12px 12px; }
  .page-note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
