/* ============================================================
   棱镜 Prism · 设计系统
   8pt 间距 · 4 级圆角 · 三段缓动 · 双主题（light / dark）
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --bg: #F4F5FA;
  --bg-2: #EDEFF7;
  --surface: #FFFFFF;
  --surface-2: #FAFBFE;
  --surface-3: #F2F4FA;
  --line: rgba(17, 22, 40, .075);
  --line-2: rgba(17, 22, 40, .13);
  --t1: #12152A;
  --t2: #4C5266;
  --t3: #868DA3;
  --t4: #AEB4C6;

  --brand: #635BFF;
  --brand-2: #4D8DFF;
  --brand-3: #2FD3E2;
  --brand-ink: #4B42E0;
  --brand-soft: #EFEDFF;
  --brand-ring: rgba(99, 91, 255, .18);
  --grad: linear-gradient(135deg, #7B61FF 0%, #4D8DFF 52%, #35D2E6 100%);
  --grad-soft: linear-gradient(135deg, rgba(123,97,255,.12), rgba(53,210,230,.12));

  --ok: #0FA36B;
  --ok-soft: #E8F8F1;
  --warn: #E59424;
  --warn-soft: #FFF6E6;
  --err: #E5484D;
  --err-soft: #FDECEC;

  --shadow-1: 0 1px 2px rgba(16, 20, 40, .04), 0 6px 20px -10px rgba(16, 20, 40, .18);
  --shadow-2: 0 2px 6px rgba(16, 20, 40, .05), 0 24px 48px -24px rgba(16, 20, 40, .32);
  --shadow-pop: 0 12px 40px -12px rgba(16, 20, 40, .28);

  --r-xs: 8px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-full: 999px;

  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-io: cubic-bezier(.4, 0, .2, 1);
  --dur: .22s;

  --side-w: 276px;
  --header-h: 64px;
  --maxw: 860px;
}

[data-theme="dark"] {
  --bg: #08090F;
  --bg-2: #0C0E16;
  --surface: #111319;
  --surface-2: #161922;
  --surface-3: #1C202B;
  --line: rgba(255, 255, 255, .07);
  --line-2: rgba(255, 255, 255, .13);
  --t1: #EFF1F7;
  --t2: #A8AFC2;
  --t3: #767D93;
  --t4: #565D72;

  --brand: #7E74FF;
  --brand-ink: #B4AEFF;
  --brand-soft: #1D2033;
  --brand-ring: rgba(126, 116, 255, .3);
  --grad: linear-gradient(135deg, #8B6BFF 0%, #4E92FF 52%, #2FD3E2 100%);
  --grad-soft: linear-gradient(135deg, rgba(139,107,255,.16), rgba(47,211,226,.12));

  --ok: #34D399; --ok-soft: #0E2A22;
  --warn: #F2B24C; --warn-soft: #2A2213;
  --err: #FF6B70; --err-soft: #2C1518;

  --shadow-1: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px -16px rgba(0,0,0,.8);
  --shadow-2: 0 2px 8px rgba(0,0,0,.5), 0 30px 60px -30px rgba(0,0,0,.9);
  --shadow-pop: 0 20px 60px -18px rgba(0,0,0,.9);
}

@media (prefers-color-scheme: dark) {
  html:not([data-theme-locked]) { color-scheme: dark; }
}

* { -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--t1);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  transition: background .3s var(--ease-io), color .3s var(--ease-io);
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--brand); text-decoration: none; }
::selection { background: var(--brand-ring); }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--t4); background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

.ic { width: 20px; height: 20px; flex: none; display: block; }
.ic-xs { width: 14px; height: 14px; }
.ic-sm { width: 17px; height: 17px; }

/* ============ 棱镜背景 ============ */
.aurora-field { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.aurora-field .blob { position: absolute; border-radius: 50%; filter: blur(90px); opacity: .55; will-change: transform; }
.aurora-field .b1 { width: 620px; height: 620px; left: -220px; top: -260px; background: radial-gradient(circle at 30% 30%, #7B61FF, transparent 70%); animation: drift1 26s var(--ease-io) infinite alternate; opacity: .5; }
.aurora-field .b2 { width: 760px; height: 760px; right: -320px; top: -260px; background: radial-gradient(circle at 60% 40%, #37D3F0, transparent 68%); animation: drift2 32s var(--ease-io) infinite alternate; opacity: .34; }
.aurora-field .b3 { width: 560px; height: 560px; left: 24%; bottom: -360px; background: radial-gradient(circle at 50% 50%, #FF7BC8, transparent 70%); animation: drift3 30s var(--ease-io) infinite alternate; opacity: .16; }
[data-theme="dark"] .aurora-field .blob { opacity: .3; filter: blur(110px); }
@keyframes drift1 { to { transform: translate3d(80px, 60px, 0) scale(1.12); } }
@keyframes drift2 { to { transform: translate3d(-70px, 90px, 0) scale(1.06); } }
@keyframes drift3 { to { transform: translate3d(60px, -80px, 0) scale(1.14); } }
.aurora-field .grain {
  position: absolute; inset: 0; opacity: .035; mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-theme="dark"] .aurora-field .grain { opacity: .06; mix-blend-mode: overlay; }

/* ============ 通用组件 ============ */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px; border-radius: var(--r-md);
  font-size: 14.5px; font-weight: 600; letter-spacing: .01em;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur), border-color var(--dur), opacity var(--dur);
  user-select: none; white-space: nowrap;
}
.btn:active:not(:disabled) { transform: scale(.975); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  color: #fff; background: var(--grad);
  box-shadow: 0 8px 22px -10px rgba(77, 141, 255, .9), inset 0 1px 0 rgba(255,255,255,.28);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 14px 30px -12px rgba(77, 141, 255, 1), inset 0 1px 0 rgba(255,255,255,.36); }
.btn-block { width: 100%; min-height: 46px; }
.btn-ghost { background: var(--surface-3); color: var(--t1); }
.btn-ghost:hover { background: var(--line); }
.btn-soft { background: var(--brand-soft); color: var(--brand-ink); }
.btn-soft:hover { background: var(--brand-ring); }
.btn-danger { background: var(--err-soft); color: var(--err); }
.btn-sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }

.icon-btn {
  width: 38px; height: 38px; border-radius: var(--r-sm);
  display: inline-grid; place-items: center; color: var(--t2);
  transition: background var(--dur), color var(--dur), transform var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--t1); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.ghost { background: transparent; }

.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px;
  border-radius: var(--r-full); font-size: 11.5px; font-weight: 600; letter-spacing: .02em;
}
.badge-soft { color: var(--brand-ink); background: var(--brand-soft); }
.badge-ok { color: var(--ok); background: var(--ok-soft); }
.badge-warn { color: var(--warn); background: var(--warn-soft); }
.badge-err { color: var(--err); background: var(--err-soft); }

.field { display: block; margin-bottom: 14px; }
.field-label { display: block; font-size: 12.5px; font-weight: 600; color: var(--t3); margin-bottom: 7px; letter-spacing: .01em; }
.field input, .field textarea, .field select, .input {
  width: 100%; min-height: 46px; padding: 11px 14px; border-radius: var(--r-md);
  background: var(--surface-2); border: 1px solid var(--line-2); color: var(--t1);
  font-size: 14.5px; outline: none;
  transition: border-color var(--dur), box-shadow var(--dur), background var(--dur);
}
.field input::placeholder, .field textarea::placeholder, .input::placeholder { color: var(--t4); }
.field input:focus, .field textarea:focus, .field select:focus, .input:focus {
  border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 4px var(--brand-ring);
}
.field textarea { min-height: 108px; resize: vertical; line-height: 1.65; }
.field-hint { font-size: 12px; color: var(--t3); margin: 6px 2px 0; line-height: 1.5; }
.form-error { min-height: 18px; margin: -2px 0 8px; font-size: 12.5px; color: var(--err); }

.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 登录页 ============ */
.auth {
  position: relative; z-index: 2; min-height: 100dvh;
  display: grid; place-items: center; padding: 28px 20px;
}
.auth-theme { position: fixed; top: 20px; right: 20px; width: 42px; height: 42px; border-radius: var(--r-md); display: grid; place-items: center; color: var(--t2); background: color-mix(in srgb, var(--surface) 70%, transparent); backdrop-filter: blur(14px); border: 1px solid var(--line); transition: transform var(--dur) var(--ease), background var(--dur); }
.auth-theme:hover { transform: translateY(-1px) rotate(-8deg); background: var(--surface); }

.auth-card {
  position: relative; width: min(440px, 100%); padding: 34px 32px 26px;
  isolation: isolate;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(26px) saturate(140%);
  border: 1px solid color-mix(in srgb, var(--surface) 60%, var(--line-2));
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255,255,255,.5);
  animation: cardIn .6s var(--ease) both;
}
[data-theme="dark"] .auth-card { box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255,255,255,.06); }
.auth-card::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px; pointer-events: none;
  background: linear-gradient(150deg, rgba(123,97,255,.55), rgba(255,255,255,0) 42%, rgba(55,211,240,.45));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: .9;
}
.auth-card::after {
  content: ""; position: absolute; inset: -40px -30px auto; height: 120px; z-index: -1;
  background: radial-gradient(60% 100% at 50% 0%, rgba(123,97,255,.18), transparent 70%); pointer-events: none;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(16px) scale(.985); } }

