/* DeepSeek 手机版 — 样式 */

:root {
  --accent: #4d6bfe;
  --accent-strong: #3a57f0;
  --accent-soft: rgba(77, 107, 254, 0.16);
  --bg: #0d0f13;
  --bg-elev: #12151b;
  --surface: #171b23;
  --surface-2: #1e232d;
  --border: rgba(255, 255, 255, 0.085);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e9ecf3;
  --text-dim: #9aa3b2;
  --text-faint: #6b7484;
  --user-bubble: #3b56e8;
  --user-text: #ffffff;
  --code-bg: #0a0c10;
  --code-border: rgba(255, 255, 255, 0.08);
  --danger: #ff6b6b;
  --ok: #35c98a;
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
  --radius: 16px;
  --topbar-h: 52px;
  --reading-size: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f5f6fa;
    --bg-elev: #ffffff;
    --surface: #ffffff;
    --surface-2: #eef1f7;
    --border: rgba(16, 24, 40, 0.09);
    --border-strong: rgba(16, 24, 40, 0.16);
    --text: #16181d;
    --text-dim: #5b6270;
    --text-faint: #8a919e;
    --user-bubble: #4d6bfe;
    --user-text: #ffffff;
    --code-bg: #f2f4f9;
    --code-border: rgba(16, 24, 40, 0.1);
    --shadow: 0 8px 30px rgba(16, 24, 40, 0.12);
  }
}

:root[data-theme="light"] {
  --bg: #f5f6fa;
  --bg-elev: #ffffff;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --border: rgba(16, 24, 40, 0.09);
  --border-strong: rgba(16, 24, 40, 0.16);
  --text: #16181d;
  --text-dim: #5b6270;
  --text-faint: #8a919e;
  --user-bubble: #4d6bfe;
  --user-text: #ffffff;
  --code-bg: #f2f4f9;
  --code-border: rgba(16, 24, 40, 0.1);
  --shadow: 0 8px 30px rgba(16, 24, 40, 0.12);
}

:root[data-theme="dark"] {
  --bg: #0d0f13;
  --bg-elev: #12151b;
  --surface: #171b23;
  --surface-2: #1e232d;
  --border: rgba(255, 255, 255, 0.085);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e9ecf3;
  --text-dim: #9aa3b2;
  --text-faint: #6b7484;
  --user-bubble: #3b56e8;
  --user-text: #ffffff;
  --code-bg: #0a0c10;
  --code-border: rgba(255, 255, 255, 0.08);
  --shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

body { position: fixed; inset: 0; }

button { font-family: inherit; color: inherit; }
input, textarea, select { font-family: inherit; font-size: 16px; color: var(--text); }
a { color: var(--accent); text-decoration: none; }

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  position: relative;
  overflow: hidden;
}

/* ---------- 顶栏 ---------- */
.topbar {
  flex: 0 0 auto;
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: calc(var(--safe-top) + 6px) 10px 6px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  z-index: 20;
  min-height: calc(var(--topbar-h) + var(--safe-top));
}

.icon-btn {
  appearance: none;
  border: 0;
  background: transparent;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  line-height: 1;
  color: var(--text);
  transition: background 0.15s;
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn.small { width: 32px; height: 32px; font-size: 15px; border-radius: 10px; color: var(--text-dim); }
.icon-btn.text-btn { font-size: 20px; font-weight: 500; }

/* 设置/导入等全屏页面：iOS 风格从右侧推入 + 左边缘跟手右滑返回 */
.back-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--accent);
  border-radius: 10px;
  padding: 10px 8px 10px 2px;
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
  flex: 0 0 auto;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.back-btn:active { opacity: 0.45; }
.head-spacer { width: 72px; flex: 0 0 auto; }
.panel-foot { margin-top: 26px; }
.panel-foot .btn { width: 100%; }

.topbar-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text);
  padding: 0 4px;
}

/* ---------- 会话区 ---------- */
.chat {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
}
.chat::-webkit-scrollbar { width: 4px; }
.chat::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

.welcome {
  margin: auto;
  padding: 32px 24px 12px;
  text-align: center;
  max-width: 520px;
}
.welcome-logo {
  display: block;
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 18px;
  object-fit: cover;
  box-shadow: 0 10px 28px rgba(77, 107, 254, 0.35);
}
.welcome h1 { font-size: 21px; margin: 0 0 8px; font-weight: 700; }
.welcome p { margin: 0 0 18px; color: var(--text-dim); font-size: 14px; line-height: 1.6; }
.welcome .chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip-btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13px;
  line-height: 1.3;
  transition: transform 0.12s, background 0.15s;
}
.chip-btn:active { transform: scale(0.96); background: var(--surface-2); }
.welcome-hint { margin-top: 18px; font-size: 12px; color: var(--text-faint); line-height: 1.7; }

