:root {
  color-scheme: light;
  --page: #f6f7fb;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #98a2b3;
  --line: #d5dbe7;
  --soft: #f0f2f7;
  --assistant: #eff1f6;
  --user: #27324a;
  --accent: #3c6df0;
  --danger: #d94b4b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--page);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100svh;
  display: flex;
  justify-content: center;
  background: linear-gradient(90deg, #eceef6 0, #ffffff 18%, #ffffff 82%, #eceef6 100%);
}

.chat-panel {
  width: min(100%, 480px);
  min-height: 100svh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--surface);
  position: relative;
}

.hero {
  padding: 54px 24px 12px;
  text-align: center;
}

.mascot {
  width: 54px;
  height: 54px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  font-size: 36px;
  transform: rotate(8deg);
}

h1 {
  margin: 0;
  font-size: clamp(22px, 5.4vw, 25px);
  line-height: 1.35;
  font-weight: 500;
  letter-spacing: 0;
}

.messages {
  overflow-y: auto;
  padding: 8px 28px 24px;
  scroll-behavior: smooth;
}

.message {
  max-width: 100%;
  width: fit-content;
  line-height: 1.65;
  font-size: 17px;
  word-break: break-word;
  white-space: pre-wrap;
}

.message.assistant {
  background: var(--assistant);
  color: var(--text);
  border-radius: 8px;
  padding: 16px 18px;
}

.message.user {
  margin: 16px 0 16px auto;
  max-width: 82%;
  background: var(--user);
  color: #ffffff;
  border-radius: 18px 18px 6px 18px;
  padding: 10px 14px;
  font-size: 16px;
}

.message.loading {
  color: #667085;
}

.message-image-frame {
  width: min(100%, 360px);
  aspect-ratio: 4 / 3;
  margin: 10px 0;
  border-radius: 8px;
  overflow: hidden;
  background: #d8dde7;
  display: block;
  position: relative;
}

.message-image-frame img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.message-image-frame.is-loading img {
  opacity: 0;
}

.message-image-frame.is-error::after {
  content: "图片加载失败";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #667085;
  font-size: 14px;
}

.message.error {
  background: #fff1f1;
  color: #a63b3b;
  border: 1px solid #ffd2d2;
}

.welcome-card {
  margin: 0 0 10px;
}

.quick-questions {
  display: grid;
  gap: 8px;
  justify-items: start;
}

.quick-question {
  max-width: 100%;
  min-height: 42px;
  padding: 7px 20px;
  border: 1px solid #cbd3e2;
  border-radius: 8px;
  background: #ffffff;
  color: #344054;
  font-size: 16px;
  line-height: 1.4;
  text-align: left;
  cursor: pointer;
}

.quick-question:active {
  transform: translateY(1px);
}

.composer-area {
  padding: 10px 24px calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(255,255,255,0), #ffffff 18%);
}

.composer {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  gap: 10px;
}

.input-wrap {
  height: 58px;
  border: 1px solid var(--line);
  border-radius: 30px;
  display: grid;
  grid-template-columns: 1fr 42px;
  align-items: center;
  padding: 0 8px 0 24px;
  box-shadow: 0 2px 10px rgba(31, 41, 55, 0.03);
}

#messageInput {
  min-width: 0;
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 18px;
}

#messageInput::placeholder {
  color: #b9c0ce;
  font-weight: 600;
}

.icon-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: #ffffff;
  color: #27324a;
  cursor: pointer;
}

.send-button {
  border: 0;
  font-size: 24px;
  font-weight: 700;
}

.clear-button {
  color: #9aa4b5;
  font-size: 22px;
}

.clear-button:hover,
.clear-button:focus-visible {
  border-color: #f0b2b2;
  color: var(--danger);
}

.icon-button:disabled,
#messageInput:disabled {
  cursor: wait;
  opacity: 0.65;
}

.disclaimer {
  margin: 10px 0 0;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.4;
}

@media (max-width: 420px) {
  .hero {
    padding-top: 48px;
  }

  .messages {
    padding-inline: 18px;
  }

  .message {
    font-size: 16px;
  }

  .composer-area {
    padding-inline: 16px;
  }

  .composer {
    grid-template-columns: 40px 1fr;
    gap: 8px;
  }

  .input-wrap {
    height: 54px;
    padding-left: 20px;
  }

  #messageInput {
    font-size: 17px;
  }
}
