/* ============================================================
 * Ting Chat v2.1 —— TRAE Work 风格
 * 布局：灰色底 + 左侧任务边栏 + 白色圆角主面板
 * 空状态：居中 Hero（书本 + Work with TRAE）+ 输入卡片
 *         + 能力 chips + 灵感推荐列表
 * 对话态：输入卡下沉到底部，消息流接管舞台
 * ========================================================== */

:root {
  --bg:            #f4f4f4;        /* 页面 / 边栏背景 */
  --surface:       #ffffff;
  --line:          #ececeb;
  --line-strong:   #dcdcd9;
  --chip-bg:       #f1f1f0;
  --chip-hover:    #e8e8e6;

  --text:          #232326;
  --text-soft:     #6f6f75;
  --text-mute:     #a0a0a5;

  --brand:         #7a5af5;        /* 发送按钮紫 */
  --brand-deep:    #6444e8;
  --brand-soft:    rgba(122, 90, 245, 0.14);
  --brand-tint:    #ede9fe;        /* 下载桌面端 pill 底 */

  --accent-orange: #e2820c;
  --accent-blue:   #3a6ce7;
  --accent-green:  #2f9e5f;

  --bubble-user:   #efeff1;
  --bubble-ai-bg:  #ffffff;
  --bubble-ai-line:#eceae4;

  --green-ok:      #4fb86a;
  --link-blue:     #3a6ce7;

  --shadow-soft:  0 2px 10px rgba(20, 20, 22, 0.04),
                  0 1px 2px  rgba(20, 20, 22, 0.03);
  --shadow-panel: 0 1px 3px  rgba(20, 20, 22, 0.05),
                  0 12px 32px rgba(20, 20, 22, 0.06);
  --shadow-pop:   0 10px 28px rgba(20, 20, 22, 0.09),
                  0 2px 6px  rgba(20, 20, 22, 0.04);
  --shadow-brand: 0 6px 16px rgba(122, 90, 245, 0.35);

  --r-sm:   10px;
  --r-md:   14px;
  --r-lg:   18px;
  --r-xl:   24px;
  --r-pill: 999px;

  --font-display: 'Fraunces', ui-serif, Georgia, serif;
  --font-body:    'Manrope', -apple-system, BlinkMacSystemFont, 'PingFang SC',
                  'Helvetica Neue', Arial, sans-serif;

  --col-main: 800px;   /* 主列宽度：输入卡 / chips / 推荐列表 */
}

/* ---------- 重置 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font-body);
  font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}
button { font-family: inherit; border: none; background: none; color: inherit; cursor: pointer; padding: 0; }
textarea { font-family: inherit; font-size: inherit; color: inherit; border: none; outline: none; background: transparent; resize: none; }
svg { display: block; }
[hidden] { display: none !important; }
code, pre { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }

/* ============================================================
 * 骨架：边栏 + 主面板
 * ========================================================== */
.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  padding: 10px;
  gap: 10px;
  background: var(--bg);
}

/* ============================================================
 * 左侧边栏
 * ========================================================== */
.side {
  width: 264px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 8px 6px 4px;
  min-height: 0;
}

.side__top {
  display: flex; align-items: center; gap: 2px;
  padding: 0 4px 8px;
}

.icon-btn {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  display: grid; place-items: center;
  color: var(--text-soft);
  transition: background .15s, color .15s;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--chip-bg); color: var(--text); }
.icon-btn:active { transform: scale(.94); }
.icon-btn img { display: block; }

/* 常驻悬浮阴影（新建按钮） */
.icon-btn--float {
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  transition: background .15s, box-shadow .2s, transform .15s;
}
.icon-btn--float:hover { box-shadow: var(--shadow-pop); }
a.icon-btn { text-decoration: none; }

/* ---------- 主导航 ---------- */
.side__nav { display: flex; flex-direction: column; gap: 2px; padding: 0 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  font-size: 14px; font-weight: 500;
  color: var(--text);
  text-decoration: none;
  text-align: left;
  transition: background .15s;
  white-space: nowrap;
}
.nav-item svg { color: var(--text-soft); flex-shrink: 0; transition: color .15s; }
.nav-item img { display: block; flex-shrink: 0; }
.nav-item:hover { background: var(--chip-bg); }
.nav-item.is-active { background: #e9e9e7; }
.nav-item.is-active svg { color: var(--text); }

.side__label {
  padding: 20px 14px 8px;
  font-size: 12.5px;
  color: var(--text-mute);
  user-select: none;
}

/* ---------- 空任务 ---------- */
.side__empty {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px;
  color: var(--text-mute);
  font-size: 13px;
  min-height: 0;
}

/* ---------- 任务列表 ---------- */
.side__list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
  padding: 0 8px;
}
.side-task {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 8px 28px 8px 10px;
  border: 0; background: none;
  border-radius: var(--r-sm);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background .15s;
  flex-shrink: 0;
}
.side-task:hover { background: var(--chip-bg); }
.side-task.is-active { background: #e9e9e7; }
.side-task__icon {
  display: grid; place-items: center;
  color: var(--text-soft);
  flex-shrink: 0;
}
.side-task__body {
  min-width: 0;
  display: flex; flex-direction: column; gap: 1px;
}
.side-task__title {
  font-size: 13.5px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.side-task__time {
  font-size: 11.5px;
  color: var(--text-mute);
}
.side-task__del {
  position: absolute;
  top: 3px; right: 3px;
  width: 20px; height: 20px;
  display: grid; place-items: center;
  padding: 0;
  border: 0; border-radius: 6px;
  background: transparent;
  color: var(--text-mute);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.side-task__del:hover { background: rgba(0, 0, 0, .07); color: #d64545; }

/* ---------- 底部用户 ---------- */
.side__foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
  padding: 10px 8px 6px;
}
.side__user { display: flex; align-items: center; gap: 3px; min-width: 0; }
.avatar {
  box-sizing: border-box;
  width: 20px; height: 20px;       /* 与用户名文字高度相当 */
  padding: 3px;                     /* 图标与背景边界 3px 间距 */
  border-radius: 10px;
  background: linear-gradient(135deg, #b9b2ff 0%, #7a5af5 100%);
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}
.side__username { font-size: 14px; font-weight: 700; }
.side__tag {
  font-size: 11px; font-weight: 500;
  color: var(--text-soft);
  background: var(--chip-bg);
  padding: 2px 7px;
  border-radius: var(--r-pill);
}
.side__desktop {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12.5px; font-weight: 500;
  color: var(--text-soft);
  padding: 5px 8px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.side__desktop:hover { background: var(--chip-bg); color: var(--text); }

/* ---------- 边栏折叠态（桌面） ---------- */
.app.is-side-collapsed .side { display: none; }

/* ---------- 移动端边栏遮罩（桌面隐藏） ---------- */
.side-backdrop { display: none; }

/* ============================================================
 * 右侧主面板
 * ========================================================== */
.panel {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-panel);
  overflow: hidden;
}

.panel__top {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 20;
  display: flex; align-items: center;
  gap: 8px;
  padding: 12px 16px 10px;
  background: rgba(255, 255, 255, .55);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  transition: box-shadow .28s;
}

/* 阴影仅在侧边栏收起时显示：
   PC 端默认展开无阴影，折叠后显示；移动端抽屉默认收起显示，打开后隐藏 */
@media (max-width: 900px) {
  .panel__top { box-shadow: 0 8px 18px -10px rgba(0, 0, 0, .18); }
  .app.is-side-open .panel__top { box-shadow: none; }
}
@media (min-width: 901px) {
  .app.is-side-collapsed .panel__top { box-shadow: 0 8px 18px -10px rgba(0, 0, 0, .18); }
}
.panel__top .dl-btn { margin-left: auto; }
.dl-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px;
  font-size: 13px; font-weight: 600;
  color: #fff;
  background: #6f6f75;
  border-radius: var(--r-pill);
  transition: background .15s, box-shadow .15s;
}
.dl-btn:hover { background: #5b40c9; box-shadow: var(--shadow-soft); }

/* ---------- 可滚动舞台 ---------- */
.stage {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 60px 28px 0;
  scroll-behavior: smooth;
}
.stage::-webkit-scrollbar { width: 6px; }
.stage::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 6px; }

/* ---------- 回到底部按钮（滚动离开最新回复时显示，sticky 悬浮右下角） ---------- */
.jump-bottom {
  position: sticky;
  bottom: 14px;
  align-self: flex-end;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  margin: -48px 8px 6px 0; /* 负上边距叠在最后一条回复上方，不额外占用滚动空间 */
  border: 1px solid var(--line-strong, #dcdcd9);
  border-radius: 50%;
  background: var(--surface, rgba(255, 255, 255, .92));
  color: var(--text, #232326);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .14);
  z-index: 5;
  transition: transform .15s, box-shadow .15s, background .15s;
}
.jump-bottom:hover {
  background: var(--brand, #7a5af5);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 8px 20px rgba(122, 90, 245, .4);
}
.jump-bottom:active { transform: translateY(2px); }
.jump-bottom[hidden] { display: none; }

/* ============================================================
 * 空状态：Work 首页
 * ========================================================== */
.home {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  max-width: var(--col-main);
  margin: 0 auto;
  padding: 5vh 0 0;
  animation: fadeUp .6s cubic-bezier(.2,.7,.2,1);
}

/* 底部占位：推荐列表+输入卡整体停在距底部 1/3 处 */
.home::after {
  content: '';
  flex: 0 0 20%;
}

.home__hero {
  --hero-size: clamp(26px, 3.4vw, 32px);
  display: flex; align-items: stretch; gap: 12px;
  margin-bottom: 24px;
  color: var(--text);
}
.home__book {
  width: auto;
  height: calc(var(--hero-size) * 1.2);
  object-fit: contain;
  color: var(--text);
}
.home__title {
  margin: 0;
  font-size: var(--hero-size);
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}

/* ---------- 输入卡片 ---------- */
.composer-wrap { width: 100%; margin-top: 28px; container-type: inline-size; }

/* 输入框上方提示：小图标 + 小字，左侧贴合、垂直居中对齐 */
.composer-hint {
  display: flex; align-items: center; gap: 5px;
  padding: 0 2px 6px;
  font-size: 11px; line-height: 1.4;
  color: var(--text-2, #8b8b87);
  user-select: none;
}
.composer-hint img { width: 13px; height: 13px; flex: none; }

.composer-card {
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-soft);
  transition: border-color .2s, box-shadow .2s;
  /* 不再裁剪溢出内容，保证模型弹窗可完整显示 */
  animation: composer-breath 2.8s ease-in-out infinite;
}

/* 静默状态：紫色光晕呼吸灯 */
@keyframes composer-breath {
  0%, 100% {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-soft), 0 0 0 0 var(--brand-soft);
  }
  50% {
    border-color: var(--brand);
    box-shadow: var(--shadow-soft), 0 0 0 7px var(--brand-soft), 0 0 18px rgba(122, 90, 245, 0.18);
  }
}

/* 聚焦输入时：停止呼吸，保持高亮边框 */
.composer-card:focus-within {
  animation: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft), var(--shadow-soft);
}

.composer-card textarea {
  display: block;
  width: 100%;
  min-height: 56px;
  max-height: 160px;
  padding: 15px 18px 6px;
  font-size: 14.5px;
  line-height: 1.6;
  color: var(--text);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.composer-card textarea::placeholder { color: var(--text-mute); }

.composer-card__bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 6px 10px 10px 12px;
}

/* 模型选择 */
.model-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 6px 8px;
  font-size: 13px; font-weight: 500;
  color: var(--text-soft);
  border-radius: var(--r-sm);
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.model-btn:hover { background: var(--chip-bg); color: var(--text); }
.model-btn svg { opacity: .7; }

/* 选中模型后的小字描述：显示在按钮右侧外部（模型名按钮后、5px 间距），
   可延伸至右侧发送按钮，超出才省略号截断 */
.model-pick__intro {
  flex: 1;
  font-size: 11px; font-weight: 400;
  color: var(--text-soft);
  overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* 占位态：未选择模型时按钮文字弱化显示"请选择模型" */
.model-btn.is-placeholder { color: var(--text-faint, var(--text-soft)); }
.model-btn.is-placeholder #modelLabel { opacity: .65; font-style: normal; }

/* 提示态：未选模型就点发送时按钮短暂高亮提醒 */
.model-btn.is-attention {
  color: var(--accent, #6c5ce7);
  animation: model-btn-pulse .35s ease-in-out 2;
}
@keyframes model-btn-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* ---------- 模型选择弹窗（向上弹出） ---------- */
.model-pick { position: relative; display: inline-flex; align-items: center; gap: 5px; min-width: 0; flex: 1; }

.model-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  /* 宽度按内容自适应（刚好放下模型名+描述），
     上限为输入框的 60% 宽，超出才省略截断，不会太宽（移动端在下方媒体查询覆盖） */
  width: fit-content;
  max-width: 60cqw;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  display: flex; flex-direction: column; gap: 2px;
  z-index: 40;
  animation: fadeUp .18s ease;
}
.model-menu__item {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start;
  gap: 3px;
  padding: 8px 30px 8px 10px; /* 右侧留出对勾位置 */
  border: 0; background: none;
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.model-menu__item:hover { background: var(--chip-bg); }
/* 第一行：加粗模型名 + 绿色"免费"徽标 */
.model-menu__row { display: inline-flex; align-items: center; gap: 5px; max-width: 100%; }
.model-menu__name { font-weight: 700; }
.model-menu__free {
  flex-shrink: 0;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px; font-weight: 600; line-height: 1.5;
  background: #16a34a; color: #fff;
}
/* 第二行：小字浅色描述 */
.model-menu__intro {
  max-width: 100%;
  min-width: 0;
  font-size: 11px; font-weight: 400;
  color: var(--text-soft);
  overflow: hidden; text-overflow: ellipsis;
}
.model-menu__item svg {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  color: var(--brand); visibility: hidden; flex-shrink: 0;
}
.model-menu__item.is-active { color: var(--brand); font-weight: 700; }
.model-menu__item.is-active svg { visibility: visible; }

/* 空状态：无可选模型时的占位文案 */
.model-menu__empty {
  padding: 14px 12px;
  font-size: 12px;
  color: var(--text-mute, var(--text-soft));
  text-align: center;
  white-space: nowrap;
}

/* ---------- 发送按钮（紫色圆角方块） ---------- */
.cb-send {
  position: relative;
  width: 34px; height: 34px;
  flex-shrink: 0;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  display: grid; place-items: center;
  box-shadow: var(--shadow-brand);
  transition: background .2s, transform .15s, box-shadow .2s, border-radius .2s;
}
.cb-send:hover {
  background: var(--brand-deep);
  box-shadow: 0 8px 20px rgba(122, 90, 245, 0.45);
}
.cb-send:active { transform: scale(.94); }

.cb-send.is-loading::before {
  content: '';
  position: absolute; inset: -3px;
  border-radius: inherit;
  border: 2.5px solid rgba(122, 90, 245, 0.28);
  border-top-color: transparent;
  animation: spin 0.9s linear infinite;
}
.cb-send.is-loading svg { opacity: 0; }

/* 打字进行中：按钮切换为停止态（方块停止符） */
.cb-send.is-stop svg { opacity: 0; }
.cb-send.is-stop::after {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: currentColor;
}

/* ---------- 灵感推荐列表 ---------- */

/* ---------- 任务结束/停止提示（与复制按钮同行同框，靠左） ---------- */
.task-footer {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: auto; /* 操作行靠右对齐，提示文字推到左侧与复制按钮平行 */
  font-size: 12px;
  color: var(--text-2, #8b8b87);
}
.task-footer img {
  width: 14px;
  height: 14px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .35)); /* 常驻悬浮阴影 */
}
.sugg {
  width: 100%;
  margin-top: auto;
  display: flex; flex-direction: column;
}
.sugg-row {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
  text-align: left;
  min-width: 0;
  transition: background .15s;
}
.sugg-row:hover { background: #fafafa; }
/* 列表标题："为你推荐"小字提示（无边框无分隔线） */
.sugg-title {
  padding: 12px 10px 8px;
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--text-2, #8b8b87);
  animation: sugg-in .4s cubic-bezier(.2,.8,.2,1) both;
}
/* 推荐列表入场：从底部逐条向上弹出（animation-delay 由 JS 按序错峰） */
.sugg-row { animation: sugg-in .45s cubic-bezier(.2,.8,.2,1) both; }
@keyframes sugg-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}
.sugg-row__title { font-weight: 700; white-space: nowrap; flex-shrink: 0; }
/* 列表图标：视频海报 1:1，与分类文字等高、垂直居中对齐 */
.sugg-row__icon {
  width: 18px;
  height: 18px;
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
  border-radius: 4px;
  object-fit: cover;
}
.sugg-row__icon--ph {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
.sugg-row__desc {
  color: #6f6f75; /* 视频名称固定灰 */
  white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
.sugg-row__arrow {
  margin-left: auto;
  color: var(--text-mute);
  flex-shrink: 0;
  display: grid; place-items: center;
  width: 26px; height: 26px;
  border-radius: var(--r-pill);
  transition: background .15s, color .15s, transform .15s;
}
.sugg-row:hover .sugg-row__arrow { background: var(--chip-bg); color: var(--text); transform: translateY(-2px); }

/* ============================================================
 * 对话态：底部停靠区 + 消息流
 * ========================================================== */
.stage__dock {
  flex-shrink: 0;
  padding: 0 28px;
}
.stage__dock .composer-wrap {
  margin-top: 0;
  max-width: var(--col-main);
  margin-left: auto;
  margin-right: auto;
  padding: 10px 0 16px;
  animation: fadeUp .35s cubic-bezier(.2,.7,.2,1);
}

/* 锁定旧任务只读态：输入区降透明度 */
.composer-wrap.is-locked { opacity: .55; }
.composer-wrap.is-locked .composer-card { pointer-events: none; }

.messages {
  width: 100%;
  margin-top: auto; /* 对话内容贴底：内容少时从底部向上排布，超出后正常滚动 */
  padding: 18px 0 28px;
  display: flex; flex-direction: column; gap: 24px;
}

/* ---------- 用户消息（右侧与输入框主列对齐，宽度贴合文字） ---------- */
.msg-user {
  width: 100%;
  max-width: var(--col-main);
  margin: 0 auto;
  display: flex;
  justify-content: flex-end;
  animation: msgIn .35s cubic-bezier(.2,.7,.2,1);
}
.msg-user__inner {
  width: fit-content;
  max-width: 90%;
  text-align: left;
  padding: 8px 14px;
  background: var(--bubble-user);
  border-radius: var(--r-lg);
  border-top-right-radius: 6px;
  position: relative;
  color: var(--text);
  font-size: 15px; line-height: 1.5;
  overflow-wrap: break-word; white-space: normal;
}

/* ---------- AI 消息 ---------- */
.msg-ai {
  width: 100%;
  max-width: var(--col-main);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  animation: msgIn .4s cubic-bezier(.2,.7,.2,1);
}
.msg-ai__brand {
  display: inline-flex; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.msg-ai__brand-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: #1a1a1e;
  color: #fff;
  display: grid; place-items: center;
}
.msg-ai__brand-mark svg { width: 16px; height: 16px; }
.msg-ai__brand-mark img { width: 16px; height: 16px; display: block; }
.msg-ai__brand-name { font-size: 15px; font-weight: 700; color: var(--text); }

.msg-ai__divider {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0 14px;
  font-size: 13px; color: var(--text-mute);
  user-select: none;
}
.msg-ai__divider::before,
.msg-ai__divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}
.msg-ai__divider-inner {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background .15s;
}
.msg-ai__divider-inner:hover { background: var(--chip-bg); }
.msg-ai__divider svg { transition: transform .2s; }
.msg-ai__divider.is-collapsed svg { transform: rotate(-90deg); }

.msg-ai__body {
  width: 100%;
  font-size: 13px;
  color: var(--text);
  line-height: 1.55;
  position: relative;
  /* 长单词 / URL 编码串等不可断内容强制换行，避免溢出容器 */
  overflow-wrap: anywhere;
  word-break: break-word;
}
/* 标题不放大字号，靠加粗/变色突出 */
.msg-ai__body h1,
.msg-ai__body h2,
.msg-ai__body h3 {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  margin: 14px 0 8px;
  line-height: 1.5;
  letter-spacing: -0.01em;
}
.msg-ai__body h3 { color: var(--accent-orange); }
.msg-ai__body h2:first-child,
.msg-ai__body h3:first-child { margin-top: 0; }

.msg-ai__body p { margin: 0 0 8px; }
.msg-ai__body p:last-child { margin-bottom: 0; }

/* 打字机增量渲染尾部容器：承载进行中的块，不参与布局 */
.msg-ai__body .type-tail { display: contents; }

/* 引用块：模拟 AI 思考过程风格 */
.msg-ai__body blockquote {
  margin: 0 0 8px;
  padding: 8px 12px;
  border-left: 3px solid var(--accent-orange);
  background: var(--chip-bg);
  border-radius: 0 10px 10px 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-2, var(--text));
  opacity: .92;
}
.msg-ai__body blockquote:last-child { margin-bottom: 0; }
.msg-ai__body blockquote strong { color: var(--accent-orange); }

/* 打印机模式：输出中的闪烁光标 */
.msg-ai__body.is-typing::after {
  content: '▌';
  display: inline-block;
  margin-left: 2px;
  color: var(--accent-orange);
  animation: typing-caret .8s steps(1) infinite;
}
@keyframes typing-caret {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

.msg-ai__body a {
  color: var(--link-blue);
  text-decoration: none;
  border-bottom: 1px solid rgba(58, 108, 231, 0.35);
  transition: border-color .15s;
}
.msg-ai__body a:hover { border-bottom-color: var(--link-blue); }

/* 通用 Markdown 按钮链接（[text](url "btn")，供各模块回复自行选用） */
.msg-ai__body a.md-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 3px 4px 3px 0;
  padding: 5px 13px;
  border: 1px solid rgba(122, 90, 245, 0.35);
  border-bottom: 1px solid rgba(122, 90, 245, 0.35);
  border-radius: var(--r-pill);
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background .15s, color .15s, box-shadow .15s, transform .15s;
}
.msg-ai__body a.md-btn::before {
  content: '';
  flex: none;
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4.5px 0 4.5px 7px;
  border-color: transparent transparent transparent currentColor;
}
.msg-ai__body a.md-btn:hover {
  background: var(--brand);
  color: #fff;
  box-shadow: var(--shadow-brand);
  transform: translateY(-1px);
}
.msg-ai__body a.md-btn:active { transform: translateY(0); }

.msg-ai__body strong { font-weight: 700; color: var(--text); }
.msg-ai__body em { font-style: italic; }

/* Markdown 内嵌本地图标（如标题前的 aigo 图标），统一渲染为黑色 */
.msg-ai__body img.md-img-icon {
  height: 1.05em;
  width: auto;
  vertical-align: -0.12em;
  margin-right: 6px;
  filter: brightness(0);
}

.msg-ai__body code:not(pre code) {
  background: var(--chip-bg);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.9em;
  color: #c2581d;
}

.msg-ai__body pre {
  background: var(--bubble-user);
  padding: 14px 16px;
  border-radius: var(--r-md);
  margin: 12px 0;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.6;
}
.msg-ai__body pre code { background: transparent; padding: 0; color: var(--text); }

.msg-ai__body ul,
.msg-ai__body ol { margin: 8px 0 12px 4px; padding-left: 22px; }
.msg-ai__body li { margin-bottom: 4px; }

.msg-ai__body .task-item {
  display: flex; align-items: flex-start; gap: 8px;
  margin: 5px 0;
  list-style: none;
  margin-left: -22px;
}
.msg-ai__body .task-box {
  flex-shrink: 0;
  width: 18px; height: 18px;
  margin-top: 2px;
  border-radius: 5px;
  border: 1.5px solid var(--line-strong);
  display: grid; place-items: center;
  background: #fff;
}
.msg-ai__body .task-item.is-done .task-box {
  background: var(--green-ok);
  border-color: var(--green-ok);
  color: #fff;
}
.msg-ai__body .task-box svg { width: 12px; height: 12px; opacity: 0; }
.msg-ai__body .task-item.is-done .task-box svg { opacity: 1; }
.msg-ai__body .task-item.is-done .task-text {
  color: var(--text-mute); text-decoration: line-through;
}

.msg-ai__body hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 10px 0;
}

.msg-ai__body .dir-row {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 0;
  color: var(--text-soft);
}
.msg-ai__body .dir-row svg { color: var(--accent-orange); }

.msg-ai__actions {
  display: flex; justify-content: flex-end; gap: 4px;
  margin-top: 10px;
}
.msg-ai__copy {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; color: var(--text-mute);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  transition: background .15s, color .15s;
}
.msg-ai__copy:hover { background: var(--chip-bg); color: var(--text-soft); }
.msg-ai__copy.is-copied { color: var(--green-ok); }

/* ---------- 打字指示器 ---------- */
.typing {
  width: 100%;
  max-width: var(--col-main);
  margin: 0 auto;
  display: flex; flex-direction: column; gap: 10px;
  padding: 4px 0 18px;
  animation: fadeUp .25s ease;
}
.typing__brand { display: inline-flex; align-items: center; gap: 8px; }
.typing__brand-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: #1a1a1e; color: #fff;
  display: grid; place-items: center;
}
.typing__brand-mark svg { width: 16px; height: 16px; }
.typing__brand span { font-size: 15px; font-weight: 700; color: var(--text); }

.typing__dots {
  align-self: flex-start;
  display: flex; gap: 4px;
  padding: 12px 18px;
  background: var(--bubble-user);
  border-radius: var(--r-lg);
  border-top-left-radius: 6px;
}
.typing__dots span {
  width: 6px; height: 6px;
  border-radius: var(--r-pill);
  background: var(--text-mute);
  animation: dot 1.2s infinite ease-in-out;
}
.typing__dots span:nth-child(2) { animation-delay: .15s; }
.typing__dots span:nth-child(3) { animation-delay: .3s; }

/* ============================================================
 * 动画
 * ========================================================== */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes dot {
  0%, 80%, 100% { opacity: .35; transform: translateY(0); }
  40%           { opacity: 1;    transform: translateY(-4px); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
 * 响应式
 * ========================================================== */
@media (min-width: 1400px) {
  .side { width: 288px; }
}

@media (max-width: 900px) {
  .app { padding: 0; gap: 0; }
  .panel { border-radius: 0; border: none; }
  .stage { padding: 0 18px; }
  .stage__dock { padding: 0 18px; }

  /* 边栏变为抽屉：默认收起，点击按钮打开 */
  .side {
    display: flex;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 288px;
    max-width: 84vw;
    background: var(--bg);
    border-right: 1px solid var(--line);
    box-shadow: var(--shadow-pop);
    z-index: 60;
    transform: translateX(-105%);
    transition: transform .28s cubic-bezier(.2,.7,.2,1);
  }
  .app.is-side-open .side { transform: translateX(0); }

  .side-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 22, 0.32);
    z-index: 50;
    opacity: 0;
    pointer-events: none;
    transition: opacity .28s;
  }
  .app.is-side-open .side-backdrop { opacity: 1; pointer-events: auto; }
}

@media (max-width: 560px) {
  /* 移动端不隐藏描述：单行显示，超宽省略号截断 */
  .sugg-row__desc { display: block; }
  .sugg-row__title { white-space: normal; }
  .home { padding-top: 8vh; }
  .model-btn span { max-width: 90px; overflow: hidden; text-overflow: ellipsis; }
  /* 模型描述移动端同样显示：宽度同样按内容自适应，上限为输入框的 90% */
  .model-menu { width: fit-content; max-width: 90cqw; }
  .cb-send { width: 32px; height: 32px; }
}

/* 新建任务确认弹窗：无边框 + 毛玻璃 */
.modal-mask {
  position: fixed; inset: 0; z-index: 1200;
  display: grid; place-items: center;
  background: rgba(20,20,24,.28);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal-mask[hidden] { display: none; }
.modal-glass {
  width: min(400px, calc(100vw - 48px));
  padding: 26px 26px 20px;
  border-radius: 18px;
  border: none;
  background: rgba(255,255,255,.55);
  backdrop-filter: blur(24px) saturate(170%);
  -webkit-backdrop-filter: blur(24px) saturate(170%);
  box-shadow: 0 24px 70px rgba(0,0,0,.22);
}
.modal-glass__text { margin: 0 0 20px; font-size: 14px; line-height: 1.7; color: var(--text); }
.modal-glass__actions { display: flex; justify-content: flex-end; gap: 10px; }
.modal-glass__btn {
  border: none; cursor: pointer;
  padding: 8px 20px; border-radius: 999px;
  font-size: 13px; font-weight: 600;
  background: rgba(255,255,255,.6); color: var(--text-soft);
  transition: background .15s, color .15s;
}
.modal-glass__btn:hover { background: rgba(255,255,255,.85); color: var(--text); }
.modal-glass__btn--ok { background: var(--text); color: #fff; }
.modal-glass__btn--ok:hover { background: #000; color: #fff; }

/* 使用帮助弹窗：本地全屏无边框毛玻璃 */
.help-mask {
  position: fixed; inset: 0; z-index: 1300;
  background: rgba(20,20,24,.30);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: help-fade .24s ease both;
}
.help-mask[hidden] { display: none; }
@keyframes help-fade { from { opacity: 0; } to { opacity: 1; } }

.help-panel {
  position: absolute; inset: 14px;
  display: flex; flex-direction: column;
  border-radius: 22px; overflow: hidden;
  border: none;
  background: rgba(255,255,255,.62);
  backdrop-filter: blur(28px) saturate(170%);
  -webkit-backdrop-filter: blur(28px) saturate(170%);
  box-shadow: 0 30px 90px rgba(0,0,0,.25);
  animation: help-pop .3s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes help-pop {
  from { opacity: 0; transform: scale(.97) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.help-panel__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 26px 14px;
  border-bottom: 1px solid rgba(0,0,0,.06);
}
.help-panel__title { margin: 0; font-size: 17px; font-weight: 700; color: var(--text); letter-spacing: .5px; }
.help-panel__close {
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border: none; border-radius: 999px; cursor: pointer;
  background: rgba(255,255,255,.6); color: var(--text-soft);
  transition: background .15s, color .15s, transform .15s;
}
.help-panel__close:hover { background: rgba(0,0,0,.08); color: var(--text); transform: rotate(90deg); }

.help-panel__body { flex: 1; overflow-y: auto; padding: 18px 26px 30px; }

.help-item {
  display: grid; gap: 10px;
  padding: 16px 18px;
  border-radius: 14px;
  background: rgba(255,255,255,.55);
  box-shadow: 0 1px 0 rgba(0,0,0,.03);
  animation: help-item-in .4s cubic-bezier(.2,.8,.2,1) both;
}
.help-item + .help-item { margin-top: 12px; }
@keyframes help-item-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.help-item__q, .help-item__a { display: flex; align-items: flex-start; gap: 10px; }
.help-item__badge {
  flex: none;
  display: grid; place-items: center;
  width: 24px; height: 24px; margin-top: 1px;
  border-radius: 8px;
  font-size: 12px; font-weight: 700;
}
.help-item__badge--q { background: rgba(0,0,0,.08); color: var(--text); }
.help-item__badge--a { background: rgba(76,175,80,.16); color: #2e7d32; }
.help-item__text { font-size: 14px; line-height: 1.75; color: var(--text-soft); overflow-wrap: anywhere; }
.help-item__q .help-item__text { font-weight: 600; color: var(--text); }

.help-empty {
  padding: 60px 0; text-align: center;
  font-size: 13px; color: var(--text-soft);
}

@media (max-width: 560px) {
  .help-panel { inset: 0; border-radius: 0; }
  .help-panel__head { padding: 16px 18px 12px; }
  .help-panel__body { padding: 14px 18px 24px; }
  .help-item { padding: 14px; }
}
