/* ===== 主题色 ===== */
:root {
  --bg: #faf9f5;
  --sidebar: #f3f1ea;
  --surface: #ffffff;
  --surface-2: #f5f3ec;
  --hover: rgba(31, 30, 29, 0.06);
  --active: rgba(31, 30, 29, 0.09);
  --text: #2b2a27;
  --text-2: #6b6a64;
  --text-3: #9a988f;
  --border: #e6e3da;
  --border-strong: #d6d2c6;
  --accent: #c96442;
  --accent-hover: #b4583a;
  --accent-soft: rgba(201, 100, 66, 0.1);
  --user-bubble: #efece3;
  --code-inline: rgba(31, 30, 29, 0.06);
  --code-block: #f7f5ef;
  --ok: #2f7d4f;
  --mid: #b7791f;
  --bad: #c0392b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.14);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  --serif: Georgia, "Songti SC", "Noto Serif SC", "Source Han Serif SC", "STSong", "SimSun", serif;
  --mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #262624;
    --sidebar: #1f1e1d;
    --surface: #30302e;
    --surface-2: #2a2a28;
    --hover: rgba(255, 255, 255, 0.06);
    --active: rgba(255, 255, 255, 0.1);
    --text: #ece9e1;
    --text-2: #b4b1a8;
    --text-3: #85837c;
    --border: #3b3a36;
    --border-strong: #4a4943;
    --accent: #d97757;
    --accent-hover: #e58a6c;
    --accent-soft: rgba(217, 119, 87, 0.14);
    --user-bubble: #3a3936;
    --code-inline: rgba(255, 255, 255, 0.08);
    --code-block: #1f1e1d;
    --ok: #5cb67f;
    --mid: #e0a23c;
    --bad: #e5675a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #262624;
  --sidebar: #1f1e1d;
  --surface: #30302e;
  --surface-2: #2a2a28;
  --hover: rgba(255, 255, 255, 0.06);
  --active: rgba(255, 255, 255, 0.1);
  --text: #ece9e1;
  --text-2: #b4b1a8;
  --text-3: #85837c;
  --border: #3b3a36;
  --border-strong: #4a4943;
  --accent: #d97757;
  --accent-hover: #e58a6c;
  --accent-soft: rgba(217, 119, 87, 0.14);
  --user-bubble: #3a3936;
  --code-inline: rgba(255, 255, 255, 0.08);
  --code-block: #1f1e1d;
  --ok: #5cb67f;
  --mid: #e0a23c;
  --bad: #e5675a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

/* ===== 基础 ===== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.hidden { display: none !important; }
svg { flex-shrink: 0; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text-2);
}
.icon-btn:hover { background: var(--hover); color: var(--text); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.input {
  width: 100%; height: 44px; padding: 0 14px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ===== 登录页 ===== */
.login-view {
  position: relative;
  height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center;
  padding: max(8vh, 32px) 16px 48px;
}
/* 语言切换：桌面在右上角，手机在品牌名上方居中 */
.lang-switch { position: absolute; top: 16px; right: 16px; display: inline-flex; flex-shrink: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.lang-switch button { border: 0; background: transparent; padding: 6px 12px; font-size: 13px; color: var(--text-2); }
.lang-switch button.on { background: var(--active); color: var(--text); font-weight: 500; }
@media (max-width: 640px) { .lang-switch { position: static; margin: -12px 0 24px; } }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.login-brand .logo { width: 40px; height: 40px; }
.login-brand h1 { margin: 0; font: 400 34px/1.2 var(--serif); letter-spacing: .5px; }
.login-sub { color: var(--text-2); margin: 0 0 28px; text-align: center; }
.login-card {
  width: min(400px, 100%); background: var(--surface);
  border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow);
}
.login-card .btn { width: 100%; height: 44px; margin-top: 6px; }
.login-error {
  color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent);
  border-radius: 8px; padding: 8px 12px; font-size: 14px; margin-bottom: 14px;
}
.login-notice { color: var(--text-2); font-size: 13px; text-align: center; margin: 18px 0 0; white-space: pre-line; max-width: 400px; }
.plans-title { font: 400 22px var(--serif); margin: 48px 0 16px; text-align: center; }
.plans-grid {
  width: min(980px, 100%);
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px;
}
.plan-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 22px;
  display: flex; flex-direction: column;
}
.plan-card h3 { margin: 0; font: 600 20px/1.3 var(--serif); color: var(--accent); }
.plan-card .plan-days { color: var(--text-2); font-size: 13px; margin: 4px 0 14px; }
.plan-prices { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 12px 0 4px; }
.plan-price { display: flex; flex-direction: column; align-items: center; padding: 8px 4px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.plan-price span { font-size: 12px; color: var(--text-2); }
.plan-price b { font-size: 16px; color: var(--text); font-variant-numeric: tabular-nums; }
.plan-price small { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.plan-card ul { margin: 0 0 14px; padding-left: 18px; color: var(--text); font-size: 14px; }
.plan-card li { margin: 4px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: auto; }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }

/* ===== 应用布局 ===== */
.app { display: grid; grid-template-columns: 272px minmax(0, 1fr); height: 100dvh; }
.app.sb-collapsed { grid-template-columns: 0 minmax(0, 1fr); }
.app.sb-collapsed .sidebar { visibility: hidden; }

.sidebar {
  background: var(--sidebar); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; min-width: 0; overflow: hidden;
}
.sb-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 6px 14px; }
.brand { display: flex; align-items: center; gap: 8px; font: 500 18px var(--serif); min-width: 0; }
.brand .logo { width: 24px; height: 24px; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.new-chat {
  display: flex; align-items: center; gap: 10px; margin: 6px 10px 10px; padding: 8px 10px;
  border: 0; border-radius: 10px; background: transparent; color: var(--text); font-weight: 500; text-align: left;
}
.new-chat:hover { background: var(--hover); }
.new-chat .plus {
  width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
}
.conv-list { flex: 1; overflow-y: auto; padding: 0 8px 12px; }
.conv-group { font-size: 12px; color: var(--text-3); padding: 12px 8px 4px; }
.conv-item {
  position: relative; display: flex; align-items: center; height: 36px; padding: 0 8px; border-radius: 8px;
  color: var(--text); font-size: 14px; cursor: pointer;
}
.conv-item:hover { background: var(--hover); }
.conv-item.active { background: var(--active); }
.conv-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-actions { display: none; gap: 2px; }
.conv-item:hover .conv-actions, .conv-item.active .conv-actions { display: flex; }
.conv-actions .icon-btn { width: 26px; height: 26px; }
.conv-rename { flex: 1; height: 28px; border: 1px solid var(--accent); border-radius: 6px; padding: 0 6px; background: var(--surface); outline: none; }
.conv-empty { color: var(--text-3); font-size: 13px; padding: 16px 10px; }
.expire-tip { margin: 0 10px 8px; padding: 8px 10px; border-radius: 8px; font-size: 12.5px; background: var(--accent-soft); color: var(--accent); }
.sb-bottom { border-top: 1px solid var(--border); padding: 8px; }
.user-card {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; border-radius: 10px;
  background: transparent; text-align: left;
}
.user-card:hover { background: var(--hover); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--text); color: var(--bg);
  display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 14px; flex-shrink: 0;
}
.user-meta { min-width: 0; flex: 1; }
.user-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-plan { font-size: 12px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main { display: flex; flex-direction: column; min-width: 0; height: 100dvh; position: relative; }
.topbar { display: flex; align-items: center; gap: 6px; height: 52px; padding: 0 12px; flex-shrink: 0; }
.topbar .title { flex: 1; min-width: 0; font-size: 14.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 4px; }
.only-collapsed, .only-mobile { display: none; }
.app.sb-collapsed .only-collapsed { display: inline-flex; }
.quota-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: 13px;
}
.quota-chip:hover { color: var(--text); border-color: var(--border-strong); }
.ring { width: 16px; height: 16px; }
.ring circle { fill: none; stroke-width: 3; }
.ring .track { stroke: var(--border); }
.ring .val { stroke: var(--ok); stroke-linecap: round; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset .4s; }
.ring.mid .val { stroke: var(--mid); }
.ring.bad .val { stroke: var(--bad); }

.chat-scroll { flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; scroll-behavior: auto; }
.messages { max-width: 780px; margin: 0 auto; padding: 16px 20px 24px; }
.welcome { display: none; text-align: center; padding: 0 20px 28px; }
.welcome .logo { width: 34px; height: 34px; vertical-align: -6px; margin-right: 10px; }
.welcome h2 { display: inline; font: 400 clamp(26px, 4.4vw, 38px)/1.3 var(--serif); color: var(--text); }

.main.empty .chat-scroll { flex: 1 1 0; display: flex; flex-direction: column; justify-content: flex-end; }
.main.empty .welcome { display: block; }
.main.empty .messages { display: none; }
.main.empty .composer-wrap { flex: 1 1 0; }
.main.empty .suggestions { display: flex; }
.main.empty .disclaimer { visibility: hidden; }

/* ===== 消息 ===== */
.msg { margin-bottom: 26px; }
.msg.user { display: flex; flex-direction: column; align-items: flex-end; }
.bubble {
  background: var(--user-bubble); border-radius: 18px; padding: 10px 16px; max-width: 85%;
  white-space: pre-wrap; word-break: break-word; overflow-wrap: anywhere;
}
.msg-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; color: var(--text-3); font-size: 12.5px; }
.msg-head .logo { width: 18px; height: 18px; }
.msg-actions { display: flex; align-items: center; gap: 2px; margin-top: 6px; color: var(--text-3); font-size: 12px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-actions, .msg:last-child .msg-actions { opacity: 1; }
.msg-actions .icon-btn { width: 28px; height: 28px; }
.msg-actions .meta { margin-left: 6px; }
@media (hover: none) { .msg-actions { opacity: 1; } }

.thinking { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px; background: var(--surface-2); }
.thinking summary {
  list-style: none; cursor: pointer; padding: 8px 12px; font-size: 13px; color: var(--text-2);
  display: flex; align-items: center; gap: 6px; user-select: none;
}
.thinking summary::-webkit-details-marker { display: none; }
.thinking summary::after { content: ""; width: 7px; height: 7px; border: solid var(--text-3); border-width: 0 1.5px 1.5px 0; transform: rotate(-45deg); margin-left: 2px; transition: transform .15s; }
.thinking[open] summary::after { transform: rotate(45deg); }
.thinking-body { padding: 0 14px 12px; font-size: 13.5px; color: var(--text-2); white-space: pre-wrap; max-height: 320px; overflow-y: auto; }
.thinking.live summary { color: var(--accent); }

.typing { display: inline-flex; gap: 5px; padding: 10px 0; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); opacity: .35; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: scale(.85); } 40% { opacity: 1; transform: scale(1); } }
.live-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); margin-top: 4px; animation: pulse 1s infinite ease-in-out; }
@keyframes pulse { 0%, 100% { opacity: .35; transform: scale(.8); } 50% { opacity: 1; transform: scale(1); } }

