/* AI 对话页 /chat */

@media (max-width: 720px) {
  body.page-chat.mobile-chat-page .site-header {
    display: none !important;
  }

  body.page-chat.mobile-chat-page {
    background: #f3f6fb;
    overflow: hidden;
  }

  body.page-chat.mobile-chat-page .app-shell {
    width: 100%;
    max-width: none;
    padding: 0;
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
  }

  .mobile-chat-shell {
    max-width: 520px;
  }
}

.mobile-chat-shell {
  margin: 0 auto;
  width: 100%;
  flex: 1;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  display: flex;
  flex-direction: column;
  padding: max(6px, env(safe-area-inset-top, 0px)) 0 0;
  box-sizing: border-box;
  overflow: hidden;
}

body.mobile-tab-shell.page-chat .mobile-chat-shell {
  min-height: 0;
  height: 100%;
  max-height: 100%;
}

.mobile-chat-header {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 10px;
}

.mobile-chat-header__back,
.mobile-chat-header__more {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: #334155;
  text-decoration: none;
  cursor: pointer;
}

.mobile-chat-header__titles {
  text-align: center;
  min-width: 0;
}

.mobile-chat-header__brand {
  display: block;
  font-size: 16px;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.2;
}

.mobile-chat-header__subtitle {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: #64748b;
}

.mobile-chat-disabled {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
  color: #64748b;
}

.mobile-chat-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.mobile-chat-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 0 14px 12px;
  -webkit-overflow-scrolling: touch;
}

.mobile-chat-welcome {
  margin-bottom: 12px;
}

.mobile-chat-welcome.hidden {
  display: none !important;
}

.mobile-chat-welcome__card {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, #eef5ff 0%, #f8fbff 55%, #ffffff 100%);
  border: 1px solid #e3edfb;
  box-shadow: 0 8px 24px rgba(30, 128, 255, 0.08);
}

.mobile-chat-welcome__icon {
  flex: 0 0 auto;
}

.mobile-chat-welcome__text {
  margin: 0;
  font-size: 14px;
  line-height: 1.65;
  color: #334155;
}

.mobile-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.mobile-chat-time {
  text-align: center;
  font-size: 12px;
  color: #94a3b8;
  margin: 2px 0;
}

.mobile-chat-row {
  max-width: 100%;
}

.mobile-chat-row--user {
  display: flex;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 10px;
}

.mobile-chat-row--assistant {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  column-gap: 10px;
  align-items: start;
}

.mobile-chat-row--assistant > .mobile-chat-avatar {
  grid-column: 1;
  grid-row: 1;
  align-self: start;
}

.mobile-chat-row--assistant > .mobile-chat-bubble-wrap {
  grid-column: 2;
  grid-row: 1;
  max-width: min(100%, 320px);
}

.mobile-chat-avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  margin-top: 2px;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px solid #fff;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.1);
  color: #fff;
}

.mobile-chat-avatar--user {
  border-radius: 50%;
}

