/* ============ Strata codex · 深色玻璃拟态 ============ */
:root {
  --bg: #0a0d16;
  --panel: rgba(22, 27, 43, 0.72);
  --panel-2: rgba(30, 36, 56, 0.65);
  --border: rgba(255, 255, 255, 0.08);
  --border-hi: rgba(124, 108, 255, 0.45);
  --text: #e8ecf6;
  --dim: #8a93ab;
  --accent: #7c6cff;
  --accent-2: #2dd4bf;
  --red: #ff5d73;
  --green: #34d399;
  --amber: #fbbf24;
  --radius: 16px;
  --font: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  --mono: "Cascadia Code", Consolas, "Microsoft YaHei", monospace;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  overflow-x: hidden;
}
.bg-glow {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 500px at 12% -8%, rgba(124, 108, 255, 0.16), transparent 60%),
    radial-gradient(800px 480px at 88% -5%, rgba(45, 212, 191, 0.12), transparent 60%),
    radial-gradient(700px 600px at 50% 115%, rgba(124, 108, 255, 0.08), transparent 60%),
    var(--bg);
}

/* ============ 顶栏：品牌 + 控制 + 标签页 ============ */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(10, 13, 22, 0.82);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}
.tb-row {
  display: flex; align-items: center; gap: 14px;
  padding: 11px 22px 11px;
}
.tb-row.tb-sub {
  padding: 0 22px;
  gap: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.045);
}
.brand { display: flex; align-items: center; gap: 11px; flex-shrink: 0; }
.logo {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center;
  font-size: 17px; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 5px 18px rgba(124, 108, 255, 0.35);
}
.brand h1 { font-size: 16.5px; font-weight: 700; letter-spacing: 0.3px; white-space: nowrap; }