.auth-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 24px; }
.logo-mark { width: 46px; height: 46px; flex: none; filter: drop-shadow(0 6px 14px rgba(99,91,255,.35)); }
.logo-mark svg { width: 100%; height: 100%; }
.auth-brand h1 { margin: 0; font-size: 21px; font-weight: 700; letter-spacing: -.02em; }
.auth-brand p { margin: 2px 0 0; font-size: 12.5px; color: var(--t3); letter-spacing: .02em; }

.seg {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  padding: 4px; margin-bottom: 22px; border-radius: var(--r-md); background: var(--surface-3);
}
.seg-item { position: relative; z-index: 1; height: 36px; border-radius: 10px; font-size: 13.5px; font-weight: 600; color: var(--t3); transition: color .25s var(--ease); }
.seg-item.active { color: var(--t1); }
.seg-thumb { position: absolute; top: 4px; left: 4px; width: calc(50% - 6px); height: 36px; border-radius: 10px; background: var(--surface); box-shadow: var(--shadow-1); transition: transform .32s var(--ease); }
.seg[data-tab="register"] .seg-thumb { transform: translateX(calc(100% + 4px)); }

.auth-form .field input { min-height: 48px; }
.form-error:empty { display: none; }

.btn-spinner { width: 16px; height: 16px; }
.auth-meta { margin-top: 22px; display: grid; gap: 10px; }
.qq-chip {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px;
  border-radius: var(--r-full); background: var(--surface-3); color: var(--t2);
  font-size: 12.5px; width: fit-content; cursor: pointer; transition: background var(--dur), transform var(--dur) var(--ease);
}
.qq-chip:hover { background: var(--brand-soft); color: var(--brand-ink); transform: translateY(-1px); }
.qq-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }
.auth-note { margin: 0; font-size: 12.5px; color: var(--t3); line-height: 1.6; }
.auth-note b { color: var(--brand-ink); font-weight: 600; }
.auth-foot { margin: 0; font-size: 11.5px; color: var(--t4); }

