/* ===== 四当图衍 · 基础样式（浅色主题 · 清华紫） ===== */
:root {
  --bg: #f6f5f8;
  --surface: #ffffff;
  --surface-2: #f8f9fd;
  --ink: #171a2b;
  --muted: #6b7186;
  --line: #e6e8f0;
  --brand: #660874;          /* 清华紫 PANTONE 259C / RGB(102,8,116) */
  --brand-2: #8e1794;
  --brand-soft: #f8f1f9;
  --accent: #0ea5e9;
  --ok: #059669;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(23, 26, 43, .05), 0 10px 30px rgba(23, 26, 43, .07);
  --shadow-sm: 0 1px 3px rgba(23, 26, 43, .08);
  --font: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-size: 14px;
  transition: all .15s ease;
  box-shadow: var(--shadow-sm);
}
.btn:hover { border-color: #c9cdea; background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; border: none; font-weight: 600;
  padding: 10px 20px; border-radius: var(--radius-sm);
  box-shadow: 0 4px 14px rgba(79, 70, 229, .30);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost { border: none; background: transparent; box-shadow: none; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); background: var(--brand-soft); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: #fef2f2; border-color: #fecaca; }
.btn-sm { padding: 4px 10px; font-size: 13px; border-radius: 8px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; font-weight: 600; }
.input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  background: var(--surface);
  color: var(--ink);
  transition: border .15s, box-shadow .15s;
  outline: none;
}
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, .14); }

