:root {
  color-scheme: dark;
  --bg: #000;
  --text: #fff;
  --muted: rgba(255, 255, 255, 0.7);
  --faint: rgba(255, 255, 255, 0.5);
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.15);
  --doctor-bubble: #262626;
  --option-bg: #171717;
  --option-hover: #262626;
  --tiktok-red: #fe2c55;
  --tiktok-blue: #5bc8e8;
  --risk-red: #dc2626;
}

* {
  box-sizing: border-box;
}

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

body {
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
a {
  font: inherit;
}

.chat-shell {
  display: flex;
  width: 100%;
  height: 100dvh;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.chat-header {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  padding: 12px;
}

.icon-button {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  cursor: pointer;
  line-height: 1;
}

.back-button {
  font-size: 34px;
  font-weight: 300;
}

.menu-button {
  font-size: 30px;
  letter-spacing: 3px;
}

.profile-image,
.message-avatar {
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  object-fit: cover;
  object-position: top;
}

.profile-image {
  width: 36px;
  height: 36px;
}

.message-avatar {
  width: 32px;
  height: 32px;
  border-color: rgba(255, 255, 255, 0.2);
}

.profile-title {
  display: flex;
  min-width: 0;
  flex: 1;
  align-items: center;
  gap: 6px;
  line-height: 1.1;
}

.profile-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  font-weight: 800;
}

.verified-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
}

.chat-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--bg);
  padding: 16px 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.chat-scroll::-webkit-scrollbar {
  width: 6px;
}

.chat-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
}

.chat-list {
  display: flex;
  width: 100%;
  max-width: 448px;
  margin: 0 auto;
  flex-direction: column;
  gap: 8px;
}

.message-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: message-in 240ms ease-out both;
}

.message-row.doctor {
  justify-content: flex-start;
}

.message-row.user {
  justify-content: flex-end;
}

.bubble {
  max-width: 80%;
  border-radius: 16px;
  padding: 10px 16px;
  font-size: 15px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.doctor .bubble {
  border-bottom-left-radius: 6px;
  background: var(--doctor-bubble);
  color: var(--text);
}

.user .bubble {
  border-bottom-right-radius: 6px;
  background: var(--tiktok-red);
  color: var(--text);
}

.typing-row {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 8px;
  animation: message-in 180ms ease-out both;
}

.typing-bubble {
  border-radius: 16px;
  border-bottom-left-radius: 6px;
  background: var(--doctor-bubble);
  padding: 12px 16px;
}

.typing-dots {
  display: flex;
  align-items: center;
  gap: 4px;
}

.typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  animation: typing-bounce 1s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
  animation-delay: -300ms;
}

.typing-dots span:nth-child(2) {
  animation-delay: -150ms;
}

.typing-label {
  align-self: flex-start;
  margin: -2px 0 2px 40px;
  color: var(--faint);
  font-size: 12px;
  animation: message-in 180ms ease-out both;
}

.analysis-card,
.risk-card,
.cta-button {
  animation: message-in 260ms ease-out both;
}

.analysis-card {
  width: 100%;
  max-width: 90%;
  align-self: center;
  margin: 8px 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #171717;
  padding: 16px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.analysis-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--tiktok-red);
  border-top-color: transparent;
  border-radius: 999px;
  animation: spin 850ms linear infinite;
}

.progress-track {
  width: 100%;
  height: 8px;
  margin-bottom: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
}

.progress-fill {
  height: 100%;
  width: 25%;
  border-radius: inherit;
  background: var(--tiktok-red);
  transition: width 700ms ease;
}

.analysis-stage {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.risk-card {
  width: 100%;
  max-width: 92%;
  align-self: center;
  margin: 8px 0;
  border: 2px solid var(--risk-red);
  border-radius: 16px;
  background: rgba(220, 38, 38, 0.1);
  padding: 16px;
  text-align: center;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.risk-card p {
  margin: 0;
  color: #ef4444;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.025em;
  text-transform: uppercase;
}

.cta-button {
  display: block;
  width: 100%;
  max-width: 94%;
  align-self: center;
  margin: 12px 0;
  border-radius: 999px;
  background: var(--tiktok-red);
  color: var(--text);
  padding: 16px 24px;
  text-align: center;
  text-decoration: none;
  font-size: 16px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgba(254, 44, 85, 0.24);
  outline: 2px solid rgba(254, 44, 85, 0.4);
  animation: message-in 260ms ease-out both, pulse-cta 1.8s infinite;
  transition: transform 180ms ease;
}

.cta-button:hover {
  transform: scale(1.02);
}

.options-footer {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  background: var(--bg);
  padding: 12px 16px 20px;
}

.options-list {
  display: flex;
  width: 100%;
  max-width: 448px;
  margin: 0 auto;
  flex-direction: column;
  gap: 8px;
}

.answer-option {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--option-bg);
  color: var(--text);
  cursor: pointer;
  padding: 14px 20px;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

.answer-option:hover {
  background: var(--option-hover);
}

.answer-option:active {
  transform: scale(0.98);
}

@keyframes message-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes typing-bounce {
  0%,
  80%,
  100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-5px);
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes pulse-cta {
  0%,
  100% {
    filter: brightness(1);
    box-shadow: 0 10px 24px rgba(254, 44, 85, 0.24);
  }
  50% {
    filter: brightness(1.08);
    box-shadow: 0 12px 32px rgba(254, 44, 85, 0.42);
  }
}

@media (max-width: 360px) {
  .chat-header {
    gap: 9px;
    padding-inline: 10px;
  }

  .bubble {
    max-width: 84%;
    padding-inline: 14px;
    font-size: 14px;
  }

  .answer-option {
    padding-inline: 14px;
    font-size: 14px;
  }
}
