/* ============================================================
   NexusAI · 聚合 AI 对话平台
   设计语言对齐 DSH：中性蓝灰底色、DeepSeek 蓝强调色、
   低对比描边、胶囊控件、克制的圆角与动效。
   ============================================================ */

/* ---------- 设计令牌 ---------- */
:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "Cascadia Code", "JetBrains Mono",
    Consolas, "Liberation Mono", monospace;

  --accent: rgb(77, 147, 248);
  --accent-strong: rgb(65, 118, 230);
  --accent-soft: rgb(237, 243, 254);
  --accent-line: rgba(86, 134, 254, .35);

  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 26px;

  --ease: cubic-bezier(.2, .7, .3, 1);
  --shadow-pop: 0 16px 48px rgba(0, 0, 0, .28), 0 0 0 .5px var(--border-3);
  --shadow-soft: 0 6px 24px rgba(0, 0, 0, .12);

  --sb-w: 264px;
  --content-w: 780px;
  --content-font: 14.5px;
}

/* 深色（默认） */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: rgb(21, 21, 23);
  --bg-elev: rgb(27, 27, 28);
  --surface: rgb(35, 35, 36);
  --surface-2: rgb(44, 44, 46);
  --surface-3: rgb(53, 54, 56);
  --sidebar: rgb(27, 27, 28);
  --bubble-assistant: rgb(35, 35, 36);
  --bubble-assistant-border: rgba(255, 255, 255, .06);
  --bubble-user: rgb(37, 52, 82);
  --bubble-user-border: rgba(96, 165, 250, .22);
  --text: rgb(249, 250, 251);
  --text-2: rgb(207, 211, 214);
  --text-3: rgb(151, 157, 166);
  --text-4: rgb(113, 118, 125);
  --border: rgba(255, 255, 255, .06);
  --border-2: rgba(255, 255, 255, .10);
  --border-3: rgba(255, 255, 255, .14);
  --hover: rgba(255, 255, 255, .055);
  --hover-strong: rgba(255, 255, 255, .09);
  --active: rgba(255, 255, 255, .11);
  --code-bg: rgb(16, 16, 17);
  --code-head: rgb(24, 24, 25);
  --inline-code: rgba(255, 255, 255, .08);
  --table-line: rgba(255, 255, 255, .09);
  --table-head: rgba(255, 255, 255, .045);
  --input-bg: rgb(35, 35, 36);
  --backdrop: rgba(0, 0, 0, .55);
  --ok: rgb(78, 209, 126);
  --warn: rgb(247, 173, 49);
  --danger: rgb(248, 113, 113);
  --thumb: rgba(255, 255, 255, .16);
}

/* 浅色 */
html[data-theme="light"] {
  color-scheme: light;
  --bg: rgb(249, 250, 251);
  --bg-elev: rgb(255, 255, 255);
  --surface: rgb(255, 255, 255);
  --surface-2: rgb(245, 246, 247);
  --surface-3: rgb(235, 238, 242);
  --sidebar: rgb(249, 250, 251);
  --bubble-assistant: rgb(255, 255, 255);
  --bubble-assistant-border: rgba(0, 0, 0, .07);
  --bubble-user: rgb(237, 243, 254);
  --bubble-user-border: rgba(65, 118, 230, .18);
  --text: rgb(15, 17, 21);
  --text-2: rgb(53, 54, 56);
  --text-3: rgb(97, 102, 107);
  --text-4: rgb(151, 157, 166);
  --border: rgba(0, 0, 0, .055);
  --border-2: rgba(0, 0, 0, .09);
  --border-3: rgba(0, 0, 0, .13);
  --hover: rgba(0, 0, 0, .04);
  --hover-strong: rgba(0, 0, 0, .065);
  --active: rgba(0, 0, 0, .08);
  --code-bg: rgb(247, 248, 250);
  --code-head: rgb(241, 243, 245);
  --inline-code: rgba(0, 0, 0, .055);
  --table-line: rgba(0, 0, 0, .08);
  --table-head: rgba(0, 0, 0, .035);
  --input-bg: rgb(255, 255, 255);
  --backdrop: rgba(15, 17, 21, .28);
  --ok: rgb(34, 160, 86);
  --warn: rgb(190, 120, 10);
  --danger: rgb(220, 60, 60);
  --thumb: rgba(0, 0, 0, .18);
  --accent-soft: rgb(237, 243, 254);
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font: var(--content-font)/1.62 var(--font-sans);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
svg { display: block; }
.hidden { display: none !important; }
::selection { background: var(--accent-line); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--thumb); border-radius: 99px;
  border: 3px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-4); background-clip: content-box; }

/* ---------- 布局 ---------- */
.app {
  display: flex; height: 100dvh; width: 100%;
  background: var(--bg);
}

/* ============ 侧栏 ============ */
.sidebar {
  width: var(--sb-w); flex: 0 0 var(--sb-w);
  display: flex; flex-direction: column;
  background: var(--sidebar);
  border-right: .5px solid var(--border-2);
  transition: margin-left .22s var(--ease), opacity .18s var(--ease);
  z-index: 30;
}
/* 侧栏收起后的展开手柄 */
.sb-open {
  display: none; position: fixed; left: 8px; top: 50%; transform: translateY(-50%);
  z-index: 120; width: 28px; height: 56px; border-radius: 0 9px 9px 0;
  border: .5px solid var(--border-3); background: var(--surface); color: var(--text-3);
  align-items: center; justify-content: center; cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
.sb-open:hover { color: var(--text); background: var(--hover-strong); }
body.sb-collapsed #menuBtn { display: grid; }
body.sb-collapsed .sb-open { display: flex; }

.app.collapsed .sidebar { margin-left: calc(-1 * var(--sb-w)); opacity: 0; pointer-events: none; }

.sb-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 12px 10px 16px;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center; overflow: hidden;
  background: transparent;
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-name { font-weight: 650; font-size: 15px; letter-spacing: .2px; }
.brand-tag {
  font-size: 10px; font-weight: 500; color: var(--accent);
  border: .5px solid var(--accent-line); background: var(--accent-soft);
  padding: 0 6px; border-radius: 99px; line-height: 17px;
}
html[data-theme="dark"] .brand-tag { background: rgba(65, 118, 230, .14); }

.icon-btn {
  width: 30px; height: 30px; border-radius: var(--radius-xs);
  display: grid; place-items: center; color: var(--text-3);
  transition: background .15s var(--ease), color .15s var(--ease);
}
.icon-btn:hover { background: var(--hover-strong); color: var(--text); }
.icon-btn:active { background: var(--active); }

.sb-actions { padding: 4px 12px 10px; }
.new-chat {
  width: 100%; height: 38px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--surface); color: var(--text);
  border: .5px solid var(--border-2);
  font-size: 13.5px; font-weight: 550;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .12s var(--ease);
}
.new-chat:hover { background: var(--surface-2); border-color: var(--border-3); }
.new-chat:active { transform: scale(.985); }

.sb-search {
  margin: 0 12px 6px; display: flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 10px; border-radius: var(--radius-xs);
  background: var(--hover); color: var(--text-4);
  border: .5px solid transparent;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.sb-search:focus-within { border-color: var(--accent-line); background: var(--surface); }
.sb-search input,
.sb-search-input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none;
  font-size: 12.5px; color: var(--text); line-height: 1.5;
  white-space: nowrap; overflow: hidden;
}
.sb-search input::placeholder { color: var(--text-4); }
.sb-search-input.is-empty::before { content: attr(data-placeholder); color: var(--text-4); }

