/* ============================================================
   ArityFlow App 设计系统
   主色：科技蓝 #2563EB ｜ 零渐变、零紫色
   双模式：浅色 / 深色（CSS 变量驱动）
   ============================================================ */

/* ---------- 主题变量 ---------- */
:root {
  /* 主色 */
  --primary: #2563EB;
  --primary-strong: #1D4ED8;
  --primary-soft: rgba(37, 99, 235, 0.08);
  --primary-softer: rgba(37, 99, 235, 0.04);
  --on-primary: #FFFFFF;

  /* 语义色 */
  --success: #16A34A;
  --success-soft: rgba(22, 163, 74, 0.10);
  --warning: #D97706;
  --warning-soft: rgba(217, 119, 6, 0.10);
  --danger: #DC2626;
  --danger-soft: rgba(220, 38, 38, 0.10);
  --info: #0891B2;

  /* 中性色 */
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --surface-2: #F0F1F3;
  --surface-3: #E7E8EB;
  --border: #E4E6EA;
  --border-strong: #D3D6DC;
  --text-1: #16181D;
  --text-2: #555A64;
  --text-3: #9AA0AA;
  --shadow: 0 1px 2px rgba(22, 24, 29, 0.04), 0 2px 8px rgba(22, 24, 29, 0.05);
  --shadow-lg: 0 8px 32px rgba(22, 24, 29, 0.14);

  /* 布局 */
  --radius-lg: 18px;
  --radius: 14px;
  --radius-sm: 10px;
  --tabbar-h: 56px;
  --header-h: 48px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, "Courier New", monospace;
}

html[data-theme="dark"] {
  --primary: #3B82F6;
  --primary-strong: #60A5FA;
  --primary-soft: rgba(59, 130, 246, 0.16);
  --primary-softer: rgba(59, 130, 246, 0.07);
  --on-primary: #FFFFFF;

  --success: #22C55E;
  --success-soft: rgba(34, 197, 94, 0.14);
  --warning: #F59E0B;
  --warning-soft: rgba(245, 158, 11, 0.14);
  --danger: #EF4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --info: #22D3EE;

  --bg: #101216;
  --surface: #191C22;
  --surface-2: #22262E;
  --surface-3: #2B303A;
  --border: #2A2F38;
  --border-strong: #3A404C;
  --text-1: #ECEEF2;
  --text-2: #A6ACB8;
  --text-3: #6C7380;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* ---------- 重置 ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-1);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font-family: inherit; border: none; background: none; color: inherit; cursor: pointer; font-size: inherit; }
input, textarea, select { font-family: inherit; font-size: 15px; color: var(--text-1); }
input::placeholder, textarea::placeholder { color: var(--text-3); }
a { color: var(--primary); text-decoration: none; }
h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; }
i[data-lucide] { display: inline-flex; }

/* ---------- App 壳 ---------- */
.app {
  position: relative;
  max-width: 480px;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 0 1px var(--border);
  overflow: hidden;
}

/* ---------- 顶部导航栏 ---------- */
.app-header {
  height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) 8px 0;
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}
.header-title {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 7px;
  font-size: 17px; font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  padding: 0 4px;
  min-width: 0;
}
.header-title svg { width: 18px; height: 18px; color: var(--primary); flex: none; }
.header-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.header-actions { display: flex; align-items: center; gap: 2px; min-width: 84px; justify-content: flex-end; }
.app-header:not(.has-back) .header-actions { min-width: 0; flex: 1; justify-content: flex-end; }
/* 子页：右侧空区与返回按钮等宽，保证标题居中 */
.app-header.has-back .header-actions { min-width: 44px; }
.app-header:not(.has-back) .header-title { justify-content: flex-start; padding-left: 10px; }
.icon-btn {
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; color: var(--text-2);
  transition: background 0.15s, color 0.15s;
}
.icon-btn:active { background: var(--surface-2); color: var(--text-1); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- 视图容器 ---------- */
.view {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  position: relative;
}
.page { padding: 12px 14px calc(16px + var(--safe-bottom)); min-height: 100%; animation: pageIn 0.22s ease; }
@keyframes pageIn { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }

/* ---------- 底部 Tab 栏 ---------- */
.tabbar {
  flex: none;
  display: flex;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 20;
}
.tab-item {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  color: var(--text-3);
  font-size: 11px;
  transition: color 0.15s;
  position: relative;
}
.tab-item svg { width: 22px; height: 22px; transition: transform 0.15s; }
.tab-item:active svg { transform: scale(0.92); }
.tab-item.active { color: var(--primary); }

/* ---------- 通用按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 42px; padding: 0 18px;
  border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 500;
  transition: transform 0.08s, opacity 0.15s, background 0.15s, color 0.15s;
  user-select: none; white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:active { background: var(--primary-strong); }
.btn-soft { background: var(--primary-soft); color: var(--primary); }
.btn-soft:active { background: var(--primary-softer); }
.btn-ghost { background: var(--surface-2); color: var(--text-1); }
.btn-ghost:active { background: var(--surface-3); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger-solid { background: var(--danger); color: #FFF; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-lg { height: 48px; font-size: 16px; border-radius: var(--radius); }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field-label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.input {
  width: 100%; height: 44px;
  padding: 0 14px;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.input:focus { border-color: var(--primary); background: var(--surface); }
.textarea {
  width: 100%; padding: 10px 14px;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  outline: none; resize: vertical; min-height: 72px;
  transition: border-color 0.15s, background 0.15s;
}
.textarea:focus { border-color: var(--primary); background: var(--surface); }
.select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%; height: 44px; padding: 0 34px 0 14px;
  background-color: var(--surface-2);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%239AA0AA' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  border: 1.5px solid transparent; border-radius: var(--radius-sm);
  outline: none; cursor: pointer;
  transition: border-color 0.15s, background-color 0.15s;
}
.select:focus { border-color: var(--primary); }
.select option { background: var(--surface); color: var(--text-1); }
.input-row { display: flex; gap: 8px; }
.input-row .input { flex: 1; }

/* 开关 */
.switch { position: relative; width: 46px; height: 27px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0;
  background: var(--surface-3);
  border-radius: 999px;
  transition: background 0.2s;
}
.switch .track::after {
  content: "";
  position: absolute; top: 2.5px; left: 2.5px;
  width: 22px; height: 22px;
  background: #FFF;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(19px); }

/* ---------- 卡片 / 列表 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.card-pad { padding: 14px 16px; }
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
  width: 100%; text-align: left;
}
.list-item:last-child { border-bottom: none; }
.list-item:active { background: var(--surface-2); }
.list-item .li-icon {
  width: 36px; height: 36px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: var(--primary-soft); color: var(--primary);
}
.list-item .li-icon svg { width: 18px; height: 18px; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-title { display: block; font-size: 15px; color: var(--text-1); }
.list-item .li-sub { display: block; font-size: 12.5px; color: var(--text-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .li-right { flex: none; display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-3); }
.list-item .li-right svg { width: 16px; height: 16px; }
.section-title { font-size: 13px; color: var(--text-3); font-weight: 600; margin: 18px 4px 8px; letter-spacing: 0.02em; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-flex; align-items: center;
  height: 20px; padding: 0 8px;
  border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: var(--surface-2); color: var(--text-2);
  white-space: nowrap;
}
.badge-blue { background: var(--primary-soft); color: var(--primary); }
.badge-green { background: var(--success-soft); color: var(--success); }
.badge-orange { background: var(--warning-soft); color: var(--warning); }
.badge-red { background: var(--danger-soft); color: var(--danger); }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed;
  left: 50%; bottom: calc(96px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 300;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none;
  max-width: 90vw;
}
.toast {
  background: rgba(22, 24, 29, 0.92);
  color: #FFF;
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13.5px;
  max-width: 82vw;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.25s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
html[data-theme="dark"] .toast { background: rgba(236, 238, 242, 0.95); color: #16181D; }
.toast.toast-error { background: var(--danger); color: #FFF; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) scale(0.95); } to { opacity: 1; transform: none; } }

/* ---------- 底部面板 Sheet ---------- */
.sheet-mask {
  position: fixed; inset: 0;
  background: rgba(10, 12, 16, 0.45);
  z-index: 200;
  animation: fadeIn 0.2s ease;
  display: flex;
  justify-content: center;
  align-items: flex-end;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%;
  max-width: 480px;
  max-height: 88dvh;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  display: flex; flex-direction: column;
  padding-bottom: var(--safe-bottom);
  animation: sheetUp 0.28s cubic-bezier(0.2, 0.9, 0.3, 1);
  overflow: hidden;
}
@keyframes sheetUp { from { transform: translateY(40%); opacity: 0.5; } to { transform: none; opacity: 1; } }
.sheet-head {
  flex: none;
  display: flex; align-items: center;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.sheet-head .sheet-title {
  flex: 1; font-size: 16px; font-weight: 600; text-align: center;
  display: flex; align-items: center; justify-content: center; gap: 7px;
}
.sheet-head .sheet-title > i { display: inline-flex; }
.sheet-head .sheet-title svg { width: 17px; height: 17px; color: var(--primary); }
.sheet-head .icon-btn { color: var(--text-3); }
.sheet-body { flex: 1; overflow-y: auto; padding: 14px 16px; }
.sheet-grip {
  flex: none;
  width: 36px; height: 4px;
  margin: 8px auto 0;
  border-radius: 999px;
  background: var(--surface-3);
}

/* 居中弹窗 */
.dialog-mask {
  position: fixed; inset: 0;
  background: rgba(10, 12, 16, 0.45);
  z-index: 210;
  display: flex; align-items: center; justify-content: center;
  padding: 28px;
  animation: fadeIn 0.18s ease;
}
.dialog {
  width: 100%; max-width: 340px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 20px 18px 14px;
  box-shadow: var(--shadow-lg);
  animation: dialogIn 0.22s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
@keyframes dialogIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: none; } }
.dialog-title { font-size: 16px; font-weight: 600; margin-bottom: 8px; text-align: center; }
.dialog-msg { font-size: 14px; color: var(--text-2); text-align: center; line-height: 1.6; word-break: break-all; }
.dialog-btns { display: flex; gap: 10px; margin-top: 18px; }
.dialog-btns .btn { flex: 1; }

/* ---------- App 风格选择器（替代原生 select） ---------- */
.select-custom {
  width: 100%; height: 44px;
  display: flex; align-items: center; gap: 8px;
  padding: 0 14px;
  background: var(--surface-2);
  border: 1.5px solid transparent;
  border-radius: var(--radius-sm);
  text-align: left;
  font-size: 15px; color: var(--text-1);
  transition: border-color 0.15s, background 0.15s;
}
.select-custom:active { background: var(--surface-3); }
.select-custom-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-custom svg { width: 16px; height: 16px; color: var(--text-3); flex: none; transition: transform 0.2s; }
.select-custom.open svg { transform: rotate(180deg); }
/* 顶栏紧凑模式（聊天页模型选择） */
.chat-topbar #chat-model-slot { flex: 1; min-width: 0; }
.chat-topbar #chat-model-slot.model-slot-narrow { flex: 1; min-width: 0; }
.chat-topbar .select-custom {
  width: 100%; height: 38px;
  border-radius: 9px; font-size: 13.5px;
  background: var(--surface-2);
}
/* 流式/非流式切换 */
.chat-stream-seg { flex: none; height: 38px; padding: 3.5px; box-sizing: border-box; }
.chat-stream-seg button { height: 31px; padding: 0 9px; white-space: nowrap; }
/* 模型分组选择器（sheet 内两级：分组 → 模型） */
.gmp-group-label { font-size: 13px; color: var(--text-3); font-weight: 600; margin: 4px 4px 8px; letter-spacing: 0.02em; }
.gmp-group-list {
  display: flex; flex-direction: column;
  max-height: 200px; overflow-y: auto;
  background: var(--surface-2);
  border-radius: 14px;
  margin-bottom: 12px;
}
.gmp-group-item {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  transition: background 0.12s;
  position: relative;
}
.gmp-group-item:last-child { border-bottom: none; }
.gmp-group-item:active { background: var(--surface-3); }
.gmp-group-item.active { background: var(--primary-soft); }
.gmp-group-item.active .gmp-gname { color: var(--primary); font-weight: 600; }
.gmp-gname { font-size: 15px; font-weight: 600; color: var(--text-1); }
.gmp-gdesc { font-size: 12px; color: var(--text-3); }
.gmp-gcheck { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--primary); }
.gmp-search {
  display: flex; align-items: center; gap: 8px;
  height: 38px;
  padding: 0 12px;
  background: var(--surface-2);
  border-radius: 10px;
  margin-bottom: 10px;
}
.gmp-search svg { width: 16px; height: 16px; color: var(--text-3); flex: none; }
.gmp-search input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 13.5px; color: var(--text-1);
}
.gmp-model-list {
  display: flex; flex-direction: column;
  max-height: 320px; overflow-y: auto;
}
.gmp-model-item {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 14px;
  border-radius: 12px;
  font-size: 15px;
  color: var(--text-1);
  text-align: left;
  transition: background 0.12s;
}
.gmp-model-item:active { background: var(--surface-2); }
.gmp-model-item.active { color: var(--primary); font-weight: 600; background: var(--primary-soft); }
.gmp-model-item .gmp-mname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gmp-model-item svg { width: 16px; height: 16px; flex: none; }
/* 选项列表（底部面板内） */
.pick-list { display: flex; flex-direction: column; }
.pick-item {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 14px;
  border-radius: 12px;
  font-size: 15px;
  color: var(--text-1);
  text-align: left;
  transition: background 0.12s;
}
.pick-item:active { background: var(--surface-2); }
.pick-item.active { color: var(--primary); font-weight: 600; background: var(--primary-soft); }
.pick-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-item svg { width: 16px; height: 16px; flex: none; }