/* ---------- 大模型服务商选型列表（可查看 / 点击选中 / 即时应用） ---------- */
.preset-list { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; max-height:290px; overflow:auto; padding-right:2px; }
.preset-item {
  display:flex; align-items:flex-start; gap:9px; width:100%; text-align:left;
  border:1px solid var(--line); border-radius:11px; background:var(--surface);
  padding:9px 10px; color:var(--ink); box-shadow:var(--shadow-sm);
  transition:border-color .15s, background .15s, box-shadow .15s, transform .12s;
}
.preset-item:hover { border-color:var(--brand); background:var(--brand-soft); transform:translateY(-1px); }
.preset-item:focus-visible { outline:2px solid var(--brand); outline-offset:2px; }
.preset-item[aria-pressed="true"] {
  border-color:var(--brand); background:linear-gradient(135deg,var(--brand-soft),#fff);
  box-shadow:0 0 0 2px rgba(102,8,116,.16), var(--shadow-sm);
}
.preset-badge {
  flex:none; width:28px; height:28px; border-radius:8px; display:grid; place-items:center;
  font-size:11px; font-weight:700; color:#fff; letter-spacing:.3px;
  background:linear-gradient(135deg,var(--brand),var(--brand-2));
}
.preset-item[aria-pressed="true"] .preset-badge { background:linear-gradient(135deg,#0ea5e9,#2563eb); }
.preset-text { flex:1; min-width:0; display:flex; flex-direction:column; gap:1px; }
.preset-name { font-size:13.5px; font-weight:600; line-height:1.3; }
.preset-sub { font-size:11px; color:var(--muted); line-height:1.35; }
.preset-model { font-size:10.5px; color:var(--muted); line-height:1.5; word-break:break-all; }
.preset-model code { font-family:ui-monospace,Menlo,Consolas,monospace; color:var(--brand-2); background:var(--brand-soft); padding:0 3px; border-radius:4px; }
.preset-check {
  flex:none; width:18px; height:18px; border-radius:50%; border:1.5px solid var(--line);
  color:transparent; display:grid; place-items:center; font-size:11px; font-weight:700; transition:all .15s;
}
.preset-item[aria-pressed="true"] .preset-check { background:var(--brand); border-color:var(--brand); color:#fff; }
@media (max-width:640px){ .preset-list { grid-template-columns:1fr; } }
.model-loading { grid-column:1/-1; padding:18px 10px; text-align:center; font-size:13px; color:var(--muted); }
.model-hint { margin-top:8px; padding:8px 10px; border-radius:8px; font-size:12.5px; line-height:1.55; }
.model-hint.warn { background:#fff7e6; color:#92400e; border:1px solid #fed7aa; }
.model-hint.info { background:var(--surface-2); color:var(--muted); border:1px solid var(--line); }

.model-row { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin-bottom:8px; }
.model-row-label { font-size:12.5px; font-weight:600; color:var(--muted); }
.model-row-hint { font-size:11.5px; color:var(--muted); }
.mp-slot { position:relative; min-width:210px; }
.lab-model-slot { margin-top:10px; }
.mp-wrap { position:relative; display:inline-block; }
.mp-trigger {
  display:inline-flex; align-items:center; gap:8px; min-width:250px;
  padding:7px 10px; border:1px solid var(--line); border-radius:10px;
  background:var(--surface); color:var(--ink); font-size:13px;
  box-shadow:var(--shadow-sm); transition:border-color .15s, background .15s;
}
.mp-trigger:hover { border-color:var(--brand); background:var(--brand-soft); }
.mp-icon {
  flex:none; width:22px; height:22px; border-radius:50%;
  display:inline-flex; align-items:center; justify-content:center;
  background:#111827; color:#fff; font-size:11px; font-weight:700; line-height:1;
}
.mp-trigger .mp-icon { width:18px; height:18px; font-size:10px; }
.mp-name { font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mp-rate { margin-left:auto; color:var(--muted); font-size:12px; white-space:nowrap; font-variant-numeric:tabular-nums; }
.mp-arrow { font-style:normal; color:var(--muted); transition:transform .15s; }
.mp-trigger[aria-expanded="true"] .mp-arrow { transform:rotate(180deg); }
.mp-panel {
  position:absolute; top:calc(100% + 6px); left:0; z-index:500;
  width:390px; max-height:420px; overflow:auto; padding:6px;
  background:var(--surface); border:1px solid var(--line); border-radius:14px;
  box-shadow:0 16px 40px rgba(23,26,43,.18);
}
.mp-head { display:flex; justify-content:space-between; align-items:center; gap:8px; padding:8px 10px 10px; margin-bottom:2px; border-bottom:1px solid var(--line); font-size:12px; color:var(--muted); }
.mp-head b { color:var(--ink); font-size:13.5px; }
.mp-list { display:flex; flex-direction:column; }
.mp-opt {
  display:flex; align-items:center; gap:8px; width:100%;
  padding:9px 10px; border:1px solid transparent; border-radius:9px;
  background:transparent; color:var(--ink); text-align:left;
  transition:background .15s, border-color .15s;
}
.mp-opt + .mp-opt { border-top:1px solid var(--line); border-top-left-radius:0; border-top-right-radius:0; }
.mp-opt:hover { background:var(--brand-soft); }
.mp-opt[aria-pressed="true"] { background:var(--surface-2); border-color:var(--line); }
.mp-opt-main { display:flex; align-items:center; gap:8px; min-width:0; flex:1; }
.mp-opt-name { font-size:14px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.mp-opt .mp-rate { margin-left:0; flex:none; }
.mp-opt-check { margin-left:2px; color:transparent; font-weight:700; font-size:13px; flex:none; }
.mp-opt[aria-pressed="true"] .mp-opt-check { color:#10b981; }
.mp-tag {
  flex:none; display:inline-flex; align-items:center; gap:3px;
  padding:2px 7px; border-radius:999px; font-size:10.5px; font-weight:600; line-height:1.5;
  background:#ecfdf5; color:#047857; border:1px solid #a7f3d0;
}
.mp-tag.night { background:#eff6ff; color:#1d4ed8; border-color:#bfdbfe; }
.mp-tag.sub { background:#fef3c7; color:#92400e; border-color:#fde68a; }
.mp-source { flex:none; color:var(--muted); font-size:10.5px; }
.mp-source.mp-vision { color:#047857; background:#ecfdf5; border:1px solid #a7f3d0; border-radius:6px; padding:0 4px; }
.mp-foot { font-size:11.5px; color:var(--muted); padding:8px 6px 4px; line-height:1.55; }
.mp-foot-warn { color:#92400e; background:#fff7e6; border-radius:8px; }
.mp-foot-info { background:var(--surface-2); border-radius:8px; }
.mp-config {
  display:flex; align-items:center; gap:8px; width:100%;
  padding:10px 10px 6px; margin-top:2px; border:0; border-top:1px solid var(--line);
  background:transparent; color:var(--ink); font-size:13px; font-weight:600; text-align:left; cursor:pointer;
}
.mp-config:hover { color:var(--brand); }
@media (max-width:640px){ .mp-trigger { min-width:220px; } .mp-panel { width:min(350px,90vw); } }

/* ---------- AI 模型配置中心 ---------- */
.modal.mc-modal { width:min(860px,94vw); max-height:88vh; overflow:auto; }
.mc-tabs { display:flex; gap:8px; border-bottom:1px solid var(--line); margin-bottom:12px; }
.mc-tab { padding:9px 12px; border:0; border-bottom:2px solid transparent; background:transparent; color:var(--muted); font-size:13.5px; cursor:pointer; }
.mc-tab.active { color:var(--brand); border-bottom-color:var(--brand); font-weight:700; }
.mc-tab-hint { font-size:11px; color:var(--muted); font-weight:400; }
.mc-note { padding:9px 11px; border-radius:9px; font-size:12.5px; line-height:1.6; margin-bottom:10px; }
.mc-note.ok { background:#ecfdf5; color:#065f46; border:1px solid #a7f3d0; }
.mc-note.info { background:var(--surface-2); color:var(--muted); border:1px solid var(--line); }
.mc-tool { display:flex; gap:8px; margin-bottom:10px; flex-wrap:wrap; }
.mc-list { display:flex; flex-direction:column; border:1px solid var(--line); border-radius:10px; overflow:hidden; }
.mc-row { display:flex; align-items:center; gap:8px; padding:9px 10px; background:var(--surface); font-size:13px; }
.mc-row + .mc-row { border-top:1px solid var(--line); }
.mc-row.off { opacity:.55; }
.mc-row-icon { width:22px; height:22px; flex:none; border-radius:50%; background:#111827; color:#fff; display:inline-flex; align-items:center; justify-content:center; font-size:11px; font-weight:700; }
.mc-row-name { font-weight:600; flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.mc-row-name em { font-style:normal; font-size:10.5px; color:#047857; background:#ecfdf5; border:1px solid #a7f3d0; border-radius:999px; padding:1px 6px; margin-left:4px; }
.mc-row-rate { color:var(--muted); font-variant-numeric:tabular-nums; flex:none; }
.mc-row-state { color:var(--muted); font-size:11.5px; }
.mc-tag { font-size:10.5px; padding:2px 7px; border-radius:999px; background:#ecfdf5; color:#047857; border:1px solid #a7f3d0; flex:none; }
.mc-empty { padding:22px; text-align:center; color:var(--muted); font-size:12.5px; border:1px dashed var(--line); border-radius:10px; }
.mc-form-slot { margin-top:12px; padding:12px; border:1px solid var(--line); border-radius:10px; background:var(--surface-2); }
.mc-form-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:9px; }
.mc-field { display:flex; flex-direction:column; gap:4px; font-size:12px; color:var(--muted); margin-bottom:8px; }
.mc-field .input { width:100%; }
.mc-check { display:inline-flex; align-items:center; gap:6px; font-size:12.5px; color:var(--muted); margin-bottom:8px; }
.mc-token { display:inline-flex; align-items:center; gap:6px; font-size:12px; color:var(--muted); }
.mc-token .input { width:190px; }
.mc-field-hint { font-size:12px; line-height:1.65; color:var(--muted); background:var(--surface-2); border:1px solid var(--line); border-radius:8px; padding:8px 10px; margin:0 0 10px; }
.mc-field-hint code { background:var(--brand-soft); color:var(--brand); padding:1px 4px; border-radius:4px; }
.mc-form-act { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.mc-form-msg { font-size:12px; color:var(--muted); }
.mc-msg-ok { color:#047857; }
.mc-msg-warn { color:#b45309; }
.mc-msg-info { color:var(--brand); }
@media (max-width:760px){ .mc-form-grid { grid-template-columns:1fr; } .mc-row { flex-wrap:wrap; } }
textarea.input { resize: vertical; min-height: 60px; }

/* ---------- 徽章 / 芯片 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
  background: var(--brand-soft); color: var(--brand);
}
.badge.ok { background: #ecfdf5; color: var(--ok); }
.badge.warn { background: #fffbeb; color: var(--warn); }
.badge.cy { background: #ecfeff; color: #0e7490; }
.badge.pk { background: #fdf2f8; color: #be185d; }
.badge.ggb { background: #f3e8ff; color: #6d28d9; }

.chip {
  display: inline-flex; align-items: center;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface);
  padding: 5px 12px; font-size: 13px; color: var(--ink);
  transition: all .15s;
}
.chip:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); }

/* ---------- Toast ---------- */
#toast-box {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: #1f2337; color: #fff;
  padding: 9px 18px; border-radius: 10px;
  font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
  animation: toastIn .25s ease;
  max-width: 80vw;
}
.toast-ok { background: #065f46; }
.toast-err { background: #991b1b; }
.toast-warn { background: #92400e; }
.toast.out { opacity: 0; transform: translateY(-8px); transition: all .3s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; } }

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 22, 40, .42);
  z-index: 900; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.modal {
  background: var(--surface); border-radius: 18px;
  width: min(480px, 92vw); max-height: 86vh; overflow: auto;
  box-shadow: 0 24px 60px rgba(23, 26, 43, .25);
  padding: 22px 24px;
  animation: toastIn .2s ease;
}
.modal h3 { font-size: 17px; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #d3d6e4; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }
