﻿/* ============ 设计令牌（飞书式浅色办公风） ============ */
:root {
  --bg: #f4f5f7;
  --bg-soft: #f8f9fa;
  --panel: #ffffff;
  --panel-strong: #ffffff;
  --border: #e5e6eb;
  --border-strong: #d0d3d9;
  --text: #1f2329;
  --text-dim: #646a73;
  --text-faint: #8f959e;
  --accent-1: #3370ff;
  --accent-2: #0098e0;
  --accent-grad: linear-gradient(135deg, #3370ff 0%, #245bdb 100%);
  --danger: #f53f3f;
  --ok: #1fa971;
  --warn: #ff8800;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 24px rgba(31, 35, 41, 0.1);
  --shadow-soft: 0 2px 8px rgba(31, 35, 41, 0.06);
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "Cascadia Code", "JetBrains Mono", Consolas, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ============ 页面背景（静态素雅，办公风） ============ */
.aurora { position: fixed; inset: 0; z-index: -1; background: var(--bg); }

/* ============ 通用控件 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 18px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--panel-strong); color: var(--text); font-size: 14px; font-family: var(--font);
  cursor: pointer; transition: all 0.18s ease; white-space: nowrap; user-select: none;
  box-shadow: 0 1px 3px rgba(31, 35, 41, 0.06);
}
.btn:hover { border-color: var(--border-strong); background: #fff; transform: translateY(-1px); box-shadow: var(--shadow-soft); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent-grad); border: none; color: #fff; font-weight: 600; box-shadow: 0 6px 20px rgba(51, 112, 255, 0.32); }
.btn-primary:hover { background: var(--accent-grad); filter: brightness(1.07); box-shadow: 0 8px 26px rgba(51, 112, 255, 0.42); }
.btn-danger { color: var(--danger); border-color: rgba(224, 51, 92, 0.3); }
.btn-danger:hover { background: rgba(224, 51, 92, 0.07); border-color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-icon { padding: 9px; border-radius: 10px; line-height: 0; }

.input, textarea.input, select.input {
  width: 100%; padding: 11px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: #fff;
  color: var(--text); font-size: 14px; font-family: var(--font);
  outline: none; transition: border 0.18s, box-shadow 0.18s;
}
.input:focus { border-color: var(--accent-1); box-shadow: 0 0 0 3px rgba(51, 112, 255, 0.14); }
.input::placeholder { color: var(--text-faint); }

.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 99px; font-size: 12px; font-weight: 600; letter-spacing: 0.3px; }
.badge-admin { background: rgba(51, 112, 255, 0.1); color: #3370ff; border: 1px solid rgba(51, 112, 255, 0.35); }
.badge-editor { background: rgba(0, 152, 224, 0.09); color: #0086c8; border: 1px solid rgba(0, 152, 224, 0.32); }
.badge-user { background: rgba(31, 35, 41, 0.05); color: var(--text-dim); border: 1px solid var(--border); }
.badge-ok { background: rgba(15, 174, 132, 0.09); color: var(--ok); border: 1px solid rgba(15, 174, 132, 0.32); }
.badge-off { background: rgba(224, 51, 92, 0.07); color: var(--danger); border: 1px solid rgba(224, 51, 92, 0.28); }

/* ============ Toast ============ */
.toast-host { position: fixed; top: calc(22px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.toast {
  padding: 11px 22px; border-radius: 12px; font-size: 14px; color: var(--text);
  background: #fff; border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  opacity: 0; transform: translateY(-12px); transition: all 0.3s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { border-color: rgba(224, 51, 92, 0.45); color: #c02550; }
.toast-success { border-color: rgba(15, 174, 132, 0.45); color: #0a8c6a; }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; z-index: 900; display: flex; align-items: center; justify-content: center;
  background: rgba(40, 52, 84, 0.32); backdrop-filter: blur(6px);
  padding: calc(12px + env(safe-area-inset-top)) calc(12px + env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) calc(12px + env(safe-area-inset-left));
  opacity: 0; pointer-events: none; transition: opacity 0.22s;
}
.modal-mask.open { opacity: 1; pointer-events: auto; }
.modal {
  width: min(480px, 92vw); max-height: 86vh; overflow: auto;
  background: #fff;
  border: 1px solid var(--border); border-radius: 20px; padding: 26px;
  box-shadow: var(--shadow); transform: scale(0.94) translateY(12px); transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.15);
}
.modal-mask.open .modal { transform: scale(1) translateY(0); }
.modal h3 { font-size: 18px; margin-bottom: 18px; }
.modal .field { margin-bottom: 14px; }
.modal .field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.modal.modal-wide { width: min(760px, 94vw); }

/* ============ 登录页 ============ */
.auth-wrap { height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card {
  width: min(420px, 94vw); padding: 42px 38px;
  background: #fff; border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow);
  animation: rise 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}
@keyframes rise { from { opacity: 0; transform: translateY(26px); } to { opacity: 1; transform: none; } }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 30px; }
.auth-brand .orb { width: 64px; height: 64px; }
.auth-brand h1 { font-size: 24px; font-weight: 700; letter-spacing: 1px; }
.auth-brand p { color: var(--text-dim); font-size: 13.5px; }
.auth-card .field { margin-bottom: 16px; }
.auth-card .field label { display: block; font-size: 13px; color: var(--text-dim); margin-bottom: 7px; }
.auth-switch { text-align: center; margin-top: 18px; font-size: 13.5px; color: var(--text-dim); }
.auth-switch a { color: var(--accent-1); cursor: pointer; text-decoration: none; font-weight: 600; }
.auth-tip { margin-top: 22px; padding: 12px 14px; border-radius: 12px; background: rgba(51, 112, 255, 0.06); border: 1px solid rgba(51, 112, 255, 0.18); font-size: 12.5px; color: var(--text-dim); line-height: 1.7; }
.auth-tip code { color: #3370ff; font-family: var(--mono); }
.apk-link { display: flex; align-items: center; justify-content: center; gap: 7px; margin-top: 14px; font-size: 13px; color: var(--text-dim); text-decoration: none; padding: 9px; border-radius: 10px; border: 1px dashed var(--border-strong); transition: all 0.18s; }
.apk-link:hover { color: var(--accent-1); border-color: var(--accent-1); background: rgba(51, 112, 255, 0.05); }

/* ============ 品牌标识（静态圆角块，办公风） ============ */
.orb {
  position: relative; width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  background: var(--accent-grad);
  box-shadow: 0 2px 8px rgba(51, 112, 255, 0.3);
}
.orb::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  background:
    radial-gradient(circle at 34% 32%, rgba(255, 255, 255, 0.92) 0%, rgba(255, 255, 255, 0.92) 22%, transparent 23%),
    radial-gradient(circle at 66% 62%, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0.55) 14%, transparent 15%);
}
.orb.thinking { animation: orbPulse 1.4s ease-in-out infinite; }
.orb.listening { animation: pulse 1.5s ease-out infinite; }
@keyframes orbPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 166, 240, 0.45); }
  100% { box-shadow: 0 0 0 22px rgba(0, 166, 240, 0); }
}

/* ============ 聊天布局 ============ */
.app { display: flex; height: 100vh; height: 100dvh; }

.sidebar {
  width: 282px; flex-shrink: 0; display: flex; flex-direction: column;
  background: var(--bg-soft); border-right: 1px solid var(--border);
}
.side-head { display: flex; align-items: center; gap: 12px; padding: 20px 18px 14px; }
.side-head .name { font-size: 18px; font-weight: 700; letter-spacing: 2px; }
.side-head .tagline { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; letter-spacing: 0.5px; }
.side-new { margin: 6px 14px 10px; }
.side-new .btn { width: 100%; }
.side-search { margin: 0 14px 10px; }
.side-search .input { padding: 8px 12px; font-size: 13px; background: #fff; }
.session-list { flex: 1; overflow-y: auto; padding: 0 10px; }
.session-item {
  display: flex; align-items: center; gap: 6px; padding: 11px 12px; margin-bottom: 4px;
  border-radius: 11px; cursor: pointer; color: var(--text-dim); font-size: 13.5px;
  border: 1px solid transparent; transition: all 0.15s;
}
.session-item:hover { background: rgba(31, 35, 41, 0.05); color: var(--text); }
.session-item.active { background: rgba(51, 112, 255, 0.08); border-color: rgba(51, 112, 255, 0.3); color: var(--text); }
.session-item .title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session-item .op { opacity: 0; border: none; background: none; color: var(--text-faint); cursor: pointer; font-size: 13px; padding: 2px 5px; border-radius: 6px; transition: all 0.15s; }
.session-item:hover .op { opacity: 1; }
.session-item .op:hover { color: var(--accent-1); background: rgba(51, 112, 255, 0.1); }
.session-item .op.del:hover { color: var(--danger); background: rgba(224, 51, 92, 0.08); }

.side-foot { padding: 14px; border-top: 1px solid var(--border); }
.user-card { display: flex; align-items: center; gap: 11px; margin-bottom: 12px; }
.avatar {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-grad); color: #fff; font-weight: 700; font-size: 16px;
}
.user-card .meta { flex: 1; min-width: 0; }
.user-card .uname { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot .links { display: flex; gap: 8px; flex-wrap: wrap; }
.side-foot .links .btn { flex: 1; font-size: 13px; }
.side-foot .apk-link { margin-top: 10px; }

/* ============ 主区 ============ */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-head {
  display: flex; align-items: center; gap: 14px; padding: 14px 26px;
  border-bottom: 1px solid var(--border); background: #fff;
}
.chat-head .who .title { font-size: 16px; font-weight: 700; }
.chat-head .who .status { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; margin-top: 1px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 6px var(--ok); }
.status-dot.busy { background: var(--warn); box-shadow: 0 0 6px var(--warn); }
.status-dot.listen { background: var(--accent-2); box-shadow: 0 0 6px var(--accent-2); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.35; } }
.chat-head .spacer { flex: 1; }

.toggle {
  display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px;
  border-radius: 99px; border: 1px solid var(--border); cursor: pointer;
  font-size: 12.5px; color: var(--text-dim); background: #fff; user-select: none; transition: all 0.18s;
}
.toggle:hover { border-color: var(--border-strong); color: var(--text); background: #fff; }
.toggle.on { color: #0086c8; border-color: rgba(0, 152, 224, 0.45); background: rgba(0, 166, 240, 0.07); }
.toggle .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); transition: all 0.18s; }
.toggle.on .dot { background: var(--accent-2); box-shadow: 0 0 6px var(--accent-2); }

/* ============ 消息区 ============ */
.messages { flex: 1; overflow-y: auto; padding: 30px 0 18px; scroll-behavior: smooth; }
.messages-inner { max-width: 820px; margin: 0 auto; padding: 0 26px; display: flex; flex-direction: column; gap: 26px; }

.msg { display: flex; gap: 14px; animation: msgIn 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.1); }
@keyframes msgIn { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.msg .bubble-wrap { max-width: 78%; min-width: 0; position: relative; }
.msg .bubble {
  padding: 13px 17px; border-radius: 18px; font-size: 14.5px; line-height: 1.75;
  word-wrap: break-word; overflow-wrap: break-word;
}
.msg.user { flex-direction: row-reverse; }
.msg.user .bubble { background: linear-gradient(135deg, #3370ff, #245bdb); border-bottom-right-radius: 6px; color: #fff; box-shadow: 0 8px 22px rgba(51, 112, 255, 0.28); }
.msg.assistant .bubble { background: #fff; border: 1px solid var(--border); border-bottom-left-radius: 6px; box-shadow: var(--shadow-soft); }
.msg .bubble p + p { margin-top: 8px; }

.msg-tools { display: flex; gap: 6px; margin-top: 7px; opacity: 0; transition: opacity 0.18s; }
.msg:hover .msg-tools { opacity: 1; }
.msg-tools button {
  border: 1px solid var(--border); background: #fff; color: var(--text-faint);
  font-size: 11.5px; padding: 3px 10px; border-radius: 7px; cursor: pointer; transition: all 0.15s; font-family: var(--font);
}
.msg-tools button:hover { color: var(--accent-1); border-color: var(--accent-1); }

.md-code { background: #20263a; color: #e3e9f7; border-radius: 10px; padding: 13px 15px; margin: 9px 0; overflow-x: auto; font-family: var(--mono); font-size: 13px; line-height: 1.6; }
.md-inline { background: rgba(51, 112, 255, 0.09); border-radius: 5px; padding: 1.5px 6px; font-family: var(--mono); font-size: 13px; color: #3370ff; }
.md-h { margin: 10px 0 6px; font-size: 15.5px; }
.md-list { margin: 6px 0 6px 22px; display: flex; flex-direction: column; gap: 4px; }
.md-quote { border-left: 3px solid var(--accent-1); padding: 6px 12px; margin: 8px 0; color: var(--text-dim); background: rgba(51, 112, 255, 0.05); border-radius: 0 8px 8px 0; }
.md-hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }
.md-table { border-collapse: collapse; margin: 10px 0; width: 100%; font-size: 13.5px; }
.md-table th, .md-table td { border: 1px solid var(--border); padding: 7px 11px; text-align: left; }
.md-table th { background: rgba(31, 35, 41, 0.04); }
.msg.assistant .bubble a { color: var(--accent-2); }

.sources { margin-top: 9px; font-size: 12.5px; }
.sources summary { cursor: pointer; color: var(--text-faint); user-select: none; }
.sources summary:hover { color: var(--accent-2); }
.source-item { margin-top: 7px; padding: 9px 12px; border-radius: 9px; background: rgba(0, 166, 240, 0.05); border: 1px solid rgba(0, 152, 224, 0.18); color: var(--text-dim); line-height: 1.6; }
.source-item b { color: #0086c8; font-weight: 600; }

/* ============ 引用溯源：胶囊 + 原文定位面板 ============ */
.citations { margin-top: 9px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.citations-label { font-size: 12.5px; color: var(--text-faint); }
.citation-pill {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  min-height: 32px; padding: 4px 12px; border-radius: 999px; cursor: pointer;
  background: rgba(0, 166, 240, 0.07); border: 1px solid rgba(0, 152, 224, 0.25);
  color: #0086c8; font-size: 12.5px; transition: background 0.15s, transform 0.1s;
}
.citation-pill:hover { background: rgba(0, 166, 240, 0.14); }
.citation-pill:active { transform: scale(0.97); background: rgba(0, 166, 240, 0.2); }
.citation-pill .pill-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 46vw; }
.citation-pill .pill-score { color: var(--text-faint); font-size: 12px; flex: none; }

.cite-mask {
  position: fixed; inset: 0; z-index: 940; background: rgba(40, 52, 84, 0.32);
  opacity: 0; pointer-events: none; transition: opacity 0.22s;
}
.cite-mask.open { opacity: 1; pointer-events: auto; }
.cite-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 950;
  width: min(460px, 100vw); display: flex; flex-direction: column;
  background: #fff; border-left: 1px solid var(--border); box-shadow: var(--shadow);
  transform: translateX(102%); transition: transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
  padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
  padding-right: env(safe-area-inset-right);
}
.cite-panel.open { transform: translateX(0); }
.cite-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex: none; }
.cite-title-wrap { flex: 1; min-width: 0; }
.cite-doc-title { font-size: 15px; font-weight: 700; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cite-sub { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.cite-nav { display: flex; align-items: center; gap: 8px; flex: none; }
.cite-nav-btn { width: 44px; height: 44px; min-width: 44px; display: inline-flex; align-items: center; justify-content: center; }
.cite-nav-btn:disabled { opacity: 0.35; cursor: default; }
.cite-counter { font-size: 12.5px; color: var(--text-dim); min-width: 34px; text-align: center; }
.cite-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 16px; }
.cite-chunk { padding: 10px 12px; border-radius: 10px; font-size: 15px; line-height: 1.8; color: var(--text-dim); white-space: pre-wrap; word-break: break-word; }
.cite-chunk + .cite-chunk { margin-top: 6px; }
.cite-chunk.hit { background: rgba(255, 196, 0, 0.14); border: 1px solid rgba(255, 170, 0, 0.35); color: var(--text); }
.cite-chunk.current { background: rgba(255, 196, 0, 0.28); border-color: rgba(255, 150, 0, 0.6); }
.cite-loading, .cite-note { padding: 18px 12px; text-align: center; font-size: 13px; color: var(--text-faint); }
.cite-note { font-size: 12px; }
.cite-error { padding: 18px 12px; display: flex; flex-direction: column; align-items: center; gap: 10px; font-size: 13px; color: #c0392b; }

@media (max-width: 480px) {
  /* 375px 窄屏：面板全屏展示 */
  .cite-panel { width: 100vw; border-left: none; padding-left: env(safe-area-inset-left); }
  .citation-pill { min-height: 44px; }
}

.typing { display: inline-flex; gap: 5px; padding: 6px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent-2); animation: bounce 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: 0.15s; }
.typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.45; } 30% { transform: translateY(-7px); opacity: 1; } }

/* ============ 欢迎页 ============ */
.welcome { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 60px 26px; gap: 18px; animation: rise 0.5s ease; }
.welcome .orb { width: 84px; height: 84px; }
.welcome h2 { font-size: 30px; font-weight: 700; color: var(--text); }
.welcome p { color: var(--text-dim); font-size: 14.5px; max-width: 480px; line-height: 1.8; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 8px; }
.chip { padding: 9px 17px; border-radius: 99px; border: 1px solid var(--border); background: #fff; color: var(--text-dim); font-size: 13.5px; cursor: pointer; transition: all 0.18s; }
.chip:hover { border-color: var(--accent-1); color: var(--accent-1); background: #fff; transform: translateY(-2px); box-shadow: var(--shadow-soft); }

/* ============ 输入区 ============ */
.composer-zone { padding: 14px 26px 22px; }
.voice-hint { max-width: 820px; margin: 0 auto 10px; display: none; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 13px; background: rgba(0, 166, 240, 0.06); border: 1px solid rgba(0, 152, 224, 0.3); font-size: 13.5px; color: #0086c8; }
.voice-hint.show { display: flex; animation: rise 0.25s ease; }
.voice-bars { display: flex; gap: 3px; align-items: center; height: 18px; }
.voice-bars i { width: 3px; border-radius: 2px; background: var(--accent-2); animation: bar 0.9s ease-in-out infinite; }
.voice-bars i:nth-child(1) { height: 8px; } .voice-bars i:nth-child(2) { height: 15px; animation-delay: 0.12s; }
.voice-bars i:nth-child(3) { height: 11px; animation-delay: 0.24s; } .voice-bars i:nth-child(4) { height: 16px; animation-delay: 0.36s; }
.voice-bars i:nth-child(5) { height: 9px; animation-delay: 0.48s; }
@keyframes bar { 0%, 100% { transform: scaleY(0.5); } 50% { transform: scaleY(1.3); } }

.composer {
  max-width: 820px; margin: 0 auto; display: flex; align-items: flex-end; gap: 10px;
  padding: 11px 12px 11px 18px; border-radius: 22px;
  background: #fff; border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  transition: border 0.2s, box-shadow 0.2s;
}
.composer:focus-within { border-color: rgba(51, 112, 255, 0.5); box-shadow: 0 12px 38px rgba(51, 112, 255, 0.16); }
.composer textarea {
  flex: 1; resize: none; border: none; outline: none; background: none;
  color: var(--text); font-size: 14.5px; font-family: var(--font); line-height: 1.6;
  max-height: 150px; padding: 8px 0;
}
.composer textarea::placeholder { color: var(--text-faint); }

.image-btn, .ppt-btn, .mic-btn, .send-btn {
  width: 42px; height: 42px; flex-shrink: 0; border-radius: 13px; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: all 0.18s; position: relative;
}
.image-btn { background: rgba(31, 35, 41, 0.04); border: 1px solid var(--border); color: var(--text-dim); }
.image-btn:hover { color: var(--accent-1); border-color: rgba(51, 112, 255, 0.35); background: #fff; }
.image-btn.loading { pointer-events: none; opacity: 0.55; }
.ppt-btn {
  background: rgba(51, 112, 255, 0.08); border: 1px solid rgba(51, 112, 255, 0.22);
  color: var(--accent-1); font-size: 11px; font-weight: 800;
}
.ppt-btn:hover { background: #fff; border-color: rgba(51, 112, 255, 0.45); }
.ppt-btn.loading { pointer-events: none; opacity: 0.55; }
.mic-btn { background: rgba(31, 35, 41, 0.04); border: 1px solid var(--border); color: var(--text-dim); }
.mic-btn:hover { color: var(--text); border-color: var(--border-strong); background: #fff; }
.mic-btn.live { background: rgba(0, 166, 240, 0.1); border-color: var(--accent-2); color: var(--accent-2); animation: micPulse 1.4s ease-out infinite; }
@keyframes micPulse { 0% { box-shadow: 0 0 0 0 rgba(0, 166, 240, 0.35); } 100% { box-shadow: 0 0 0 14px rgba(0, 166, 240, 0); } }
.mic-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.send-btn { background: var(--accent-grad); color: #fff; box-shadow: 0 6px 16px rgba(51, 112, 255, 0.35); }
.send-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.send-btn:disabled { opacity: 0.4; filter: none; transform: none; cursor: not-allowed; }
.image-preview-strip {
  max-width: 820px; margin: 9px auto 0; display: none; flex-wrap: wrap; gap: 8px;
  align-items: center; overflow: hidden;
}
.image-preview-strip.show { display: flex; }
.image-chip {
  display: inline-flex; align-items: center; gap: 8px; width: 210px; max-width: 100%;
  padding: 6px 8px; border-radius: 10px; background: #fff;
  border: 1px solid var(--border); box-shadow: 0 2px 8px rgba(30,45,90,0.06);
  overflow: hidden;
}
.image-preview-strip .image-chip > img {
  display: block; width: 56px !important; height: 56px !important;
  min-width: 56px; max-width: 56px; min-height: 56px; max-height: 56px;
  border-radius: 8px; object-fit: cover; background: rgba(28,42,80,0.06);
}
.image-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; color: var(--text-dim); }
.image-chip button {
  width: 22px; height: 22px; border: none; border-radius: 7px; cursor: pointer;
  color: var(--text-faint); background: rgba(28,42,80,0.05); flex-shrink: 0;
}
.image-chip button:hover { color: var(--danger); background: rgba(224, 51, 92, 0.08); }
.msg-images { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.msg-images img {
  width: min(180px, 42vw); max-height: 180px; object-fit: cover;
  border-radius: 12px; border: 1px solid var(--border);
}
.msg.assistant .msg-images img { border-color: var(--border); }
.presentation-result {
  display: flex; align-items: center; gap: 12px; margin-top: 14px; padding: 12px;
  border-radius: 14px; border: 1px solid rgba(51, 112, 255, 0.2);
  background: linear-gradient(135deg, rgba(51, 112, 255, 0.08), rgba(0, 166, 240, 0.05));
}
.presentation-result-icon {
  display: flex; align-items: center; justify-content: center; width: 48px; height: 48px;
  flex-shrink: 0; border-radius: 12px; color: #fff; font-size: 12px; font-weight: 800;
  background: var(--accent-grad); box-shadow: 0 6px 16px rgba(51, 112, 255, 0.25);
}
.presentation-result-copy { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 3px; }
.presentation-result-copy b { font-size: 14px; }
.presentation-result-copy span {
  color: var(--text-dim); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.presentation-download {
  padding: 9px 13px; border: none; border-radius: 10px; cursor: pointer;
  color: #fff; background: var(--accent-grad); font-weight: 700; white-space: nowrap;
}
.presentation-download:hover { filter: brightness(1.08); }
.generated-media-card {
  margin-top: 12px; overflow: hidden; border-radius: 14px;
  border: 1px solid var(--border); background: #fff;
}
.generated-media-card img,
.generated-media-card video {
  display: block; width: 100%; max-width: 680px; max-height: 520px;
  object-fit: contain; background: #0c1020;
}
.generated-media-actions {
  display: flex; justify-content: flex-end; padding: 10px 12px;
}
.generated-media-actions a {
  padding: 8px 13px; border-radius: 9px; color: #fff;
  background: var(--accent-grad); font-size: 13px; font-weight: 700;
  text-decoration: none;
}
.foot-note { text-align: center; font-size: 11.5px; color: var(--text-faint); margin-top: 10px; }

/* ============ 通知铃铛与面板 ============ */
.bell-wrap { position: relative; }
.bell-badge {
  position: absolute; top: -5px; right: -5px; min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: 99px; background: var(--danger); color: #fff; font-size: 10.5px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 6px rgba(224, 51, 92, 0.4);
}
.notif-panel {
  position: absolute; right: 0; top: calc(100% + 10px); width: 372px; max-height: 480px; z-index: 200;
  display: none; flex-direction: column; overflow: hidden;
  background: #fff; border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow);
}
.notif-panel.open { display: flex; animation: rise 0.22s ease; }
.notif-head { display: flex; align-items: center; justify-content: space-between; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.notif-list { overflow-y: auto; }
.notif-empty { padding: 36px 0; text-align: center; color: var(--text-faint); font-size: 13px; }
.notif-item { padding: 13px 16px; border-bottom: 1px solid rgba(31, 35, 41, 0.05); position: relative; }
.notif-item:last-child { border-bottom: none; }
.notif-item.unread { background: rgba(51, 112, 255, 0.04); }
.notif-item.unread::before { content: ""; position: absolute; left: 6px; top: 19px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-1); }
.notif-item .n-title { font-size: 13.5px; font-weight: 600; margin-bottom: 3px; display: flex; align-items: center; gap: 6px; }
.notif-item .n-body { font-size: 12.5px; color: var(--text-dim); line-height: 1.6; white-space: pre-wrap; word-break: break-word; max-height: 88px; overflow: hidden; }
.notif-item .n-time { font-size: 11px; color: var(--text-faint); margin-top: 5px; }
.notif-item .n-actions { display: flex; gap: 8px; margin-top: 8px; }
.notif-item.clickable { cursor: pointer; transition: background 0.15s; }
.notif-item.clickable:hover { background: rgba(51, 112, 255, 0.08); }
.n-icon { font-size: 14px; }

/* ============ 流式错误 / 停止生成 ============ */
.send-btn.stop-mode { background: #e5484d; box-shadow: 0 6px 16px rgba(229, 72, 77, 0.35); }
.send-btn.stop-mode:hover { filter: brightness(1.08); }
.stream-error { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.stream-error-icon {
  width: 20px; height: 20px; flex-shrink: 0; border-radius: 50%; background: #e5484d; color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.stream-error-text { color: #c62f34; font-size: 13.5px; }
.stream-retry-btn {
  border: 1px solid rgba(229, 72, 77, 0.45); background: rgba(229, 72, 77, 0.08); color: #c62f34;
  border-radius: 9px; padding: 4px 12px; font-size: 12.5px; cursor: pointer; transition: all 0.15s;
}
.stream-retry-btn:hover { background: rgba(229, 72, 77, 0.16); }
.stream-stopped { margin-top: 6px; font-size: 12px; color: var(--text-faint); }

/* ============ 滚动条 ============ */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(31, 35, 41, 0.16); border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: rgba(31, 35, 41, 0.3); background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

.menu-btn { display: none; }
.side-mask { display: none; }

/* ============ 移动端适配 ============ */
/* 禁用双击缩放误触发，统一触屏行为 */
button, a, .btn, .chip, .toggle, .nav-item, .session-item, .conv-item, .notif-item, input, textarea, select { touch-action: manipulation; }
body { -webkit-tap-highlight-color: transparent; }

/* 弹窗 / 抽屉打开时锁定背景滚动（防穿透） */
body.no-scroll { overflow: hidden !important; }

/* 触屏按压态（hover 在触屏上不可用） */
.btn:active { transform: scale(0.97); background: var(--bg-soft); box-shadow: none; }
.btn-primary:active { background: var(--accent-grad); filter: brightness(0.9); }
.btn-danger:active { background: rgba(224, 51, 92, 0.12); }
.chip:active { border-color: var(--accent-1); color: var(--accent-1); transform: scale(0.97); }
.toggle:active { background: var(--bg-soft); border-color: var(--border-strong); }
.session-item:active { background: rgba(31, 35, 41, 0.08); }
.nav-item:active { background: rgba(31, 35, 41, 0.08); }
.notif-item.clickable:active { background: rgba(51, 112, 255, 0.12); }
.apk-link:active { color: var(--accent-1); border-color: var(--accent-1); background: rgba(51, 112, 255, 0.08); }
.image-btn:active, .ppt-btn:active, .mic-btn:active { transform: scale(0.93); background: rgba(31, 35, 41, 0.08); }
.send-btn:active { transform: scale(0.93); filter: brightness(0.9); }
.msg-tools button:active, .stream-retry-btn:active { color: var(--accent-1); border-color: var(--accent-1); background: rgba(51, 112, 255, 0.08); }

/* 长文本防溢出兜底 */
.msg .bubble, .notif-item .n-body, .modal { overflow-wrap: break-word; word-break: break-word; }

@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; transform: translateX(-100%); transition: transform 0.25s;
    padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); padding-left: env(safe-area-inset-left);
  }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(15, 22, 40, 0.3); }
  .menu-btn { display: inline-flex; }
  .side-mask { position: fixed; inset: 0; background: rgba(15, 22, 40, 0.35); z-index: 49; }
  .sidebar.open + .side-mask { display: block; }
  .chat-head {
    flex-wrap: wrap; gap: 8px 10px;
    padding: calc(10px + env(safe-area-inset-top)) calc(14px + env(safe-area-inset-right)) 10px calc(14px + env(safe-area-inset-left));
  }
  .msg .bubble-wrap { max-width: 92%; }
  .messages-inner { padding: 0 14px; }
  .composer-zone {
    padding: 10px calc(14px + env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) calc(14px + env(safe-area-inset-left));
  }
}

@media (max-width: 768px) {
  /* 输入框字号 ≥16px，防 iOS 聚焦自动放大 */
  .input, textarea.input, select.input, .composer textarea { font-size: 16px; }

  /* 触控目标 ≥44px、间距 ≥8px */
  .btn { min-height: 44px; }
  .btn-sm { min-height: 40px; padding: 8px 14px; }
  .btn-icon { min-width: 44px; min-height: 44px; }
  .toggle { min-height: 36px; }
  .session-item { min-height: 44px; }
  .session-item .op { opacity: 1; padding: 8px 9px; }
  .chip { padding: 11px 18px; }
  .composer { gap: 8px; }
  .image-btn, .ppt-btn, .mic-btn, .send-btn { width: 44px; height: 44px; }
  .msg-tools { opacity: 1; gap: 8px; }
  .msg-tools button { padding: 7px 12px; min-height: 34px; }

  /* 通知面板占满屏宽，避免 375px 下溢出 */
  .notif-panel {
    position: fixed; left: 12px; right: 12px; top: calc(64px + env(safe-area-inset-top));
    width: auto; max-height: min(480px, 70vh);
  }

  /* 消息里的 Markdown 表格：容器内横向滚动，不撑破气泡 */
  .md-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }

  /* 弹窗贴合小屏 */
  .modal { padding: 20px 18px; border-radius: 16px; }
  .modal.modal-wide { width: min(760px, 100%); }

  .welcome { padding: 40px 18px; }
  .welcome h2 { font-size: 24px; }
  .auth-card { padding: 32px 22px; }
}
