/* =============================================================================
   AIChatConsole — base.css
   深色设计系统 + 三套页面（登录 / 对话 / 后台）共用样式
   规则：不使用任何外部 CDN / 外部字体 / 绝对路径资源；全部相对引用。
   -----------------------------------------------------------------------------
   目录
     01 tokens            02 reset & base       03 typography helpers
     04 buttons           05 fields & switches   06 badges & chips
     07 app shell         08 model picker        09 messages & bubbles
     10 attachments       11 progress & cursor   12 composer
     13 auth (login)      14 admin (tables/forms/modals/drawer)
     15 toast & lightbox  16 responsive          17 motion
   ============================================================================= */

/* ------------------------------------------------------------------ 01 tokens */
:root {
  /* 背景层级：越靠上层越亮，保持低对比深色 */
  --bg: #0b0f17;
  --bg-soft: #0e1420;
  --surface: #121a28;
  --surface-2: #16202f;
  --surface-3: #1c2839;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);

  /* 文本层级 */
  --text: #e9eefc;
  --text-dim: #9aa7bd;
  --text-faint: #6b7a92;

  /* 品牌色 */
  --brand: #6d8bff;
  --brand-2: #a855f7;
  --brand-3: #22d3ee;
  --accent: linear-gradient(135deg, #5b7cfa 0%, #9b5cf6 55%, #f857a6 100%);
  --accent-soft: linear-gradient(135deg, rgba(91, 124, 250, 0.18), rgba(168, 85, 247, 0.14));

  /* 语义色 */
  --ok: #34d399;
  --ok-dim: rgba(52, 211, 153, 0.14);
  --warn: #fbbf24;
  --warn-dim: rgba(251, 191, 36, 0.14);
  --danger: #f87171;
  --danger-dim: rgba(248, 113, 113, 0.14);
  --info: #60a5fa;
  --info-dim: rgba(96, 165, 250, 0.14);

  /* 尺寸 */
  --radius-xs: 8px;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --sidebar-w: 284px;

  /* 阴影 */
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-2: 0 18px 40px -22px rgba(0, 0, 0, 0.9);
  --shadow-glow: 0 18px 46px -24px rgba(109, 139, 255, 0.7);

  /* 字体：仅系统字体，无外部加载 */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC",
    sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", "Courier New", monospace;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ---------------------------------------------------------- 02 reset & base */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.62;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 620px at 12% -12%, rgba(109, 139, 255, 0.12), transparent 62%),
    radial-gradient(760px 520px at 102% -6%, rgba(168, 85, 247, 0.1), transparent 58%),
    radial-gradient(1000px 700px at 50% 120%, rgba(34, 211, 238, 0.05), transparent 65%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4,
p,
ul,
ol,
figure {
  margin: 0;
}

ul,
ol {
  padding-left: 1.25em;
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  font: inherit;
  color: inherit;
}

img,
video {
  max-width: 100%;
}

hr {
  border: 0;
  border-top: 1px solid var(--line);
}

[hidden] {
  display: none !important;
}

::selection {
  background: rgba(109, 139, 255, 0.32);
}

:focus-visible {
  outline: 2px solid rgba(109, 139, 255, 0.7);
  outline-offset: 2px;
}

/* 滚动条：细、低对比 */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.16) transparent;
}

*::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

*::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.14);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.24);
  background-clip: padding-box;
}

/* --------------------------------------------------- 03 typography helpers */
.muted {
  color: var(--text-dim);
}

.faint {
  color: var(--text-faint);
}

.mono {
  font-family: var(--mono);
  font-variant-ligatures: none;
}

.tnum {
  font-variant-numeric: tabular-nums;
}

.nowrap {
  white-space: nowrap;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.ta-r {
  text-align: right;
}

/* -------------------------------------------------------------- 04 buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface-2);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease),
    transform 0.12s var(--ease), box-shadow 0.18s var(--ease), opacity 0.18s;
}

.btn:hover {
  background: var(--surface-3);
  border-color: rgba(255, 255, 255, 0.22);
}

.btn:active {
  transform: translateY(1px);
}

.btn[disabled],
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  border: 0;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 10px 26px -14px rgba(140, 105, 255, 0.95);
}

.btn-primary:hover {
  filter: brightness(1.07);
  box-shadow: 0 14px 30px -12px rgba(140, 105, 255, 0.9);
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text-dim);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.btn-danger {
  color: #fff;
  background: linear-gradient(135deg, #ef4444, #f97316);
  border: 0;
}

.btn-sm {
  padding: 6px 11px;
  font-size: 12.5px;
  border-radius: 8px;
}

.btn-xs {
  padding: 3px 8px;
  font-size: 12px;
  border-radius: 7px;
}

.btn-lg {
  padding: 12px 20px;
  font-size: 15px;
  border-radius: 12px;
}

.btn-block {
  width: 100%;
}

.btn-icon {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand);
  font-size: 13px;
  cursor: pointer;
}

.link-btn:hover {
  text-decoration: underline;
}

.link-btn[disabled] {
  color: var(--text-faint);
  cursor: not-allowed;
  text-decoration: none;
}

/* 按钮内加载态 */
.btn.is-busy {
  pointer-events: none;
  opacity: 0.75;
}

.btn.is-busy::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.45);
  border-top-color: transparent;
  animation: spin 0.7s linear infinite;
}

