/* =====================================================================
   TokenMark 共享设计系统（UI-DESIGN.md D1：原生无构建）
   复用 public/index.html 的 CSS 变量，保证营销页 / 管理后台 / 客户门户
   三套界面品牌一致。所有界面均为深色主题。
   ===================================================================== */
:root {
  --bg: #0b0e14;
  --surface: #151a23;
  --surface-2: #1c2230;
  --border: #2a3242;
  --text: #e6eaf2;
  --muted: #93a0b5;
  --accent: #4f8cff;
  --accent-2: #7c5cff;
  --green: #3ddc84;
  --red: #ff5d6c;
  --radius: 16px;
  --radius-sm: 9px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.mono {
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}

/* ---------- 应用骨架（侧栏 + 主区） ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 18px; font-weight: 700; margin: 4px 8px 22px;
}
.sidebar .brand .logo {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.sidebar .brand .sub { font-size: 11px; color: var(--muted); font-weight: 400; margin-left: auto; }

.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--muted); font-size: 14px; font-weight: 500;
  margin-bottom: 4px;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active {
  background: linear-gradient(90deg, rgba(79,140,255,.18) 0%, rgba(124,92,255,.08) 100%);
  color: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent);
  border: 1px solid rgba(79,140,255,.25);
  text-shadow: 0 0 12px rgba(79,140,255,.5);
}
.nav .ico { width: 18px; text-align: center; }
.nav .grp { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: #5b6678; margin: 18px 12px 6px; }

/* ---------- 侧边栏底部 ---------- */
.sidebar-footer {
  margin-top: auto;
  padding: 16px 12px 20px;
  border-top: 1px solid var(--border);
}
.sidebar-home-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, color .15s;
}
.sidebar-home-link:hover {
  background: var(--surface-2);
  color: var(--text);
  text-decoration: none;
}
.sidebar-legal {
  margin-top: 8px;
  padding: 0 14px;
  font-size: 11.5px;
  color: var(--muted);
  opacity: 0.7;
}
.sidebar-legal a {
  color: var(--muted);
  text-decoration: none;
}
.sidebar-legal a:hover {
  color: var(--text);
  text-decoration: underline;
}

.main { flex: 1 1 auto; min-width: 0; padding: 26px 30px 60px; display: flex; flex-direction: column; }
#view { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 24px;
}
.topbar h1 { font-size: 22px; margin: 0; font-weight: 700; }
.topbar .spacer { flex: 1; }
.topbar .who {
  font-size: 12.5px; color: var(--muted);
  background: var(--surface); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 999px;
}

/* ---------- 卡片 / 面板 ---------- */
.card, .panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  transition: transform .15s ease, border-color .15s ease;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); }
.panel { margin-bottom: 22px; }
.panel h2 { margin: 0 0 16px; font-size: 18px; }
.panel h3 { margin: 0 0 12px; font-size: 15px; color: var(--muted); font-weight: 600; }

