/* ===== DS5 DongleRE 配置工具 ===== */
:root {
  --bg: #131519;
  --panel: #1c1f26;
  --panel2: #242832;
  --line: #333a46;
  --text: #e8eaf0;
  --dim: #9aa3b2;
  --accent: #4a9eff;
  --accent2: #31c48d;
  --danger: #ef5350;
  --warn: #f6c343;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 14px/1.5 "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 10px 18px; background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand {
  display: flex; flex-wrap: wrap; align-items: baseline; min-width: 0;
  font-weight: 700; font-size: 16px; letter-spacing: .3px;
}
.brand .ver { color: var(--dim); font-weight: 400; font-size: 13px; }
.brand .ver.cpu { color: var(--text); font-variant-numeric: tabular-nums; }
/* 顶栏手柄状态：未连接 → 红字强调；已连接（电量 / 报文）→ 绿字 */
.brand .ver.pad-off { color: var(--danger); font-weight: 700; }
.brand .ver.pad-on { color: var(--accent2); }
/* 测试站角标：橙底深字的小胶囊，紧跟版本号；只有 donglerebeta 主机名会插入这个元素，
 * 同时 body.beta 给顶栏加一条橙边，正式站和本地服务器都没有。 */
.brand .ver.beta-badge {
  display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px;
  background: var(--warn); color: #1a1300; font-weight: 700; font-size: 11px;
  letter-spacing: .8px; line-height: 1.5; align-self: center;
}
body.beta .topbar { border-top: 3px solid var(--warn); }
/* 健康信息留在顶部状态组，但独立成行，不把页签和连接按钮横向挤没。 */
.brand .ver.top-health {
  display: flex; flex: 1 0 100%; flex-wrap: wrap; gap: 1px 12px;
  margin-top: 2px; font-size: 12px; line-height: 1.45;
  font-variant-numeric: tabular-nums; letter-spacing: 0;
}
.top-health > span { white-space: nowrap; }
#conn-health-state.good { color: var(--accent2); }
#conn-health-state.warn, #conn-health-temp.warn { color: var(--warn); }
#conn-health-state.bad, #conn-health-temp.bad { color: var(--danger); }
.tabs { display: flex; gap: 6px; flex: 1; }
.tab {
  background: transparent; color: var(--dim); border: 1px solid transparent;
  padding: 7px 16px; border-radius: 8px; cursor: pointer; font-size: 14px;
}
.tab:hover { color: var(--text); background: var(--panel2); }
.tab.active { color: #fff; background: var(--panel2); border-color: var(--line); }
.conn { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
/* r243：对频按钮紧跟在「未连接手柄」右边（在 .brand 里，不在右上角 .conn） */
#btn-pair { white-space: nowrap; margin-left: 10px; align-self: center; font-weight: 400; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #555; flex: none; }
.dot.on { background: var(--accent2); box-shadow: 0 0 8px var(--accent2); }

/* 健康信息加入后，中等宽度把导航独立成一行；不要挤成逐字换行的竖排文字。 */
@media (max-width: 1680px) {
  .topbar { flex-wrap: wrap; gap: 8px 16px; }
  .brand { flex: 1 1 420px; }
  .top-health > span { white-space: normal; }
  .tabs { order: 3; flex: 1 0 100%; flex-wrap: wrap; }
  .tab { flex: none; white-space: nowrap; }
  .conn { margin-left: auto; }
}

/* ---------- generic ---------- */
main { padding: 16px; }
.page { display: none; }
.page.active { display: block; }
.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px;
}
h2 { font-size: 14px; margin: 4px 0 10px; color: var(--text); }
h2:not(:first-child) { margin-top: 18px; }
h3 { font-size: 13px; margin: 12px 0 6px; color: var(--dim); font-weight: 600; }
.muted { color: var(--dim); }
.hint { color: var(--dim); font-size: 12px; }
/* 参数解释直接跟在控件后面，不使用悬浮层。 */
.param-note { margin: 6px 0 2px; line-height: 1.6; white-space: pre-line; }
.kv .param-note { display: table-cell; margin: 0; padding: 0 0 8px; }
/* 实时数值：等宽才不会因为位数变化左右横跳 */
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.row { display: flex; align-items: center; }
.row.gap { gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btn {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  padding: 7px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.small { padding: 4px 10px; font-size: 12px; }
/* 大号按钮：高级配置的「写入接收器 / 重新读取」（2026-10-17 用户要求显眼） */
.btn.big { padding: 10px 22px; font-size: 15px; }
.btn.danger { border-color: var(--danger); color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; font-weight: 600; }
.btn.danger.solid:hover { border-color: var(--danger); filter: brightness(1.12); }
button:disabled { opacity: .45; cursor: not-allowed; }
input[type=number], input[type=text], select {
  background: var(--panel2); color: var(--text); border: 1px solid var(--line);
  border-radius: 6px; padding: 4px 8px; width: 84px; font-size: 13px;
}
input:focus, select:focus { outline: 1px solid var(--accent); }
code { background: var(--panel2); padding: 1px 6px; border-radius: 4px; font-size: 12px; }

/* ---------- page 1 layout ---------- */
.map-layout {
  display: grid; grid-template-columns: 250px minmax(420px, 1fr) 380px;
  gap: 14px; align-items: start;
}
.map-center { min-height: 520px; }
/* 标题在左、说明占满中段、重置按钮钉在右端 */
.pad-head { display: flex; align-items: baseline; gap: 12px; }
.pad-head > h2 { flex: none; }
.pad-head > .hint { flex: 1; text-align: right; min-width: 0; }
.pad-head #btn-reset-layer { flex: none; align-self: center; }

.layer-list { display: flex; flex-direction: column; gap: 6px; }
.layer-item {
  display: flex; flex-direction: column; gap: 5px; padding: 7px 9px;
  background: var(--panel2); border: 1px solid var(--line); border-left: 3px solid var(--line);
  border-radius: 8px; cursor: pointer;
}
.layer-item.active { background: #24344d; box-shadow: inset 0 0 0 1px var(--accent); }
.layer-item .l-head { display: flex; align-items: center; gap: 7px; }
.layer-item .idx {
  font-size: 12px; font-weight: 700; width: 16px; text-align: center; flex: none;
}
.layer-item .l-name {
  background: transparent; border: none; width: 100%; flex: 1; padding: 1px 0;
  font-size: 13px; font-weight: 600; border-bottom: 1px dashed transparent;
  /* 平时不接受鼠标事件：点名字等于点行（切层），改名必须先点 ✎。
   * 否则点击会落到输入框上、抢焦点，既切不了层又像进了编辑态 */
  pointer-events: none;
}
.layer-item.renaming .l-name { pointer-events: auto; }
.layer-item .l-name:not([readonly]):hover { border-bottom-color: var(--line); }
.layer-item .l-name:focus { outline: none; border-bottom-color: var(--accent); }
.layer-item .l-ren {
  flex: none; background: transparent; border: 1px solid transparent; border-radius: 5px;
  color: var(--dim); font-size: 12px; line-height: 1; padding: 2px 4px; cursor: pointer;
}
.layer-item .l-ren:hover { color: var(--text); border-color: var(--line); background: var(--panel2); }
.layer-item.renaming { box-shadow: inset 0 0 0 1px var(--accent); }
.layer-item .dirty { color: var(--warn); font-size: 11px; flex: none; }
.layer-item .l-bind { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.layer-item .l-bind select { width: 100%; padding: 2px 4px; font-size: 12px; }
.layer-item .l-bind.muted { font-size: 11px; }

.kv { width: 100%; border-collapse: collapse; }
.kv td { padding: 3px 0; }
.kv td:first-child { color: var(--dim); }


/* ---------- controller pad ----------
 * 图形来自 web/assets/ds-edge-controller.svg（dualshock-tools，MIT）。
 * 素材自带的是浅色主题配色：st2=所有按键、st3=机身、st4=触摸板上沿、st71=扬声器孔，
 * 这里按本工具的暗色主题重描；热区就是素材里的 <g id="Xxx_infill">（JS 挂 data-btn）。 */
.pad-wrap { padding: 8px 0 0; }
.pad-svg {
  display: block; width: 100%; max-width: 640px; height: auto; margin: 0 auto;
  user-select: none;
  /* 素材用 var(--bs-body-bg) 作机身填充（它默认跟随 Bootstrap 明暗主题） */
  --bs-body-bg: #232833;
}
.pad-svg .st2, .pad-svg .st3 { stroke-width: 2px; }
/* 四条线色都走 --art-line：主层不设（用兜底的原蓝灰），切到覆盖层时由 updatePadMarks()
 * 写成那一层的淡色，整张图一眼就能看出「现在改的不是主层」。填充色不跟着变，
 * 免得盖掉按键上的映射状态色。 */
.pad-svg .st3 { fill: #232833; stroke: var(--art-line, #55708c); }   /* 机身 + 摇杆圈 */
.pad-svg .st2 { fill: #171b22; stroke: var(--art-line, #5b6b82); }   /* 按键 */
.pad-svg .st4 { stroke: var(--art-line, #5b6b82); }                  /* 触摸板上沿 */
.pad-svg .st71 { fill: var(--art-line, #5b6b82); }                   /* 扬声器孔 */

.pad-svg [data-btn] { cursor: pointer; }
.pad-svg [data-btn] .st2 { transition: fill .12s, stroke .12s; }
.pad-svg [data-btn]:hover .st2 { fill: #2b3546; stroke: var(--accent); }
/* --mark 由 updatePadMarks() 按当前层写入（主金/1橙/2绿/3青/4紫） */
.pad-svg [data-btn].mapped .st2 { fill: #24425f; stroke: var(--mark, var(--accent)); }
.pad-svg [data-btn].inherit .st2 { fill: #1e2a38; stroke: #4a6a8a; stroke-dasharray: 3 2; }
.pad-svg [data-btn].remapped .st2 { fill: #2b3242; stroke: var(--mark, #bc8cff); stroke-width: 2.4px; }
.pad-svg [data-btn].blanked .st2 { fill: #3a2a12; stroke: var(--warn); }
.pad-svg [data-btn].sel .st2 { stroke: #fff; stroke-width: 2.8px; stroke-dasharray: none; }

/* 选中的那一瞬间：整个按键填满高亮，然后 1.5 秒淡掉（用户 2026-10-20：光有白边不明显）。
 * 填充色跟**当前编辑的层**走（--pick-color 由 flashPick() 写成该层颜色：主层金 / 1橙 / 2绿 / 3青 / 4紫）。
 * 鼠标点选和手柄直选都会走 selectBtn() → flashPick()，所以只在这一处定义动画。 */
@keyframes pickFlash {
  0%   { fill: var(--pick-color, var(--accent)); fill-opacity: .95; }
  30%  { fill: var(--pick-color, var(--accent)); fill-opacity: .72; }
  100% { fill: var(--pick-color, var(--accent)); fill-opacity: 0; }
}
.pad-svg [data-btn].picked .st2 { animation: pickFlash 1.5s ease-out 1; }
.pad-svg [data-stick].picked .st3 { animation: pickFlash 1.5s ease-out 1; }
/* V1..V4 那些芯片不是 SVG，用外发光闪一下（同样用层色） */
@keyframes chipFlash {
  0%   { box-shadow: 0 0 0 2px var(--pick-color, var(--accent)) inset,
                     0 0 14px var(--pick-color, var(--accent)); }
  100% { box-shadow: 0 0 0 0 transparent inset, 0 0 0 transparent; }
}
.vk-chip.picked { animation: chipFlash 1.1s ease-out 1; }
@media (prefers-reduced-motion: reduce) {
  .pad-svg [data-btn].picked .st2, .pad-svg [data-stick].picked .st3, .vk-chip.picked { animation: none; }
}

/* 摇杆圈（[data-stick]）＝点开右侧「摇杆曲线 · 校准（开发中）」说明；内圈小圆是 L3 / R3 */
.pad-svg [data-stick] { cursor: pointer; transition: stroke .12s; }
.pad-svg [data-stick]:hover { stroke: var(--accent); }
.pad-svg [data-stick].sel { stroke: #fff; stroke-width: 2.4px; }

.pad-note { max-width: 640px; margin: 6px auto 0; line-height: 1.6; text-align: center; }

/* 图上的文字标注（#pad-labels / #pad-dots 盖在按键上，别挡住点击） */
.pad-svg #pad-labels, .pad-svg #pad-dots { pointer-events: none; }
.pad-svg text { text-anchor: middle; user-select: none; }
.pad-svg .lbl-main { fill: #dce7f5; font-size: 9px; font-weight: 600; }
.pad-svg .lbl-sub { fill: #7f8ea3; font-size: 8px; }
.pad-svg .lbl-main.inh { fill: #7fa3c8; }
.pad-svg .lbl-main.none, .pad-svg .lbl-sub.none { fill: var(--warn); }

/* 页面3 实时点亮（.on 只用在测试页，跟页面1 的映射态配色不冲突） */
.pad-svg [data-btn].on .st2 { fill: #1d5f4a; stroke: #4ee39a; stroke-width: 2.6px; }
.pad-svg .stick-dot { fill: #4ee39a; stroke: #0b0f14; stroke-width: 1.5; }

/* ---------- 陀螺仪（体感）面板 ----------
 * 水平轴用蓝色、垂直轴用黄色标出来（图例和示意图同步高亮） */
.gy-panel { max-width: 720px; margin: 14px auto 0; padding-top: 12px; border-top: 1px solid var(--line); }
/* 两段式扳机（R2.5/r60）：设置面板已经挪进右栏（page-map.js 里生成），
 * 这里只剩一个"老固件"用的警示色；左下角那块面板与那排芯片都已删除。 */
.warn-text { color: var(--warn); }
/* r65：测试页那两行扳机效果条（行程 + 效果区间）—— 等宽、别换行，格子才对得齐 */
#trig-live code { font-family: ui-monospace, Consolas, monospace; white-space: pre; }
/* 右栏：扳机的「模式」开关那两格跟形态页签同一套观感，只是一行放两个、字长一点 */
#e-mode-row .form-tab { padding: 5px 12px; }
.stage-tabs { margin-top: 2px; }
.stage-tabs .hint { flex: 1 1 auto; text-align: right; }
.gy-head { display: flex; align-items: baseline; gap: 12px; justify-content: space-between; }
.gy-head h2 { margin: 0 0 10px; }
.gy-head .hint { text-align: right; margin-left: auto; }
/* 陀螺仪总开关（2026-10-20）：标题右边第二项，和右边的状态文字分开 */
.gy-head .gy-master {
  margin-left: 4px; padding: 2px 8px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--panel2);
  font-size: 12px; white-space: nowrap; flex: none;
}
.gy-head .gy-master:hover { border-color: var(--accent); }
.gy-layout { display: grid; grid-template-columns: 252px 1fr; gap: 16px; align-items: start; }
.gy-svg { display: block; width: 100%; height: auto; }
.gy-svg .gy-pad { fill: #232833; stroke: #55708c; stroke-width: 1.6; }
.gy-svg .gy-tp { fill: none; stroke: #3a4354; stroke-width: 1.2; }
.gy-svg .gy-yaw { fill: none; stroke: #4a6a8a; stroke-width: 1.6; stroke-dasharray: 5 4; }
.gy-svg .gy-axis { stroke: #4a6a8a; stroke-width: 1.4; stroke-dasharray: 4 3; }
.gy-svg .gy-arrow { fill: #4a6a8a; }
.gy-svg .gy-t { fill: #7f8ea3; font-size: 9px; text-anchor: middle; }
.gy-svg .gy-t.end { text-anchor: end; }
.gy-svg [data-axis], .gy-svg .gy-arrow { transition: stroke .12s, fill .12s; }
.gy-svg [data-axis].on-h { stroke: var(--accent); }
.gy-svg .gy-arrow.on-h { fill: var(--accent); stroke: none; }
.gy-svg [data-axis].on-v { stroke: var(--warn); }
.gy-svg .gy-arrow.on-v { fill: var(--warn); stroke: none; }

.gy-legend { display: flex; flex-direction: column; gap: 2px; margin: 8px 0 6px; }
.gy-leg-h, .gy-item {
  display: grid; grid-template-columns: 10px minmax(0, 1fr) 46px 46px;
  align-items: center; column-gap: 4px; padding: 2px 5px;
}
.gy-leg-h { font-size: 11px; color: var(--dim); }
.gy-item { font-size: 12px; color: var(--dim); border-radius: 6px; }
.gy-item i:not(.gy-ar) { width: 10px; height: 10px; border-radius: 2px; background: #3a4354; }
.gy-item .gy-nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gy-item b, .gy-leg-h b { text-align: right; font-variant-numeric: tabular-nums; }
.gy-item b { font-weight: 600; }
.gy-item b + b { color: var(--text); }
.gy-leg-h b { font-weight: 400; }
.gy-leg-unit { font-size: 11px; color: var(--dim); padding: 0 5px; }
.gy-item code { padding: 0 3px; }
.gy-item.on-h { color: var(--text); background: #24344d; }
.gy-item.on-h i { background: var(--accent); }
.gy-item.on-v { color: var(--text); background: #332c1c; }
.gy-item.on-v i { background: var(--warn); }

/* .tp-ctl 是触摸板「移动逻辑」页的控件容器：长得跟 .gy-ctl 一样，
   但不吃陀螺仪那套「关闭时整块变灰」的 .off 状态 */
.gy-ctl .field, .tp-ctl .field, .st-ctl .field { grid-template-columns: 78px 1fr; gap: 8px; }
.gy-ctl .chk, .st-ctl .chk { font-size: 12px; }
.gy-ctl .chk input[type=checkbox], .st-ctl .chk input[type=checkbox] { width: auto; }
/* 下拉框和滑杆都要能跟右边的复选框/数值同行，别把 .stack 挤到换行 */
.gy-ctl .field select, .tp-ctl .field select { width: auto; flex: 1 1 auto; min-width: 120px; }
.gy-ctl input[type=range], .tp-ctl input[type=range], .st-ctl input[type=range] { width: auto; flex: 1 1 110px; min-width: 80px; accent-color: var(--accent); }
.gy-ctl .gy-val, .tp-ctl .gy-val, .st-ctl .gy-val { font-size: 12px; color: var(--dim); min-width: 46px; text-align: right; flex: none; }
.gy-ctl.off, .st-ctl.off { opacity: .45; }
.gy-ctl.off input, .gy-ctl.off select, .st-ctl.off input { cursor: not-allowed; }
/* R3.38：目标 = 原生透传时，死区/灵敏度/水平轴/垂直轴这几行不参与，单独变灰；
   「启用模式 / 启用键 / 映射到」照常可改（那三个才决定透传本身开不开） */
.gy-ctl.native .gy-map-only { opacity: .45; }
/* 「启用模式 / 启用键」那一块不参与变灰（.gy-en-ctl 不加 off）：陀螺仪关了还要靠它重新开 */

/* 映射页只保留陀螺仪死区调参；零偏校准集中在独立校准页。 */
.gy-dz-box {
  margin-top: 12px; padding: 10px 10px 8px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
}
.gy-dot { width: 7px; height: 7px; border-radius: 50%; background: #3a4354; flex: none; }
.gy-dot.ok { background: #4bbf73; }
.gy-dot.run { background: var(--warn); }
.gy-dot.err { background: #d9534f; }
.gy-dz-box .hint { margin: 0; }
.gy-dz-row {
  display: flex; align-items: center; gap: 8px;
}
.gy-dz-row > label { min-width: 56px; color: var(--dim); font-size: 12px; }
.gy-dz-row input[type=range] { flex: 1 1 auto; min-width: 80px; accent-color: var(--accent); }
.gy-dz-row .gy-val { min-width: 50px; text-align: right; font-variant-numeric: tabular-nums; }
/* 实时读数（原始 / 处理后）：右栏最上面的一张小卡片（r158 从左栏挪回来）。
 * 不设宽度、块级撑满右栏 → 左右边缘和下面 .field 控件对齐。 */
.gy-live-top {
  width: auto; margin: 0 0 12px; padding: 8px 10px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 10px;
}
.gy-live-top .gy-leg-h, .gy-live-top .gy-item { grid-template-columns: 10px minmax(0, 1fr) 64px 64px; }
.gy-live-top .gy-leg-h { letter-spacing: .02em; }
.gy-live-top .gy-item b { color: var(--dim); font-weight: 500; }
.gy-live-top .gy-item b + b { color: var(--text); font-weight: 700; }
.gy-live-top .gy-leg-unit { margin-top: 2px; }

/* R3.53：启用模式 / 映射到 并排一行 */
.gy-row2 { display: grid; grid-template-columns: 1fr 1fr; column-gap: 10px; }
.gy-row2 .field { grid-template-columns: 54px minmax(0, 1fr); gap: 6px; }
.gy-row2 .field select { min-width: 0; font-size: 12px; }
.gy-row2 .field > label { font-size: 12px; }

/* 摇杆曲线图：拖动点用 SVG 指针事件，禁掉浏览器自己的滚动/缩放手势 */
.st-graph { width: 100%; background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 4px; }
.st-graph svg { width: 100%; height: auto; display: block; touch-action: none; user-select: none; }

/* R3.72：曲线输入 / 最终输出沿用校准页同款双圆；数字常显，不靠颜色读值。 */
.st-global { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.st-live-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.st-live-head h4 { margin: 0; }
.st-live-rings { padding: 9px; gap: 9px; }
.st-live-rings .cal-stick-pad { max-width: 140px; }
.st-live-note { margin: 9px 0 10px; line-height: 1.6; }
/* r166：独立校准页。状态只表达校准结果，连接/旧固件/进行中保持中性提示。 */
.cal-page { max-width: 1180px; margin: 0 auto; }
.cal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.cal-head h2 { margin: 0 0 4px; }
.cal-head > div:first-child > .hint { margin: 0; line-height: 1.7; }
.cal-conn {
  display: flex; align-items: center; gap: 8px; flex: none; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--panel);
  color: var(--dim); font-size: 13px; white-space: nowrap;
}
.cal-conn.ok { color: var(--accent2); border-color: rgba(49, 196, 141, .35); }
.cal-conn.bad { color: var(--warn); border-color: rgba(255, 180, 0, .35); }
.cal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.cal-card { min-width: 0; margin: 0; }
.cal-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.cal-card-head h3 { margin: 0; font-size: 17px; }
.cal-card-head .hint { text-align: right; }
.cal-state { min-height: 26px; color: var(--text); font-size: 16px; font-weight: 700; line-height: 1.6; }
.cal-state.cal-state-ok { color: var(--accent2); }
.cal-state.cal-state-bad { color: var(--danger); }
.cal-params { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 12px 0; }
.cal-params > div { min-width: 0; padding: 8px 9px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; }
.cal-params span { display: block; margin-bottom: 3px; color: var(--dim); font-size: 11px; }
.cal-params code { display: block; overflow: hidden; color: var(--text); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.cal-global { margin: 0 0 12px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.02); }
.cal-global-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.cal-global-head h4 { margin: 0; font-size: 14px; }
.cal-global .field { margin: 7px 0; }
.cal-global > .hint { margin: 7px 0 0; line-height: 1.6; }
/* R3.80b：陀螺仪的死区/反死区并排一行（用户 2026-11-01 要求） */
.cal-shape-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: center; }
.cal-shape-row .field { margin: 4px 0; }
@media (max-width: 720px) { .cal-shape-row { grid-template-columns: 1fr; } }
.cal-shape-status { min-height: 20px; }
.cal-shape-status.cal-state-bad { color: var(--danger); }
.cal-gyro-curve-head { justify-content: flex-start; flex-wrap: wrap; gap: 6px 12px; }
.cal-gyro-curve-head > .hint:last-child { margin-left: auto; }
.cal-gyro-range { display: flex; align-items: center; gap: 6px; }
.cal-gyro-range > label { color: var(--dim); font-size: 12px; font-weight: 400; }
.cal-gyro-range input { width: 82px; margin: 0; padding: 3px 6px; }
.cal-gyro-range-min { min-width: 18px; color: var(--text); text-align: center; font-variant-numeric: tabular-nums; }
.cal-gyro-curve-body { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: stretch; }
.cal-gyro-curve-body .field { margin: 4px 0; }
.cal-gyro-curve-body .cal-gyro-graph { display: block; }
.cal-gyro-graph .stack { display: block; }
.cal-gyro-graph .st-graph { max-width: 300px; }
.cal-gyro-curve-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin-top: 7px; }
.cal-gyro-curve-foot .hint { margin: 0; line-height: 1.6; }
.cal-gyro-curve-foot .cal-shape-status { text-align: right; }
.cal-gyro-range-hint { font-size: 11px; }
.cal-gyro-curve-fields { min-width: 0; display: grid; grid-template-columns: 1fr; align-content: space-between; }
.cal-gyro-curve-fields .field { grid-template-columns: 42px minmax(0, 1fr); }
.cal-gyro-curve-fields .stack { flex-wrap: nowrap; }
.cal-gyro-curve-fields input[type=range] { width: auto; min-width: 0; flex: 1 1 auto; }
.cal-stick-live { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 10px; background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; }
.cal-stick-stage { min-width: 0; }
.cal-raw-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 8px; color: var(--dim); font-size: 12px; }
.cal-stick-pad { position: relative; width: 100%; max-width: 180px; aspect-ratio: 1; margin: 4px auto 8px; background: var(--panel); border: 1px solid var(--dim); border-radius: 50%; }
.cal-stick-pad::before, .cal-stick-pad::after { content: ''; position: absolute; pointer-events: none; opacity: .55; }
.cal-stick-pad::before { left: 0; right: 0; top: 50%; border-top: 1px solid var(--line); }
.cal-stick-pad::after { top: 0; bottom: 0; left: 50%; border-left: 1px solid var(--line); }
.cal-stick-dot { position: absolute; z-index: 1; width: 11px; height: 11px; background: var(--accent); border: 2px solid var(--text); border-radius: 50%; transform: translate(-50%, -50%); box-shadow: 0 0 0 2px var(--panel); pointer-events: none; }
.cal-stick-dot.cal { background: var(--accent2); }
.cal-stick-dot[hidden] { display: none; }
.cal-stick-values { display: flex; justify-content: center; gap: 14px; color: var(--dim); font-size: 12px; }
.cal-stick-values output { color: var(--text); font-variant-numeric: tabular-nums; }
.cal-start { width: 100%; margin-top: 12px; }
.cal-card-note { margin: 8px 0 0; line-height: 1.6; }
.cal-gyro { grid-column: 1 / -1; }
.cal-gyro-top { display: grid; grid-template-columns: 480px minmax(0, 1fr); gap: 12px; align-items: start; }
.cal-gyro-setup { min-width: 0; display: grid; grid-template-columns: 1fr; gap: 12px; }
.cal-gyro-setup .cal-global { margin-bottom: 0; }
.cal-gyro-top .cal-gyro-layout { grid-template-columns: minmax(0, 1fr) 190px; gap: 12px; }
.cal-gyro-top .cal-shape-row { grid-template-columns: 1fr; }
.cal-gyro-top .cal-shape-row .stack { flex-wrap: nowrap; }
.cal-gyro-top .cal-shape-row input[type=range] { width: auto; min-width: 0; flex: 1 1 auto; }
.cal-gyro-top .cal-shape-row .gy-val { min-width: 44px; text-align: right; }
.cal-gyro-layout { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 24px; align-items: center; }
.cal-gy-bias { margin-top: 8px; color: var(--text); font-family: ui-monospace, Consolas, monospace; font-size: 13px; font-variant-numeric: tabular-nums; }
.cal-gy-tip { margin: 8px 0 0; line-height: 1.7; }
.cal-gy-controls .btn { width: 100%; }
.cal-gy-controls progress { width: 100%; height: 7px; margin-top: 9px; accent-color: var(--accent); }
.cal-gy-controls .hint { display: block; margin-top: 7px; line-height: 1.6; text-align: center; }
@media (min-width: 761px) and (max-width: 1100px) {
  .cal-gyro-top { grid-template-columns: 1fr; }
  .cal-gyro-setup { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cal-gyro-top .cal-gyro-layout { grid-template-columns: minmax(0, 1fr) 190px; }
  .cal-gyro-top .cal-shape-row { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .cal-head { flex-direction: column; gap: 10px; }
  .cal-grid { grid-template-columns: 1fr; }
  .cal-gyro { grid-column: auto; }
  .cal-gyro-top, .cal-gyro-setup { grid-template-columns: 1fr; }
  .cal-gyro-layout, .cal-gyro-top .cal-gyro-layout { grid-template-columns: 1fr; gap: 14px; }
  .cal-gyro-curve-body { grid-template-columns: 1fr; }
  .cal-gyro-graph .st-graph { margin: 0 auto; }
}
.scal-modal { width: 440px; }
.scal-dir { height: 74px; display: flex; align-items: center; justify-content: center; font-size: 54px; line-height: 1; color: var(--text); }
.scal-modal #scal-step { margin: 4px 0 6px; text-align: center; color: var(--text); }
.scal-modal #scal-hint { min-height: 38px; margin: 0 0 8px; text-align: center; line-height: 1.6; }
.scal-modal progress { width: 100%; height: 8px; accent-color: var(--accent); }
.scal-dots { display: flex; justify-content: space-between; gap: 4px; margin: 12px 0; }
.scal-dots span { flex: 1; padding: 3px 0; border: 1px solid var(--line); border-radius: 6px; color: var(--dim); text-align: center; }
.scal-dots span.active { border-color: var(--accent); color: var(--text); }
.scal-dots span.done { color: var(--accent2); border-color: var(--accent2); background: rgba(49, 196, 141, .10); }
.scal-live { padding: 8px; background: var(--panel2); border-radius: 7px; text-align: center; font-variant-numeric: tabular-nums; }
.scal-result { margin-top: 10px; padding: 9px 10px; background: var(--panel2); border-radius: 7px; white-space: pre-line; line-height: 1.7; }
.scal-result.err { border: 1px solid var(--danger); }

/* 摇杆面板子页签：曲线（死区/反死区/五点曲线） / RC 滤波（用户 2026-10-20 定的层级） */
.st-tabs { display: flex; gap: 6px; margin: 2px 0 10px; }
.st-tab {
  flex: 1 1 0; padding: 6px 10px; border-radius: 8px; cursor: pointer; font-size: 13px;
  background: var(--panel2); border: 1px solid var(--line); color: var(--dim);
}
.st-tab:hover { border-color: var(--accent); }

/* R3.67：手柄图上的触摸板四方向区（映射模式）；编辑右侧某一块时对应分区亮边框 */
#tp-zones { pointer-events: none; }
/* 里面那圈虚线（90%）：四个小框的外边，和外框同一条路径、天然平行 */
#tp-zones .tp-zone-cell { fill: none; stroke: rgba(175, 198, 228, .7); stroke-width: 1.3;
  stroke-dasharray: 6 4; pointer-events: none; }
#tp-zones .tp-zone-area { fill: transparent; stroke: rgba(175, 198, 228, .7); stroke-width: 1.3;
  stroke-dasharray: 6 4; pointer-events: all; cursor: pointer; }
#tp-zones rect[data-z="-1"] { fill: transparent; stroke: none; pointer-events: all; cursor: pointer; }
#tp-zones .tp-zone-area.sel { fill: rgba(240, 167, 66, .28); stroke: #f0a742; stroke-width: 2; stroke-dasharray: none; }
#tp-zones .tp-zone-area:hover { fill: rgba(74, 158, 255, .12); }

/* R3.49：触摸板小地图：外框＝通用设置，中间 4 个小框＝四个区 */
.tp-map-box { position: relative; border: 2px solid var(--line); border-radius: 12px;
  padding: 22px 12px 12px; cursor: pointer; background: rgba(255, 255, 255, .02); margin: 4px 0 8px; }
.tp-map-box.on { border-color: #f0a742; }
.tp-map-hint { position: absolute; top: 4px; left: 12px; font-size: 10px; color: var(--dim); }
.tp-map-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; align-items: stretch; }
.tp-map-center { display: flex; align-items: center; justify-content: center; color: var(--dim); font-size: 11px; }
.tp-map-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 2px;
  padding: 8px; font: inherit; text-align: left; color: var(--text); background: var(--panel2);
  border: 1px dashed var(--line); border-radius: 8px; cursor: pointer; min-width: 0; }
.tp-map-cell .z { font-size: 12px; font-weight: 600; }
.tp-map-cell .a { font-size: 10px; color: var(--dim); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tp-map-cell.on { border-color: #f0a742; border-style: solid; box-shadow: 0 0 0 1px #f0a742 inset; }
.tp-map-cell:hover { border-color: var(--accent); }

/* R3.46：原生透传勾着时，映射区整块变灰、不可点 */
#tp-map.off { opacity: .45; pointer-events: none; }
/* 鼠标模式是纯单指：双指那一组变灰 */
.tp-off { opacity: .45; pointer-events: none; }

/* R3.46：触摸板手势动作行（左标签 + 输出类型 + 值 + 修饰键） */
.tp-act { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0; }
.tp-act-n { width: 76px; flex: none; font-size: 12px; color: var(--dim); }
.tp-act select { width: auto; flex: 1 1 120px; min-width: 110px; }
.tp-act .chk { font-size: 11px; }
/* 轻触 / 按下用色块区分：轻触＝绿、按下＝蓝 */
.tp-act[data-kind="tap"], .tp-act[data-kind="press"] { border-radius: 6px; padding: 4px 6px; margin: 4px 0; }
.tp-act[data-kind="tap"] { background: rgba(49, 196, 141, .07); box-shadow: inset 3px 0 0 #31c48d; }
.tp-act[data-kind="press"] { background: rgba(74, 158, 255, .07); box-shadow: inset 3px 0 0 #4a9eff; }
.tp-act[data-kind="tap"] > .tp-act-n { background: rgba(49, 196, 141, .16); color: #31c48d; }
.tp-act[data-kind="press"] > .tp-act-n { background: rgba(74, 158, 255, .16); color: #4a9eff; }
.tp-act > .tp-act-n { padding: 2px 6px; border-radius: 4px; }
/* 轻触 / 按下按区分组 */
.tp-zone { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; margin: 8px 0; }
.tp-zone-t { font-size: 12px; font-weight: 600; color: var(--text); margin: 2px 0 4px; }

/* R3.47：下拉即捕获的值选择器 —— 原 <select> 隐藏，自绘按钮 + 列表 */
.vp-src { display: none !important; }
.vp-btn { display: inline-flex; align-items: center; justify-content: space-between; gap: 6px;
  width: 100%; min-width: 0; padding: 6px 8px; font: inherit; color: var(--text);
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }
.vp-btn:hover { border-color: var(--accent); }
.vp-btn i { font-style: normal; color: var(--dim); font-size: 10px; }
.vp-pop { position: fixed; z-index: 9999; max-height: 280px; overflow-y: auto; padding: 4px;
  display: flex; flex-direction: column; gap: 2px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); }
.vp-opt { text-align: left; padding: 6px 8px; font: inherit; color: var(--text); background: none;
  border: 0; border-radius: 4px; cursor: pointer; white-space: nowrap; }
.vp-opt:hover { background: var(--panel2); }
.vp-opt.cur { background: var(--panel2); color: var(--accent); }
.tp-act .vp-btn { flex: 1 1 120px; min-width: 110px; width: auto; }
.tp-cell .vp-btn { flex: none; width: 100%; min-width: 0; }

/* R3.46：方向用十字格摆出来（上/下/左/右各一格）
 * minmax(0,1fr) 是必须的：不然单元格里的 nowrap 文字会把列撑宽，上和下就错位了 */
.tp-cross { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) minmax(0,1fr); gap: 6px; margin: 8px 0 10px; align-items: stretch; }
.tp-cross-mid { display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--dim); letter-spacing: 1px; }
.tp-cell { border: 1px solid var(--line); border-radius: 6px; padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tp-cell > b { font-size: 12px; font-weight: 600; color: var(--fg); white-space: normal; text-align: center; line-height: 1.3; }
.tp-cell select { width: 100%; min-width: 0; }

/* R3.44：摇杆面板的小节标题（RC 滤波）—— 带分隔线，别再挤成一行小字 */
.st-sec {
  margin: 16px 0 4px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: .02em;
}.st-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- 触摸板面板（在按键编辑区里，选到触摸板相关的键才出现） ----------
 * 分「移动逻辑 / 按键逻辑」两段；编辑栏窄，所以双指那两块竖着排 */
.tp-panel { margin: 12px 0 10px; }
.tp-phead { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.tp-phead h4 { margin: 0 0 6px; }
.tp-phead .hint { font-size: 11px; text-align: right; }
.tp-sec {
  font-size: 12px; font-weight: 600; color: var(--accent);
  margin: 12px 0 4px; padding-bottom: 3px; border-bottom: 1px dashed var(--line);
}
.tp-pinch { display: grid; grid-template-columns: 1fr; gap: 10px; align-items: start; margin-top: 8px; }
.tp-box { border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px 6px; }
.tp-box h4 { margin: 0 0 7px; font-size: 12px; color: var(--dim); font-weight: 600; }
.tp-box .field { grid-template-columns: 46px 1fr; gap: 8px; }
.hide { display: none !important; }

/* ---------- edit panel ---------- */
/* 右栏标题：按当前编辑层**填充**层色（主层金 / 1橙 / 2绿 / 3青 / 4紫），深色字保证可读。
 * 颜色由 page-map.js 的 paintEditTitle() 写到 --title-bg / --title-ink 上。 */
#edit-title {
  display: inline-block; margin: 0 0 10px; padding: 3px 10px;
  border-radius: 7px;
  background: var(--title-bg, transparent);
  color: var(--title-ink, var(--text));
  font-size: 14px; font-weight: 700; letter-spacing: .3px;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, .25) inset;
}
.edit-body .form-tabs { display: flex; gap: 4px; flex-wrap: nowrap; margin-bottom: 10px; }
.form-tab {
  padding: 5px 8px; font-size: 12px; border-radius: 7px; cursor: pointer;
  background: var(--panel2); border: 1px solid var(--line); color: var(--dim);
  white-space: nowrap;
}
.form-tab.active { color: #fff; border-color: var(--accent); background: #24344d; }
.form-tab .badge { color: var(--accent2); font-size: 10px; margin-left: 4px; }
.field { display: grid; grid-template-columns: 72px 1fr; gap: 6px; align-items: center; margin: 8px 0; }
.field > label { color: var(--dim); font-size: 12px; }
.field .stack { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
/* 数值 + 单位必须同一行（如 频率 次/秒） */
.field .stack.nowrap { flex-wrap: nowrap; }

/* 组合键的两个源键下拉：水平并排，中间一个加号 */
.vk-src { display: flex; gap: 6px; align-items: center; }
.vk-src select { flex: 1 1 0; min-width: 0; width: auto; }
.vk-plus { color: var(--dim); font-weight: 600; }
.field select, .field input { width: 100%; }
/* 「下拉列表 ＋ 捕获输入」并排：select 让位收缩，按钮才不会被 100% 宽度挤到下一行 */
.field .stack.pick > select { width: auto; flex: 1 1 0; min-width: 0; }
.field .stack.pick > .btn { flex: none; }
.sub-box {
  background: var(--panel2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; margin: 10px 0;
}
.sub-box h4 { margin: 0 0 6px; font-size: 12px; color: var(--dim); font-weight: 600; }
/* 按键映射按真实数据流分组：输入触发在上，当前形态的输出在下。 */
.io-section { border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; background: rgba(0, 0, 0, .08); }
.io-section-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.io-section-head h4 { margin: 0; color: var(--accent); font-size: 13px; }
.io-output .io-section-head h4 { color: var(--accent2); }
.io-section-head span { color: var(--dim); font-size: 12px; }
.io-section > .sub-box:last-child { margin-bottom: 0; }
.io-flow { height: 20px; text-align: center; color: var(--dim); line-height: 20px; }
.io-current { margin: 0 0 8px; font-size: 12px; }
.chk { display: flex; gap: 6px; align-items: center; font-size: 13px; white-space: nowrap; }
.thumb-preview { max-width: 100%; border: 1px solid var(--line); border-radius: 6px; background: #000; image-rendering: pixelated; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(80px);
  background: #2b3140; border: 1px solid var(--line); color: var(--text);
  padding: 10px 18px; border-radius: 10px; opacity: 0; transition: .25s; z-index: 99;
  max-width: 70vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--danger); }

/* ---------- page 2 ---------- */
.cfg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); gap: 14px; align-items: stretch; }
.cfg-grid .panel h2 { margin-top: 0; }
/* 同一行的卡片拉到一样高（用户 2026-11-01：卡片拉长一点） */
.cfg-grid .panel { display: flex; flex-direction: column; }
.cfg-side > .banner-warn { margin: 14px 0 0; }
/* R3.81：操作 / 设备状态 / 灯光合成一栏，用小标题分开 */
.cfg-sub + .cfg-sub { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.cfg-sub > h3 { margin: 0 0 8px; font-size: 14px; }
/* 触摸板面板要一行排下六个模式按钮，窄屏下就退回一栏 */
.cfg-grid .panel.wide { grid-column: span 2; }
@media (max-width: 760px) { .cfg-grid .panel.wide { grid-column: auto; } }
/* 标签对控件的第一行（r40 给每个字段加了多行 hint 后，居中对齐会让标签
 * 相对控件下沉半行~一行，看起来"标签和控件对不上"），所以顶对齐 */
.cfg-item { display: grid; grid-template-columns: 130px 1fr; gap: 10px; align-items: start; margin: 9px 0; }
.cfg-item > label { color: var(--dim); font-size: 13px; }
.cfg-item select, .cfg-item input[type=number], .cfg-item input[type=text] { width: 100%; }
/* R3.81.2：有上下限的参数改成滑条 + 实时数值 */
.cfg-slider { display: grid; grid-template-columns: minmax(0, 1fr) 42px; align-items: center; gap: 10px; width: 100%; }
.cfg-slider output { min-width: 34px; text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.cfg-item input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 18px; margin: 0; background: transparent; cursor: pointer;
}
.cfg-item input[type=range]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent) 0 var(--p, 50%), var(--line) var(--p, 50%) 100%);
}
.cfg-item input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 15px; height: 15px; margin-top: -4.5px; border-radius: 50%;
  background: #fff; border: 2px solid var(--accent);
  box-shadow: 0 0 0 3px rgba(74, 158, 255, .18);
  transition: transform .12s ease, box-shadow .12s ease;
}
.cfg-item input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.1); }
.cfg-item input[type=range]:focus-visible { outline: none; }
.cfg-item input[type=range]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 5px rgba(74, 158, 255, .28); }
.cfg-item input[type=range]:disabled { opacity: .4; cursor: not-allowed; }
.cfg-item input[type=range]::-moz-range-track { height: 6px; border-radius: 99px; background: var(--line); }
.cfg-item input[type=range]::-moz-range-progress { height: 6px; border-radius: 99px; background: var(--accent); }
.cfg-item input[type=range]::-moz-range-thumb {
  width: 13px; height: 13px; border: 2px solid var(--accent); border-radius: 50%; background: #fff;
}

/* 分段控件（触摸板映射模式）：整行铺开，选中的那格填强调色 */
.seg { display: flex; flex-wrap: wrap; gap: 0; }
.seg-btn {
  flex: 1 1 auto; min-width: 62px; padding: 6px 8px; font-size: 12px; cursor: pointer;
  background: var(--panel2); color: var(--dim);
  border: 1px solid var(--line); border-right-width: 0;
  font-family: inherit; white-space: nowrap;
}
.seg-btn:first-child { border-radius: 7px 0 0 7px; }
.seg-btn:last-child { border-radius: 0 7px 7px 0; border-right-width: 1px; }
.seg-btn:hover { color: var(--text); }
.seg-btn.on { background: var(--accent); border-color: var(--accent); color: #0b0e12; font-weight: 600; }
.seg-btn.on + .seg-btn { border-left-color: var(--accent); }

/* ---------- page 2 / M61R 资源管理 ---------- */
.resource-card { min-width: 0; }
.resource-card[hidden], .resource-card [hidden] { display: none !important; }
.res-head, .res-section-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.res-head { justify-content: space-between; }
.res-head h2, .res-section h3, .res-section-head h3 { margin: 0; }
.res-section h3, .res-section-head h3 { font-size: 14px; }
.res-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; margin: 12px 0 9px; }
.res-stats > div { min-width: 0; padding: 7px 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel2); }
.res-stats span { display: block; color: var(--dim); font-size: 11px; margin-bottom: 3px; }
.res-stats code { display: block; overflow-wrap: anywhere; }
.res-progress-row { display: grid; grid-template-columns: 82px minmax(0, 1fr); align-items: center; gap: 9px; margin: 8px 0; }
.res-stats > .res-use-card { position: relative; isolation: isolate; overflow: hidden; }
.res-use-card > span, .res-use-card > code { position: relative; z-index: 1; }
.res-use-card > .res-use-percent { margin-top: 2px; font-size: 11px; }
.res-use-fill { position: absolute; z-index: 0; inset: 0 auto 0 0; width: 0; opacity: .22;
  border-radius: inherit; transition: width .15s ease; background: var(--accent2); pointer-events: none; }
.res-use-fill.green { background: var(--accent2); }
.res-use-fill.orange { background: var(--warn); }
.res-use-fill.brown { background: #a5533c; }
.res-use-fill.red { background: var(--danger); }
.res-use-percent.orange { color: var(--warn); }
.res-use-percent.brown { color: #d4775b; }
.res-use-percent.red { color: var(--danger); font-weight: 700; }
.res-progress-row progress { width: 100%; height: 9px; accent-color: var(--accent); }
.res-progress-row { grid-template-columns: minmax(0, 1fr); gap: 3px; }
.res-progress-row .hint { min-height: 18px; font-variant-numeric: tabular-nums; }
.res-status { margin: 10px 0; padding: 9px 10px; border: 1px solid var(--line); border-left: 3px solid var(--accent);
  border-radius: 7px; background: var(--panel2); font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.res-status.err { border-left-color: var(--danger); color: #ffaaa5; }
.res-status.ok { border-left-color: var(--accent2); color: var(--accent2); }
.res-status.warn { border-left-color: var(--warn); }
.res-section { margin-top: 13px; padding-top: 11px; border-top: 1px solid var(--line); }
.res-section-head { justify-content: space-between; }
.res-file-row { display: grid; grid-template-columns: 118px minmax(0, 1fr); gap: 6px 9px; align-items: center; margin-top: 9px; }
.res-file-row > label { color: var(--dim); font-size: 13px; }
.res-file-row > input[type=file] { min-width: 0; width: 100%; font-size: 12px; color: var(--dim); }
.res-file-row > input[type=file]::file-selector-button { margin-right: 8px; padding: 5px 8px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--panel2); color: var(--text); font: inherit; cursor: pointer; }
.res-file-row > .hint { grid-column: 2; min-width: 0; overflow-wrap: anywhere; }
.res-audio-row { grid-template-columns: 118px minmax(0, 1fr) auto; }
.res-row-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.res-audio-row > .res-row-actions { grid-column: 2 / 4; }
.res-video-editor { margin-top: 12px; }
.res-video-controls { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; min-width: 0; }
.res-video-track { flex: 2 1 480px; min-width: 0; }
.res-video-track > .res-row-actions { margin-top: 8px; }
.res-video-previews { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; gap: 16px;
  align-items: start; margin-top: 14px; }
.res-video-generate-mid { align-self: center; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 4px; }
.res-video-generate-mid .btn { white-space: nowrap; }
.res-video-write-side { align-self: center; padding: 0 4px; }
.res-video-write-side .btn { white-space: nowrap; }
.res-video-preview-panel { min-width: 0; }
.res-video-preview-panel > .res-section-head { max-width: 320px; min-height: 28px; align-items: center; }
.res-video-preview-panel > .hint { display: block; max-width: 320px; margin-top: 7px; }
.res-source-preview h3 { font-size: 13px; }
.res-video-source-view { display: grid; place-items: center; width: 100%; max-width: 320px; aspect-ratio: 4 / 3;
  margin-top: 7px; overflow: hidden; border: 1px solid var(--line); border-radius: 7px; background: #050608; }
.res-video-source-view canvas { display: block; width: 100%; height: 100%; cursor: grab; touch-action: none; }
.res-video-source-view canvas.dragging { cursor: grabbing; }
.res-video-source-view > span { padding: 12px; text-align: center; }
.res-video-timeline { position: relative; height: 38px; border: 1px solid var(--line); border-radius: 7px;
  background: repeating-linear-gradient(90deg, var(--panel2) 0, var(--panel2) calc(10% - 1px), var(--line) 10%);
  overflow: hidden; touch-action: none; }
.res-video-timeline.disabled { opacity: .5; }
.res-video-selection { position: absolute; top: 4px; bottom: 4px; min-width: 2px; cursor: grab;
  border: 2px solid var(--accent); border-radius: 5px; background: #63a8ff38; touch-action: none; }
.res-video-selection:active { cursor: grabbing; }
.res-video-playhead { position: absolute; z-index: 2; top: -1px; bottom: -1px; width: 2px; margin-left: -1px;
  background: #fff; box-shadow: 0 0 0 1px #0b0e12aa, 0 0 6px #ffffffaa; pointer-events: none; }
.res-video-scale { display: flex; justify-content: space-between; margin-top: 3px; color: var(--dim);
  font-size: 11px; font-variant-numeric: tabular-nums; }
.res-video-numbers { display: flex; flex: 1 1 320px; align-items: center; align-content: flex-start; gap: 8px; flex-wrap: wrap; margin: 0; }
.res-video-numbers label { color: var(--dim); font-size: 12px; }
.res-video-numbers input { width: 66px; padding: 5px 6px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--panel2); color: var(--text); font: inherit; }
.res-video-numbers .hint { flex: 1 1 260px; font-variant-numeric: tabular-nums; }
.res-video-preview { position: relative; width: 100%; max-width: 320px; height: auto; aspect-ratio: 4 / 3;
  margin-top: 7px; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 8px;
  background: #050607; color: #fff; cursor: pointer; }
.res-video-preview:disabled { cursor: default; opacity: .7; }
.res-video-preview.stale { border-color: var(--warn); }
.res-video-preview img { display: block; width: 100%; height: 100%; object-fit: contain; }
.res-video-preview > span { position: absolute; left: 0; right: 0; bottom: 0; padding: 6px;
  background: #050607b8; color: #fff; font-size: 12px; pointer-events: none; }
#res-video-preview-state.warn { color: var(--warn); }
.res-processing { z-index: 160; }
.res-processing .modal { width: 480px; }
.res-processing progress { width: 100%; height: 12px; accent-color: var(--accent); }
.res-processing .res-status { margin-bottom: 0; }
.res-rom-list { margin-top: 8px; }
.res-rom-row { display: grid; grid-template-columns: 24px minmax(80px, 1fr) auto auto auto auto; gap: 5px;
  align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.res-rom-index { color: var(--dim); font-size: 12px; text-align: right; }
.res-rom-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.res-rom-row .btn { padding: 3px 6px; }
.res-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 15px; }
@media (max-width: 760px) {
  .res-video-previews { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .res-stats { grid-template-columns: 1fr; }
  .res-file-row, .res-audio-row { grid-template-columns: 1fr; }
  .res-file-row > .hint, .res-audio-row > .res-row-actions { grid-column: 1; }
  .res-use-row { grid-template-columns: 44px minmax(0, 1fr) 58px; }
  .res-rom-row { grid-template-columns: 22px minmax(70px, 1fr) auto; }
  .res-rom-row > .hint { display: none; }
}

/* ---------- page 3 ---------- */
.test-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.test-status { margin-top: 14px; }
.stick-row, .trig-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0; }
.stick-box { display: grid; grid-template-columns: 34px 1fr 36px; align-items: center; gap: 8px; }
.stick-box label { color: var(--dim); font-size: 12px; }
.stick-box progress { width: 100%; height: 14px; }
.stick-box span { font-size: 12px; color: var(--dim); text-align: right; }
.test-pad { margin: 12px 0 0; }
/* 测试页两张图跟按键映射页**同一个尺寸**（基础规则 .pad-svg 就是 width:100% + max-width:640px）。
 * 这里以前写了 max-width:100%，把 640px 上限覆盖掉了 → 大屏上撑满整块面板（用户 2026-10-17 报的）。 */
.test-pad .pad-svg { max-width: 640px; margin: 0 auto; }
/* r57：没连手柄时两张实时图变灰（内容按回中帧画） */
.test-pad.pad-idle { opacity: .35; filter: grayscale(1); }
/* R3.73 / r182：真实 PCM 电平，只读监控，不是音量滑块。 */
.audio-meter { display: grid; grid-template-columns: 112px minmax(0, 1fr) 62px; gap: 10px;
               align-items: center; margin-top: 10px; }
.audio-meter + .audio-meter { margin-top: 7px; }
.audio-meter label { color: var(--dim); font-size: 12px; }
.audio-meter progress { width: 100%; height: 12px; accent-color: var(--accent2); }
.audio-meter span { color: var(--dim); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.audio-meter.inactive { opacity: .48; }
.audio-mic-detect, .test-tool-row { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.audio-mic-detect .btn, .test-tool-row .btn { flex: none; }
.audio-mic-detect .hint, .test-tool-row .hint { min-width: 0; line-height: 1.5; }
.audio-mic-detect .hint.err, .test-tool-row .hint.err { color: var(--danger); }
/* 按住型按钮：别让长按选中文字或触发系统手势 */
.test-tool-row .btn.hold { user-select: none; -webkit-user-select: none; touch-action: none; }
.kb-out { margin-top: 8px; display: flex; gap: 24px; font-size: 13px; flex-wrap: wrap; }
.kb-out.col { flex-direction: column; gap: 3px; align-items: stretch; }
.kb-out.col code { min-width: 0; }
.kb-out code { min-width: 60px; display: inline-block; color: var(--dim); }
.kb-out code.on { color: var(--accent2); font-weight: 600; }
.kb-out code.num { white-space: pre; }   /* 陀螺仪读数靠补空格定宽，别让浏览器把空格合并掉 */
/* R3.25：合并行里的分隔符（鼠标 · 移动、触摸板 · 开合） */
.kb-sep { color: var(--dim); margin: 0 6px; opacity: .55; }
/* R3.25：测试页「当前层」一行 + 它前面那个层色圆点（颜色由 JS 按层写） */
.layer-now {
  margin-top: 10px; display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--dim);
}
/* 和标题同一行：标题左，这一串右对齐（用户 2026-10-17：「这个要弄成一行」） */
.test-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.test-head > h2 { margin: 0; flex: none; }
.test-head > .layer-now { margin: 0 0 0 auto; align-self: center; }
.layer-now code { color: var(--accent2); font-weight: 600; }
.layer-now .muted { font-size: 12px; }
.layer-dot {
  width: 10px; height: 10px; border-radius: 50%; display: inline-block;
  background: var(--art-line, #55708c); box-shadow: 0 0 0 1px rgba(255, 255, 255, .10);
}

/* 触摸板实时位置：直接画在手柄图上（PadArt.makeTouch 建的 #pad-touch 覆盖层）。
   方框＝固件死区，虚线＝两指连线，圆点＝手指（1 蓝 2 红）。 */
.pad-svg .tp-dz { fill: #4a6a8a18; stroke: #4a6a8a; stroke-width: 1.2px; stroke-dasharray: 4 3; }
.pad-svg .tp-link { stroke: var(--warn); stroke-width: 1.6px; stroke-dasharray: 3 3; }
.pad-svg .tp-dot { stroke: #0b0f14; stroke-width: 1.6px; }
.pad-svg .tp-dot.f0 { fill: var(--accent2); }
.pad-svg .tp-dot.f1 { fill: var(--danger); }
.pad-svg .tp-num { font-size: 11px; font-weight: 700; paint-order: stroke;
                   stroke: #0b0f14; stroke-width: 2.4px; }
.pad-svg .tp-num.f0 { fill: var(--accent2); }
.pad-svg .tp-num.f1 { fill: var(--danger); }

/* ---------- modal / 宏管理器 ---------- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(8, 10, 14, .68);
  display: none; align-items: center; justify-content: center; z-index: 100;
}
.modal-bg.show { display: flex; }
.modal {
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; width: 560px; max-width: 94vw; max-height: 88vh; overflow: auto;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .5);
}
.modal.wide { width: 1000px; }
.modal h2 { display: flex; align-items: center; gap: 8px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }
.modal-head h2 { margin: 0; }

.macro-layout { display: grid; grid-template-columns: 320px 1fr; gap: 14px; margin-top: 10px; }
.macro-list { display: flex; flex-direction: column; gap: 5px; margin-bottom: 10px; }
.macro-row {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
.macro-row:hover { border-color: var(--accent); }
.macro-row.active { border-color: var(--accent); background: #24344d; }
.macro-row .m-info { flex: 1; min-width: 0; }
.macro-row .m-name { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.macro-row.draft { border-style: dashed; border-color: var(--accent2); }
.tag {
  font-size: 10px; padding: 1px 5px; border-radius: 4px; margin-left: 4px;
  background: #1d3b31; color: var(--accent2); border: 1px solid #2c5a49; white-space: nowrap;
}
.tag.warn { background: #3a2a12; color: var(--warn); border-color: #5a4320; }
.macro-main { min-width: 0; }
.macro-main .field input[type=text] { width: 100%; }

/* ---------- 宏管理器：标签页（宏列表 / 战备库） ---------- */
.mk-tabs { display: flex; gap: 6px; }
.tab2 {
  background: var(--panel2); border: 1px solid var(--line); color: var(--dim);
  padding: 5px 14px; border-radius: 8px; cursor: pointer; font-size: 13px;
}
.tab2:hover { border-color: var(--accent); }
.tab2.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- 战备库 ---------- */
.lib-bar { display: flex; align-items: center; gap: 8px; margin: 12px 0 8px; flex-wrap: wrap; }
.lib-bar .spacer { flex: 1; }
.lib-slots { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.lib-slot {
  width: 116px; background: var(--panel2); border: 2px solid var(--line);
  border-radius: 9px; padding: 5px 6px 7px; cursor: pointer;
}
.lib-slot:hover { border-color: var(--accent); }
.lib-slot.active { border-color: var(--accent); background: #24344d; }
.lib-slot-top { display: flex; align-items: center; gap: 2px; }
.lib-slot-top select { width: 100%; font-size: 11px; padding: 2px 4px; }
.lib-slot-x {
  background: none; border: 0; color: var(--dim); cursor: pointer;
  font-size: 12px; padding: 0 2px; line-height: 1;
}
.lib-slot-x:hover { color: var(--danger); }
.lib-slot-cap {
  width: 100%; margin-top: 3px; background: var(--panel); border: 1px solid var(--line);
  color: var(--text); border-radius: 5px; font-size: 10px; padding: 2px 0; cursor: pointer;
}
.lib-slot-cap:hover { border-color: var(--accent); }
.lib-slot-cap.capturing { background: var(--accent); border-color: var(--accent); color: #fff; }
.lib-slot-art { height: 62px; display: flex; align-items: center; justify-content: center; }
.lib-slot-art img { width: 56px; height: 56px; }
.lib-slot-art .ph { color: var(--dim); font-size: 12px; }
.lib-slot-name {
  font-size: 11px; text-align: center; line-height: 1.25; color: var(--text);
  height: 28px; overflow: hidden;
}
.lib-slot-warn { font-size: 10px; text-align: center; color: var(--warn); }
.lib-slot.add {
  display: flex; align-items: center; justify-content: center;
  color: var(--dim); font-size: 12px; min-height: 118px; border-style: dashed;
}
.lib-slot.add:hover { color: var(--text); }

.lib-cats { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.lib-cat {
  background: var(--panel2); border: 1px solid var(--line); color: var(--text);
  padding: 4px 12px; border-radius: 999px; cursor: pointer; font-size: 12px;
}
.lib-cat:hover { border-color: var(--accent); }
.lib-cat.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.lib-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px; max-height: 44vh; overflow: auto; padding: 2px; margin-bottom: 8px;
}
.lib-cell {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 9px;
  padding: 7px 4px 5px; cursor: pointer; color: var(--text);
}
.lib-cell:hover { border-color: var(--accent); }
.lib-cell img { width: 52px; height: 52px; display: block; }
.lib-cell .ph {
  width: 52px; height: 52px; display: flex; align-items: center;
  justify-content: center; color: var(--dim);
}
.lib-cell-name {
  font-size: 11px; line-height: 1.25; text-align: center; color: var(--dim);
  height: 28px; overflow: hidden;
}
.lib-cell:hover .lib-cell-name { color: var(--text); }
.lib-cell-badge {
  position: absolute; top: 3px; right: 3px; max-width: 76px; overflow: hidden;
  white-space: nowrap; font-size: 9px; padding: 1px 4px; border-radius: 4px;
  background: var(--accent); color: #fff;
}
.lib-foot { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; }
.lib-foot > span:last-child { opacity: .65; white-space: nowrap; }

.steps-scroll { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; }
table.steps { width: 100%; border-collapse: collapse; font-size: 12px; }
table.steps th, table.steps td { padding: 3px 6px; text-align: left; border-bottom: 1px solid var(--line); }
table.steps th { color: var(--dim); font-weight: 600; position: sticky; top: 0; background: var(--panel2); }
table.steps input { width: 70px; padding: 2px 4px; }

.rec-dot {
  display: inline-block; width: 11px; height: 11px; border-radius: 50%;
  background: var(--danger); animation: recblink 1s infinite;
}
@keyframes recblink { 50% { opacity: .25; } }
.rec-stat { margin: 6px 0; font-size: 13px; color: var(--dim); }
.rec-stat span { color: var(--text); font-weight: 700; }
.rec-line { padding: 2px 8px; font-size: 12px; color: var(--dim); border-bottom: 1px solid #262b34; }

input[type=color] { background: var(--panel2); border: 1px solid var(--line); border-radius: 6px; cursor: pointer; }

.btn.capturing { background: var(--accent); border-color: var(--accent); color: #fff;
                 animation: recblink 1s infinite; }
.pad-svg [data-btn].blanked .st2 { fill: #3a2a12; stroke: var(--warn); }

/* ---------- 虚拟组合键 V1..V4（叠在手柄图上 L2/R2 之间的空白处） ---------- */
.pad-stage { position: relative; max-width: 640px; margin: 0 auto; }
.pad-stage .pad-svg { max-width: none; }
.vk-chips {
  position: absolute; top: 5.5%; left: 50%; transform: translateX(-50%);
  display: flex; gap: 5px;
}
.vk-chip {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 62px; padding: 3px 6px 4px;
  background: #1b2430; border: 1px solid #3d4f66; border-radius: 7px;
  cursor: pointer; font: inherit; color: var(--dim); line-height: 1.25;
}
.vk-chip b { font-size: 12px; color: var(--text); }
.vk-chip span { font-size: 12px; color: var(--dim); white-space: nowrap; }
.vk-chip:hover { border-color: var(--accent); }
.vk-chip.on { background: #223444; border-color: #4a7196; }
.vk-chip.on span { color: #8fb6d8; }
.vk-chip.mapped { border-color: var(--mark, var(--accent2)); }
.vk-chip.sel { border-color: #fff; box-shadow: 0 0 0 1px #ffffff80; }
.vk-chip.blanked { border-color: var(--warn); }

/* ---------- 触摸板子页签（移动逻辑 / 按键逻辑） ---------- */
.tp-tabs { display: flex; gap: 6px; margin-bottom: 10px; }

/* ---------- 自适应扳机那一节的行（R3.1，用户说"太丑了"） ----------
 * 原来用的是通用的 .field（2 列 grid：标签 + 内容），一行里放「标签+滑条+数值」时第 3 个元素被挤到
 * 下一行 → 数值掉到滑条下面，很难看。这里给扳机那一节单独改成 flex：标签 | 滑条 | 数值 一行放下。 */
.field.trig-row { display: flex; gap: 8px; align-items: center; }
.field.trig-row > label { flex: none; width: 64px; }
.field.trig-row > input[type="range"] { flex: 1 1 auto; min-width: 0; width: auto; }
.field.trig-row > select { flex: 1 1 auto; min-width: 0; width: auto; }
.field.trig-row > .gy-val { flex: none; min-width: 44px; text-align: right; }
.field.trig-row > #e-sync { cursor: pointer; color: var(--accent2, #7aa2f7); text-decoration: underline; }
.field.trig-row > #e-sync:hover { color: #fff; }
/* 两段模式中间那根分界滑条：一段 | 滑条 | 二段，同样一行 */
.stage-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.stage-row .stage-btn { flex: none; }
.stage-row .stage-pct { flex: 1 1 auto; display: flex; gap: 8px; align-items: center; min-width: 0; }
.stage-row .stage-pct > input[type="range"] { flex: 1 1 auto; min-width: 0; }
.stage-row .stage-pct > .gy-val { flex: none; min-width: 36px; text-align: right; }
.tp-tab {
  flex: 1 1 0; padding: 6px 10px; border-radius: 8px; cursor: pointer; font-size: 13px;
  background: var(--panel2); border: 1px solid var(--line); color: var(--dim);
}
.tp-tab:hover { border-color: var(--accent); }
.tp-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ---------- 输出类型「绝地潜兵 2 战备宏」的参数区 ---------- */
.strat-art { width: 40px; height: 40px; border-radius: 7px; background: #1b2430; flex: none; }
.strat-art.ph {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px dashed var(--line); color: var(--dim); font-size: 12px;
}
.strat-name { font-size: 13px; }
.strat-seq { font-size: 18px; letter-spacing: 3px; color: var(--accent2); }

.banner-warn {
  background: #3a2a12; border-bottom: 1px solid #6b4a17; color: #ffd79a;
  padding: 9px 14px; font-size: 13px; line-height: 1.7;
}
.banner-warn code { background: #00000040; padding: 1px 5px; border-radius: 4px; color: #ffe9c2; }
.banner-warn .btn { margin: 0 6px; }
.banner-warn .hint { color: #c9a877; }

@media (max-width: 1280px) {
  .macro-layout { grid-template-columns: 1fr; }
  .gy-layout { grid-template-columns: 1fr; }
  .map-layout { grid-template-columns: 220px 1fr; }
  .map-edit { grid-column: 1 / -1; }
  .test-layout { grid-template-columns: 1fr; }
}

/* ===== 未连接接收器时禁止编辑配置（2026-10-11） =====
 * 没连设备就不该能改参数 —— 否则会以为'改了但没写进去'。
 * 整页（main）变灰且不可点；顶部连接按钮不在 main 里，仍然可点。 */
body.offline main { opacity: .4; filter: grayscale(.35); pointer-events: none; user-select: none; }
body.offline::before {
  content: '未连接接收器 —— 请先点右上角「连接接收器」，连上后才能编辑配置';
  position: fixed; left: 50%; top: 62px; transform: translateX(-50%);
  z-index: 60; padding: 8px 16px; border-radius: 8px;
  background: rgba(255, 180, 0, .14); border: 1px solid rgba(255, 180, 0, .45);
  color: #ffcf70; font-size: 13px; white-space: nowrap; pointer-events: none;
}
@media (max-width: 1100px) {
  body.offline::before { top: 116px; }
}
@media (max-width: 600px) {
  body.offline::before {
    top: auto; bottom: 12px; width: max-content; max-width: calc(100vw - 24px);
    white-space: normal; text-align: center;
  }
}


/* ===== 固件更新页（2026-10-11，webflash 独立版合并） =====
 * 豁免 offline 锁定：刷机恰恰发生在接收器不进 HID（ISP 模式）的时候，
 * 整页锁死就永远没法刷。app.js 在切到本页时给 body 加 on-flash。 */
body.offline.on-flash main { opacity: 1; filter: none; pointer-events: auto; user-select: auto; }
body.offline.on-flash::before { display: none; }

.flash-layout { display: grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); gap: 14px; max-width: 1180px; margin: 0 auto; }
.fw-flash-action { margin-top: 12px; }
@media (max-width: 960px) { .flash-layout { grid-template-columns: 1fr; } }
/* 更新内容（2026-10-15 r45 替换原文件清单表）：滚动盒，版本号加粗，条目小字 */
.fw-notes-h { margin: 12px 0 4px; font-size: 13px; }
.fw-notes { max-height: 240px; overflow-y: auto; margin-top: 2px; padding: 6px 10px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 6px;
  font-size: 12px; line-height: 1.65; }
.fw-notes-ver { font-weight: 600; color: var(--accent); margin-top: 6px; }
.fw-notes-ver:first-child { margin-top: 0; }
.fw-notes ul { margin: 2px 0 4px; padding-left: 18px; color: var(--text); }
.fw-notes li { margin: 1px 0; }
.fw-steps { margin: 4px 0 8px; padding-left: 0; font-size: 13px; line-height: 1.65; color: var(--dim); }
.fw-steps b { color: var(--warn); }
.fw-guide-modal { font-size: 13px; line-height: 1.65; }
.fw-guide-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.fw-guide-facts > div { padding: 9px 11px; background: var(--panel2); border: 1px solid var(--line); border-radius: 7px; }
.fw-guide-facts span { display: block; color: var(--dim); font-size: 11px; }
.fw-guide-facts b { display: block; margin-top: 2px; color: var(--text); }
.fw-guide-steps { margin: 0; padding-left: 22px; }
.fw-guide-steps li + li { margin-top: 7px; }
.fw-guide-risk { margin: 12px 0 0; padding: 9px 11px; color: #e6bd7d; background: #e6a23c10;
  border-left: 3px solid var(--warn); border-radius: 4px; }
@media (max-width: 520px) { .fw-guide-facts { grid-template-columns: 1fr; } }

/* 页签上的「有可刷版本」黄点（JS 用 hidden 属性控制显隐，
 * .upd-dot 的 display:inline-block 会盖掉 UA 的 [hidden] 规则，必须显式补一条） */
.upd-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: var(--warn); margin-left: 5px; vertical-align: 2px;
  box-shadow: 0 0 6px var(--warn); }
.upd-dot[hidden] { display: none; }

/* 接收器当前固件 ≠ 固件包时的「可刷写更新」醒目徽章（page-flash.js 动态插入） */
.fw-upd { color: #1a1d24; background: var(--warn); border-radius: 4px; padding: 1px 7px;
  font-size: 12px; white-space: nowrap; box-shadow: 0 0 8px var(--warn); }

/* 连接状态点：刷写中 */
.dot.busy { background: var(--warn); box-shadow: 0 0 8px var(--warn); }

/* 进度条 */
.fw-prog { position: relative; height: 18px; border-radius: 9px; margin-top: 10px;
  background: #10131a; border: 1px solid #2a2f3a; overflow: hidden; }
.fw-prog #fw-bar { height: 100%; width: 0; border-radius: 8px;
  background: linear-gradient(90deg, #2b6cb0, var(--accent)); transition: width .15s; }
.fw-prog #fw-barTxt { position: absolute; inset: 0; display: flex; align-items: center;
  justify-content: center; font-size: 11px; color: #dfe6f2; text-shadow: 0 1px 2px #000; }

/* 成功 / 失败横幅（默认隐藏，.show 才出现） */
.fw-banner { display: none; margin-top: 10px; padding: 10px 12px; border-radius: 8px;
  font-size: 13px; line-height: 1.6; }
.fw-banner.show { display: block; }
.fw-banner.ok { background: #31c48d18; border: 1px solid #31c48d66; color: #7fe0bb; }
.fw-banner.err { background: #ef535018; border: 1px solid #ef535066; color: #f0a8a6; }
.fw-banner b { color: inherit; }

/* 日志控制台 */
.fw-loghead { display: flex; align-items: center; gap: 8px; margin-top: 14px;
  font-size: 13px; color: var(--muted, #8b93a3); }
.fw-log { height: 220px; overflow-y: auto; margin-top: 6px; padding: 8px 10px;
  background: #0d1015; border: 1px solid #262b35; border-radius: 8px;
  font-family: Consolas, monospace; font-size: 12px; line-height: 1.55; white-space: pre-wrap; }
.fw-log .t { color: #5a6473; }
.fw-log .dim { color: #6b7489; }
.fw-log .ok { color: var(--accent2); }
.fw-log .err { color: var(--danger); }
.fw-log .warn { color: var(--warn); }

/* ===== 日志页（js/page-log.js，2026-10-14） =====
 * 和固件刷写页一样豁免 offline 锁定：接收器掉了正是要看日志、导出日志的时候。 */
body.offline.on-log main { opacity: 1; filter: none; pointer-events: auto; user-select: auto; }
body.offline.on-log::before { display: none; }

.log-layout { display: grid; grid-template-columns: 1fr; gap: 14px; max-width: 1280px; margin: 0 auto; }.lg-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.lg-head h2 { margin: 0; }
.lg-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 10px; margin-top: 10px; }
.lg-card { background: var(--panel2); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; }
.lg-card h3 { margin: 0 0 6px; color: var(--accent); font-size: 13px; }
.lg-row { display: flex; justify-content: space-between; gap: 10px; font-size: 12px; line-height: 1.7; }
.lg-k { color: var(--dim); white-space: nowrap; }
.lg-v { text-align: right; font-family: Consolas, monospace; }
.lg-v.good { color: var(--accent2); }
.lg-v.warn { color: var(--warn); }
.lg-v.bad { color: var(--danger); }
#lg-spark { display: block; width: 100%; height: 54px; margin-top: 6px;
  background: #10131a; border: 1px solid #2a2f3a; border-radius: 6px; }
.lg-legend { margin-top: 2px; }
.lg-sw { display: inline-block; width: 10px; height: 3px; margin: 0 4px 3px 6px; vertical-align: middle; }
.lg-sw.rx { background: #4a9eff; }
.lg-sw.proc { background: #31c48d; }
/* CPU 占用：一行一个任务，标签短、单行不折、百分比右对齐（2026-10-17 精简） */
.lg-cpu-row { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center;
  font-size: 12px; line-height: 1.5; padding: 1px 0; }
.lg-cpu-n { color: var(--dim); white-space: nowrap; }
.lg-cpu-bar { height: 6px; background: #10131a; border-radius: 3px; overflow: hidden; }
.lg-cpu-bar i { display: block; height: 100%; background: var(--accent); }
.lg-cpu-row.idle .lg-cpu-bar i { background: #3b4352; }
.lg-cpu-p { text-align: right; font-family: Consolas, monospace; min-width: 46px; }
.lg-log { height: 460px; }
.lg-log .hb { color: #6b7489; }
.lg-log.quiet .hb { display: none; }

/* ===== 游戏配置（2026-10-16，按键映射页左上 js/game-cfg.js）=====
 * 整页按键映射按名字存成 C 盘用户目录里的一份文件；下拉切换、✎ 改名（和层列表
 * 一个手感）、保存＝接收机 + 本地文件。做成卡片并给个青色描边，在左栏里一眼能看到。 */
.gm-card {
  border: 1px solid #2b6b7a; border-radius: 10px; padding: 10px;
  background: linear-gradient(180deg, #12242c, var(--panel2));
  box-shadow: 0 0 0 1px rgba(80, 200, 220, .12), 0 6px 18px rgba(0, 0, 0, .3);
  margin-bottom: 14px;
}
/* 标题单独一行（用户要的：「游戏按键映射配置」几个字独占一行），行尾挂「＋新建」；
 * 下面一行 = 下拉列表 + 行内 ✎（点了在下拉那一排就地改成输入框） */
.gm-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.gm-head-btns { display: flex; gap: 6px; flex: none; }   /* 标题行右边：⧉ 复制 + 🔄 刷新 + ＋ 新建 */
/* 标题必须**一行**：三个图标挤进来后，卡片只有 220px 宽，字号大一点就折行
 * （2026-10-17 加「复制」图标时踩到，标题折成两行）。 */
.gm-title { margin: 0; color: #6fd7e8; letter-spacing: .5px; font-size: 14px;
            white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.gm-plus {
  flex: none; width: 22px; height: 22px; padding: 0; line-height: 1; cursor: pointer;
  background: #14424c; color: #7fe0f0; border: 1px solid #2b6b7a; border-radius: 6px;
  font-size: 15px; font-weight: 700;
}
.gm-plus:hover:not(:disabled) { background: #1b5665; color: #c9f4ff; }
.gm-plus:disabled { opacity: .45; cursor: default; }
.gm-pick { display: flex; align-items: center; gap: 6px; }
.gm-pick .gm-sel { flex: 1; min-width: 0; }
.gm-chip {
  font-size: 11px; padding: 1px 6px; border-radius: 999px; white-space: nowrap;
  background: #14424c; color: #7fe0f0; border: 1px solid #2b6b7a;
}
.gm-chip[hidden] { display: none; }
.gm-chip.warn { background: #4a3410; color: #ffd479; border-color: #7a5a1e; }
/* r57：说明类黄字（接收机和本机文件对不上时说清楚怎么回事）会比较长，允许折行 */
.gm-chip.note { white-space: normal; border-radius: 8px; line-height: 1.5; }
.gm-link {
  margin-left: 6px; padding: 0; background: none; border: 0; cursor: pointer;
  color: #7fe0f0; font-size: 11px; text-decoration: underline;
}
.gm-link[hidden] { display: none; }
.gm-sel {
  width: 100%; padding: 6px 8px; font-size: 13px; font-weight: 600;
  background: #0d1b21; border: 1px solid #2b6b7a; border-radius: 8px; color: var(--text);
}
.gm-sel:focus { outline: none; border-color: #6fd7e8; }
/* 下拉里那行是占位提示（文件夹空着「暂无配置」/ 读不到接口）而不是真配置时：小字、灰色、
   不加粗 —— 用户 2026-10-16 要的 placeholder 手感。<select> 没有原生 placeholder，
   给 select 和 option 一起上样式（Chromium 画闭合的下拉时用的是被选中那条 option 的样式）。 */
.gm-sel.empty, .gm-sel.empty option {
  color: var(--dim); font-size: 11px; font-weight: 400; letter-spacing: 0;
}
/* r57 方案 B：占位那行和真配置同在一个下拉里（没选中时顶上一条「接收机里这份还没存」）——
   展开后真配置照常显示，只有占位那行是灰字 */
.gm-sel.empty option:not(.ph) { color: var(--text); font-size: 13px; font-weight: 600; }
/* 改名时下拉就地换成输入框（同一排，和层列表一个手感） */
.gm-name-in {
  flex: 1; min-width: 0; background: #0d1b21; border: 1px solid #6fd7e8; border-radius: 8px;
  color: var(--text); font-size: 13px; font-weight: 600; padding: 5px 8px;
}
.gm-name-in[hidden] { display: none; }
.gm-name-in:focus { outline: none; }
.gm-pick .l-ren {
  flex: none; background: transparent; border: 1px solid transparent; border-radius: 5px;
  color: var(--dim); font-size: 12px; line-height: 1; padding: 2px 4px; cursor: pointer;
}
.gm-pick .l-ren:hover:not(:disabled) { color: var(--text); border-color: var(--line); }
.gm-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.gm-meta:empty { display: none; }
.gm-icon { padding: 1px 7px; font-size: 13px; line-height: 1.5; }
.gm-acts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
/* 「导入… / 下载配置 / 📁 / 删除」要挤在一排（卡片内宽只有 ~198px）：这一排按钮收窄一点，「删除」才不会掉到下一行 */
.gm-acts .btn.small { padding: 4px 6px; }
.gm-acts .gm-icon { padding: 1px 4px; }
/* 「保存」单独一行、占满卡片宽度：它是最常用的按钮（用户 2026-10-17 要求） */
.gm-acts-save .btn { width: 100%; }
/* 「音频」面板里那段运行时音频编码，用一条分隔线跟上面的配置字段分开 */
.cfg-divider {
  margin: 12px 0 6px; padding-top: 8px; border-top: 1px solid var(--line);
  color: var(--accent); font-size: 13px; font-weight: 600;
}
/* 手动参数折叠（默认收起）：玩家只看到三个挡位 */
.cfg-details { margin-top: 10px; }
.cfg-details > summary { cursor: pointer; color: var(--dim); font-size: 12px; }
.cfg-details[open] > summary { color: var(--text); }
.gm-card .hint { margin: 8px 0 0; font-size: 11px; line-height: 1.6; }

/* ---------- 测试页：自适应扳机那两行（R3.3c，用户要求横排） ---------- */
.trig-live-row { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.trig-live-row .stick-box { display: flex; gap: 8px; align-items: center; }
.trig-live-row .stick-box > label { white-space: nowrap; }
.trig-live-row .stick-box > code { white-space: nowrap; font-size: 12px; }

/* ===== 教程与资源管理 =====
 * 教程独立离线可看；资源管理是自己的页签，仍走 body.offline main 的默认设备锁。 */
body.offline.on-bili main { opacity: 1; filter: none; pointer-events: auto; user-select: auto; }
body.offline.on-bili::before { display: none; }

.bili-layout { max-width: 1180px; margin: 0 auto; }
#resource-mount { margin-top: 14px; }
.bili-btn { display: inline-block; padding: 10px 20px; font-size: 15px; font-weight: 600; text-decoration: none; }
.bili-embed {
  position: relative; width: 100%; aspect-ratio: 16 / 9; margin-top: 12px;
  background: #000; border: 1px solid var(--line); border-radius: 9px; overflow: hidden;
}
.bili-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
