:root {
  --bg: #0f1216;
  --panel: #171c22;
  --panel2: #1e242c;
  --border: #2a323c;
  --text: #d7dde5;
  --muted: #8a93a0;
  --accent: #4da3ff;
  --green: #3ecf8e;
  --red: #ff6b6b;
  --yellow: #f5c451;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 20px; margin: 0; }
.muted { color: var(--muted); font-size: 12px; }
.err { color: var(--red); font-size: 12px; min-height: 18px; margin-top: 8px; }

/* ---------- login ---------- */
.login-body { display: flex; min-height: 100vh; align-items: center;
  justify-content: center; }
.login-card {
  width: 320px; background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 28px;
}
.login-card h1 { text-align: center; margin-bottom: 4px; }
.login-card p { text-align: center; margin-top: 0; }
.login-card input {
  width: 100%; margin: 8px 0; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--panel2); color: var(--text);
}
.login-card button {
  width: 100%; margin-top: 10px; padding: 10px; border: 0; border-radius: 8px;
  background: var(--accent); color: #fff; font-size: 15px; cursor: pointer;
}
.login-card button:disabled { opacity: .6; }

/* ---------- layout ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  background: var(--panel); position: sticky; top: 0; z-index: 5;
}
.topbar .spacer { flex: 1; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 18px; }
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px; margin-bottom: 16px;
}
.card h2 { font-size: 15px; margin: 0 0 12px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

input, select {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel2); color: var(--text);
}
button {
  padding: 8px 14px; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--accent); color: #fff;
}
button.ghost { background: transparent; border: 1px solid var(--border);
  color: var(--text); }
button.danger { background: transparent; border: 1px solid var(--red);
  color: var(--red); }
button:disabled { opacity: .5; cursor: default; }
button.small { padding: 4px 10px; font-size: 12px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border);
  vertical-align: top; }
th { color: var(--muted); font-weight: 500; white-space: nowrap; }
td .sub { color: var(--muted); font-size: 11px; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 99px;
  font-size: 11px; white-space: nowrap;
}
.badge.recording { background: rgba(62,207,142,.15); color: var(--green); }
.badge.queued, .badge.starting, .badge.stopping { background: rgba(245,196,81,.15); color: var(--yellow); }
.badge.done { background: rgba(77,163,255,.15); color: var(--accent); }
.badge.failed, .badge.rejected { background: rgba(255,107,107,.15); color: var(--red); }
.badge.stopped { background: rgba(138,147,160,.18); color: var(--muted); }
.badge.on { background: rgba(62,207,142,.15); color: var(--green); }
.badge.off { background: rgba(138,147,160,.18); color: var(--muted); }

.agents { display: flex; gap: 12px; flex-wrap: wrap; }
.agent {
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; min-width: 240px; flex: 1;
}
.agent b { font-size: 14px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px;
  font-size: 12px; margin-top: 6px; }
.kv span:nth-child(odd) { color: var(--muted); }

.models { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px; }
.model { background: var(--panel2); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden; }
.model img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block;
  background: #000; }
.model .m-info { padding: 8px; }
.model .m-name { font-size: 13px; font-weight: 600; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.model .m-meta { color: var(--muted); font-size: 11px; margin: 2px 0 6px; }
.model .m-actions { display: flex; gap: 6px; }
.model .m-actions button { flex: 1; }
.tabs { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.tabs button.on { background: var(--accent); }
.toast {
  position: fixed; right: 16px; bottom: 16px; z-index: 50;
  background: var(--panel2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 16px; font-size: 13px;
  box-shadow: 0 6px 24px rgba(0,0,0,.4);
}
.toast.err { border-color: var(--red); color: var(--red); }
.hide { display: none !important; }
/* ---------- 节点编辑模态 ---------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.55);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px; width: 100%; max-width: 380px;
}
.modal h2 { margin: 0 0 14px; font-size: 16px; }
.modal label { display: block; color: var(--muted); font-size: 12px; margin: 8px 0; }
.modal input {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px;
  border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel2); color: var(--text); font-size: 14px;
}
code.tok { background: var(--panel2); padding: 2px 6px; border-radius: 6px;
  font-size: 12px; word-break: break-all; }
.live-note { color: var(--muted); font-size: 11px; max-width: 340px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 二级 tag chips ---------- */
.chips {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-bottom: 12px; padding: 8px;
  background: var(--panel2); border: 1px solid var(--border); border-radius: 10px;
  max-height: 34vh; overflow-y: auto;
}
.chip {
  padding: 4px 10px; border-radius: 99px; font-size: 12px; cursor: pointer;
  background: transparent; border: 1px solid var(--border); color: var(--text);
}
.chip i { font-style: normal; color: var(--muted); font-size: 11px; margin-left: 2px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.on i { color: rgba(255,255,255,.75); }
.chip-group { color: var(--muted); font-size: 11px; margin: 2px 2px 2px 6px;
  white-space: nowrap; }

/* ---------- 移动端适配 ---------- */
@media (max-width: 720px) {
  body { font-size: 13px; }
  .topbar { flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .topbar h1 { font-size: 16px; }
  .wrap { padding: 10px; }
  .card { padding: 12px; border-radius: 10px; }
  .row > input, .row > select { flex: 1 1 140px; }
  button { padding: 8px 12px; }
  button.small { padding: 6px 10px; }
  /* 表格: 收窄为关键列, 其余横向滚动 */
  .card { overflow-x: auto; }
  table { min-width: 560px; }
  th, td { padding: 6px 8px; }
  /* 模型网格 2 列 + 更大点击区 */
  .models { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .model .m-actions button { width: auto; padding: 8px 0; font-size: 13px; }
  .chips { max-height: 30vh; }
  .agent { min-width: 100%; }
  .toast { left: 12px; right: 12px; text-align: center; }
}
