:root {
  --accent: #4f8ef7;
  --accent-deep: #377dff;
  --text-main: #222;
  --text-sub: #98a0ac;
  --text-body: #555;
  --dock-h-desktop: 110px; /* 宽屏：dock 高度 */
  --dock-h-mobile: 90px; /* 窄屏：dock 高度 */
  --dock-gap: 12px; /* 两块之间间距 */
  --input-area-height: 140px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: linear-gradient(
    180deg,
    #eefbff 0%,
    #ffffff 20%,
    #ffffff 90%,
    #ffffff 100%
  );
  font-family: "Inter", system-ui, sans-serif;
  max-width: 100%;
  overflow-x: hidden;
}

header {
  text-align: center;
  padding: 20px 10px 4px;
  background: transparent;
}

header h1 {
  margin: 0;
  font-size: 2.4rem;
  font-weight: 700;
  background: linear-gradient(90deg, #4a7bff, #6aa4ff);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

header p {
  margin-top: 6px;
  font-size: 1.05rem;
  color: var(--text-sub);
}

/* =========================
   ✅ Header 右上角结束按钮
   ========================= */
.header-inner {
  position: relative;
  width: min(980px, calc(100vw - 32px));
  margin: 0 auto;
}

/* ✅ 结束按钮：绝对定位，不占布局 */
.end-session-btn {
  position: absolute;
  top: 6px;
  right: 0px;

  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid rgba(180, 180, 180, 0.45);

  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(10px) saturate(160%);
  -webkit-backdrop-filter: blur(10px) saturate(160%);

  font-size: 0.88rem;
  font-weight: 700;
  color: #3b3b3b;

  cursor: pointer;
}
/* ✅ 默认不显示（欢迎页不会出现） */
.end-session-btn {
  display: none;
}

/* ✅ 聊天状态显示 */
body.chat-started .end-session-btn {
  display: inline-flex;
}

.end-session-btn:hover {
  filter: brightness(1.05);
}

@media (max-width: 900px) {
  .end-session-btn {
    top: 4px;
    right: 2px;
    padding: 8px 12px;
    font-size: 0.82rem;
  }
}

#chat-container {
  flex: 1;
  padding: 0 24px 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
  min-height: 0;
}

/* 欢迎消息 */
#welcome-message {
  position: relative;
  /* max-width: 80%; */
  width: min(800px, 90%);
  margin: 60px auto 0;
  padding: 55px 45px;
  text-align: center;

  background: linear-gradient(
    150deg,
    #f3dbff,
    #f3dbff,
    #d1effe,
    #ffffff,
    #f3fcff,
    #f7e7ff,
    #d5f2ff,
    #cdd6ff,
    #f8fbff
  );
  background-size: 250% 350%;
  animation: softGradientShift 30s cubic-bezier(0.2, 0, 0, 0.2) infinite;

  border-radius: 36px;
  border: 2.6px solid rgba(255, 255, 255, 0.665);

  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);

  box-shadow:
    0 6px 16px rgba(223, 241, 255, 0.976),
    0 12px 20px rgba(238, 249, 255, 0.857);

  word-break: break-word;
  overflow-wrap: break-word;
}

@keyframes softGradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

#welcome-message img.welcome-logo {
  width: 96px;
  height: 96px;
  border-radius: 24px;

  background: radial-gradient(
    circle at center,
    rgba(150, 180, 255, 0.45),
    transparent 65%
  );

  box-shadow:
    0 8px 12px rgba(62, 116, 254, 0.276),
    0 0 15px rgba(140, 186, 255, 0.55);

  margin: 0 auto 18px;
  animation: logoFloat 5s ease-in-out infinite alternate;
}

@keyframes logoFloat {
  from {
    transform: translateY(3px);
  }
  to {
    transform: translateY(-5px);
  }
}

#welcome-message h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 30px;
  color: #2e2e2e;
}

#welcome-message p {
  margin-top: 26px;
  color: #3b3b3b;
  font-size: 1.07rem;
  line-height: 1.75;
}

/* ✅ 防止刷新闪 welcome：默认先不显示 */
#welcome-message {
  display: none;
}

/* ✅ JS 判定无历史才显示 welcome */
body.show-welcome #welcome-message {
  display: block;
}

/* 聊天气泡 */
.message {
  padding: 12px 18px;
  border-radius: 14px;
  line-height: 1.7;
  word-break: break-word;
  margin-bottom: 15px;
  font-size: 1rem;
}

.message.user {
  max-width: 45%;
  align-self: flex-end;
  background: linear-gradient(135deg, #d4edff, #f1f6ff);
  color: #000000;
  border-bottom-right-radius: 6px;
  margin-right: 12%;
  margin-bottom: 10px;
  margin-top: 10px;
  box-shadow: 0 4px 8px rgba(123, 169, 255, 0.46);
}

.message.assistant {
  width: 100%;
  align-self: flex-start;
  background: #f9f9f9a9;

  box-shadow: 0 4px 8px rgba(192, 192, 192, 0.367);
}

/* ⭐ 三点跳动动画 */
.typing {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin: 0 3px;
  background: #bbb;
  border-radius: 50%;
  animation: typingBounce 1s infinite ease-in-out both;
}
.typing:nth-child(1) {
  animation-delay: -0.32s;
}
.typing:nth-child(2) {
  animation-delay: -0.16s;
}

.typing-message {
  margin-left: 8%;
  padding: 20px 18px;
  width: auto !important; /* ⭐ 关键 */
  max-width: 50%;
  display: inline-flex; /* 让三个点自然包裹 */
  align-self: flex-start;
}

@keyframes typingBounce {
  0%,
  80%,
  100% {
    transform: scale(0.4);
    opacity: 0.6;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* =========================================
   ✅ input-area（宽屏默认）统一专业版
   - emotion-meter + input-wrapper 永远并排
   - input-wrapper 吃剩余空间
   - 两块同高
   - 永不裁边框/阴影
   ========================================= */

#input-area {
  position: sticky;
  bottom: 0;
  z-index: 10;

  width: min(920px, calc(100vw - 32px));
  margin: 0 auto;

  padding: 0 18px;
  padding-bottom: calc(22px + env(safe-area-inset-bottom));

  display: flex;
  flex-wrap: nowrap; /* ✅ 永远并排 */
  gap: var(--dock-gap);

  align-items: stretch; /* ✅ 让两个子块同高 */
  box-sizing: border-box;

  background: rgba(255, 255, 255, 0);
  /* backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%); */

  overflow: visible; /* 不裁阴影 */
}

/* =========================
   2) 右侧输入框容器
   ========================= */
.input-wrapper {
  flex: 1 1 auto;
  min-width: 0;

  height: var(--dock-h-desktop); /* ✅ 高度锁死 */

  margin: 12px 0 8px;
  padding: 12px 18px;

  display: flex;
  align-items: flex-start;

  background: #fff;
  border-radius: 18px;
  border: 1px solid #e2e2e2c9;

  box-shadow:
    0 4px 8px rgba(217, 217, 217, 0.515),
    inset 0 3px 6px rgba(255, 255, 255, 0.9);

  box-sizing: border-box;
}

/* ✅ textarea：不撑高，内部滚动 */
#user-input {
  flex: 1;
  min-width: 0;

  /* height: 100%;
  max-height: 100%; */

  border: none;
  outline: none;
  background: transparent;

  padding: 6px 0 56px 0;
  font-family:
    "Inter",
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  font-size: 1rem;
  line-height: 1.2;

  resize: none;
  overflow-y: auto;
}

#user-input::placeholder {
  pointer-events: none;
  line-height: 1.2em;
  color: #a4a4a4;
}

.input-indicator {
  width: 24px;
  height: 24px;
  background: #20c574;
  color: white;
  font-size: 13px;
  border-radius: 999px;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-right: 8px;
}

.send-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;

  background: linear-gradient(135deg, #4f8ef7, #377dff);
  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  /* ⭐ 关键：让按钮自己垂直居中 */
  align-self: center;
}

.send-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* .send-circle:hover {
  filter: brightness(1.08);
} */

/* .send-circle:active {
  transform: scale(0.92);
} */

/* 手机端优化 */
@media (max-width: 900px) {
  header {
    padding: 18px 0 10px;
  }

  header h1 {
    font-size: 1.8rem;
  }

  header p {
    font-size: 0.9rem;
  }
  #chat-container {
    flex: 1;
    padding: 0 16px 8px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
  }

  #welcome-message img.welcome-logo {
    width: 80px;
    height: 80px;
    border-radius: 18px;
    margin-top: 8px;
    margin-bottom: 4px;
  }

  #welcome-message h2 {
    font-size: 1.2rem;
  }
  #welcome-message p {
    font-size: 0.9rem;
  }

  #welcome-message {
    margin-top: 20px;

    padding-top: 26px;
    padding-right: 32px;
    padding-bottom: 16px;
    padding-left: 32px;
    width: 96%;
    max-width: 96%;
  }

  #send-btn {
    padding: 7px 14px;
    font-size: 0.83rem;
  }

  .input-indicator {
    width: 18px;
    height: 18px;
    font-size: 11px;
    margin-right: 6px;
  }

  .send-circle {
    width: 30px;
    height: 30px;
  }
  /* 发送按钮、清空按钮不要挤出 */
  .send-circle,
  .input-clear-btn {
    flex: 0 0 auto;
  }

  .send-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }
}