/* ============ 应用骨架 ============ */
.app {
  position: relative; z-index: 2; height: 100dvh;
  display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr);
  opacity: 0; animation: appIn .45s var(--ease) forwards;
}
@keyframes appIn { to { opacity: 1; } }

.scrim { position: fixed; inset: 0; background: rgba(8, 10, 18, .52); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .28s var(--ease); z-index: 40; }
.scrim.show { opacity: 1; pointer-events: auto; }

/* ---- 侧栏 ---- */
.sidebar {
  position: relative; display: flex; flex-direction: column; min-height: 0;
  padding: 14px 12px 12px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(20px);
  border-right: 1px solid var(--line);
  transition: transform .32s var(--ease), width .32s var(--ease), padding .32s var(--ease);
  z-index: 45;
}
.side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 2px 4px 14px; }
.brand-small { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo-mini { width: 32px; height: 32px; flex: none; }
.logo-mini svg { width: 100%; height: 100%; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 14.5px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text span { font-size: 11px; color: var(--t3); white-space: nowrap; }

.btn-new {
  width: 100%; justify-content: flex-start; gap: 9px; padding: 0 14px; height: 44px;
  border-radius: var(--r-md); color: #fff; background: var(--grad);
  box-shadow: 0 10px 24px -14px rgba(77,141,255,.95), inset 0 1px 0 rgba(255,255,255,.25);
  font-size: 14px; font-weight: 600; margin-bottom: 12px;
}
.btn-new:hover { transform: translateY(-1px); box-shadow: 0 16px 30px -16px rgba(77,141,255,1); }
.btn-new kbd { margin-left: auto; font-family: var(--font); font-size: 11px; padding: 2px 6px; border-radius: 6px; background: rgba(255,255,255,.18); color: rgba(255,255,255,.9); }

.side-search { position: relative; margin-bottom: 8px; }
.side-search .ic { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--t4); }
.side-search input {
  width: 100%; height: 36px; padding: 0 10px 0 32px; border-radius: var(--r-sm);
  background: var(--surface-3); border: 1px solid transparent; font-size: 13px; outline: none;
  transition: background var(--dur), border-color var(--dur), box-shadow var(--dur);
}
.side-search input:focus { background: var(--surface); border-color: var(--line-2); box-shadow: 0 0 0 3px var(--brand-ring); }

.conv-list { flex: 1; min-height: 0; overflow-y: auto; margin: 4px -6px 8px; padding: 0 6px; display: flex; flex-direction: column; gap: 2px; }
.conv-empty { font-size: 12.5px; color: var(--t4); text-align: center; padding: 24px 8px; margin: 0; }
.conv-group-label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--t4); padding: 10px 8px 4px; }
.conv-item {
  position: relative; display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 10px; border-radius: var(--r-sm); color: var(--t2); text-align: left;
  font-size: 13.5px; transition: background var(--dur), color var(--dur);
}
.conv-item:hover { background: var(--surface-3); color: var(--t1); }
.conv-item.active { background: var(--brand-soft); color: var(--brand-ink); font-weight: 600; }
.conv-item.active::before { content: ""; position: absolute; left: -6px; top: 50%; transform: translateY(-50%); width: 3px; height: 16px; border-radius: 99px; background: var(--grad); }
.conv-item .ci-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-item .ci-del { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; opacity: 0; color: var(--t3); transition: opacity .18s, background .18s, color .18s; }
.conv-item:hover .ci-del, .conv-item:focus-within .ci-del { opacity: 1; }
.conv-item .ci-del:hover { background: var(--err-soft); color: var(--err); }

/* 侧栏底部 */
.side-foot { display: flex; flex-direction: column; gap: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.balance-card {
  padding: 12px 13px; border-radius: var(--r-md); background: var(--grad-soft);
  border: 1px solid var(--line); cursor: pointer; transition: transform var(--dur) var(--ease), box-shadow var(--dur);
}
.balance-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-1); }
.bc-top { display: flex; align-items: center; justify-content: space-between; }
.bc-label { font-size: 11.5px; color: var(--t3); letter-spacing: .02em; }
.bc-value { display: flex; align-items: baseline; gap: 3px; margin: 5px 0 7px; font-variant-numeric: tabular-nums; }
.bc-value .cur { font-size: 13px; color: var(--t2); }
.bc-value #balanceValue { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.bc-bar { height: 3px; border-radius: 99px; background: color-mix(in srgb, var(--t1) 8%, transparent); overflow: hidden; }
.bc-bar i { display: block; height: 100%; width: 60%; border-radius: 99px; background: var(--grad); transition: width .5s var(--ease); }
.bc-actions { display: flex; gap: 6px; margin-top: 10px; }
.mini-btn {
  flex: 1; height: 28px; border-radius: var(--r-xs); font-size: 12px; font-weight: 600; color: var(--t2);
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  background: color-mix(in srgb, var(--surface) 70%, transparent); border: 1px solid var(--line);
  transition: background var(--dur), color var(--dur), transform var(--dur) var(--ease);
}
.mini-btn:hover { background: var(--surface); color: var(--brand-ink); transform: translateY(-1px); }

.side-tools { display: flex; gap: 4px; }
.tool-btn { flex: 1; min-width: 0; }
.tool-btn {
  display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 7px 2px;
  border-radius: var(--r-sm); color: var(--t3); font-size: 11px; transition: background var(--dur), color var(--dur);
}
.tool-btn:hover { background: var(--surface-3); color: var(--t1); }
.tool-btn .ic { width: 18px; height: 18px; }

.user-chip { display: flex; align-items: center; gap: 9px; padding: 6px 6px 6px 8px; border-radius: var(--r-md); transition: background var(--dur); }
.user-chip:hover { background: var(--surface-3); }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--grad); color: #fff; font-weight: 700; font-size: 13px; flex: none;
  box-shadow: 0 4px 12px -4px rgba(99,91,255,.6);
}
.uc-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; flex: 1; }
.uc-meta strong { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uc-meta span { font-size: 11px; color: var(--t3); }

/* ---- 主区 ---- */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }

.topbar {
  height: var(--header-h); flex: none; display: flex; align-items: center; gap: 10px;
  padding: 0 20px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 78%, transparent); backdrop-filter: blur(18px);
  z-index: 10;
}
.topbar-spacer { flex: 1; }

.model-picker { position: relative; }
.model-btn {
  display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px 0 8px;
  border-radius: var(--r-full); background: var(--surface); border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; color: var(--t1); transition: border-color var(--dur), box-shadow var(--dur), transform var(--dur) var(--ease);
}
.model-btn:hover { border-color: var(--line-2); box-shadow: var(--shadow-1); transform: translateY(-1px); }
.model-orb { width: 16px; height: 16px; border-radius: 50%; background: var(--grad); box-shadow: 0 0 0 3px var(--brand-ring); }
.model-btn .ic { color: var(--t3); transition: transform .25s var(--ease); }
.model-btn.open .ic { transform: rotate(90deg); }
.model-menu {
  position: absolute; top: calc(100% + 8px); left: 0; min-width: 258px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-md);
  box-shadow: var(--shadow-pop); z-index: 30; transform-origin: top left;
  opacity: 0; transform: translateY(-6px) scale(.98); pointer-events: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.model-menu.open { opacity: 1; transform: none; pointer-events: auto; }
.model-item { display: flex; flex-direction: column; gap: 2px; width: 100%; padding: 9px 10px; border-radius: var(--r-sm); text-align: left; transition: background var(--dur); }
.model-item:hover { background: var(--surface-3); }
.model-item.active { background: var(--brand-soft); }
.model-item strong { font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.model-item small { font-size: 11.5px; color: var(--t3); font-variant-numeric: tabular-nums; }
.model-item .tick { margin-left: auto; color: var(--brand); opacity: 0; }
.model-item.active .tick { opacity: 1; }

.mode-switch { display: flex; gap: 2px; padding: 3px; border-radius: var(--r-full); background: var(--surface-3); }
.mode-btn { height: 28px; padding: 0 11px; border-radius: var(--r-full); font-size: 12.5px; font-weight: 600; color: var(--t3); transition: color var(--dur), background var(--dur), box-shadow var(--dur); }
.mode-btn:hover { color: var(--t1); }
.mode-btn.active { background: var(--surface); color: var(--t1); box-shadow: var(--shadow-1); }

.price-pill { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: var(--r-full); font-size: 11.5px; color: var(--t3); background: var(--surface-3); font-variant-numeric: tabular-nums; }
.price-pill b { color: var(--brand-ink); font-weight: 700; }

/* ---- 会话区 ---- */
.chat { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; padding: 0 20px; }
.chat-inner { max-width: var(--maxw); margin: 0 auto; }

.welcome { max-width: 760px; margin: 0 auto; padding: clamp(24px, 8vh, 84px) 0 8px; text-align: center; animation: riseIn .6s var(--ease) both; }
.welcome-orb { width: 96px; height: 96px; margin: 0 auto 18px; filter: drop-shadow(0 12px 30px rgba(99,91,255,.32)); animation: floatY 6s var(--ease-io) infinite alternate; }
.welcome-orb svg { width: 100%; height: 100%; }
@keyframes floatY { to { transform: translateY(-8px); } }
.welcome-title { margin: 0 0 8px; font-size: clamp(24px, 3.4vw, 32px); font-weight: 700; letter-spacing: -.03em; line-height: 1.25; }
.welcome-sub { margin: 0 0 30px; color: var(--t3); font-size: 14px; }
.suggest-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; text-align: left; }
.suggest {
  text-align: left;
  display: grid; grid-template-columns: 26px 1fr; grid-template-rows: auto auto; column-gap: 10px;
  padding: 14px 14px; border-radius: var(--r-md); background: color-mix(in srgb, var(--surface) 70%, transparent);
  border: 1px solid var(--line); transition: transform var(--dur) var(--ease), border-color var(--dur), box-shadow var(--dur), background var(--dur);
}
.suggest:hover { transform: translateY(-2px); border-color: var(--brand-ring); box-shadow: var(--shadow-1); background: var(--surface); }
.suggest-ic { grid-row: span 2; width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: linear-gradient(135deg, rgba(123,97,255,.16), rgba(55,211,240,.16)); color: var(--brand-ink); font-size: 13px; border: 1px solid color-mix(in srgb, var(--brand) 18%, transparent); }
.suggest strong { font-size: 13.5px; font-weight: 650; }
.suggest em { font-style: normal; font-size: 12px; color: var(--t3); }
.welcome-note { margin: 26px 0 0; font-size: 11.5px; color: var(--t4); font-variant-numeric: tabular-nums; }
.welcome-note b { color: var(--t2); font-weight: 600; }

.messages { max-width: var(--maxw); margin: 0 auto; padding: 22px 0 10px; display: flex; flex-direction: column; gap: 22px; }
.chat-bottom { height: 12px; }

.msg { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 12px; animation: riseIn .38s var(--ease) both; }
@keyframes riseIn { from { opacity: 0; transform: translateY(10px); } }
.msg-avatar { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.msg-ai .msg-avatar { background: var(--grad); color: #fff; box-shadow: 0 6px 14px -8px rgba(99,91,255,.9); }
.msg-user { grid-template-columns: minmax(0, 1fr) 30px; }
.msg-user .msg-avatar { order: 2; background: var(--surface-3); color: var(--t2); }
.msg-user .msg-body { order: 1; align-items: flex-end; }
.msg-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.msg-name { font-size: 11.5px; color: var(--t4); font-weight: 600; letter-spacing: .02em; }
.msg-content { font-size: 15px; line-height: 1.72; color: var(--t1); word-break: break-word; }
.msg-user .msg-content {
  background: var(--brand-soft); color: var(--t1); padding: 10px 14px; border-radius: 16px 16px 4px 16px;
  max-width: 82%; white-space: pre-wrap;
}
.msg-err { color: var(--err); background: var(--err-soft); padding: 10px 14px; border-radius: var(--r-md); font-size: 13.5px; }

.msg-content p { margin: 0 0 10px; }
.msg-content p:last-child { margin-bottom: 0; }
.msg-content h1, .msg-content h2, .msg-content h3 { margin: 18px 0 8px; line-height: 1.35; letter-spacing: -.01em; }
.msg-content h1 { font-size: 20px; } .msg-content h2 { font-size: 17.5px; } .msg-content h3 { font-size: 16px; }
.msg-content ul, .msg-content ol { margin: 0 0 10px; padding-left: 22px; }
.msg-content li { margin: 4px 0; }
.msg-content blockquote { margin: 10px 0; padding: 6px 14px; border-left: 3px solid var(--brand-ring); color: var(--t2); background: var(--surface-3); border-radius: 0 8px 8px 0; }
.msg-content hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.msg-content a { border-bottom: 1px solid var(--brand-ring); }
.msg-content table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 13.5px; }
.msg-content th, .msg-content td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; }
.msg-content th { background: var(--surface-3); font-weight: 600; }
.msg-content code.inline { font-family: var(--mono); font-size: 13px; padding: 2px 6px; border-radius: 6px; background: var(--surface-3); border: 1px solid var(--line); }
.code-block { position: relative; margin: 12px 0; border-radius: var(--r-md); overflow: hidden; border: 1px solid var(--line-2); background: #0E1119; }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 7px 12px; background: rgba(255,255,255,.04); border-bottom: 1px solid rgba(255,255,255,.06); }
.code-lang { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: rgba(255,255,255,.5); }
.code-copy { font-size: 11.5px; color: rgba(255,255,255,.6); padding: 3px 8px; border-radius: 6px; transition: background .2s, color .2s; }
.code-copy:hover { background: rgba(255,255,255,.1); color: #fff; }
.code-block pre { margin: 0; padding: 14px 16px; overflow-x: auto; }
.code-block code { font-family: var(--mono); font-size: 13px; line-height: 1.65; color: #D6E1F5; white-space: pre; }

.typing-dots { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--t4); animation: blink 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .16s; } .typing-dots i:nth-child(3) { animation-delay: .32s; }
@keyframes blink { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

.reasoning { margin-bottom: 8px; border-radius: var(--r-md); background: var(--surface-3); border: 1px solid var(--line); overflow: hidden; }
.reasoning summary { cursor: pointer; padding: 8px 12px; font-size: 12.5px; color: var(--t3); list-style: none; display: flex; align-items: center; gap: 6px; }
.reasoning summary::-webkit-details-marker { display: none; }
.reasoning[open] summary { border-bottom: 1px solid var(--line); }
.reasoning .rs-body { padding: 10px 12px; font-size: 13px; color: var(--t2); white-space: pre-wrap; max-height: 300px; overflow: auto; line-height: 1.65; }

.msg-meta { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--t4); font-variant-numeric: tabular-nums; }
.msg-actions { display: flex; gap: 4px; opacity: 0; transition: opacity .2s; }
.msg:hover .msg-actions { opacity: 1; }
.msg-act { height: 24px; padding: 0 8px; border-radius: 6px; font-size: 11.5px; color: var(--t3); display: inline-flex; align-items: center; gap: 4px; transition: background var(--dur), color var(--dur); }
.msg-act:hover { background: var(--surface-3); color: var(--t1); }

/* ---- 输入区 ---- */
.composer-wrap { flex: none; padding: 0 20px 14px; background: linear-gradient(to top, var(--bg) 55%, transparent); }
.composer {
  max-width: var(--maxw); margin: 0 auto; position: relative;
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1); padding: 10px 12px 8px;
  transition: border-color var(--dur), box-shadow var(--dur), transform var(--dur) var(--ease);
}
.composer:focus-within { border-color: var(--brand-ring); box-shadow: 0 0 0 4px var(--brand-ring), var(--shadow-1); }
.composer textarea {
  width: 100%; border: 0; background: transparent; resize: none; outline: none;
  font-size: 15px; line-height: 1.66; max-height: 220px; min-height: 26px; padding: 4px 2px 6px;
}
.composer textarea::placeholder { color: var(--t4); }
.composer-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.composer-left { display: flex; align-items: center; gap: 8px; min-width: 0; }
.chip-btn {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 9px;
  border-radius: var(--r-full); background: var(--brand-soft); color: var(--brand-ink);
  font-size: 12px; font-weight: 600; transition: background var(--dur), transform var(--dur) var(--ease);
}
.chip-btn:hover { background: var(--brand-ring); transform: translateY(-1px); }
.composer-hint { font-size: 11.5px; color: var(--t4); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-variant-numeric: tabular-nums; }
.btn-send {
  width: 38px; height: 38px; padding: 0; border-radius: 12px; color: #fff; background: var(--grad);
  box-shadow: 0 8px 18px -10px rgba(77,141,255,.95); transition: transform var(--dur) var(--ease), box-shadow var(--dur), opacity var(--dur);
}
.btn-send:hover:not(:disabled) { transform: translateY(-1px) scale(1.02); box-shadow: 0 12px 24px -12px rgba(77,141,255,1); }
.btn-send:disabled { opacity: .35; box-shadow: none; cursor: not-allowed; }
.btn-send.stop { background: var(--err); box-shadow: 0 8px 18px -10px rgba(229,72,77,.9); }
.disclaimer { text-align: center; font-size: 11px; color: var(--t4); margin: 8px 0 0; }
.disclaimer b { color: var(--t3); font-weight: 600; }

/* ---- 面板 ---- */
.panel-scrim { position: fixed; inset: 0; background: rgba(8,10,18,.36); backdrop-filter: blur(3px); opacity: 0; pointer-events: none; transition: opacity .3s var(--ease); z-index: 60; }
.panel-scrim.show { opacity: 1; pointer-events: auto; }
.panel {
  position: fixed; top: 0; right: 0; height: 100dvh; width: min(452px, 100vw);
  background: var(--surface); border-left: 1px solid var(--line);
  box-shadow: -20px 0 60px -30px rgba(0,0,0,.45);
  transform: translateX(102%); transition: transform .34s var(--ease);
  z-index: 61; display: flex; flex-direction: column;
}
.panel.open { transform: none; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px 14px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.panel-body { padding: 18px 20px 28px; overflow-y: auto; flex: 1; }

.panel-section { margin-bottom: 22px; }
.panel-section > h4 { margin: 0 0 10px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--t4); }
.panel-note { font-size: 12.5px; color: var(--t3); line-height: 1.6; }
.panel-note b { color: var(--t1); }

.amount-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px; }
.amount-btn { height: 38px; border-radius: var(--r-sm); background: var(--surface-3); font-size: 13px; font-weight: 600; color: var(--t2); transition: background var(--dur), color var(--dur), transform var(--dur) var(--ease); }
.amount-btn:hover { background: var(--brand-soft); color: var(--brand-ink); transform: translateY(-1px); }