/* ------------------------------------------------- 05 fields & form widgets */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.field-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-dim);
  letter-spacing: 0.01em;
}

.field-hint {
  font-size: 12px;
  color: var(--text-faint);
}

.input,
.textarea,
.select {
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: rgba(8, 12, 20, 0.72);
  color: var(--text);
  font: inherit;
  transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
}

.input::placeholder,
.textarea::placeholder {
  color: #5c6a80;
}

.input:hover,
.textarea:hover,
.select:hover {
  border-color: rgba(255, 255, 255, 0.2);
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: none;
  border-color: rgba(109, 139, 255, 0.65);
  box-shadow: 0 0 0 3px rgba(109, 139, 255, 0.16);
  background: rgba(8, 12, 20, 0.9);
}

.input[readonly] {
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.02);
}

.textarea {
  min-height: 90px;
  resize: vertical;
}

.select-wrap {
  position: relative;
  display: block;
}

.select-wrap::after {
  content: "▾";
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text-faint);
  pointer-events: none;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 30px;
  cursor: pointer;
}

.input-affix {
  position: relative;
  display: block;
}

.input-affix .input {
  padding-right: 58px;
}

.affix-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  padding: 4px 8px;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
}

.affix-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.1);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 18px;
}

.form-grid .span-2 {
  grid-column: 1 / -1;
}

.form-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(248, 113, 113, 0.32);
  background: var(--danger-dim);
  color: #ffc9c9;
  font-size: 13px;
}

.form-error::before {
  content: "!";
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  border-radius: 50%;
  background: var(--danger);
  color: #2a0505;
  font-size: 11px;
  font-weight: 700;
}

.form-hint-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* 开关 */
.switch-field {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  cursor: pointer;
}

.switch-field:hover {
  border-color: var(--line-strong);
}

.switch-field > span:last-child {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 13px;
}

.switch-field small {
  color: var(--text-faint);
  font-size: 11.5px;
}

.switch {
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  flex: 0 0 auto;
  width: 38px;
  height: 21px;
  margin: 0;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.2s var(--ease);
}

.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  transition: transform 0.2s var(--ease);
}

.switch:checked {
  background: linear-gradient(135deg, #5b7cfa, #9b5cf6);
}

.switch:checked::after {
  transform: translateX(17px);
}

/* 分段控件 */
.segmented {
  display: inline-flex;
  padding: 3px;
  gap: 2px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.segmented button {
  padding: 5px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-dim);
  font-size: 12.5px;
  cursor: pointer;
}

.segmented button.is-active {
  background: rgba(109, 139, 255, 0.18);
  color: #cfd9ff;
  box-shadow: inset 0 0 0 1px rgba(109, 139, 255, 0.32);
}

/* --------------------------------------------------------- 06 badges/chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 99px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.6;
  white-space: nowrap;
}

.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.9;
}

.badge.no-dot::before {
  display: none;
}

.badge.ok {
  color: #7ff0c4;
  background: var(--ok-dim);
  border-color: rgba(52, 211, 153, 0.3);
}

.badge.warn {
  color: #ffd98a;
  background: var(--warn-dim);
  border-color: rgba(251, 191, 36, 0.3);
}

.badge.danger {
  color: #ffb4b4;
  background: var(--danger-dim);
  border-color: rgba(248, 113, 113, 0.32);
}

.badge.info {
  color: #b8d4ff;
  background: var(--info-dim);
  border-color: rgba(96, 165, 250, 0.3);
}

.badge.muted {
  color: var(--text-faint);
  background: rgba(255, 255, 255, 0.03);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-dim);
  font-size: 12px;
}

/* 余额徽章 */
.balance-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 8px;
  border-radius: 99px;
  border: 1px solid rgba(52, 211, 153, 0.28);
  background: linear-gradient(135deg, rgba(52, 211, 153, 0.16), rgba(34, 211, 238, 0.08));
  color: #9df3d3;
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.balance-badge::before {
  content: "¥";
  display: inline-grid;
  place-items: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(52, 211, 153, 0.22);
  font-size: 10px;
  font-weight: 700;
  color: #b8ffe6;
}

.balance-badge .balance-value {
  font-weight: 600;
}

/* 价格小标签 */
.price-tag {
  padding: 1px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 11.5px;
  white-space: nowrap;
}

/* ------------------------------------------------------------- 07 app shell */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.sidebar {
  position: relative;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100%;
  padding: 16px 14px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(14, 20, 32, 0.92), rgba(10, 14, 22, 0.96));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 2px 4px 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  min-width: 0;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
  box-shadow: 0 8px 20px -10px rgba(140, 105, 255, 0.95);
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.brand-text strong {
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-text small {
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.brand-lg .brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  font-size: 15px;
}

.sidebar-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 6px 0;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.conv-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 2px;
  margin: 0 -2px;
}

.conv-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  text-align: left;
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
}

.conv-item:hover {
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
}

.conv-item.is-active {
  background: linear-gradient(135deg, rgba(109, 139, 255, 0.16), rgba(168, 85, 247, 0.1));
  border-color: rgba(109, 139, 255, 0.28);
  color: var(--text);
}

.conv-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: var(--text-faint);
  font-size: 11px;
}

.conv-model {
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conv-empty {
  padding: 18px 10px;
  color: var(--text-faint);
  font-size: 12.5px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}

.sidebar-foot {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.user-row {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 2px;
  min-width: 0;
}

.avatar {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
}

.avatar-ai {
  border-radius: 11px;
  background: var(--accent);
  border: 0;
  color: #fff;
  box-shadow: 0 6px 16px -10px rgba(140, 105, 255, 0.9);
}

.avatar-user {
  background: rgba(109, 139, 255, 0.18);
  border-color: rgba(109, 139, 255, 0.3);
  color: #d6e0ff;
}

.user-meta {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.user-meta > span:first-child {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-meta small {
  color: var(--text-faint);
  font-size: 11px;
}

.foot-actions {
  display: flex;
  gap: 6px;
}

.foot-actions .btn {
  flex: 1;
}

.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  height: 100%;
  overflow: hidden;
}

/* 顶栏 */
.topbar,
.chat-top {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 15, 23, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.chat-title,
.topbar-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.3;
}

.chat-title h1,
.topbar-titles h1 {
  font-size: 14.5px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-title p,
.topbar-titles p {
  color: var(--text-faint);
  font-size: 11.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-top-actions,
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.backdrop {
  display: none;
}

/* 移动端才出现的元素 */
.only-mobile {
  display: none;
}

/* ---------------------------------------------------------- 08 model picker */
.model-picker {
  position: relative;
  flex: 0 0 auto;
}

.model-select {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 210px;
  max-width: 300px;
  padding: 8px 11px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02));
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
}

.model-select:hover {
  border-color: rgba(109, 139, 255, 0.45);
  box-shadow: 0 0 0 3px rgba(109, 139, 255, 0.08);
}

.model-select[aria-expanded="true"] {
  border-color: rgba(109, 139, 255, 0.6);
  box-shadow: 0 0 0 3px rgba(109, 139, 255, 0.12);
}

.model-dot {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 4px rgba(109, 139, 255, 0.16);
}

.model-dot[data-type="image"] {
  background: var(--brand-2);
  box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.16);
}

.model-dot[data-type="video"] {
  background: var(--brand-3);
  box-shadow: 0 0 0 4px rgba(34, 211, 238, 0.16);
}

.model-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.model-price {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 11.5px;
  white-space: nowrap;
}

.model-caret {
  width: 8px;
  height: 8px;
  flex: 0 0 auto;
  margin-left: 2px;
  border-right: 1.5px solid var(--text-faint);
  border-bottom: 1.5px solid var(--text-faint);
  transform: rotate(45deg) translateY(-2px);
  transition: transform 0.2s var(--ease);
}

.model-select[aria-expanded="true"] .model-caret {
  transform: rotate(-135deg) translateY(-2px);
}

.model-menu {
  position: absolute;
  z-index: 60;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  max-height: min(64vh, 460px);
  overflow-y: auto;
  padding: 8px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: rgba(18, 26, 40, 0.98);
  box-shadow: var(--shadow-2), 0 0 0 1px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: pop-in 0.14s var(--ease);
}

.model-group + .model-group {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid var(--line);
}

.model-group-label {
  padding: 7px 9px 4px;
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.model-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.model-item:hover {
  background: rgba(255, 255, 255, 0.055);
}

.model-item.is-active {
  background: linear-gradient(135deg, rgba(109, 139, 255, 0.18), rgba(168, 85, 247, 0.1));
  border-color: rgba(109, 139, 255, 0.3);
}

.model-item-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.model-item-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-item-desc {
  color: var(--text-faint);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-item-price {
  flex: 0 0 auto;
  padding: 2px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11px;
  white-space: nowrap;
}

/* ------------------------------------------------------- 09 messages/bubbles */
.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 22px 20px 8px;
  scroll-behavior: smooth;
}

.messages-inner {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.day-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 6px 0 14px;
  color: var(--text-faint);
  font-size: 11.5px;
}

.day-divider::before,
.day-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-strong), transparent);
}

.msg {
  display: flex;
  gap: 11px;
  padding: 7px 0;
  animation: rise 0.22s var(--ease);
}

.msg[data-role="user"] {
  flex-direction: row-reverse;
}

.msg-body {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  max-width: min(760px, 84%);
}

.msg[data-role="user"] .msg-body {
  align-items: flex-end;
}

.bubble {
  position: relative;
  max-width: 100%;
  padding: 11px 15px;
  border-radius: 16px 16px 16px 6px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.032);
  color: var(--text);
  font-size: 14px;
  line-height: 1.68;
  overflow-wrap: anywhere;
}

.msg[data-role="user"] .bubble {
  border-radius: 16px 16px 6px 16px;
  border-color: rgba(109, 139, 255, 0.28);
  background: linear-gradient(135deg, rgba(91, 124, 250, 0.24), rgba(168, 85, 247, 0.18));
}

.bubble > :first-child {
  margin-top: 0;
}

.bubble > :last-child {
  margin-bottom: 0;
}

/* 气泡内无 padding 的媒体形态 */
.bubble.is-media {
  padding: 7px;
  background: rgba(255, 255, 255, 0.02);
}

/* 媒体气泡给一个确定宽度，避免 grid/video 的 min-content 把气泡压窄 */
.msg[data-role="assistant"][data-modality="image"] .msg-body,
.msg[data-role="assistant"][data-modality="video"] .msg-body {
  width: min(560px, 100%);
}

.msg[data-role="user"] .bubble.is-media {
  background: rgba(109, 139, 255, 0.12);
}

.msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
  color: var(--text-faint);
  font-size: 11px;
  line-height: 1.5;
  flex-wrap: wrap;
}

.msg-meta .dot {
  opacity: 0.5;
}

.msg-meta .cost {
  color: #9df3d3;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.msg-meta time {
  font-variant-numeric: tabular-nums;
}

.msg[data-streaming="true"] .msg-meta .status-text {
  color: #b9c6ff;
}

/* markdown-lite 渲染结果 */
.md > *:first-child {
  margin-top: 0;
}

.md > *:last-child {
  margin-bottom: 0;
}

.md p {
  margin: 0 0 0.65em;
}

.md h4 {
  margin: 1em 0 0.4em;
  font-size: 14.5px;
  font-weight: 600;
}

.md ul,
.md ol {
  margin: 0 0 0.7em;
  padding-left: 1.3em;
}

.md li {
  margin: 0.18em 0;
}

.md li::marker {
  color: var(--brand);
}

.md strong {
  color: #fff;
  font-weight: 600;
}

.md a {
  color: #9fbcff;
  text-decoration: underline;
  text-decoration-color: rgba(159, 188, 255, 0.35);
  text-underline-offset: 2px;
}

.md a:hover {
  text-decoration-color: rgba(159, 188, 255, 0.9);
}

.md code {
  padding: 1.5px 5px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: #c9d8ff;
  font-family: var(--mono);
  font-size: 0.88em;
  white-space: break-spaces;
}

.md pre {
  position: relative;
  margin: 0.8em 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #080c14;
  overflow-x: auto;
  max-width: 100%;
}

.md pre code {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  color: #d7e3ff;
  font-size: 12.5px;
  line-height: 1.62;
  white-space: pre;
}

.md pre[data-lang]::before {
  content: attr(data-lang);
  position: absolute;
  top: 6px;
  right: 10px;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.md blockquote {
  margin: 0 0 0.7em;
  padding: 2px 0 2px 12px;
  border-left: 2px solid rgba(109, 139, 255, 0.45);
  color: var(--text-dim);
}

/* 图片提示词小卡片（demo / 真实消息均可复用） */
.prompt-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.prompt-card .prompt-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.prompt-card p {
  margin: 0;
}

/* ------------------------------------------------------------ 10 attachments */
.msg-images {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  width: 100%;
}

/* 三张时第三张通栏，避免出现半空格子 */
.msg-images[data-count="3"] > .img-item:last-child {
  grid-column: 1 / -1;
  aspect-ratio: 16 / 10;
}

.msg-images.is-single {
  grid-template-columns: minmax(0, 1fr);
  width: min(420px, 100%);
}

.img-item {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: #05080f;
  cursor: zoom-in;
}

.msg-images.is-single .img-item {
  aspect-ratio: 4 / 3;
}

.img-item img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transition: transform 0.35s var(--ease), filter 0.2s;
}

.img-item:hover img {
  transform: scale(1.035);
  filter: brightness(1.05);
}

.img-item:focus-visible {
  outline: 2px solid rgba(109, 139, 255, 0.8);
  outline-offset: 2px;
}

.img-tools {
  position: absolute;
  right: 6px;
  bottom: 6px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.18s, transform 0.18s;
}

.img-item:hover .img-tools,
.img-item:focus-visible .img-tools {
  opacity: 1;
  transform: none;
}

.img-tool {
  display: inline-grid;
  place-items: center;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(6, 9, 15, 0.78);
  color: #fff;
  font-size: 11px;
  backdrop-filter: blur(8px);
}

.msg-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 2px 2px 0;
}

.msg-actions .btn {
  background: rgba(255, 255, 255, 0.04);
}

/* 视频 */
.msg-video {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(560px, 100%);
}

.video-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #05080f;
}

.video-frame.is-portrait {
  aspect-ratio: 9 / 16;
  width: min(300px, 100%);
}

.video-frame video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  background: #05080f;
}

.video-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 3px 8px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(6, 9, 15, 0.72);
  color: #dfe7f7;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  backdrop-filter: blur(8px);
  pointer-events: none;
}

.video-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* 生成中的视频骨架 */
.video-skeleton {
  display: grid;
  place-items: center;
  background:
    radial-gradient(420px 260px at 30% 20%, rgba(109, 139, 255, 0.18), transparent 65%),
    radial-gradient(380px 240px at 80% 80%, rgba(168, 85, 247, 0.16), transparent 65%),
    #080c15;
}

.video-shimmer {
  position: absolute;
  inset: -40%;
  background: linear-gradient(
    100deg,
    transparent 35%,
    rgba(255, 255, 255, 0.07) 48%,
    transparent 60%
  );
  animation: shimmer 2.6s linear infinite;
}

.video-state {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  border-radius: 99px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(6, 9, 15, 0.66);
  color: #dfe7f7;
  font-size: 12.5px;
  backdrop-filter: blur(10px);
}

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #9bb0ff;
  animation: spin 0.8s linear infinite;
}

/* -------------------------------------------------------- 11 progress/cursor */
.progress-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.progress {
  position: relative;
  flex: 1;
  height: 6px;
  min-width: 80px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: var(--accent);
  box-shadow: 0 0 12px rgba(140, 105, 255, 0.75);
  transition: width 0.45s var(--ease);
}

.progress-text {
  min-width: 34px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.progress.is-indeterminate .progress-bar {
  width: 38%;
  animation: indeterminate 1.5s var(--ease) infinite;
}

.msg-note {
  color: var(--text-faint);
  font-size: 11.5px;
}

/* 流式光标 */
.cursor {
  display: inline-block;
  width: 7px;
  height: 1.02em;
  margin-left: 2px;
  vertical-align: -0.16em;
  border-radius: 2px;
  background: linear-gradient(180deg, #8fa6ff, #c084fc);
  animation: blink 1.05s steps(2, start) infinite;
}

/* ---------------------------------------------------------------- 12 composer */
.composer {
  flex: 0 0 auto;
  padding: 10px 20px 16px;
  background: linear-gradient(180deg, transparent, rgba(11, 15, 23, 0.55) 45%);
}

.composer-inner {
  max-width: 900px;
  margin: 0 auto;
}

.composer-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 11px 12px 9px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: rgba(18, 26, 40, 0.92);
  box-shadow: var(--shadow-1), 0 0 0 1px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.composer-box:focus-within {
  border-color: rgba(109, 139, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(109, 139, 255, 0.12), var(--shadow-1);
}

.composer-input {
  width: 100%;
  min-height: 46px;
  max-height: 210px;
  padding: 4px 4px 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 14.5px;
  line-height: 1.6;
  resize: none;
  overflow-y: auto;
}

.composer-input::placeholder {
  color: #5b6880;
}

.composer-input:focus {
  outline: none;
}

.composer-opts {
  display: none;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 7px 6px;
  border-top: 1px dashed var(--line);
}

.composer[data-mode="image"] #composer-opts-image,
.composer[data-mode="video"] #composer-opts-video {
  display: flex;
}

.opt {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-faint);
  font-size: 12px;
}

.opt .select {
  width: auto;
  min-width: 96px;
  padding: 5px 26px 5px 9px;
  font-size: 12.5px;
  border-radius: 8px;
  background: rgba(8, 12, 20, 0.8);
}

.opt .select-wrap::after {
  right: 9px;
  font-size: 10px;
}

.opt-hint {
  margin-left: auto;
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 11px;
}

.composer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px;
}

.composer-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.composer-hint {
  color: var(--text-faint);
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 0 0 auto;
}

.composer[data-streaming="true"] #send {
  display: none;
}

.composer[data-streaming="true"] #stop {
  display: inline-flex;
}

#stop {
  display: none;
  border-color: rgba(248, 113, 113, 0.35);
  color: #ffb9b9;
  background: rgba(248, 113, 113, 0.1);
}

#stop::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: currentColor;
}

.composer-foot {
  padding: 7px 4px 0;
  color: var(--text-faint);
  font-size: 11px;
  text-align: center;
}

/* ------------------------------------------------------------- 13 auth/login */
.auth-body {
  display: flex;
  min-height: 100%;
  align-items: stretch;
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.06fr) minmax(420px, 0.94fr);
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
}

.auth-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 46px clamp(32px, 5vw, 76px);
  overflow: hidden;
  border-right: 1px solid var(--line);
  background:
    radial-gradient(620px 380px at 18% 8%, rgba(109, 139, 255, 0.2), transparent 62%),
    radial-gradient(560px 420px at 82% 78%, rgba(168, 85, 247, 0.18), transparent 62%),
    linear-gradient(180deg, rgba(14, 20, 33, 0.9), rgba(9, 12, 20, 0.96));
}

.auth-hero > * {
  position: relative;
  z-index: 2;
}

.auth-hero h1 {
  margin-top: auto;
  max-width: 12em;
  font-size: clamp(30px, 3.5vw, 46px);
  font-weight: 650;
  line-height: 1.18;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, #fff 25%, #c9d4ff 60%, #d8b4fe 95%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.auth-lead {
  max-width: 34em;
  color: var(--text-dim);
  font-size: 14.5px;
  line-height: 1.75;
}

.auth-points {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.auth-points li {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  color: var(--text-dim);
  font-size: 13.5px;
}

.tick {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  margin-top: 2px;
  border-radius: 50%;
  border: 1px solid rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.12);
  color: #8df0c8;
  font-size: 10px;
}

.auth-foot {
  margin-top: auto;
  color: var(--text-faint);
  font-size: 11.5px;
  letter-spacing: 0.02em;
}

.auth-orbs {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.auth-orbs span {
  position: absolute;
  border-radius: 50%;
  filter: blur(46px);
  opacity: 0.5;
}

.auth-orbs span:nth-child(1) {
  width: 280px;
  height: 280px;
  top: -70px;
  right: 6%;
  background: rgba(109, 139, 255, 0.45);
}

.auth-orbs span:nth-child(2) {
  width: 220px;
  height: 220px;
  bottom: 16%;
  left: -60px;
  background: rgba(168, 85, 247, 0.4);
}

.auth-orbs span:nth-child(3) {
  width: 160px;
  height: 160px;
  bottom: 4%;
  right: 18%;
  background: rgba(34, 211, 238, 0.3);
}

.auth-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px 28px;
}

.auth-card {
  width: min(400px, 100%);
  padding: 26px 26px 22px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(22, 32, 47, 0.92), rgba(14, 20, 32, 0.94));
  box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(16px);
}

.auth-card-head {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 20px;
}

.auth-card-head h2 {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.auth-card-head p {
  color: var(--text-faint);
  font-size: 12.5px;
}

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.captcha-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hcaptcha-slot {
  display: grid;
  place-items: center;
  min-height: 78px;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--line-strong);
  background: rgba(8, 12, 20, 0.55);
}

.hcaptcha-slot.is-loaded {
  border-style: solid;
  border-color: rgba(109, 139, 255, 0.25);
  background: rgba(8, 12, 20, 0.3);
}

.hcaptcha-slot.is-error {
  border-color: rgba(248, 113, 113, 0.4);
  background: var(--danger-dim);
}

.captcha-hint {
  color: var(--text-faint);
  font-size: 11.5px;
}

.auth-note {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.auth-note p {
  color: var(--text-faint);
  font-size: 12.5px;
  line-height: 1.6;
}

.auth-note .badge {
  align-self: flex-start;
}

.auth-alt {
  margin-top: 12px;
  color: var(--text-faint);
  font-size: 12px;
}

.auth-tip {
  max-width: 400px;
  color: var(--text-faint);
  font-size: 11.5px;
  text-align: center;
}

/* --------------------------------------------------------------- 14 admin */
.admin-app {
  grid-template-columns: 250px minmax(0, 1fr);
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 11px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.16s, color 0.16s;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
}

.nav-item.is-active {
  background: linear-gradient(135deg, rgba(109, 139, 255, 0.18), rgba(168, 85, 247, 0.1));
  border-color: rgba(109, 139, 255, 0.3);
  color: #e6ecff;
}

.nav-ico {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  font-size: 11px;
}

.nav-item.is-active .nav-ico {
  background: rgba(109, 139, 255, 0.28);
  color: #dbe4ff;
}

.views {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 22px 24px 46px;
}

.view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 1120px;
  margin: 0 auto;
  animation: fade-in 0.2s var(--ease);
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.view-head h2 {
  font-size: 16px;
  font-weight: 600;
}

.view-head p {
  margin-top: 3px;
  color: var(--text-faint);
  font-size: 12px;
}

.card {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012));
  box-shadow: var(--shadow-1);
}

.card-head {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 15px 18px 0;
}

.card-head h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14.5px;
  font-weight: 600;
}

.card-head p {
  color: var(--text-faint);
  font-size: 12px;
}

.card-body {
  padding: 16px 18px 18px;
}

.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr);
  gap: 16px;
  align-items: start;
}

.settings-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.test-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  grid-column: 1 / -1;
  padding-top: 2px;
}

.test-result {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-faint);
  font-size: 12px;
}

.test-result.ok {
  color: #8df0c8;
}

.test-result.error {
  color: #ffb4b4;
}

.settings-grid .form-actions {
  grid-column: 1 / -1;
}

.form-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 2px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: rgba(14, 20, 32, 0.94);
  backdrop-filter: blur(14px);
  box-shadow: 0 -10px 30px -20px rgba(0, 0, 0, 0.9);
  z-index: 5;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 360px;
}

.search-wrap .input {
  padding-left: 32px;
}

.search-wrap::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 11px;
  height: 11px;
  margin-top: -7px;
  border-radius: 50%;
  border: 1.5px solid var(--text-faint);
  pointer-events: none;
}

.search-wrap::after {
  content: "";
  position: absolute;
  left: 21px;
  top: 50%;
  width: 5px;
  height: 1.5px;
  background: var(--text-faint);
  transform: rotate(45deg) translateY(3px);
  pointer-events: none;
}

/* 表格 */
.table-card {
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}

.table thead th {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.022);
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-align: left;
  white-space: nowrap;
}

.table tbody td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: 0;
}

.table tbody tr {
  transition: background 0.14s;
}

.table tbody tr:hover {
  background: rgba(255, 255, 255, 0.028);
}

.table .cell-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.35;
}

.table .cell-main strong {
  font-weight: 500;
  font-size: 13px;
}

.table .cell-main small {
  color: var(--text-faint);
  font-family: var(--mono);
  font-size: 10.5px;
}

.table .num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.table .row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  flex-wrap: nowrap;
}

.table .row-actions .btn {
  padding: 4px 8px;
  font-size: 12px;
  background: transparent;
  border-color: var(--line);
}

.table .row-actions .btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.table-empty {
  padding: 34px 16px;
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
}

.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  color: var(--text-faint);
  font-size: 12px;
}

.pager {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pager button {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
}

.pager button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

.pager button.is-active {
  border-color: rgba(109, 139, 255, 0.45);
  background: rgba(109, 139, 255, 0.16);
  color: #dbe4ff;
}

.pager button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* 统计小卡 */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 13px 15px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.stat-label {
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: 0.06em;
}

.stat-value {
  font-family: var(--mono);
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.stat-value.is-up {
  color: #8df0c8;
}

.stat-value.is-down {
  color: #ffb4b4;
}

/* 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 12, 0.72);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  opacity: 0;
  transition: opacity 0.18s;
}

.modal-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(660px, 100%);
  max-height: min(88vh, 780px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #16202f, #0f1522);
  box-shadow: var(--shadow-2), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  opacity: 0;
  transform: translateY(10px) scale(0.985);
  transition: opacity 0.2s var(--ease), transform 0.2s var(--ease);
}

.modal.is-open .modal-backdrop {
  opacity: 1;
}

.modal.is-open .modal-panel {
  opacity: 1;
  transform: none;
}

.modal.is-sm .modal-panel {
  width: min(440px, 100%);
}

/* 弹窗内部表单撑满面板，让 .modal-body 成为唯一滚动区 */
.modal-panel > form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
}

.modal-panel > form > .modal-body,
.modal-panel > .modal-body {
  flex: 1 1 auto;
  min-height: 0;
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 20px 12px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2 {
  font-size: 15.5px;
  font-weight: 600;
}

.modal-head p {
  margin-top: 2px;
  color: var(--text-faint);
  font-size: 12px;
}

.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid var(--line);
}

.modal-foot .left {
  margin-right: auto;
  color: var(--text-faint);
  font-size: 11.5px;
}

.form-grid .field-group {
  display: none;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}

[data-type="chat"] .field-group[data-price-for="chat"],
[data-type="image"] .field-group[data-price-for="image"],
[data-type="video"] .field-group[data-price-for="video"] {
  display: grid;
}

.field-group-label {
  grid-column: 1 / -1;
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.field-group .span-2 {
  grid-column: 1 / -1;
}

/* 抽屉 */
.drawer {
  position: fixed;
  inset: 0;
  z-index: 85;
  display: grid;
  justify-items: end;
}

.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 6, 12, 0.66);
  backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.18s;
}

.drawer-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(520px, 100%);
  height: 100%;
  border-left: 1px solid var(--line-strong);
  background: linear-gradient(180deg, #121a28, #0d131e);
  box-shadow: -20px 0 50px -30px rgba(0, 0, 0, 0.9);
  transform: translateX(24px);
  opacity: 0;
  transition: transform 0.24s var(--ease), opacity 0.24s var(--ease);
}

.drawer.is-open .drawer-backdrop {
  opacity: 1;
}

.drawer.is-open .drawer-panel {
  transform: none;
  opacity: 1;
}

.ledger-list {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.ledger-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line);
}

.ledger-item:last-child {
  border-bottom: 0;
}

.ledger-item-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ledger-item-main strong {
  font-size: 12.5px;
  font-weight: 500;
}

.ledger-item-main small {
  color: var(--text-faint);
  font-size: 11px;
}

.ledger-amount {
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.ledger-amount.plus {
  color: #8df0c8;
}

.ledger-amount.minus {
  color: #ffb4b4;
}

/* 代码/JSON 展示 */
.json-view {
  margin: 0;
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: #080c14;
  color: #cfe0ff;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* --------------------------------------------------- 15 toast & lightbox */
.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  min-width: 220px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 10px 13px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(22, 32, 47, 0.97);
  box-shadow: var(--shadow-2);
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
  pointer-events: auto;
  animation: toast-in 0.22s var(--ease);
  backdrop-filter: blur(12px);
}

.toast::before {
  content: "";
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 3px rgba(109, 139, 255, 0.18);
}

.toast.is-ok::before {
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18);
}

.toast.is-error::before {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.18);
}

.toast.is-warn::before {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.18);
}

.toast.is-leaving {
  animation: toast-out 0.2s var(--ease) forwards;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 8px;
  padding: 16px;
  background: rgba(3, 5, 10, 0.94);
  backdrop-filter: blur(6px);
  animation: fade-in 0.16s var(--ease);
}

.lightbox-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.lightbox-stage {
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: auto;
}

.lightbox-stage img {
  max-width: 100%;
  max-height: 100%;
  border-radius: 12px;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.9);
}

.lightbox .btn-ghost {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.16);
}

/* 骨架块（加载占位） */
.skeleton {
  border-radius: 8px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.05) 25%,
    rgba(255, 255, 255, 0.09) 37%,
    rgba(255, 255, 255, 0.05) 63%
  );
  background-size: 400% 100%;
  animation: skeleton 1.4s ease infinite;
}

/* --------------------------------------------------------- 16 responsive */
@media (max-width: 1180px) {
  .settings-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .app,
  .admin-app {
    grid-template-columns: minmax(0, 1fr);
  }

  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: min(300px, 84vw);
    transform: translateX(-102%);
    transition: transform 0.24s var(--ease);
    box-shadow: 24px 0 60px -30px rgba(0, 0, 0, 0.95);
    border-right: 1px solid var(--line-strong);
    z-index: 70;
  }

  .app.sidebar-open .sidebar {
    transform: none;
  }

  .backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 60;
    background: rgba(3, 6, 12, 0.62);
    backdrop-filter: blur(3px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s;
  }

  .app.sidebar-open .backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .only-mobile {
    display: inline-grid;
  }

  .only-desktop {
    display: none !important;
  }

  .chat-top,
  .topbar {
    padding: 9px 14px;
    min-height: 58px;
    gap: 9px;
  }

  .chat-title h1,
  .topbar-titles h1 {
    font-size: 13.5px;
  }

  .chat-title p,
  .topbar-titles p {
    display: none;
  }

  .model-select {
    min-width: 0;
    max-width: 52vw;
    padding: 7px 9px;
  }

  .model-price {
    display: none;
  }

  .model-menu {
    width: min(340px, calc(100vw - 28px));
    right: 0;
  }

  .messages {
    padding: 16px 12px 4px;
  }

  .msg-body {
    max-width: 88%;
  }

  .composer {
    padding: 8px 10px 12px;
  }

  .composer-hint {
    display: none;
  }

  .composer-foot {
    font-size: 10.5px;
  }

  .views {
    padding: 16px 14px 40px;
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .form-grid .span-2 {
    grid-column: auto;
  }

  .table thead th,
  .table tbody td {
    padding: 9px 12px;
  }

  .auth-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-hero {
    display: none;
  }

  .auth-panel {
    padding: 28px 16px;
    justify-content: center;
  }

  .auth-card {
    padding: 22px 20px 18px;
  }

  .form-actions {
    padding: 10px 12px;
  }

  .modal {
    padding: 12px;
    align-items: end;
  }

  .modal-panel {
    width: 100%;
    max-height: 92vh;
  }

  .toast-stack {
    right: 10px;
    bottom: 10px;
    left: 10px;
  }

  .toast {
    max-width: none;
  }
}

@media (max-width: 560px) {
  .msg .avatar {
    display: none;
  }

  .msg-body {
    max-width: 100%;
  }

  .msg-images {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }


  .msg-images.is-single {
    width: 100%;
  }

  .opt-hint {
    margin-left: 0;
    width: 100%;
  }

  .view-head {
    align-items: flex-start;
  }

  .search-wrap {
    max-width: none;
  }

  .toolbar .btn {
    flex: 1;
  }
}

/* ------------------------------------------------------------- 17 motion */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes blink {
  0%,
  45% {
    opacity: 1;
  }
  50%,
  100% {
    opacity: 0.12;
  }
}

@keyframes shimmer {
  from {
    transform: translateX(-55%);
  }
  to {
    transform: translateX(55%);
  }
}

@keyframes indeterminate {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(320%);
  }
}

@keyframes pop-in {
  from {
    opacity: 0;
    transform: translateY(-5px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(6px);
  }
}

@keyframes skeleton {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}