.messages {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 14px 18px;
  width: 100%;
  max-width: 780px;
  margin: 0 auto;
}

.msg { display: flex; flex-direction: column; position: relative; }
.msg + .msg { margin-top: 10px; }

.load-earlier {
  align-self: center;
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1;
  padding: 9px 14px;
  border-radius: 999px;
  margin: 2px auto 12px;
}
.load-earlier:active { background: var(--surface-2); color: var(--text); }

.msg-user { align-items: flex-end; }
.msg-user .bubble {
  max-width: 84%;
  background: var(--user-bubble);
  color: var(--user-text);
  padding: 10px 14px;
  border-radius: 18px 18px 5px 18px;
  font-size: var(--reading-size);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.msg-user .bubble .bubble-images {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 4px;
  margin-top: 6px;
  white-space: normal;
}
.msg-user .bubble .bubble-images img {
  width: 100%;
  max-height: 170px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}

.msg-assistant { align-items: stretch; }
.msg-assistant .assistant-body {
  font-size: var(--reading-size);
  line-height: 1.7;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* 深度思考 / 联网搜索 开关 */
.composer-toggles {
  display: flex;
  gap: 8px;
  padding: 7px 2px 1px;
}
.toggle-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1;
  padding: 8px 12px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.toggle-btn:active { transform: scale(0.97); }
.toggle-btn.active {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  color: var(--text);
}
.toggle-btn[disabled] { opacity: 0.45; }

/* 联网搜索结果 */
.search-block {
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border-radius: 12px;
  margin: 8px 0 10px;
  overflow: hidden;
}
.search-block > summary {
  cursor: pointer;
  list-style: none;
  padding: 9px 12px;
  font-size: 12.5px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 7px;
  user-select: none;
}
.search-block > summary::-webkit-details-marker { display: none; }
.search-block[open] > summary { border-bottom: 1px solid var(--border); }
.search-list { padding: 6px 10px 10px; display: flex; flex-direction: column; gap: 8px; }
.search-item {
  display: block;
  text-decoration: none;
  color: inherit;
  border-radius: 10px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.search-item:active { background: var(--surface-2); }
.search-item .si-title2 {
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
  line-height: 1.45;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-item .si-snippet {
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.55;
  margin-top: 3px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.search-item .si-meta { font-size: 10.5px; color: var(--text-faint); margin-top: 3px; }
.citation-list {
  padding: 8px 12px 10px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.7;
}
.citation-list a { color: var(--accent); }
.citation-list .cite-index { color: var(--text-faint); margin-right: 4px; }

/* 输入框上方的待发送图片 */
.image-strip {
  display: flex;
  gap: 8px;
  padding: 8px 4px 2px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.image-strip::-webkit-scrollbar { display: none; }
.image-strip[hidden] { display: none; }
.image-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 62px;
  height: 62px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
}
.image-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.image-thumb .rm {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, 0.62);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  display: grid;
  place-items: center;
}

/* 待发送文件的小卡片 */
.file-chip {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 30px 9px 10px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 12px;
  color: var(--text);
  max-width: 210px;
}
.file-chip .fc-icon {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 3px 4px;
  min-width: 26px;
  text-align: center;
  flex: 0 0 auto;
}
.file-chip .fc-main { min-width: 0; }
.file-chip .fc-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.file-chip .fc-meta { font-size: 10.5px; color: var(--text-faint); margin-top: 2px; }
.file-chip .rm {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 0;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 11px;
  line-height: 1;
  display: grid;
  place-items: center;
}

/* 用户消息气泡里的附件 */
.msg-user .bubble .bubble-files {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 6px;
  white-space: normal;
}
.msg-user .bubble .bubble-file {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 11.5px;
  line-height: 1.3;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 图片查看器 */
.image-viewer {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(0, 0, 0, 0.93);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.image-viewer[hidden] { display: none; }
.image-viewer img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 8px; }

.msg-actions {
  display: flex;
  gap: 2px;
  align-items: center;
  margin-top: 4px;
  opacity: 0.55;
  transition: opacity 0.2s;
}
.msg-user .msg-actions { justify-content: flex-end; }
.msg:active .msg-actions, .msg-actions:hover { opacity: 1; }
.msg-action {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  font-size: 11.5px;
  padding: 5px 8px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.msg-action:active { background: var(--surface-2); color: var(--text); }

.msg-error {
  color: var(--danger);
  font-size: 13px;
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 28%, transparent);
  border-radius: 12px;
  padding: 10px 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

/* 思考过程 */
.reasoning {
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  border-radius: 12px;
  margin-bottom: 8px;
  overflow: hidden;
}
.reasoning summary {
  cursor: pointer;
  list-style: none;
  padding: 9px 12px;
  font-size: 12.5px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 7px;
  user-select: none;
}
.reasoning summary::-webkit-details-marker { display: none; }
.reasoning summary::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  flex: 0 0 auto;
}
.reasoning[open] summary { border-bottom: 1px solid var(--border); }
.reasoning .reasoning-text {
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-dim);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow-y: auto;
}

.typing-dots { display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px; }
.typing-dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-faint);
  animation: dot 1.2s infinite ease-in-out;
}
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}

.cursor-blink::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -0.14em;
  background: var(--accent);
  animation: blink 1s steps(2, start) infinite;
  border-radius: 1px;
}
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