/* ChatGPT 风格 Markdown 渲染 */
.message.assistant p {
  margin: 12px 0;
  line-height: 1.7;
  color: #1f1f1f;
}

.message.assistant h1,
.message.assistant h2,
.message.assistant h3,
.message.assistant h4 {
  font-weight: 600;
  color: #111;
  margin: 20px 0 10px;
}

.message.assistant h1 {
  font-size: 1.5rem;
}
.message.assistant h2 {
  font-size: 1.35rem;
}
.message.assistant h3 {
  font-size: 1.15rem;
}
.message.assistant h4 {
  font-size: 1.05rem;
}

.message.assistant ul,
.message.assistant ol {
  padding-left: 24px;
  margin: 10px 0;
}

.message.assistant li {
  margin: 6px 0;
  line-height: 1.6;
}

.message.assistant blockquote {
  border-left: 4px solid #4f8ef7;
  padding-left: 12px;
  margin: 14px 0;
  color: #444;
  background: #f9fbff;
}

.message.assistant table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
  font-size: 0.95rem;
  border-radius: 8px;
  overflow: hidden;
  background: #ffffff;
}

.message.assistant th,
.message.assistant td {
  border: 1px solid #e2e6ef;
  padding: 10px 14px;
  text-align: left;
}

.message.assistant th {
  background: #f3f6ff;
  font-weight: 600;
}

.message.assistant tr:nth-child(even) td {
  background: #fafbff;
}

.message.assistant pre {
  background: #f6f8fa;
  padding: 14px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 14px 0;
}

.message.assistant code {
  font-family: Menlo, Consolas, monospace;
  color: #d63384;
  font-size: 0.95rem;
}

.message.assistant > p:first-child {
  margin-top: 2px;
}

.message.assistant > p:last-child {
  margin-bottom: 0;
}

.assistant-block {
  display: flex;
  flex-direction: column;
  gap: 10px;

  /* ⭐ 统一宽度规则在这里 */
  max-width: 45%;
  margin-top: 10px;
  margin-left: 12%;
  margin-right: auto;
  position: relative;
}
.assistant-block .typing-message {
  max-width: none;
}

/* ====== FAQ 横向滚动区域 ====== */
/* 外层容器：隐藏超出部分 */
/* 外层容器：隐藏超出部分（必须） */
#faq-wrapper {
  min-width: 70%;
  max-width: 960px;
  margin: 26px auto 0;

  overflow-x: auto;
  overflow-y: hidden;

  scrollbar-width: none; /* Firefox */

  display: flex;
  justify-content: flex-start; /* ⭐ 关键 */
  flex: 1;
  display: flex;
  align-items: center; /* ⭐ FAQ 卡片纵向居中 */
}

#faq-wrapper::-webkit-scrollbar {
  display: none; /* Chrome / Safari */
}

/* 内层容器：横向排列，不换行（必须） */
#faq-suggestions {
  display: flex;
  flex-direction: row;
  gap: 14px;
  white-space: nowrap;
  padding: 6px 0;
  position: relative;
}

/* FAQ 卡片（可以保留 hover 与 media） */
.faq-card {
  flex-shrink: 0; /* 不允许缩小，滑动不被挤压 */
  white-space: nowrap; /* 单行显示 */
  overflow: hidden;
  text-overflow: ellipsis;

  padding: 10px 18px;
  border-radius: 14px;

  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);

  border: 1px solid rgba(236, 236, 236, 0.715);

  /* 柔和光感、玻璃拟态阴影 */
  box-shadow:
    0 4px 6px rgba(130, 150, 220, 0.18),
    inset 0 0 9px rgba(230, 240, 255, 0.45);

  font-size: 0.93rem;
  color: #2b2b2b;

  cursor: pointer;
  user-select: none;

  transition: all 0.25s ease;
}

.faq-card:hover {
  transform: translateY(-3px);
  background: rgba(255, 255, 255, 0.7);
  box-shadow:
    0 4px 10px rgba(100, 130, 220, 0.28),
    inset 0 0 14px rgba(200, 230, 255, 0.55);
}
.faq-card:active {
  transform: scale(0.97);
}

/* ========= 📱 手机端专属样式（max-width: 900px）========= */
@media (max-width: 900px) {
  .faq-card {
    padding: 8px 14px;
    font-size: 0.85rem;
    border-radius: 14px;
  }
  #faq-wrapper {
    width: 100%; /* 手机一般更窄，不然 FAQ 太挤 */
    margin-top: 18px; /* 视觉上更紧凑一些 */
  }
}

/* ===== FAQ 外壳 ===== */
.faq-shell {
  position: relative;
  width: 66%;
  max-width: 960px;
  margin: 8px auto 0;

  display: flex;
  align-items: center;

  overflow: visible; /* ⭐ 防止箭头被裁 */
}

/* ✅ 默认：FAQ 不渲染（避免刷新闪一下） */
.faq-shell {
  display: none;
}

/* ✅ 只有 welcome 状态才显示 FAQ */
body.show-welcome .faq-shell {
  display: block;
}

/* ✅ chat-started 状态确保不显示（保险） */
body.chat-started .faq-shell {
  display: none;
}

/* ✅ booting 阶段：先都别显示，等 JS 决定最终状态 */
body.booting .faq-shell {
  display: none !important;
}
body.booting #welcome-message {
  display: none !important;
}

.faq-arrow {
  position: absolute;
  z-index: 10; /* ⭐ 一定要高于 faq-wrapper */
  top: 50%;
  transform: translateY(calc(-50% + 12.6px)); /* ⭐ 视觉修正 */

  width: 28px;
  height: 28px;
  border-radius: 50%;

  background: rgba(200, 200, 200, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 18px;
  line-height: 1;
}

/* 左右位置 */
.faq-arrow.left {
  left: -17px; /* 原来是 -16 */
}

.faq-arrow.right {
  right: -17px;
}

/* 隐藏态 */
.faq-arrow.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%) scale(0.9);
}
@media (max-width: 900px) {
  .faq-arrow {
    position: absolute;
    z-index: 10; /* ⭐ 一定要高于 faq-wrapper */
    top: 50%;
    transform: translateY(calc(-50% + 8px)); /* ⭐ 视觉修正 */

    width: 22px;
    height: 22px;
    border-radius: 50%;

    background: rgba(200, 200, 200, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;

    font-size: 18px;
    line-height: 1;
  }
  .faq-shell {
    position: relative;
    width: 84%;
    max-width: 960px;
    margin: 2px auto 0;

    display: flex;
    align-items: center;

    overflow: visible; /* ⭐ 防止箭头被裁 */
  }
}

.input-clear-btn {
  position: relative;

  width: 24px;
  height: 24px;
  border-radius: 999px;

  background: #20c574;
  border: none;
  padding: 0;

  cursor: pointer;

  margin-right: 8px;

  /* 显隐动画 */
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9);

  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
}

/* 显示状态 */
.input-clear-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: scale(1);
}

/* hover / active */
.input-clear-btn:hover {
  filter: brightness(1.05);
}

.input-clear-btn:active {
  transform: scale(0.9);
}

/* ====== 用伪元素画 ×（核心） ====== */
.input-clear-btn::before,
.input-clear-btn::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;

  width: 12px;
  height: 2px;
  background: white;
  border-radius: 1px;

  transform-origin: center;
}

.input-clear-btn::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.input-clear-btn::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* ====== 手机端适配 ====== */
@media (max-width: 900px) {
  .input-clear-btn {
    width: 18px;
    height: 18px;
    margin-right: 6px;
  }

  .input-clear-btn::before,
  .input-clear-btn::after {
    width: 9px;
    height: 2px;
  }
}

.anger-card {
  width: 100%;
  align-self: stretch;
  /* 让它进入和 message 完全同一套 flex 布局 */
  align-self: flex-start;

  margin-right: auto;
  margin-bottom: 0px;

  padding: 14px 16px;
  border-radius: 14px;

  background: linear-gradient(135deg, #fff5f5, #f7faff);
  border: 1px solid #f1d4d4;
}

.anger-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 8px;
}

.anger-level {
  color: #d64545;
}

.anger-score {
  font-size: 0.85rem;
  color: #777;
  margin-left: 4px;
}

.anger-bar-wrapper {
  height: 10px;
  background: #eee;
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 8px;
}

.anger-bar {
  height: 100%;
  background: linear-gradient(90deg, #9ed6f5, #eca7a7);
  transition: width 0.6s ease;
}

.anger-desc {
  font-size: 0.85rem;
  color: #555;
}
.assistant-avatar {
  position: absolute;
  top: 4px;
  left: -50px;

  width: 40px;
  height: 40px;
  border-radius: 10px;

  object-fit: cover;
  background: white;

  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
}
@media (max-width: 900px) {
  .message.user {
    max-width: calc(100% - 90px);
    margin-left: 80px !important;
    margin-right: 10px !important;
    max-width: none;
  }
  .assistant-block {
    width: calc(100% - 40px);
    margin-left: 30px !important;
    margin-right: 10px !important;
    max-width: none;
    position: relative;
  }
  .assistant-block .typing-message {
    max-width: none;
  }

  .message.assistant,
  .anger-card {
    width: 100%;
  }
  .typing-message {
    margin-left: 10px !important;
  }
  .assistant-avatar {
    position: absolute;
    top: 4px;
    left: -38px;

    width: 30px;
    height: 30px;
    border-radius: 8px;

    object-fit: cover;
    background: white;

    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
  }
}

.welcome-title {
  text-align: center;
}

.title-wrap {
  display: inline-flex;
  flex-wrap: wrap; /* ⭐ 允许整体换行 */
  justify-content: center;
}

.nowrap {
  white-space: nowrap; /* 第一段永不拆 */
}

.tail {
  white-space: nowrap; /* 第二段也不拆 */
}

/* ====== 强制接管浏览器原生 button 样式 ====== */
.mood-actions .mood-btn {
  appearance: none;
  -webkit-appearance: none;
  border: none;
}

/* ====== 情绪按钮统一外观 ====== */
.mood-actions .mood-btn {
  flex: 1;
  min-width: 96px;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;

  color: white;

  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
  transition: all 0.18s ease;
}

.mood-actions {
  display: flex;
  gap: 10px; /* ⭐ 按钮之间的间距（原来一般是 8~10） */
  margin-top: 10px; /* ⭐ 上方留白 */
  margin-bottom: 10px; /* ⭐ 下方留白（可选） */
}

.mood-actions .mood-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.16);
}

.mood-actions .mood-btn:active {
  transform: scale(0.96);
}

.mood-actions .mood-btn:disabled {
  opacity: 0.55;
  cursor: default;
  transform: none;
  box-shadow: none;
}

/* ====== 精准三种状态 ====== */

/* 有所缓解 → 绿色 */
.mood-actions .mood-btn[data-mood="better"] {
  background: linear-gradient(135deg, #6ce06c, #48f048dc);
}

/* 依然强烈 → 红色 */
.mood-actions .mood-btn[data-mood="strong"] {
  background: linear-gradient(135deg, #f77577, #d43f3f);
}

/* 好多了（已离开情绪） → 浅蓝 */
.mood-actions .mood-btn[data-mood="resolved"] {
  background: linear-gradient(135deg, #80c5f9, #65bef1);
}

/* ====== mood 按钮选中态 ====== */

/* 所有禁用按钮：默认淡出 */
.mood-actions .mood-btn:disabled {
  opacity: 0.45;
  filter: grayscale(0.2);
}

/* 被选中的那个：重新高亮 */
.mood-actions .mood-btn.selected {
  opacity: 1;
  filter: none;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.22);
  transform: scale(1.03);
}

/* 防止 selected + disabled 冲突 */
.mood-actions .mood-btn.selected:disabled {
  opacity: 1;
}

/* ===== 移除 number input 的上下箭头 ===== */

#emotion-value::-webkit-outer-spin-button,
#emotion-value::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

#emotion-value {
  appearance: textfield;
}

/* =========================================
   Emotion Tracker 情绪追踪条（完整替换版）
   支持：输入数字 + 加减按钮 + 10格条
   ========================================= */

/* ===== 容器 ===== */
.emotion-meter {
  flex: 0 0 320px; /* 宽屏默认宽度 */
  max-width: 360px;
  min-width: 220px;

  height: var(--dock-h-desktop); /* ✅ 高度锁死，保证与右边一致 */

  margin: 12px 0 8px;
  padding: 14px 14px 16px;

  box-sizing: border-box;
  overflow: hidden; /* ✅ 高度固定，禁止撑出去 */

  border-radius: 18px;
  border: 1px solid #e2e2e2c9;
  background: rgb(255, 255, 255);
  /* backdrop-filter: blur(10px); */

  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.06);

  display: flex;
  flex-direction: column;
  justify-content: space-between; /* head 在上 control 在下 */
  gap: 8px;
}

