/* ============================================================
   OpenAI Chat — Apple 风高级主题
   设计语言：无分割线、色阶分层、细腻阴影、大留白、圆角柔和
   浅色/深色双主题，<html data-theme="..."> 切换
   ============================================================ */

/* ---------- 主题变量 ---------- */
:root,
[data-theme="light"] {
  color-scheme: light;

  /* 灰阶分层（近白画布 + 白色面板） */
  --bg-app: #fcfcfc;
  --bg-surface: #ffffff;
  --bg-surface-2: #fafafa;
  --bg-sidebar: rgba(248, 248, 250, 0.85);
  --bg-hover: rgba(0, 0, 0, 0.045);
  --bg-active: rgba(0, 0, 0, 0.08);
  --bg-input: #ffffff;
  --bg-code: rgba(0, 0, 0, 0.035);
  --bg-user-msg: rgba(0, 0, 0, 0.05);

  /* 文字（苹果灰阶） */
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;

  /* 层级阴影（代替分割线） */
  --hairline: rgba(0, 0, 0, 0.06);          /* 极淡边缘，视觉上"无边框" */
  --hairline-strong: rgba(0, 0, 0, 0.12);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.12);
  --shadow-pop: 0 8px 40px rgba(0, 0, 0, 0.14);

  /* 主色 */
  --primary: #1d1d1f;
  --primary-hover: #000000;
  --primary-text: #ffffff;
  --accent: #0071e3;            /* 苹果蓝，少量点缀 */

  /* 语义色 */
  --danger: #ff3b30;
  --danger-bg: rgba(255, 59, 48, 0.08);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;

  --fs: 14px;
  --fs-title: 16px;
  --fs-display: 20px;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg-app: #000000;
  --bg-surface: #1d1d1f;
  --bg-surface-2: #161618;
  --bg-sidebar: rgba(28, 28, 30, 0.85);
  --bg-hover: rgba(255, 255, 255, 0.06);
  --bg-active: rgba(255, 255, 255, 0.1);
  --bg-input: #1c1c1e;
  --bg-code: rgba(255, 255, 255, 0.06);
  --bg-user-msg: rgba(255, 255, 255, 0.08);

  --text: #f5f5f7;
  --text-secondary: #98989d;
  --text-tertiary: #6e6e73;

  --hairline: rgba(255, 255, 255, 0.08);
  --hairline-strong: rgba(255, 255, 255, 0.14);
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 6px 24px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.6);
  --shadow-pop: 0 8px 40px rgba(0, 0, 0, 0.7);

  --primary: #f5f5f7;
  --primary-hover: #ffffff;
  --primary-text: #1d1d1f;
  --accent: #2997ff;

  --danger: #ff453a;
  --danger-bg: rgba(255, 69, 58, 0.12);
}

/* ---------- 基础 ---------- */
@font-face {
  font-family: "思源宋体";
  src: url("../SourceHanSerifCN.otf") format("opentype");
  font-display: swap;
  font-weight: 200 900;
  font-style: normal;
}
@font-face {
  font-family: "Times New Roman 内置";
  src: url("../Times%20New%20Roman.ttf") format("truetype");
  font-display: swap;
  font-weight: 400 700;
  font-style: normal;
}
* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--oc-font-family, "TinyChat Text", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif);
  background: var(--bg-app);
  color: var(--text);
  font-size: var(--fs, 14px);
  line-height: 1.6;
  display: flex;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

.hidden { display: none !important; }
.muted { color: var(--text-secondary); }
.small { font-size: var(--fs, 14px); }

::selection { background: var(--accent); color: #fff; }

/* 滚动条（苹果式极细） */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(128, 128, 128, 0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(128, 128, 128, 0.5); }

/* 无边框的按钮基础 */
.icon-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn:active { transform: scale(0.94); }

/* ============================================================
   侧边栏（无边框，靠浮起层次）
   ============================================================ */
.sidebar {
  width: 264px;
  min-width: 264px;
  background: var(--bg-sidebar);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}
.sidebar::after {
  content: "";
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(to bottom, transparent, var(--hairline) 12%, var(--hairline) 88%, transparent);
}
.sidebar.collapsed { margin-left: calc(0px - var(--sidebar-w, 264px)); }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 14px 10px;
}
.new-chat-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--bg-surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}
.new-chat-btn:hover { box-shadow: var(--shadow-sm); background: var(--bg-surface); }
.new-chat-btn:active { transform: scale(0.98); }

.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.chat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.12s;
}
.chat-item:hover { background: var(--bg-hover); }
.chat-item.active { background: var(--bg-active); font-weight: 500; }
.chat-item .chat-icon { flex-shrink: 0; color: var(--text-tertiary); display: flex; }
.chat-item.active .chat-icon { color: var(--text-secondary); }
.chat-item .chat-title { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.chat-item .del-chat {
  opacity: 0;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: opacity 0.12s;
}
.chat-item:hover .del-chat { opacity: 1; }
.chat-item .del-chat:hover { color: var(--danger); background: var(--danger-bg); }

.sidebar-footer {
  padding: 10px 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: var(--radius-sm);
}
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--text), var(--text-secondary));
  color: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}
.user-meta { display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.user-name { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; }
.quota { font-size: 12px; color: var(--text-secondary); }
.quota.low { color: var(--danger); font-weight: 600; }

.footer-actions { display: flex; gap: 4px; }
.footer-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 6px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.footer-btn:hover { background: var(--bg-hover); color: var(--text); }

/* ============================================================
   主区域
   ============================================================ */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  height: 56px;
  flex-shrink: 0;
  position: relative;
  background: transparent;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
}
.topbar-right { display: flex; align-items: center; gap: 4px; }

/* 模型选择器（左上角胶囊） */
.model-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  background: var(--bg-surface);
  box-shadow: var(--shadow-xs);
  transition: background 0.15s, box-shadow 0.15s;
  user-select: none;
  -webkit-user-select: none;
}
.model-picker:hover { box-shadow: var(--shadow-sm); }
.model-icon { color: var(--text-secondary); flex-shrink: 0; display: flex; }
.model-picker .model-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chevron {
  color: var(--text-tertiary);
  flex-shrink: 0;
  display: flex;
  transition: transform 0.2s;
}
.model-picker.open .chevron { transform: rotate(180deg); }

/* 侧边栏折叠时的悬空展开按钮 */
.sidebar-float-btn {
  position: fixed;
  left: 12px;
  top: 64px;
  z-index: 600;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--bg-surface);
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
  transition: transform 0.15s, box-shadow 0.15s;
  animation: floatIn 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sidebar-float-btn:hover { box-shadow: var(--shadow-lg); transform: scale(1.06); }
.sidebar-float-btn:active { transform: scale(0.94); }
@keyframes floatIn {
  from { opacity: 0; transform: translateX(-8px) scale(0.9); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

/* 主题切换图标 */
.sun-icon, .moon-icon { display: none; }
[data-theme="light"] .sun-icon { display: block; }
[data-theme="dark"] .moon-icon { display: block; }

/* 供应商指示胶囊 */
.provider-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 999px;
  margin-right: 6px;
  background: var(--bg-hover);
}
.provider-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); flex-shrink: 0; }

/* ============================================================
   自定义下拉面板（fixed 定位，永远不被裁剪/遮挡）
   ============================================================ */
.oc-menu {
  position: fixed;
  z-index: 9999;
  min-width: 220px;
  max-width: min(520px, calc(100vw - 16px));
  box-sizing: border-box;
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-pop);
  padding: 6px;
  animation: menuIn 0.15s cubic-bezier(0.2, 0.8, 0.2, 1);
  max-height: 320px;
  display: flex;
  flex-direction: column;
}
@keyframes menuIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.oc-menu .oc-menu-title {
  font-size: 12px;
  color: var(--text-tertiary);
  padding: 6px 10px 4px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}