/* Markdown */
.md p { margin: 0 0 10px; }
.md p:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 18px 0 8px; line-height: 1.4; font-weight: 700; letter-spacing: 0.1px; }
.md h1 { font-size: 20px; }
.md h2 { font-size: 18.5px; }
.md h3 { font-size: 17px; }
.md h4 { font-size: 16px; }
.md h1:first-child, .md h2:first-child, .md h3:first-child { margin-top: 2px; }

/* 生成中的纯文本渲染：保留换行，避免逐字重排 */
.md.stream-plain {
  white-space: pre-wrap;
  word-break: break-word;
}

/* 数学公式（KaTeX） */
.math-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 8px 0;
  -webkit-overflow-scrolling: touch;
}
.katex-display { margin: 0.4em 0; }
.math-inline .katex { font-size: 1.02em; }
.math-fallback { font-size: 0.92em; }

/* 回答版本切换（1/2 ‹ ›） */
.variant-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  width: fit-content;
}
.variant-switch .variant-count {
  font-size: 12px;
  color: var(--text-dim);
  min-width: 34px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.variant-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 17px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 999px;
}
.variant-btn:active { background: var(--surface-2); }
.variant-btn[disabled] { color: var(--text-faint); opacity: 0.4; }
.md ul, .md ol { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 3px 0; }
.md li > p { margin: 0; }
.md blockquote {
  margin: 0 0 10px;
  padding: 2px 12px;
  border-left: 3px solid var(--accent);
  color: var(--text-dim);
}
.md hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
.md strong { font-weight: 700; }
.md em { font-style: italic; }
.md del { color: var(--text-faint); }
.md code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  padding: 1.5px 5px;
  border-radius: 6px;
}
.md .code-block {
  position: relative;
  margin: 10px 0 12px;
  border-radius: 12px;
  border: 1px solid var(--code-border);
  background: var(--code-bg);
  overflow: hidden;
}
.md .code-block .code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px 6px 12px;
  border-bottom: 1px solid var(--code-border);
  font-size: 11.5px;
  color: var(--text-faint);
  font-family: var(--mono);
}
.md .code-block pre {
  margin: 0;
  padding: 12px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.md .code-block code {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre;
}
.copy-code {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
}
.copy-code:active { background: var(--surface-2); color: var(--text); }

.md table { width: 100%; border-collapse: collapse; margin: 8px 0 12px; font-size: 14px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border-strong); padding: 6px 9px; text-align: left; }
.md th { background: var(--surface-2); font-weight: 600; }
.md img { max-width: 100%; border-radius: 10px; }
.md a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* ---------- 输入区 ---------- */
.composer-wrap {
  flex: 0 0 auto;
  padding: 8px 10px calc(8px + var(--safe-bottom));
  background: linear-gradient(to top, var(--bg) 78%, transparent);
  position: relative;
  z-index: 15;
}
.composer {
  max-width: 780px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 6px 6px 6px 8px;
  transition: border-color 0.2s;
}
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }

.composer-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 2px 0;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.composer-tools::-webkit-scrollbar { display: none; }
.spacer { flex: 1 1 auto; min-width: 4px; }
.chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1;
  padding: 7px 10px;
  border-radius: 999px;
  white-space: nowrap;
  flex: 0 0 auto;
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.chip:active { background: var(--accent-soft); color: var(--text); }
.chip .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.chip.skill-chip {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--border));
  color: var(--text);
}