/* 顶栏内嵌的引擎控制组（整体靠左，按钮作为组中主角居中） */
.tb-main { position: relative; justify-content: flex-start; gap: 22px; }
.ctrl-inline {
  position: relative; left: 0; transform: none;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  justify-content: flex-start;
}
#btnOfficial { margin-left: auto; }
.ctrl-model select {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 7px 12px; font-size: 13px; min-width: 150px; max-width: 220px;
  outline: none; cursor: pointer; transition: border-color 0.2s; font-family: var(--font);
  text-overflow: ellipsis;
}
.ctrl-model select:hover, .ctrl-model select:focus { border-color: var(--border-hi); }
/* 选中的是「依赖文件缺失」的配置：明确标红，别让用户白等一次失败 */
.ctrl-model select.bad { border-color: rgba(255, 93, 115, 0.75); color: #ffc2cb; }
.ctrl-start.warn {
  background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #3a2600;
  box-shadow: 0 6px 22px rgba(251, 191, 36, 0.35);
}
.ctrl-status {
  display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--dim);
  white-space: nowrap; max-width: 320px; overflow: hidden;
}
.ctrl-status .dot { width: 9px; height: 9px; border-radius: 50%; background: #64748b; transition: 0.3s; flex-shrink: 0; }
.ctrl-status.on { color: #d9fbe9; }
.ctrl-status.on .dot { background: var(--green); box-shadow: 0 0 0 0 rgba(52,211,153,0.5); animation: pulse 1.8s infinite; }
.ctrl-status.ext { color: #c7d2fe; }
.ctrl-status.ext .dot { background: var(--accent-2); }
.ctrl-status.err { color: #ffc4cc; }
.ctrl-status.err .dot { background: var(--red); animation: pulse 1s infinite; }

.ctrl-start {
  background: linear-gradient(135deg, #2dd4bf, #34d399); color: #06281f; border: none;
  font-weight: 800; font-size: 14px; padding: 9px 22px; border-radius: 11px; cursor: pointer;
  font-family: var(--font); box-shadow: 0 4px 16px rgba(45,212,191,0.34); letter-spacing: 0.4px;
  transition: all 0.18s ease;
}
.ctrl-start:hover:not(:disabled) { box-shadow: 0 6px 22px rgba(45,212,191,0.5); transform: translateY(-1px); }
.ctrl-start:disabled { opacity: 0.32; cursor: not-allowed; box-shadow: none; }

/* ===== 运行形式：固定 / 智能 ===== */
.mode-switch {
  position: relative; display: inline-flex; align-items: stretch;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 999px; padding: 3px; flex-shrink: 0;
}
.mode-opt {
  position: relative; z-index: 1; flex: 1 1 0; min-width: 84px;
  border: none; background: none; color: var(--dim); font-family: var(--font);
  font-size: 13px; font-weight: 600; padding: 7px 16px; border-radius: 999px;
  cursor: pointer; transition: color .2s; white-space: nowrap; text-align: center;
}
.mode-opt.active { color: #06281f; }
.mode-thumb {
  position: absolute; z-index: 0; top: 3px; bottom: 3px; left: 3px;
  width: calc(50% - 3px); border-radius: 999px;
  background: linear-gradient(135deg, #2dd4bf, #34d399);
  box-shadow: 0 3px 12px rgba(45,212,191,.4);
  transition: transform .26s cubic-bezier(.34,1.4,.5,1), background .26s, box-shadow .26s;
}
.mode-switch.smart .mode-thumb {
  transform: translateX(100%);
  background: linear-gradient(135deg, #7c6cff, #a78bfa);
  box-shadow: 0 3px 12px rgba(124,108,255,.42);
}

/* 智能模式说明药丸（替代模型下拉，保持布局平衡） */
.ctrl-smart { display: inline-flex; flex-shrink: 0; }
.smart-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, rgba(124,108,255,.20), rgba(167,139,250,.12));
  border: 1px solid rgba(124,108,255,.42); color: #c7d2fe;
  border-radius: 10px; padding: 8px 14px; font-size: 12.5px; white-space: nowrap;
}

/* ===== 圆形播放/暂停合一按钮（精致居中，缩小一点避免遮挡） ===== */
.power-wrap { position: relative; width: 52px; height: 52px; flex-shrink: 0; z-index: 2; }
.power-wrap::before {
  content: ""; position: absolute; inset: -4px; border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(45,212,191,0) 0deg, rgba(45,212,191,0) 235deg,
              #2dd4bf 330deg, #a7f3d0 356deg, rgba(45,212,191,0) 360deg);
  opacity: 0; transition: opacity 0.3s; pointer-events: none;
}
.power-wrap.running::before { opacity: 1; animation: powerSpin 1.5s linear infinite; }
.power-wrap.loading::before {
  opacity: 1;
  background: conic-gradient(from 0deg, rgba(124,108,255,0.06) 0deg, rgba(124,108,255,0.06) 300deg, #a78bfa 360deg);
  animation: powerSpin 0.9s linear infinite;
}
.power-wrap.warn::before { opacity: 1; animation: none;
  background: conic-gradient(#fbbf24, #f59e0b, #fbbf24); }
.power-btn {
  position: relative; width: 52px; height: 52px; border-radius: 50%; border: none; cursor: pointer;
  background: linear-gradient(135deg, #34d4bf, #2dd4bf 42%, #34d399); color: #06281f;
  display: grid; place-items: center; font-family: var(--font);
  box-shadow: 0 6px 20px rgba(45,212,191,0.45), inset 0 1px 2px rgba(255,255,255,0.45), inset 0 -3px 7px rgba(0,0,0,0.18);
  transition: transform 0.16s, box-shadow 0.2s, background 0.25s;
}
.power-btn:hover { transform: scale(1.05); box-shadow: 0 8px 28px rgba(45,212,191,0.62), inset 0 1px 2px rgba(255,255,255,0.5); }
.power-btn:active { transform: scale(0.97); }
.pb-icon { font-size: 18px; line-height: 1; letter-spacing: -1px; padding-left: 3px; text-shadow: 0 1px 1px rgba(0,0,0,0.15); }
.power-wrap.running .power-btn {
  background: linear-gradient(135deg, #ff5d73, #ff7a5c 45%, #ff6b8a); color: #fff;
  box-shadow: 0 6px 20px rgba(255,93,115,0.45), inset 0 1px 2px rgba(255,255,255,0.35), inset 0 -3px 7px rgba(0,0,0,0.2);
}
.power-wrap.running .pb-icon { padding-left: 0; font-size: 14px; letter-spacing: 0; }
.power-wrap.loading .power-btn { background: rgba(124,108,255,0.3); color: #c4b5fd; cursor: wait;
  box-shadow: 0 6px 22px rgba(124,108,255,0.4), inset 0 1px 2px rgba(255,255,255,0.3); }
.power-wrap.warn .power-btn {
  background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #3a2600;
  box-shadow: 0 6px 22px rgba(251,191,36,0.45), inset 0 1px 2px rgba(255,255,255,0.4);
}
@keyframes powerSpin { to { transform: rotate(360deg); } }

/* 标签页 */
.tabs { display: flex; gap: 2px; flex-wrap: wrap; position: relative; }
.more-wrap { position: relative; display: flex; align-items: center; }
.more-menu { position: absolute; top: 100%; right: 0; margin-top: 6px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; gap: 6px; z-index: 30; min-width: 220px; box-shadow: 0 12px 32px rgba(0,0,0,.45); }
.more-menu[hidden] { display: none; }   /* 作者样式会盖掉 [hidden] 的默认 display:none，必须显式补回 */
.more-menu .more-item { background: transparent; border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; font-size: 12.5px; color: var(--text); cursor: pointer; text-align: left; }
.more-menu .more-item:hover { border-color: var(--accent); }
.tab {
  background: none; border: none; color: var(--dim); font-family: var(--font);
  font-size: 13.5px; padding: 12px 15px 11px; cursor: pointer; position: relative;
  transition: color 0.2s; border-radius: 9px 9px 0 0; white-space: nowrap;
  display: inline-flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); font-weight: 600; }
.tab.active::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2.5px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); border-radius: 3px;
}
/* 「📊 监控」标签右侧引擎状态点：红=未运行 / 琥珀=模型未加载 / 绿=本地模型运行中 */
.tab-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: #64748b; transition: background .3s, box-shadow .3s; }
.tab-dot.off { background: #ef4444; box-shadow: 0 0 7px #ef4444aa; }
.tab-dot.busy { background: #f5b14c; box-shadow: 0 0 7px #f5b14caa; animation: mmPulse 1.2s infinite; }
.tab-dot.on { background: #22c55e; box-shadow: 0 0 7px #22c55eaa; }
@keyframes mmPulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

/* 迷你监控条（顶栏第二行右侧） */
.mini-mon { display: flex; align-items: stretch; gap: 7px; flex-wrap: wrap; margin-left: auto; }
/* 一排 4 张小卡片：引擎状态 / 显存 / 温度·功耗 / 网关 */
.mm-card {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 5px 11px; min-width: 96px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
  transition: border-color 0.25s, background 0.25s;
}
.mm-card .mm-txt { display: flex; flex-direction: column; line-height: 1.25; }
.mm-card .mm-txt b { color: var(--text); font-weight: 600; font-size: 12.5px; }
.mm-card .mm-txt span { font-size: 10px; color: var(--dim); }
.mm-ic { font-size: 14px; opacity: 0.9; }
.mm-card.gw-card { cursor: pointer; border-color: rgba(45,212,191,0.35); background: rgba(45,212,191,0.1); }
.mm-card.gw-card .mm-txt b, .mm-card.gw-card .mm-txt span { color: #6ee7d3; }
.mm-card.gw-card.on { border-color: rgba(52,211,153,0.5); background: rgba(52,211,153,0.14); }
.mm-card.gw-card.on .mm-txt b, .mm-card.gw-card.on .mm-txt span { color: #86efac; }
.mm-card.gw-card.off { border-color: rgba(148,163,184,0.28); background: rgba(148,163,184,0.08); }
.mm-card.gw-card.off .mm-txt b, .mm-card.gw-card.off .mm-txt span { color: #94a3b8; }
/* 窄屏（≤1200px）：卡片收紧留空间，只显示主值行 */
@media (max-width: 1200px) {
  .mini-mon { gap: 5px; }
  .mm-card { min-width: 0; padding: 4px 8px; }
  .mm-card .mm-txt span { display: none; }
  .mm-card .mm-txt b { font-size: 11.5px; }
}
.mm-dot { width: 7px; height: 7px; border-radius: 50%; background: #64748b; transition: 0.3s; }
.mm-dot.on { background: var(--green); box-shadow: 0 0 8px rgba(52,211,153,0.6); }
.mm-dot.busy { background: var(--accent-2); animation: pulse 1.2s infinite; }
.mm-dot.err { background: var(--red); }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(52,211,153,0.45); }
  70% { box-shadow: 0 0 0 7px rgba(52,211,153,0); }
  100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); }
}

/* ============ 按钮 ============ */
.btn {
  border: 1px solid var(--border); background: var(--panel-2); color: var(--text);
  padding: 9px 18px; border-radius: 11px; font-size: 13.5px; cursor: pointer;
  font-family: var(--font); text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
  transition: all 0.18s ease; white-space: nowrap;
}
.btn:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--border-hi); }
.btn:active:not(:disabled) { transform: translateY(0); }
.btn:disabled { opacity: 0.38; cursor: not-allowed; }
.btn.primary { background: linear-gradient(135deg, #7c6cff, #5b8cff); border: none; box-shadow: 0 4px 18px rgba(91,140,255,0.35); font-weight: 600; }
.btn.primary:hover:not(:disabled) { box-shadow: 0 6px 24px rgba(91,140,255,0.5); }
.btn.go { background: linear-gradient(135deg, #2dd4bf, #34d399); color: #06281f; border: none; font-weight: 700; box-shadow: 0 4px 18px rgba(45,212,191,0.3); }
.btn.danger { background: linear-gradient(135deg, #ff5d73, #ff7a5c); border: none; font-weight: 600; }
.btn.danger-o { border-color: rgba(255, 93, 115, 0.45); color: #ffb3bd; }
.btn.danger-o:hover { background: rgba(255, 93, 115, 0.12); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 12px; font-size: 12.5px; border-radius: 9px; }

/* ============ 标签页 ============ */
main { padding: 18px 22px 24px; max-width: 1760px; margin: 0 auto; }
.view { display: none; animation: fadein 0.3s ease; }
.view.active { display: block; }

/* ===== 合体：Strata codex 是本体，这里只是进入它的入口（紧凑横幅，不占屏） ===== */
.dsh-merge { display: flex; align-items: center; justify-content: center;
  min-height: 44vh; padding: 20px; }
.dsh-merge-card { width: min(780px, 100%); display: flex; align-items: center; gap: 16px;
  text-align: left; padding: 16px 18px;
  background: linear-gradient(180deg, rgba(45,212,191,.07), rgba(18,22,31,.55));
  border: 1px solid rgba(45,212,191,.22); border-radius: 14px;
  box-shadow: 0 12px 34px rgba(0,0,0,.28); }
.dsh-merge-logo { font-size: 30px; line-height: 1; flex: none; }
.dsh-merge-main { flex: 1 1 auto; min-width: 0; }
.dsh-merge-card h2 { margin: 0 0 4px; font-size: 16px; color: #e6edf7; }
.dsh-merge-card p { margin: 0; font-size: 12.5px; line-height: 1.6; color: #aab6cc; }
.dsh-merge-card b { color: #2dd4bf; font-weight: 600; }
.dsh-merge-hint { display: none; }      /* 文案已并进上面那段，窄屏也不会挤 */

/* ============ 内网穿透面板（精简版） ============ */
.tunnel-card { max-width: 560px; padding: 20px 22px; }
.tn-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.tn-dot {
  width: 12px; height: 12px; border-radius: 50%; flex: none;
  background: #ef4444; transition: background 0.3s, box-shadow 0.3s;
}
.tn-dot.on { background: var(--green); box-shadow: 0 0 10px rgba(52,211,153,0.55); }
.tn-dot.off { background: #ef4444; }
.tn-dot.wait { background: #f5b14c; animation: pulse 1.2s infinite; }
.tn-titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tn-titles b { font-size: 15px; color: var(--text); }
.tn-row { display: flex; flex-direction: column; gap: 9px; margin: 14px 0; }
.tn-hint { margin: 0; font-size: 11.5px; line-height: 1.55; color: var(--dim); }
/* 滑动开关：左关 右开 */
.tn-switch-line { display: flex; align-items: center; gap: 10px; }
.tn-sw-label { font-size: 12.5px; color: var(--dim); transition: color 0.25s; }
.tn-sw-label.lit { color: var(--text); font-weight: 600; }
.tn-switch { position: absolute; opacity: 0; width: 0; height: 0; }
.tn-sw-track {
  width: 46px; height: 25px; border-radius: 999px; flex: none; cursor: pointer;
  background: rgba(148,163,184,0.25); border: 1px solid var(--border);
  position: relative; transition: background 0.25s, border-color 0.25s;
}
.tn-sw-thumb {
  position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 50%;
  background: #e2e8f0; box-shadow: 0 1px 4px rgba(0,0,0,0.4);
  transition: transform 0.25s cubic-bezier(.4,0,.2,1), background 0.25s;
}
.tn-switch:checked + .tn-sw-track { background: rgba(52,211,153,0.45); border-color: rgba(52,211,153,0.6); }
.tn-switch:checked + .tn-sw-track .tn-sw-thumb { transform: translateX(21px); background: #34d399; }
.tn-switch:focus-visible + .tn-sw-track { outline: 2px solid var(--accent); outline-offset: 2px; }
/* 访问地址 */
.tn-url-label { font-size: 12px; color: var(--dim); }
.tn-url-line { display: flex; gap: 8px; align-items: center; }
.tn-url-line code {
  flex: 1; word-break: break-all; font-size: 12.5px; color: #6ee7d3;
  background: rgba(45,212,191,0.08); border: 1px solid rgba(45,212,191,0.3);
  border-radius: 8px; padding: 8px 10px;
}
/* 首次一次性设置（默认折叠） */
.tn-setup { margin: 10px 0 0; font-size: 12px; color: var(--dim); }
.tn-setup summary { cursor: pointer; color: var(--accent); user-select: none; }
.tn-setup p { margin: 8px 0 0; line-height: 1.6; }
.dsh-merge-actions { display: flex; gap: 8px; flex: none; }
.dsh-merge-actions .btn { text-decoration: none; white-space: nowrap; }
@media (max-width: 700px) {
  .dsh-merge-card { flex-wrap: wrap; }
  .dsh-merge-actions { width: 100%; }
  .dsh-merge-actions .btn { flex: 1; }
}

/* ============ 对话页：Strata codex（内置 iframe） ============ */
.dsh-shell {
  border: 1px solid var(--border); border-radius: 16px; overflow: hidden;
  background: #151517;                       /* 与 DSH 自身底色一致，避免白闪 */
  height: calc(100vh - 212px); min-height: 480px;
  display: flex; flex-direction: column;
}
.dsh-bar {
  display: flex; align-items: center; gap: 10px; flex: 0 0 auto;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  background: rgba(22, 27, 43, 0.82);
}
.dsh-tag {
  font-size: 12px; font-weight: 600; letter-spacing: .3px;
  color: var(--accent-2); border: 1px solid rgba(45, 212, 191, 0.35);
  background: rgba(45, 212, 191, 0.08); border-radius: 999px; padding: 3px 10px;
}
.dsh-state { font-size: 12px; color: var(--dim); }
.dsh-state.on { color: var(--green); }
.dsh-state.err { color: var(--red); }
.dsh-sp { flex: 1; }
.dsh-stage { position: relative; flex: 1 1 auto; min-height: 0; }
.dsh-loading {
  position: absolute; inset: 0; z-index: 5; display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: #151517; color: var(--dim); font-size: 13px; text-align: center; padding: 24px;
}
.dsh-loading.show { display: flex; }
.dsh-spin {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid rgba(124, 108, 255, 0.25); border-top-color: var(--accent);
  animation: dsh-spin 0.9s linear infinite;
}
@keyframes dsh-spin { to { transform: rotate(360deg); } }
.dsh-err { color: var(--red); font-family: var(--mono); font-size: 12px; word-break: break-all; }
.dsh-loading code {
  font-family: var(--mono); background: rgba(255, 255, 255, 0.07);
  padding: 2px 6px; border-radius: 6px; color: var(--text);
}
#btnWeb { border-color: rgba(45, 212, 191, 0.35) !important; color: var(--accent-2) !important; }
.dsh-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); display: inline-block; flex: 0 0 auto; }
.dsh-dot.on { background: var(--green); box-shadow: 0 0 8px rgba(52, 211, 153, 0.6); }
.dsh-dot.err { background: var(--red); }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============ 卡片 ============ */
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}
.card h3 { font-size: 14.5px; font-weight: 600; margin-bottom: 12px; color: #cdd5e8; }

/* ============ 监控页 ============ */
.state-banner {
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: 16px 22px; margin-bottom: 16px; flex-wrap: wrap;
  background: linear-gradient(120deg, rgba(124,108,255,0.10), rgba(45,212,191,0.06)), var(--panel);
}
.state-title { font-size: 20px; font-weight: 700; letter-spacing: 0.3px; }
.state-detail { color: var(--dim); margin-top: 4px; font-size: 13px; }
.state-right { text-align: right; color: var(--dim); font-size: 12.5px; line-height: 1.8; }
.state-right b { color: var(--text); }

.empty-hint { text-align: center; padding: 46px 20px; color: var(--dim); border: 1.5px dashed rgba(255,255,255,0.12); border-radius: var(--radius); background: rgba(255,255,255,0.015); }
.empty-icon { font-size: 36px; margin-bottom: 10px; filter: grayscale(0.25); }
.eh-title { font-size: 16px; color: var(--text); font-weight: 650; margin-bottom: 8px; }
.eh-sub { font-size: 13px; line-height: 1.9; }
.eh-sub b { color: var(--accent-2); font-weight: 600; }

/* 监控指标：横排 4 个、3 排共 12 张（窄屏自动降为 2 列） */
.grid-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; margin-bottom: 16px; }
@media (max-width: 1180px) { .grid-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 620px) { .grid-stats { grid-template-columns: 1fr; } }
.stat-card { padding: 15px 17px 11px; position: relative; overflow: hidden; transition: border-color 0.25s; }
.stat-card:hover { border-color: var(--border-hi); }
.stat-head { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 12.5px; margin-bottom: 8px; }
.stat-head .ic { font-size: 15px; }
.stat-val { font-size: 25px; font-weight: 750; letter-spacing: 0.3px; line-height: 1.1; }
.stat-val small { font-size: 13px; color: var(--dim); font-weight: 500; margin-left: 3px; }
.stat-sub { font-size: 11.5px; color: var(--dim); margin-top: 3px; min-height: 15px; }
.stat-spark { display: block; width: 100%; height: 32px; margin-top: 8px; opacity: 0.9; }

.monitor-bottom { display: grid; grid-template-columns: 320px 1fr; gap: 14px; }
@media (max-width: 980px) { .monitor-bottom { grid-template-columns: 1fr; } }
.gauge-col { padding: 20px; }
.donut-wrap { position: relative; width: 168px; margin: 6px auto 18px; }
.donut { width: 168px; height: 168px; transform: rotate(-90deg); }
.donut-bg { fill: none; stroke: rgba(255,255,255,0.07); stroke-width: 11; }
.donut-fg { fill: none; stroke: var(--accent-2); stroke-width: 11; stroke-linecap: round; stroke-dasharray: 314; stroke-dashoffset: 314; transition: stroke-dashoffset 0.6s ease; }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; }
.donut-center b { font-size: 27px; font-weight: 750; }
.donut-center span { font-size: 11.5px; color: var(--dim); margin: 2px 0; }
.donut-center em { font-style: normal; font-size: 11px; color: var(--dim); }
.bar-row { display: flex; justify-content: space-between; font-size: 12.5px; margin: 13px 0 6px; color: #c3cbdf; }
.bar-row span { color: var(--dim); font-variant-numeric: tabular-nums; }
.bar { height: 8px; border-radius: 6px; background: rgba(255,255,255,0.06); overflow: hidden; }
.bar-fg { height: 100%; border-radius: 6px; width: 0%; transition: width 0.5s ease; }
.c-violet { background: linear-gradient(90deg, #7c6cff, #a78bfa); }
.c-red { background: linear-gradient(90deg, #f87171, #ff5d73); }
.c-amber { background: linear-gradient(90deg, #fbbf24, #f59e0b); }

.req-col { padding: 20px; display: flex; flex-direction: column; min-height: 300px; }
.req-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.totals { font-size: 11.5px; color: var(--dim); }
.table-wrap { overflow-x: auto; flex: 1; }
.req-table { width: 100%; border-collapse: collapse; font-size: 12.8px; }
.req-table th { text-align: left; color: var(--dim); font-weight: 500; font-size: 11.5px; padding: 8px 10px; border-bottom: 1px solid var(--border); letter-spacing: 0.4px; text-transform: uppercase; white-space: nowrap; }
.req-table td { padding: 8.5px 10px; border-bottom: 1px solid rgba(255,255,255,0.04); font-variant-numeric: tabular-nums; white-space: nowrap; }
.req-table tr:hover td { background: rgba(124,108,255,0.05); }
.tag { padding: 2.5px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }
.tag.done { background: rgba(52,211,153,0.14); color: #6ee7b7; }
.tag.length { background: rgba(251,191,36,0.14); color: #fcd34d; }
.tag.cancelled { background: rgba(148,163,184,0.15); color: #cbd5e1; }
.tag.error, .tag.failed { background: rgba(255,93,115,0.15); color: #fda4af; }
.dim { color: var(--dim); }

/* ============ 参数页 ============ */
.params-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 20px; margin-bottom: 16px; flex-wrap: wrap; }
.pt-left { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.chip { background: linear-gradient(135deg, rgba(124,108,255,0.25), rgba(45,212,191,0.2)); border: 1px solid var(--border-hi); padding: 5px 14px; border-radius: 999px; font-weight: 600; font-size: 13px; }
.pt-right { display: flex; gap: 8px; flex-wrap: wrap; }
.params-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 14px; }
@media (max-width: 920px) { .params-grid { grid-template-columns: 1fr; } }
.pgroup { padding: 18px 20px; }
.pgroup .gtitle { display: flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 650; margin-bottom: 4px; }
.pgroup .gdesc { font-size: 11.5px; color: var(--dim); margin-bottom: 14px; }
.field { display: flex; align-items: center; gap: 10px; margin: 9px 0; flex-wrap: wrap; }
.field > span { width: 128px; min-width: 128px; font-size: 12.5px; color: #b8c1d9; flex-shrink: 0; }
.field input[type=text], .field input[type=number], .field select, .field textarea {
  flex: 1; min-width: 130px; background: rgba(10,13,22,0.55); border: 1px solid var(--border);
  color: var(--text); border-radius: 9px; padding: 7.5px 11px; font-size: 13px; outline: none; transition: border-color 0.2s; font-family: var(--font);
}
.field textarea { font-family: var(--mono); font-size: 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--border-hi); }
.field .hint { width: 100%; font-size: 11px; color: var(--dim); padding-left: 138px; margin-top: -4px; }
.field input[type=range] { flex: 1; accent-color: var(--accent); }
.field .range-val { min-width: 52px; text-align: right; font-variant-numeric: tabular-nums; color: var(--accent-2); font-weight: 600; }

.switch-row { display: flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; color: #b8c1d9; }
.switch-row input { display: none; }
.switch-row .switch { width: 38px; height: 21px; background: rgba(255,255,255,0.12); border-radius: 999px; position: relative; transition: 0.25s; flex-shrink: 0; }
.switch-row .switch::after { content: ""; position: absolute; width: 15px; height: 15px; border-radius: 50%; background: #fff; top: 3px; left: 3px; transition: 0.25s; }
.switch-row input:checked + .switch { background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.switch-row input:checked + .switch::after { left: 20px; }
.field.switch-row > span { width: auto; min-width: 0; }
.field .sw-label { width: 128px; min-width: 128px; font-size: 12.5px; color: #b8c1d9; flex-shrink: 0; }

.env-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 18px; }
@media (max-width: 620px) { .env-grid { grid-template-columns: 1fr; } }
.env-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 0; }
.env-item .sw-label { flex: 1; }
.env-item input[type=text] { width: 74px; background: rgba(10,13,22,0.55); border: 1px solid var(--border); color: var(--text); border-radius: 8px; padding: 5px 9px; font-size: 12px; font-family: var(--mono); }

.cmd-preview { margin-top: 14px; padding: 18px 20px; position: relative; }
.cmd-preview pre { font-family: var(--mono); font-size: 12px; color: #9fe8d8; white-space: pre-wrap; word-break: break-all; background: rgba(0,0,0,0.35); padding: 14px; border-radius: 11px; border: 1px solid var(--border); max-height: 200px; overflow-y: auto; line-height: 1.7; }
.cmd-preview .btn { position: absolute; top: 14px; right: 16px; }

/* ============ 日志页 ============ */
.log-toolbar { display: flex; align-items: center; gap: 18px; padding: 11px 18px; margin-bottom: 12px; flex-wrap: wrap; }
.grow { flex: 1; }
.log-shell { height: calc(100vh - 216px); min-height: 340px; overflow: hidden; padding: 0; }
#logView { font-family: var(--mono); font-size: 12.3px; line-height: 1.75; height: 100%; overflow-y: auto; padding: 16px 20px; color: #b7c3dd; }
#logView.wrap { white-space: pre-wrap; word-break: break-all; }
#logView:not(.wrap) { white-space: pre; }
#logView .ln-err { color: #ff8b9d; }
#logView .ln-warn { color: #fcd34d; }
#logView .ln-ok { color: #6ee7b7; }
#logView .ln-info { color: #93c5fd; }
#logView .ln-tok { color: #7dd3fc; }

/* ============ 系统页 ============ */
.sys-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 14px; }
.sys-card { padding: 20px 22px; }
.sys-card .big { font-size: 16px; font-weight: 650; margin: 6px 0 2px; word-break: break-all; }
.sys-card .row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 12.8px; border-bottom: 1px dashed rgba(255,255,255,0.05); }
.sys-card .row:last-child { border-bottom: none; }
.sys-card .row span { color: var(--dim); }

/* ============ 聊天页（DeepSeek 风格：左侧工作区/会话 + 右侧对话） ============ */
.chat-shell { display: flex; height: calc(100vh - 212px); min-height: 480px; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: var(--panel); position: relative; }
.chat-shell.side-hidden .chat-side { display: none; }
.chat-side { width: 250px; flex-shrink: 0; display: flex; flex-direction: column; background: rgba(10,13,22,0.45); border-right: 1px solid var(--border); min-height: 0; }
.side-brand { display: flex; align-items: center; gap: 9px; padding: 14px 14px 10px; font-size: 15px; }
.side-logo { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, #7c6cff, #5b8cff); display: grid; place-items: center; font-size: 16px; flex-shrink: 0; }
.side-brand b { letter-spacing: 0.5px; }
.side-brand .side-icon { margin-left: auto; }
.side-icon { width: 26px; height: 26px; border: none; background: transparent; color: var(--dim); border-radius: 7px; cursor: pointer; font-size: 14px; line-height: 1; display: grid; place-items: center; transition: background 0.15s, color 0.15s; flex-shrink: 0; }
.side-icon:hover { background: rgba(124,108,255,0.16); color: var(--text); }
.new-chat-btn { margin: 4px 12px 10px; padding: 10px 12px; border: 1px solid var(--border-hi); border-radius: 10px; background: rgba(124,108,255,0.12); color: var(--text); font-size: 13.5px; cursor: pointer; text-align: left; transition: background 0.15s, border-color 0.15s; font-family: var(--font); }
.new-chat-btn:hover { background: rgba(124,108,255,0.22); border-color: var(--accent); }
.ws-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px 4px; font-size: 12px; color: var(--dim); }
.ws-tools { display: flex; gap: 2px; }
.ws-search { margin: 4px 12px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; background: rgba(10,13,22,0.5); color: var(--text); font-size: 12.5px; outline: none; font-family: var(--font); }
.ws-search:focus { border-color: var(--border-hi); }
.ws-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; min-height: 0; }
.ws-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 9px; cursor: pointer; font-size: 13px; color: var(--text); margin-top: 4px; }
.ws-item:hover { background: rgba(124,108,255,0.10); }
.ws-item.active { background: rgba(124,108,255,0.16); }
.ws-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-count { font-size: 11px; color: var(--dim); }
.convo-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px 7px 30px; border-radius: 9px; cursor: pointer; font-size: 12.8px; color: var(--dim); }
.convo-item:hover { background: rgba(124,108,255,0.10); color: var(--text); }
.convo-item.active { background: rgba(124,108,255,0.16); color: var(--text); }
.convo-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo-time { font-size: 10.5px; opacity: 0.7; flex-shrink: 0; }
.convo-del { visibility: hidden; border: none; background: transparent; color: var(--dim); cursor: pointer; font-size: 11px; flex-shrink: 0; }
.convo-item:hover .convo-del { visibility: visible; }
.convo-del:hover { color: #ff8a9b; }
.ws-none { padding: 14px 12px; font-size: 12px; color: var(--dim); text-align: center; }
.side-expand { position: absolute; top: 12px; left: 10px; z-index: 5; width: 30px; height: 30px; border: 1px solid var(--border-hi); border-radius: 8px; background: var(--panel); color: var(--dim); cursor: pointer; }
.side-expand:hover { color: var(--text); }
.chat-main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }

.chat-msgs { flex: 1; overflow-y: auto; padding: 28px 32px 12px; display: flex; flex-direction: column; gap: 16px; }
.chat-empty { margin: auto; text-align: center; color: var(--dim); max-width: 560px; padding-bottom: 6vh; }
.hero-ic { font-size: 46px; margin-bottom: 12px; }
.hero-title { font-size: 23px; color: var(--text); margin: 0 0 14px; font-weight: 700; }
.hero-steps { display: flex; gap: 10px; justify-content: center; margin-bottom: 14px; flex-wrap: wrap; }
.step-card { background: rgba(124,108,255,0.06); border: 1px solid var(--border); border-radius: 12px; padding: 10px 14px; min-width: 150px; }
.step-card b { display: block; font-size: 13px; color: var(--text); margin-bottom: 3px; }
.step-card span { font-size: 11.5px; color: var(--dim); }
.hero-pills { display: flex; gap: 10px; justify-content: center; margin-bottom: 16px; }
.hero-pills .pill { font-size: 12px; color: var(--dim); border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px; background: rgba(124,108,255,0.07); }
.hero-sub { font-size: 13px; line-height: 1.85; }

.msg { display: flex; gap: 12px; max-width: 92%; }
/* 对话全文可选中复制（显式声明，防止任何全局 user-select 干扰） */
.msg .bubble, .msg .bubble * { user-select: text; -webkit-user-select: text; cursor: text; }
.msg .msg-imgs, .msg .msg-imgs * { user-select: none; -webkit-user-select: none; }
.msg.user { align-self: flex-end; flex-direction: row-reverse; }
.msg .ava { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; flex-shrink: 0; }
.msg.user .ava { background: linear-gradient(135deg, #2dd4bf, #34d399); }
.msg.bot .ava { background: linear-gradient(135deg, #7c6cff, #5b8cff); }
.msg .bubble { padding: 12px 16px; border-radius: 14px; line-height: 1.7; font-size: 14px; word-break: break-word; }
.msg.user .bubble { background: linear-gradient(135deg, rgba(45,212,191,0.18), rgba(52,211,153,0.14)); border: 1px solid rgba(45,212,191,0.25); border-bottom-right-radius: 4px; }
.msg.bot .bubble { background: var(--panel-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg .bubble pre { position: relative; background: rgba(0,0,0,0.35); padding: 10px 12px; border-radius: 8px; margin: 8px 0; font-family: var(--mono); font-size: 12.5px; overflow-x: auto; }
/* 代码块右上角 / 消息右上角的复制按钮 */
.copy-btn {
  border: 1px solid var(--border); background: rgba(20,24,34,0.85); color: var(--dim);
  font-size: 11px; padding: 3px 9px; border-radius: 7px; cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s; white-space: nowrap;
}
.copy-btn:hover { color: var(--text); border-color: var(--accent); background: rgba(124,108,255,0.18); }
.copy-btn.copied { color: #34d399; border-color: rgba(52,211,153,0.5); }
.pre-copy { position: absolute; top: 6px; right: 6px; opacity: 0; }
.msg .bubble pre:hover .pre-copy, .pre-copy:focus { opacity: 1; }
.msg.bot { position: relative; }
.msg-actions { position: absolute; top: -9px; right: 10px; z-index: 3; opacity: 0; transform: translateY(2px); transition: opacity 0.15s, transform 0.15s; }
.msg.bot:hover .msg-actions, .msg-actions:focus-within { opacity: 1; transform: translateY(0); }
.msg .bubble code { background: rgba(0,0,0,0.3); padding: 1px 5px; border-radius: 5px; font-family: var(--mono); font-size: 12.5px; }
.msg .bubble p { margin: 0 0 8px; }
.msg .bubble p:last-child { margin-bottom: 0; }
/* Markdown 标题 / 列表 / 引用 */
.msg .bubble h1, .msg .bubble h2, .msg .bubble h3,
.msg .bubble h4, .msg .bubble h5, .msg .bubble h6 { margin: 10px 0 6px; line-height: 1.4; }
.msg .bubble h1 { font-size: 18px; } .msg .bubble h2 { font-size: 16.5px; } .msg .bubble h3 { font-size: 15px; }
.msg .bubble h4, .msg .bubble h5, .msg .bubble h6 { font-size: 14px; }
.msg .bubble h1:first-child, .msg .bubble h2:first-child, .msg .bubble h3:first-child { margin-top: 0; }
.msg .bubble ul, .msg .bubble ol { margin: 6px 0; padding-left: 22px; }
.msg .bubble li { margin: 3px 0; }
.msg .bubble blockquote { margin: 6px 0; padding: 6px 12px; border-left: 3px solid var(--accent); background: rgba(124,108,255,0.10); border-radius: 0 8px 8px 0; color: var(--dim); }
.msg .bubble a { color: #8ab4ff; }
/* 消息内图片 */
.msg-imgs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.msg-imgs img { max-width: 220px; max-height: 160px; border-radius: 10px; border: 1px solid var(--border); cursor: zoom-in; display: block; }
/* 输入区待发送图片条 */
.chat-imgs-strip { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 28px 0; }
.chat-imgs-strip[hidden] { display: none; }
.chat-img-thumb { position: relative; width: 64px; height: 64px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border-hi); }
.chat-img-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.chat-img-thumb button {
  position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%;
  border: none; background: rgba(0,0,0,0.65); color: #fff; font-size: 10px; line-height: 1;
  cursor: pointer; display: grid; place-items: center; padding: 0;
}
.chat-img-thumb button:hover { background: rgba(255,93,115,0.85); }
.cursor-blink::after { content: "▋"; color: var(--accent-2); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ===== 底部输入卡（composer） ===== */
.composer { padding: 0 28px 14px; }
.composer-box { border: 1px solid var(--border-hi); border-radius: 16px; background: rgba(10,13,22,0.6); transition: border-color 0.15s, box-shadow 0.15s; }
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(124,108,255,0.12); }
.composer-box textarea { display: block; width: 100%; resize: none; background: transparent; border: none; color: var(--text); padding: 14px 16px 6px; font-size: 14px; font-family: var(--font); outline: none; max-height: 160px; line-height: 1.55; }
.composer-bar { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px 10px; gap: 10px; }
.cb-left { display: flex; align-items: center; gap: 6px; min-width: 0; }
.cb-sep { width: 1px; height: 16px; background: var(--border-hi); margin: 0 2px; flex-shrink: 0; }
.icon-btn { width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 9px; background: transparent; color: var(--dim); font-size: 14px; cursor: pointer; line-height: 1; transition: color 0.15s, border-color 0.15s, background 0.15s; flex-shrink: 0; display: grid; place-items: center; }
.icon-btn:hover { color: var(--text); border-color: var(--accent); background: rgba(124,108,255,0.10); }
.icon-btn.danger:hover:not(:disabled) { color: #ff8a9b; border-color: rgba(255,93,115,0.55); background: rgba(255,93,115,0.10); }
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.cb-ws { font-size: 12px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-left: 2px; }
.cb-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
/* 模型选择：带边框的可见框 */
.model-box { display: flex; align-items: center; gap: 4px; border: 1px solid var(--border-hi); border-radius: 10px; padding: 4px 8px 4px 10px; background: rgba(10,13,22,0.55); max-width: 320px; transition: border-color 0.15s, background 0.15s; }
.model-box:hover, .model-box:focus-within { border-color: var(--accent); background: rgba(10,13,22,0.75); }
.model-chip { appearance: none; -webkit-appearance: none; border: none; background: transparent; color: var(--text); font-size: 12px; font-family: var(--font); cursor: pointer; max-width: 270px; outline: none; text-overflow: ellipsis; }
.model-chip option { background: var(--panel); color: var(--text); font-size: 13px; }
.mb-arrow { color: var(--dim); font-size: 10px; pointer-events: none; transform: translateY(-1px); }
.send-round { width: 36px; height: 36px; border-radius: 50%; border: none; background: linear-gradient(135deg, #2dd4bf, #34d399); color: #06281f; font-size: 17px; font-weight: 700; cursor: pointer; display: grid; place-items: center; transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s; box-shadow: 0 4px 14px rgba(45,212,191,0.35); flex-shrink: 0; }
.send-round:hover { transform: scale(1.07); box-shadow: 0 6px 18px rgba(45,212,191,0.5); }
.send-round:active { transform: scale(0.95); }
.send-round:disabled { opacity: 0.45; cursor: not-allowed; }
.composer-hint { text-align: center; font-size: 11px; color: var(--dim); opacity: 0.75; margin-top: 8px; }

.chat-settings { position: absolute; bottom: 110px; right: 28px; width: 340px; max-width: calc(100% - 32px); background: var(--panel); border: 1px solid var(--border-hi); border-radius: 14px; padding: 18px; box-shadow: 0 16px 50px rgba(0,0,0,0.5); z-index: 20; backdrop-filter: blur(16px); }
.chat-settings .cs-row { margin-bottom: 14px; }
.chat-settings label { font-size: 12.5px; color: #b8c1d9; display: block; margin-bottom: 6px; }
.chat-settings label b { color: var(--accent-2); }
.chat-settings textarea, .chat-settings input[type=number] { width: 100%; background: rgba(10,13,22,0.6); border: 1px solid var(--border); color: var(--text); border-radius: 9px; padding: 8px 10px; font-size: 13px; font-family: var(--font); outline: none; }
.chat-settings .cs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.chat-settings .cs-item label { margin-bottom: 6px; }
.chat-settings input[type=range] { width: 100%; accent-color: var(--accent); }
.cs-stream { margin-top: 4px; }

/* ============ 设置页 ============ */
.settings-card { padding: 22px 24px; margin-bottom: 0; max-width: none; }
.settings-card .set-row { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.settings-card input[type=text] { flex: 1; min-width: 220px; background: rgba(10,13,22,0.6); border: 1px solid var(--border); color: var(--text); border-radius: 10px; padding: 9px 12px; font-size: 13px; outline: none; font-family: var(--mono); }
.settings-card input[type=text]:focus { border-color: var(--border-hi); }
.set-status { margin-top: 10px; font-size: 13px; min-height: 18px; }
.set-status.ok { color: var(--green); }
.set-status.err { color: var(--red); }
.settings-card .row { display: flex; justify-content: space-between; padding: 7px 0; font-size: 13px; border-bottom: 1px dashed rgba(255,255,255,0.05); }
.settings-card .row:last-child { border-bottom: none; }
.settings-card .row span { color: var(--dim); }

/* ============ 弹窗 & 提示 ============ */
.modal-mask { position: fixed; inset: 0; background: rgba(5,8,15,0.6); z-index: 50; display: grid; place-items: center; backdrop-filter: blur(4px); }
.modal { width: min(430px, 92vw); padding: 24px; }
.modal .field { margin-top: 14px; }
.modal .field > span { width: 82px; min-width: 82px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.small { font-size: 12px; margin-top: 10px; }
code { font-family: var(--mono); background: rgba(255,255,255,0.06); padding: 1px 5px; border-radius: 5px; font-size: 0.92em; }

.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(80px); background: rgba(20,25,40,0.95); border: 1px solid var(--border-hi); padding: 11px 22px; border-radius: 12px; font-size: 13.5px; z-index: 99; transition: transform 0.3s ease, opacity 0.3s; opacity: 0; pointer-events: none; box-shadow: 0 10px 40px rgba(0,0,0,0.5); max-width: 80vw; }
.toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.toast.err { border-color: rgba(255,93,115,0.6); color: #ffc4cc; }
.toast.ok { border-color: rgba(52,211,153,0.6); color: #b7f5dd; }

/* ============ 主页内嵌实时日志 ============ */
.home-log { padding: 16px 20px; margin-top: 16px; }
.home-log-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; flex-wrap: wrap; gap: 8px; }
.home-log-head h3 { margin-bottom: 0; font-size: 14px; }
#homeLogView { font-family: var(--mono); font-size: 12px; line-height: 1.62; max-height: 220px; overflow-y: auto; padding: 14px 16px; border-radius: 12px; background: rgba(0,0,0,0.34); border: 1px solid var(--border); color: #b7c3dd; white-space: pre-wrap; word-break: break-all; }
#homeLogView.wrap { white-space: pre-wrap; word-break: break-all; }

/* ============ 底部控制条已移除（控制移到顶部） ============ */
@media (max-width: 1180px) {
  .tb-main { display: flex; flex-wrap: wrap; gap: 10px; }
  .ctrl-inline { position: static; transform: none; order: 3; width: 100%; justify-content: flex-start; }
}
@media (max-width: 1080px) {
  .tb-row { flex-wrap: wrap; gap: 10px; }
  .tb-sub { flex-wrap: wrap; padding-bottom: 8px; }
  .mini-mon { margin-left: 0; width: 100%; }
  .chat-shell { height: calc(100vh - 268px); }
  .log-shell { height: calc(100vh - 272px); }
}
@media (max-width: 700px) {
  .brand h1 { display: none; }
  .ctrl-model select { min-width: 140px; }
  .ctrl-status { font-size: 11.5px; max-width: 150px; }
  .tab { padding: 10px 10px 9px; font-size: 12.5px; }
}

/* 滚动条 */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(124,108,255,0.28); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(124,108,255,0.5); }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 模型接入页 ============ */
.access-hero {
  display: flex; gap: 26px; align-items: flex-start; justify-content: space-between;
  padding: 24px 26px; margin-bottom: 16px;
  background: linear-gradient(135deg, rgba(124,108,255,0.14), rgba(45,212,191,0.08) 60%, transparent);
  border-color: rgba(124,108,255,0.3);
}
.access-hero .ah-left { flex: 1; min-width: 0; }
.access-hero h3 { font-size: 17px; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; }
.access-hero .ah-right { text-align: right; min-width: 190px; }
.access-hero .small { margin-bottom: 14px; }
.copy-url { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.copy-url code {
  font-family: var(--mono); font-size: 15px; font-weight: 600; color: var(--accent-2);
  background: rgba(10,13,22,0.75); border: 1px solid rgba(45,212,191,0.3);
  padding: 9px 16px; border-radius: 10px; letter-spacing: 0.3px;
}
.ah-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.st-chip {
  font-size: 11.5px; color: var(--dim); background: rgba(255,255,255,0.045);
  border: 1px solid var(--border); padding: 4px 11px; border-radius: 999px;
}
.st-chip b { color: var(--text); font-weight: 600; }
.switch-row.big { justify-content: flex-end; }
.switch-row.big b { margin-left: 10px; font-size: 14px; }
.gw-state { margin-top: 12px; display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }
.gw-state b { font-size: 13px; }
.gw-state span { font-size: 11.5px; color: var(--dim); }
.gw-state.on b { color: var(--green); }
.gw-state.off b { color: var(--amber); }

.access-card { padding: 22px 24px; margin-bottom: 16px; }
.access-card h3 { font-size: 15.5px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.access-card > .dim { margin-bottom: 14px; }
.ac-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.ac-head h3 { margin-bottom: 0; }

.smart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(272px, 1fr)); gap: 16px; margin-bottom: 18px; }
.smart-item {
  background: rgba(255,255,255,0.028); border: 1px solid var(--border);
  border-radius: 13px; padding: 15px 17px;
}
.smart-item .switch-row { margin-bottom: 8px; }
.smart-item .sw-label { font-size: 13.5px; font-weight: 600; color: var(--text); }
.smart-item .hint { font-size: 11.5px; color: var(--dim); line-height: 1.65; }
.field.slim { margin: 0; }
.field.slim > span { width: auto; min-width: 0; font-size: 12.5px; display: block; margin-bottom: 7px; }
.field.slim input { width: 100%; background: rgba(10,13,22,0.6); border: 1px solid var(--border); color: var(--text); border-radius: 9px; padding: 8px 11px; font-size: 13px; outline: none; font-family: var(--mono); }
.field.slim input:focus { border-color: var(--border-hi); }
.field.grow { flex: 1; margin: 0; }
.field.grow > span { width: auto; min-width: 0; display: block; margin-bottom: 7px; }

/* 供应商列表 */
.pv-list { display: flex; flex-direction: column; gap: 12px; }
.pv-item {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--border);
  border-radius: 13px; padding: 15px 18px; transition: border-color .18s;
}
.pv-item:hover { border-color: var(--border-hi); }
.pv-item.off { opacity: 0.52; }
.pv-main { min-width: 0; flex: 1; }
.pv-title { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; flex-wrap: wrap; }
.pv-title b { font-size: 14px; }
.pv-url { font-family: var(--mono); font-size: 12px; color: var(--accent-2); margin-bottom: 4px; word-break: break-all; }
.pv-meta { font-size: 11.5px; color: var(--dim); }
.pv-ops { display: flex; gap: 7px; flex-shrink: 0; }
.pv-empty {
  padding: 30px; text-align: center; color: var(--dim); font-size: 13px; line-height: 1.8;
  border: 1px dashed var(--border); border-radius: 13px; background: rgba(255,255,255,0.018);
}
.tag.on { background: rgba(52,211,153,0.15); color: #6ee7b7; }
.tag.off, .tag.warn { background: rgba(148,163,184,0.15); color: #cbd5e1; }
.tag.key { background: rgba(124,108,255,0.16); color: #c4b5fd; }
.tag.ext { background: rgba(251,191,36,0.15); color: #fcd34d; }

/* 供应商弹窗 */
.modal.wide { width: min(620px, 94vw); max-height: 90vh; overflow-y: auto; }
.pv-form { margin-top: 6px; }
.pv-form .field { flex-direction: column; align-items: stretch; gap: 6px; }
.pv-form .field > span { width: auto; min-width: 0; }
.pv-form input, .pv-form select, .pv-form textarea {
  width: 100%; background: rgba(10,13,22,0.65); border: 1px solid var(--border);
  color: var(--text); border-radius: 9px; padding: 9px 11px; font-size: 13px;
  font-family: var(--mono); outline: none;
}
.pv-form textarea { font-family: var(--mono); font-size: 12px; resize: vertical; }
.pv-form input:focus, .pv-form select:focus, .pv-form textarea:focus { border-color: var(--border-hi); }
.pv-form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.pv-test { margin-top: 12px; font-size: 12.5px; padding: 10px 13px; border-radius: 9px; background: rgba(255,255,255,0.04); color: var(--dim); min-height: 20px; }
.pv-test.ok { background: rgba(52,211,153,0.11); color: #6ee7b7; }
.pv-test.err { background: rgba(255,93,115,0.11); color: #fda4af; }

/* 关于页行 */
.settings-card .row b { color: var(--text); font-family: var(--mono); font-size: 12px; }


/* ================= 免费 API 厂家库 ================= */
.modal.wide2 { width: 1040px; max-width: calc(100vw - 48px); }

.lm-list { display: grid; gap: 10px; margin-top: 14px; max-height: 42vh; overflow-y: auto; }
.lm-item { border: 1px solid var(--border); border-radius: 9px; padding: 11px 13px; cursor: pointer; background: rgba(10,13,22,0.35); }
.lm-item:hover { border-color: var(--border-hi); }
.lm-item.active { border-color: var(--accent); box-shadow: 0 0 0 1px rgba(124,108,255,0.35) inset, 0 4px 16px rgba(91,140,255,0.16); }
.lm-item .lm-title { font-weight: 600; font-size: 13px; color: var(--text); margin-bottom: 4px; word-break: break-all; }
.lm-item .lm-meta { font-size: 12px; color: var(--dim); word-break: break-all; }
.lm-item .lm-warn { font-size: 11.5px; color: #ffbe7a; margin-top: 5px; }
.lm-form { margin-top: 16px; border-top: 1px dashed var(--border); padding-top: 14px; }
.lm-form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.lm-form-grid .field { flex-direction: column; align-items: stretch; gap: 6px; margin: 0; }
.lm-form-grid .field > span { width: auto; min-width: 0; }
.lm-detail { margin-top: 12px; font-size: 12px; color: var(--dim); background: rgba(10,13,22,0.5); border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; white-space: pre-wrap; word-break: break-all; max-height: 160px; overflow-y: auto; }
@media (max-width: 760px) { .lm-form-grid { grid-template-columns: 1fr; } }
.free-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.free-head input[type=text] { width: 220px; }
.free-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
  gap: 12px; max-height: 58vh; overflow-y: auto; padding: 4px 6px 4px 0; margin: 10px 0;
}
.free-card {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 14px;
  padding: 14px 15px; display: flex; flex-direction: column; gap: 7px;
  transition: border-color .18s, transform .18s;
}
.free-card:hover { border-color: rgba(124,108,255,0.4); transform: translateY(-2px); }
.free-card.installed { border-color: rgba(52,211,153,0.45); }
.fc-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.fc-emoji { font-size: 20px; }
.fc-top b { font-size: 14.5px; }
.fc-desc { font-size: 12.5px; color: #c3cade; line-height: 1.6; }
.fc-quota { font-size: 12px; color: var(--accent-2); }
.fc-models { font-size: 11.5px; color: var(--dim); font-family: var(--mono); line-height: 1.5;
  word-break: break-all; }
.fc-ops { display: flex; gap: 8px; margin-top: 2px; }
.fc-form {
  display: flex; flex-direction: column; gap: 8px; margin-top: 6px; padding-top: 10px;
  border-top: 1px dashed var(--border);
}
.fc-form input[type=text] { width: 100%; padding: 8px 10px; border-radius: 9px;
  background: rgba(10,13,22,0.6); border: 1px solid var(--border); color: var(--text); }
.fc-form .btn { align-self: flex-start; }
.tag.go { background: rgba(45,212,191,0.16); color: var(--accent-2); border-color: rgba(45,212,191,0.4); }

/* ================= 智能路由设置 ================= */
.settings-card h4.sec {
  font-size: 13.5px; margin: 18px 0 8px; padding-left: 10px;
  border-left: 3px solid rgba(124,108,255,0.5);
}
.route-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.route-grid .field > span { font-size: 12.5px; }
.set-row.wrap-row { flex-wrap: wrap; gap: 8px 22px; }
.chain-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.chain-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 11px;
}
.cr-idx {
  width: 22px; height: 22px; border-radius: 50%; background: rgba(124,108,255,0.2);
  color: var(--accent-2); font-size: 12px; display: flex; align-items: center; justify-content: center;
}
.cr-label { font-size: 13px; }
.rule-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.rule-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 12px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 11px;
}
.rule-row input[type=text] { flex: 1 1 220px; min-width: 160px; padding: 7px 10px; border-radius: 9px;
  background: rgba(10,13,22,0.6); border: 1px solid var(--border); color: var(--text); }
.rule-row select { flex: 1 1 240px; min-width: 160px; padding: 7px 10px; border-radius: 9px;
  background: rgba(10,13,22,0.6); border: 1px solid var(--border); color: var(--text); }
.rt-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 10px; }
.rt-stat {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 12px;
  padding: 11px 13px; display: flex; flex-direction: column; gap: 5px;
}
.rs-name { font-size: 13px; }
.rs-nums { font-size: 12px; color: var(--dim); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.rs-nums b { color: var(--text); }
.rs-err { font-size: 11.5px; word-break: break-all; }
.rs-ops { display: flex; gap: 8px; margin-top: 2px; }

/* ================= 设置页（并排 · 填满 · 简洁易懂） ================= */
.set-intro {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  padding: 16px 20px; color: var(--dim); font-size: 13px; margin-bottom: 16px;
  background: linear-gradient(120deg, rgba(124,108,255,0.10), rgba(45,212,191,0.05)), var(--panel);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.set-intro b { font-size: 17px; color: var(--text); }
.set-intro span { line-height: 1.6; }

/* 设置分区锚点条：7 张卡片纵排很长，吸顶一排直达；窄屏可横向滑动 */
.set-nav {
  position: sticky; top: 0; z-index: 20;
  display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto;
  padding: 8px; margin-bottom: 14px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: var(--radius);
  scrollbar-width: none;
}
.set-nav::-webkit-scrollbar { display: none; }
.set-nav a {
  flex: none; text-decoration: none; white-space: nowrap;
  font-size: 12.5px; color: var(--dim); padding: 6px 11px; border-radius: 999px;
  border: 1px solid transparent; transition: 0.15s;
}
.set-nav a:hover { color: var(--text); background: var(--panel-2); border-color: var(--border); }
/* 目标卡片轻描一下，让人知道跳到哪儿了 */
.settings-card:target { border-color: rgba(124,108,255,0.55); box-shadow: 0 0 0 3px rgba(124,108,255,0.12); }

/* 设置卡片：两列并排，填满整页宽度 */
.settings-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start;
}
.settings-card.span-all { grid-column: 1 / -1; }
@media (max-width: 920px) { .settings-grid { grid-template-columns: 1fr; } }
.settings-card.wide { max-width: none; }
.settings-card .set-grid2 {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px 26px; margin-top: 4px;
}
.set-cell .hint { margin-top: 7px; }
.settings-card .hint { font-size: 11.5px; color: var(--dim); line-height: 1.65; }
.settings-card h3 { display: flex; align-items: center; gap: 8px; font-size: 15px; }

/* 排除模型 */
.excl-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.excl-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--panel-2); border: 1px dashed rgba(251, 191, 36, 0.35); border-radius: 11px;
}
.excl-row .cr-label { font-size: 13px; }
#rtCard.on { border-color: rgba(124, 108, 255, 0.4); }
#rtEnabledTxt { font-size: 13px; color: var(--dim); }
#rtEnabled:checked ~ b { color: var(--accent-2); }
#rtDetail { margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--border); }

/* ===== 内嵌模式：作为浮层嵌在 Strata codex 页面里 ===== */
/* 隐藏顶栏/标签页，让单个子页面（监控/参数/接入/设置/日志）铺满浮层。 */
body.embed { overflow: hidden; }
body.embed .topbar { display: none !important; }
body.embed .bg-glow { display: none !important; }
body.embed main { padding: 0 !important; margin: 0 !important; max-width: none !important; }
body.embed .view {
  position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden;
  padding: 14px 16px 34px; animation: none;
  scrollbar-width: thin; scrollbar-color: var(--border2, rgba(140,150,175,.5)) transparent;
}
body.embed .view:not(.active) { display: none; }
/* 浮层只有半个屏幕高，必须让人一眼看出「下面还有」——给个常显的滚动条 */
body.embed .view::-webkit-scrollbar { width: 10px; }
body.embed .view::-webkit-scrollbar-track { background: transparent; }
body.embed .view::-webkit-scrollbar-thumb {
  background: rgba(140,150,175,.45); border-radius: 5px;
  border: 2px solid transparent; background-clip: content-box;
}
body.embed .view::-webkit-scrollbar-thumb:hover { background: rgba(140,150,175,.7); background-clip: content-box; }
/* 嵌入 dsh 设置面板时的页首标题条（默认隐藏，仅 embed 模式显示） */
.embed-title { display: none; }
body.embed .embed-title {
  display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap;
  margin: 0 0 14px; padding: 11px 14px; border: 1px solid var(--border);
  border-radius: 12px; background: var(--panel);
}
body.embed .embed-title b { font-size: 15px; font-weight: 700; }
body.embed .embed-title span { font-size: 12px; color: var(--dim); }
/* 嵌入时卡片更紧凑一点，一屏能看到更多内容 */
body.embed .card { border-radius: 11px; }
body.embed .set-nav { top: 0; }