.mobile-chat-avatar--assistant {
  border-radius: 12px;
  background: linear-gradient(145deg, #5b9bff 0%, #1e80ff 55%, #1565e6 100%);
}

.mobile-chat-avatar--photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mobile-chat-avatar--initial {
  background: linear-gradient(145deg, #60a5fa 0%, #2563eb 100%);
  font-size: 14px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.mobile-chat-avatar--icon svg {
  display: block;
}

.mobile-chat-bubble-wrap {
  max-width: min(78%, 320px);
  min-width: 0;
}

.mobile-chat-bubble {
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.mobile-chat-bubble--user {
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  color: #0f172a;
  border-bottom-right-radius: 6px;
}

.mobile-chat-bubble--assistant {
  background: #fff;
  color: #1e293b;
  border: 1px solid #e8eef5;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
  border-bottom-left-radius: 6px;
}

.mobile-chat-bubble--pending {
  color: #64748b;
}

.mobile-chat-bubble--error {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

.mobile-chat-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
}

.mobile-chat-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
}

.mobile-chat-action:hover,
.mobile-chat-action.is-active {
  color: #1e80ff;
  background: rgba(30, 128, 255, 0.08);
}

.mobile-chat-composer {
  flex: 0 0 auto;
  position: relative;
  z-index: 20;
  padding: 8px 14px calc(10px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(180deg, rgba(243, 246, 251, 0) 0%, #f3f6fb 24%);
  border-top: 1px solid rgba(226, 232, 240, 0.85);
  box-shadow: 0 -6px 20px rgba(15, 23, 42, 0.04);
}

body.mobile-tab-shell.page-chat .mobile-chat-composer {
  padding-bottom: calc(10px + var(--mobile-tab-bar-clearance, calc(58px + env(safe-area-inset-bottom, 0px))));
}

.mobile-chat-suggestions {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

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

.mobile-chat-suggestion {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.mobile-chat-suggestion__icon {
  width: 14px;
  height: 14px;
  display: inline-block;
  background: center / contain no-repeat;
}

.mobile-chat-suggestion__icon--pen {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231e80ff' stroke-width='2'%3E%3Cpath d='M12 20h9'/%3E%3Cpath d='M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z'/%3E%3C/svg%3E");
}

.mobile-chat-suggestion__icon--palette {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231e80ff' stroke-width='2'%3E%3Cpath d='M12 3c-4 0-7 2.5-7 6.5S8 18 12 18c1 0 2-.3 2.7-.8.6-.4 1.3-.2 1.8.3l.5.5c.8.8 2 .4 2.2-.7C20.7 14.2 21 12.6 21 11c0-4.4-4-8-9-8Z'/%3E%3Ccircle cx='8.5' cy='10.5' r='1' fill='%231e80ff'/%3E%3Ccircle cx='12' cy='7.5' r='1' fill='%231e80ff'/%3E%3Ccircle cx='15.5' cy='10.5' r='1' fill='%231e80ff'/%3E%3C/svg%3E");
}

.mobile-chat-suggestion__icon--doc {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231e80ff' stroke-width='2'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8Z'/%3E%3Cpath d='M14 2v6h6M8 13h8M8 17h8M8 9h2'/%3E%3C/svg%3E");
}

.mobile-chat-suggestion__icon--bulb {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231e80ff' stroke-width='2'%3E%3Cpath d='M9 18h6M10 22h4M12 2a6 6 0 0 0-3 11.3V16h6v-2.7A6 6 0 0 0 12 2Z'/%3E%3C/svg%3E");
}

.mobile-chat-input-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: flex-end;
  min-height: 44px;
}

.mobile-chat-input-addon,
.mobile-chat-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.mobile-chat-input-addon {
  background: #fff;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.mobile-chat-input-addon:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.mobile-chat-input-addon.is-active {
  color: #1e80ff;
  border-color: #93c5fd;
  background: #eff6ff;
}

.mobile-chat-attach-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e2e8f0;
}

.mobile-chat-attach-preview.hidden {
  display: none !important;
}

.mobile-chat-attach-preview__img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.mobile-chat-attach-preview__remove {
  margin-left: auto;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: #f1f5f9;
  color: #64748b;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.mobile-chat-bubble__img {
  display: block;
  max-width: min(220px, 100%);
  max-height: 180px;
  object-fit: cover;
  border-radius: 10px;
  margin-bottom: 6px;
}

.mobile-chat-bubble__text {
  white-space: pre-wrap;
  word-break: break-word;
}

.mobile-chat-send {
  background: linear-gradient(135deg, #3b82f6, #1e80ff);
  color: #fff;
  box-shadow: 0 6px 16px rgba(30, 128, 255, 0.28);
}

.mobile-chat-send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.mobile-chat-input-wrap {
  min-width: 0;
  padding: 8px 14px;
  border-radius: 22px;
  background: #fff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.04);
}

.mobile-chat-input {
  display: block;
  width: 100%;
  min-height: 24px;
  max-height: 120px;
  border: 0;
  resize: none;
  background: transparent;
  font: inherit;
  font-size: 14px;
  line-height: 1.5;
  color: #0f172a;
  outline: none;
}

.mobile-chat-input::placeholder {
  color: #94a3b8;
}

@media (min-width: 721px) {
  body.mobile-tab-shell.page-chat .mobile-chat-composer {
    padding-bottom: calc(10px + var(--mobile-tab-bar-clearance, calc(58px + env(safe-area-inset-bottom, 0px))));
  }

  body.mobile-tab-shell.page-chat .mobile-chat-shell {
    min-height: 0;
    height: 100%;
  }
}