.msg-note { margin-top: 8px; font-size: 13px; color: var(--text-3); }
.msg-status { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--text-2); }
.msg-status::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--border-strong); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.msg-files { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.file-card {
  display: flex; align-items: center; gap: 12px; min-width: 240px; max-width: 100%; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); text-decoration: none;
  transition: border-color .15s, box-shadow .15s;
}
.file-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.file-ico {
  width: 40px; height: 40px; border-radius: 9px; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  font: 700 11px var(--font); color: #fff; background: #8a8780; letter-spacing: .3px;
}
.file-ico.pptx { background: #d24726; } .file-ico.xlsx { background: #1d6f42; }
.file-ico.docx { background: #2b579a; } .file-ico.pdf { background: #e5252a; }
.file-ico.text { background: #5c6b7a; } .file-ico.image { background: #7b5ea7; }
.file-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.file-info b { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-info small { font-size: 12px; color: var(--text-2); }
.file-dl { color: var(--text-2); display: flex; }

/* ===== 上传附件 ===== */
.composer.dragging { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.attach-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.att-chip {
  position: relative; display: flex; align-items: center; gap: 8px; max-width: 230px; padding: 6px 30px 6px 6px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
}
.att-chip.error { border-color: var(--bad); }
.att-chip img, .att-chip .file-ico { width: 36px; height: 36px; border-radius: 7px; object-fit: cover; font-size: 10px; }
.att-meta { min-width: 0; display: flex; flex-direction: column; }
.att-meta b { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-meta small { font-size: 11.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-chip.error .att-meta small { color: var(--bad); }
.att-x { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; }
.msg-atts { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: flex-end; gap: 8px; margin-bottom: 6px; max-width: 85%; }
.msg-atts img { display: block; max-width: 220px; max-height: 220px; border-radius: 12px; border: 1px solid var(--border); }
.msg-att-file {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); text-decoration: none; font-size: 13px; max-width: 240px;
}
.msg-att-file .file-ico { width: 30px; height: 30px; font-size: 9.5px; border-radius: 6px; }
.msg-att-file span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-error {
  margin-top: 8px; padding: 10px 14px; border-radius: 10px; font-size: 14px;
  color: var(--bad); background: color-mix(in srgb, var(--bad) 9%, transparent); border: 1px solid color-mix(in srgb, var(--bad) 22%, transparent);
}

/* ===== Markdown ===== */
.md { font-size: 15.5px; line-height: 1.75; word-break: break-word; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .85em; }
.md h1, .md h2, .md h3, .md h4, .md h5, .md h6 { margin: 1.3em 0 .55em; line-height: 1.4; font-weight: 600; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.28em; } .md h3 { font-size: 1.13em; } .md h4, .md h5, .md h6 { font-size: 1em; }
.md ul, .md ol { margin: 0 0 .85em; padding-left: 1.6em; }
.md li { margin: .25em 0; }
.md li > ul, .md li > ol { margin: .2em 0; }
.md blockquote { margin: 0 0 .85em; padding: .1em 0 .1em 1em; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 1.4em 0; }
.md code { font-family: var(--mono); font-size: .87em; background: var(--code-inline); padding: .12em .4em; border-radius: 5px; }
.md a { text-decoration: underline; text-underline-offset: 2px; }
.code-block { margin: .4em 0 1em; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--code-block); }
.code-head {
  display: flex; align-items: center; justify-content: space-between; padding: 5px 8px 5px 14px;
  font: 12px var(--mono); color: var(--text-3); border-bottom: 1px solid var(--border);
}
.copy-code { border: 0; background: transparent; color: var(--text-2); font-size: 12px; padding: 3px 8px; border-radius: 6px; }
.copy-code:hover { background: var(--hover); color: var(--text); }
.code-block pre { margin: 0; padding: 12px 14px; overflow-x: auto; }
.code-block code { background: none; padding: 0; font-size: 13.5px; line-height: 1.6; white-space: pre; }
.table-wrap { overflow-x: auto; margin: 0 0 1em; }
.md table { border-collapse: collapse; font-size: 14px; min-width: 50%; }
.md th, .md td { border: 1px solid var(--border); padding: 7px 12px; text-align: left; vertical-align: top; }
.md th { background: var(--surface-2); font-weight: 600; }

/* ===== 输入框 ===== */
.composer-wrap { padding: 0 16px 10px; flex-shrink: 0; }
.composer {
  position: relative; max-width: 780px; margin: 0 auto; background: var(--surface);
  border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow);
  padding: 14px 12px 10px 16px; transition: border-color .15s;
}
.composer:focus-within { border-color: var(--border-strong); }
.composer textarea {
  display: block; width: 100%; min-height: 26px; max-height: 260px; border: 0; outline: none; resize: none;
  background: transparent; font-size: 16px; line-height: 1.6; padding: 0 4px 0 0;
}
.composer textarea::placeholder { color: var(--text-3); }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; }
.composer-bar .left, .composer-bar .right { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 999px; background: transparent; color: var(--text-2); font-size: 13px;
}
.pill:hover { background: var(--hover); color: var(--text); }
.pill.on { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.model-btn {
  display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 8px 0 10px; border: 0; border-radius: 8px;
  background: transparent; color: var(--text-2); font-size: 13.5px; max-width: 200px;
}
.model-btn span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-btn:hover { background: var(--hover); color: var(--text); }
.send-btn {
  width: 34px; height: 34px; border: 0; border-radius: 10px; background: var(--accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { background: var(--border-strong); cursor: default; }
.send-btn.stop { background: var(--text); color: var(--bg); }
.disclaimer { text-align: center; font-size: 12px; color: var(--text-3); padding-top: 8px; }
.suggestions { display: none; flex-wrap: wrap; justify-content: center; gap: 8px; max-width: 780px; margin: 16px auto 0; }
.suggestions .pill { background: var(--surface); }

.menu {
  position: absolute; z-index: 30; bottom: calc(100% + 8px); right: 0; width: min(320px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg);
  padding: 6px; max-height: 60vh; overflow-y: auto;
}
.menu-group { font-size: 12px; color: var(--text-3); padding: 8px 10px 4px; }
.menu-item {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px;
  background: transparent; text-align: left;
}
.menu-item:hover { background: var(--hover); }
.menu-item .mi-main { flex: 1; min-width: 0; }
.menu-item .mi-name { font-size: 14px; font-weight: 500; }
.menu-item .mi-desc { font-size: 12.5px; color: var(--text-2); }
.menu-item .mi-check { color: var(--accent); visibility: hidden; margin-top: 2px; }
.menu-item.selected .mi-check { visibility: visible; }

/* ===== 弹窗 ===== */
.modal-back {
  position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .35);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fade .15s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto;
  background: var(--bg); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg);
}
.modal.sm { width: min(420px, 100%); }
.modal-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between;
  padding: 16px 16px 10px 22px; background: var(--bg);
}
.modal-head h3 { margin: 0; font: 500 19px var(--serif); }
.modal-body { padding: 4px 22px 22px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 0 22px 20px; }
.panel-sec { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; }
.panel-sec h4 { margin: 0 0 10px; font-size: 14px; font-weight: 600; color: var(--text); }
.kv { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 3px 0; }
.kv > span:first-child { color: var(--text-2); }
.kv > span:last-child { font-variant-numeric: tabular-nums; text-align: right; }
.bar { height: 6px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; margin: 4px 0 10px; }
.bar i { display: block; height: 100%; background: var(--ok); border-radius: inherit; transition: width .4s; }
.bar.mid i { background: var(--mid); }
.bar.bad i { background: var(--bad); }
.limit-box { text-align: center; padding: 4px 0; }
.limit-icon {
  width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
}
.limit-msg { margin: 0 0 10px; font-size: 15px; line-height: 1.6; }
.limit-sub { margin: 0; font-size: 13.5px; line-height: 1.7; color: var(--text-2); }
.limit-sub b { color: var(--accent); }
.balance-big { font: 600 30px/1.3 var(--font); font-variant-numeric: tabular-nums; color: var(--accent); margin: 2px 0 6px; }
.reset-tip { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.line-group { font-size: 12.5px; color: var(--text-2); margin: 10px 0 6px; }
.line-group:first-of-type { margin-top: 0; }
.line-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.line-card {
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; background: var(--bg); text-align: left;
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.line-card:hover { border-color: var(--border-strong); }
.line-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.line-card b { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.line-card small { font-size: 12px; color: var(--text-2); }
.lv-low { color: var(--ok); } .lv-mid { color: var(--mid); } .lv-high, .lv-bad { color: var(--bad); }
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; background: transparent; padding: 6px 14px; font-size: 13px; color: var(--text-2); }
.seg button.on { background: var(--active); color: var(--text); font-weight: 500; }
.announcement { white-space: pre-wrap; line-height: 1.75; }

.toast-wrap { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow-lg); max-width: min(90vw, 480px); animation: fade .15s; }
.toast.err { background: var(--bad); color: #fff; }

.overlay { display: none; }

/* ===== 联系客服 ===== */
.support-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 45;
  display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 16px 0 13px;
  border: 0; border-radius: 999px; background: var(--accent); color: #fff; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); transition: background .15s, transform .15s;
}
.support-fab:hover { background: var(--accent-hover); transform: translateY(-1px); }
/* 聊天界面中等宽度：按钮缩成圆形图标，输入框两侧留出相同空间保持居中，避免互相遮挡 */
@media (min-width: 769px) and (max-width: 1399px) {
  .app.has-support .composer-wrap { padding-left: 68px; padding-right: 68px; }
  body.in-app .support-fab { width: 44px; padding: 0; justify-content: center; }
  body.in-app .support-fab span { display: none; }
}
.support-box { text-align: center; padding: 6px 0 4px; }
.support-icon {
  width: 56px; height: 56px; margin: 0 auto 12px; border-radius: 16px; background: #07c160; color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.support-label { font-size: 13px; color: var(--text-2); }
.support-id { font: 600 24px/1.4 var(--mono); letter-spacing: .5px; margin: 4px 0 10px; word-break: break-all; user-select: all; }
.support-note { margin: 0; font-size: 13.5px; color: var(--text-2); white-space: pre-line; }

/* ===== 手机端 ===== */
@media (max-width: 768px) {
  .app, .app.sb-collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; z-index: 40; top: 0; bottom: 0; left: 0; width: min(300px, 84vw);
    transform: translateX(-100%); transition: transform .2s ease; visibility: visible !important;
  }
  .app.sb-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .app.sb-open .overlay { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(0, 0, 0, .3); }
  .only-mobile { display: inline-flex; }
  .only-collapsed, .app.sb-collapsed .only-collapsed { display: none; }
  .sb-collapse { display: none; }
  .messages { padding: 8px 16px 20px; }
  .composer-wrap { padding: 0 10px calc(8px + env(safe-area-inset-bottom)); }
  .main.empty .chat-scroll { flex: 1 1 0; }
  .main.empty .composer-wrap { flex: 0.6 1 0; }
  .bubble { max-width: 92%; }
  .quota-chip .qc-text { display: none; }
  /* 手机聊天界面：按钮移到顶部栏，避免挡住输入框 */
  body.in-app .support-fab { display: none; }
  .support-fab { right: 14px; bottom: 14px; }
}
@media (min-width: 769px) {
  .support-top { display: none !important; }
}
