/* ==========================================================================
   AI API 开放平台 · 简洁风格设计系统（浅色为主 + 深色可选）
   ========================================================================== */

:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --panel-3: #f1f3f6;
  --line: #e4e7ee;
  --line-2: #ccd2dd;
  --fg: #12151b;
  --fg-muted: #4a5262;
  --fg-dim: #69707e;
  --accent: #2158d6;
  --accent-hover: #1b49b8;
  --accent-soft: #eef3ff;
  --ok: #15803d;
  --ok-soft: #f0fdf4;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --err: #b91c1c;
  --err-soft: #fef2f2;
  --info: #0369a1;
  --radius: 10px;
  --radius-sm: 8px;
  --shadow: 0 8px 24px rgba(16, 24, 40, .08);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --ease: cubic-bezier(.4, 0, .2, 1);
  /* 让 UA 绘制的控件（未显式着色的 button、滚动条、select 下拉、自动填充）跟随页面主题，
     而不是跟着 <meta name="color-scheme"> 猜——否则系统深色 + 页面浅色时，按钮文字会是白的 */
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #0f1116;
  --panel: #16181e;
  --panel-2: #1a1d24;
  --panel-3: #21252d;
  --line: #262a33;
  --line-2: #333945;
  --fg: #e7e9ee;
  --fg-muted: #a6adbb;
  --fg-dim: #8b93a3;
  --accent: #5b8cff;
  --accent-hover: #7aa2ff;
  --accent-soft: #1b2333;
  --ok: #4ade80;
  --ok-soft: #11231a;
  --warn: #fbbf24;
  --warn-soft: #241d10;
  --err: #f87171;
  --err-soft: #241417;
  --info: #7dd3fc;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
