/* ═══════════════════════════════════════════════
   webtest · QwenPaw 控制台  —  设计系统(浅色)
   现代 SaaS 风格:冷灰画布 + 白卡片 + 主色蓝
   ═══════════════════════════════════════════════ */

:root {
  /* 色板 */
  --bg: #eef1f6;              /* 页面画布(冷灰) */
  --panel: #ffffff;           /* 卡片/面板 */
  --panel-2: #f7f8fc;         /* 次级面板/聊天区底 */
  --border: #e4e8f0;          /* 细边框 */
  --border-strong: #cdd4e2;   /* 强调边框 */
  --text: #1b2230;            /* 主文本 */
  --text-2: #5a6474;          /* 次级文本 */
  --text-3: #98a2b3;          /* 弱文本 */
  --accent: #3e6bff;          /* 主色 */
  --accent-strong: #2f54eb;
  --accent-weak: #eaf0ff;
  --accent-weak-2: #dbe6ff;
  --danger: #e5484d;
  --success: #1a9e60;
  --warn: #d97706;
  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06);
  --shadow-md: 0 6px 24px rgba(16,24,40,.09);
  --shadow-pop: 0 12px 40px rgba(16,24,40,.14);
  /* 圆角 */
  --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── 应用卡片布局 ── */
.wrap { max-width: 1920px; height: 100vh; margin: 0 auto; padding: 14px; }
.main {
  height: 100%; display: flex; overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-md);
}

/* ── 滚动条 ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #ccd4e2; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #aab5c8; }
::-webkit-scrollbar-track { background: transparent; }
* { scrollbar-width: thin; scrollbar-color: #ccd4e2 transparent; }

/* ── 侧栏 ── */
#sidebar {
  flex: 0 0 22%; min-width: 0; max-width: 80%; min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}

/* 左右区域拖拽分隔条（sidebar / chat-area 比例 20%~80%） */
.main-divider {
  flex: none; width: 6px; cursor: col-resize;
  background: var(--border); transition: background .15s ease;
}
.main-divider:hover, .main-divider.dragging { background: var(--accent); }

.side-head { padding: 14px 12px 10px; display: flex; flex-direction: column; gap: 10px; }
.agent-select {
  width: 100%; padding: 8px 10px; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--panel); color: var(--text); cursor: pointer; outline: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.agent-select:hover { border-color: var(--border-strong); }
.agent-select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-weak); }
.side-head .btn-new {
  width: 100%; padding: 9px 0; font-size: 13px; font-weight: 500;
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--r-md); cursor: pointer;
  transition: background .15s ease, box-shadow .15s ease;
}
.side-head .btn-new:hover { background: var(--accent-strong); box-shadow: 0 2px 8px rgba(62,107,255,.35); }

/* 侧栏 tab：历史会话 / 远程文件 */
.side-tabs {
  flex: none; display: flex; gap: 2px; padding: 0 8px;
  border-bottom: 1px solid var(--border);
}
.side-tab {
  flex: 1; padding: 9px 0 8px; font-size: 12px; font-weight: 500;
  background: transparent; border: none; border-bottom: 2px solid transparent;
  color: var(--text-3); cursor: pointer; border-radius: 0;
  transition: color .15s ease, border-color .15s ease;
}
.side-tab:hover { color: var(--text); }
.side-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.side-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.side-panel.hidden { display: none; }

