* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

button,
textarea {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

textarea {
  border: 0;
  outline: 0;
  resize: none;
}

/* 首页：只做入口，不展示 AI 回复 */
.landing-body {
  display: flex;
  justify-content: center;
  background: #000;
  color: #fff;
}

.page-shell {
  position: relative;
  width: min(100vw, 750px);
  min-height: 100vh;
  background: #000;
  overflow-x: hidden;
  padding-bottom: calc(36px + env(safe-area-inset-bottom));
}

.hero {
  width: 100%;
  line-height: 0;
  background: #000;
}

.hero img {
  display: block;
  width: 100%;
  height: auto;
  user-select: none;
  pointer-events: none;
}

.home-input-card {
  position: relative;
  width: 85.2%;
  height: 238px;
  margin: 14px auto 0;
  padding: 20px 24px 14px;
  background: #fff;
  border: 2px solid #ee1654;
  border-radius: 23px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .05) inset;
}

.home-input-card textarea {
  display: block;
  width: 100%;
  height: 135px;
  background: transparent;
  color: #222;
  font-size: 22px;
  line-height: 1.55;
  letter-spacing: .5px;
  padding: 0;
}

.home-input-card textarea::placeholder {
  color: #c8c8c8;
  opacity: 1;
}

.card-actions {
  position: absolute;
  right: 18px;
  bottom: 14px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.upload-btn,
.send-btn {
  height: 39px;
  min-width: 135px;
  padding: 0 17px;
  border-radius: 999px;
  background: #e5e5e5;
  color: #333;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 18px;
  line-height: 1;
  white-space: nowrap;
}

.send-btn {
  color: #ee1654;
}

.send-btn:disabled {
  opacity: .65;
  cursor: not-allowed;
}

.upload-icon {
  position: relative;
  width: 20px;
  height: 17px;
  display: inline-block;
  border: 2px solid #333;
  border-radius: 2px;
}

.upload-icon::before {
  content: "";
  position: absolute;
  left: 3px;
  bottom: 2px;
  width: 11px;
  height: 8px;
  background: linear-gradient(135deg, transparent 49%, #333 50% 58%, transparent 59%), linear-gradient(45deg, transparent 49%, #333 50% 58%, transparent 59%);
}

.upload-icon::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 2px;
  width: 4px;
  height: 4px;
  background: #333;
  border-radius: 50%;
}

.send-icon {
  width: 22px;
  height: 22px;
  display: inline-block;
  background: #ee1654;
  clip-path: polygon(0 46%, 100% 0, 68% 100%, 48% 62%, 17% 77%);
}

.image-preview {
  position: absolute;
  left: 24px;
  bottom: 14px;
  width: 72px;
  height: 72px;
  border-radius: 12px;
  overflow: visible;
  background: #f3f3f3;
  border: 1px solid #e1e1e1;
}

.image-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 12px;
}

.image-preview button,
.composer-preview button {
  position: absolute;
  right: -9px;
  top: -9px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ee1654;
  color: #fff;
  font-size: 18px;
  line-height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.notice {
  width: 84%;
  margin: 16px auto 0;
  color: #cfcfcf;
  text-align: center;
  font-size: 13px;
  line-height: 1.75;
  letter-spacing: .2px;
}

/* 对话页：仿豆包/Kimi 的移动端聊天页面 */
.chat-body {
  display: flex;
  justify-content: center;
  background: #f6f7f9;
  color: #171a1f;
}

.chat-page {
  position: relative;
  width: min(100vw, 750px);
  height: 100vh;
  height: 100dvh;
  background: #f6f7f9;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.chat-header {
  position: relative;
  z-index: 3;
  height: calc(56px + env(safe-area-inset-top));
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(246, 247, 249, .96);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid rgba(0, 0, 0, .06);
}

.back-btn {
  position: relative;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  background: transparent;
}

.back-btn::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 10px;
  width: 12px;
  height: 12px;
  border-left: 2px solid #171a1f;
  border-bottom: 2px solid #171a1f;
  transform: rotate(45deg);
}

.chat-title-wrap {
  min-width: 0;
  flex: 1;
  text-align: center;
  margin-left: -36px;
}

.chat-title-wrap h1 {
  margin: 0;
  color: #15181d;
  font-size: 17px;
  font-weight: 700;
  line-height: 1.25;
}

.chat-title-wrap p {
  margin: 2px 0 0;
  color: #8f969f;
  font-size: 11px;
  line-height: 1.1;
}

.new-chat-btn {
  height: 32px;
  min-width: 64px;
  padding: 0 10px;
  border-radius: 999px;
  background: #fff;
  color: #343840;
  border: 1px solid rgba(0, 0, 0, .06);
  font-size: 13px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, .04);
}

.message-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 14px calc(118px + env(safe-area-inset-bottom));
}

.welcome-card {
  width: calc(100% - 26px);
  margin: 14px auto 0;
  padding: 30px 22px 28px;
  border-radius: 28px;
  text-align: center;
  background: #fff;
  box-shadow: 0 8px 28px rgba(20, 28, 45, .06);
}

.welcome-logo {
  width: 54px;
  height: 54px;
  margin: 0 auto 13px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ee1654, #ff6f91);
  color: #fff;
  font-weight: 800;
  letter-spacing: .5px;
}

.welcome-card h2 {
  margin: 0;
  color: #15181d;
  font-size: 18px;
  line-height: 1.4;
}

.welcome-card p {
  margin: 9px 0 0;
  color: #7e8792;
  font-size: 14px;
  line-height: 1.55;
}

.message-item {
  width: 100%;
  display: flex;
  align-items: flex-start;
  margin: 15px 0;
  gap: 8px;
}

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

.message-item.is-ai {
  justify-content: flex-start;
}

.message-avatar {
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 10px;
  background: #ee1654;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.message-bubble {
  max-width: 78%;
  padding: 12px 14px;
  border-radius: 18px;
  font-size: 16px;
  line-height: 1.72;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 4px 18px rgba(20, 28, 45, .05);
}

.is-user .message-bubble {
  background: #171a1f;
  color: #fff;
  border-bottom-right-radius: 5px;
}

.is-ai .message-bubble {
  background: #fff;
  color: #242830;
  border-bottom-left-radius: 5px;
}

.message-bubble.is-error {
  color: #ee1654;
}

.message-image {
  display: block;
  width: min(220px, 58vw);
  max-height: 260px;
  object-fit: cover;
  border-radius: 13px;
  margin-bottom: 8px;
}

.message-text:empty {
  display: none;
}

.typing-dots {
  height: 24px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #c6cbd1;
  animation: typingDot 1s infinite ease-in-out;
}

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

.typing-dots span:nth-child(3) {
  animation-delay: .3s;
}

@keyframes typingDot {
  0%, 80%, 100% { transform: translateY(0); opacity: .45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.chat-composer-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  padding: 8px 13px calc(13px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(246, 247, 249, 0), #f6f7f9 24%, #f6f7f9 100%);
}

.composer-preview {
  position: relative;
  width: 70px;
  height: 70px;
  margin: 0 0 8px 12px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 4px 18px rgba(20, 28, 45, .1);
}

.composer-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 14px;
}

.chat-composer {
  min-height: 56px;
  padding: 8px 9px 8px 10px;
  border-radius: 24px;
  background: #fff;
  box-shadow: 0 8px 30px rgba(20, 28, 45, .1);
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.composer-plus {
  position: relative;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 50%;
  background: #f2f3f5;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1px;
}

.composer-plus::before,
.composer-plus::after {
  content: "";
  position: absolute;
  background: #171a1f;
  border-radius: 99px;
}

.composer-plus::before {
  width: 16px;
  height: 2px;
}

.composer-plus::after {
  width: 2px;
  height: 16px;
}

.chat-composer textarea {
  flex: 1;
  min-width: 0;
  min-height: 38px;
  max-height: 118px;
  padding: 8px 0;
  background: transparent;
  color: #171a1f;
  font-size: 16px;
  line-height: 22px;
  overflow-y: auto;
}

.chat-composer textarea::placeholder {
  color: #b1b6bd;
}

.composer-send {
  position: relative;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 50%;
  background: #171a1f;
  margin-bottom: 1px;
}

.composer-send::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 10px;
  width: 18px;
  height: 18px;
  background: #fff;
  clip-path: polygon(0 46%, 100% 0, 68% 100%, 48% 62%, 17% 77%);
}

.composer-send:disabled {
  opacity: .55;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(36px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px);
  max-width: 78vw;
  padding: 11px 17px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .78);
  color: #fff;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 99;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 430px) {
  .page-shell {
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }

  .home-input-card {
    height: 30vw;
    min-height: 158px;
    max-height: 188px;
    margin-top: 2vw;
    padding: 3vw 3.5vw 2vw;
    border-radius: 3vw;
  }

  .home-input-card textarea {
    height: calc(100% - 52px);
    font-size: 4.15vw;
    line-height: 1.42;
  }

  .card-actions {
    right: 2.6vw;
    bottom: 2vw;
    gap: 1vw;
  }

  .upload-btn,
  .send-btn {
    min-width: 16.5vw;
    height: 7.4vw;
    padding: 0 3vw;
    gap: 1.3vw;
    font-size: 3.35vw;
  }

  .upload-icon {
    width: 4vw;
    height: 3.4vw;
    border-width: 1.5px;
  }

  .send-icon {
    width: 4.7vw;
    height: 4.7vw;
  }

  .image-preview {
    left: 3.5vw;
    bottom: 2vw;
    width: 11.8vw;
    height: 11.8vw;
  }

  .notice {
    width: 88%;
    margin-top: 2.6vw;
    font-size: 2.65vw;
    line-height: 1.55;
  }

  @media (max-height: 700px) {
    .home-input-card {
      min-height: 142px;
      height: 27vw;
    }

    .home-input-card textarea {
      height: calc(100% - 48px);
      font-size: 3.9vw;
    }

    .notice {
      margin-top: 2vw;
      font-size: 2.55vw;
      line-height: 1.45;
    }
  }

  .message-list {
    padding-left: 12px;
    padding-right: 12px;
  }

  .message-bubble {
    max-width: 82%;
    font-size: 15.5px;
  }
}

.typewriter-cursor {
  display: inline-block;
  width: 2px;
  height: 1.12em;
  margin-left: 2px;
  vertical-align: -0.18em;
  background: currentColor;
  animation: typeCursorBlink .8s infinite;
}

@keyframes typeCursorBlink {
  0%, 45% { opacity: 1; }
  46%, 100% { opacity: 0; }
}

.message-text-content {
  display: block;
  white-space: pre-wrap;
}