/* 表单控件不吃 UA 默认前景色：没写 color 的按钮会变成系统 buttontext（深色系统下就是白字） */
button, input, select, textarea, summary { color: inherit; font: inherit; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 13.5px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
body.no-scroll { overflow: hidden; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: .93em; }
code { background: var(--panel-3); padding: 1px 5px; border-radius: 4px; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.005em; }
h2 { font-size: 19px; }
h3 { font-size: 14.5px; }
h4 { font-size: 12.5px; color: var(--fg-muted); font-weight: 600; }
p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--fg-muted); }
.tiny { font-size: 12px; }
.center { text-align: center; }
.grow { flex: 1; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: 6px; }
::selection { background: var(--accent-soft); }
.skip-link { position: absolute; left: -999px; top: 0; z-index: 100; background: var(--accent); color: #fff; padding: 8px 14px; }
.skip-link:focus { left: 0; }

/* ─────────── 控件 ─────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 13px; border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--panel); color: var(--fg); font: inherit; font-weight: 500;
  cursor: pointer; transition: background .12s var(--ease), border-color .12s, color .12s;
  white-space: nowrap; user-select: none; text-decoration: none;
}
.btn:hover { background: var(--panel-3); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--err); border-color: var(--line-2); background: var(--panel); }
.btn.danger:hover { background: var(--err-soft); border-color: var(--err); }
.btn.ghost { background: transparent; border-color: var(--line-2); }
.btn.ghost:hover { background: var(--panel-3); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; }
.btn.lg { padding: 10px 18px; font-size: 14.5px; }
.btn.block { width: 100%; }
.btn[disabled], .btn.busy { opacity: .55; pointer-events: none; }
.btn.busy::after { content: ""; width: 11px; height: 11px; border-radius: 50%; border: 2px solid currentColor; border-top-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn {
  width: 30px; height: 30px; display: grid; place-items: center; border-radius: var(--radius-sm);
  border: 1px solid var(--line-2); background: var(--panel); color: var(--fg-muted); cursor: pointer; transition: .12s;
}
.icon-btn:hover { color: var(--fg); background: var(--panel-3); }
.icon-btn svg { width: 15px; height: 15px; }
.link-btn { background: none; border: 0; color: var(--accent); cursor: pointer; font: inherit; padding: 0; font-size: 12.5px; }
.link-btn:hover { text-decoration: underline; }

.input, input, textarea, select {
  width: 100%; background: var(--panel); color: var(--fg); border: 1px solid var(--line-2);
  border-radius: var(--radius-sm); padding: 8px 10px; font: inherit; transition: border-color .12s, box-shadow .12s;
}
input::placeholder, textarea::placeholder { color: var(--fg-dim); }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type="number"] { font-variant-numeric: tabular-nums; }
.input.sm, input.sm, select.sm { padding: 5px 9px; font-size: 12.5px; width: auto; min-width: 110px; }
textarea { resize: vertical; line-height: 1.55; }
textarea.mono { font-family: var(--mono); font-size: 12px; }

.field { display: grid; gap: 5px; font-size: 13px; color: var(--fg-muted); }
.field-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.field .hint, .hint { font-size: 12px; color: var(--fg-dim); }
.input-affix { position: relative; display: flex; align-items: center; gap: 6px; }
.affix-btn { border: 1px solid var(--line-2); background: var(--panel); color: var(--fg-muted); cursor: pointer; font: inherit; font-size: 12px; padding: 5px 9px; border-radius: var(--radius-sm); white-space: nowrap; }
.affix-btn:hover { color: var(--fg); background: var(--panel-3); }
.search-box { position: relative; display: inline-flex; align-items: center; min-width: 200px; }
.search-box .icon { position: absolute; left: 9px; color: var(--fg-dim); display: grid; place-items: center; }
.search-box .icon svg { width: 14px; height: 14px; }
.search-box input { padding-left: 30px; }
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }

.seg { display: inline-flex; background: var(--panel-3); border-radius: var(--radius-sm); padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--fg-muted); padding: 5px 10px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 12.5px; transition: .12s; }
.seg button:hover { color: var(--fg); }
.seg button.active { background: var(--panel); color: var(--fg); font-weight: 500; box-shadow: var(--shadow-sm); }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--fg-muted); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span { width: 32px; height: 18px; border-radius: 999px; background: var(--line-2); position: relative; transition: .18s; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: .18s var(--ease); box-shadow: var(--shadow-sm); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { left: 16px; }

.tag { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; font-size: 12px; color: var(--fg-muted); white-space: nowrap; }
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag.ok { color: var(--ok); }
.tag.warn { color: var(--warn); }
.tag.err { color: var(--err); }
.tag.info { color: var(--info); }
.tag.plain::before { display: none; }

.pbar { height: 5px; border-radius: 999px; background: var(--panel-3); overflow: hidden; min-width: 46px; }
.pbar i { display: block; height: 100%; border-radius: 999px; background: var(--accent); transition: width .3s var(--ease); }
.pbar.warn i { background: #f59e0b; }
.pbar.err i { background: #ef4444; }

/* ─────────── 登录 ─────────── */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); }
.login-hero { padding: 64px 56px; display: flex; flex-direction: column; gap: 18px; justify-content: center; }
.login-hero .hero-title { font-size: 30px; line-height: 1.3; font-weight: 600; margin-top: 8px; }
.grad { color: var(--accent); }
.hero-text { color: var(--fg-muted); max-width: 44ch; font-size: 14px; }
.hero-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; color: var(--fg-muted); font-size: 13px; }
.hero-list li { display: flex; gap: 8px; align-items: flex-start; }
.hero-list li::before { content: "·"; color: var(--accent); font-weight: 700; }
.hero-base { margin-top: 4px; display: grid; gap: 6px; }
.code-inline { font-family: var(--mono); font-size: 12.5px; color: var(--fg); background: var(--panel); border: 1px solid var(--line); padding: 8px 11px; border-radius: var(--radius-sm); word-break: break-all; }
.login-card { background: var(--panel); border-left: 1px solid var(--line); padding: 56px 52px; display: flex; flex-direction: column; gap: 14px; justify-content: center; }
.login-card h2 { font-size: 20px; }
.form-error { background: var(--err-soft); border: 1px solid #f3c7c7; color: var(--err); padding: 8px 11px; border-radius: var(--radius-sm); font-size: 12.5px; }
[data-theme="dark"] .form-error { border-color: #4a2323; }
#captcha-element:empty { display: none; }
.qr-box { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; align-items: start; }
.qr-box img { width: 220px; height: 220px; border: 1px solid var(--line); border-radius: 8px; background: #fff; display: block; }
.qr-secret { font-family: var(--mono); font-size: 12.5px; word-break: break-all; background: var(--panel-2, var(--panel)); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 10px; user-select: all; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 14px; font-family: var(--mono); font-size: 13.5px; letter-spacing: .5px; background: var(--panel-2, var(--panel)); border: 1px dashed var(--line); border-radius: var(--radius-sm); padding: 12px 14px; user-select: all; }
.modal.locked .title .icon-btn { display: none; }
@media (max-width: 640px) { .qr-box { grid-template-columns: minmax(0, 1fr); } }
.form-ok { background: var(--ok-soft); border: 1px solid #bfe6cb; color: var(--ok); padding: 8px 11px; border-radius: var(--radius-sm); font-size: 12.5px; }

/* ─────────── 顶栏 ─────────── */
.page-progress { position: fixed; top: 0; left: 0; height: 2px; width: 0; background: var(--accent); z-index: 90; transition: width .3s var(--ease), opacity .3s; opacity: 0; }
.page-progress.on { opacity: 1; }
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand { display: flex; gap: 10px; align-items: center; }
.brand-logo { width: 40px; height: 40px; border-radius: 8px; object-fit: contain; display: block; background: transparent; }
.brand-logo.sm { width: 32px; height: 32px; border-radius: 6px; }
.brand.small { gap: 8px; }
.brand.small .brand-name { font-size: 13.5px; }
.brand-text { display: grid; gap: 0; }
.brand-name { font-weight: 600; font-size: 13.5px; line-height: 1.25; }
.base-chip { display: inline-flex; align-items: center; gap: 6px; background: none; border: 0; color: var(--fg-dim); font: inherit; font-size: 11.5px; font-family: var(--mono); cursor: pointer; padding: 0; max-width: 260px; }
.base-chip:hover { color: var(--accent); }
.base-chip .dot { width: 5px; height: 5px; border-radius: 50%; background: var(--ok); flex: none; }
.base-chip span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.tabs button { background: transparent; border: 0; color: var(--fg-muted); padding: 7px 11px; border-radius: var(--radius-sm); cursor: pointer; font: inherit; font-size: 13.5px; transition: .12s; }
.tabs button:hover { color: var(--fg); background: var(--panel-3); }
.tabs button.active { color: var(--accent); background: var(--accent-soft); font-weight: 500; }
.tabs.sub { gap: 4px; }
.tabs.sub button { border: 1px solid var(--line); font-size: 12.5px; padding: 4px 10px; border-radius: 999px; }
.tabs.sub button.active { border-color: var(--accent); }

.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.quota-mini { display: flex; align-items: center; gap: 7px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; }
.quota-mini .qbar { width: 56px; height: 4px; border-radius: 999px; background: var(--panel-3); overflow: hidden; }
.quota-mini .qbar i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .3s var(--ease); }
.user-menu-wrap { position: relative; }
.user-btn { display: flex; align-items: center; gap: 7px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px 10px 3px 4px; color: var(--fg); cursor: pointer; font: inherit; font-size: 12.5px; }
.user-btn:hover { background: var(--panel-3); }
.avatar { width: 22px; height: 22px; border-radius: 50%; background: var(--accent); display: grid; place-items: center; font-size: 11px; font-weight: 600; color: #fff; }
.user-menu { position: absolute; right: 0; top: calc(100% + 6px); width: 220px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 5px; z-index: 40; }
.menu-head { padding: 8px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.menu-item { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--fg); padding: 7px 10px; border-radius: 6px; cursor: pointer; font: inherit; font-size: 13px; }
.menu-item:hover { background: var(--panel-3); }
.menu-item.danger { color: var(--err); }

/* 行内“更多”菜单 */
.menu-wrap { position: relative; display: inline-flex; }
#apply-models label.is-default { border-color: var(--ok); }
.row-menu { position: fixed; right: auto; top: 0; left: 0; z-index: 55; }
.kebab { width: 28px; height: 28px; border: 1px solid var(--line-2); background: var(--panel); border-radius: var(--radius-sm); color: var(--fg-muted); cursor: pointer; line-height: 1; font-size: 15px; }
.kebab:hover { background: var(--panel-3); color: var(--fg); }

/* ─────────── 布局 ─────────── */
.container { max-width: 1180px; margin: 0 auto; padding: 20px 20px 64px; display: grid; gap: 14px; }
/* 让含表格的栅格子项可以收缩，避免表格把卡片撑破 */
.container > *, .tab > *, .card > *, .grid-2 > *, .grid-2-1 > *, .row > *, .editor-item > * { min-width: 0; }
.grid-2.asym { grid-template-columns: minmax(240px, .8fr) minmax(0, 1.4fr); }
@media (max-width: 980px) { .grid-2.asym { grid-template-columns: minmax(0, 1fr); } }
.tab { display: grid; gap: 14px; align-content: start; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head h2 { font-size: 19px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; align-content: start; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-2-1 { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.row-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.sub-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.grid { display: grid; }

.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 6px; }
.stat .l { color: var(--fg-muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.stat .l svg { opacity: .7; }
.stat .v { font-size: 22px; font-weight: 600; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat .s { color: var(--fg-dim); font-size: 11.5px; }
.stat .delta { font-size: 11.5px; }
.stat .delta.up { color: var(--ok); }
.stat .delta.down { color: var(--err); }

/* ─────────── 表格 ─────────── */
table { width: 100%; max-width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
td { white-space: nowrap; }
th { color: var(--fg-muted); font-weight: 500; font-size: 12.5px; background: var(--panel-2); white-space: nowrap; position: sticky; top: 0; z-index: 2; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--fg); }
th .arrow { opacity: .4; font-size: 10px; margin-left: 3px; }
tbody tr:hover td { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: 0; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.wrap { white-space: normal; min-width: 220px; max-width: 460px; word-break: break-word; overflow-wrap: anywhere; }
.cell-2 .sub { white-space: normal; }
td .row { flex-wrap: wrap; }
td .mono { white-space: nowrap; }
td.nowrap { white-space: nowrap; }
.table-wrap { overflow-x: auto; max-width: 100%; overscroll-behavior-x: contain; }
/* 长文本单元格：默认折叠 3 行，hover 出全文，点击展开/收起 */
.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; cursor: zoom-in; }
.clamp.open { display: block; -webkit-line-clamp: unset; overflow: visible; cursor: zoom-out; }
.stack { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }
.cell-2 { display: grid; gap: 1px; }
.cell-2 .sub, .sub { color: var(--fg-dim); font-size: 12px; }
.empty { padding: 32px 16px; text-align: center; color: var(--fg-muted); display: grid; gap: 10px; place-items: center; }
.empty .big { font-size: 14px; color: var(--fg); }
.empty .em { font-size: 22px; opacity: .35; }
.skeleton { border-radius: 6px; background: var(--panel-3); height: 12px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .55; } }
.skel-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); }

/* ─────────── 图表 ─────────── */
.chart-host { display: grid; grid-template-columns: 52px minmax(0, 1fr); grid-template-rows: 190px 18px; gap: 6px 8px; }
.chart-y { display: flex; flex-direction: column; justify-content: space-between; text-align: right; font-size: 11px; color: var(--fg-dim); font-variant-numeric: tabular-nums; }
.chart-plot { position: relative; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.gline { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); opacity: .6; }
.bars { position: absolute; inset: 0; display: flex; align-items: flex-end; gap: 3px; padding: 0 4px; }
.bar { flex: 1 1 0; min-width: 4px; border-radius: 3px 3px 0 0; background: var(--accent); opacity: .85; transition: opacity .12s; position: relative; }
.bar.err { background: #ef4444; }
.bar:hover { opacity: 1; }
.bar .tip { position: absolute; bottom: calc(100% + 6px); left: 50%; transform: translate(-50%, 3px); opacity: 0; pointer-events: none; background: var(--fg); color: var(--panel); border-radius: 6px; padding: 5px 9px; font-size: 11.5px; white-space: nowrap; z-index: 6; transition: .12s var(--ease); }
[data-theme="dark"] .bar .tip { background: var(--panel-3); color: var(--fg); border: 1px solid var(--line-2); }
.bar:hover .tip { opacity: 1; transform: translate(-50%, 0); }
.chart-x { grid-column: 2; display: flex; gap: 3px; padding: 0 4px; font-size: 11px; color: var(--fg-dim); }
.chart-x span { flex: 1 1 0; text-align: center; white-space: nowrap; overflow: hidden; }
.legend { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); margin-right: 5px; }
.legend i.err { background: #ef4444; }

/* ─────────── 代码 / 说明 ─────────── */
.code-block { font-family: var(--mono); font-size: 12.5px; background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; white-space: pre-wrap; word-break: break-word; line-height: 1.55; margin: 0; }
.code-block.big { max-height: 380px; overflow: auto; }
.code-host { position: relative; }
.code-host .btn { position: absolute; top: 7px; right: 7px; }
.code-host .code-block { padding-right: 76px; }
.step-list { display: grid; gap: 8px; }
.step { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; color: var(--fg-muted); }
.step i { flex: none; width: 18px; height: 18px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-size: 10.5px; font-style: normal; font-weight: 600; margin-top: 1px; }
.summary { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 12.5px; display: grid; gap: 5px; }
.summary b { font-weight: 600; }
.rules { margin: 0; padding-left: 16px; color: var(--fg-muted); display: grid; gap: 7px; font-size: 12.5px; }
.rules b { color: var(--fg); font-weight: 600; }
.faq { display: grid; gap: 4px; }
.faq details, details.card { border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel-2); }
.faq summary, details.card > summary { cursor: pointer; padding: 10px 12px; font-weight: 500; font-size: 13px; list-style: none; }
.faq summary::-webkit-details-marker, details.card > summary::-webkit-details-marker { display: none; }
.faq summary::before, details.card > summary::before { content: "▸ "; color: var(--fg-dim); }
.faq details[open] summary::before, details.card[open] > summary::before { content: "▾ "; }
.faq p { margin: 0; padding: 0 12px 12px; color: var(--fg-muted); font-size: 12.5px; }
details.card { display: block; padding: 0; background: var(--panel); }
details.card > div { padding: 0 16px 16px; }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.presets button { border: 1px solid var(--line-2); background: var(--panel); color: var(--fg-muted); border-radius: 999px; padding: 3px 10px; font: inherit; font-size: 12px; cursor: pointer; }
.presets button:hover, .presets button.active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line-2); padding: 5px 11px; border-radius: 999px; font-size: 12.5px; color: var(--fg-muted); cursor: pointer; transition: .12s; }
.checks label:hover { border-color: var(--accent); }
.checks label.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.checks input { width: auto; accent-color: var(--accent); }
.kv { display: grid; gap: 14px; }
.onboard { display: grid; gap: 10px; }
.onboard ol { margin: 0; padding-left: 18px; color: var(--fg-muted); display: grid; gap: 6px; font-size: 13px; }
.onboard ol b { color: var(--fg); }
.warnbox { background: var(--warn-soft); border: 1px solid #f0d9a8; color: var(--warn); border-radius: var(--radius-sm); padding: 9px 11px; font-size: 12.5px; }
[data-theme="dark"] .warnbox { border-color: #4a3c17; }

/* ─────────── CC Switch 面板 ─────────── */
.cvs { display: grid; gap: 14px; }
.cvs-step { display: grid; gap: 8px; }
.cvs-label { font-size: 12.5px; color: var(--fg-muted); display: flex; align-items: center; gap: 8px; }
.cvs-label b { color: var(--fg); font-weight: 600; }
.cvs-apps { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; }
.cvs-app { display: grid; gap: 2px; text-align: left; padding: 10px 12px; border: 1px solid var(--line-2); background: var(--panel); border-radius: var(--radius-sm); cursor: pointer; font: inherit; color: var(--fg); transition: .12s; }
.cvs-app:hover { border-color: var(--accent); }
.cvs-app.active { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cvs-app.locked { cursor: default; }
.cvs-app.locked:hover { border-color: var(--accent); }
.cvs-app b { font-weight: 600; font-size: 13px; color: inherit; }
.cvs-app span { font-size: 11.5px; color: var(--fg-muted); }
.cvs-app.active b { color: var(--accent); }
.cvs-app.active span { color: var(--fg-muted); }
.cvs-app::before { content: ""; }
.cvs-keyline { display: grid; grid-template-columns: minmax(160px, 1fr) minmax(200px, 1.4fr) auto; gap: 8px; align-items: center; }
.cvs-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.cvs-adv { display: grid; gap: 10px; padding: 12px; border: 1px dashed var(--line-2); border-radius: var(--radius-sm); background: var(--panel-2); }
.cvs-result { display: grid; gap: 10px; padding-top: 4px; border-top: 1px solid var(--line); }
.cvs-endpoint { font-family: var(--mono); font-size: 12.5px; color: var(--fg); word-break: break-all; }
.cvs-file { display: grid; gap: 6px; }
.cvs-file-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cvs-file-head span { font-family: var(--mono); font-size: 12px; color: var(--fg-muted); }

/* ─────────── 管理端编辑器 ─────────── */
.editor-list { display: grid; gap: 10px; }
.editor-item { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; display: grid; gap: 10px; }
.editor-item .ei-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.editor-item .ei-title { font-weight: 600; display: flex; align-items: center; gap: 8px; font-size: 13px; }
.editor-item .ei-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.editor-item input, .editor-item select, .editor-item textarea { font-size: 12.5px; }
.json-panel { background: var(--panel-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; display: grid; gap: 10px; }
.model-list { max-height: 340px; overflow: auto; display: grid; gap: 5px; padding-right: 4px; }
.model-pick { display: flex; align-items: center; gap: 9px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--panel); cursor: pointer; font-size: 12.5px; }
.model-pick:hover { border-color: var(--accent); }
.model-pick input { width: auto; accent-color: var(--accent); }
.model-pick .mid { font-family: var(--mono); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ─────────── 模态 / 提示 ─────────── */
.modal-mask { position: fixed; inset: 0; background: rgba(16, 24, 40, .45); display: grid; place-items: center; padding: 20px; z-index: 60; overflow: auto; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 20px; width: 100%; max-width: 540px; display: grid; gap: 14px; box-shadow: var(--shadow); max-height: 92vh; overflow: auto; }
.modal.wide { max-width: 720px; }
.modal .title { font-size: 16px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.modal .modal-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.modal .desc { color: var(--fg-muted); font-size: 12.5px; }
.key-reveal { display: grid; gap: 8px; }
.key-reveal .value { font-family: var(--mono); font-size: 13px; background: var(--panel-2); border: 1px solid var(--accent); border-radius: var(--radius-sm); padding: 11px; word-break: break-all; }
.countdown { font-size: 11.5px; color: var(--fg-muted); }
.toast-root { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 80; max-width: min(92vw, 380px); }
.toast { display: flex; gap: 10px; align-items: flex-start; background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--accent); padding: 10px 12px; border-radius: var(--radius-sm); font-size: 12.5px; box-shadow: var(--shadow); }
.toast .x { background: none; border: 0; color: var(--fg-dim); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; }
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast.warn { border-left-color: var(--warn); }
.toast.out { opacity: 0; transition: .2s; }

/* ─────────── 响应式 ─────────── */
@media (max-width: 1180px) { .grid-2-1 { grid-template-columns: minmax(0, 1fr); } .quota-mini { display: none; } }
@media (max-width: 980px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { padding: 36px 24px 8px; }
  .login-hero .hero-title { font-size: 24px; }
  .login-card { border-left: 0; border-top: 1px solid var(--line); padding: 28px 24px 44px; }
  .grid-2, .row-3, .row-4 { grid-template-columns: minmax(0, 1fr); }
  .cvs-keyline { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .topbar { gap: 8px; padding: 10px 14px; }
  .topbar-right { width: 100%; margin-left: 0; justify-content: space-between; }
  .user-name { display: none; }
  .container { padding: 14px 14px 56px; }
  table.responsive thead { display: none; }
  table.responsive tr { display: grid; gap: 5px; padding: 11px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 8px; }
  table.responsive td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 1px 0; white-space: normal; text-align: right; }
  table.responsive td::before { content: attr(data-label); color: var(--fg-dim); font-size: 11.5px; text-align: left; flex: none; }
  .chart-host { grid-template-columns: 44px minmax(0, 1fr); grid-template-rows: 160px 18px; }
}
@media (max-width: 620px) {
  .page-head { align-items: flex-start; flex-direction: column; }
  .card { padding: 14px; }
  .modal { padding: 16px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }
