/* ============================================================ */
/* 「我的习惯」入口按钮 & 弹窗样式                                  */
/* ============================================================ */

/* === 列表卡片上的 NEW 角标(个性化模式下显示) === */
.aigc3-list .item .bg { position: relative; }
.aigc3-list .item .item-new-badge {
  position: absolute;
  top: 0.625vw;
  right: 0.625vw;
  padding: 0.156vw 0.625vw;
  background: linear-gradient(135deg, #FF6B35, #E94E46);
  color: #fff;
  font-size: 0.625vw;
  font-weight: 700;
  letter-spacing: 1px;
  border-radius: 4px;
  z-index: 2;
  box-shadow: 0 0.156vw 0.417vw rgba(233, 78, 70, 0.35);
  animation: newBadgePulse 1.8s ease-in-out infinite;
}
@keyframes newBadgePulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}
@media (max-width: 768px) {
  .aigc3-list .item .item-new-badge {
    top: 6px; right: 6px;
    padding: 2px 8px;
    font-size: 10px;
  }
}

/* === 让 .tab-group 变成 flex,使「我的习惯」按钮和 tab-group-box 同行 === */
.tab-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.625vw;
}

/* === 搜索框紧凑版(去掉 search-tag 后,输入框收窄) === */
.C-search-compact {
  padding: 0.42vw 0.83vw;
}
.C-search-compact input {
  width: 8vw;
  min-width: 150px;
}
.C-search-compact .icon {
  width: 1.1vw;
  margin-left: 0.5vw;
}
/* tab-group-box 已是 flex,这里只确保它跟旁边的按钮 align 一致 */

/* === 我的习惯按钮:未设置时与普通 tab 一致灰底,设置过后才有特殊配色 === */
.user-pref-tab {
  user-select: none;
  flex-shrink: 0;
  /* 默认不强制 background,跟普通 .tab 灰底一致 */
}
/* "已设置过偏好"但未激活筛选 → 淡黄底色提醒"功能可用" */
.user-pref-tab.has-pref:not(.on) {
  background-color: #FFF3E0 !important;
  color: #E65100;
}
.user-pref-tab.has-pref:not(.on):hover {
  background-color: #FFE0B2 !important;
}
/* 激活筛选 → 绿色高亮 */
.user-pref-tab.on {
  background-color: #C9FF85 !important;
  color: #070707 !important;
  font-weight: 700;
}
/* 让按钮内的 ⭐ / ✓ 与文字垂直对齐 */
.user-pref-tab > span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  line-height: 1;
}
.user-pref-tab .user-pref-icon {
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  line-height: 1;
}
.user-pref-tab .user-pref-status {
  color: #08C764;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

/* ⚙ 齿轮设置按钮(仅已设置偏好后显示) */
.user-pref-gear {
  /* 复用 .tab 基础样式,但更小 */
  background-color: #f0f0f0 !important;
  color: #555;
  padding: 0 12px !important;
  font-size: 16px;
  cursor: pointer;
  user-select: none;
}
.user-pref-gear:hover {
  background-color: #e0e0e0 !important;
}
.user-pref-gear > span {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

/* === 弹窗框架 === */
.user-pref-modal {
  display: none;
  position: fixed; inset: 0;
  z-index: 99999;
}
.user-pref-modal.on { display: block; }
.upm-mask {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, .55);
  animation: upmFade .25s ease;
}
.upm-box {
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 820px; max-width: calc(100vw - 48px);
  max-height: calc(100vh - 48px);
  /* 默认不强制高度,内容多少撑多少;聊天状态由 .upm-box.is-chat 强制大尺寸 */
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 16px 60px rgba(0, 0, 0, .35);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: upmPop .3s cubic-bezier(.4, 1.5, .6, 1);
}
/* 聊天状态:弹窗强制大尺寸(留足聊天空间) */
.upm-box.is-chat {
  height: 75vh;
  max-height: 700px;
  min-height: 480px;
}
@keyframes upmFade {
  from { opacity: 0; } to { opacity: 1; }
}
@keyframes upmPop {
  from { opacity: 0; transform: translate(-50%, -45%); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}

/* === 顶部头 === */
.upm-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px;
  background: linear-gradient(135deg, #C9FF85, #A8E060);
  border-bottom: 1px solid rgba(0, 0, 0, .06);
}
.upm-head-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 16px; font-weight: 700; color: #070707;
}
.upm-head-icon { font-size: 20px; line-height: 1; }
.upm-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(0, 0, 0, .08);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .2s;
  font-size: 14px; color: #555;
}
.upm-close:hover { background: rgba(0, 0, 0, .15); }

/* === 阶段容器 === */
.upm-stage { display: none; }

/* === 阶段 A:对话 === */
.upm-stage-chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.upm-chat-list {
  flex: 1;
  min-height: 320px;
  overflow-y: auto;
  padding: 24px 28px;
  background: #FAFAFA;
}
.upm-bubble {
  margin-bottom: 14px;
  max-width: 80%;
  word-break: break-word;
}
.upm-bubble-text {
  display: inline-block;
  padding: 12px 16px;
  border-radius: 16px;
  line-height: 1.6;
  font-size: 14px;
}
.upm-bubble-ai {
  margin-right: auto;
}
.upm-bubble-ai .upm-bubble-text {
  background: #fff;
  color: #070707;
  border: 1px solid #eee;
  border-bottom-left-radius: 4px;
}
.upm-bubble-user {
  margin-left: auto; text-align: right;
}
.upm-bubble-user .upm-bubble-text {
  background: #C9FF85;
  color: #070707;
  border-bottom-right-radius: 4px;
}
.upm-chat-input-row {
  display: flex; gap: 10px; padding: 12px 16px;
  border-top: 1px solid #f0f0f0;
  background: #fff;
}
.upm-chat-input {
  flex: 1;
  resize: none;
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 12px;
  font-size: 14px; line-height: 1.5;
  outline: none;
  background: #FAFAFA;
  min-height: 40px; max-height: 100px;
  font-family: inherit;
}
.upm-chat-input:focus { border-color: #07C160; background: #fff; }
.upm-chat-send {
  padding: 0 22px;
  height: 40px;
  background: #070707;
  color: #C9FF85;
  border: 0;
  border-radius: 999px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background .2s, opacity .2s;
}
.upm-chat-send:hover { background: #222; }
.upm-chat-send:disabled { background: #999; opacity: .7; cursor: not-allowed; }
.upm-chat-tip {
  padding: 8px 20px 16px;
  font-size: 12px; color: #888;
  background: #fff;
}

/* === 阶段 B:排序中 === */
.upm-stage-ranking {
  padding: 60px 32px 48px;
  text-align: center;
}
.upm-rank-anim {
  display: inline-flex; gap: 10px;
  margin-bottom: 28px;
}
.upm-rank-dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: #C9FF85;
  animation: upmDot 1.4s ease-in-out infinite;
}
.upm-rank-dot:nth-child(2) { animation-delay: .2s; }
.upm-rank-dot:nth-child(3) { animation-delay: .4s; }
@keyframes upmDot {
  0%, 80%, 100% { transform: scale(.6); opacity: .4; }
  40%           { transform: scale(1.2); opacity: 1; }
}
.upm-rank-title {
  font-size: 20px; font-weight: 700; color: #070707;
  margin-bottom: 12px;
}
.upm-rank-step {
  font-size: 14px; color: #555;
  margin-bottom: 18px;
  min-height: 22px;
}
.upm-rank-tip {
  font-size: 12px; color: #999;
}

/* === 阶段 C:摘要面板 === */
.upm-stage-summary { padding: 20px 24px 24px; }
.upm-sum-section { margin-bottom: 18px; }
.upm-sum-label {
  font-size: 12px; color: #999;
  margin-bottom: 8px;
  font-weight: 600;
  letter-spacing: .5px;
}
.upm-sum-val {
  font-size: 14px; color: #070707;
  line-height: 1.6;
}
.upm-sum-tags {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.upm-tag {
  display: inline-block;
  padding: 4px 12px;
  background: #f5f5f5;
  border-radius: 999px;
  font-size: 12px; color: #555;
}
.upm-sum-tags-ai .upm-tag {
  background: linear-gradient(135deg, #FFF3E0, #FFE0B2);
  color: #E65100;
  font-weight: 600;
}
.upm-sum-empty { color: #bbb; font-size: 13px; }
.upm-sum-actions {
  display: flex; gap: 10px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid #f0f0f0;
}
.upm-btn {
  flex: 1;
  height: 44px;
  border: 0;
  border-radius: 999px;
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}
.upm-btn-ghost {
  background: #fff;
  color: #555;
  border: 1px solid #ddd;
}
.upm-btn-ghost:hover { background: #f5f5f5; }
.upm-btn-primary {
  background: #070707;
  color: #C9FF85;
}
.upm-btn-primary:hover { background: #222; }

/* === 移动端适配 === */
@media (max-width: 768px) {
  .user-pref-btn {
    height: 28px;
    padding: 0 10px;
    font-size: 12px;
    margin-left: 6px;
  }
  .user-pref-btn .user-pref-text { font-size: 12px; }
  .upm-box { width: 92vw; }
  .upm-chat-list { min-height: 240px; max-height: 60vh; }
  .upm-stage-ranking { padding: 40px 20px 32px; }
}