.oc-menu .oc-menu-search {
  margin: 4px 6px 4px;
  padding: 8px 12px;
  border: none;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  outline: none;
}
.oc-menu .oc-menu-search::placeholder { color: var(--text-tertiary); }
.oc-menu .oc-menu-list {
  overflow-y: auto;
  flex: 1;
  padding: 2px;
}
.oc-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text);
  transition: background 0.1s;
  white-space: nowrap;
}
.oc-menu-item:hover { background: var(--bg-hover); }
.oc-menu-item.active { background: var(--bg-active); font-weight: 600; }
.oc-menu-item .check {
  color: var(--accent);
  display: flex;
  flex-shrink: 0;
  opacity: 0;
}
.oc-menu-item.active .check { opacity: 1; }
.oc-menu-item .item-label { min-width: 0; overflow-wrap: anywhere; white-space: normal; line-height: 1.4; }
.oc-menu-item .item-sub { font-size: 12px; color: var(--text-tertiary); flex-shrink: 0; }

/* ============================================================
   聊天区
   ============================================================ */
.chat-area {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-secondary);
  text-align: center;
  padding: 20px;
}
.empty-logo {
  color: var(--text-tertiary);
  margin-bottom: 16px;
  opacity: 0.65;
}
.empty-state h2 {
  color: var(--text);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.empty-state p.muted { font-size: 15px; }
.empty-hint { margin-top: 10px; font-size: 13px; color: var(--text-tertiary); }

.messages {
  flex: 1;
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 24px 10px;
}

.msg {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  padding: 18px 0;
  animation: msgIn 0.25s ease;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.msg .msg-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-text);
  flex-shrink: 0;
  margin-top: 2px;
  background: linear-gradient(135deg, var(--primary), var(--text-secondary));
}
.msg.user .msg-avatar { background: var(--text); }

.msg .msg-content {
  flex: 1 1 100%;
  min-width: 0;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.7;
}
.msg.user .msg-content {
  background: var(--bg-user-msg);
  border-radius: var(--radius-lg);
  padding: 11px 18px;
  max-width: 85%;
}
.msg.assistant .msg-content { padding-top: 4px; }

/* 回复富文本 */
.msg.assistant p { margin: 8px 0; }
.msg.assistant p:first-child { margin-top: 0; }
.msg.assistant p:last-child { margin-bottom: 0; }
.msg.assistant h1, .msg.assistant h2, .msg.assistant h3, .msg.assistant h4 {
  margin: 16px 0 8px; font-weight: 650; line-height: 1.35; letter-spacing: -0.01em;
}
.msg.assistant h1, .msg.assistant h2, .msg.assistant h3 { font-size: 1em; }
.msg.assistant ul, .msg.assistant ol { margin: 8px 0; padding-left: 24px; }
.msg.assistant li { margin: 4px 0; }
.msg.assistant code {
  font-family: "SF Mono", "JetBrains Mono", "Consolas", monospace;
  font-size: 13.5px;
  background: var(--bg-code);
  padding: 2px 7px;
  border-radius: 6px;
}
.msg.assistant pre {
  background: var(--bg-code);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  overflow-x: auto;
  font-size: 13.5px;
  margin: 12px 0;
  line-height: 1.6;
}
.msg.assistant pre code { background: none; padding: 0; }
.msg.assistant blockquote {
  border-left: 3px solid var(--text-tertiary);
  padding-left: 16px;
  color: var(--text-secondary);
  margin: 12px 0;
}
.msg.assistant table { border-collapse: collapse; margin: 12px 0; width: 100%; font-size: 14px; }
.msg.assistant th, .msg.assistant td { border: 1px solid var(--hairline-strong); padding: 8px 12px; text-align: left; }
.msg.assistant th { background: var(--bg-code); font-weight: 600; }
.msg.assistant a { color: var(--accent); text-decoration: none; }
.msg.assistant a:hover { text-decoration: underline; }
.msg.assistant hr { border: none; height: 1px; background: var(--hairline); margin: 16px 0; }

