/* ============================================================
   CodeMentor · 编程学习助手
   视觉方向：浅色「程序员工作台」 + 深色代码编辑器卡片
   强调色：琥珀橙  代码字体：JetBrains Mono  标题：Space Grotesk
   ============================================================ */

/* ---------- 本地字体 ---------- */
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../assets/fonts/jetbrains-mono-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../assets/fonts/jetbrains-mono-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../assets/fonts/jetbrains-mono-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../assets/fonts/jetbrains-mono-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../assets/fonts/space-grotesk-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../assets/fonts/space-grotesk-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../assets/fonts/space-grotesk-latin-700-normal.woff2') format('woff2');
}

/* ---------- 设计变量 ---------- */
:root {
  --bg: #f3f5f8;
  --bg-grid: rgba(22, 32, 46, 0.025);
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --surface-3: #f1f4f8;

  --ink: #151f2b;
  --ink-2: #3a4757;
  --muted: #6b7787;
  --faint: #97a2b1;

  --line: #e2e8f0;
  --line-2: #eceff4;

  --amber: #e07416;
  --amber-strong: #c25f0a;
  --amber-soft: #fdf0e3;
  --amber-ink: #9a4a0c;

  --teal: #0d9488;
  --teal-soft: #e6f5f3;
  --green: #1a7f4e;
  --red: #d23b3b;
  --red-soft: #fdecec;

  --code-bg: #0c131b;
  --code-bg-2: #111b26;
  --code-line: #1d2835;
  --code-ink: #dbe3ee;
  --code-muted: #8593a5;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 30, 45, 0.05), 0 6px 20px -10px rgba(20, 30, 45, 0.12);
  --shadow-lg: 0 12px 48px -12px rgba(15, 23, 35, 0.28);

  --font-ui: 'Space Grotesk', -apple-system, BlinkMacSystemFont, 'PingFang SC',
    'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans CJK SC', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas,
    'Liberation Mono', monospace;
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 28px 28px;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }
::selection { background: var(--amber-soft); color: var(--amber-ink); }

/* 焦点可见 */
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ---------- 顶部导航 ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
  height: 54px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--ink);
  color: #fff;
  flex-shrink: 0;
}
.brand-mark svg { width: 20px; height: 20px; color: var(--amber); }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-weight: 700; font-size: 15.5px; letter-spacing: 0.2px; }
.brand-sub { font-size: 11.5px; color: var(--muted); font-family: var(--font-ui); white-space: nowrap; }

.lang-switch {
  display: flex;
  gap: 2px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 3px;
  flex-shrink: 0;
}
.lang-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  font-family: var(--font-mono);
  padding: 4px 13px;
  border-radius: 6px;
  line-height: 1.5;
  transition: all 0.15s ease;
}
.lang-btn:hover { color: var(--ink); }
.lang-btn.active {
  background: var(--surface);
  color: var(--amber-strong);
  box-shadow: 0 1px 2px rgba(20, 30, 45, 0.10);
}

.top-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  padding: 8px 13px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.ghost-btn svg { width: 17px; height: 17px; flex-shrink: 0; }
.ghost-btn:hover { border-color: var(--amber); color: var(--amber-strong); background: var(--amber-soft); }

/* 顶部导航：普通功能按钮低调化（去边框、图标化），仅保留“充值 / 余额”为强调主按钮 */
.topbar .ghost-btn {
  border-color: transparent;
  background: transparent;
  padding: 7px 10px;
  font-size: 13px;
}
.topbar .ghost-btn svg { width: 16px; height: 16px; }
.topbar .ghost-btn:hover { border-color: transparent; color: var(--ink); background: var(--surface-3); }
.topbar .topup-entry {
  border-color: var(--amber);
  background: var(--amber-soft);
  color: var(--amber-strong);
  font-weight: 600;
  padding: 7px 12px;
}
.topbar .topup-entry:hover { border-color: var(--amber-strong); background: #fae3cc; color: var(--amber-strong); }

/* ---------- 模式切换 ---------- */
.mode-tabs {
  display: flex;
  gap: 6px;
  padding: 12px 22px 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  color: var(--muted);
  padding: 10px 18px;
  font-size: 14.5px;
  font-weight: 600;
  border-radius: 10px 10px 0 0;
  position: relative;
  transition: all 0.15s ease;
}
.mode-btn svg { opacity: 0.8; }
.mode-btn:hover { color: var(--ink); }
.mode-btn.active {
  color: var(--amber-strong);
  background: var(--bg);
  border-color: var(--line);
}
.mode-btn.active::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 2px;
  background: var(--bg);
}