/* 导入重名冲突提示文案 */
.conflict-tip { font-size: 13px; color: var(--text-2); line-height: 1.6; margin-bottom: 12px; }

/* ---------- 骨架屏 ---------- */
.skeleton {
  background: var(--surface-2);
  border-radius: 8px;
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

/* ---------- 空状态 ---------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 24px; gap: 12px;
  color: var(--text-3);
}
.empty svg { width: 44px; height: 44px; opacity: 0.5; }
.empty .empty-text { font-size: 13.5px; }

/* ============================================================
   认证页
   ============================================================ */
.auth-view {
  min-height: 100%;
  display: flex; flex-direction: column;
  padding: calc(64px + var(--safe-top)) 28px calc(24px + var(--safe-bottom));
  animation: pageIn 0.22s ease;
}
.auth-brand { text-align: center; margin-bottom: 34px; }
.auth-logo-img {
  width: 78px; height: 78px;
  margin: 0 auto 16px;
  border-radius: 22px;
  object-fit: cover;
  display: block;
  box-shadow: 0 4px 16px rgba(22, 24, 29, 0.10);
}
.auth-brand h1 { font-size: 24px; letter-spacing: 0.01em; }
.auth-welcome { font-size: 13.5px; color: var(--text-3); margin-top: 6px; }
.auth-brand-sm { margin-bottom: 26px; }
.auth-register { padding-top: calc(14px + var(--safe-top)); }
.auth-back {
  width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  background: var(--surface-2); color: var(--text-2);
  margin-bottom: 18px;
}
.auth-back:active { background: var(--surface-3); }
.auth-back svg { width: 20px; height: 20px; }

/* 图标输入框（App 原生风格，无卡片包裹） */
.auth-input {
  display: flex; align-items: center; gap: 10px;
  height: 48px;
  padding: 0 14px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-input:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.auth-input > svg { width: 19px; height: 19px; color: var(--text-3); flex: none; transition: color 0.15s; }
.auth-input:focus-within > svg { color: var(--primary); }
.auth-input .input {
  flex: 1; height: 100%;
  border: none; background: transparent;
  padding: 0;
}
.auth-input .input:focus { border-color: transparent; background: transparent; }
.auth-eye {
  width: 32px; height: 32px; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3); border-radius: 8px;
}
.auth-eye:active { background: var(--surface-2); color: var(--text-1); }
.auth-eye svg { width: 18px; height: 18px; }

/* 验证码行 */
.auth-code-row { display: flex; gap: 10px; align-items: stretch; }
.auth-code-row .auth-input { flex: 1; }
.auth-code-row #btn-send-code { flex: none; width: 118px; height: 48px; border-radius: 14px; }

/* 页面底部切换链接 */
.auth-switch {
  text-align: center;
  font-size: 14px;
  color: var(--text-2);
  margin-top: 24px;
}
.auth-switch button { color: var(--primary); font-weight: 600; }
.auth-switch button:active { opacity: 0.7; }

.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 13px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  display: none;
}
.form-error.show { display: block; animation: pageIn 0.18s ease; }

/* ============================================================
   首页
   ============================================================ */
.home-hello { display: flex; align-items: center; gap: 12px; margin: 4px 2px 14px; }
.home-avatar {
  width: 44px; height: 44px; flex: none;
  border-radius: 50%;
  background: var(--primary);
  color: #FFF;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 17px;
}
.home-hello .hh-name { font-size: 17px; font-weight: 600; }
.home-hello .hh-sub { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }

.quota-card {
  background: var(--primary);
  color: #FFF;
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.quota-card::after {
  content: "";
  position: absolute; right: -26px; top: -26px;
  width: 110px; height: 110px;
  border: 18px solid rgba(255, 255, 255, 0.12);
  border-radius: 50%;
}
.quota-head { display: flex; align-items: center; justify-content: space-between; font-size: 13px; opacity: 0.9; }
.quota-refresh-btn {
  position: absolute; bottom: 14px; right: 14px;
  background: rgba(255, 255, 255, 0.16); color: #FFF;
  border-radius: 50%; width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  z-index: 2;
}
.quota-refresh-btn:active { background: rgba(255, 255, 255, 0.28); }
.quota-refresh-btn svg { width: 14px; height: 14px; }
.quota-refresh-btn.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.quota-num { font-size: 30px; font-weight: 700; margin: 8px 0 2px; letter-spacing: 0.01em; padding-right: 122px; }
.quota-sub { font-size: 12.5px; opacity: 0.85; padding-right: 122px; }
.quota-actions { display: flex; gap: 8px; margin-top: 14px; position: relative; z-index: 1; }
.quota-actions .btn { background: rgba(255, 255, 255, 0.16); color: #FFF; height: 34px; font-size: 13px; border-radius: 9px; }
.quota-actions .btn:active { background: rgba(255, 255, 255, 0.28); }

/* 看广告赚余额入口（余额卡右侧空白处，垂直居中胶囊；三态：正常/冷却倒计时/今日达上限） */
.quota-ad-btn {
  position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
  z-index: 1;
  display: flex; align-items: center; gap: 7px;
  background: rgba(255, 255, 255, 0.16); color: #FFF;
  border-radius: 999px; padding: 9px 14px;
  font-size: 13px; font-weight: 600; line-height: 1.2;
  white-space: nowrap; /* disabled 态文案「明日 8 点重置」不换行 */
}
.quota-ad-btn:active { background: rgba(255, 255, 255, 0.28); }
.quota-ad-btn:disabled { opacity: 0.65; }
.quota-ad-btn svg { width: 19px; height: 19px; flex: none; }
.quota-ad-text { display: flex; flex-direction: column; align-items: flex-start; }
.quota-ad-text small { font-size: 10.5px; font-weight: 400; opacity: 0.85; margin-top: 1px; }

.stat-row { display: flex; gap: 10px; margin-top: 12px; }
.stat-card {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.stat-card .sc-label { font-size: 12px; color: var(--text-3); }
.stat-card .sc-value { font-size: 18px; font-weight: 650; margin-top: 3px; }
.stat-card .sc-value small { font-size: 11.5px; font-weight: 500; color: var(--text-3); }

.quick-grid { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 10px; }
.quick-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 6px 11px;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  font-size: 12px; color: var(--text-2);
  transition: transform 0.1s, background 0.12s;
}
.quick-item:active { transform: scale(0.95); background: var(--surface-2); }
.quick-item .qi-icon {
  width: 38px; height: 38px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
}
.quick-item .qi-icon svg { width: 19px; height: 19px; }

.model-list { display: flex; flex-wrap: wrap; gap: 8px; }
.model-chip {
  padding: 8px 13px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px; color: var(--text-2);
  transition: all 0.15s;
}
.model-chip:active { transform: scale(0.94); }
.model-chip.chip-active { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); font-weight: 500; }

/* 折叠区块（details/summary 通用） */
.collapse summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.collapse summary::-webkit-details-marker { display: none; }
.collapse summary .chev {
  flex: none;
  width: 15px; height: 15px;
  color: var(--text-3);
  transition: transform 0.2s;
  margin-left: auto;
}
.collapse[open] summary .chev { transform: rotate(180deg); }

/* ---------- 首页折叠组件 ---------- */
.banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  margin-bottom: 12px;
  overflow: hidden;
}
.banner summary {
  display: flex; align-items: center; gap: 6px;
  padding: 12px 14px;
  font-size: 13.5px; font-weight: 600;
}
.banner summary:active { background: var(--surface-2); }
.banner-title { display: flex; align-items: center; gap: 6px; }
.banner-title svg { width: 15px; height: 15px; color: var(--primary); }
.banner-text { font-size: 12.5px; color: var(--text-2); white-space: pre-wrap; max-height: 96px; overflow-y: auto; line-height: 1.7; padding: 0 14px 12px; }
.banner-text:empty { display: none; }

.model-panel summary {
  display: flex; align-items: center; gap: 6px;
  cursor: pointer;
}
.model-panel[open] summary { margin-bottom: 10px; }

/* ============================================================
   聊天页
   ============================================================ */
.chat-page { display: flex; flex-direction: column; padding: 0; height: 100%; animation: none; }
.chat-topbar {
  flex: none;
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.chat-topbar .select {
  flex: 1; height: 38px;
  background-color: var(--surface-2);
  font-size: 13.5px;
  border-radius: 9px;
}
.chat-topbar .icon-btn { width: 38px; height: 38px; flex: none; }

.chat-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden; /* 长内容/代码块横向溢出防护 */
  -webkit-overflow-scrolling: touch;
  padding: 14px 12px 8px;
  display: flex; flex-direction: column; gap: 14px;
}
.chat-empty {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px;
  color: var(--text-3);
}
.chat-empty svg { width: 46px; height: 46px; opacity: 0.45; }
.chat-empty .ce-title { font-size: 15px; font-weight: 600; color: var(--text-2); }
.chat-empty .ce-sub { font-size: 12.5px; }

.msg { display: flex; flex-direction: column; max-width: 88%; animation: msgIn 0.2s ease; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg-user { align-self: flex-end; align-items: flex-end; }
.msg-assistant { align-self: flex-start; align-items: flex-start; max-width: 94%; }

.msg-bubble {
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.62;
  word-break: break-word;
}
.msg-user .msg-bubble {
  background: var(--primary);
  color: #FFF;
  border-bottom-right-radius: 5px;
}
.msg-assistant .msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-1);
  border-bottom-left-radius: 5px;
  box-shadow: var(--shadow);
}
.msg-time { font-size: 10.5px; color: var(--text-3); margin-top: 4px; padding: 0 4px; }
.msg-error .msg-bubble { background: var(--danger-soft); color: var(--danger); border-color: transparent; }

/* 思考过程折叠 */
.msg-reasoning {
  margin-bottom: 8px;
  width: 100%;
  background: var(--surface-2);
  border-radius: 12px;
  overflow: hidden;
}
.msg-reasoning summary {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 12px;
  font-size: 12px; font-weight: 600;
  color: var(--text-2);
  cursor: pointer; user-select: none;
  list-style: none;
}
.msg-reasoning summary::-webkit-details-marker { display: none; }
.msg-reasoning summary svg { width: 14px; height: 14px; transition: transform 0.18s; }
.msg-reasoning[open] summary svg { transform: rotate(90deg); }
.msg-reasoning .reason-body {
  padding: 2px 12px 10px;
  font-size: 12.5px;
  color: var(--text-2);
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.msg-streaming .msg-bubble::after {
  content: "";
  display: inline-block;
  width: 7px; height: 14px;
  margin-left: 2px;
  vertical-align: -2px;
  border-radius: 2px;
  background: var(--primary);
  animation: blink 0.9s infinite;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* 流式加载态：thinking 三点动画 */
.thinking {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-3);
  padding: 2px 0;
}
.thinking-dots { display: inline-flex; gap: 4px; }
.thinking-dots i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-3);
  animation: thinkBounce 1.2s infinite ease-in-out;
}
.thinking-dots i:nth-child(2) { animation-delay: 0.15s; }
.thinking-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes thinkBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* 消息内图片（多模态） */
.chat-msg-imgs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chat-msg-img {
  max-width: 200px; max-height: 200px;
  border-radius: 10px;
  object-fit: cover;
  display: block;
}
.chat-msg-text { white-space: pre-wrap; word-break: break-word; }

/* 待发送图片预览 */
.chat-img-preview {
  display: flex; gap: 8px;
  padding: 0 12px 6px;
  overflow-x: auto;
}
.chat-img-preview.hidden { display: none; }
.chat-preview {
  position: relative; flex: none;
  width: 64px; height: 64px;
}
.chat-preview img {
  width: 100%; height: 100%;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
}
.chat-preview-del {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--danger); color: #FFF;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
}
.chat-preview-del svg { width: 11px; height: 11px; }

/* 输入栏图片按钮 */
.chat-img-btn { color: var(--text-3); flex: none; }
.chat-img-btn:active { color: var(--primary); background: var(--primary-soft); }

/* 编辑指示条 */
.chat-editbar {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px 2px;
}
.chat-edit-tip {
  flex: 1;
  font-size: 11.5px; color: var(--primary);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-editbar .icon-btn { width: 26px; height: 26px; }
.chat-editbar .icon-btn svg { width: 14px; height: 14px; }
.chat-input-inner.editing { border-color: var(--primary); }

/* 会话抽屉：搜索 + 分类 */
.sess-search {
  display: flex; align-items: center; gap: 8px;
  height: 38px;
  padding: 0 12px;
  background: var(--surface-2);
  border-radius: 10px;
  margin-bottom: 10px;
}
.sess-search svg { width: 16px; height: 16px; color: var(--text-3); flex: none; }
.sess-search input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 13.5px; color: var(--text-1);
}
.sess-cats { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.sess-cats-scroll {
  flex: 1; min-width: 0;
  display: flex; gap: 6px; overflow-x: auto;
  padding: 2px;
}
.sess-chip {
  flex: none;
  height: 30px; padding: 0 13px;
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 12.5px; color: var(--text-2);
  transition: all 0.15s;
}
.sess-chip:active { transform: scale(0.95); }
.sess-chip.active { background: var(--primary); color: #FFF; font-weight: 600; }
.sess-cat-manage {
  flex: none;
  width: 32px; height: 32px;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); background: var(--surface-2);
}
.sess-cat-manage:active { background: var(--surface-3); }
.sess-cat-manage svg { width: 16px; height: 16px; }

/* 消息操作条 */
.msg-actions { display: flex; gap: 2px; margin-top: 4px; opacity: 0; transition: opacity 0.15s; }
.msg:hover .msg-actions, .msg-actions.pinned { opacity: 1; }
/* 触屏设备无 hover：常显操作条 */
@media (hover: none) { .msg-actions { opacity: 1; } }
.msg-actions .icon-btn { width: 28px; height: 28px; border-radius: 8px; }
.msg-actions .icon-btn svg { width: 14px; height: 14px; }
.msg-meta { font-size: 11px; color: var(--text-3); padding: 0 4px; }

/* markdown 渲染 */
.md { word-break: break-word; overflow-x: auto; } /* 宽公式/表格横向滚动 */
.md-raw { white-space: pre-wrap; } /* 流式期间的纯文本过渡态 */
.md .katex-display { overflow-x: auto; overflow-y: hidden; padding: 2px 0; }

/* AI 回复原地编辑 */
.msg-edit-box { width: 100%; }
.msg-edit-input { background: var(--surface-2); }
.msg-edit-btns { display: flex; gap: 8px; margin-top: 8px; justify-content: flex-end; }
.md p { margin: 4px 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 12px 0 6px; font-size: 1.06em; }
.md h1 { font-size: 1.18em; } .md h2 { font-size: 1.12em; } .md h3 { font-size: 1.07em; }
.md ul, .md ol { margin: 4px 0; padding-left: 20px; }
.md li { margin: 2px 0; }
.md blockquote {
  border-left: 3px solid var(--border-strong);
  padding-left: 10px;
  color: var(--text-2);
  margin: 6px 0;
}
.md code {
  font-family: var(--mono);
  font-size: 0.88em;
  background: var(--surface-2);
  padding: 1.5px 5px;
  border-radius: 5px;
}
.md pre {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 8px 0;
  overflow-x: auto;
  position: relative;
}
.md pre code { background: none; padding: 0; font-size: 12.5px; line-height: 1.6; white-space: pre; }
.md pre .code-lang {
  position: absolute; top: 6px; right: 10px;
  font-size: 10.5px; color: var(--text-3);
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.md pre .code-copy {
  position: absolute; top: 5px; right: 8px;
  width: 26px; height: 26px;
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-3);
  background: transparent;
  transition: background 0.12s, color 0.12s;
  opacity: 0;
}
.md pre:hover .code-copy { opacity: 1; }
.md pre .code-copy:active { background: var(--surface-3); color: var(--text-1); }
.md pre .code-copy svg { width: 13px; height: 13px; }
.md a { word-break: break-all; }
.md hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }
.md table { border-collapse: collapse; margin: 8px 0; font-size: 13px; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 5px 10px; }
.md th { background: var(--surface-2); font-weight: 600; }
.md img { max-width: 100%; border-radius: 8px; }

/* 输入栏 */
.chat-inputbar {
  flex: none;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 8px 10px calc(8px + var(--safe-bottom));
}
.chat-input-inner {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--surface-2);
  border-radius: 20px;
  padding: 6px 6px 6px 14px;
  border: 1.5px solid transparent;
  transition: border-color 0.15s, background 0.15s;
}
.chat-input-inner:focus-within { border-color: var(--primary); background: var(--surface); }
.chat-input-inner textarea {
  flex: 1;
  border: none; outline: none; background: transparent;
  resize: none;
  max-height: 120px;
  font-size: 14.5px;
  line-height: 1.5;
  padding: 7px 0;
  color: var(--text-1);
}
.send-btn {
  width: 36px; height: 36px; flex: none;
  border-radius: 50%;
  background: var(--primary);
  color: #FFF;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.1s, opacity 0.15s, background 0.15s;
}
.send-btn svg { width: 17px; height: 17px; }
.send-btn:active { transform: scale(0.9); }
.send-btn:disabled { opacity: 0.4; pointer-events: none; }
.send-btn.stop { background: var(--danger); }

/* 会话抽屉 */
.session-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; }
.session-item.active { background: var(--primary-soft); }
.si-icon {
  width: 34px; height: 34px; flex: none;
  border-radius: 10px;
  background: var(--surface-2); color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
}
.session-item.active .si-icon { background: var(--primary); color: #FFF; }
.si-icon svg { width: 16px; height: 16px; }
.session-item .si-main { flex: 1; min-width: 0; }
.session-item .si-title { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.session-item .si-sub { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.session-item .si-del { color: var(--text-3); width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; border-radius: 8px; }
.session-item .si-del:active { background: var(--danger-soft); color: var(--danger); }
.session-item .si-del svg { width: 15px; height: 15px; }

/* 参数面板 */
.param-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 2px; border-bottom: 1px solid var(--border); }
.param-row:last-child { border-bottom: none; }
.param-row .pr-label { font-size: 14px; }
.param-row .pr-sub { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }
.param-row .pr-val { font-size: 14px; color: var(--primary); font-weight: 600; width: 52px; text-align: right; }
.param-row input[type="range"] {
  flex: 1; margin: 0 12px;
  accent-color: var(--primary);
  height: 26px;
}
.param-row input[type="range"]::-webkit-slider-thumb { cursor: pointer; }

/* ============================================================
   密钥管理页（App 卡片风格）
   ============================================================ */
.token-list { display: flex; flex-direction: column; gap: 10px; }
.token-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow);
  animation: pageIn 0.2s ease;
}
.tc-head { display: flex; align-items: center; gap: 10px; }
.tc-icon {
  width: 38px; height: 38px; flex: none;
  border-radius: 12px;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.tc-icon svg { width: 18px; height: 18px; }
.tc-info { flex: 1; min-width: 0; }
.tc-name { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 6px; min-width: 0; }
.tc-name .ellipsis { flex: 1; }
.tc-sub { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.tc-btn {
  width: 32px; height: 32px; flex: none;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.12s, transform 0.08s;
}
.tc-btn:active { opacity: 0.65; transform: scale(0.94); }
.tc-btn svg { width: 15px; height: 15px; }
.tc-btn-copy { background: var(--primary-soft); color: var(--primary); }
.tc-btn-del { background: var(--danger-soft); color: var(--danger); }
.tc-key {
  width: 100%;
  margin-top: 12px;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border-radius: 10px;
  padding: 10px 12px;
  text-align: left;
  transition: background 0.15s;
}
.tc-key:active { background: var(--surface-3); }
.tc-key-text {
  flex: 1;
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-2);
  word-break: break-all;
}
.tc-key-icon { width: 14px; height: 14px; color: var(--text-3); flex: none; }
.tc-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tc-meta {
  display: flex; gap: 12px; flex-wrap: wrap;
  font-size: 11.5px; color: var(--text-3);
  margin-top: 8px;
}

/* ============================================================
   我的页
   ============================================================ */
.profile-head {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 4px;
}
.profile-avatar {
  width: 54px; height: 54px; flex: none;
  border-radius: 50%;
  background: var(--primary);
  color: #FFF;
  display: flex; align-items: center; justify-content: center;
  font-size: 21px; font-weight: 600;
}
.profile-info { flex: 1; min-width: 0; }
.profile-name { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.profile-email { font-size: 12.5px; color: var(--text-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.profile-stats { display: flex; gap: 0; margin-top: 8px; }
.profile-stats .ps {
  flex: 1;
  display: flex; flex-direction: column;
  font-size: 11px; color: var(--text-3);
}
.profile-stats .ps b { font-size: 14px; color: var(--text-1); font-weight: 600; }

/* 签到日历 */
.checkin-card { margin-bottom: 12px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; margin-top: 10px; }
.cal-head { text-align: center; font-size: 11px; color: var(--text-3); padding: 3px 0; }
.cal-day {
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  border-radius: 10px;
  color: var(--text-2);
  position: relative;
}
.cal-day.other { color: var(--text-3); opacity: 0.45; }
.cal-day.done { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.cal-day.done::after {
  content: "";
  position: absolute; bottom: 4px;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--primary);
}
.cal-day.today { box-shadow: inset 0 0 0 1.5px var(--primary); font-weight: 600; }

/* 日志 */
.log-item { flex-direction: column; align-items: stretch; gap: 6px; }
.log-top { display: flex; align-items: center; gap: 10px; }
.log-content { font-size: 14px; flex: 1; min-width: 0; word-break: break-all; }
.log-model { font-family: var(--mono); font-size: 11.5px; color: var(--text-2); background: var(--surface-2); padding: 2px 7px; border-radius: 6px; }
.log-meta { font-size: 11.5px; color: var(--text-3); display: flex; gap: 12px; flex-wrap: wrap; }
.log-quota { color: var(--warning); font-weight: 600; }

/* 分段切换 */
.seg { display: flex; background: var(--surface-2); border-radius: 11px; padding: 3.5px; gap: 3.5px; }
.seg button {
  flex: 1; height: 32px;
  border-radius: 8px;
  font-size: 13px; font-weight: 500;
  color: var(--text-2);
  transition: all 0.15s;
}
.seg button.active { background: var(--surface); color: var(--primary); font-weight: 600; box-shadow: var(--shadow); }

/* 设置项 */
.set-item { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); width: 100%; }
.set-item:last-child { border-bottom: none; }
.set-item .si-label { flex: 1; font-size: 14.5px; text-align: left; }
.set-item .si-sub { display: block; font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

/* ---------- 工具类 ---------- */
.hidden { display: none !important; }
.flex { display: flex; align-items: center; }
.flex-1 { flex: 1; min-width: 0; }
.gap8 { gap: 8px; }
.gap12 { gap: 12px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb12 { margin-bottom: 12px; }
.text-2 { color: var(--text-2); } .text-3 { color: var(--text-3); }
.text-right { text-align: right; }
.mono { font-family: var(--mono); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 分页加载 */
.load-more { display: flex; justify-content: center; padding: 12px 0 4px; }
.load-more .btn { width: 100%; }

/* 滚动条（桌面端观感） */
.view::-webkit-scrollbar, .chat-body::-webkit-scrollbar, .sheet-body::-webkit-scrollbar,
.md pre::-webkit-scrollbar, .banner-text::-webkit-scrollbar { width: 5px; height: 5px; }
.view::-webkit-scrollbar-thumb, .chat-body::-webkit-scrollbar-thumb,
.sheet-body::-webkit-scrollbar-thumb, .md pre::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 999px; }

@media (min-width: 480px) {
  .toast-wrap { max-width: 480px; }
}

/* ============================================================
   模型详情 Sheet
   ============================================================ */
.mdl-sheet { display: flex; flex-direction: column; height: 100%; }
.mdl-sheet .mdl-tabs {
  display: flex; gap: 8px; margin-bottom: 14px;
  background: var(--surface-2); border-radius: 11px; padding: 4px;
}
.mdl-sheet .mdl-tab {
  flex: 1; height: 36px; border-radius: 8px;
  font-size: 14px; font-weight: 500; color: var(--text-2);
  background: transparent; transition: all 0.15s;
}
.mdl-sheet .mdl-tab.active {
  background: var(--surface); color: var(--primary); font-weight: 600;
  box-shadow: var(--shadow);
}
.mdl-sheet .mdl-panel { flex: 1; overflow-y: auto; }
.mdl-sheet .mdl-panel.hidden { display: none; }
.mdl-sheet .mdl-content { display: flex; flex-direction: column; gap: 12px; }
.mdl-sheet .mdl-footer {
  flex: none; padding-top: 12px; margin-top: 4px;
  border-top: 1px solid var(--border);
}
.mdl-sheet .mdl-footer .btn { height: 48px; font-size: 16px; border-radius: 12px; }

/* 模型详情卡片 */
.mdl-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.mdl-card .mdl-card-title {
  font-size: 13px; color: var(--text-2); font-weight: 600;
  margin-bottom: 10px; letter-spacing: 0.02em;
}
.mdl-card .mdl-empty {
  font-size: 13px; color: var(--text-3); text-align: center;
  padding: 24px 0;
}

/* 模型详情头部 */
.mdl-header {
  display: flex; flex-direction: column; gap: 8px;
  padding: 4px 0 12px;
}
.mdl-header-name {
  font-size: 20px; font-weight: 700; color: var(--text-1);
  letter-spacing: -0.01em;
}

/* 指标网格 */
.mdl-metrics {
  display: flex; gap: 12px; flex-wrap: wrap;
}
.mdl-metric {
  flex: 1; min-width: 80px;
  display: flex; flex-direction: column; gap: 4px;
}
.mdl-metric-label {
  font-size: 11px; color: var(--text-3);
}
.mdl-metric-val {
  font-size: 18px; font-weight: 600; color: var(--text-1);
}
.mdl-metric-val.success { color: var(--success); }

/* 定价信息 */
.mdl-pricing-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.mdl-pricing-row:last-child { border-bottom: none; padding-bottom: 0; }
.mdl-pricing-label { font-size: 13px; color: var(--text-2); }
.mdl-pricing-val { font-size: 13px; color: var(--text-1); font-weight: 500; }

/* 模型信息 */
.mdl-model-info { display: flex; flex-direction: column; gap: 6px; }
.mdl-model-name {
  font-size: 16px; font-weight: 600; color: var(--text-1);
}
.mdl-model-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-2);
}

/* 表格 */
.mdl-table-wrap { overflow-x: auto; }
.mdl-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
}
.mdl-table th, .mdl-table td {
  padding: 8px 6px; text-align: left;
  border-bottom: 1px solid var(--border);
}
.mdl-table th {
  font-weight: 600; color: var(--text-2); background: var(--surface-3);
  white-space: nowrap;
}
.mdl-table td { color: var(--text-1); }
.mdl-table tr:last-child td { border-bottom: none; }

/* ============================================================
   订阅管理页
   ============================================================ */
.sub-list { display: flex; flex-direction: column; gap: 10px; }
.sub-card { animation: pageIn 0.2s ease; }
.sub-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.sub-card-title { font-size: 15.5px; font-weight: 600; }
.sub-card-meta {
  display: flex; flex-wrap: wrap; gap: 10px;
  font-size: 12.5px; color: var(--text-2);
  margin-top: 8px;
}
.sub-card-meta span { display: inline-flex; align-items: center; gap: 4px; }
.sub-card-meta svg { width: 13px; height: 13px; }

.plan-list { display: flex; flex-direction: column; gap: 10px; }
.plan-card { animation: pageIn 0.2s ease; }
.plan-card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-bottom: 4px;
}
.plan-card-title { font-size: 15.5px; font-weight: 600; }
.plan-card-price {
  font-size: 14px; font-weight: 600; color: var(--primary);
  white-space: nowrap;
  margin-bottom: 8px;
}
.plan-card-desc {
  font-size: 13px; color: var(--text-2);
  margin-bottom: 8px; line-height: 1.5;
}
.plan-card-meta-list {
  display: flex; flex-direction: column; gap: 5px;
  margin-bottom: 10px;
}
.plan-meta {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--text-2);
}
.plan-meta svg { width: 14px; height: 14px; color: var(--text-3); flex: none; }
.plan-card-models {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-bottom: 12px;
}
.plan-model-chip {
  display: inline-flex; align-items: center;
  padding: 4px 10px;
  background: var(--surface-2);
  border-radius: 999px;
  font-size: 12px; color: var(--text-2);
  font-family: var(--mono);
}

/* ============================================================
   角色卡工作台（card workshop）— cw-* 命名空间
   ============================================================ */

.cw-page {
  display: flex; flex-direction: column;
  min-height: 100%; padding-top: 8px;
}

/* ---------- 顶栏 ---------- */
.cw-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 16px 10px;
}
.cw-header-right { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.cw-title-btn {
  display: inline-flex; align-items: center; gap: 4px;
  max-width: 50%;
  padding: 6px 10px; border: none; background: transparent;
  color: var(--text-2); font-size: 15px; font-weight: 600;
  cursor: pointer; border-radius: var(--radius-sm);
}
.cw-title-btn:active { background: var(--surface-2); }
.cw-title-text {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text);
}
.cw-title-btn svg { width: 16px; height: 16px; color: var(--text-3); flex: none; }

/* 模型选择 pill 复用 .select-custom 外观 */
.cw-model-pill {
  display: inline-flex; align-items: center; gap: 4px;
  max-width: 160px;
  padding: 6px 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; font-size: 12.5px; color: var(--text-2);
  cursor: pointer; transition: border-color 0.12s;
}
.cw-model-pill:active { transform: scale(0.97); }
.cw-model-pill svg { width: 14px; height: 14px; color: var(--text-3); flex: none; }
.cw-model-pill .select-custom-label { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cw-icon-btn {
  width: 34px; height: 34px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--text-2);
  border-radius: var(--radius-sm); cursor: pointer;
}
.cw-icon-btn svg { width: 18px; height: 18px; }
.cw-icon-btn:active { background: var(--surface-2); }
.cw-icon-btn:disabled { opacity: 0.4; pointer-events: none; }
.cw-danger { color: #EF4444; }

/* ---------- Tab 栏 ---------- */
.cw-tabs {
  display: flex; gap: 4px; padding: 0 16px 8px;
}
.cw-segment-item {
  flex: 1; padding: 8px 6px;
  font-size: 13px; color: var(--text-3);
  background: transparent; border: none; border-radius: var(--radius-sm);
  cursor: pointer; transition: color 0.12s, background 0.12s;
}
.cw-segment-item-active {
  color: var(--primary); font-weight: 600;
  background: var(--primary-soft);
}

/* ---------- 内容区 ---------- */
.cw-content {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 4px 16px 140px;
}

/* 字段区块 */
.cw-field { margin-bottom: 14px; }
.cw-row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cw-field-head { margin-bottom: 6px; }
.cw-field-side { display: flex; align-items: center; gap: 8px; }
.cw-setting-label { font-size: 13.5px; font-weight: 600; color: var(--text-2); }
.cw-setting-sub { font-size: 12px; color: var(--text-3); line-height: 1.5; }
.cw-mt12 { margin-top: 12px; }
.cw-my16 { margin-top: 16px; margin-bottom: 16px; }
.cw-flex1 { flex: 1; min-width: 0; }
.cw-char-count { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.cw-prompt-input, .cw-dialog-input, .cw-dialog-textarea {
  width: 100%; box-sizing: border-box;
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); padding: 10px 12px;
  font-size: 15px; color: var(--text); outline: none;
  transition: border-color 0.15s; font-family: inherit;
}
.cw-prompt-input:focus, .cw-dialog-input:focus, .cw-dialog-textarea:focus { border-color: var(--primary); }
.cw-prompt-input { resize: none; line-height: 1.6; min-height: 56px; }
.cw-dialog-textarea { resize: none; line-height: 1.6; }
.cw-prompt-input:disabled, .cw-dialog-input:disabled, .cw-dialog-textarea:disabled {
  opacity: 0.6; background: var(--surface-2);
}

/* ---------- 按钮 ---------- */
.cw-btn-outline {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 12px; font-size: 13px; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: border-color 0.12s, transform 0.1s;
}
.cw-btn-outline svg { width: 14px; height: 14px; }
.cw-btn-outline:active { transform: scale(0.96); }
.cw-btn-outline.cw-danger { color: #EF4444; border-color: rgba(239,68,68,0.3); }
.cw-btn-outline:disabled { opacity: 0.4; pointer-events: none; }
.cw-btn-text { padding: 4px 8px; font-size: 13px; color: var(--text-3); background: transparent; border: none; cursor: pointer; border-radius: 6px; }
.cw-btn-text.cw-primary { color: var(--primary); font-weight: 600; }

/* ---------- 引导 ---------- */
.cw-guide {
  position: relative; margin-bottom: 14px;
  padding: 14px 14px 12px; background: var(--primary-soft);
  border: 1px solid rgba(37,99,235,0.15); border-radius: var(--radius);
}
.cw-guide-close {
  position: absolute; top: 8px; right: 8px;
  width: 24px; height: 24px; border: none; background: transparent;
  color: var(--text-3); cursor: pointer; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
}
.cw-guide-close svg { width: 14px; height: 14px; }
.cw-guide-title { font-size: 15px; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.cw-guide-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.cw-chip {
  padding: 5px 10px; font-size: 12px; color: var(--text-2);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; cursor: pointer;
}
.cw-chip:active { transform: scale(0.96); }

/* ---------- 头像 ---------- */
.cw-avatar-row { display: flex; gap: 14px; margin-bottom: 14px; }
.cw-avatar {
  position: relative; width: 72px; height: 72px; flex: none;
  border-radius: var(--radius); overflow: hidden;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.cw-avatar-img { width: 100%; height: 100%; object-fit: cover; }
.cw-avatar-placeholder { color: var(--text-3); display: flex; }
.cw-avatar-placeholder svg { width: 32px; height: 32px; }
.cw-avatar-badge {
  position: absolute; bottom: 4px; right: 4px;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.cw-avatar-badge svg { width: 12px; height: 12px; }
.cw-avatar-side { display: flex; flex-direction: column; gap: 4px; }
.cw-avatar-btns { display: flex; gap: 8px; margin-top: 6px; }

/* ---------- 条目列表（世界书/正则） ---------- */
.cw-tab-actions { display: flex; gap: 8px; margin-bottom: 12px; }
.cw-entry-list { display: flex; flex-direction: column; gap: 8px; }
.cw-entry {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.cw-entry-main { flex: 1; min-width: 0; cursor: pointer; }
.cw-entry-off { opacity: 0.55; }
.cw-entry-title { font-size: 14px; color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 6px; }
.cw-entry-sub { font-size: 12px; color: var(--text-3); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cw-entry-tag {
  display: inline-block; padding: 1px 7px;
  font-size: 11px; color: var(--primary);
  background: var(--primary-soft); border-radius: 4px; flex: none;
}
.cw-empty { padding: 24px 0; text-align: center; font-size: 13px; color: var(--text-3); }

/* ---------- 开关 ---------- */
.cw-toggle {
  width: 40px; height: 22px; flex: none;
  border-radius: 999px; border: none;
  background: var(--surface-3); cursor: pointer;
  position: relative; transition: background 0.15s;
  padding: 0;
}
.cw-toggle-on { background: var(--primary); }
.cw-toggle-dot {
  position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; transition: transform 0.15s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.cw-toggle-dot-on { transform: translateX(18px); }

/* ---------- 弹层内表单 ---------- */
.cw-form { display: flex; flex-direction: column; gap: 4px; }
.cw-toggle-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.cw-num-grid { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 10px; margin-top: 12px; }
.cw-num-grid-2 { grid-template-columns: 1fr 1fr; }
.cw-flags { display: flex; gap: 14px; margin-top: 6px; flex-wrap: wrap; }
.cw-flag { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--text-2); }
.cw-flag input { accent-color: var(--primary); width: 16px; height: 16px; }
.cw-regex-result {
  margin-top: 8px; padding: 10px 12px; min-height: 48px; max-height: 120px; overflow: auto;
  background: var(--surface-2); border-radius: var(--radius-sm);
  font-size: 13px; color: var(--text-2); white-space: pre-wrap; word-break: break-word;
}
.cw-regex-result-err { color: #EF4444; }
.cw-divider { height: 1px; background: var(--border); flex-shrink: 0; }
.cw-sheet-section-label { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 10px; }
.cw-sheet-list { display: flex; flex-direction: column; }
.cw-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 12px; font-size: 14px; color: var(--text-2);
  background: transparent; border: none; cursor: pointer;
  border-radius: var(--radius-sm); text-align: left;
}
.cw-menu-item svg { width: 18px; height: 18px; flex: none; }
.cw-menu-item:active { background: var(--surface-2); }
.cw-menu-item.cw-danger { color: #EF4444; }

/* 导出条目选择 */
.cw-export-list { display: flex; flex-direction: column; gap: 4px; max-height: 50vh; overflow: auto; }
.cw-export-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: pointer;
}
.cw-export-item:active { background: var(--surface-2); }
.cw-export-item input { accent-color: var(--primary); width: 16px; height: 16px; flex: none; }
.cw-export-item-title { font-size: 14px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 卡片管理列表 ---------- */
.cw-card-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  cursor: default;
}
.cw-card-item-active { background: var(--primary-soft); }
.cw-card-thumb {
  width: 40px; height: 40px; flex: none; border-radius: 10px;
  background: var(--surface-2); display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.cw-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.cw-card-thumb svg { width: 20px; height: 20px; color: var(--text-3); }
.cw-card-item-main { flex: 1; min-width: 0; cursor: pointer; }
.cw-card-item-name { font-size: 14px; color: var(--text); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 底部 composer ---------- */
.cw-composer {
  position: fixed; left: 0; right: 0; bottom: 0;
  padding: 10px 12px 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 5;
}
.cw-composer-row { display: flex; align-items: flex-end; gap: 8px; }
.cw-composer-input {
  flex: 1; resize: none; min-height: 40px; max-height: 120px;
  padding: 10px 12px; font-size: 15px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 20px; outline: none; line-height: 1.5;
  font-family: inherit;
}
.cw-composer-input:focus { border-color: var(--primary); }
.cw-send-btn {
  width: 40px; height: 40px; flex: none;
  border: none; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform 0.1s;
}
.cw-send-btn svg { width: 18px; height: 18px; }
.cw-send-btn:active { transform: scale(0.92); }
.cw-diff-btn { margin-top: 8px; width: 100%; justify-content: center; }

/* 进度条 */
.cw-progress { margin-bottom: 8px; }
.cw-progress-bar {
  height: 4px; background: var(--surface-3); border-radius: 999px; overflow: hidden;
}
.cw-progress-fill {
  height: 100%; background: var(--primary); border-radius: 999px;
  transition: width 0.2s; width: 0%;
}
.cw-progress-text { display: block; margin-top: 5px; font-size: 12px; color: var(--text-3); }

/* ---------- Diff 确认 ---------- */
.cw-diff-list { display: flex; flex-direction: column; gap: 10px; max-height: 56vh; overflow: auto; }
.cw-diff-item {
  padding: 10px; background: var(--surface-2);
  border-radius: var(--radius-sm);
}
.cw-diff-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.cw-diff-head input { accent-color: var(--primary); width: 16px; height: 16px; flex: none; }
.cw-diff-cols { display: flex; gap: 8px; }
.cw-diff-before, .cw-diff-after {
  flex: 1; min-width: 0; padding: 8px;
  background: var(--surface); border-radius: 8px;
  font-size: 12px; color: var(--text-2);
  white-space: pre-wrap; word-break: break-word;
  max-height: 120px; overflow: auto;
}
.cw-diff-before { border-left: 2px solid #EF4444; }
.cw-diff-after { border-left: 2px solid var(--success); }

/* ---------- 预览 iframe ---------- */
.cw-preview-wrap { padding: 0; }
.cw-preview-frame {
  width: 100%; height: 60vh; border: none; border-radius: var(--radius-sm);
  background: #fff;
}

/* 弹层内避免 .sheet-body 默认 padding 过大影响表单密度 */
.sheet-body .cw-form,
.sheet-body .cw-sheet-list { padding: 0; }