/* ===== 顶部信息行 ===== */
/* ✅ head：可换行 + 自动缩字，但永不撑高 */
.emotion-head {
  flex: 1 1 auto;
  min-height: 0;

  display: flex;
  align-items: center;

  flex-wrap: wrap; /* ✅ 可以换行 */
  row-gap: 2px;
  column-gap: 6px;
}

.emotion-label {
  flex: 1 1 auto;
  min-width: 0;

  white-space: normal;
  line-height: 1.1;

  font-size: clamp(0.78rem, 1.5vw, 0.95rem);
  font-weight: 700;
  color: #222;
}

/* ===== 右侧：输入数字 /10 ===== */
.emotion-num {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.emotion-suffix {
  font-size: clamp(0.74rem, 1.5vw, 0.9rem);
  color: #98a0ac;
  font-weight: 700;
}

/* 输入框：0-10 */
.emotion-input {
  /* width: clamp(40px, 9vw, 50px); */
  width: 36px;
  height: 24px;
  font-size: clamp(0.8rem, 1.5vw, 0.9rem);

  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: rgba(255, 255, 255, 0.92);

  text-align: center;
  font-weight: 800;
  color: #377dff;

  outline: none;
}

.emotion-input:focus {
  border-color: rgba(55, 125, 255, 0.55);
  box-shadow: 0 0 0 4px rgba(55, 125, 255, 0.18);
}

/* placeholder 显示 “–” */
.emotion-input::placeholder {
  color: #98a0ac;
  font-weight: 600;
}

/* 去掉 number 输入框的上下小箭头（Chrome/Safari） */
.emotion-input::-webkit-outer-spin-button,
.emotion-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
.emotion-input[type="number"] {
  -moz-appearance: textfield; /* Firefox */
}

/* ================================
   控制区：-  分段条  +
   ================================ */
/* ✅ control：永不溢出（按钮固定圆，bar 可压缩） */
.emotion-control {
  flex: 0 0 40px; /* ✅ 固定底部控制区高度 */
  min-height: 40px;

  display: flex;
  align-items: center;
  gap: 10px;

  min-width: 0;
  overflow: hidden; /* ✅ 防止撑出去 */
}

/* ✅ 按钮：永远正圆 */
.emotion-btn {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  aspect-ratio: 1 / 1;

  border-radius: 50%;
  border: none;

  background: linear-gradient(135deg, #4f8ef7, #377dff);
  color: #fff;

  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;

  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;
}

/* .emotion-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px rgba(55, 125, 255, 0.45);
}

.emotion-btn:active {
  transform: translateY(0);
  box-shadow: 0 4px 10px rgba(55, 125, 255, 0.3);
} */

.emotion-btn:disabled {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
}

/* ================================
   分段情绪条（10 格）
   ================================ */
/* ✅ bar：10 格压缩列，不溢出 */
.emotion-bar {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;

  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 3px;

  height: 10px;
  min-height: 10px;

  background: rgba(0, 0, 0, 0.04);
  border-radius: 8px;
  padding: 2px;
}

.emotion-bar .seg {
  min-width: 0;
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(180deg, #e4e9f4, #d9e0f0);
  box-shadow: inset 0 0 0 1px rgba(55, 125, 255, 0.08);
}

/* 激活状态 */
.emotion-bar .seg.active {
  background: linear-gradient(180deg, #76adff, #5c98ff);
  box-shadow: 0 2px 6px rgba(72, 136, 255, 0.517);
  transform: scaleY(1.05);
}

/* 强度越高，颜色略微加深（视觉反馈） */
.emotion-bar .seg.active:nth-child(n + 3) {
  background: linear-gradient(180deg, #ffdd6e, #ffc745);
  box-shadow: 0 2px 8px rgba(255, 227, 67, 0.563);
}

/* 强度越高，颜色略微加深（视觉反馈） */
.emotion-bar .seg.active:nth-child(n + 6) {
  background: linear-gradient(180deg, #ff9f6e, #ff7a45);
  box-shadow: 0 2px 8px rgba(255, 122, 69, 0.5);
}

.emotion-bar .seg.active:nth-child(n + 9) {
  background: linear-gradient(180deg, #ff6b6b, #e03131);
  box-shadow: 0 2px 10px rgba(224, 49, 49, 0.55);
}

/* =========================
   4) Mobile（<900px）：40% / 60%
   ========================= */
@media (max-width: 900px) {
  #input-area {
    width: 100% !important; /* ✅ 强制跟随屏幕变化 */
    max-width: 100% !important; /* ✅ 防止被桌面 max-width 限制 */
    margin: 0 !important; /* ✅ 别再 auto 居中 */
    box-sizing: border-box;

    padding-left: 14px;
    padding-right: 14px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
    gap: 8px;
    padding-inline: 20px;
  }

  /* 左40% */
  .emotion-meter {
    flex: 0 0 40%;
    max-width: 40%;
    min-width: 0;

    height: var(--dock-h-mobile); /* ✅ 移动端高度锁死 */
    margin: 0;
    padding: 12px 10px;
    border-radius: 16px;
    margin-left: -4px;
  }

  /* 右60% */
  .input-wrapper {
    flex: 0 0 60%;
    max-width: 60%;
    min-width: 0;

    height: var(--dock-h-mobile); /* ✅ 移动端高度锁死 */
    margin: 0;
    padding: 10px 12px;
    border-radius: 16px;
  }

  /* textarea 填满容器高度，内部滚动 */
  #user-input {
    height: 100%;
    max-height: 100%;

    font-size: 16px;
    line-height: 1.2;
    /* ✅ 改为对称 padding，不再人为制造“向上挤”的视觉 */
    padding: 4px 0 42px 0;
  }
  /* ✅ placeholder 也跟随移动端字体 */
  #user-input::placeholder {
    font-size: 16px;
    line-height: 1.2;
  }

  /* 控制区更紧凑 */
  .emotion-control {
    flex: 0 0 30px;
    min-height: 20px;
    gap: 6px;
  }

  .emotion-btn {
    width: 24px;
    height: 24px;
    font-size: 1rem;
  }
  /* ------- head：强制上下布局 ------- */
  .emotion-head {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
    margin-bottom: 12px;
    align-items: center;

    flex-wrap: nowrap; /* ✅ 不要 wrap，否则布局会乱 */
    white-space: normal;
  }

  .emotion-label {
    font-size: 0.9rem; /* ✅ 固定字体 */
    font-weight: 500;
    line-height: 0.9;
    white-space: nowrap; /* ✅ 不让标题自己换行 */
  }

  .emotion-num {
    width: 100%;
    justify-content: center;
    gap: 6px;
  }

  /* ------- control：确保不会横向挤爆 ------- */
  .emotion-control {
    width: 100%;
    min-width: 0;

    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 4px;
  }

  /* ✅ +/- 按钮永远正圆 */
  .emotion-btn {
    flex: 0 0 auto !important;

    width: 24px !important;
    height: 24px !important;
    aspect-ratio: 1 / 1;

    border-radius: 50% !important;

    padding: 0;
    line-height: 1;
  }

  /* ✅ bar 必须能真正收缩，格子不乱 */
  .emotion-bar {
    flex: 1 1 auto;
    min-width: 0;

    width: auto;
    height: 10px;
    min-height: 10px;

    display: grid;
    grid-template-columns: repeat(10, minmax(0, 1fr)); /* ✅ 关键 */
    gap: 2px;
    padding: 2px;

    overflow: hidden;
  }

  .emotion-bar .seg {
    min-width: 0;
  }
}

/* =========================
   ✅ Fix: history-messages 布局一致化
   原因：.message.user 的 align-self 只有在 flex 子项中才会生效
   ========================= */
#history-messages {
  display: flex;
  flex-direction: column;
  /* gap: 18px; 你如果想用 gap 控制间距就打开这行 */
  gap: 0; /* ✅ 保持你原先的 margin-bottom 节奏，更像之前 */
}

/* ================================
   情绪引导遮罩层
   ================================ */

.emotion-guide-card {
  background: white;
  width: min(90%, 420px);
  border-radius: 16px;
  padding: 22px 20px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  text-align: center;
  animation: guidePop 0.25s ease;
}

@keyframes guidePop {
  from {
    transform: translateY(10px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.emotion-guide-card h3 {
  margin: 0 0 10px;
  font-size: 1.2rem;
}

.emotion-guide-card p {
  margin: 0 0 16px;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #555;
}

.emotion-guide-card button {
  border: none;
  background: #4f8ef7;
  color: white;
  padding: 8px 18px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 0.9rem;
}

.emotion-guide-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;

  /* ⭐ 关键：不要盖到底部输入区 */
  bottom: var(--input-area-height, 120px);

  background: rgba(255, 255, 255, 0.324);
  z-index: 9999;

  display: flex;
  align-items: center;
  justify-content: center;
}

.emotion-guide-overlay.hidden {
  display: none;
}

/* ================================
   只模糊背景内容（不包括底部输入区）
   ================================ */
body.emotion-guide-active header,
body.emotion-guide-active #chat-container {
  filter: blur(4px);
  transition: filter 0.2s ease;
}

/* ================================
   关闭底部玻璃模糊（否则情绪条会糊）
   ================================ */
body.emotion-guide-active #input-area,
body.emotion-guide-active .emotion-meter {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* ================================
   让右侧输入框留在“暗背景”
   ================================ */
body.emotion-guide-active .input-wrapper {
  position: relative;
  z-index: 1; /* 在遮罩层下面 */
  opacity: 0.35;
  transform: scale(0.98);
  transition: all 0.25s ease;
}

/* ================================
   ⭐ 只高亮 emotion-meter 卡片
   ================================ */
body.emotion-guide-active #emotion-meter {
  position: relative;
  z-index: 10000; /* 高于遮罩层 */

  background: #ffffff;
  transform: scale(1.05);
  border-radius: 14px;

  box-shadow:
    0 0 0 3px rgba(79, 142, 247, 0.5),
    0 14px 40px rgba(79, 142, 247, 0.35);

  transition: all 0.25s ease;
}

/* =========================================
   Breath Card Container
   ========================================= */

.breath-card {
  margin: 18px 0 14px;
  padding: 24px 20px 30px;
  border-radius: 26px;
  background: transparent;
  position: relative;
  -webkit-user-select: none;
  user-select: none;
}

/* =========================================
   顶部提示文字
   ========================================= */

.breath-tip {
  font-size: 1rem;
  line-height: 1.6;
  color: #7e7e7e;
  text-align: center;
  margin-bottom: 24px;
}

/* =========================================
   圆形区域容器
   ========================================= */

.breath-circle-wrap {
  position: relative;
  width: 240px;
  height: 260px;
  margin: 0 auto;
}

/* =========================================
   呼吸文字（在圆上方）
   ========================================= */

.breath-label {
  position: absolute;
  top: 0;
  width: 100%;
  text-align: center;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: #9a9a9a;
  z-index: 3;
  transition: color 0.3s ease;
}

.breath-card.done .breath-label {
  color: #9a9a9a;
}

/* =========================================
   SVG 进度环（绝对同心）
   ========================================= */

.breath-progress-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 220px;
  height: 220px;
  transform: translate(-50%, -50%);
  z-index: 0;
}

.breath-progress-ring svg {
  width: 100%;
  height: 100%;
}

.breath-progress-ring .bg {
  fill: none;
  stroke: rgba(79, 142, 247, 0.08);
  stroke-width: 8;
}

.breath-progress-ring .progress {
  fill: none;
  stroke: #73b7ff;
  stroke-width: 8;
  stroke-linecap: round;

  transform: rotate(-90deg);
  transform-origin: 50% 50%;

  transition: stroke 0.3s ease;
}
/* =========================================
   中心玻璃圆（高级质感）
   ========================================= */

.breath-circle {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 170px;
  height: 170px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  z-index: 1;

  cursor: pointer;
  user-select: none;
  touch-action: none;

  /* 底层玻璃基底 */
  background: radial-gradient(
    circle at center,
    rgb(188, 236, 255) 0%,
    rgb(222, 244, 255) 50%,
    rgb(255, 255, 255) 100%
  );

  border: 2px solid rgba(255, 255, 255, 0.45);

  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);

  overflow: hidden;

  -webkit-user-select: none;
  -webkit-touch-callout: none; /* 禁止 iOS 长按弹菜单 */
  -webkit-tap-highlight-color: transparent; /* 去掉点击高亮 */
}

.breath-circle::before {
  content: "";
  position: absolute;
  inset: -25%;
  border-radius: 50%;

  background: radial-gradient(
    circle at center,
    rgb(187, 236, 255) 0%,
    rgb(228, 247, 255) 50%,
    rgb(255, 255, 255) 100%,
    transparent 100%
  );

  animation: radialFlow 14s linear infinite;
  pointer-events: none;
}

@keyframes radialFlow {
  0% {
    transform: scale(0.8);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.6;
  }
  100% {
    transform: scale(1.4);
    opacity: 0;
  }
}

/* =========================================
   轻微动态波纹效果（更高级）
   ========================================= */

@keyframes ripple {
  0% {
    transform: scale(0.8);
    opacity: 0.6;
  }
  70% {
    transform: scale(1.3);
    opacity: 0.2;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

.icp-footer {
  text-align: center;
  margin: 10px 0 10px;
  font-size: 12px;
  color: #888;
}

.icp-footer a {
  color: #888;
  text-decoration: none;
}

.icp-footer a:hover {
  text-decoration: underline;
}