.composer-input-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 4px 0 0;
}
#input {
  flex: 1;
  min-height: 34px;
  max-height: 150px;
  padding: 7px 2px;
  border: 0;
  outline: 0;
  background: transparent;
  resize: none;
  line-height: 1.45;
  font-size: 16px;
  overflow-y: auto;
}
#input::placeholder { color: var(--text-faint); }

.send-btn {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s, background 0.15s, opacity 0.15s;
  margin: 0 2px 1px 0;
}
.send-btn:active { transform: scale(0.93); }
.send-btn[disabled] { opacity: 0.35; }
.send-btn.stop { background: var(--surface-2); color: var(--text); border: 1px solid var(--border-strong); }
.send-btn.stop .stop-square {
  width: 12px; height: 12px; border-radius: 3px; background: currentColor;
}

.composer-hint {
  max-width: 780px;
  margin: 6px auto 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-faint);
  padding: 0 8px;
  line-height: 1.5;
}

/* ---------- 抽屉 ---------- */
.drawer-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s;
  z-index: 40;
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
.drawer-mask.show { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  width: min(86vw, 360px);
  background: var(--bg-elev);
  border-right: 1px solid var(--border);
  z-index: 41;
  transform: translateX(-102%);
  transition: transform 0.26s cubic-bezier(0.32, 0.72, 0, 1);
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  touch-action: pan-y;
}
.drawer.show { transform: translateX(0); }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 8px;
  font-size: 16px;
  font-weight: 700;
}
.drawer-head button {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 13px;
}
.drawer-search {
  margin: 0 12px 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  outline: 0;
  font-size: 14px;
}
.drawer-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding: 2px 8px 8px;
}
.session-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px;
  border-radius: 12px;
  cursor: pointer;
}
.session-item:active { background: var(--surface-2); }
.session-item.active { background: var(--accent-soft); }
.session-item .si-main { flex: 1; min-width: 0; }
.session-item .si-title {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pin-mark {
  font-size: 10px;
  margin-right: 5px;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  vertical-align: 1px;
}
.session-item .si-sub { font-size: 11px; color: var(--text-faint); margin-top: 3px; }
.session-item .si-more {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 16px;
  flex: 0 0 auto;
}
.session-item .si-more:active { background: var(--surface); color: var(--text); }
.drawer-empty { text-align: center; color: var(--text-faint); font-size: 13px; padding: 30px 10px; line-height: 1.7; }

.drawer-foot {
  border-top: 1px solid var(--border);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.drawer-foot button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  text-align: left;
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 14px;
}
.drawer-foot button:active { background: var(--surface-2); color: var(--text); }

/* ---------- 全屏面板（设置 / 导入） ---------- */
.panel {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.34s cubic-bezier(0.32, 0.72, 0, 1);
  visibility: hidden;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.16);
  will-change: transform;
  touch-action: pan-y;
}
.panel.show { transform: translateX(0); visibility: visible; }
.panel.dragging { transition: none !important; }
.panel-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(var(--safe-top) + 6px) 10px 6px;
  border-bottom: 1px solid var(--border);
  min-height: calc(52px + var(--safe-top));
}
.panel-head h2 { flex: 1; margin: 0; text-align: center; font-size: 16px; font-weight: 700; }
.panel-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px calc(24px + var(--safe-bottom));
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}