.conv-list {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  padding: 2px 8px 12px;
}
.conv-group-label {
  font-size: 11px; color: var(--text-4); font-weight: 500;
  padding: 12px 8px 5px; letter-spacing: .3px;
}
.conv-item {
  position: relative; display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 8px; margin: 1px 0;
  border-radius: var(--radius-xs); color: var(--text-2);
  font-size: 13px; cursor: pointer;
  transition: background .13s var(--ease), color .13s var(--ease);
}
.conv-item:hover { background: var(--hover-strong); color: var(--text); }
.conv-item.active { background: var(--hover-strong); color: var(--text); font-weight: 550; }
.conv-item.active::before {
  content: ""; position: absolute; left: 0; top: 9px; bottom: 9px;
  width: 2.5px; border-radius: 99px; background: var(--accent);
}
.conv-title {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.conv-cost { font-size: 10.5px; color: var(--text-4); font-variant-numeric: tabular-nums; }
.conv-del {
  position: absolute; right: 6px; width: 22px; height: 22px; border-radius: 6px;
  display: none; place-items: center; color: var(--text-3);
  background: var(--surface-2);
}
.conv-item:hover .conv-del { display: grid; }
.conv-del:hover { color: var(--danger); background: var(--surface-3); }
.conv-empty { padding: 26px 14px; text-align: center; color: var(--text-4); font-size: 12.5px; line-height: 1.9; }

.sb-foot {
  border-top: .5px solid var(--border-2); padding: 8px;
  display: flex; flex-direction: column; gap: 1px;
}
.sb-link {
  display: flex; align-items: center; gap: 9px; height: 34px; padding: 0 10px;
  border-radius: var(--radius-xs); color: var(--text-2); font-size: 13px;
  transition: background .13s var(--ease), color .13s var(--ease);
}
.sb-link:hover { background: var(--hover-strong); color: var(--text); }
.sb-link-val { margin-left: auto; font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.sb-link:hover { background: var(--hover); color: var(--text); }

/* ---------- 平台 LOGO ---------- */
.logo-chip {
  display: inline-grid; place-items: center; flex: 0 0 auto;
  border-radius: 8px; overflow: hidden; border: .5px solid var(--border-2);
}
.logo-chip img { width: 80%; height: 80%; object-fit: contain; display: block; }
.logo-chip i { display: none; font-style: normal; font-size: 9px; font-weight: 700; letter-spacing: .2px; }
.logo-chip.noimg i { display: block; }
.logo-chip.bg-light { background: #fff; color: #2a2a2e; }
.logo-chip.bg-dark { background: #17181c; color: #fff; border-color: rgba(255, 255, 255, .16); }
.logo-chip.mj-chip img { filter: brightness(0) invert(1); }
.logo-chip.md { width: 28px; height: 28px; }
.logo-chip.sm { width: 24px; height: 24px; border-radius: 7px; }
.logo-chip.xs { width: 26px; height: 26px; border-radius: 7px; }

.brand-pill {
  display: flex; align-items: center; gap: 7px; height: 34px; padding: 0 11px 0 4px;
  border-radius: 99px; border: .5px solid var(--border-2); background: var(--surface);
  color: var(--text-2); font-size: 12px; transition: border-color .15s var(--ease), background .15s var(--ease);
}
.brand-pill:hover { border-color: var(--border-3); background: var(--surface-2); color: var(--text); }
.brand-pill .logo-chip { width: 26px; height: 26px; }
.brand-pill-name { max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 主区 ---------- */
.main {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  position: relative; background: var(--bg);
}
.pane { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pane.hidden { display: none !important; }

/* ---------- 模式页签 ---------- */
.modes {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px;
  margin: 2px 10px 8px; padding: 3px; border-radius: var(--radius-sm);
  background: var(--hover); border: .5px solid var(--border);
}
.mode {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px 5px; border-radius: 7px; color: var(--text-3);
  font-size: 11px; transition: background .14s var(--ease), color .14s var(--ease);
}
.mode:hover { color: var(--text); background: var(--hover-strong); }
.mode.on {
  color: var(--accent); background: var(--surface);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .16);
}
.mode-count { font-style: normal; font-size: 9px; color: var(--text-4); line-height: 1; }
.mode.on .mode-count { color: var(--accent); opacity: .8; }


.topbar {
  height: 56px; flex: 0 0 56px; display: flex; align-items: center; gap: 10px;
  padding: 0 16px; border-bottom: .5px solid var(--border);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px) saturate(160%);
  z-index: 20;
}
.only-mobile { display: none; }

.model-trigger {
  display: flex; align-items: center; gap: 9px; height: 40px;
  padding: 3px 10px 3px 4px; border-radius: var(--radius-sm);
  border: .5px solid transparent; max-width: min(420px, 58vw);
  transition: background .15s var(--ease), border-color .15s var(--ease);
}
.model-trigger:hover { background: var(--hover-strong); border-color: var(--border-2); }
.model-trigger.open { background: var(--hover-strong); border-color: var(--border-3); }
.mt-avatar {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px;
  display: grid; place-items: center; overflow: hidden;
}
.mt-avatar .logo-chip { width: 30px; height: 30px; }
.mt-text { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; line-height: 1.3; }
.mt-name { font-size: 13.5px; font-weight: 600; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-meta { font-size: 10.5px; color: var(--text-4); white-space: nowrap; }
.mt-caret { color: var(--text-4); flex: 0 0 auto; transition: transform .15s var(--ease); }
.model-trigger.open .mt-caret { transform: rotate(180deg); }
.top-title {
  min-width: 0; max-width: 52vw; font-size: 12.5px; font-weight: 600; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.composer-model {
  height: 30px; max-width: 210px; padding: 2px 8px 2px 3px; gap: 6px; flex: 0 0 auto;
  border-color: var(--border-2); background: var(--surface);
}
.composer-model .mt-avatar { width: 22px; height: 22px; flex-basis: 22px; }
.composer-model .mt-avatar .logo-chip { width: 22px; height: 22px; border-radius: 6px; }
.composer-model .mt-name { font-size: 11.5px; max-width: 130px; }
.composer-model .mt-meta { display: none; }
.top-model {
  height: 36px; max-width: 280px; padding: 3px 9px 3px 3px;
  border-color: transparent; flex: 0 0 auto;
}
.top-model .mt-avatar { width: 26px; height: 26px; flex-basis: 26px; }
.top-model .mt-avatar .logo-chip { width: 26px; height: 26px; border-radius: 7px; }
.top-model .mt-name { font-size: 13px; max-width: 190px; }
.top-model .mt-meta { font-size: 10px; }
@media (max-width: 720px) {
  .top-model .mt-text { display: none; }
  .top-title { display: none; }
}
.media-model { flex: 0 0 auto; }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.mode-pill {
  font-size: 10.5px; line-height: 19px; padding: 0 8px; border-radius: 99px;
  color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: .5px solid color-mix(in srgb, var(--warn) 34%, transparent);
  white-space: nowrap;
}
.mode-pill.live { color: var(--ok); background: color-mix(in srgb, var(--ok) 11%, transparent); border-color: color-mix(in srgb, var(--ok) 32%, transparent); }

/* ---------- 滚动区 ---------- */
.scroll {
  flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
  scroll-behavior: smooth; position: relative;
}
.scroll-pad { height: 20px; }

/* ---------- 欢迎 ---------- */
.hero {
  max-width: var(--content-w); margin: 0 auto;
  padding: clamp(28px, 8vh, 92px) 24px 8px;
  transition: opacity .2s var(--ease);
}
.hero.hide { display: none; }
.hero-mark {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(150deg, var(--accent) 0%, var(--accent-strong) 100%);
  color: #fff; box-shadow: 0 8px 26px rgba(65, 118, 230, .32);
  margin-bottom: 18px;
}
.hero h1 { margin: 0 0 6px; font-size: clamp(22px, 3.2vw, 30px); font-weight: 650; letter-spacing: -.3px; }
.hero-sub { margin: 0 0 26px; color: var(--text-3); font-size: 13.5px; }
.suggests { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.suggest {
  text-align: left; display: grid; grid-template-columns: 26px 1fr; grid-template-rows: auto auto;
  column-gap: 10px; row-gap: 1px; align-items: center;
  padding: 13px 14px; border-radius: var(--radius-md);
  background: var(--surface); border: .5px solid var(--border-2);
  transition: border-color .15s var(--ease), background .15s var(--ease), transform .15s var(--ease);
}
.suggest:hover { border-color: var(--accent-line); transform: translateY(-1px); }
.suggest:active { transform: translateY(0); }
.sg-icon {
  grid-row: 1 / span 2; width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center; font-size: 13px;
  color: var(--accent); background: var(--accent-soft);
}
html[data-theme="dark"] .sg-icon { background: rgba(65, 118, 230, .15); }
.sg-title { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sg-desc { font-size: 11px; color: var(--text-4); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ---------- 消息 ---------- */
.messages { max-width: var(--content-w); margin: 0 auto; padding: 8px 24px 0; }
.msg { display: flex; gap: 12px; padding: 14px 0; }
.msg.user { flex-direction: row-reverse; }
.msg-avatar {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 8px; margin-top: 2px;
  display: grid; place-items: center; font-size: 10px; font-weight: 700; overflow: hidden;
}
.msg.assistant .msg-avatar { background: none; border: 0; }
.msg.assistant .msg-avatar .logo-chip { width: 28px; height: 28px; }
.msg.user .msg-avatar { color: var(--text-2); background: var(--surface-2); border: .5px solid var(--border-2); }

.msg-body { min-width: 0; max-width: calc(100% - 44px); }
.msg.user .msg-body { display: flex; flex-direction: column; align-items: flex-end; }
.msg-head { display: flex; align-items: center; gap: 7px; margin-bottom: 4px; min-height: 18px; }
.msg.user .msg-head { flex-direction: row-reverse; }
.msg-who { font-size: 11.5px; font-weight: 600; color: var(--text-2); }
.msg-model {
  font-size: 10px; color: var(--text-4); padding: 0 6px; line-height: 16px;
  border-radius: 99px; border: .5px solid var(--border-2);
}

/* 用户气泡 */
.msg.user .content.plain {
  background: var(--bubble-user); border: .5px solid var(--bubble-user-border);
  padding: 9px 13px; border-radius: 14px 14px 4px 14px;
  white-space: pre-wrap; word-break: break-word;
}
/* 助手内容 */
.msg.assistant .content {
  background: var(--bubble-assistant); border: .5px solid var(--bubble-assistant-border);
  padding: 12px 15px; border-radius: 4px 14px 14px 14px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.content { min-width: 0; max-width: 100%; overflow-wrap: anywhere; }
.content > :first-child { margin-top: 0; }
.content > :last-child { margin-bottom: 0; }

/* 思考块 */
.think {
  border: .5px solid var(--border-2); border-radius: var(--radius-sm);
  background: var(--surface-2); margin: 0 0 9px; overflow: hidden;
}
.think-head {
  display: flex; align-items: center; gap: 7px; width: 100%;
  padding: 7px 10px; font-size: 11.5px; color: var(--text-3); text-align: left;
}
.think-head:hover { color: var(--text-2); }
.think-dot {
  width: 6px; height: 6px; border-radius: 99px; background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
  animation: pulse 1.4s ease-in-out infinite;
}
.think.done .think-dot { animation: none; background: var(--text-4); box-shadow: none; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.think-caret { margin-left: auto; transition: transform .18s var(--ease); color: var(--text-4); }
.think.open .think-caret { transform: rotate(90deg); }
.think-body {
  display: none; padding: 2px 12px 10px; font-size: 12.5px; color: var(--text-3);
  white-space: pre-wrap; line-height: 1.7; border-top: .5px solid var(--border);
  max-height: 260px; overflow: auto;
}
.think.open .think-body { display: block; }

/* 等待态：骨架 + 阶段 + 计时 */
.msg.streaming .msg-body { min-width: min(380px, calc(100vw - 120px)); }
.wait-panel { margin-top: 8px; }
.wait-panel.bubble {
  margin-top: 0; padding: 14px 15px; border-radius: 4px 14px 14px 14px;
  background: var(--bubble-assistant); border: .5px solid var(--bubble-assistant-border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.wait-skel { display: flex; flex-direction: column; gap: 7px; margin: 2px 0 11px; }
.wait-skel i {
  height: 9px; border-radius: 99px; display: block;
  background: linear-gradient(90deg, var(--hover) 20%, var(--hover-strong) 38%, var(--hover) 56%);
  background-size: 300% 100%;
  animation: shimmer 1.5s var(--ease) infinite;
}
.wait-skel i:nth-child(1) { width: 78%; }
.wait-skel i:nth-child(2) { width: 92%; }
.wait-skel i:nth-child(3) { width: 54%; }
@keyframes shimmer { 0% { background-position: 120% 0; } 100% { background-position: -80% 0; } }

.wait-line { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--text-4); min-height: 18px; }
.wait-dot {
  width: 7px; height: 7px; border-radius: 99px; background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
  animation: pulse 1.2s ease-in-out infinite; flex: 0 0 7px;
}
.wait-label { color: var(--text-3); }
.wait-time { font-variant-numeric: tabular-nums; color: var(--text-4); }
.wait-hint { color: var(--warn); font-size: 10.5px; }
.wait-hint[hidden] { display: none; }
.composer.busy { border-color: var(--accent-line); }
.composer.busy .wait-dot { animation: pulse 1.2s ease-in-out infinite; }

/* 打字光标 */
.caret {
  display: inline-block; width: 7px; height: 15px; vertical-align: -2px;
  margin-left: 2px; border-radius: 1.5px; background: var(--accent);
  animation: blink 1s steps(1) infinite;
}
.gen-hint { display: inline-flex; align-items: center; gap: 4px; color: var(--text-4); font-size: 12px; }
.gen-hint i {
  width: 4px; height: 4px; border-radius: 99px; background: var(--text-4); opacity: .4;
  animation: dotpulse 1.2s ease-in-out infinite;
}
.gen-hint i:nth-child(2) { animation-delay: .18s; }
.gen-hint i:nth-child(3) { animation-delay: .36s; }
@keyframes dotpulse { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-1px); } }
@keyframes blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: 0; } }

/* 消息底部 */
.msg-foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 6px; font-size: 10.5px; color: var(--text-4);
}
.msg.user .msg-foot { justify-content: flex-end; }
.stat-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 0 6px; line-height: 17px; border-radius: 99px;
  background: var(--hover); border: .5px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.stat-chip b { font-weight: 600; color: var(--text-3); }
.stat-chip.cost b { color: var(--ok); }
.msg-actions { display: flex; gap: 2px; margin-left: 2px; opacity: 0; transition: opacity .15s var(--ease); }
.msg:hover .msg-actions { opacity: 1; }
.mini-btn {
  width: 24px; height: 22px; border-radius: 6px; display: grid; place-items: center;
  color: var(--text-4); transition: background .13s var(--ease), color .13s var(--ease);
}
.mini-btn:hover { background: var(--hover-strong); color: var(--text); }

/* ---------- Markdown ---------- */
.md p { margin: 0 0 .72em; }
.md h1, .md h2, .md h3, .md h4 { margin: 1.15em 0 .5em; line-height: 1.42; font-weight: 650; }
.md h1 { font-size: 1.34em; }
.md h2 { font-size: 1.2em; }
.md h3 { font-size: 1.08em; }
.md h4 { font-size: 1em; }
.md ul, .md ol { margin: 0 0 .72em; padding-left: 1.35em; }
.md li { margin: .18em 0; }
.md li > ul, .md li > ol { margin: .18em 0; }
.md a { color: var(--accent); text-decoration: none; border-bottom: .5px solid var(--accent-line); }
.md a:hover { border-bottom-color: var(--accent); }
.md strong { font-weight: 650; color: var(--text); }
.md em { font-style: italic; }
.md del { color: var(--text-4); }
.md hr { border: 0; border-top: .5px solid var(--border-2); margin: 1.1em 0; }
.md blockquote {
  margin: .7em 0; padding: 6px 12px; color: var(--text-3);
  border-left: 2px solid var(--accent-line); background: var(--hover);
  border-radius: 0 6px 6px 0;
}
.md blockquote p:last-child { margin-bottom: 0; }
.md code:not(pre code) {
  font-family: var(--font-mono); font-size: .88em;
  background: var(--inline-code); padding: .12em .4em; border-radius: 5px;
  border: .5px solid var(--border);
}
.md .table-wrap { overflow-x: auto; margin: .7em 0; border: .5px solid var(--border-2); border-radius: var(--radius-sm); }
.md table { border-collapse: collapse; width: 100%; font-size: .94em; }
.md th, .md td { padding: 6px 11px; text-align: left; border-bottom: .5px solid var(--table-line); white-space: nowrap; }
.md th { background: var(--table-head); font-weight: 600; color: var(--text-2); font-size: .95em; }
.md tr:last-child td { border-bottom: 0; }

/* 代码块 */
.codeblock {
  margin: .75em 0; border-radius: var(--radius-sm); overflow: hidden;
  border: .5px solid var(--border-2); background: var(--code-bg);
}
.code-head {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 12px;
  background: var(--code-head); border-bottom: .5px solid var(--border);
  font-size: 11px; color: var(--text-3);
}
.code-lang { font-family: var(--font-mono); letter-spacing: .3px; text-transform: lowercase; }
.code-copy {
  margin-left: auto; display: flex; align-items: center; gap: 4px;
  font-size: 10.5px; color: var(--text-3); padding: 1px 6px; border-radius: 5px;
}
.code-copy:hover { background: var(--hover-strong); color: var(--text); }
.codeblock pre { margin: 0; padding: 11px 13px; overflow-x: auto; }
.codeblock code {
  font-family: var(--font-mono); font-size: 12.4px; line-height: 1.65;
  color: var(--text-2); white-space: pre;
}
/* 轻量语法着色 */
.tok-key { color: #c792ea; }
.tok-str { color: #a5e075; }
.tok-num { color: #f78c6c; }
.tok-com { color: var(--text-4); font-style: italic; }
.tok-fn { color: #82aaff; }
html[data-theme="light"] .tok-key { color: #8b3ec9; }
html[data-theme="light"] .tok-str { color: #2f7d32; }
html[data-theme="light"] .tok-num { color: #b4520d; }
html[data-theme="light"] .tok-fn { color: #2158c9; }

/* ---------- 输入区 ---------- */
.composer-wrap {
  position: relative; flex: 0 0 auto; padding: 6px 24px 14px;
  background: linear-gradient(to top, var(--bg) 62%, transparent);
}
.composer {
  max-width: var(--content-w); margin: 0 auto;
  border-radius: var(--radius-lg); background: var(--input-bg);
  border: .5px solid var(--border-3);
  box-shadow: 0 8px 30px rgba(0, 0, 0, .10), 0 0 0 .5px rgba(0, 0, 0, .02);
  padding: 10px 10px 8px 14px; display: flex; flex-direction: column;
  transition: border-color .16s var(--ease), box-shadow .16s var(--ease);
}
.composer:focus-within {
  border-color: var(--accent-line);
  box-shadow: 0 8px 34px rgba(0, 0, 0, .12), 0 0 0 3px color-mix(in srgb, var(--accent) 11%, transparent);
}
.composer textarea {
  width: 100%; border: 0; outline: 0; resize: none; background: none;
  font: inherit; line-height: 1.6; color: var(--text);
  max-height: 220px; min-height: 24px; padding: 2px 2px 6px;
}
.composer textarea::placeholder { color: var(--text-4); }

.attach-row { display: flex; flex-wrap: wrap; gap: 7px; padding: 0 0 8px; }
.attach-item { position: relative; width: 56px; height: 56px; border-radius: 9px; overflow: hidden; border: .5px solid var(--border-2); }
.tool-btn.is-muted { opacity: .42; }
.attach-item img { width: 100%; height: 100%; object-fit: cover; }
.attach-item.uploading {
  display: grid; place-items: center; background: var(--surface-2);
  border-color: var(--accent-line);
}
.attach-item.uploading::before {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 20%, rgba(120, 150, 255, .14) 45%, transparent 70%);
  background-size: 220% 100%; animation: upload-shine 1.2s linear infinite;
}
.attach-item.uploading .up-spin {
  width: 17px; height: 17px; border-radius: 50%;
  border: 2px solid var(--border-3); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.attach-item.uploading .up-name {
  position: absolute; left: 0; right: 0; bottom: 2px; text-align: center;
  font-size: 8px; color: var(--text-3); padding: 0 2px;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
@keyframes upload-shine {
  from { background-position: 120% 0; }
  to { background-position: -120% 0; }
}
.attach-del {
  position: absolute; right: 2px; top: 2px; width: 17px; height: 17px; border-radius: 99px;
  display: grid; place-items: center; background: rgba(0, 0, 0, .62); color: #fff; font-size: 11px;
}

.composer-bar { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.cb-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cb-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.tool-btn {
  width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center;
  color: var(--text-3); border: .5px solid var(--border-2); background: var(--surface);
  transition: background .13s var(--ease), color .13s var(--ease), border-color .13s;
}
.tool-btn:hover { color: var(--text); border-color: var(--border-3); background: var(--surface-2); }
.est { font-size: 11px; color: var(--text-4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.price-chip {
  font-size: 10.5px; color: var(--text-3); white-space: nowrap;
  padding: 0 8px; line-height: 20px; border-radius: 99px;
  background: var(--hover); border: .5px solid var(--border);
  font-variant-numeric: tabular-nums;
}
.send {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: var(--accent-strong); color: #fff; flex: 0 0 auto;
  transition: background .14s var(--ease), transform .12s var(--ease), opacity .14s;
}
.send:hover { background: var(--accent); }
.send:active { transform: scale(.94); }
.send:disabled { opacity: .38; }
.send.stop { background: var(--text-2); color: var(--bg); }

.composer-tip {
  max-width: var(--content-w); margin: 6px auto 0;
  text-align: center; font-size: 10.5px; color: var(--text-4);
}
.chat-queue {
  border: .5px solid var(--border-2); border-radius: 10px; background: var(--surface);
  margin: 0 0 7px; overflow: hidden;
}
.cq-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 7px 10px; font-size: 11px; font-weight: 600; color: var(--text-2);
  cursor: pointer; user-select: none;
}
.cq-head .cq-count { display: inline-flex; align-items: center; gap: 6px; }
.cq-head .cq-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.cq-list { display: flex; flex-direction: column; gap: 1px; padding: 0 6px 6px; }
.cq-item { display: flex; align-items: center; gap: 8px; padding: 6px 4px; border-top: .5px solid var(--border); }
.cq-text { flex: 1; min-width: 0; font-size: 11.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cq-actions { display: flex; align-items: center; gap: 1px; flex: 0 0 auto; }
.cq-actions button { border: 0; background: none; color: var(--text-4); width: 24px; height: 24px; border-radius: 5px; cursor: pointer; display: grid; place-items: center; }
.cq-actions button:hover { background: var(--hover-strong); color: var(--text); }
.cq-actions button[data-qdel]:hover { color: var(--danger); }

.to-bottom {
  position: absolute; left: 50%; bottom: calc(100% + 2px); transform: translateX(-50%);
  width: 30px; height: 30px; border-radius: 99px; display: grid; place-items: center;
  background: var(--surface); border: .5px solid var(--border-3); color: var(--text-3);
  box-shadow: var(--shadow-soft); z-index: 5;
}
.to-bottom:hover { color: var(--text); background: var(--surface-2); }
.to-bottom.hidden { display: none; }

/* ---------- 模型选择面板 ---------- */
.picker-backdrop { position: fixed; inset: 0; z-index: 40; }
.picker {
  position: fixed; z-index: 50; width: min(460px, calc(100vw - 24px));
  max-height: min(560px, calc(100dvh - 96px));
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: blur(28px) saturate(170%);
  border: .5px solid var(--border-3); border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop); display: flex; flex-direction: column;
  overflow: hidden; transform-origin: top left;
  animation: pickerIn .16s var(--ease);
}
@keyframes pickerIn { from { opacity: 0; transform: translateY(-4px) scale(.985); } to { opacity: 1; } }
.picker.hidden { display: none; }
.picker-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px 8px;
  border-bottom: .5px solid var(--border);
}
.picker-search {
  flex: 1; display: flex; align-items: center; gap: 7px; height: 32px;
  padding: 0 10px; border-radius: var(--radius-xs);
  background: var(--hover); border: .5px solid transparent; color: var(--text-4);
}
.picker-search:focus-within { border-color: var(--accent-line); }
.picker-search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; font-size: 12.5px; }
.picker-hint { font-size: 10px; color: var(--text-4); white-space: nowrap; }
.picker-groups { overflow-y: auto; padding: 4px 6px 8px; }
.pg-label {
  display: flex; align-items: center; gap: 7px; padding: 10px 8px 5px;
  font-size: 11px; font-weight: 600; color: var(--text-3);
}
.pg-badge {
  font-size: 9.5px; font-weight: 500; padding: 0 5px; line-height: 15px; border-radius: 99px;
  color: var(--accent); background: var(--accent-soft); border: .5px solid var(--accent-line);
}
html[data-theme="dark"] .pg-badge { background: rgba(65, 118, 230, .15); }
.pg-badge.open { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.pg-badge.global { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.pg-desc { font-weight: 400; color: var(--text-4); font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-filters {
  display: flex; gap: 4px; padding: 8px 10px 6px; border-bottom: .5px solid var(--border);
}
.picker-filters button {
  flex: 1; height: 28px; border-radius: 7px; font-size: 11.5px; color: var(--text-3);
  background: var(--hover); border: .5px solid transparent;
}
.picker-filters button:hover { color: var(--text); }
.picker-filters button.on {
  color: var(--accent); background: var(--accent-soft);
  border-color: var(--accent-line); font-weight: 600;
}
html[data-theme="dark"] .picker-filters button.on { background: rgba(65, 118, 230, .16); }

.pg-section {
  display: flex; align-items: center; gap: 8px; padding: 12px 10px 5px;
  font-size: 11px; font-weight: 650; color: var(--text-2); letter-spacing: .3px;
}
.pg-section em { font-style: normal; font-weight: 400; font-size: 10px; color: var(--text-4); }
.pc-head {
  display: flex; align-items: center; gap: 8px; padding: 9px 10px 4px;
}
.pc-head .logo-chip { width: 22px; height: 22px; border-radius: 6px; }
.pc-head b { font-size: 12px; font-weight: 650; color: var(--text); }
.pc-head em { font-style: normal; font-size: 10px; color: var(--text-4); }
.pc-head .pc-sub { font-size: 9.5px; color: var(--text-4); }
.ps-label {
  padding: 5px 10px 2px 40px; font-size: 9.5px; color: var(--text-4);
  letter-spacing: .3px;
}
.pm-item {
  display: flex; align-items: center; gap: 9px; padding: 7px 9px 7px 22px; margin: 1px 0;
  border-radius: var(--radius-xs); cursor: pointer; border: .5px solid transparent;
}
.picker-filters.hidden { display: none; }
.pm-item:hover, .pm-item.cursor { background: var(--hover-strong); }
.pm-item.selected { background: var(--hover-strong); border-color: var(--accent-line); }
.pm-avatar {
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 7px; display: grid; place-items: center;
  overflow: hidden;
}
.pm-avatar .logo-chip { width: 26px; height: 26px; }
.pm-main { min-width: 0; flex: 1; }
.pm-row { display: flex; align-items: baseline; gap: 6px; }
.pm-name { font-size: 12.8px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-vendor { font-size: 10px; color: var(--text-4); white-space: nowrap; }
.pm-sub {
  display: flex; align-items: center; gap: 7px; font-size: 10.5px; color: var(--text-4);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.pm-caps { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-top: 3px; }
.pm-cap {
  font-size: 9.5px; line-height: 15px; padding: 0 6px; border-radius: 4px;
  color: var(--text-3); background: var(--hover); border: .5px solid var(--border);
}
.pm-tag {
  font-size: 9.5px; padding: 0 5px; line-height: 15px; border-radius: 4px;
  color: var(--text-3); background: var(--hover); border: .5px solid var(--border);
}
.pm-price { text-align: right; font-size: 10px; color: var(--text-4); white-space: nowrap; font-variant-numeric: tabular-nums; line-height: 1.45; }
.pm-price b { display: block; font-size: 11.5px; font-weight: 600; color: var(--text-2); }
.pm-price { text-align: right; }
.pm-check { width: 16px; color: var(--accent); flex: 0 0 16px; }
.picker-empty { padding: 26px; text-align: center; color: var(--text-4); font-size: 12.5px; }

/* ---------- 弹窗 ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60; background: var(--backdrop);
  display: grid; place-items: center; padding: 20px;
  backdrop-filter: blur(3px);
  animation: fadeIn .15s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } }
.modal {
  width: min(460px, 100%); max-height: min(86dvh, 760px); display: flex; flex-direction: column;
  background: var(--bg-elev); border: .5px solid var(--border-3); border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop); overflow: hidden;
  animation: modalIn .18s var(--ease);
}
.modal-wide { width: min(880px, 100%); }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px) scale(.99); } }
.modal-head {
  display: flex; align-items: flex-start; gap: 12px; padding: 16px 16px 12px 20px;
  border-bottom: .5px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 650; }
.modal-sub { margin: 3px 0 0; font-size: 11.5px; color: var(--text-4); line-height: 1.6; }
.modal-head .icon-btn { margin-left: auto; }
.modal-body { padding: 16px 20px 20px; overflow-y: auto; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px; margin-bottom: 16px; }
.stat-card {
  padding: 11px 12px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: .5px solid var(--border-2);
}
.stat-card .k { font-size: 10.5px; color: var(--text-4); margin-bottom: 3px; }
.stat-card .v { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; letter-spacing: -.2px; }
.stat-card .v small { font-size: 10px; font-weight: 500; color: var(--text-4); margin-left: 3px; }
.stat-card.hl .v { color: var(--ok); }

.bill-cols { display: grid; grid-template-columns: 1fr 1.35fr; gap: 12px; }
.bill-panel { border: .5px solid var(--border-2); border-radius: var(--radius-sm); padding: 11px 12px; background: var(--surface); }
.bill-panel h3, .recent-title { margin: 0 0 8px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.recent-title { margin: 16px 0 8px; }
.bill-list { display: flex; flex-direction: column; gap: 7px; max-height: 210px; overflow-y: auto; }
.bl-row { display: flex; align-items: center; gap: 8px; font-size: 11.5px; }
.bl-name { width: 92px; flex: 0 0 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.bl-bar { flex: 1; height: 5px; border-radius: 99px; background: var(--hover); overflow: hidden; }
.bl-bar i { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--accent-strong), var(--accent)); }
.bl-val { width: 76px; text-align: right; color: var(--text-3); font-variant-numeric: tabular-nums; }
.bl-empty { color: var(--text-4); font-size: 11.5px; padding: 8px 0; }

.table-wrap { overflow-x: auto; border: .5px solid var(--border-2); border-radius: var(--radius-sm); }
.bill-table { border-collapse: collapse; width: 100%; font-size: 11.5px; }
.bill-table th, .bill-table td { padding: 7px 10px; text-align: right; border-bottom: .5px solid var(--border); white-space: nowrap; }
.bill-table th { background: var(--table-head); color: var(--text-3); font-weight: 500; text-align: right; }
.bill-table th:first-child, .bill-table td:first-child { text-align: left; }
.bill-table td { color: var(--text-2); font-variant-numeric: tabular-nums; }
.bill-table tr:last-child td { border-bottom: 0; }
.bill-table .cost { color: var(--ok); }
.bill-empty { padding: 22px; text-align: center; color: var(--text-4); font-size: 12px; }

.set-row {
  display: flex; align-items: center; gap: 14px; padding: 13px 0;
  border-bottom: .5px solid var(--border);
}
.set-row:last-child { border-bottom: 0; }
.set-title { font-size: 13px; font-weight: 550; }
.set-desc { font-size: 11px; color: var(--text-4); margin-top: 2px; line-height: 1.6; }
.set-row > div:first-child { flex: 1; min-width: 0; }
.seg {
  display: flex; padding: 2px; border-radius: var(--radius-xs);
  background: var(--hover); border: .5px solid var(--border-2); gap: 2px;
}
.seg button {
  padding: 0 11px; height: 26px; border-radius: 6px; font-size: 11.5px; color: var(--text-3);
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .14); }
.badge-soft {
  font-size: 10.5px; padding: 0 8px; line-height: 21px; border-radius: 99px;
  color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent);
  border: .5px solid color-mix(in srgb, var(--warn) 30%, transparent); white-space: nowrap;
}
.badge-soft.live { color: var(--ok); background: color-mix(in srgb, var(--ok) 11%, transparent); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.btn-danger {
  height: 28px; padding: 0 12px; border-radius: var(--radius-xs); font-size: 12px;
  color: var(--danger); border: .5px solid color-mix(in srgb, var(--danger) 36%, transparent);
  background: color-mix(in srgb, var(--danger) 8%, transparent);
}
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 16%, transparent); }

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; z-index: 90; pointer-events: none;
}
.toast {
  padding: 8px 14px; border-radius: var(--radius-sm); font-size: 12.5px;
  background: var(--surface-3); color: var(--text); border: .5px solid var(--border-3);
  box-shadow: var(--shadow-pop); animation: toastIn .18s var(--ease);
  max-width: min(78vw, 460px); text-align: center;
}
.toast.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 34%, transparent); }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } }

/* ---------- 媒体创作 ---------- */
.media-wrap {
  max-width: 980px; margin: 0 auto; padding: 26px 24px 40px;
}
.media-head h1 { margin: 0 0 4px; font-size: 22px; font-weight: 650; letter-spacing: -.2px; }
.m-sub { margin: 0 0 10px; color: var(--text-3); font-size: 13px; line-height: 1.6; }
.m-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 16px; }
.m-chip {
  font-size: 10.5px; padding: 1px 8px; line-height: 18px; border-radius: 99px;
  color: var(--text-3); background: var(--hover); border: .5px solid var(--border-2);
}
.m-chip.accent { color: var(--accent); background: var(--accent-soft); border-color: var(--accent-line); }
html[data-theme="dark"] .m-chip.accent { background: rgba(65, 118, 230, .14); }

.media-form {
  background: var(--surface); border: .5px solid var(--border-2);
  border-radius: var(--radius-md); padding: 16px 16px 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .06);
}
.mf-prompt label { display: block; font-size: 11.5px; color: var(--text-3); margin-bottom: 6px; }
.mf-prompt textarea {
  width: 100%; border: .5px solid var(--border-2); outline: 0; resize: vertical;
  background: var(--bg-elev); border-radius: var(--radius-sm); padding: 10px 12px;
  font: inherit; line-height: 1.65; min-height: 92px; color: var(--text);
}
.mf-prompt textarea:focus { border-color: var(--accent-line); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent); }
.mf-hint { margin-top: 6px; font-size: 10.5px; color: var(--text-4); line-height: 1.65; }

.mf-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 4px; }
.mf-field { display: flex; flex-direction: column; gap: 5px; }
.mf-field label { font-size: 10.5px; color: var(--text-4); }
.mf-field select, .mf-field input[type="text"], .mf-field input[type="number"] {
  height: 32px; min-width: 96px; padding: 0 9px; border-radius: var(--radius-xs);
  background: var(--bg-elev); border: .5px solid var(--border-2);
  font-size: 12.5px; outline: 0; color: var(--text);
}
.mf-field select:focus, .mf-field input:focus { border-color: var(--accent-line); }
.mf-field.wide { flex: 1; min-width: 200px; }
.mf-field.wide textarea {
  width: 100%; min-height: 62px; resize: vertical; padding: 8px 10px;
  border-radius: var(--radius-xs); background: var(--bg-elev);
  border: .5px solid var(--border-2); font: inherit; font-size: 12.5px; outline: 0; color: var(--text);
}

.mf-refs { margin-top: 14px; padding-top: 12px; border-top: .5px solid var(--border); }
.mf-refs-head { display: flex; align-items: baseline; gap: 8px; font-size: 11.5px; color: var(--text-3); margin-bottom: 8px; }
.mf-refs-tip { font-size: 10px; color: var(--text-4); }
.mf-refs .attach-row { padding-bottom: 8px; }

.mf-foot { display: flex; align-items: center; gap: 12px; margin-top: 14px; padding-top: 12px; border-top: .5px solid var(--border); }
.mf-est { flex: 1; font-size: 11px; color: var(--text-4); min-width: 0; }
.primary-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 16px;
  border-radius: var(--radius-sm); background: var(--accent-strong); color: #fff;
  font-size: 13px; font-weight: 550; transition: background .15s var(--ease), transform .12s var(--ease), opacity .15s;
}
.primary-btn:hover { background: var(--accent); }
.primary-btn:active { transform: scale(.985); }
.primary-btn:disabled { opacity: .5; cursor: not-allowed; }
.primary-btn.small { height: 30px; padding: 0 12px; font-size: 12px; }
.ghost-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 11px;
  border-radius: var(--radius-xs); border: .5px solid var(--border-2);
  background: var(--bg-elev); color: var(--text-2); font-size: 12px;
}
.ghost-btn:hover { border-color: var(--border-3); background: var(--surface-2); color: var(--text); }
.link-btn { font-size: 11.5px; color: var(--text-4); }
.link-btn:hover { color: var(--text-2); }

.gallery-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 24px 0 10px;
}
.gallery-head h2 { margin: 0; font-size: 14px; font-weight: 600; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.gal-card {
  border-radius: var(--radius-md); overflow: hidden; background: var(--surface);
  border: .5px solid var(--border-2); display: flex; flex-direction: column;
  transition: border-color .15s var(--ease), transform .15s var(--ease);
}
.gal-card:hover { border-color: var(--accent-line); }
.gal-media {
  position: relative; background: var(--surface-2); display: grid; place-items: center;
  min-height: 150px; overflow: hidden;
}
.gal-media img, .gal-media video { width: 100%; height: auto; display: block; max-height: 420px; object-fit: contain; }
.gal-media.audio { min-height: 96px; padding: 14px; background: linear-gradient(140deg, var(--surface-2), var(--surface)); }
.gal-media.audio audio { width: 100%; }
.gal-card.audio-card { grid-column: 1 / -1; }
.gal-card.audio-card .gal-media { min-height: 0; }
.gal-card.audio-card .gal-body { flex-direction: row; align-items: center; gap: 14px; flex-wrap: wrap; }
.gal-card.audio-card .gal-prompt { flex: 1; min-width: 160px; -webkit-line-clamp: 2; }
.gal-media .track { display: flex; align-items: center; gap: 8px; width: 100%; }
.gal-media .track + .track { margin-top: 8px; }
.gal-media .track-no {
  width: 18px; height: 18px; flex: 0 0 18px; border-radius: 99px; display: grid; place-items: center;
  font-size: 10px; color: var(--text-3); background: var(--hover-strong);
}
.gal-media .track audio { flex: 1; min-width: 0; }
.gal-progress {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(3px);
}
.gal-progress .ring {
  width: 38px; height: 38px; border-radius: 99px;
  border: 2.5px solid var(--border-3); border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.gal-progress .pv { font-size: 17px; font-weight: 650; font-variant-numeric: tabular-nums; }
.gal-progress .ps { font-size: 11px; color: var(--text-3); }
.gal-body { padding: 9px 11px 10px; display: flex; flex-direction: column; gap: 5px; }
.gal-prompt {
  font-size: 11.5px; color: var(--text-2); line-height: 1.55;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.gal-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 10px; color: var(--text-4); }
.gal-meta .cost { color: var(--ok); }
.gal-actions { display: flex; gap: 6px; margin-top: 2px; flex-wrap: wrap; }
.gal-actions a, .gal-actions button {
  display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 8px;
  border-radius: 6px; border: .5px solid var(--border-2); background: var(--bg-elev);
  font-size: 10.5px; color: var(--text-3); text-decoration: none; white-space: nowrap;
}
.gal-actions a:hover, .gal-actions button:hover { color: var(--text); border-color: var(--border-3); }
.gal-error { padding: 16px 12px; font-size: 11.5px; color: var(--danger); line-height: 1.6; }
.gal-empty {
  grid-column: 1 / -1; padding: 34px 16px; text-align: center;
  color: var(--text-4); font-size: 12px; border: .5px dashed var(--border-2);
  border-radius: var(--radius-md); line-height: 1.9;
}

/* 设置：上游接入 */
.set-block { padding: 0 0 14px; border-bottom: .5px solid var(--border); margin-bottom: 4px; }
.set-block .set-title { margin-bottom: 10px; }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 10.5px; color: var(--text-4); margin-bottom: 5px; }
.field input {
  width: 100%; height: 32px; padding: 0 10px; border-radius: var(--radius-xs);
  background: var(--bg-elev); border: .5px solid var(--border-2);
  font-size: 12.5px; outline: 0; color: var(--text); font-family: var(--font-mono);
}
.field input:focus { border-color: var(--accent-line); }
.set-actions { display: flex; align-items: center; gap: 10px; }
.set-status { font-size: 11px; color: var(--text-4); }
.set-status.ok { color: var(--ok); }
.set-status.err { color: var(--danger); }

/* 单图预览 */
.attach-item.small { width: 48px; height: 48px; }

/* 响应式补充 */
@media (max-width: 860px) {
  .media-wrap { padding: 18px 14px 30px; }
  .gallery { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .modes { margin: 2px 8px 6px; }
}

/* ---------- 全权限模式 ---------- */
.agent-toggle {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px;
  border-radius: 99px; border: .5px solid var(--border-2); background: var(--bg-elev);
  font-size: 11px; color: var(--text-3); white-space: nowrap;
  transition: color .15s var(--ease), border-color .15s var(--ease), background .15s var(--ease);
}
.agent-toggle:hover { border-color: var(--border-3); color: var(--text-2); }
.agent-toggle .at-dot {
  width: 6px; height: 6px; border-radius: 99px; background: var(--text-4);
  transition: background .15s var(--ease), box-shadow .15s var(--ease);
}
.agent-toggle.on {
  color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent);
  background: color-mix(in srgb, var(--warn) 10%, transparent);
}
.agent-toggle.on .at-dot { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 20%, transparent); }
.agent-toggle.full { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 42%, transparent); background: color-mix(in srgb, var(--danger) 10%, transparent); }
.agent-toggle.full .at-dot { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 20%, transparent); }
.agent-toggle.pulse .at-dot { animation: pulse 1.3s ease-in-out infinite; }
.agent-toggle .at-gear {
  font-size: 10px; opacity: .55; margin-left: 1px; padding-left: 5px;
  border-left: .5px solid var(--border-2); line-height: 12px;
}
.agent-toggle .at-gear:hover { opacity: 1; }

.danger-note {
  display: flex; gap: 10px; padding: 10px 12px; margin-bottom: 6px;
  border-radius: var(--radius-sm); font-size: 11.5px; line-height: 1.65;
  color: var(--text-2); background: color-mix(in srgb, var(--danger) 8%, transparent);
  border: .5px solid color-mix(in srgb, var(--danger) 28%, transparent);
}
.danger-note strong { color: var(--danger); white-space: nowrap; }

.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: 0 0 38px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; border-radius: 99px; background: var(--hover-strong);
  border: .5px solid var(--border-2); transition: background .16s var(--ease);
}
.switch span::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 14px; height: 14px;
  border-radius: 99px; background: var(--text-3); transition: transform .16s var(--ease), background .16s;
}
.switch input:checked + span { background: var(--accent-strong); border-color: var(--accent-strong); }
.switch input:checked + span::after { transform: translateX(16px); background: #fff; }
.switch.danger input:checked + span { background: var(--danger); border-color: var(--danger); }

.set-row.col { flex-direction: column; align-items: stretch; gap: 9px; }
.level-list { display: flex; flex-direction: column; gap: 6px; }
.level-list label {
  display: flex; gap: 9px; align-items: flex-start; padding: 9px 11px;
  border-radius: var(--radius-sm); border: .5px solid var(--border-2);
  background: var(--bg-elev); cursor: pointer; font-size: 12px;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.level-list label:hover { border-color: var(--border-3); }
.level-list label:has(input:checked) { border-color: var(--accent-line); background: var(--accent-soft); }
html[data-theme="dark"] .level-list label:has(input:checked) { background: rgba(65, 118, 230, .12); }
.level-list input { margin-top: 2px; accent-color: var(--accent-strong); }
.level-list b { display: block; font-weight: 600; color: var(--text); }
.level-list i { display: block; font-style: normal; color: var(--text-4); font-size: 11px; margin-top: 1px; }

.mini-select {
  height: 30px; min-width: 80px; border-radius: var(--radius-xs); padding: 0 8px;
  background: var(--bg-elev); border: .5px solid var(--border-2); color: var(--text); font-size: 12.5px;
}
.tool-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 12px 0 6px; }
.tool-chips .m-chip { font-family: var(--font-mono); font-size: 10px; }
.set-actions.end { justify-content: flex-end; padding-top: 10px; }

/* 执行卡片 */
.tool-cards { display: flex; flex-direction: column; gap: 6px; margin: 2px 0 10px; }
.tool-card {
  border: .5px solid var(--border-2); border-radius: var(--radius-sm);
  background: var(--surface-2); overflow: hidden;
}
.tool-card.fail { border-color: color-mix(in srgb, var(--danger) 30%, transparent); }
.tool-card.denied { border-color: color-mix(in srgb, var(--warn) 36%, transparent); }
.tool-head {
  display: flex; align-items: center; gap: 7px; width: 100%;
  padding: 7px 10px; font-size: 11.5px; text-align: left; color: var(--text-2);
}
.tool-head:hover { background: var(--hover); }
.tool-ico {
  width: 18px; height: 18px; flex: 0 0 18px; border-radius: 5px; display: grid; place-items: center;
  font-size: 9px; font-family: var(--font-mono); color: var(--accent);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.tool-card.fail .tool-ico { color: var(--danger); background: color-mix(in srgb, var(--danger) 13%, transparent); }
.tool-card.denied .tool-ico { color: var(--warn); background: color-mix(in srgb, var(--warn) 13%, transparent); }
.tool-name { font-family: var(--font-mono); font-size: 11px; color: var(--text); }
.tool-preview {
  flex: 1; min-width: 0; color: var(--text-4); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-mono); font-size: 10.5px;
}
.tool-ref { color: var(--accent); font-size: 10px; padding: 1px 5px; border-radius: 4px; background: color-mix(in srgb, var(--accent) 12%, transparent); flex: 0 0 auto; }
.tool-badge { font-size: 9.5px; padding: 0 6px; line-height: 16px; border-radius: 99px; white-space: nowrap; }
.tool-badge.ok { color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, transparent); }
.tool-badge.fail { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.tool-badge.denied { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); }
.tool-badge.run { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.tool-body {
  display: none; border-top: .5px solid var(--border); padding: 8px 10px;
  font-family: var(--font-mono); font-size: 10.5px; line-height: 1.6;
  color: var(--text-3); white-space: pre-wrap; word-break: break-word;
  max-height: 260px; overflow: auto; background: var(--code-bg);
}
.tool-card.open .tool-body { display: block; }

/* 对话内出图 */
.tool-card.image-tool .tool-head { cursor: default; }
.tool-bar { height: 3px; margin: 0 10px 6px; border-radius: 99px; background: var(--hover); overflow: hidden; }
.tool-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-strong), var(--accent)); transition: width .4s var(--ease); }
.tool-stage { margin: -2px 10px 8px; font-size: 10px; color: var(--text-4); text-align: right; }
.tool-imgs { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 6px; padding: 0 10px 10px; }
.gen-img { position: relative; border-radius: var(--radius-sm); overflow: hidden; border: .5px solid var(--border-2); background: var(--surface-2); }
.gen-img .tool-img { border: 0; border-radius: 0; }
.gen-img video { width: 100%; max-height: 460px; display: block; background: #000; object-fit: contain; cursor: pointer; }
.tool-img { display: block; overflow: hidden; background: var(--surface-2); line-height: 0; }
.tool-img img { width: 100%; height: auto; display: block; max-height: 460px; object-fit: contain; transition: transform .2s var(--ease); }
.tool-img:hover img { transform: scale(1.012); }
.img-actions {
  position: absolute; left: 8px; bottom: 8px; z-index: 3; display: flex; gap: 6px;
  opacity: 1;
}
.img-actions button {
  height: 26px; padding: 0 10px; border-radius: 7px; border: 0; cursor: pointer;
  font-size: 11px; color: #fff; background: rgba(0, 0, 0, .55); backdrop-filter: blur(4px);
}
.img-actions button:hover { background: rgba(0, 0, 0, .75); }
.gal-actions button {
  height: 25px; padding: 0 8px; border-radius: 6px; border: 0; cursor: pointer;
  font-size: 11px; color: var(--text-2); background: transparent;
}
.gal-actions button:hover { color: var(--accent); background: var(--hover); }
.upscale-modal { width: min(760px, calc(100vw - 32px)); }
.upscale-stage {
  min-height: 260px; max-height: 64vh; overflow: auto; display: grid; place-items: center;
  border-radius: 10px; background: var(--surface-2); padding: 10px;
}
.upscale-stage img { max-width: 100%; height: auto; display: block; border-radius: 6px; }
.up-loading { display: flex; flex-direction: column; align-items: center; gap: 12px; color: var(--text-3); font-size: 12px; }
.up-loading .ring { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border-3); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
.tool-img img { width: 100%; height: auto; display: block; max-height: 460px; object-fit: contain; transition: transform .2s var(--ease); }
.tool-img:hover img { transform: scale(1.012); }
.agent-strip {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  padding: 5px 10px; margin-bottom: 8px; border-radius: var(--radius-sm);
  font-size: 10.5px; color: var(--text-3);
  background: color-mix(in srgb, var(--warn) 8%, transparent);
  border: .5px solid color-mix(in srgb, var(--warn) 24%, transparent);
}
.agent-strip b { color: var(--warn); font-weight: 600; }
.agent-strip .as-tool { font-family: var(--font-mono); color: var(--text-4); }

.audit-table td { font-size: 11px; }
.audit-table td.mono { font-family: var(--font-mono); font-size: 10.5px; color: var(--text-3); max-width: 380px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.audit-table .ok { color: var(--ok); }
.audit-table .bad { color: var(--danger); }
.audit-table .warn { color: var(--warn); }

/* 参考素材：按模型能力动态渲染 */
.mf-refs-body { display: flex; flex-direction: column; gap: 9px; }
.ref-block { border: .5px dashed var(--border-2); border-radius: var(--radius-sm); padding: 8px 10px 6px; }
.ref-head { display: flex; align-items: center; gap: 8px; }
.ref-title { font-size: 11.5px; color: var(--text-2); font-weight: 550; }
.ref-count { font-size: 10px; color: var(--text-4); font-variant-numeric: tabular-nums; }
.ref-add { margin-left: auto; height: 26px; padding: 0 9px; font-size: 11px; }
.ref-add:disabled { opacity: .45; cursor: not-allowed; }
.ref-hint { font-size: 9.5px; color: var(--text-4); margin-top: 4px; }
.mf-refs-none { font-size: 11px; color: var(--text-4); padding: 2px 0 4px; }
.attach-item.video video { width: 100%; height: 100%; object-fit: cover; display: block; }
.attach-name {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 1px 3px;
  font-size: 8.5px; color: #fff; background: rgba(0, 0, 0, .55);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.file-chip {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 9px; border-radius: 9px;
  border: .5px solid var(--border-2); background: var(--bg-elev); font-size: 11px; color: var(--text-2);
}
.file-ico {
  font-size: 9px; font-family: var(--font-mono); color: var(--accent);
  background: color-mix(in srgb, var(--accent) 13%, transparent);
  padding: 1px 4px; border-radius: 4px;
}
.file-name { max-width: 130px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.file-meta { font-size: 9.5px; color: var(--text-4); white-space: nowrap; }
.attach-del.inline {
  position: static; width: 16px; height: 16px; background: none; color: var(--text-4);
  font-size: 13px; line-height: 1; display: grid; place-items: center; border-radius: 4px;
}
.attach-del.inline:hover { background: var(--hover-strong); color: var(--text); }
.user-files { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; justify-content: flex-end; }

/* 用户消息附件 */
.user-imgs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; justify-content: flex-end; }
.user-img {
  width: 104px; height: 104px; border-radius: 10px; overflow: hidden;
  border: .5px solid var(--border-2); line-height: 0; background: var(--surface-2);
  padding: 0; cursor: zoom-in;
}
.user-img img { width: 100%; height: 100%; object-fit: cover; }

/* ---------- 登录 / 钱包 / 管理 ---------- */
.login-overlay {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center;
  background: rgba(18, 18, 20, .28);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}
.login-card {
  position: relative;
  width: min(380px, calc(100vw - 32px)); padding: 26px 24px 20px;
  background: var(--bg-elev); border: .5px solid var(--border-3); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-pop);
}
.login-close { position: absolute; top: 12px; right: 12px; }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.login-brand .brand-mark.lg { width: 38px; height: 38px; border-radius: 11px; }
.login-brand b { display: block; font-size: 17px; letter-spacing: -.2px; }
.login-brand span { font-size: 11.5px; color: var(--text-4); }
.wx-hero { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 4px 0 12px; }
.wx-logo-big {
  width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center;
  background: #07c160; color: #fff; box-shadow: 0 10px 26px rgba(7, 193, 96, .35);
}
.wx-title { font-size: 16px; font-weight: 650; letter-spacing: .2px; }
.login-tabs { display: flex; gap: 4px; padding: 3px; border-radius: var(--radius-sm); background: var(--hover); margin-bottom: 14px; }
.login-tabs button { flex: 1; height: 30px; border-radius: 7px; font-size: 12.5px; color: var(--text-3); }
.login-tabs button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .14); }
#authForm, #phoneForm, #loginForm, #registerForm, #resetForm { display: flex; flex-direction: column; gap: 10px; }
#authForm input, #phoneForm input, #loginForm input, #registerForm input, #resetForm input {
  height: 38px; padding: 0 12px; border-radius: var(--radius-xs);
  background: var(--bg); border: .5px solid var(--border-2); color: var(--text); font-size: 13px; outline: 0;
}
#authForm input:focus, #phoneForm input:focus, #loginForm input:focus,
#registerForm input:focus, #resetForm input:focus { border-color: var(--accent-line); }
#phoneForm .primary-btn, #loginForm .primary-btn, #registerForm .primary-btn, #resetForm .primary-btn { width: 100%; }
.login-switch { margin-top: 12px; text-align: center; font-size: 11px; color: var(--text-4); }
.login-switch a { color: var(--text-3); text-decoration: none; border-bottom: .5px solid var(--border-2); }
.login-switch a:hover { color: var(--accent); }
.admin-home { display: none; }
body.admin-entry .admin-home { display: block; }
body.admin-entry #authTabs,
body.admin-entry #loginForm,
body.admin-entry #registerForm,
body.admin-entry #resetForm,
body.admin-entry #adminLink { display: none !important; }
body.admin-entry #authForm { display: flex !important; }
body.admin-entry #authForm::before {
  content: "管理后台登录"; font-size: 12px; font-weight: 600; color: var(--text-2);
  margin-bottom: 2px;
}
#userDetailModal { z-index: 70; }
.primary-btn.lg { height: 40px; justify-content: center; font-size: 13.5px; }
.login-hint { margin-top: 12px; font-size: 11px; color: var(--text-4); text-align: center; line-height: 1.6; }
.login-hint.err { color: var(--danger); }

.user-card { display: flex; align-items: center; gap: 2px; padding: 3px 5px 3px 6px; border-radius: 9px; }
.user-card:hover { background: var(--hover); }
.user-main {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  padding: 4px 6px; border-radius: 7px; text-align: left; color: var(--text); cursor: pointer;
}
.user-main:hover { background: var(--hover-strong); }
.user-avatar {
  width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 11px; font-weight: 700; flex: 0 0 26px;
  overflow: hidden;
}
html[data-theme="dark"] .user-avatar { background: rgba(65, 118, 230, .16); }
.user-name { flex: 1; min-width: 0; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-gear { width: 24px; height: 24px; flex: 0 0 24px; color: var(--text-4); }
.user-gear:hover { color: var(--text); background: var(--hover-strong); }
.wallet-btn {
  display: inline-flex; align-items: baseline; gap: 3px; height: 24px; padding: 0 8px;
  border-radius: 99px; border: .5px solid color-mix(in srgb, var(--warn) 34%, transparent);
  background: color-mix(in srgb, var(--warn) 10%, transparent); color: var(--warn); font-size: 10.5px;
}
.wallet-btn b { font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; }

.wallet-modal { width: min(980px, calc(100vw - 40px)); max-height: 92vh; }
.wallet-modal .modal-body { padding: 20px 22px 18px; }

.wallet-hero {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 16px 18px; margin-bottom: 16px; border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(65, 118, 230, .22), rgba(65, 118, 230, .05));
  border: .5px solid var(--accent-line);
}
.wh-left span { font-size: 11.5px; color: var(--text-3); }
.wh-left div { display: flex; align-items: baseline; gap: 6px; margin-top: 2px; }
.wh-left b { font-size: 30px; font-weight: 750; letter-spacing: -.6px; }
.wh-left i { font-style: normal; font-size: 12px; color: var(--text-3); }
.wh-right { text-align: right; font-size: 11.5px; line-height: 1.7; color: var(--text-3); }
.wh-right span { font-size: 10.5px; color: var(--text-4); }

.wallet-sec { display: flex; align-items: baseline; gap: 8px; margin: 4px 0 10px; }
.wallet-sec b { font-size: 13px; }
.wallet-sec span { font-size: 11px; color: var(--text-4); }

.pkg-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.pkg {
  position: relative; text-align: left; padding: 13px 12px 11px; border-radius: 11px;
  border: .5px solid var(--border-2); background: var(--surface); cursor: pointer;
  transition: border-color .15s var(--ease), transform .15s var(--ease), background .15s var(--ease);
}
.pkg:hover { border-color: var(--accent-line); transform: translateY(-1px); background: var(--surface-2); }
.pkg.hot { border-color: rgba(247, 173, 49, .6); background: linear-gradient(180deg, rgba(247, 173, 49, .10), var(--surface) 60%); }
.pkg .pk-tag {
  position: absolute; right: 8px; top: 8px; font-size: 9px; padding: 0 6px; line-height: 15px;
  border-radius: 99px; color: var(--warn); background: rgba(247, 173, 49, .12);
  border: .5px solid rgba(247, 173, 49, .35);
}
.pkg .pk-price { font-size: 21px; font-weight: 750; letter-spacing: -.4px; }
.pkg .pk-price i { font-style: normal; font-size: 12px; font-weight: 500; color: var(--text-3); }
.pkg .pk-credits { font-size: 17px; font-weight: 700; margin-top: 2px; }
.pkg .pk-credits small { font-size: 10.5px; font-weight: 400; color: var(--text-3); margin-left: 2px; }
.pkg .pk-gift { font-size: 10.5px; color: var(--warn); margin-top: 2px; }
.pkg .pk-cta { font-size: 10.5px; color: var(--accent); margin-top: 7px; }

.wallet-bottom { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; margin-top: 12px; align-items: start; }
.wallet-bottom .custom-card, .wallet-bottom .gift-note { margin-top: 0; }

@media (max-width: 900px) {
  .wallet-modal { width: calc(100vw - 24px); }
  .pkg-grid { grid-template-columns: repeat(2, 1fr); }
  .wallet-bottom { grid-template-columns: 1fr; }
}

.custom-card {
  margin-top: 12px; padding: 14px; border-radius: 11px;
  border: .5px dashed var(--border-3); background: var(--surface);
}
.cc-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.cc-head b { font-size: 12.5px; }
.cc-head span { font-size: 10.5px; color: var(--text-4); }
.cc-row { display: flex; align-items: center; gap: 8px; }
.cc-yen { font-size: 16px; font-weight: 650; color: var(--text-2); }
.cc-row input {
  flex: 1; min-width: 0; height: 36px; padding: 0 10px; font-size: 14px;
  border-radius: 8px; border: .5px solid var(--border-2); background: var(--bg); color: var(--text); outline: 0;
}
.cc-row input:focus { border-color: var(--accent-line); }
#customAmount::-webkit-outer-spin-button, #customAmount::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#customAmount { -moz-appearance: textfield; appearance: textfield; }
.cc-row button {
  height: 36px; padding: 0 16px; border-radius: 8px; border: 0;
  background: var(--accent-deep); color: #fff; font-size: 12.5px; font-weight: 600; cursor: pointer;
}
.cc-row button:hover { background: var(--accent); }
.cc-preview { margin-top: 8px; font-size: 11px; color: var(--text-3); }
.cc-preview b { color: var(--warn); }

.gift-note { margin-top: 12px; padding: 11px 13px; border-radius: 10px; background: var(--hover); }
.gn-title { font-size: 10.5px; color: var(--text-3); margin-bottom: 6px; }
.gn-tiers { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 10.5px; color: var(--text-4); }
.gn-tiers b { color: var(--warn); }
.pay-panel { display: flex; gap: 16px; align-items: center; margin-top: 14px; padding: 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: .5px solid var(--border-2); }
.pay-qr { flex: 0 0 auto; width: 188px; height: 188px; border-radius: 10px; background: #fff; padding: 8px; }
.pay-qr svg, .pay-qr img { width: 172px; height: 172px; display: block; }
.mock-qr {
  height: 100%; display: grid; place-content: center; text-align: center;
  color: #333; font-size: 13px; line-height: 1.7;
}
.mock-qr span { font-size: 11px; color: #888; }
.pay-title { font-size: 13px; font-weight: 600; }
.pay-sub { font-size: 11px; color: var(--text-4); margin-top: 3px; word-break: break-all; }
.pay-status { font-size: 11.5px; color: var(--accent); margin-top: 8px; }
.pay-info .ghost-btn { margin-top: 10px; }
.redeem-row { display: flex; gap: 8px; margin-top: 14px; }
.redeem-row input {
  flex: 1; height: 32px; padding: 0 10px; border-radius: var(--radius-xs);
  background: var(--bg); border: .5px solid var(--border-2); color: var(--text); font-size: 12px; outline: 0;
}
.ledger-list { display: flex; flex-direction: column; gap: 1px; max-height: 220px; overflow: auto; }
.ledger-row { display: flex; align-items: center; gap: 10px; padding: 6px 2px; border-bottom: .5px solid var(--border); font-size: 11.5px; }
.ledger-row .lg-note { flex: 1; min-width: 0; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ledger-row .lg-time { color: var(--text-4); font-size: 10px; }
.ledger-row .lg-delta { width: 62px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.ledger-row .lg-delta.plus { color: var(--ok); }
.ledger-row .lg-delta.minus { color: var(--text-3); }

.admin-tools { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: .5px solid var(--border-2); margin-bottom: 6px; }
.field.inline { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11.5px; color: var(--text-3); }
.field.inline input { width: 84px; height: 28px; padding: 0 8px; border-radius: 6px; background: var(--bg); border: .5px solid var(--border-2); color: var(--text); font-size: 12px; }
.codes-out { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.codes-out code {
  font-family: var(--font-mono); font-size: 11px; padding: 2px 7px; border-radius: 5px;
  background: var(--code-bg); border: .5px solid var(--border-2); color: var(--text-2); user-select: all;
}
.credit-adjust { display: flex; gap: 4px; align-items: center; white-space: nowrap; }
.credit-adjust input { width: 64px; height: 24px; padding: 0 6px; border-radius: 5px; background: var(--bg); border: .5px solid var(--border-2); color: var(--text); font-size: 11px; }
.credit-adjust button { height: 24px; padding: 0 7px; font-size: 10.5px; border-radius: 5px; border: .5px solid var(--border-2); color: var(--text-2); }
.credit-adjust button:hover { border-color: var(--accent-line); color: var(--text); }

/* ---------- 手机号登录 / 实名 / 广告位 ---------- */
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; min-width: 0; }
.code-row .ghost-btn { height: 38px; flex: 0 0 112px; justify-content: center; }
.code-row .ghost-btn:disabled { opacity: .5; cursor: not-allowed; }
.safe-note {
  padding: 9px 11px; margin-bottom: 12px; border-radius: var(--radius-sm);
  font-size: 11px; line-height: 1.6; color: var(--text-3);
  background: color-mix(in srgb, var(--ok) 7%, transparent);
  border: .5px solid color-mix(in srgb, var(--ok) 24%, transparent);
}

.ad-banner {
  max-width: var(--content-w); margin: 14px auto 0; padding: 0 24px;
}
.ad-banner .ad-item, .ad-card, .ad-login {
  position: relative; display: block; border-radius: var(--radius-md); overflow: hidden;
  border: .5px solid var(--border-2); background: var(--surface);
  text-decoration: none; color: var(--text-2);
}
.ad-banner .ad-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
.ad-banner img { width: 100%; max-height: 110px; object-fit: cover; display: block; }
.ad-card { margin: 6px 10px 8px; padding: 10px 11px; font-size: 11.5px; line-height: 1.6; }
.ad-login { margin-top: 14px; padding: 9px 11px; font-size: 11px; line-height: 1.6; }
.ad-item .ad-kicker { font-size: 9.5px; color: var(--text-4); letter-spacing: .5px; }
.ad-item .ad-title { font-weight: 600; color: var(--text); font-size: 12.5px; }
.ad-item .ad-desc { color: var(--text-4); font-size: 11px; }
.ad-placeholder { border-style: dashed; color: var(--text-4); text-align: center; }
.ad-placeholder .ad-title { color: var(--text-3); }
.ad-item:hover { border-color: var(--accent-line); }

@media (max-width: 860px) {
  .ad-banner { padding: 0 14px; }
  .ad-card { display: none; }
}

/* 首屏鉴权中的占位，避免已登录用户刷新时闪一下登录框 */
.boot-splash {
  position: fixed; inset: 0; z-index: 200; display: grid; place-content: center;
  justify-items: center; gap: 14px; background: var(--bg); color: var(--text-3); font-size: 12px;
}
.boot-splash.hidden { display: none; }
.boot-splash .boot-logo {
  width: 54px; height: 54px; border-radius: 14px; display: grid; place-items: center;
  background: transparent;
}
.boot-splash .boot-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.boot-splash p { margin: 0; }

#userAvatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }
.wechat-btn {
  width: 100%; height: 42px; border: 0; border-radius: var(--radius-sm);
  background: #07c160; color: #fff; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer;
}
.wechat-btn:hover { background: #06ad56; }
.wechat-btn:disabled { opacity: .55; cursor: not-allowed; }
.wechat-refresh {
  width: 100%; height: 34px; margin-top: 12px; justify-content: center; font-size: 12px;
}
.wechat-refresh:disabled { opacity: .5; cursor: not-allowed; }
.wechat-qr {
  margin: 10px auto 0; width: 168px; height: 168px; padding: 8px;
  background: #fff; border-radius: 10px; display: grid; place-items: center;
}
.wechat-qr canvas, .wechat-qr img, .wechat-qr svg { width: 152px; height: 152px; display: block; }

/* ---------- 本地执行器 ---------- */
.local-steps { margin: 0 0 14px; padding-left: 18px; font-size: 12px; line-height: 1.9; color: var(--text-2); }
.local-steps a { color: var(--accent); }
.local-steps code { background: var(--hover-strong); padding: 1px 5px; border-radius: 4px; }
.local-note {
  margin: -4px 0 12px; padding: 9px 11px; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--warn) 8%, transparent);
  border: .5px solid color-mix(in srgb, var(--warn) 28%, transparent);
  font-size: 11px; line-height: 1.7; color: var(--text-3);
}
.local-info {
  margin-top: 12px; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--surface); border: .5px solid var(--border-2); font-size: 11.5px; line-height: 1.8;
}
.local-out {
  margin: 10px 0 0; padding: 10px 12px; background: var(--bg); border: .5px solid var(--border-2);
  border-radius: var(--radius-sm); font-size: 11px; max-height: 220px; overflow: auto; white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--text-2);
}

/* 侧栏建议入口 */
.suggest-cta {
  display: flex; align-items: center; gap: 9px; margin: 8px 10px 6px; padding: 9px 11px;
  border-radius: 10px; border: .5px solid var(--border-2); background: var(--surface);
  color: var(--text); text-align: left; cursor: pointer;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.suggest-cta:hover { border-color: var(--accent-line); background: var(--surface-2); }
.sc-ico {
  flex: none; width: 26px; height: 26px; border-radius: 8px;
  display: grid; place-items: center; font-size: 14px;
  background: rgba(247, 173, 49, .15);
}
.sc-text { min-width: 0; }
.sc-text b { display: block; font-size: 11.5px; font-weight: 600; color: var(--text); }
.sc-text em { display: block; font-style: normal; font-size: 10px; color: var(--text-4); margin-top: 1px; }
.sc-arrow { margin-left: auto; font-size: 13px; color: var(--text-4); }
.suggest-cta:hover .sc-arrow { color: var(--accent); }
#suggestText {
  width: 100%; min-height: 120px; padding: 10px 12px; border-radius: 8px;
  border: .5px solid var(--border-2); background: var(--bg); color: var(--text);
  font: 12.5px/1.7 var(--font); resize: vertical; outline: 0;
}
#suggestText:focus { border-color: var(--accent-line); }

.billing-modal { width: min(620px, calc(100vw - 32px)); }
.billing-summary {
  display: flex; gap: 18px; padding: 12px 14px; margin-bottom: 12px;
  border-radius: 10px; background: var(--hover); font-size: 12px; color: var(--text-3);
}
.billing-summary b { font-size: 18px; color: var(--text); margin-left: 4px; }
.billing-list { max-height: 400px; overflow: auto; }

/* 设置：从侧栏用户区上拉的小面板 */
#settingsModal {
  place-items: end start;
  padding: 0 0 70px 10px;
  background: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}
#settingsModal .modal {
  width: min(372px, calc(100vw - 24px));
  max-height: min(620px, calc(100vh - 120px));
  border-radius: 14px;
  animation: settings-up .16s var(--ease);
}
@keyframes settings-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.link-btn {
  border: 0; padding: 0; background: none; color: var(--accent); font: inherit; cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}
.link-btn:hover { color: var(--accent-strong); }
.attach-wrap { position: relative; display: flex; }
.attach-menu {
  position: absolute; left: 0; bottom: calc(100% + 8px); z-index: 60;
  width: 164px; padding: 5px; border-radius: 10px;
  background: var(--bg-elev); border: .5px solid var(--border-3);
  box-shadow: var(--shadow-pop); animation: attach-up .14s var(--ease);
}
.attach-menu button {
  display: flex; align-items: center; gap: 9px; width: 100%; height: 34px; padding: 0 9px;
  border-radius: 7px; font-size: 12px; color: var(--text-2); text-align: left;
}
.attach-menu button:hover { background: var(--hover-strong); color: var(--text); }
.attach-menu button svg { color: var(--text-3); flex: 0 0 auto; }
@keyframes attach-up {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- 右侧预览抽屉 ---------- */
.pd-mask { position: fixed; inset: 0; z-index: 175; background: rgba(0, 0, 0, .18); }
.preview-drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 180;
  width: min(520px, 92vw); display: flex; flex-direction: column;
  background: var(--bg-elev); border-left: .5px solid var(--border-3);
  box-shadow: -18px 0 50px rgba(0, 0, 0, .28);
  transform: translateX(102%); transition: transform .2s var(--ease);
}
.preview-drawer.open { transform: translateX(0); }
.app.preview-open { padding-right: min(520px, 92vw); transition: padding-right .2s var(--ease); }
@media (max-width: 900px) {
  .app.preview-open { padding-right: 0; }
}
.pd-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border-bottom: .5px solid var(--border-2); flex: 0 0 auto;
}
.pd-tabs { display: flex; gap: 4px; padding: 3px; border-radius: 8px; background: var(--hover); }
.pd-tabs button { height: 28px; padding: 0 14px; border-radius: 6px; font-size: 12px; color: var(--text-3); }
.pd-tabs button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.pd-head .icon-btn { margin-left: auto; }
.pd-body { flex: 1; min-height: 0; overflow: auto; padding: 16px; display: grid; place-items: center; }
.pd-body img, .pd-body video { max-width: 100%; max-height: calc(100vh - 110px); display: block; border-radius: 8px; }
.pd-text {
  width: 100%; align-self: start; margin: 0; white-space: pre-wrap; word-break: break-word;
  font: 13px/1.8 var(--font); color: var(--text); background: var(--surface-2);
  border: .5px solid var(--border-2); border-radius: 10px; padding: 14px;
}
.pd-empty { color: var(--text-4); font-size: 12.5px; text-align: center; line-height: 1.8; }
.pd-actions { display: flex; gap: 8px; margin-top: 12px; justify-content: center; flex-wrap: wrap; }
.gal-media img, .user-img img { cursor: zoom-in; }
.gal-media video { cursor: pointer; }
.tool-img { border: 0; padding: 0; width: 100%; background: transparent; cursor: zoom-in; }
.doc-list { display: flex; flex-direction: column; gap: 6px; margin: 2px 0 16px; }
.doc-link {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border-radius: var(--radius-sm); border: .5px solid var(--border-2);
  background: var(--surface); color: var(--text-2); font-size: 12.5px; cursor: pointer; text-align: left;
}
.doc-link:hover { border-color: var(--accent-line); color: var(--text); }
.doc-link span { color: var(--text-4); }
.doc-body { font-size: 13px; line-height: 1.85; color: var(--text-2); }
.doc-body h2 { font-size: 15px; color: var(--text); margin: 0 0 12px; }
.doc-body h3 { font-size: 13px; color: var(--text); margin: 18px 0 6px; }
.doc-body p { margin: 6px 0; }
.doc-body ul { margin: 4px 0 10px; padding-left: 18px; }
.doc-body li { margin: 3px 0; }
.doc-body b { color: var(--text); }
.doc-body code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 11.5px;
  background: var(--hover-strong); padding: 1px 5px; border-radius: 4px;
}

/* ---------- 响应式 ---------- */
@media (max-width: 1100px) and (min-width: 861px) {
  .suggests { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw);
    box-shadow: var(--shadow-pop); transform: translateX(-100%);
    transition: transform .22s var(--ease); margin: 0 !important; opacity: 1 !important;
    pointer-events: auto !important;
  }
  .app.mobile-open .sidebar { transform: translateX(0); }
  .app.collapsed .sidebar { transform: translateX(-100%); }
  .only-mobile { display: grid; }
  .topbar { padding: 0 10px; gap: 6px; }
  .mt-name { max-width: 46vw; }
  .mt-meta { max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
  .suggests { grid-template-columns: 1fr; }
  .messages { padding: 6px 14px 0; }
  .composer-wrap { padding: 6px 12px 10px; }
  .hero { padding: 26px 16px 6px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bill-cols { grid-template-columns: 1fr; }
  .mode-pill { display: none; }
  .brand-pill-name { display: none; }
  .brand-pill { padding: 0 4px; }
  .price-chip { display: none; }
  .msg-body { max-width: calc(100% - 40px); }
}
@media (max-width: 520px) {
  .mt-text { display: none; }
  .tool-btn { display: none; }
  .composer-tip { display: none; }
  .composer-wrap { padding: 6px 10px 8px; }
  .topbar { height: 52px; flex-basis: 52px; }
  .topbar-right { gap: 2px; }
}
/* ================= 充值窗口 v2（蓝紫渐变布局） ================= */
.wallet-modal { width: min(1180px, calc(100vw - 40px)); max-height: 92vh; }
.wallet-modal .modal-body { padding: 20px 22px 22px; }

.wallet-hero {
  color: #fff;
  background:
    radial-gradient(620px 220px at 88% -30%, rgba(150, 90, 255, .45), transparent 62%),
    radial-gradient(420px 160px at 8% 120%, rgba(70, 130, 255, .28), transparent 65%),
    linear-gradient(120deg, #162856 0%, #1d1b4d 55%, #24123f 100%);
  border: 1px solid rgba(130, 150, 255, .35);
  box-shadow: inset 0 0 0 1px rgba(180, 160, 255, .08), 0 12px 40px rgba(80, 60, 220, .18);
  padding: 18px 20px;
}
.wh-left b { font-size: 38px; color: #fff; }
.wh-left span { color: rgba(220, 228, 255, .72); }
.wh-left i { color: rgba(220, 228, 255, .6); }
.wh-right { color: rgba(220, 228, 255, .7); }
.wh-right span { color: rgba(200, 210, 240, .5); }

.pkg-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.pkg {
  min-height: 132px; padding: 13px 12px 11px; border-radius: 12px;
  border: 1px solid var(--border-2);
  background: linear-gradient(180deg, rgba(255, 255, 255, .035), transparent 70%), var(--surface);
}
.pkg:hover { border-color: rgba(130, 150, 255, .55); background: var(--surface-2); }
.pkg.hot {
  border-color: rgba(145, 130, 255, .65);
  background:
    radial-gradient(150px 90px at 80% 0%, rgba(160, 100, 255, .35), transparent 72%),
    linear-gradient(160deg, rgba(80, 120, 255, .16), rgba(140, 80, 255, .10)),
    var(--surface);
  box-shadow: 0 10px 30px rgba(90, 80, 255, .25), inset 0 0 0 1px rgba(170, 150, 255, .12);
}
.pkg .pk-price { font-size: 24px; }
.pkg .pk-credits { font-size: 20px; }
.pkg .pk-tag {
  color: #f5c56a; background: rgba(247, 173, 49, .12);
  border: .5px solid rgba(247, 173, 49, .35);
}
.pkg.hot .pk-tag { color: #ffd98a; background: rgba(247, 173, 49, .18); }
.pkg .pk-cta { color: #9db4ff; }

.wallet-cols { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 14px; margin-top: 14px; align-items: start; }
.wallet-main { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.wallet-side { display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.custom-card {
  margin-top: 0;
  border: 1px dashed rgba(130, 140, 255, .35);
  background: linear-gradient(180deg, rgba(255, 255, 255, .025), transparent 70%), var(--surface);
}
.cc-row button { background: linear-gradient(135deg, #4b7bff, #9a5cff); }
.cc-row button:hover { filter: brightness(1.08); }

.gift-note { margin-top: 0; background: var(--surface); border: 1px solid var(--border-2); border-radius: 12px; padding: 12px 14px; }
.wallet-ledger { background: var(--surface); border: 1px solid var(--border-2); border-radius: 12px; padding: 12px 14px; }
.wallet-ledger-head { font-size: 13px; font-weight: 650; margin-bottom: 8px; }
.wallet-ledger .ledger-list { max-height: 380px; }
.wallet-ledger .ledger-row { padding: 8px 2px; }

.pay-placeholder {
  min-height: 300px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 24px; border-radius: 14px;
  background:
    radial-gradient(420px 220px at 50% 0%, rgba(100, 110, 255, .12), transparent 70%),
    var(--surface);
  border: 1px dashed rgba(130, 140, 255, .28);
}
.pp-ico {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  color: #07c160; background: rgba(7, 193, 96, .12); border: .5px solid rgba(7, 193, 96, .25);
}
.pp-title { font-size: 14px; font-weight: 650; }
.pp-sub { font-size: 11.5px; color: var(--text-4); text-align: center; line-height: 1.75; }

.pay-panel {
  display: flex; flex-direction: column; align-items: center; gap: 9px;
  margin-top: 0; padding: 18px 16px 16px; border-radius: 14px;
  background:
    radial-gradient(420px 200px at 50% 0%, rgba(120, 90, 255, .20), transparent 70%),
    var(--surface);
  border: 1px solid rgba(130, 120, 255, .28);
}
.pay-head { display: flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 650; }
.pay-wx { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: #07c160; color: #fff; }
.pay-badge { font-size: 10px; padding: 0 7px; line-height: 17px; border-radius: 99px; color: #ffd98a; background: rgba(247, 173, 49, .16); border: .5px solid rgba(247, 173, 49, .35); }
.pay-qr { width: 196px; height: 196px; border-radius: 12px; background: #fff; padding: 8px; box-shadow: 0 6px 20px rgba(0, 0, 0, .18); }
.pay-qr svg, .pay-qr img { width: 180px; height: 180px; display: block; }
.pay-note { font-size: 12.5px; color: var(--text-2); }
.pay-sub { font-size: 11.5px; color: var(--text-3); }
.pay-status { font-size: 11px; color: var(--text-4); text-align: center; word-break: break-all; }
.pay-info .ghost-btn { margin-top: 0; }

@media (max-width: 1000px) {
  .wallet-modal { width: calc(100vw - 24px); }
  .pkg-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .wallet-cols { grid-template-columns: 1fr; }
}
@media (max-width: 620px) {
  .wallet-modal { width: calc(100vw - 16px); }
  .pkg-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wallet-hero { flex-direction: column; align-items: flex-start; gap: 8px; }
  .wh-right { text-align: left; }
}
