:root {
  color-scheme: light;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: #e9edf0;
  color: #202124;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  overflow: hidden;
}

body {
  min-height: 100dvh;
  background: #e9edf0;
}

button,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.app-shell {
  width: min(100%, 760px);
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  margin: 0 auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto auto;
  overflow: hidden;
  background: #f7f8f9;
  box-shadow: 0 0 28px rgb(32 33 36 / 12%);
}

.topbar {
  min-height: 76px;
  padding: max(12px, env(safe-area-inset-top)) 18px 12px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid #dfe3e6;
  background: #ffffff;
}

.brand-avatar {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid #e0e3e5;
}

.brand-copy {
  min-width: 0;
}

.brand-copy h1 {
  margin: 0 0 4px;
  font-size: 18px;
  line-height: 1.25;
  font-weight: 700;
}

.presence {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #6a7075;
  font-size: 12px;
}

.presence-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: #9aa0a6;
}

.presence.online {
  color: #087f5b;
}

.presence.online .presence-dot {
  background: #12a879;
  box-shadow: 0 0 0 3px rgb(18 168 121 / 13%);
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #4b5157;
  cursor: pointer;
}

.icon-button:hover {
  background: #eef1f3;
}

.icon-button:focus-visible,
.message-audio-button:focus-visible,
.dance-button:focus-visible,
.suggestions button:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgb(0 130 150 / 24%);
  outline-offset: 2px;
}

.icon-button svg,
.dance-button svg {
  width: 21px;
  height: 21px;
  stroke-width: 2;
}

.conversation {
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 16px 18px 22px;
  scrollbar-width: thin;
}

.date-marker {
  width: max-content;
  margin: 0 auto 18px;
  color: #858b90;
  font-size: 12px;
}

.message {
  display: flex;
  align-items: flex-end;
  gap: 9px;
  margin: 0 0 16px;
}

.message img,
.message-avatar-spacer {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 50%;
}

.message-bubble {
  max-width: min(78%, 520px);
  padding: 11px 13px;
  border-radius: 8px;
  font-size: 15px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.assistant-message .message-bubble {
  border: 1px solid #e1e4e6;
  background: #ffffff;
  color: #25292d;
}

.assistant-message.has-audio .message-bubble {
  max-width: min(calc(100% - 84px), 520px);
}

.message-audio-button {
  width: 30px;
  height: 30px;
  padding: 0;
  flex: 0 0 30px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #d9dddf;
  border-radius: 50%;
  background: #ffffff;
  color: #61676c;
  cursor: pointer;
}

.message-audio-button:hover {
  border-color: #b8d8d0;
  color: #126653;
}

.message-audio-button:disabled {
  cursor: wait;
  opacity: 0.55;
}

.message-audio-button.preparing svg {
  animation: audio-prepare 800ms linear infinite;
}

.message-audio-button svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

@keyframes audio-prepare {
  to { transform: rotate(360deg); }
}

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

.user-message .message-bubble {
  background: #b4232f;
  color: #ffffff;
}

.message.loading .message-bubble {
  width: 58px;
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.message.loading i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #777d82;
  animation: blink 1s infinite ease-in-out;
}

.message.loading i:nth-child(2) {
  animation-delay: 140ms;
}

.message.loading i:nth-child(3) {
  animation-delay: 280ms;
}

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

.suggestions {
  margin: 2px 0 8px 39px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

.suggestions::-webkit-scrollbar {
  display: none;
}

.suggestions button {
  min-height: 36px;
  padding: 7px 11px;
  flex: 0 0 auto;
  border: 1px solid #d5dadd;
  border-radius: 8px;
  background: #ffffff;
  color: #3d454a;
  font-size: 13px;
  cursor: pointer;
}

.suggestions button:hover {
  border-color: #b4232f;
  color: #9c1723;
}

.robot-strip {
  min-height: 62px;
  padding: 8px 18px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  border-top: 1px solid #dfe3e6;
  background: #eef2f3;
}

.robot-strip > img {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border: 1px solid #d9dddf;
  border-radius: 50%;
}

.robot-strip div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.robot-strip strong {
  font-size: 13px;
}

.robot-strip span {
  overflow: hidden;
  color: #6c7378;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dance-button {
  min-width: 80px;
  height: 38px;
  padding: 0 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 1px solid #252a2e;
  border-radius: 7px;
  background: #252a2e;
  color: #ffffff;
  cursor: pointer;
}

.dance-button:disabled {
  border-color: #c7cccf;
  background: #c7cccf;
  cursor: not-allowed;
}

.composer {
  min-height: 68px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 42px;
  align-items: end;
  gap: 5px;
  border-top: 1px solid #dfe3e6;
  background: #ffffff;
}

.composer textarea {
  width: 100%;
  min-height: 42px;
  max-height: 118px;
  padding: 10px 12px;
  resize: none;
  overflow-y: auto;
  border: 1px solid #d5dadd;
  border-radius: 8px;
  background: #f7f8f9;
  color: #202124;
  line-height: 20px;
}

.composer textarea::placeholder {
  color: #92979c;
}

.mic-button.recording {
  background: #fce7e8;
  color: #b4232f;
  animation: record-pulse 1.2s infinite;
}

@keyframes record-pulse {
  50% { box-shadow: 0 0 0 5px rgb(180 35 47 / 12%); }
}

.send-button {
  background: #b4232f;
  color: #ffffff;
}

.send-button:hover {
  background: #951b26;
}

.send-button:disabled {
  background: #d3d7da;
  cursor: not-allowed;
}

.safe-area {
  height: env(safe-area-inset-bottom);
  background: #ffffff;
}

.toast {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: calc(86px + env(safe-area-inset-bottom));
  max-width: min(88vw, 420px);
  padding: 10px 14px;
  border-radius: 7px;
  background: #252a2e;
  color: #ffffff;
  font-size: 13px;
  line-height: 1.4;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 480px) {
  .topbar,
  .conversation,
  .robot-strip {
    padding-left: 14px;
    padding-right: 14px;
  }

  .message-bubble {
    max-width: 82%;
  }

  .suggestions {
    margin-left: 39px;
  }
}

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