#chatList { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 8px 8px; display: flex; flex-direction: column; gap: 2px; }
.chat-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border-radius: var(--r-md); cursor: pointer;
  transition: background .12s ease;
}
.chat-item:hover { background: var(--panel-2); }
.chat-item.active { background: var(--accent-weak); }
.chat-item.active .ci-name { color: var(--accent-strong); font-weight: 500; }
.chat-item .ci-main { flex: 1; min-width: 0; }
.chat-item .ci-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .ci-meta { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.chat-item .ci-del {
  flex: none; font-size: 11px; color: var(--text-3);
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 2px 7px; cursor: pointer;
  visibility: hidden; transition: color .12s ease, border-color .12s ease;
}
.chat-item:hover .ci-del { visibility: visible; }
.chat-item .ci-del:hover { color: var(--danger); border-color: var(--danger); }
/* 重命名按钮(删除左边,hover 显示) */
.chat-item .ci-rename {
  flex: none; font-size: 11px; color: var(--text-3);
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 2px 7px; cursor: pointer;
  visibility: hidden; transition: color .12s ease, border-color .12s ease;
}
.chat-item:hover .ci-rename { visibility: visible; }
.chat-item .ci-rename:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-weak); }
/* 重命名内联编辑框 */
.chat-item .ci-edit {
  width: 100%; font-size: 13px; padding: 2px 6px; box-sizing: border-box;
  border: 1px solid var(--accent); border-radius: var(--r-sm);
  outline: none; background: var(--panel); color: var(--text);
}
.chat-item.editing { cursor: text; }
.side-empty { padding: 32px 12px; text-align: center; font-size: 12px; color: var(--text-3); }
.side-more { padding: 6px 0 4px; text-align: center; }
.side-more a { font-size: 12px; color: var(--accent); text-decoration: none; cursor: pointer; }
.side-more a:hover { text-decoration: underline; }
.side-foot {
  padding: 8px 12px; font-size: 11px; color: var(--text-3);
  border-top: 1px solid var(--border);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── 远程文件浏览器 ── */
.remote-panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.remote-head { padding: 10px 12px 4px; display: flex; align-items: center; gap: 6px; }
.remote-title { font-size: 11px; font-weight: 600; letter-spacing: .5px; color: var(--text-3); text-transform: uppercase; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.remote-btn {
  flex: none; font-size: 12px; padding: 3px 9px;
  border: 1px solid var(--border); background: var(--panel);
  border-radius: var(--r-sm); cursor: pointer; color: var(--text-2);
  transition: all .12s ease;
}
.remote-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-weak); }
.remote-list { flex: 1; overflow-y: auto; padding: 2px 6px 6px; }
/* 拖拽上传:悬停高亮(inset 阴影不占布局空间) */
.remote-panel.dragging { box-shadow: inset 0 0 0 2px var(--accent); background: var(--accent-weak); border-radius: var(--r-sm); }
.remote-panel.uploading { opacity: .65; pointer-events: none; }
.rf-item {
  display: flex; align-items: center; gap: 6px; padding: 5px 7px;
  border-radius: var(--r-sm); cursor: pointer; font-size: 12px;
  transition: background .12s ease;
}
.rf-item:hover { background: var(--panel-2); }
.rf-item .rf-ico { flex: none; width: 16px; text-align: center; font-size: 13px; }
.rf-item .rf-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rf-item .rf-meta { flex: none; font-size: 10px; color: var(--text-3); white-space: nowrap; }
.rf-item .rf-dl {
  flex: none; font-size: 12px; color: var(--text-3); text-decoration: none;
  padding: 0 4px; border-radius: var(--r-sm); visibility: hidden; cursor: pointer; line-height: 1.4;
  transition: all .12s ease;
}
.rf-item:hover .rf-dl { visibility: visible; }
.rf-item .rf-dl:hover { color: var(--accent); background: var(--accent-weak); }
.rf-item .rf-goto {
  flex: none; font-size: 11px; color: var(--accent);
  border: 1px solid var(--border); background: var(--panel);
  border-radius: var(--r-sm); padding: 1px 6px; cursor: pointer; visibility: hidden;
  transition: all .12s ease;
}
.rf-item:hover .rf-goto { visibility: visible; }
.rf-item .rf-goto:hover { background: var(--accent-weak); border-color: var(--accent); }
.rf-item.parent { color: var(--text-3); }
.rf-item .rf-name.dir { font-weight: 500; color: var(--text); }
.remote-status { padding: 2px 12px 8px; font-size: 11px; color: var(--text-3); min-height: 16px; }

/* ── 聊天区头部 ── */
.chat-area { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--panel-2); }
header {
  padding: 10px 20px; background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo {
  width: 30px; height: 30px; border-radius: var(--r-md); flex: none;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 600;
  box-shadow: 0 2px 6px rgba(62,107,255,.35);
}
.brand-title { font-size: 14px; font-weight: 600; margin: 0; line-height: 1.2; white-space: nowrap; }
.brand-sub { font-size: 11px; color: var(--text-3); white-space: nowrap; }
header .h-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
header .model-label { font-size: 12px; color: var(--text-3); white-space: nowrap; }
header .model-select {
  font-size: 12px; padding: 5px 10px; max-width: 240px;
  border: 1px solid var(--border); background: var(--panel);
  border-radius: var(--r-md); color: var(--text-2); cursor: default;
  transition: all .15s ease;
}
header .model-select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-weak); }

/* ── 消息区 / 预览面板 ── */
.chat-body { flex: 1; min-height: 0; display: flex; }
#log { flex: 1; min-width: 0; overflow-y: auto; padding: 22px 24px; display: flex; flex-direction: column; gap: 16px; }

/* 预览面板(默认隐藏;打开时占 50%,可拖拽 30%~70%) */
.preview-divider {
  flex: none; width: 6px; cursor: col-resize;
  background: var(--border); transition: background .15s ease;
  display: none;
}
.preview-divider:hover, .preview-divider.dragging { background: var(--accent); }
.preview-panel {
  flex: 0 0 50%; min-width: 0; display: none;
  flex-direction: column; border-left: 1px solid var(--border);
  background: var(--panel);
}
.preview-panel.open { display: flex; }
.preview-head {
  padding: 8px 12px; display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--border); background: var(--panel-2);
}
.pv-name { flex: 1; min-width: 0; font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-badge {
  flex: none; font-size: 10px; color: var(--accent-strong);
  background: var(--accent-weak); border-radius: 999px; padding: 2px 8px;
}
.pv-actions { flex: none; display: flex; align-items: center; gap: 4px; }
.pv-dl {
  font-size: 11px; color: var(--accent); text-decoration: none;
  border: 1px solid var(--accent); border-radius: var(--r-sm); padding: 3px 8px;
  transition: all .15s ease;
}
.pv-dl:hover { background: var(--accent); color: #fff; }
.pv-close {
  font-size: 13px; color: var(--text-3); background: none; border: none;
  cursor: pointer; padding: 3px 7px; border-radius: var(--r-sm); transition: all .12s ease;
}
.pv-close:hover { color: var(--danger); background: #fdf2f2; }
.preview-body { flex: 1; overflow: auto; padding: 12px 14px; }
.preview-body iframe {
  width: 100%; height: 100%; border: none; border-radius: var(--r-md);
  background: #fff;
}
.preview-body img.pv-img { max-width: 100%; max-height: 100%; border-radius: var(--r-md); display: block; margin: 0 auto; }
.preview-body pre.pv-text {
  margin: 0; font-family: ui-monospace, Consolas, "SF Mono", monospace;
  font-size: 12px; line-height: 1.6; white-space: pre-wrap; word-break: break-all;
  color: var(--text);
}
.preview-status { padding: 4px 12px 8px; font-size: 11px; color: var(--text-3); min-height: 16px; }
.preview-status.err { color: var(--danger); }

.msg { display: flex; align-items: flex-start; gap: 10px; max-width: 100%; }
.msg.user { flex-direction: row-reverse; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.av-user { background: var(--accent-weak-2); color: var(--accent-strong); }
.av-bot { background: var(--accent); color: #fff; box-shadow: 0 2px 6px rgba(62,107,255,.35); }
.bubble {
  max-width: 78%; padding: 9px 14px;
  border-radius: 14px; font-size: 14px; line-height: 1.65;
  box-shadow: var(--shadow-sm); word-break: break-word;
}
.msg.user .bubble {
  background: var(--accent); color: #fff;
  border-bottom-right-radius: 5px; white-space: pre-wrap;
}
.msg.bot .bubble { background: var(--panel); border: 1px solid var(--border); border-bottom-left-radius: 5px; }
.msg .role { font-size: 11px; margin-bottom: 3px; }
.msg.user .role { color: rgba(255,255,255,.78); }
.msg.bot .role { color: var(--text-3); }
.msg .body { font-size: 14px; }
.msg .time {
  font-size: 10px; line-height: 1; text-align: right;
  margin-top: 4px; color: var(--text-3); user-select: none;
}
.msg.user .time { color: rgba(255,255,255,.6); }
.dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); margin-right: 6px; vertical-align: middle;
  animation: blink 1s infinite;
}
@keyframes blink { 0%,100%{opacity:.25} 50%{opacity:1} }

/* ── Markdown 渲染样式 ── */
.md p { margin: 5px 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 12px 0 6px; font-weight: 600; line-height: 1.35; color: var(--text); }
.md h1 { font-size: 17px; } .md h2 { font-size: 16px; } .md h3 { font-size: 15px; } .md h4 { font-size: 14px; }
.md ul, .md ol { margin: 5px 0; padding-left: 22px; }
.md li { margin: 3px 0; }
.md li.task { list-style: none; margin-left: -22px; display: flex; align-items: flex-start; gap: 6px; }
.md li.task input[type=checkbox] { margin: 4px 0 0; cursor: default; accent-color: var(--accent); }
.md code {
  background: #f0f3f9; padding: 1px 5px; border-radius: 4px;
  font-family: ui-monospace, Consolas, "SF Mono", monospace; font-size: 12.5px;
}
.msg.user .md code { background: rgba(255,255,255,.2); }
.md pre {
  background: #f4f6fa; border: 1px solid var(--border);
  padding: 10px 12px; border-radius: var(--r-md); overflow-x: auto; line-height: 1.5;
}
.md pre code { background: none; padding: 0; font-size: 12.5px; }
.md blockquote { border-left: 3px solid var(--border-strong); margin: 6px 0; padding: 2px 12px; color: var(--text-2); }
.md a { color: var(--accent); text-decoration: none; }
.md a:hover { text-decoration: underline; }
.md table { border-collapse: collapse; margin: 8px 0; font-size: 13px; width: 100%; }
.md th, .md td { border: 1px solid var(--border); padding: 5px 10px; text-align: left; }
.md thead th { background: var(--accent-weak); color: var(--accent-strong); font-weight: 500; }
.md tbody tr:nth-child(even) { background: #fafbfd; }
.md tbody tr:hover { background: var(--accent-weak); }
.md hr { border: none; border-top: 1px solid var(--border); margin: 10px 0; }

/* ── 文件 / 媒体块 ── */
.msg .body img { max-width: 100%; border-radius: var(--r-md); display: block; margin: 6px 0; }
.msg .body video, .msg .body audio { max-width: 100%; display: block; margin: 6px 0; border-radius: var(--r-md); }
.file-card {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 10px 12px; margin: 8px 0; max-width: 380px; background: var(--panel);
  transition: box-shadow .15s ease, border-color .15s ease;
}
.file-card:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); }
.file-card .file-ico {
  width: 36px; height: 36px; border-radius: var(--r-md); flex: none;
  background: var(--accent-weak); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.file-card .file-meta { min-width: 0; }
.file-card .file-name { font-size: 13px; font-weight: 500; word-break: break-all; }
.file-card .file-size { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.file-card .file-dl {
  margin-left: auto; flex: none; font-size: 12px;
  color: var(--accent); text-decoration: none;
  border: 1px solid var(--accent); padding: 4px 12px; border-radius: var(--r-sm);
  transition: all .15s ease;
}
.file-card .file-dl:hover { background: var(--accent); color: #fff; }

/* ── 思考内容折叠块 ── */
.reason {
  border-left: 3px solid var(--border-strong); background: var(--panel-2);
  border-radius: var(--r-md); margin: 8px 0; padding: 0; font-size: 13px;
}
.reason summary {
  cursor: pointer; padding: 8px 12px; color: var(--text-2);
  user-select: none; font-size: 12px; border-radius: var(--r-md);
  transition: color .12s ease;
}
.reason summary:hover { color: var(--text); background: rgba(0,0,0,.02); }
.reason .reason-body {
  border-top: 1px dashed var(--border); padding: 8px 12px;
  color: var(--text-2); white-space: pre-wrap; word-break: break-word;
  line-height: 1.6; font-size: 12.5px; max-height: 320px; overflow: auto;
}

/* ── 待发送附件 pills ── */
#pills { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 20px 8px; background: var(--panel-2); }
.pill {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 8px 4px 4px; font-size: 12px; max-width: 240px;
  box-shadow: var(--shadow-sm);
}
.pill img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; flex: none; }
.pill .pill-ico {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent-weak); color: var(--accent);
  display: flex; align-items: center; justify-content: center; font-size: 12px; flex: none;
}
.pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill button { border: none; background: none; cursor: pointer; color: var(--text-3); font-size: 14px; padding: 0 2px; line-height: 1; transition: color .12s ease; }
.pill button:hover { color: var(--danger); }

/* ── 输入区 ── */
footer {
  padding: 12px 20px 10px; background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
footer .input-row { display: flex; gap: 10px; align-items: center; }
footer .send-col { flex: none; display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
footer textarea#input {
  flex: 1; min-width: 0; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--r-lg);
  font-size: 14px; line-height: 1.5; font-family: inherit;
  outline: none; background: var(--panel-2); color: var(--text);
  resize: none; overflow-y: auto;
  min-height: 44px;        /* ≈1 行 */
  max-height: 200px;       /* ≈8 行，超出滚动 */
  transition: border-color .15s ease, box-shadow .15s ease, background .15s ease;
}
footer textarea#input:focus {
  border-color: var(--accent); background: var(--panel);
  box-shadow: 0 0 0 3px var(--accent-weak);
}
footer .attach {
  width: 40px; height: 40px; flex: none;
  border: 1px solid var(--border); background: var(--panel);
  border-radius: var(--r-lg); cursor: pointer; color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
  padding: 0; transition: all .15s ease;
}
footer .attach:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-weak); }
/* 录音中：按钮变红 + 图标脉冲 */
footer .attach.recording { color: #fff; background: var(--danger); border-color: var(--danger); }
footer .attach.recording:hover { color: #fff; background: #d1353a; border-color: #d1353a; }
footer .attach.recording svg { animation: recPulse 1.2s ease-in-out infinite; }
@keyframes recPulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
footer .attach.recording svg.stop-ico { animation: none; }
.rec-timer {
  flex: none; font-size: 12px; font-variant-numeric: tabular-nums;
  color: var(--danger); font-weight: 500; white-space: nowrap;
}
footer button.send {
  padding: 11px 22px; background: var(--accent); color: #fff;
  border: none; border-radius: var(--r-lg); font-size: 14px; font-weight: 500;
  cursor: pointer; flex: none; transition: all .15s ease;
}
footer button.send:hover { background: var(--accent-strong); box-shadow: 0 2px 8px rgba(62,107,255,.35); }
footer button.send:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
footer button.send.stop { background: var(--danger); }
footer button.send.stop:hover { background: #d1353a; box-shadow: 0 2px 8px rgba(229,72,77,.35); }
footer button.reset {
  padding: 4px 0; font-size: 12px; text-align: center;
  border: 1px solid var(--border); background: var(--panel);
  border-radius: var(--r-md); color: var(--text-3); cursor: pointer;
  transition: all .15s ease;
}
footer button.reset:hover { color: var(--danger); border-color: var(--danger); background: #fdf1f1; }

/* ── 技能栏（输入框下方）── */
.skill-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  min-height: 24px;
}
.skill-bar:empty { display: none; }
.skill-btn {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; padding: 4px 10px;
  border: 1px solid var(--border); background: var(--panel);
  border-radius: 999px; color: var(--text-2); cursor: pointer;
  transition: all .12s ease;
}
.skill-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-weak); }
.skill-add {
  flex: none; width: 26px; height: 26px; display: flex;
  align-items: center; justify-content: center;
  border: 1px dashed var(--border-strong); background: var(--panel);
  border-radius: 50%; color: var(--text-3); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 0;
  transition: all .12s ease;
}
.skill-add:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-weak); }