.typing-dots { display: inline-flex; gap: 4px; padding: 10px 2px; }
.typing-dots span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-tertiary); animation: blink 1.4s infinite both; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

.msg-error { color: var(--danger); font-size: 13.5px; margin-top: 6px; }

/* ============================================================
   输入区（悬浮卡片式）
   ============================================================ */
.composer-area {
  padding: 8px 18px 12px;
  flex-shrink: 0;
}
.composer-wrap { max-width: 800px; margin: 0 auto; }
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border-radius: var(--radius-xl);
  padding: 9px 9px 9px 18px;
  background: var(--bg-surface);
  box-shadow: var(--shadow-md);
  transition: box-shadow 0.2s;
}
.composer:focus-within { box-shadow: var(--shadow-lg); }
.composer textarea {
  flex: 1;
  border: none;
  outline: none;
  resize: none;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.5;
  max-height: 180px;
  background: transparent;
  color: var(--text);
  padding: 6px 0;
}
.composer textarea::placeholder { color: var(--text-tertiary); }

.send-btn, .stop-btn {
  width: 34px; height: 34px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.12s;
}
.send-btn:hover { background: var(--primary-hover); }
.send-btn:active { transform: scale(0.9); }
.send-btn:disabled { background: var(--bg-active); color: var(--text-tertiary); cursor: not-allowed; }
.stop-btn { background: var(--text-secondary); }
.stop-btn:hover { background: var(--text); }

.composer-hint { text-align: center; font-size: 12px; color: var(--text-tertiary); margin-top: 9px; }

/* ============================================================
   弹窗
   ============================================================ */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.18s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  width: min(540px, 92vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
}
.modal-header h3 { font-size: 17px; font-weight: 650; letter-spacing: -0.01em; }
.modal-body { padding: 6px 22px 24px; overflow-y: auto; }
.section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  margin: 18px 0 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.section-title:first-child { margin-top: 6px; }

/* 表单 */
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; font-weight: 500; }
.field input {
  width: 100%;
  padding: 11px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: var(--bg-hover);
  color: var(--text);
  transition: background 0.15s, box-shadow 0.15s;
}
.field input:focus { background: var(--bg-input); box-shadow: 0 0 0 3px var(--hairline-strong); }

/* 自定义选择框（替代原生 select） */
.select-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-hover);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.15s;
}
.select-box:hover { background: var(--bg-active); }
.select-box .sb-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.select-box .sb-arrow { color: var(--text-tertiary); display: flex; flex-shrink: 0; }

/* 表格行内的小尺寸选择框 */
.select-box-sm {
  display: inline-flex;
  width: auto;
  min-width: 110px;
  padding: 6px 10px;
  font-size: 13px;
  border-radius: 8px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
}
.select-box-sm:hover { background: var(--bg-active); border-color: var(--border-strong); }

/* 按钮 */
.btn {
  padding: 10px 20px;
  border: none;
  border-radius: 999px;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  background: var(--bg-hover);
  color: var(--text);
  transition: all 0.15s;
  font-weight: 500;
}
.btn:hover { background: var(--bg-active); }
.btn.primary { background: var(--primary); color: var(--primary-text); }
.btn.primary:hover { background: var(--primary-hover); }
.btn.primary:disabled { background: var(--bg-active); color: var(--text-tertiary); cursor: not-allowed; }
.btn.danger { background: var(--danger-bg); color: var(--danger); }
.btn.danger:hover { background: var(--danger); color: #fff; }
.btn.small { padding: 6px 14px; font-size: 13px; border-radius: 999px; }
.w-full { width: 100%; }

/* 供应商卡片 */
.provider-list { display: flex; flex-direction: column; gap: 8px; }
.provider-card {
  border-radius: var(--radius-md);
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-surface-2);
  transition: background 0.15s;
}
.provider-card:hover { background: var(--bg-hover); }
.provider-card .pc-info { min-width: 0; }
.provider-card-actions { flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 560px) {
  .provider-card { align-items: flex-start; flex-direction: column; }
  .provider-card-actions { width: 100%; justify-content: flex-start; }
}
.provider-card .pc-name { font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.provider-card .pc-url { font-size: 12px; color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.badge { font-size: 11px; padding: 2px 9px; border-radius: 999px; font-weight: 500; }
.badge.global { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); }
.badge.default { background: var(--bg-active); color: var(--text-secondary); }
.badge.user { background: var(--bg-hover); color: var(--text-secondary); }
.badge.disabled { background: var(--bg-hover); color: var(--text-tertiary); }
.provider-card.disabled { opacity: 0.55; }
.provider-card.disabled .pc-name { color: var(--text-tertiary); }

.provider-test-modal .modal-body { padding-bottom: 18px; }
.provider-test-target {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface-2);
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.provider-test-modal .select-box.disabled { opacity: .6; pointer-events: none; }
.provider-test-modal textarea { resize: vertical; min-height: 88px; }
.provider-test-status { min-height: 20px; margin-top: 4px; }
.provider-test-result {
  margin-top: 10px;
  padding: 11px 12px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-2);
  overflow-wrap: anywhere;
}
.provider-test-result.ok { border-color: color-mix(in srgb, var(--brand, #16a34a) 35%, var(--hairline)); }
.provider-test-result.bad { border-color: color-mix(in srgb, #dc2626 30%, var(--hairline)); }
.provider-test-result-item + .provider-test-result-item { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--hairline); }
.provider-test-result-title { font-weight: 600; font-size: 13px; }
.provider-test-result-meta { margin-top: 3px; color: var(--text-tertiary); font-size: 12px; }
.provider-test-result-text { margin-top: 8px; color: var(--text-secondary); font-size: 13px; line-height: 1.6; white-space: pre-wrap; }

.group-default-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin: 4px 0 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--hairline, var(--border));
}

/* 用户组卡片 */
.group-card {
  border-radius: var(--radius-md);
  padding: 13px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-surface-2);
  transition: background 0.15s;
  margin-bottom: 8px;
}
.group-card:hover { background: var(--bg-hover); }

/* 模型授权 */
.access-section { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.access-title { font-weight: 600; font-size: 14px; color: var(--text-primary); }
.access-row {
  border-radius: var(--radius-md);
  padding: 12px 16px;
  background: var(--bg-surface-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.access-prov { font-weight: 500; font-size: 13.5px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.access-models { display: flex; flex-wrap: wrap; gap: 6px; }
.access-model {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s;
  color: var(--text-secondary);
}
.access-model:hover { border-color: var(--accent); color: var(--text-primary); }
.access-model input { accent-color: var(--accent); margin: 0; }
.access-model.disabled { opacity: 0.45; pointer-events: none; }
.access-all { font-size: 12px; color: var(--text-secondary); cursor: pointer; }

.add-provider { margin-top: 16px; }
.add-provider summary {
  cursor: pointer;
  font-size: 14px;
  color: var(--accent);
  font-weight: 500;
  padding: 6px 0;
  list-style: none;
  transition: opacity 0.15s;
}
.add-provider summary:hover { opacity: 0.8; }
.add-provider summary::-webkit-details-marker { display: none; }
.add-provider-form { margin-top: 14px; padding-top: 14px; }

.row-between { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; font-size: 14px; }

/* 开关 */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--bg-active);
  border-radius: 26px;
  transition: 0.2s;
}
.slider::before {
  content: ""; position: absolute; width: 20px; height: 20px;
  border-radius: 50%; background: #fff; left: 3px; top: 3px;
  transition: 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ============================================================
   登录页
   ============================================================ */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-app);
}
.auth-card {
  width: 400px;
  max-width: 92vw;
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  padding: 44px 40px 36px;
  box-shadow: var(--shadow-md);
}
.auth-logo { text-align: center; margin-bottom: 30px; }
.auth-logo .logo-wrap {
  width: 60px; height: 60px;
  margin: 0 auto 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--primary), var(--text-secondary));
  color: var(--primary-text);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-md);
}
.auth-logo h1 { font-size: 22px; color: var(--text); font-weight: 700; letter-spacing: -0.02em; }
.auth-logo p { margin-top: 4px; }
.auth-error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 16px;
}
.auth-switch { text-align: center; margin-top: 22px; font-size: 14px; color: var(--text-secondary); }
.auth-switch a { color: var(--accent); text-decoration: none; font-weight: 500; }
.auth-switch a:hover { text-decoration: underline; }

/* ============================================================
   管理后台
   ============================================================ */
.admin-body { display: block; overflow: auto; background: var(--bg-app); }
.admin-container { width: 80%; max-width: none; margin: 0 auto; padding: 36px 0 60px; }
.admin-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 26px;
}
.admin-header h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 26px; }
.stat-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 20px 22px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.15s;
}
.stat-card:hover { box-shadow: var(--shadow-sm); }
.stat-card .stat-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; }
.stat-card .stat-label { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.admin-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-xs);
  margin-bottom: 20px;
}
.admin-card h2 { font-size: 17px; font-weight: 650; margin-bottom: 18px; letter-spacing: -0.01em; }
.model-votes { display: flex; flex-direction: column; gap: 6px; }
.model-vote-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px 72px;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg-app);
}
.model-vote-row .mv-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.model-vote-row .mv-up,
.model-vote-row .mv-down { font-size: 13px; font-variant-numeric: tabular-nums; text-align: right; }
.model-vote-row .mv-up { color: var(--brand); }
.model-vote-row .mv-down { color: var(--text-tertiary); }

/* 后台页签导航 */
.admin-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 22px;
  padding: 4px;
  background: var(--bg-hover);
  border-radius: 12px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}
.admin-tab {
  border: none;
  background: transparent;
  padding: 8px 18px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  font-family: inherit;
}
.admin-tab:hover { color: var(--text); }
.admin-tab.active {
  background: var(--bg-surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
  font-weight: 600;
}
.admin-panel { display: none; }
.admin-panel.active { display: block; animation: panelIn 0.18s ease; }
@keyframes panelIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th, .admin-table td { text-align: left; padding: 12px 14px; }
.admin-table th { color: var(--text-tertiary); font-weight: 500; font-size: 12.5px; letter-spacing: 0.03em; text-transform: uppercase; }
.admin-table td { border-top: 1px solid var(--hairline); }
.admin-table tr:first-child td { border-top: none; }
.admin-table tr:hover td { background: var(--bg-hover); }
.admin-row-actions { display: flex; gap: 6px; align-items: center; }
.admin-row-actions input[type="number"] {
  width: 84px;
  padding: 6px 10px;
  border: none;
  border-radius: 8px;
  background: var(--bg-hover);
  color: var(--text);
  font-size: 13px;
  outline: none;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg-surface);
  padding: 11px 22px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 2000;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.2s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(12px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.toast.error { background: var(--danger); color: #fff; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 768px) {
  .admin-container { width: auto; margin: 0 16px; }
  .sidebar { position: fixed; z-index: 500; height: 100%; box-shadow: var(--shadow-lg); }
  .topbar-left { gap: 2px; }
  .model-picker .model-name { max-width: 140px; }
  .sidebar-float-btn { top: 60px; left: 10px; }
  .msg.user .msg-content { max-width: 92%; }
}