.field { margin-bottom: 16px; }
.field > label { display: block; font-size: 13px; font-weight: 600; color: var(--text-dim); margin-bottom: 7px; }
.field .hint { font-size: 12px; color: var(--text-faint); line-height: 1.6; margin-top: 6px; }
.field input[type="text"], .field input[type="password"], .field input[type="number"], .field select, .field textarea {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  outline: 0;
  font-size: 15px;
}
.field textarea { min-height: 76px; resize: vertical; line-height: 1.6; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.input-with-btn { display: flex; gap: 8px; }
.input-with-btn input { flex: 1; }
.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
}
.btn:active { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: transparent; color: #fff; }
.btn.primary:active { background: var(--accent-strong); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.btn.block { display: block; width: 100%; }
.btn[disabled] { opacity: 0.45; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { flex: 1; min-width: 120px; }

.section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-faint);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin: 22px 0 10px;
}
.section-title:first-child { margin-top: 4px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card .card-title { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.card .card-desc { font-size: 12.5px; color: var(--text-dim); line-height: 1.65; }

.kv { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; padding: 5px 0; color: var(--text-dim); }
.kv b { color: var(--text); font-weight: 500; }

.log {
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 12px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text-dim);
  max-height: 260px;
  overflow-y: auto;
  margin-top: 12px;
}
.log:empty { display: none; }
.log .ok { color: var(--ok); }
.log .err { color: var(--danger); }

/* ---------- Toast / 安装提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(150px + var(--safe-bottom));
  transform: translateX(-50%) translateY(8px);
  background: rgba(20, 22, 28, 0.94);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 13.5px;
  line-height: 1.4;
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: 82vw;
  text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.install-hint {
  max-width: 780px;
  margin: 0 auto 8px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 11px 13px;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-dim);
  box-shadow: var(--shadow);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.install-hint[hidden] { display: none; }

.install-hint .ih-close {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
}
.install-hint b { color: var(--text); }

/* ---------- 操作表 ---------- */
.action-sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 70;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.action-sheet-mask.show { opacity: 1; pointer-events: auto; }
.action-sheet {
  position: fixed;
  left: 8px;
  right: 8px;
  bottom: calc(8px + var(--safe-bottom));
  z-index: 71;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  max-height: calc(100dvh - 30px - var(--safe-bottom));
  transform: translateY(110%);
  transition: transform 0.26s cubic-bezier(0.32, 0.72, 0, 1);
}
.action-sheet.show { transform: translateY(0); }
.action-sheet button {
  display: block;
  width: 100%;
  appearance: none;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 15px 18px;
  font-size: 15px;
}
.action-sheet button:last-child { border-bottom: 0; }
.action-sheet button.danger { color: var(--danger); }
.action-sheet button.cancel { text-align: center; color: var(--text-dim); font-weight: 600; }
.action-sheet button:active { background: var(--surface-2); }
.action-sheet .as-title { padding: 12px 18px 6px; font-size: 12px; color: var(--text-faint); text-align: center; }

/* 出错兜底提示条 */
.fatal-banner {
  position: fixed;
  left: 8px;
  right: 8px;
  top: calc(var(--safe-top) + 8px);
  z-index: 120;
  background: #2b1c1c;
  color: #ffd7d7;
  border: 1px solid rgba(255, 120, 120, 0.5);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  box-shadow: var(--shadow);
}
.fatal-banner[hidden] { display: none; }
.fatal-banner .fatal-text { word-break: break-word; }
.fatal-banner .fatal-actions { display: flex; gap: 8px; margin-top: 8px; }
.fatal-banner .fatal-actions .btn { padding: 7px 12px; font-size: 12.5px; }

/* ---------- 开关 ---------- */
.switch-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.switch-field > div { flex: 1; min-width: 0; }
.switch-field > div > label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.switch {
  appearance: none;
  border: 0;
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  position: relative;
  flex: 0 0 auto;
  padding: 0;
  transition: background 0.2s, border-color 0.2s;
}
.switch span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
  transition: transform 0.2s;
}
.switch[aria-checked="true"] { background: var(--accent); border-color: transparent; }
.switch[aria-checked="true"] span { transform: translateX(20px); }

/* ---------- 文本输入对话框 ---------- */
.name-dialog-mask {
  position: fixed;
  inset: 0;
  z-index: 95;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.name-dialog-mask[hidden] { display: none; }
.name-dialog {
  width: min(86vw, 360px);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.name-dialog h3 { margin: 0 0 12px; font-size: 16px; font-weight: 700; }
.name-dialog input {
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  outline: 0;
  font-size: 16px;
}
.name-dialog input:focus { border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); }
.name-dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}
.name-dialog-actions .btn { flex: 1; }

/* ---------- 技能列表 ---------- */
.skill-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 11px 12px;
  margin-bottom: 10px;
}
.skill-row .sk-emoji {
  font-size: 19px;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
}
.skill-row .sk-main { flex: 1; min-width: 0; }
.skill-row .sk-name {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.skill-row .sk-desc {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 3px;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.skill-row .sk-actions { display: flex; flex-direction: column; gap: 2px; flex: 0 0 auto; }
.skill-row .sk-actions button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  padding: 5px 8px;
  border-radius: 8px;
}
.skill-row .sk-actions button:active { background: var(--surface-2); color: var(--text); }
.skill-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

#skillsPanel { z-index: 61; }
#skillFormPanel { z-index: 62; }
#skillsPanel .panel-body, #skillFormPanel .panel-body { padding-bottom: calc(40px + var(--safe-bottom)); }

@media (min-width: 720px) {
  .messages { padding-left: 24px; padding-right: 24px; }
  .composer-wrap { padding-left: 24px; padding-right: 24px; }
}

/* 顶栏菜单：CSS 线条，不依赖图标字体或 SVG */
.menu-btn {
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
}
.menu-btn span {
  display: block;
  width: 17px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
}