/* ── 技能选择弹窗 ── */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 23, 42, .45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-mask[hidden] { display: none; }
.modal {
  width: 680px; max-width: 100%; max-height: 80vh;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: 0 12px 40px rgba(15,23,42,.25);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-head {
  padding: 12px 16px; display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--border); font-size: 14px; font-weight: 600;
}
.modal-close {
  border: none; background: none; color: var(--text-3); font-size: 15px;
  cursor: pointer; padding: 2px 4px; line-height: 1; transition: color .12s ease;
}
.modal-close:hover { color: var(--danger); }
.modal-body {
  flex: 1; min-height: 0; overflow-y: auto; padding: 8px 10px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 2px 8px;
}
.skill-opt {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 8px; border-radius: var(--r-sm); cursor: pointer;
  font-size: 13px; color: var(--text); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; transition: background .12s ease;
}
.skill-opt:hover { background: var(--panel-2); }
.skill-opt input[type="checkbox"] { flex: none; accent-color: var(--accent); cursor: pointer; }
.skill-opt .skill-name { overflow: hidden; text-overflow: ellipsis; }
.modal-foot {
  padding: 10px 16px; display: flex; justify-content: flex-end; gap: 8px;
  border-top: 1px solid var(--border);
}
.modal-btn {
  padding: 7px 18px; font-size: 13px; border-radius: var(--r-md);
  border: 1px solid var(--border); background: var(--panel); color: var(--text-2);
  cursor: pointer; transition: all .12s ease;
}
.modal-btn:hover { border-color: var(--accent); color: var(--accent); }
.modal-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.modal-btn.primary:hover { background: var(--accent-strong); color: #fff; }

/* ── 摄像弹窗 ── */
.modal.cam-modal { width: 520px; }
.cam-body { padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.cam-body video, .cam-body img {
  width: 100%; max-height: 46vh; object-fit: contain;
  background: #0b1220; border-radius: var(--r-md);
}
.cam-actions { display: flex; justify-content: center; gap: 10px; }
.cam-status { font-size: 12px; color: var(--text-3); text-align: center; min-height: 16px; }

/* ── 诊断面板 ── */
#diag {
  font-size: 12px; color: var(--text-2); margin-top: 8px;
  white-space: pre-wrap; background: var(--panel);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 10px 14px; box-shadow: var(--shadow-sm);
}
#diag.ok { color: var(--success); border-color: rgba(26,158,96,.35); background: #f0faf4; }
#diag.err { color: var(--danger); border-color: rgba(229,72,77,.35); background: #fdf2f2; }
