:root {
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --text: #1f2330;
  --text-soft: #6b7280;
  --border: #e7e8ee;
  --bot-bubble: #f1f3f7;
  --radius: 18px;
  --shadow: 0 10px 40px rgba(20, 23, 38, 0.08);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

/* ---- Shell --------------------------------------------------------------- */
.chat-shell {
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  max-height: 760px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow);
  border-radius: 0;
}

@media (min-width: 520px) {
  body {
    padding: 24px;
  }
  .chat-shell {
    border-radius: 24px;
    border: 1px solid var(--border);
  }
}

/* ---- Header -------------------------------------------------------------- */
.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.chat-header__avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  font-size: 22px;
  flex-shrink: 0;
}

.chat-header__meta {
  flex: 1;
  min-width: 0;
}

.chat-header__name {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
}

.chat-header__status {
  font-size: 12.5px;
  color: var(--text-soft);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.chat-header__action {
  border: none;
  background: transparent;
  color: var(--text-soft);
  cursor: pointer;
  padding: 8px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  transition: background 0.15s, color 0.15s;
}

.chat-header__action:hover {
  background: var(--bg);
  color: var(--text);
}

/* ---- Messages ------------------------------------------------------------ */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.messages::-webkit-scrollbar {
  width: 8px;
}
.messages::-webkit-scrollbar-thumb {
  background: #d8dae2;
  border-radius: 8px;
}

.msg {
  display: flex;
  max-width: 84%;
  animation: pop 0.22s ease;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg__bubble {
  padding: 11px 15px;
  border-radius: var(--radius);
  font-size: 15px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.msg__bubble p {
  margin: 0 0 8px;
}
.msg__bubble p:last-child {
  margin-bottom: 0;
}
.msg__bubble ul,
.msg__bubble ol {
  margin: 4px 0 8px;
  padding-left: 20px;
}
.msg__bubble li {
  margin-bottom: 3px;
}
.msg__bubble a {
  color: var(--accent);
}
.msg__bubble code {
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 5px;
  border-radius: 5px;
  font-size: 0.9em;
}
.msg__bubble strong {
  font-weight: 600;
}

.msg--bot {
  align-self: flex-start;
}
.msg--bot .msg__bubble {
  background: var(--bot-bubble);
  color: var(--text);
  border-bottom-left-radius: 5px;
}

.msg--user {
  align-self: flex-end;
}
.msg--user .msg__bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 5px;
}

/* ---- Suggestions --------------------------------------------------------- */
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: flex-start;
  max-width: 100%;
  margin-top: 2px;
}

.suggestion {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.suggestion:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.suggestion:active {
  transform: scale(0.97);
}

/* ---- Typing indicator ---------------------------------------------------- */
.typing {
  display: flex;
  gap: 4px;
  padding: 4px 2px;
}
.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b4b8c4;
  animation: blink 1.3s infinite both;
}
.typing span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing span:nth-child(3) {
  animation-delay: 0.4s;
}

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

/* ---- Composer ------------------------------------------------------------ */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 14px 6px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.composer__input {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 11px 16px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  background: var(--bg);
  max-height: 120px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}

.composer__input:focus {
  border-color: var(--accent);
  background: var(--surface);
}

.composer__send {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.1s, opacity 0.15s, filter 0.15s;
}

.composer__send:hover {
  filter: brightness(1.08);
}
.composer__send:active {
  transform: scale(0.92);
}
.composer__send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.composer__hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-soft);
  padding: 0 0 10px;
}