.list-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.list-row:last-child { border-bottom: 0; }
.list-row .lr-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.list-row .lr-main strong { font-weight: 600; font-size: 13.5px; }
.list-row .lr-main span { font-size: 11.5px; color: var(--t4); }
.list-row .lr-amt { font-variant-numeric: tabular-nums; font-weight: 600; }
.lr-amt.pos { color: var(--ok); } .lr-amt.neg { color: var(--t2); }

.switch { position: relative; width: 42px; height: 24px; border-radius: 99px; background: var(--line-2); transition: background .25s var(--ease); flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .25s var(--ease); }
.switch.on { background: var(--brand); }
.switch.on::after { transform: translateX(18px); }

.seg-mini { display: flex; padding: 3px; background: var(--surface-3); border-radius: var(--r-sm); gap: 2px; }
.seg-mini button { flex: 1; height: 32px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--t3); transition: background var(--dur), color var(--dur); }
.seg-mini button.active { background: var(--surface); color: var(--t1); box-shadow: var(--shadow-1); }

/* ---- Toast ---- */
.toasts { position: fixed; left: 50%; bottom: 132px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 200; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 9px; padding: 10px 16px; border-radius: var(--r-md);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(18px);
  border: 1px solid var(--line-2); box-shadow: var(--shadow-pop); font-size: 13px; color: var(--t1);
  animation: toastIn .32s var(--ease) both;
}
.toast.out { animation: toastOut .25s var(--ease) forwards; }
.toast .ic { width: 16px; height: 16px; }
.toast.ok .ic { color: var(--ok); } .toast.err .ic { color: var(--err); } .toast.info .ic { color: var(--brand); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px) scale(.96); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px) scale(.98); } }