/* ---------- 对话区 ---------- */
.chat-area {
  flex: 1;
  overflow-y: auto;
  scroll-behavior: smooth;
}
.messages {
  max-width: 880px;
  margin: 0 auto;
  padding: 28px 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* 欢迎页 */
.welcome {
  text-align: center;
  padding: 46px 12px 10px;
}
.welcome-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  border-radius: 16px;
  background: var(--ink);
  color: var(--amber);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}
.welcome h1 {
  font-size: 27px;
  font-weight: 700;
  margin: 0 0 10px;
  letter-spacing: 0.2px;
}
.welcome h1 .lang-name { color: var(--amber-strong); font-family: var(--font-mono); }
.welcome p { color: var(--muted); margin: 0 auto 26px; max-width: 560px; font-size: 15px; }
.welcome-feats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 0 auto 28px;
  max-width: 680px;
}
.feat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 14px;
  text-align: left;
}
.feat-ico {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--amber-soft);
  color: var(--amber-strong);
  display: grid;
  place-items: center;
  margin-bottom: 9px;
}
.feat-card h4 { margin: 0 0 4px; font-size: 14px; font-weight: 600; }
.feat-card p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.welcome-lbl { font-size: 12.5px; color: var(--faint); margin-bottom: 10px; text-transform: uppercase; letter-spacing: 1px; }
.example-chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; max-width: 680px; margin: 0 auto; }
.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  border-radius: 999px;
  padding: 8px 15px;
  font-size: 13px;
  transition: all 0.14s ease;
}
.chip:hover { border-color: var(--amber); color: var(--amber-strong); background: var(--amber-soft); }

/* 消息行 */
.msg { display: flex; gap: 12px; align-items: flex-start; }
.msg-avatar {
  width: 34px; height: 34px;
  border-radius: 9px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  margin-top: 2px;
}
.msg-user .msg-avatar { background: var(--amber); color: #fff; }
.msg-ai .msg-avatar { background: var(--ink); color: var(--amber); }
.msg-body { flex: 1; min-width: 0; }
.msg-meta { display: flex; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.msg-name { font-size: 13.5px; font-weight: 600; }
.msg-time { font-size: 11.5px; color: var(--faint); }

.msg-bubble {
  border-radius: var(--radius);
  padding: 14px 16px;
  border: 1px solid var(--line);
}
.msg-user .msg-bubble {
  background: var(--amber-soft);
  border-color: #f3d9bf;
  color: var(--ink);
}
.msg-ai .msg-bubble {
  background: var(--surface);
  box-shadow: var(--shadow);
}

/* 用户代码预览 */
.msg-code-preview {
  margin-top: 10px;
  background: var(--code-bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--code-line);
}
.msg-code-preview .cp-head {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--code-bg-2);
  border-bottom: 1px solid var(--code-line);
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--code-muted);
}
.msg-code-preview pre {
  margin: 0;
  padding: 12px 14px;
  max-height: 260px;
  overflow: auto;
}
.msg-code-preview code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--code-ink);
  white-space: pre;
}
.msg-question {
  margin-top: 8px;
  font-size: 14px;
  padding-top: 8px;
  border-top: 1px dashed #ecc79f;
}
.msg-question .q-lbl { color: var(--amber-ink); font-weight: 600; margin-right: 6px; }

/* Markdown 内容 */
.md > *:first-child { margin-top: 0; }
.md > *:last-child { margin-bottom: 0; }
.md h1, .md h2, .md h3, .md h4 {
  font-weight: 600;
  line-height: 1.35;
  margin: 20px 0 9px;
}
.md h1 { font-size: 20px; }
.md h2 { font-size: 17.5px; }
.md h3 { font-size: 15.5px; }
.md h4 { font-size: 14.5px; }
.md p { margin: 9px 0; }
.md ul, .md ol { margin: 9px 0; padding-left: 22px; }
.md li { margin: 4px 0; }
.md li::marker { color: var(--amber); }
.md strong { color: var(--ink); font-weight: 600; }
.md blockquote {
  margin: 12px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--amber);
  background: var(--surface-2);
  border-radius: 0 8px 8px 0;
  color: var(--ink-2);
}
.md a { color: var(--amber-strong); text-decoration: underline; text-underline-offset: 2px; }
.md hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.md table { border-collapse: collapse; margin: 12px 0; font-size: 13.5px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 7px 12px; text-align: left; }
.md th { background: var(--surface-3); font-weight: 600; }

