/* ============================================================================
 *  对话界面：对齐 DeepSeek 安卓版
 *
 *  只覆盖样式，不动 app.js 的结构：
 *    · 用户消息：右侧蓝色气泡
 *    · 助手消息：左侧无气泡纯文本（支持轻量 Markdown）
 *    · 输入区：整条胶囊，输入框常显，话筒/附件/发送都在胶囊里
 * ========================================================================== */

/* ---------- 消息区 ---------- */

#log {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 14px 14px 6px;
}

.msg {
  max-width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  white-space: normal;
  word-break: break-word;
}

/* 用户：右侧气泡 */
.msg.user {
  align-self: flex-end;
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 18px;
  border-bottom-right-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  white-space: pre-wrap;
  font-size: 15.5px;
  line-height: 1.6;
}

/* 助手：左侧纯文本（DeepSeek 就是这么排的，不给气泡） */
.msg.assistant {
  align-self: stretch;
  color: var(--text);
  font-size: 15.5px;
  line-height: 1.78;
  padding-top: 2px;
}

.msg.assistant p { margin: 0 0 12px; }
.msg.assistant p:last-child { margin-bottom: 0; }
.msg.assistant h1,
.msg.assistant h2,
.msg.assistant h3 { margin: 4px 0 10px; line-height: 1.4; }
.msg.assistant h1 { font-size: 19px; }
.msg.assistant h2 { font-size: 17px; }
.msg.assistant h3 { font-size: 16px; }
.msg.assistant ul,
.msg.assistant ol { margin: 0 0 12px; padding-left: 22px; }
.msg.assistant li { margin: 3px 0; }
.msg.assistant a { color: #6ea8fe; text-decoration: none; }
.msg.assistant a:active { text-decoration: underline; }

/* 行内代码 */
.msg.assistant code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13.5px;
  background: rgba(255, 255, 255, .09);
  padding: 1px 5px;
  border-radius: 5px;
}

/* 代码块 */
.msg.assistant pre {
  margin: 0 0 12px;
  padding: 11px 13px;
  border-radius: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.msg.assistant pre code {
  background: none;
  padding: 0;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre;
}

/* 引用块 */
.msg.assistant blockquote {
  margin: 0 0 12px;
  padding: 2px 12px;
  border-left: 3px solid var(--line);
  color: var(--muted);
}

/* 系统提示 / 错误：居中细条 */
.msg.note,
.msg.err {
  align-self: center;
  max-width: 92%;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 13px;
  text-align: center;
}
.msg.note { color: var(--muted); background: transparent; }
.msg.err { color: var(--err); background: rgba(255, 107, 107, .10); border: 1px solid rgba(255, 107, 107, .3); }

.msg .meta {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}
.msg.user .meta { color: rgba(255, 255, 255, .72); }

/* 消息操作条（复制 / 重新生成） */
.msg-actions {
  display: flex;
  gap: 16px;
  margin-top: 8px;
}
.msg-actions button {
  background: none;
  border: 0;
  padding: 0;
  color: var(--muted);
  font: inherit;
  font-size: 12.5px;
  cursor: pointer;
}
.msg-actions button:active { color: var(--text); }

/* ---------- 输入区：整条胶囊 ---------- */

.composer {
  flex: 0 0 auto;
  padding: 8px 12px calc(10px + var(--safe-b));
  border-top: 0;
  background: transparent;
  backdrop-filter: none;
}

/* 已选附件条 */
.attach-strip {
  margin-bottom: 8px;
  padding: 8px 10px;
  border-radius: 14px;
  background: var(--bg-card);
  border: 1px solid var(--line);
}

.composer-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  min-width: 0;            /* 关键：允许收缩，否则整页被撑宽、底部导航被切 */
  max-width: 100%;
  padding: 6px 8px 6px 6px;
  border-radius: 26px;
  background: var(--bg-card);
  border: 1px solid var(--line);
}

/* 文字输入常显，和 DeepSeek 一样直接把输入框摆在胶囊里 */
.text-row,
#textRow {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;            /* 同上：文本行可以缩到比内容更窄 */
  align-items: flex-end;
  gap: 6px;
  background: transparent;
}
.text-row.hidden { display: flex !important; }

#textInput,
.text-row textarea {
  flex: 1 1 0;
  min-width: 0;
  min-height: 24px;
  max-height: 120px;
  padding: 9px 4px;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15.5px;
  line-height: 1.5;
  resize: none;
  outline: none;
}

#btnSend.primary.small {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  font-size: 0;               /* 只显示箭头，不要"发送"两个字 */
  background: var(--accent);
  position: relative;
}
#btnSend.primary.small::after {
  content: '↑';
  font-size: 19px;
  line-height: 34px;
  color: var(--on-accent);
}

/* 胶囊里的小按钮：话筒、附件、图片 */
.composer-row .icon-btn,
.composer-row .icon-btn.big {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  font-size: 17px;
  border-radius: 50%;
}

/* 原来那个大话筒改成胶囊内的圆形按钮 */
.composer-row .call {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: visible;
}
.composer-row .call .call-ring {
  display: none;
}
.composer-row .call .call-icon { font-size: 18px; line-height: 1; }

/* 空闲提示 */
#emptyHint.empty {
  margin: auto;
  padding: 0 20px;
  text-align: center;
}
#emptyHint.empty p:first-child {
  font-size: 22px;
  font-weight: 600;
  margin: 0 0 10px;
}
#emptyHint.empty p.muted { margin: 4px 0; }

/* "⌨ 打字" 这个开关不需要了 —— 输入框已经常显 */
#btnKeyboard { display: none !important; }

/* ---------- 顶部：导入按钮 ---------- */

#btnImportChat {
  margin-right: 4px;
}

/* ---------- 导入对话弹层 ---------- */

.import-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 60;
  backdrop-filter: blur(2px);
}

.import-sheet {
  width: 100%;
  max-width: 560px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--bg-card);
  border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(16px + var(--safe-b));
  border: 1px solid var(--line);
}

.import-sheet h3 {
  margin: 0 0 4px;
  font-size: 17px;
}

.import-sheet .hint {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.import-drop {
  border: 1px dashed var(--line);
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  margin-bottom: 12px;
}
.import-drop:active { background: var(--bg-soft); }

.import-sheet textarea {
  width: 100%;
  min-height: 96px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  resize: vertical;
  box-sizing: border-box;
}

.import-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.import-actions button {
  flex: 1 1 0;
  padding: 12px 0;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}
.import-actions button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
}
.import-actions button:disabled { opacity: .5; }

.import-msg {
  margin-top: 10px;
  font-size: 13px;
  color: var(--muted);
  min-height: 18px;
}
.import-msg.err { color: var(--err); }
.import-msg.ok { color: var(--ok); }