/* ---- 弹窗 ---- */
.modal-root { position: fixed; inset: 0; z-index: 120; display: none; }
.modal-root.show { display: block; }
.modal-mask { position: absolute; inset: 0; background: rgba(8,10,18,.48); backdrop-filter: blur(4px); animation: fadeIn .22s ease; }
@keyframes fadeIn { from { opacity: 0; } }
.modal { position: relative; width: min(420px, calc(100vw - 32px)); margin: 12vh auto 0; background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: var(--shadow-2); padding: 22px; animation: modalIn .3s var(--ease); }
@keyframes modalIn { from { opacity: 0; transform: translateY(14px) scale(.97); } }
.modal h3 { margin: 0 0 6px; font-size: 17px; letter-spacing: -.01em; }
.modal p.modal-sub { margin: 0 0 16px; font-size: 13px; color: var(--t3); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---- 响应式 ---- */
@media (max-width: 1080px) {
  .mode-switch { display: none; }
  .price-pill { display: none; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 84%; max-width: 320px;
    transform: translateX(-102%); box-shadow: var(--shadow-2);
    background: var(--surface); z-index: 50;
  }
  .sidebar.open { transform: none; }
  .hide-md { display: none; }
  .only-sm { display: inline-grid; }
  .topbar { padding: 0 12px; gap: 8px; }
  .chat { padding: 0 12px; }
  .composer-wrap { padding: 0 12px 10px; }
  .welcome { padding-top: 26px; }
  .suggest-grid { grid-template-columns: 1fr; }
  .msg-user .msg-content { max-width: 92%; }
  .price-pill { display: none; }
  .model-btn span:not(.model-orb) { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (min-width: 901px) { .only-sm { display: none; } }

/* 折叠侧栏 */
.app.collapsed { grid-template-columns: 78px minmax(0, 1fr); }
.app.collapsed .sidebar { padding: 14px 8px 12px; }
.app.collapsed .brand-text,
.app.collapsed .btn-new span,
.app.collapsed .btn-new kbd,
.app.collapsed .side-search,
.app.collapsed .conv-list,
.app.collapsed .bc-top,
.app.collapsed .bc-value,
.app.collapsed .bc-bar,
.app.collapsed .bc-actions,
.app.collapsed .tool-btn span,
.app.collapsed .uc-meta,
.app.collapsed .user-chip .icon-btn { display: none; }
.app.collapsed .side-head { justify-content: center; }
.app.collapsed .btn-new { justify-content: center; padding: 0; width: 46px; margin-inline: auto; }
.app.collapsed .balance-card { padding: 8px; display: grid; place-items: center; }
.app.collapsed .balance-card::after { content: "¥"; font-weight: 700; color: var(--brand-ink); }
.app.collapsed .side-tools { grid-template-columns: 1fr; }
.app.collapsed .user-chip { justify-content: center; padding: 6px 0; }
.app.collapsed .tool-btn { padding: 9px 0; }

/* 账号密码二次确认弹窗 */
.cred-mask { position: fixed; inset: 0; background: rgba(8,10,16,.55); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: 500; animation: credIn .18s var(--ease); }
.cred-box { width: min(400px, calc(100vw - 40px)); background: var(--bg-1); border: 1px solid var(--line-2); border-radius: 16px; padding: 22px 22px 18px; box-shadow: 0 30px 70px -30px #000; }
.cred-box h4 { margin: 0 0 6px; font-size: 16px; font-weight: 650; }
.cred-box p { margin: 0 0 16px; font-size: 12.5px; color: var(--t3); line-height: 1.6; }
.cred-fld { display: block; margin-bottom: 12px; }
.cred-fld span { display: block; font-size: 12px; color: var(--t3); margin-bottom: 6px; }
.cred-fld input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg-2); color: var(--t1); font-size: 13.5px; outline: none; }
.cred-fld input:focus { border-color: var(--accent); }
.cred-err { min-height: 16px; font-size: 12px; color: #f472b6; margin-bottom: 6px; }
.cred-act { display: flex; justify-content: flex-end; gap: 10px; margin-top: 4px; }
@keyframes credIn { from { opacity: 0; } to { opacity: 1; } }

/* 消费闸门进度 */
.bc-gate { margin-top: 8px; font-size: 11.5px; color: var(--t3); display: flex; align-items: center; gap: 6px; }
.bc-gate b { color: var(--t1); font-weight: 600; }
.bc-gate.due { color: #fbbf24; }


/* 账号密码二次确认弹窗 */
.cred-mask { position: fixed; inset: 0; background: rgba(12,14,24,.42); backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center; z-index: 500; }
.cred-box { width: min(408px, calc(100vw - 40px)); background: var(--surface); border: 1px solid var(--line-2); border-radius: 18px; padding: 24px 24px 20px; box-shadow: var(--shadow-2); }
.cred-box h4 { margin: 0 0 8px; font-size: 16.5px; font-weight: 650; color: var(--t1); letter-spacing: -.01em; }
.cred-box p { margin: 0 0 18px; font-size: 12.5px; color: var(--t3); line-height: 1.65; }
.cred-fld { display: block; margin-bottom: 14px; }
.cred-fld span { display: block; font-size: 11.5px; font-weight: 600; color: var(--t3); margin-bottom: 7px; letter-spacing: .01em; }
.cred-fld input { width: 100%; height: 44px; padding: 0 13px; border-radius: 11px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--t1); font-size: 14px; outline: none; transition: border-color .18s, box-shadow .18s; }
.cred-fld input::placeholder { color: var(--t4); }
.cred-fld input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.cred-err { min-height: 17px; font-size: 12px; color: var(--err); margin: 2px 0 8px; }
.cred-act { display: flex; justify-content: flex-end; gap: 10px; margin-top: 2px; }
.cred-act .btn { min-width: 96px; }