.cards-grid {
  display: grid; gap: 16px; margin-bottom: 22px;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
}
.cards-grid.two-col { grid-template-columns: 1fr 1fr; }
.stat .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.stat .value.green { color: var(--green); }
.stat .value.red { color: var(--red); }
.stat .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---------- 财务对账（S5） ---------- */
.tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.tab { background: var(--surface-2); border: 1px solid var(--border); color: var(--muted);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.tab:hover { border-color: var(--accent); color: var(--text); }
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.alert-bar { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 18px; font-size: 14px; font-weight: 600; }
.alert-bar.red { background: rgba(255,90,90,.12); border: 1px solid var(--red); color: #ff9b9b; }
.alert-bar.green { background: rgba(80,200,120,.12); border: 1px solid var(--green); color: #8be0a8; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .mono { font-size: 12.5px; word-break: break-all; }
.table .empty { text-align: center; color: var(--muted); padding: 26px; }

/* Key 列表优化 */
.keys-table th, .keys-table td { vertical-align: middle; }
.keys-table th.actions-cell,
.keys-table td.actions-cell { width: 1%; white-space: nowrap; text-align: right; }
.keys-table th.label-cell,
.keys-table td.label-cell { min-width: 120px; max-width: 220px; }
.keys-table td.label-cell { font-weight: 600; font-size: 14px; word-break: break-all; }
.keys-table th.key-cell,
.keys-table td.key-cell { min-width: 180px; }
.keys-table th.points-cell,
.keys-table td.points-cell { width: 1%; white-space: nowrap; text-align: right; }
.keys-table th.validity-cell,
.keys-table td.validity-cell { width: 1%; white-space: nowrap; }
.keys-table th.ip-cell,
.keys-table td.ip-cell { width: 1%; min-width: 80px; max-width: 140px; }
.keys-table td.ip-cell .ip-pill { display: inline-block; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-value-wrap { display: flex; align-items: center; gap: 6px; }
.key-value-wrap .mono { font-size: 12px; color: var(--muted); word-break: break-all; }
.key-value-wrap .key-full { color: var(--text); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; border: none; cursor: pointer; padding: 2px; line-height: 1; border-radius: var(--radius-sm); background: transparent; color: var(--muted); }
.icon-btn:hover { color: var(--text); background: var(--surface-2); }
.icon-btn svg { width: 16px; height: 16px; display: block; }
.icon-btn.copy { font-size: 12px; padding: 2px 8px; background: var(--accent); color: #fff; border-radius: 4px; margin-left: 2px; }
.icon-btn.copy:hover { filter: brightness(1.08); background: var(--accent); }
.actions-cell { white-space: nowrap; }
.action-links { display: inline-flex; align-items: center; }
.action-links a { font-size: 12.5px; color: var(--muted); text-decoration: none; }
.action-links a:hover { color: var(--accent); text-decoration: underline; }
.action-links a.danger { color: var(--red); }
.action-links a.danger:hover { color: #ff7a85; }
.action-links a + a::before { content: '|'; margin: 0 10px; color: var(--border); pointer-events: none; }
.points-cell .limit-wrap { display: inline-flex; align-items: center; gap: 8px; }
.points-cell .inline-action { font-size: 12px; color: var(--muted); text-decoration: none; }
.points-cell .inline-action:hover { color: var(--accent); text-decoration: underline; }
/* 移动端：表格横向滚动，避免窄屏挤压列 / 整页横向溢出 */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll > .table { min-width: 560px; }
.keys-table { min-width: 720px; }

/* 模型管理表格 */
.models-table { min-width: 560px; }
.models-table th, .models-table td { vertical-align: middle; }
.models-table td:first-child, .models-table th:first-child { white-space: nowrap; word-break: normal; min-width: 140px; }
.models-table td.scope-cell, .models-table th.scope-cell { white-space: nowrap; }

/* ---------- 表单 / 输入 / 按钮 ---------- */
.form { display: grid; gap: 14px; max-width: 560px; }
.form .row { display: grid; gap: 6px; }
.form label { font-size: 13px; color: var(--muted); }
.form .help { font-size: 12px; color: #5b6678; margin-top: 2px; }
.input, .select, .textarea {
  width: 100%; background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 14px; font-family: inherit;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); }
.textarea { min-height: 78px; resize: vertical; font-family: "SF Mono", ui-monospace, Menlo, monospace; font-size: 12.5px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); }
.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 9px 15px; font-size: 13.5px; font-weight: 600; cursor: pointer;
  font-family: inherit; transition: border-color .15s, background .15s;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--red); border-color: rgba(255,93,108,.4); }
.btn.danger:hover { background: rgba(255,93,108,.12); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- 个人资料页 ---------- */
.profile-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
  align-items: stretch;
}
@media (max-width: 980px) {
  .profile-grid { grid-template-columns: 1fr; }
}
.profile-grid .panel {
  margin-bottom: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.profile-grid .panel > .profile-section:last-child { margin-bottom: 0; flex: 1 1 auto; }

.profile-header {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 20px; padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.profile-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: #fff; flex: 0 0 52px;
}
.profile-meta { flex: 1 1 auto; min-width: 0; }
.profile-meta .name { font-size: 16px; font-weight: 600; }
.profile-meta .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

.profile-section { border-top: 1px solid var(--border); padding-top: 18px; margin-top: 18px; }
.profile-section.first { border-top: none; padding-top: 0; margin-top: 0; }
.profile-section h3 { margin: 0 0 12px; font-size: 14px; color: var(--text); font-weight: 600; }
.profile-section h3.muted { color: var(--muted); }

.profile-edit-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.input.readonly {
  background: transparent; border-color: transparent; padding-left: 0;
  color: var(--muted); cursor: default;
}
.input.readonly:focus { border-color: transparent; }

.profile-hint { font-size: 12px; color: #5b6678; margin-top: 4px; line-height: 1.45; }
.profile-actions { display: flex; justify-content: flex-end; margin-top: 4px; }
.profile-actions + .profile-actions { margin-top: 10px; }
.form.compact { gap: 12px; max-width: none; }

.info-list { display: flex; flex-direction: column; gap: 16px; }
.info-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.info-main { display: flex; flex-direction: column; gap: 4px; }
.info-label { font-size: 12.5px; color: var(--muted); }
.info-value { font-size: 14.5px; color: var(--text); font-weight: 500; }
.info-value.mono { font-family: "SF Mono", ui-monospace, Menlo, monospace; }

/* ---------- 徽章 / 状态 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border: 1px solid var(--border);
  border-radius: 999px; font-size: 12px; color: var(--muted);
  background: var(--surface-2);
}
.badge.on { color: var(--green); border-color: rgba(61,220,132,.4); }
.badge.off { color: var(--red); border-color: rgba(255,93,108,.4); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px rgba(61,220,132,.15); }
.dot.off { background: var(--red); box-shadow: 0 0 0 3px rgba(255,93,108,.15); }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.tag.green { color: var(--green); border-color: rgba(61,220,132,.4); }
.tag.red { color: var(--red); border-color: rgba(255,93,108,.4); }
.tag.blue { color: var(--accent); border-color: rgba(79,140,255,.4); }

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(3,6,12,.66);
  backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center;
  z-index: 50; padding: 20px;
}
.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 24px; width: 100%; max-width: 600px;
  max-height: 90vh; overflow-y: auto;
}
.modal h2 { margin: 0 0 18px; font-size: 18px; }
.modal .close { float: right; cursor: pointer; color: var(--muted); font-size: 18px; }
.modal .close:hover { color: var(--text); }

/* ---------- Toast ---------- */
#toast-wrap { position: fixed; top: 22px; right: 22px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-size: 14px;
  font-weight: 500;
  min-width: 280px;
  max-width: 380px;
  box-shadow: 0 12px 40px rgba(0,0,0,.6), 0 0 0 1px rgba(79,140,255,.1);
  animation: toast-in .2s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}
.toast.ok {
  border-left-color: var(--green);
  box-shadow: 0 12px 40px rgba(0,0,0,.6), 0 0 0 1px rgba(61,220,132,.12);
}
.toast.err {
  border-left-color: var(--red);
  background: rgba(255,93,108,.08);
  color: #ffb3b9;
  box-shadow: 0 12px 40px rgba(0,0,0,.6), 0 0 0 1px rgba(255,93,108,.2);
  font-weight: 600;
}

/* ---------- 找回密码步骤指示器 ---------- */
.ff-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin: 16px 0 24px;
}
.ff-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  opacity: .4;
  transition: opacity .3s;
}
.ff-step.active { opacity: 1; }
.ff-step.done { opacity: .7; }
.ff-step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  transition: all .3s;
}
.ff-step.active .ff-step-num {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 12px rgba(79,140,255,.5);
}
.ff-step.done .ff-step-num {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.ff-step-label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
.ff-step.active .ff-step-label { color: var(--accent); font-weight: 600; }
.ff-step.done .ff-step-label { color: var(--green); }
.ff-step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  min-width: 40px;
  max-width: 60px;
  margin-bottom: 16px;
  transition: background .3s;
}

/* ---------- 登录屏 ---------- */
.login {
  max-width: 420px; margin: 12vh auto 0; padding: 30px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.login h1 { font-size: 22px; margin: 0 0 6px; }
.login p { color: var(--muted); font-size: 13.5px; margin: 0 0 20px; }

/* ---------- 图表 ---------- */
.chart { width: 100%; display: block; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .bar { fill: var(--accent); }
.chart .bar.profit { fill: var(--green); }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .dotpt { fill: var(--accent); }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; flex-basis: auto; height: auto; position: static; display: flex; flex-wrap: wrap; gap: 6px; padding: 12px; align-items: center; }
  .sidebar .brand { margin: 0 12px 0 0; flex: 1; }
  .sidebar .grp { display: none; }
  .nav { display: flex; flex-wrap: wrap; gap: 4px; }
  .nav a { margin: 0; padding: 8px 10px; }
  .main { padding: 18px 16px 50px; }
}
@media (max-width: 560px) {
  .cards-grid { grid-template-columns: 1fr; }
  .cards-grid.two-col { grid-template-columns: 1fr; }
  .btn-row { gap: 8px; }
  .main { padding: 14px 12px 40px; }
  .card, .panel { padding: 14px 16px; }
  .panel h2 { font-size: 16px; margin-bottom: 12px; }
  .sidebar { padding: 8px 12px; }
  .sidebar .brand { font-size: 15px; }
  .nav a { padding: 6px 8px; font-size: 12.5px; }
  .topbar { flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }
  .topbar h1 { flex: 1 1 100%; font-size: 18px; }
  .modal-mask { padding: 12px; }
  .modal { padding: 18px; }
  /* chat */
  .chat-toolbar { gap: 8px; }
  .chat-toolbar .select { min-width: 0; flex: 1 1 120px; font-size: 13px; }
  .chat-bal { font-size: 12px; padding: 5px 10px; flex: 1 1 auto; text-align: center; }
  .chat-toolbar .btn.sm { padding: 5px 10px; font-size: 12px; }
  .chat-input { gap: 8px; padding-top: 10px; }
  .chat-input .textarea { padding: 12px 14px; font-size: 16px; }
  .chat-input .send { width: 48px; height: 48px; }
  .bubble { font-size: 15px; padding: 10px 12px; }
  /* Key 列表在手机上进一步紧凑：隐藏 IP 列、减小列宽、操作换行 */
  .keys-table { min-width: 0; }
  .keys-table th.key-cell,
  .keys-table td.key-cell { min-width: 0; }
  .keys-table th.label-cell,
  .keys-table td.label-cell { min-width: 80px; max-width: 140px; }
  .keys-table th.ip-cell,
  .keys-table td.ip-cell { display: none; }
  .keys-table .action-links { flex-direction: column; align-items: flex-start; gap: 4px; }
  .keys-table .action-links a + a::before { content: none; }
  .key-ops-help { font-size: 12px; padding: 10px 12px; }
  /* 模型管理：手机上隐藏供应商与单价列，模型 ID 不再被挤成竖排 */
  .table-scroll > .table.models-table { min-width: 0; }
  .models-table th.supplier-cell,
  .models-table td.supplier-cell,
  .models-table th.price-cell,
  .models-table td.price-cell { display: none; }
  .models-table td:first-child, .models-table th:first-child { min-width: 0; }
  .stat .hint { display: none; }
}

/* ---------- 客户注册引导 ---------- */
.auth-lead { color: var(--muted); font-size: 13px; margin: 0 0 14px; line-height: 1.7; }
.auth-lead b { color: var(--accent); }
.reg-steps { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.reg-step { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; }
.reg-step .n { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; }

/* ---------- 对话（Chat） ---------- */
.chat-app { display: flex; flex-direction: column; height: 100%; max-height: 100%; }
.chat-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.chat-toolbar .select { width: auto; min-width: 150px; }
.chat-toolbar .spacer { flex: 1; }
.chat-bal { font-size: 13px; color: var(--muted); background: var(--surface); border: 1px solid var(--border); padding: 7px 13px; border-radius: 999px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.chat-bal b { color: var(--text); }
.chat-msgs { flex: 1 1 auto; overflow-y: auto; padding: 8px 4px 16px; display: flex; flex-direction: column; gap: 16px; }
.bubble { max-width: 80%; padding: 12px 15px; border-radius: 14px; font-size: 14px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.bubble.user { align-self: flex-end; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-bottom-right-radius: 4px; }
.bubble.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble .role { font-size: 11px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .4px; }
.bubble.assistant .role { color: var(--accent); }
.bubble .usage { margin-top: 8px; font-size: 11.5px; color: var(--muted); border-top: 1px dashed var(--border); padding-top: 6px; font-variant-numeric: tabular-nums; }
.bubble .md { white-space: normal; }
.bubble .md p { margin: 0 0 8px; }
.bubble .md p:last-child { margin-bottom: 0; }
.bubble .md h1, .bubble .md h2, .bubble .md h3 { margin: 0 0 8px; font-size: 15px; color: var(--text); }
.bubble .md ul, .bubble .md ol { margin: 0 0 8px; padding-left: 20px; }
.bubble .md li { margin-bottom: 4px; }
.bubble .md strong { font-weight: 600; }
.bubble .md table { width: 100%; border-collapse: collapse; margin: 0 0 12px; font-size: 13.5px; border: 1px solid var(--border); }
.bubble .md table:last-child { margin-bottom: 0; }
.bubble .md th, .bubble .md td { padding: 8px 10px; text-align: left; border: 1px solid var(--border); vertical-align: top; }
.bubble .md thead { background: var(--surface-2); }
.bubble .md th { font-weight: 600; color: var(--text); }
.bubble .md tbody tr:nth-child(even) { background: rgba(255,255,255,0.03); }
.chat-empty { margin: auto; text-align: center; color: var(--muted); max-width: 360px; }
.chat-empty h3 { color: var(--text); font-size: 17px; margin: 0 0 8px; }
.chat-input { display: flex; gap: 10px; align-items: flex-end; margin-top: 12px; border-top: 1px solid var(--border); padding-top: 14px; }
.chat-input .textarea { flex: 1; min-height: 56px; max-height: 160px; padding: 15px 18px; border-radius: var(--radius); line-height: 1.5; font-size: 14px; }
.chat-input .send {
  flex: 0 0 auto;
  width: 56px; height: 56px;
  padding: 0;
  border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(79, 140, 255, 0.35);
}
.chat-input .send:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(79, 140, 255, 0.45); }
.chat-input .send:disabled { opacity: 0.6; transform: none; box-shadow: none; }
.bubble.chat-typing::after { content: '▋'; margin-left: 2px; animation: blink 1s steps(2) infinite; color: var(--muted); }
@keyframes blink { 50% { opacity: 0; } }
/* ---------- 对话页模型选择器（POE 风格） ---------- */
.chat-model-bar { position: relative; display: flex; align-items: center; margin: 0 0 10px; }
.model-trigger {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 13px; font-size: 13.5px; cursor: pointer;
  transition: border-color .15s, background .15s; max-width: 100%;
}
.model-trigger:hover { border-color: var(--accent); background: var(--surface-2); }
.model-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.model-trigger-icon { font-size: 15px; line-height: 1; }
.model-trigger-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-trigger-caret { color: var(--muted); flex: 0 0 auto; }
.model-picker {
  position: absolute; bottom: calc(100% + 8px); left: 0;
  width: 380px; max-width: calc(100vw - 48px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 12px 40px rgba(0,0,0,0.45);
  z-index: 50; display: none; overflow: hidden;
}
.model-picker-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 14px; color: var(--text);
}
.model-picker-close {
  background: transparent; border: 0; color: var(--muted);
  font-size: 22px; line-height: 1; cursor: pointer; padding: 0 2px;
}
.model-picker-close:hover { color: var(--text); }
.model-picker-body { max-height: 320px; overflow-y: auto; padding: 6px; }
.model-picker-empty { padding: 18px 12px; color: var(--muted); text-align: center; font-size: 13.5px; }
.model-group { margin-bottom: 6px; }
.model-group:last-child { margin-bottom: 0; }
.model-group-title {
  padding: 8px 10px 6px; font-size: 11.5px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .5px; font-weight: 600;
}
.model-option {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  width: 100%; text-align: left;
  background: transparent; border: 1px solid transparent; border-radius: 10px;
  padding: 9px 11px; margin-bottom: 3px; cursor: pointer; color: var(--text);
  transition: background .12s, border-color .12s;
}
.model-option:last-child { margin-bottom: 0; }
.model-option:hover { background: var(--surface-2); border-color: var(--border); }
.model-option.active { background: rgba(79,140,255,0.12); border-color: var(--accent); }
.model-option-name { font-size: 14px; font-weight: 500; }
.model-option-id { font-size: 11.5px; color: var(--muted); }

@media (max-width: 560px) {
  .chat-app { height: 100%; max-height: 100%; }
  .bubble { max-width: 90%; }
  .model-picker { width: 100%; max-width: 100%; left: 0; bottom: calc(100% + 6px); border-radius: var(--radius-sm); }
  .model-picker-body { max-height: 260px; }
  .model-trigger { padding: 6px 11px; font-size: 13px; }
}

/* 模型管理页：启用/停用开关 */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; cursor: pointer; inset: 0; background: var(--border); transition: .2s; border-radius: 22px; }
.switch .slider::before { content: ''; position: absolute; height: 16px; width: 16px; left: 3px; bottom: 3px; background: #fff; transition: .2s; border-radius: 50%; }
.switch input:checked + .slider { background: var(--accent, #3b82f6); }
.switch input:checked + .slider::before { transform: translateX(18px); }