/* 行内代码 */
.md :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--surface-3);
  color: var(--amber-ink);
  border: 1px solid var(--line-2);
  border-radius: 5px;
  padding: 0.12em 0.42em;
  word-break: break-word;
}

/* 代码块（编辑器卡片） */
.code-block {
  margin: 13px 0;
  background: var(--code-bg);
  border: 1px solid var(--code-line);
  border-radius: var(--radius);
  overflow: hidden;
}
.code-block-head {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 38px;
  padding: 0 10px 0 13px;
  background: var(--code-bg-2);
  border-bottom: 1px solid var(--code-line);
}
.cb-dots { display: flex; gap: 5px; flex-shrink: 0; }
.cb-dots i { width: 9px; height: 9px; border-radius: 50%; display: block; }
.cb-dots i:nth-child(1) { background: #ff5f57; }
.cb-dots i:nth-child(2) { background: #febc2e; }
.cb-dots i:nth-child(3) { background: #28c840; }
.cb-file {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--code-ink);
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cb-file svg { color: var(--code-muted); flex-shrink: 0; }
.cb-lang {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--amber);
  background: rgba(224, 116, 22, 0.14);
  border: 1px solid rgba(224, 116, 22, 0.28);
  padding: 1px 7px;
  border-radius: 5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  flex-shrink: 0;
}
.cb-actions { margin-left: auto; display: flex; gap: 4px; flex-shrink: 0; }
.cb-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: transparent;
  color: var(--code-muted);
  font-size: 11.5px;
  padding: 5px 8px;
  border-radius: 6px;
  transition: all 0.13s ease;
}
.cb-btn:hover { color: var(--code-ink); background: var(--code-line); }
.code-block-body { margin: 0; overflow-x: auto; }
.code-block-body pre { margin: 0; padding: 14px 16px; }
.code-block-body code {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  color: var(--code-ink);
  background: transparent;
  padding: 0;
  border: none;
  white-space: pre;
}

/* highlight.js 配色（GitHub Dark 风格） */
.hljs-comment, .hljs-quote { color: #8b949e; font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-doctag, .hljs-tag { color: #ff7b72; }
.hljs-string, .hljs-regexp, .hljs-addition { color: #a5d6ff; }
.hljs-number, .hljs-literal, .hljs-built_in { color: #79c0ff; }
.hljs-title, .hljs-title.function_, .hljs-section { color: #d2a8ff; }
.hljs-title.class_, .hljs-type, .hljs-class .hljs-title { color: #ffa657; }
.hljs-name, .hljs-selector-id, .hljs-selector-class, .hljs-attr, .hljs-attribute { color: #7ee787; }
.hljs-variable, .hljs-template-variable, .hljs-symbol { color: #ffa657; }
.hljs-meta, .hljs-deletion { color: #8b949e; }
.hljs-bullet, .hljs-link { color: #79c0ff; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* AI 消息底部操作 */
.msg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px solid var(--line-2);
}
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-2);
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.14s ease;
}
.action-btn:hover { border-color: var(--amber); color: var(--amber-strong); }
.action-btn.primary {
  background: var(--amber);
  border-color: var(--amber);
  color: #fff;
}
.action-btn.primary:hover { background: var(--amber-strong); border-color: var(--amber-strong); color: #fff; }

/* 流式光标 */
.stream-cursor {
  display: inline-block;
  width: 8px;
  height: 16px;
  background: var(--amber);
  vertical-align: text-bottom;
  margin-left: 2px;
  border-radius: 1px;
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }
.msg-error {
  margin-top: 10px;
  background: var(--red-soft);
  border: 1px solid #f3c5c5;
  color: #a32626;
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 13px;
}
.msg-error .err-title { font-weight: 600; display: block; margin-bottom: 3px; }
.typing-dots { display: inline-flex; gap: 4px; align-items: center; padding: 4px 2px; }
.typing-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: bounce 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* ---------- 输入区 ---------- */
.composer {
  flex-shrink: 0;
  padding: 14px 22px 18px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.composer-inner {
  max-width: 880px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  transition: border-color 0.15s ease;
}
.composer-inner:focus-within { border-color: var(--amber); }

.file-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 9px; }
.file-chips:empty { display: none; }
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--ink);
  color: #e8edf4;
  border-radius: 7px;
  padding: 5px 9px 5px 10px;
  font-family: var(--font-mono);
  font-size: 12px;
}
.file-chip svg { color: var(--amber); }
.file-chip button {
  border: none;
  background: transparent;
  color: var(--code-muted);
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 4px;
  line-height: 0;
}
.file-chip button:hover { color: #fff; }

.main-input-wrap { position: relative; }
.main-input {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  color: var(--ink);
  resize: none;
  line-height: 1.6;
  min-height: 78px;
  max-height: 260px;
}
.main-input.code-font {
  font-family: var(--font-mono);
  font-size: 13px;
  tab-size: 4;
}
.main-input:focus { outline: none; border-color: var(--amber); background: var(--surface); }

.question-row {
  display: none;
  align-items: center;
  gap: 9px;
  margin-top: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  background: var(--surface-2);
}
.question-row svg { color: var(--faint); flex-shrink: 0; }
.question-row input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 0;
  font-size: 13.5px;
  color: var(--ink);
}
.question-row input:focus { outline: none; }
body.mode-explain .question-row { display: flex; }

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 11px;
}
.composer-left { display: flex; align-items: center; gap: 10px; }
.composer-tip { font-size: 11.5px; color: var(--faint); }
.composer-right { display: flex; gap: 8px; }
.send-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: none;
  background: var(--amber);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  padding: 9px 20px;
  border-radius: 9px;
  transition: all 0.15s ease;
}
.send-btn:hover { background: var(--amber-strong); }
.send-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.stop-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--red);
  background: var(--red-soft);
  color: var(--red);
  font-weight: 600;
  font-size: 14px;
  padding: 9px 18px;
  border-radius: 9px;
}
.stop-dot { width: 9px; height: 9px; background: var(--red); border-radius: 50%; }
.stop-btn:hover { background: var(--red); color: #fff; }
.stop-btn:hover .stop-dot { background: #fff; }

/* ---------- 抽屉 ---------- */
.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 360px;
  max-width: 88vw;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  z-index: 60;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 17px 18px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.drawer-head-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  width: 32px; height: 32px;
  border-radius: 7px;
  display: grid;
  place-items: center;
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.text-btn { border: none; background: transparent; color: var(--amber-strong); font-size: 13px; font-weight: 500; padding: 6px 8px; border-radius: 6px; }
.text-btn:hover { background: var(--amber-soft); }
.drawer-body { flex: 1; overflow-y: auto; padding: 10px; }
.drawer-empty { text-align: center; color: var(--faint); font-size: 13.5px; padding: 46px 20px; }
.history-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 11px 12px;
  margin-bottom: 8px;
  transition: all 0.13s ease;
}
.history-item:hover { border-color: var(--amber); background: var(--amber-soft); }
.hi-top { display: flex; align-items: center; gap: 7px; margin-bottom: 4px; }
.hi-mode { font-size: 10.5px; font-weight: 600; padding: 1px 6px; border-radius: 4px; }
.hi-mode.explain { background: var(--teal-soft); color: var(--teal); }
.hi-mode.generate { background: var(--amber-soft); color: var(--amber-ink); }
.hi-lang { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); }
.hi-title { font-size: 13.5px; font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hi-time { font-size: 11px; color: var(--faint); margin-top: 3px; }

/* ---------- 模态 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 35, 0.45);
  z-index: 50;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal.open { display: flex; }
.modal-card {
  background: var(--surface);
  border-radius: 14px;
  width: 560px;
  max-width: 100%;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: pop 0.18s ease;
}
@keyframes pop { from { transform: scale(0.97); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 17px; font-weight: 600; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 15px 20px;
  border-top: 1px solid var(--line);
}
.field { margin-bottom: 15px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink-2); }
.field input[type=text], .field input[type=password], .field input[type=number], .field select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13.5px;
  color: var(--ink);
  background: var(--surface-2);
}
.field input:focus, .field select:focus { outline: none; border-color: var(--amber); background: var(--surface); }
.field-hint { display: block; font-size: 11.5px; color: var(--faint); margin-top: 5px; line-height: 1.5; }
.input-with-action { display: flex; gap: 8px; }
.input-with-action input { flex: 1; }
.field-check { margin-top: 4px; }
.check-label { display: flex; align-items: flex-start; gap: 9px; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.check-label input { margin-top: 3px; accent-color: var(--amber); }
.test-result { margin-top: 6px; font-size: 13px; border-radius: var(--radius-sm); padding: 0; max-height: 0; overflow: hidden; transition: all 0.2s ease; }
.test-result.show { padding: 10px 13px; margin-top: 8px; }
.test-result.ok { background: var(--teal-soft); color: var(--teal); }
.test-result.fail { background: var(--red-soft); color: #a32626; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  font-size: 13.5px;
  padding: 11px 20px;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: all 0.22s ease;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  /* 中等屏：副标题隐藏；顶部 使用说明/历史/设置 收成图标，只保留“充值 / 余额”文字 */
  .brand-sub { display: none; }
  .topbar .ghost-btn:not(.topup-entry) span { display: none; }
  .topbar .ghost-btn:not(.topup-entry) { padding: 7px; }
}
@media (max-width: 720px) {
  .topbar { padding: 0 10px; height: 52px; gap: 8px; }
  .brand-sub { display: none; }
  .brand-name { font-size: 14.5px; }
  .ghost-btn span { display: none; }
  .ghost-btn { padding: 7px; }
  .top-actions { gap: 2px; }
  .lang-btn { padding: 4px 10px; }
  .mode-tabs { padding: 10px 13px 0; }
  .mode-btn { padding: 10px 12px; font-size: 13.5px; }
  .mode-btn span { display: none; }
  .messages { padding: 18px 13px; }
  .composer { padding: 10px 13px 14px; }
  .welcome-feats { grid-template-columns: 1fr; }
  .composer-tip { display: none; }
  .send-btn { padding: 9px 15px; }
  .field-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ============================================================
   v1.4 新增：充值入口按钮 / 图片上传 / 页脚 / 充值页 / 帮助
   ============================================================ */

/* 顶部“充值 / 余额”强调按钮 */
.topup-entry {
  border-color: var(--amber);
  color: var(--amber-strong);
  background: var(--amber-soft);
  font-weight: 600;
}
.topup-entry:hover { background: var(--amber); color: #fff; border-color: var(--amber); }

/* 页脚署名（最下方一行小字） */
.app-footer {
  flex-shrink: 0;
  text-align: center;
  font-size: 11.5px;
  color: var(--faint);
  padding: 7px 12px 9px;
  letter-spacing: 0.2px;
  background: var(--bg);
}

/* 图片缩略图 chips（输入区） */
.image-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 9px; }
.image-chips:empty { display: none; }
.image-chip {
  position: relative;
  width: 58px; height: 58px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--code-bg);
  display: flex;
}
.image-chip img { width: 100%; height: 100%; object-fit: cover; }
.image-chip .ic-name { display: none; }
.ic-remove {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px; border: none; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(12,19,27,0.72); color: #fff; padding: 0; line-height: 0;
}
.ic-remove:hover { background: var(--red); }

/* 用户消息里的图片 */
.msg-images { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 10px; }
.msg-img {
  max-width: 200px; border-radius: 10px; overflow: hidden;
  border: 1px solid var(--line); background: var(--surface-3);
}
.msg-img img { display: block; width: 100%; height: auto; max-height: 220px; object-fit: cover; }
.msg-img-missing {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; font-size: 12px; color: var(--muted);
  max-width: 280px;
}

/* 设置弹窗里的服务商描述 small */
#providerDesc { display: block; margin-top: 6px; color: var(--muted); }

/* ============ 全屏页面（充值中心） ============ */
.fullpage-view {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column;
  background: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 28px 28px;
}
.fullpage-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; padding: 0 22px; height: 62px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.fullpage-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.fullpage-head .head-spacer { width: 96px; }
.fullpage-body { flex: 1; overflow-y: auto; }
.topup-container { max-width: 1000px; margin: 0 auto; padding: 26px 22px 40px; }

/* 余额卡片 */
.balance-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow);
  padding: 20px 22px; margin-bottom: 26px;
}
.balance-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.balance-provider { font-size: 18px; font-weight: 700; }
.balance-meta { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.balance-meta code { font-family: var(--font-mono); background: var(--surface-3); padding: 1px 6px; border-radius: 5px; }
.balance-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 11.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.badge-cloud { background: var(--surface-3); color: var(--ink-2); border-color: var(--line); }
.badge-local { background: var(--teal-soft); color: var(--teal); }
.badge-balance { background: var(--amber-soft); color: var(--amber-ink); }
.badge-vision { background: #eef2ff; color: #4347c4; }

.balance-status { margin-top: 14px; font-size: 13.5px; padding: 11px 14px; border-radius: 10px; line-height: 1.6; }
.balance-status.muted { background: var(--surface-2); color: var(--muted); }
.balance-status.info { background: var(--teal-soft); color: #0b6b62; }
.balance-status.ok { background: #e9f7ef; color: var(--green); }
.balance-status.warn { background: var(--red-soft); color: #a32626; }
.balance-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.bal-list { margin-top: 10px; display: grid; gap: 8px; }
.bal-row {
  display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap;
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; background: var(--surface-2);
}
.bal-currency { font-weight: 700; font-family: var(--font-mono); }
.bal-total { font-size: 14px; color: var(--ink-2); }
.bal-total b { font-size: 20px; color: var(--amber-strong); font-family: var(--font-mono); }
.bal-sub { font-size: 12.5px; color: var(--muted); }

/* 充值服务商卡片 */
.topup-section-title { margin-bottom: 14px; }
.topup-section-title h3 { margin: 0 0 4px; font-size: 16px; }
.topup-section-title p { margin: 0; font-size: 13px; color: var(--muted); }
.topup-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 14px;
}
.topup-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px;
}
.topup-card.current { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber), var(--shadow); }
.tpc-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.tpc-name { font-size: 15.5px; font-weight: 700; }
.tpc-badges { display: flex; gap: 5px; flex-wrap: wrap; }
.tpc-badges .badge { font-size: 10.5px; padding: 2px 7px; }
.tpc-desc { font-size: 12.5px; color: var(--muted); line-height: 1.6; min-height: 40px; }
.tpc-model { font-size: 11.5px; color: var(--faint); word-break: break-all; }
.tpc-model code { font-family: var(--font-mono); background: var(--surface-3); padding: 1px 5px; border-radius: 5px; }
.tpc-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; padding-top: 4px; }

/* 按钮/链接小药丸（充值页通用） */
.pill-link {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  text-decoration: none; font-size: 12.5px; font-weight: 600;
  padding: 7px 12px; border-radius: 8px; transition: all .15s ease;
}
.pill-link:hover { border-color: var(--amber); color: var(--amber-strong); background: var(--amber-soft); }
.pill-link.primary { background: var(--amber); border-color: var(--amber); color: #fff; }
.pill-link.primary:hover { background: var(--amber-strong); border-color: var(--amber-strong); color: #fff; }
.pill-link:disabled { opacity: .6; cursor: default; }
.use-btn { font-weight: 700; }
.topup-note {
  margin-top: 22px; font-size: 12.5px; color: var(--muted); line-height: 1.7;
  background: var(--surface); border: 1px dashed var(--line); border-radius: 10px; padding: 12px 16px;
}

/* ============ 使用说明弹窗 ============ */
.modal-wide { width: 720px; }
.help-body { font-size: 13.5px; color: var(--ink-2); line-height: 1.75; }
.help-body h4 { font-size: 14.5px; color: var(--ink); margin: 18px 0 8px; }
.help-body h4:first-child { margin-top: 2px; }
.help-body ol, .help-body ul { margin: 0 0 6px; padding-left: 22px; }
.help-body li { margin-bottom: 6px; }
.help-body code {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--code-bg); color: var(--code-ink);
  padding: 1px 6px; border-radius: 5px; word-break: break-all;
}
.help-body ul ul { margin-top: 4px; }
.help-contact {
  margin-top: 18px; padding: 12px 14px; border-radius: 10px;
  background: var(--amber-soft); color: var(--amber-ink);
  font-size: 13px; text-align: center; font-weight: 600;
}

/* 响应式补充 */
@media (max-width: 720px) {
  .topup-entry span { display: inline; }
  .fullpage-head { padding: 0 13px; }
  .topup-container { padding: 18px 13px 30px; }
  .topup-grid { grid-template-columns: 1fr; }
  .modal-wide { width: 100%; }
  .backend-banner-inner { flex-wrap: wrap; }
}

/* ============ 后端未生效告警横幅（v1.4.1） ============ */
.backend-banner {
  background: #fef3ec;
  border-bottom: 1px solid #f0c8ad;
  padding: 10px 16px;
}
.backend-banner[hidden] { display: none; }
.backend-banner-inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: #8a3d12;
}
.backend-banner-inner svg { flex: 0 0 auto; margin-top: 2px; color: #d9621b; }
.backend-banner-text { flex: 1 1 auto; font-size: 13px; line-height: 1.55; }
.backend-banner-text strong { display: block; margin-bottom: 2px; font-size: 14px; }
.backend-banner-text b { font-weight: 700; }
.backend-banner-btn {
  flex: 0 0 auto;
  margin-top: 2px;
  background: #d9621b;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.backend-banner-btn:hover { background: #c25314; }
.backend-banner-close {
  flex: 0 0 auto;
  background: transparent;
  border: none;
  color: #a65a28;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}
