/* ===== 豆包风格 AI 对话页 ===== */
/* [hidden] 兜底：display:flex/grid 会覆盖 [hidden] 的 display:none，
   导致所有用 hidden 属性控制的弹窗菜单永远显示。此处强制隐藏，优先级最高。 */
[hidden] { display: none !important; }

/* 暗夜护眼主题：修正发白的半透明背景 */
[data-theme="night-care"] .sidebar { background: rgba(37, 43, 54, 0.6); }
[data-theme="night-care"] .chat-topbar { background: rgba(27, 31, 39, 0.85); }
[data-theme="night-care"] .composer { background: var(--bg-card); }
[data-theme="night-care"] .attach-img img,
[data-theme="night-care"] .msg-up-image { border-color: rgba(255, 255, 255, 0.12); }

.chat-page {
  margin: 0;
  height: 100vh;
  overflow: hidden;
}

.chat-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  height: 100vh;
  background:
    radial-gradient(1000px 500px at 12% -8%, rgba(var(--primary-rgb), 0.08), transparent 60%),
    linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
}

/* ---------- 左侧栏 ---------- */
.sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.sidebar__top {
  padding: 16px 14px 10px;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  font-weight: 800;
  color: var(--text-primary);
}

.sidebar__mark {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--color-primary), #22c55e);
  font-size: 16px;
}

.sidebar__new {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.sidebar__new:hover {
  border-color: rgba(var(--primary-rgb), 0.5);
  background: var(--bg-hover);
}

.sidebar__new span {
  color: var(--color-primary);
  font-weight: 800;
}

.sidebar__list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 8px;
}

/* 会话列表工具栏（管理 / 多选） */
.conv-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 14px 2px;
}
.conv-toolbar__label {
  flex: 1;
  font-size: 12px;
  color: var(--text-muted);
}
.conv-toolbar__manage {
  border: 0;
  background: transparent;
  color: var(--color-primary);
  font-size: 12px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
}
.conv-toolbar__manage:hover { background: var(--bg-hover); }
.conv-toolbar__manage[hidden] { display: none; }
.conv-toolbar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
}
.conv-toolbar__actions[hidden] { display: none; }
.conv-toolbar__all {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-secondary);
  cursor: pointer;
}
.conv-toolbar__del {
  border: 0;
  background: transparent;
  color: var(--color-danger, #dc2626);
  cursor: pointer;
}
.conv-toolbar__del:disabled { opacity: 0.4; cursor: not-allowed; }
.conv-toolbar__cancel {
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.conv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px;
  margin-bottom: 3px;
  border-radius: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.conv-item:hover {
  background: var(--bg-hover);
}

.conv-item--select.is-checked {
  background: var(--color-primary-soft);
}
.conv-item__check {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
  cursor: pointer;
}

.conv-item.is-active {
  background: var(--color-primary-soft);
  color: var(--color-primary-dark);
  font-weight: 700;
}

.conv-item__title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.conv-item__del {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.conv-item:hover .conv-item__del {
  opacity: 1;
}

.conv-item__del:hover {
  background: rgba(220, 38, 38, 0.12);
  color: var(--color-danger);
}

.sidebar__settings {
  padding: 14px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mini-field {
  display: block;
  margin-bottom: 0;
}

.mini-field span {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}

.mini-field select {
  width: 100%;
  height: 40px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background-color: var(--bg-card);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a94a6' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease;
}

.mini-field select:hover {
  border-color: var(--color-primary, #4a90d9);
  background-color: var(--bg-hover);
}

.mini-field select:focus {
  border-color: var(--color-primary, #4a90d9);
  box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.15);
}

.mini-field select option {
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 8px;
}

.quota-note {
  margin-top: 4px;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12px;
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
}

.sidebar__user {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border-color);
}

.sidebar__username {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
}

.sidebar__logout {
  flex-shrink: 0;
  padding: 6px 12px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
}

.sidebar__logout:hover {
  color: var(--color-danger);
  border-color: rgba(220, 38, 38, 0.4);
}

/* ---------- 右侧对话区 ---------- */
.chat-main {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: transparent;
}

.chat-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  min-height: 58px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(8px);
}

.topbar__icon {
  display: none;
  border: 0;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-secondary);
}

.topbar__title {
  flex: 1;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar__export {
  padding: 8px 14px;
  border: 1px solid var(--border-color);
  border-radius: 999px;
  background: var(--bg-card);
  color: var(--text-primary);
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.topbar__export:hover {
  border-color: rgba(var(--primary-rgb), 0.5);
  background: var(--bg-hover);
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px 0;
}

.messages__inner,
.welcome-card,
.message-row {
  width: min(760px, calc(100% - 40px));
  margin-left: auto;
  margin-right: auto;
}

.welcome-card {
  margin-top: 12vh;
  padding: 32px;
  text-align: center;
  border: 1px dashed rgba(var(--primary-rgb), 0.28);
  border-radius: var(--radius-lg);
  background: rgba(var(--primary-rgb), 0.05);
}

.welcome-card__icon {
  margin-bottom: 14px;
  font-size: 42px;
}

.welcome-card p {
  color: var(--text-secondary);
  line-height: 1.8;
}

.message-row {
  display: flex;
  margin-bottom: 22px;
}

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

.message-bubble {
  max-width: 100%;
  padding: 14px 18px;
  border-radius: 16px;
  line-height: 1.75;
  word-break: break-word;
}

.message-row.is-user .message-bubble {
  max-width: 72%;
  width: auto;
  flex: 0 0 auto;
  align-self: flex-end;
  color: #fff;
  border-bottom-right-radius: 6px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  white-space: pre-wrap;
}

.message-row.is-assistant .message-bubble {
  width: 100%;
  color: var(--text-primary);
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 6px;
}

.message-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}
.message-actions--user {
  justify-content: flex-end;
}

.message-actions > button,
.msg-more__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-secondary);
  background: var(--bg-card);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.message-actions > button:hover,
.msg-more__btn:hover {
  border-color: rgba(var(--primary-rgb), 0.5);
  color: var(--color-primary-dark);
  background: var(--bg-hover);
}
.msg-more__btn { font-weight: 700; letter-spacing: 1px; }

/* 更多菜单弹层 */
.msg-more { position: relative; }
.msg-more__menu {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0;
  z-index: 20;
  min-width: 132px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.14);
  animation: theme-menu-in 0.16s ease;
}
.message-actions--user .msg-more__menu { left: auto; right: 0; }
.msg-more__menu[hidden] { display: none; }
.msg-more__menu button {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.12s ease;
}
.msg-more__menu button:hover { background: var(--bg-hover); }

@keyframes theme-menu-in {
  from { opacity: 0; transform: translateY(6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* 用户消息：气泡 + 操作栏竖排，整体右对齐 */
.message-col {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  max-width: min(28em, 72%);
}
.message-col .message-bubble { width: auto; }

/* 编辑态提示条 */
.edit-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  padding: 8px 14px;
  border: 1px solid rgba(var(--primary-rgb), 0.35);
  border-radius: 12px;
  background: var(--color-primary-soft);
  font-size: 13px;
  color: var(--color-primary-dark);
}
.edit-bar[hidden] { display: none; }
.edit-bar__cancel {
  border: 0;
  background: transparent;
  color: var(--color-primary-dark);
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  flex-shrink: 0;
}

/* ---------- 文生图（即梦）结果 ---------- */
.message-bubble--image {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 640px;
}
/* 多图并排（单图时占满，多图时自适应换行） */
.gen-image__gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.gen-image__gallery .gen-image__wrap {
  flex: 1 1 200px;
  min-width: 160px;
  max-width: 100%;
}

.gen-image__caption {
  font-size: 14px;
  color: var(--text-secondary);
}

.gen-image__wrap {
  position: relative;
  display: block;
}
.gen-image__link {
  display: block;
  line-height: 0;
  width: 100%;
}

.gen-image {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.gen-image:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
}

/* 图片左下角悬浮工具栏：引用 / 再次生图 / 下载原图（豆包风格） */
.gen-image__toolbar {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}
.gen-image__wrap:hover .gen-image__toolbar {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.img-tool {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease;
}
.img-tool:hover { background: rgba(255, 255, 255, 0.18); }
/* hover 文字提示，浮在图标上方 */
.img-tool__tip {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease;
}
.img-tool:hover .img-tool__tip { opacity: 1; visibility: visible; }

/* ---------- Markdown 内容样式 ---------- */
.md h1, .md h2, .md h3, .md h4 {
  margin: 18px 0 10px;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.md h1 { font-size: 24px; }
.md h2 { font-size: 21px; }
.md h3 { font-size: 18px; }
.md h4 { font-size: 16px; }
.md h1:first-child, .md h2:first-child, .md h3:first-child { margin-top: 0; }

.md p {
  margin: 10px 0;
}

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

.md li {
  margin: 4px 0;
  line-height: 1.7;
}

.md strong {
  font-weight: 700;
  color: var(--text-primary);
}

.md code {
  padding: 2px 6px;
  border-radius: 6px;
  background: #eef1f6;
  font-family: Consolas, Monaco, monospace;
  font-size: 0.92em;
  color: #d6336c;
}

.md pre {
  margin: 12px 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: #1e2430;
  overflow-x: auto;
}

.md pre code {
  padding: 0;
  background: transparent;
  color: #e6e9ef;
  font-size: 13px;
  line-height: 1.6;
}

.md blockquote {
  margin: 12px 0;
  padding: 8px 16px;
  border-left: 4px solid var(--color-primary);
  background: var(--color-primary-soft);
  border-radius: 0 8px 8px 0;
  color: var(--text-secondary);
}

.md hr {
  margin: 16px 0;
  border: 0;
  border-top: 1px solid var(--border-color);
}

.md a {
  color: var(--color-primary);
  text-decoration: underline;
}

.md table {
  width: 100%;
  margin: 12px 0;
  border-collapse: collapse;
  font-size: 14px;
}

.md th, .md td {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  text-align: left;
}

.md th {
  background: #eef2fb;
  font-weight: 700;
}

/* ---------- 联网来源角标 + hover 卡片 ---------- */
.cite {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 15px;
  height: 15px;
  padding: 0 4px;
  margin: 0 1px;
  border-radius: 4px;
  background: rgba(74, 144, 217, 0.12);
  color: var(--color-primary, #4a90d9);
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  vertical-align: baseline;
  top: -1px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease;
}
.cite--nolink { color: var(--text-secondary, #8a94a6); background: rgba(138, 148, 166, 0.12); cursor: default; }
.cite:hover { background: rgba(74, 144, 217, 0.22); }
.cite-card {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: max-content;
  max-width: 280px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff;
  color: var(--text-primary, #1f2430);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
  border: 1px solid var(--border-color, #e3e8f0);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.15s ease, transform 0.15s ease;
  white-space: normal;
  text-align: left;
}
.cite:hover .cite-card {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}
.cite-card__site { font-size: 12px; color: var(--text-secondary, #8a94a6); }
.cite-card__title { font-size: 13px; line-height: 1.4; font-weight: 600; }


.composer-dock {
  width: min(760px, calc(100% - 40px));
  margin: 0 auto;
  padding: 12px 0 22px;
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px 10px 16px;
  border: 1px solid var(--border-color);
  border-radius: 22px;
  background: var(--bg-card);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

/* 仅当文本输入区（textarea / 音乐填空区）聚焦时高亮，点击下方功能按钮不触发外发光 */
.composer:has(textarea:focus),
.composer:has(.music-fill:focus) {
  border-color: rgba(var(--primary-rgb), 0.5);
  box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.1);
}

.composer textarea {
  width: 100%;
  min-height: 26px;
  max-height: 180px;
  resize: none;
  padding: 4px 0;
  border: 0;
  outline: none;
  color: var(--text-primary);
  background: transparent;
  line-height: 1.55;
  font-family: inherit;
  font-size: 15px;
}

/* 底部操作条：📎 在左，功能条居中滚动，麦克风+发送固定右侧 */
.composer__bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 豆包式功能条：横向可滚动，占据中间弹性空间 */
.composer__tools {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-behavior: smooth;
  padding: 2px 0;
}
.composer__tools::-webkit-scrollbar { display: none; }

.composer__tool {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 0 12px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 17px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.composer__tool svg { flex-shrink: 0; }
.composer__tool:hover { background: var(--bg-hover); color: var(--text-primary); }
/* 焦点态：去掉浏览器默认轮廓/阴影/边框，避免点击后按钮周围出现黑框 */
.composer__tool:focus,
.composer__tool:focus-visible,
.composer__tool:active {
  outline: none;
  box-shadow: none;
  border: 0;
}
/* 非 hover / 非激活时，即便处于焦点也保持透明背景 */
.composer__tool:focus:not(:hover):not(.is-active) { background: transparent; }
/* 激活态（当前模式 / 联网开启）：主题色高亮胶囊 */
.composer__tool.is-active {
  background: var(--color-primary-soft, rgba(74, 144, 217, 0.14));
  color: var(--color-primary-dark, #2f6dbf);
}
.composer__more-wrap { position: relative; flex: 0 0 auto; }

/* 更多角色 弹出菜单 */
.tool-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 25;
  width: 240px;
  max-height: 300px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--bg-card);
  box-shadow: var(--shadow-md, 0 10px 28px rgba(0, 0, 0, 0.14));
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tool-menu__item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 14px;
}
.tool-menu__item:hover { background: var(--bg-hover); }
.tool-menu__item.is-active { background: var(--color-primary-soft); color: var(--color-primary-dark); }
.tool-menu__icon { font-size: 16px; flex-shrink: 0; }
.tool-menu__name { flex: 1 1 auto; }
.tool-menu__desc {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}
/* 「升级」标签：亮色引导 */
.tool-menu__badge {
  flex-shrink: 0;
  align-self: center;
  padding: 2px 7px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, #f59e0b, #f97316);
}
/* 快速模式菜单略宽，容纳说明文字；靠左对齐（快速按钮在最左） */
.tool-menu--speed { width: 250px; left: 0; right: auto; }
/* 「快速」按钮下拉箭头 + 触发器容器 */
.composer__speed-wrap { position: relative; flex: 0 0 auto; }
.composer__tool-caret { opacity: 0.6; margin-left: -1px; }

/* 麦克风按钮 */
.composer__mic {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease;
}
.composer__mic:hover { background: var(--bg-hover); color: var(--text-primary); }

.composer__send {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--color-primary, #4a90d9);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

.composer__send:hover { opacity: 0.9; }
.composer__send:active { transform: scale(0.94); }

.composer__send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

/* 停止输出：主题色实心方块钮 */
.composer__send.is-stop {
  background: var(--color-primary);
}

/* 等待 AI 响应：按钮转圈 */
.composer__send.is-loading {
  position: relative;
  color: transparent;
}
.composer__send.is-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: send-spin 0.7s linear infinite;
}
@keyframes send-spin {
  to { transform: rotate(360deg); }
}

/* 逐字打印光标：紧跟文字末尾的闪烁竖条 */
.type-cursor {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--color-primary);
  border-radius: 1px;
  animation: cursor-blink 1s step-end infinite;
}
@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ---------- 打字动画 ---------- */
.typing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: pulse 1.2s infinite ease-in-out;
}

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

@keyframes pulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ---------- 侧栏遮罩（移动端） ---------- */
.sidebar-mask {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(15, 23, 42, 0.4);
}

/* ---------- 响应式 ---------- */
@media (max-width: 820px) {
  .chat-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 40;
    width: 268px;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .topbar__icon {
    display: block;
  }
}

/* ---------- 单条消息删除按钮 ---------- */
.message-row { position: relative; }
.msg-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-muted);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.message-row:hover .msg-del { opacity: 1; }
.msg-del:hover { background: var(--color-danger); color: #fff; }
.message-row.is-user .msg-del { left: 2px; right: auto; }

/* ---------- 附件上传 ---------- */
.composer__attach {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  cursor: pointer;
  border-radius: 50%;
  color: var(--text-secondary);
  transition: background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}
.composer__attach:hover { background: var(--bg-hover); color: var(--text-primary); }

/* 功能专属选项行 */
.composer__options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 4px 2px;
}
.composer__opt {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--border-color);
  border-radius: 15px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
}
.composer__opt-label { line-height: 1; white-space: nowrap; }
.composer__opt-select {
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  cursor: pointer;
  outline: none;
  padding: 0 2px;
}

/* ---------- 音乐模式：结构化「填空句」输入区 ---------- */
/* 多行自动换行排版，行内元素垂直居中，与豆包输入区风格一致 */
.music-compose {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 6px;
  padding: 4px 2px 6px;
  font-size: 15px;
  line-height: 2;
  color: var(--text-primary);
}
.music-txt { flex: 0 0 auto; }

/* 内联下拉：白色圆角背景 + 灰色文字 + 下拉箭头 */
.music-drop {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 8px 0 10px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: #fff;
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.music-drop:hover { border-color: rgba(var(--primary-rgb), 0.5); }
.music-drop:focus-visible,
.music-drop.is-open {
  outline: none;
  border-color: rgba(var(--primary-rgb), 0.6);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.12);
}
/* 展开的下拉提升堆叠层级，避免被后面的同级下拉/占位区遮挡 */
.music-drop.is-open { z-index: 120; }
.music-drop__text { line-height: 1; white-space: nowrap; }
.music-drop__arrow {
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}
.music-drop.is-open .music-drop__arrow { transform: rotate(180deg); }

/* 下拉菜单：向上弹出，避免被输入框裁切 */
.music-drop__menu {
  position: absolute;
  left: 0;
  bottom: calc(100% + 6px);
  z-index: 130;
  min-width: 120px;
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-card);
  box-shadow: var(--shadow-md, 0 8px 24px rgba(0, 0, 0, 0.12));
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.music-drop__item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.music-drop__item:hover { background: var(--bg-hover); }
.music-drop__item.is-sel {
  color: var(--color-primary-dark);
  background: var(--color-primary-soft);
}
/* 靠右的下拉（音色）菜单右对齐，避免溢出输入框右缘 */
.music-drop[data-key="voice"] .music-drop__menu { left: auto; right: 0; }

/* 可编辑占位输入区：浅灰高亮，提示可编辑，可随内容换行增高 */
.music-fill {
  flex: 1 1 200px;
  min-width: 160px;
  padding: 2px 10px;
  border-radius: 10px;
  background: var(--bg-hover, rgba(0, 0, 0, 0.05));
  color: var(--text-primary);
  outline: none;
  word-break: break-word;
  transition: box-shadow 0.15s ease, background 0.15s ease;
}
.music-fill:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
}
.music-fill:focus {
  background: var(--color-primary-soft);
  box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.25);
}

/* ---------- 音乐态底部控件（分隔线 / 标签 / 模板） ---------- */
.composer__music-extra {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}
.composer__sep {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  flex-shrink: 0;
}
/* 「音乐生成」高亮标签：浅蓝背景 + 蓝色文字 + 关闭× */
.composer__tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 6px 0 12px;
  border-radius: 15px;
  background: var(--color-primary-soft, rgba(74, 144, 217, 0.14));
  color: var(--color-primary-dark, #2f6dbf);
  font-size: 13px;
  flex-shrink: 0;
}
.composer__tag-label { line-height: 1; white-space: nowrap; }
.composer__tag-x {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  font-size: 11px;
  cursor: pointer;
  opacity: 0.75;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.composer__tag-x:hover { background: rgba(var(--primary-rgb), 0.2); opacity: 1; }
/* 模板按钮：白底浅灰文字 + 图标 */
.composer__template {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 12px;
  border: 1px solid var(--border-color);
  border-radius: 15px;
  background: var(--bg-card, #fff);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.composer__template:hover { background: var(--bg-hover); color: var(--text-primary); }

/* 模板菜单：向上弹出 */
.template-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 130;
  width: 260px;
  max-height: 280px;
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--border-color);
  border-radius: 14px;
  background: var(--bg-card);
  box-shadow: var(--shadow-md, 0 10px 28px rgba(0, 0, 0, 0.14));
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.template-menu__item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.template-menu__item:hover { background: var(--bg-hover); }
.template-menu__name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.template-menu__desc {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 音乐态：隐藏普通 textarea 与其它模式按钮，突出填空句 */
/* 音乐态：隐藏普通 textarea 与功能滚动条，突出填空句 + 音乐标签 */
.composer.is-music textarea { display: none; }
.composer.is-music .composer__tools { display: none; }

/* 生成的视频 / 音频 */
.gen-video {
  display: block;
  width: 100%;
  max-width: 480px;
  border-radius: 12px;
  border: 1px solid var(--border-color);
  background: #000;
}
.gen-audio {
  display: block;
  width: 100%;
  max-width: 420px;
  margin-top: 4px;
}

.attach-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 4px;
}
/* 图片：大缩略图方块 + 右上悬浮删除 */
.attach-img {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 10px;
  overflow: visible;
}
.attach-img img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  display: block;
}
/* 文档：横向卡片 */
.attach-doc {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 28px 8px 8px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--bg-card);
  max-width: 220px;
}
.attach-doc__icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}
.attach-doc__icon.is-word { background: #2b7cd3; }
.attach-doc__icon.is-excel { background: #1f9d55; }
.attach-doc__icon.is-pdf { background: #e0533d; }
.attach-doc__icon.is-ppt { background: #e08a2b; }
.attach-doc__icon.is-text { background: #8a94a6; }
.attach-doc__info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.attach-doc__name {
  font-size: 13px; font-weight: 600; color: var(--text-primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 140px;
}
.attach-doc__meta { font-size: 11px; color: var(--text-secondary); }
/* 通用删除按钮：悬浮右上角 */
.attach-del {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border: 1.5px solid #fff;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 2;
}
.attach-del:hover { background: var(--color-danger, #e0533d); }
.msg-up-images { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.msg-up-image { max-width: 160px; max-height: 160px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.3); }
.msg-up-docs { font-size: 13px; opacity: 0.85; margin-bottom: 6px; }
