/* ====================================================================
 *  TinyMouse Configurator —— 暗色科技主题
 *  设计语言:
 *    - 背景: 深蓝紫渐变 + 微光晕
 *    - 主色: 青蓝 (#22d3ee) 强调, 紫 (#a78bfa) 次强调
 *    - 卡片: 半透明玻璃 + 1px 描边光
 *    - 强反馈: ok=绿, warn=橙, err=粉红
 * ==================================================================== */

:root {
  --bg-0:        #0b0f1a;
  --bg-1:        #111729;
  --bg-2:        #18213a;
  --panel:       rgba(22, 31, 53, 0.72);
  --panel-2:     rgba(31, 42, 70, 0.66);
  --panel-line:  rgba(255, 255, 255, 0.06);
  --panel-glow:  rgba(34, 211, 238, 0.10);

  --txt:         #e6edf6;
  --txt-soft:    #cbd5e1;
  --muted:       #94a3b8;
  --muted-2:     #64748b;

  --pri:         #22d3ee;
  --pri-2:       #06b6d4;
  --pri-ink:     #03212a;
  --acc:         #a78bfa;
  --acc-2:       #8b5cf6;

  --ok:          #34d399;
  --warn:        #fbbf24;
  --err:         #fb7185;

  --rssi-grid:   rgba(255, 255, 255, 0.07);
  --rssi-axis:   #8896b5;
  --rssi-line:   #22d3ee;

  --radius-s:    8px;
  --radius:      12px;
  --radius-l:    18px;

  --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.45),
                 0 1px 0   rgba(255, 255, 255, 0.04) inset;
  --shadow-pop:  0 18px 50px rgba(0, 0, 0, 0.55);

  --mono: ui-monospace, "SF Mono", Menlo, Consolas, "Cascadia Code", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;

  /* 页面宽度与边距：随视口缩放，兼顾手机安全区 */
  --page-max:    1080px;
  --page-pad:    clamp(12px, 3.2vw, 24px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
html, body { margin: 0; padding: 0; }

body {
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--sans);
  color: var(--txt);
  overflow-x: hidden;
  background:
    radial-gradient(1100px 600px at 12% -10%, rgba(34,211,238,0.10), transparent 60%),
    radial-gradient(900px  600px at 90% 10%,  rgba(167,139,250,0.10), transparent 60%),
    radial-gradient(800px  600px at 50% 110%, rgba(34,211,238,0.06), transparent 60%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 40%, var(--bg-0));
  background-attachment: fixed;
}

a { color: var(--pri); text-decoration: none; }
a:hover { text-decoration: underline; }

code, kbd, .mono { font-family: var(--mono); }

kbd {
  display: inline-block;
  padding: 1px 6px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--panel-line);
  border-bottom-width: 2px;
  border-radius: 5px;
  font-size: 0.85em;
  color: var(--txt-soft);
}

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap;
  padding: 12px calc(var(--page-pad) + var(--safe-right)) 12px calc(var(--page-pad) + var(--safe-left));
  background: linear-gradient(180deg, rgba(11,15,26,0.88), rgba(11,15,26,0.4));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--panel-line);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px;
  color: var(--txt); text-decoration: none;
}
.brand:hover { text-decoration: none; }
.brand-logo { width: 30px; height: 30px; filter: drop-shadow(0 0 8px rgba(34,211,238,0.35)); }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 15px; }
.brand-text em {
  font-style: normal; color: var(--muted); font-size: 11px; letter-spacing: 0.8px;
  text-transform: uppercase;
}

.topnav {
  display: flex; align-items: center; gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.navlink {
  padding: 6px 12px; border-radius: 8px; color: var(--txt-soft);
  font-size: 13px; background: transparent; border: 1px solid transparent;
  cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.navlink:hover { background: rgba(255,255,255,0.05); color: var(--txt); text-decoration: none; }
.navlink.danger:hover { color: var(--err); border-color: rgba(251,113,133,0.4); }
.logout-form { margin: 0; }

.userchip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  background: rgba(34,211,238,0.08); border: 1px solid rgba(34,211,238,0.18);
  font-size: 12px; color: var(--txt-soft);
}
.userchip small {
  background: var(--acc-2); color: white;
  padding: 1px 6px; border-radius: 6px; font-size: 10px; letter-spacing: 0.5px;
}

/* ====================================================================
 *  Toast(右上角浮窗)
 * ==================================================================== */
.toast-stack {
  position: fixed;
  top: calc(68px + env(safe-area-inset-top, 0px));
  right: calc(var(--page-pad) + var(--safe-right));
  left: auto;
  z-index: 9000;
  display: flex; flex-direction: column; gap: 10px;
  width: min(360px, calc(100vw - var(--page-pad) * 2 - var(--safe-left) - var(--safe-right)));
  max-width: calc(100vw - 32px);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: grid;
  grid-template-columns: 28px 1fr 24px;
  gap: 10px; align-items: start;
  padding: 11px 12px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-left: 3px solid var(--muted-2);
  border-radius: 12px;
  box-shadow: var(--shadow-pop);
  backdrop-filter: blur(14px);
  color: var(--txt);
  transform: translateX(0);
  opacity: 1;
  animation: toast-in 0.28s ease both;
}
.toast.toast-leaving {
  animation: toast-out 0.25s ease forwards;
}
@keyframes toast-in {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}
@keyframes toast-out {
  from { transform: translateX(0);    opacity: 1; }
  to   { transform: translateX(120%); opacity: 0; }
}
.toast-icon {
  width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-weight: 700; font-size: 13px;
  background: rgba(255,255,255,0.08);
  color: var(--txt);
}
.toast-body { min-width: 0; }
.toast-title { font-weight: 700; font-size: 13.5px; margin-bottom: 2px; }
.toast-msg   { font-size: 12.5px; color: var(--txt-soft); word-break: break-word; }
.toast-close {
  background: transparent; border: none; cursor: pointer;
  color: var(--muted); font-size: 14px; line-height: 1;
  padding: 2px 6px; align-self: start;
}
.toast-close:hover { color: var(--err); }

.toast-success { border-left-color: var(--ok); }
.toast-success .toast-icon { background: rgba(52,211,153,0.18);  color: var(--ok); }
.toast-error   { border-left-color: var(--err); }
.toast-error   .toast-icon { background: rgba(251,113,133,0.18); color: var(--err); }
.toast-warn    { border-left-color: var(--warn); }
.toast-warn    .toast-icon { background: rgba(251,191,36,0.18);  color: var(--warn); }
.toast-info    { border-left-color: var(--pri); }
.toast-info    .toast-icon { background: rgba(34,211,238,0.18);  color: var(--pri); }
.toast-sys     { border-left-color: var(--muted); }
.toast-sys     .toast-icon { background: rgba(255,255,255,0.06); color: var(--muted); }

/* 全局 confirm modal 略微收窄 */
.modal-card-sm { width: 420px; max-width: 96vw; }
.confirm-msg { margin: 0; color: var(--txt-soft); white-space: pre-wrap; line-height: 1.6; }

/* ---------- Footer ---------- */
.footer {
  max-width: var(--page-max);
  margin: 32px auto calc(16px + var(--safe-bottom));
  padding: 0 calc(var(--page-pad) + var(--safe-right)) 0 calc(var(--page-pad) + var(--safe-left));
  color: var(--muted-2); font-size: 12px; text-align: center;
  line-height: 1.6;
}

/* ---------- Layout main ---------- */
.main {
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 20px calc(var(--page-pad) + var(--safe-right)) calc(16px + var(--safe-bottom)) calc(var(--page-pad) + var(--safe-left));
}

/* ====================================================================
 *  AUTH 页面（登录 / 注册 / 改密）
 * ==================================================================== */

.auth-page .main {
  min-height: calc(100vh - 64px - 60px);
  display: flex; align-items: center; justify-content: center;
}
.auth-card {
  width: 100%; max-width: 380px; padding: 28px 28px 22px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(14px);
}
.auth-title {
  margin: 0 0 18px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 24px;
}
.auth-sub, .auth-warn { display: none; }
.auth-alt { margin: 14px 0 0; font-size: 13px; color: var(--muted); text-align: center; }
.auth-card .checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.auth-card .field-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { color: var(--muted); font-size: 12px; }
.field input,
.row input, .row select,
.tm-input,
.modal input[type="text"],
.modal input[type="search"],
.modal input[type="number"],
.evt-rng-input,
.step-delay-wrap input,
.timing-row .tr-input,
.picker-search input,
.custom-hex input,
.mouse-row-slider input[type="number"] {
  background: var(--panel-2);
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  color: var(--txt);
  padding: 9px 12px;
  font: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  color-scheme: dark;
}
.field input:focus,
.row input:focus, .row select:focus,
.tm-input:focus,
.modal input[type="text"]:focus,
.modal input[type="search"]:focus,
.modal input[type="number"]:focus,
.evt-rng-input:focus,
.step-delay-wrap input:focus,
.timing-row .tr-input:focus,
.picker-search input:focus,
.custom-hex input:focus,
.mouse-row-slider input[type="number"]:focus {
  border-color: var(--pri);
  box-shadow: 0 0 0 3px rgba(34,211,238,0.15);
}
.modal input::placeholder,
.picker-search input::placeholder,
.custom-hex input::placeholder {
  color: var(--muted-2);
}
.evt-rng-input,
.step-delay-wrap input,
.timing-row .tr-input {
  font-family: var(--mono);
  font-size: 13px;
}
.modal input[type="number"].evt-rng-input,
.step-delay-wrap input[type="number"] {
  padding: 3px 6px;
  height: 28px;
  line-height: 1.2;
  box-sizing: border-box;
  text-align: center;
  border-radius: 6px;
}
.modal input[type="number"].evt-rng-input:focus,
.step-delay-wrap input[type="number"]:focus {
  border-color: var(--pri);
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.12);
}
input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--pri);
}

/* 隐藏 number 输入框的步进按钮（全站） */
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.checkbox { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; color: var(--txt-soft); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 9px 14px; border-radius: 9px;
  font: 600 13px/1 var(--sans);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.05s, opacity 0.15s;
  user-select: none;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.is-busy { opacity: 0.75; cursor: wait; }

.btn-primary {
  background: linear-gradient(180deg, var(--pri), var(--pri-2));
  color: var(--pri-ink);
  box-shadow: 0 4px 14px rgba(34,211,238,0.30);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }

.btn-ghost {
  background: transparent; color: var(--txt);
  border-color: var(--panel-line);
}
.btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,0.05); border-color: rgba(255,255,255,0.16); }

.btn-danger {
  background: linear-gradient(180deg, #f43f5e, #be123c);
  color: white;
  box-shadow: 0 4px 14px rgba(244,63,94,0.30);
}
.btn-danger:hover:not(:disabled) { filter: brightness(1.08); }

.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 12px; }

/* ====================================================================
 *  Dashboard
 * ==================================================================== */

.dash { display: flex; flex-direction: column; gap: 18px; }

.card {
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(12px);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.card::before {
  /* 卡片上方一条 1px 光带 */
  content: ""; position: absolute; left: 14px; right: 14px; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(34,211,238,0.5), transparent);
  pointer-events: none;
}
.card-head {
  display: flex; align-items: flex-start; gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.card-head .card-title { flex: 1 1 auto; min-width: 0; }
.card-head .card-sub { flex: 1 1 100%; }
.card-head .card-actions { margin-left: auto; }
.card-title {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.2px;
}
.dash .card-sub,
.admin-page .card-sub { display: none; }

/* ---------- Hero / 连接 + INFO ---------- */
.card-hero { padding: 20px 22px; }
.card-head--split {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(280px, 1.2fr);
  gap: clamp(16px, 4vw, 28px);
  margin-bottom: 0;
  align-items: start;
}
.head-block { min-width: 0; }
.head-block--info {
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
}
.hero-left .hero-status {
  display: inline-flex; align-items: center; gap: 10px; margin: 14px 0 6px;
}
.hero-mode {
  display: inline-flex; align-items: center; gap: 10px;
  margin: 6px 0 14px;
  padding: 6px 10px; border-radius: 999px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-line);
  font-size: 12.5px;
}
.mode-label { color: var(--muted); }
.mode-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 10px; border-radius: 999px;
  font-weight: 700; letter-spacing: 0.4px;
  background: rgba(167,139,250,0.12);
  border: 1px solid rgba(167,139,250,0.4);
  color: var(--acc);
}
.mode-badge.mode-mouse {
  background: rgba(34,211,238,0.12);
  border-color: rgba(34,211,238,0.4);
  color: var(--pri);
}
.mode-switch {
  display: inline-flex; align-items: center;
  border: 1px solid var(--panel-line); border-radius: 999px;
  overflow: hidden;
}
.mode-seg {
  appearance: none; cursor: pointer;
  border: 0; background: transparent;
  color: var(--muted);
  padding: 3px 12px; font-size: 12px; font-weight: 600;
  transition: background .15s, color .15s;
}
.mode-seg + .mode-seg { border-left: 1px solid var(--panel-line); }
.mode-seg:hover:not(:disabled) { color: var(--fg); background: rgba(255,255,255,0.05); }
.mode-seg.is-active { background: var(--acc); color: #0b0b12; }
.mode-seg:disabled { opacity: .45; cursor: not-allowed; }
.hero-rename {
  display: inline-flex; align-items: center; gap: 10px;
  margin: 0 0 14px;
  padding: 6px 10px; border-radius: 12px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-line);
  font-size: 12.5px; flex-wrap: wrap;
}
.rename-row { display: inline-flex; align-items: center; gap: 8px; }
.rename-input {
  width: 180px; max-width: 56vw;
  padding: 5px 10px; font-size: 13px;
}
.hero-actions {
  display: flex; gap: 10px;
  flex-wrap: wrap;
}
.hero-actions .btn { flex: 1 1 auto; min-width: 120px; }
.hero-info-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.hero-info-head .btn { margin-left: auto; }
.hero-h { margin: 0; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.7px; }

.info-grid {
  margin: 0; display: grid;
  grid-template-columns: 1fr 1fr; gap: 6px 18px;
}
.info-grid dt { color: var(--muted); font-size: 12px; }
.info-grid dd { margin: 0 0 4px; font-family: var(--mono); font-size: 13px; color: var(--txt); }

.conn-pill {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
  border: 1px solid; background: rgba(255,255,255,0.03);
}
.conn-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }
.conn-off { color: var(--muted); border-color: var(--panel-line); }
.conn-on  { color: var(--ok);    border-color: rgba(52,211,153,0.45); }
.conn-err { color: var(--err);   border-color: rgba(251,113,133,0.45); }
.conn-name { color: var(--muted); font-size: 12.5px; font-family: var(--mono); }

/* ---------- Profile tabs ---------- */
.profile-row {
  display: flex; align-items: flex-start; gap: 14px;
  flex-wrap: wrap;
}
.profile-tabs { display: flex; gap: 8px; flex-wrap: wrap; flex: 1 1 280px; }
.profile-actions {
  display: flex; gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}
.profile-actions .help { margin-left: 2px; }

.profile-tab {
  --tab-color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--panel-line);
  background: var(--panel-2);
  color: var(--txt-soft);
  cursor: pointer; user-select: none;
  font-size: 12.5px; font-weight: 600;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.profile-tab .swatch {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--tab-color);
  box-shadow: 0 0 8px var(--tab-color);
}
.profile-tab:hover:not(:disabled) { background: rgba(255,255,255,0.05); color: var(--txt); }
.profile-tab.selected {
  color: var(--txt);
  border-color: var(--tab-color);
  background: color-mix(in srgb, var(--tab-color) 14%, transparent);
}
.profile-tab.active::after {
  content: "● 活跃"; font-size: 10px; color: var(--ok);
  margin-left: 4px;
}

/* ====================================================================
 *  DPAD: 真实位置 + 短/长按拆分
 * ==================================================================== */
.dpad {
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  padding: 8px 0 4px;
}
.dpad-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-rows: 1fr 1fr 1fr;
  gap: clamp(8px, 2.5vw, 18px);
  width: min(620px, 100%);
  aspect-ratio: 1 / 1;
  max-height: min(620px, 85vw);
}
.dpad-pos { display: flex; align-items: stretch; justify-content: stretch; }
.pos-up     { grid-column: 2; grid-row: 1; }
.pos-left   { grid-column: 1; grid-row: 2; }
.pos-center { grid-column: 2; grid-row: 2; }
.pos-right  { grid-column: 3; grid-row: 2; }
.pos-down   { grid-column: 2; grid-row: 3; }

.keytile {
  display: flex; flex-direction: column;
  gap: 8px; padding: 12px 10px;
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--panel-line);
  border-radius: 16px;
  color: var(--txt);
  width: 100%; height: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.keytile-hd {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  padding-bottom: 2px;
}
.kt-arrow {
  font-size: 22px; color: var(--pri);
  filter: drop-shadow(0 0 8px rgba(34,211,238,0.25));
  line-height: 1;
}
.keytile-center .kt-arrow { color: var(--acc); filter: drop-shadow(0 0 10px rgba(167,139,250,0.35)); }
.kt-name {
  font: 700 11px var(--mono); letter-spacing: 1.2px; color: var(--muted);
}
.keytile-slots {
  display: flex; flex-direction: column; gap: 6px;
  flex: 1; justify-content: center;
}

.slot-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 10px; border-radius: 10px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--panel-line);
  color: var(--txt);
  font: inherit;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
  min-height: 36px;
}
.slot-btn:hover:not(:disabled) {
  border-color: rgba(34,211,238,0.45);
  background: rgba(34,211,238,0.08);
}
.slot-btn:active:not(:disabled) { transform: translateY(1px); }
.slot-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.slot-btn-wide { padding: 8px 12px; }

.slot-tag {
  flex: 0 0 38px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 2px 6px; border-radius: 6px;
  background: rgba(167,139,250,0.15); border: 1px solid rgba(167,139,250,0.35);
  color: var(--acc); font-weight: 700; font-size: 11px; letter-spacing: 0.3px;
}
.slot-btn[data-slot]:nth-child(odd) .slot-tag {
  /* 短按 = 青蓝 */
  background: rgba(34,211,238,0.12);
  border-color: rgba(34,211,238,0.35);
  color: var(--pri);
}

.slot-summary {
  flex: 1; min-width: 0;
  font-family: var(--mono); font-size: 11.5px;
  color: var(--txt-soft);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.slot-summary[data-summary-slot]:empty,
.slot-summary:placeholder-shown { color: var(--muted); }

.slot-locked {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 10px; border-radius: 10px;
  background: rgba(255,255,255,0.02);
  border: 1px dashed var(--panel-line);
  color: var(--muted);
  font-size: 11.5px;
  min-height: 36px;
}
.slot-locked .slot-summary { flex: 1; min-width: 0; }
.slot-locked .slot-tag { background: transparent; border-color: var(--muted-2); color: var(--muted); }

.dpad-tips, .tips-h, .tips-list, .tips-note { display: none !important; }

/* ====================================================================
 *  系统参数 timing
 * ==================================================================== */
.timing-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px;
}
.timing-row {
  display: grid; grid-template-columns: 1fr 130px auto; gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
}
.timing-row .tr-label {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.timing-row .tr-name { color: var(--txt); font-size: 13px; font-weight: 600; }
.timing-row .tr-desc { display: none; }
.timing-row .tr-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.timing-row .tr-input {
  width: 130px;
}
.timing-row .tr-unit { color: var(--muted); font-size: 12px; }
.timing-row .tr-save { white-space: nowrap; }
.timing-row.dirty { border-color: rgba(34,211,238,0.45); }

/* ====================================================================
 *  鼠标参数 mouse
 * ==================================================================== */
.mouse-grid {
  display: flex; flex-direction: column; gap: 10px;
}
.mouse-row {
  display: grid; grid-template-columns: 220px 1fr; gap: 14px;
  align-items: center;
  padding: 10px 12px;
  background: var(--panel-2);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
}
.mouse-row-hd {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.mouse-row-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--txt);
  font-size: 13px;
  font-weight: 600;
}
.mouse-row-tip { display: none; }
.mouse-row-checks .checkbox {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}
.mouse-actions {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: flex-end;
  align-items: center;
  margin-top: 4px;
}
#airCalibBadge { margin-right: auto; }
.mouse-actions .help--actions { margin-left: 4px; }
.mouse-row-body { min-width: 0; }
.mouse-row-checks {
  display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center;
}
.mouse-led-hint {
  flex-basis: 100%;
  margin: 6px 0 0;
}
.mouse-row-checks .mouse-led-hint {
  width: 100%;
}
.mouse-row-slider {
  display: grid; grid-template-columns: 1fr 90px; gap: 12px; align-items: center;
}
.mouse-row-slider input[type=range] {
  width: 100%;
  height: 28px;
  cursor: pointer;
  accent-color: var(--pri);
  -webkit-appearance: auto;
  appearance: auto;
}
body.disconnected .mouse-row-slider input[type=range]:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
.mouse-row-slider input[type=number] {
  font-family: var(--mono);
  font-size: 13px;
  padding: 6px 10px;
  width: 100%;
  box-sizing: border-box;
  text-align: center;
  border-radius: 8px;
}
body.disconnected .mouse-row-slider input[type=number]:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}
.mouse-row.dirty { border-color: rgba(34,211,238,0.45); }

/* ---------- 日志 ---------- */
.log {
  background: #060a14;
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  padding: 10px 12px;
  height: 220px; overflow-y: auto;
  font: 12px var(--mono); line-height: 1.55;
  white-space: pre-wrap; word-break: break-all;
}
.log .tx  { color: var(--pri); }
.log .rx  { color: var(--acc); }
.log .ok  { color: var(--ok); }
.log .err { color: var(--err); }
.log .sys { color: var(--muted); }

/* ====================================================================
 *  Modal / Dialog
 * ==================================================================== */

dialog.modal {
  border: none; padding: 0;
  background: transparent;
  color: var(--txt);
  /* 宽度交给内部卡片决定，避免宽弹窗(680px)溢出固定宽 dialog 被裁剪 */
  width: auto;
  max-width: min(96vw, 720px);
  max-height: min(92vh, 92dvh);
  overflow: visible;
}
dialog.modal::backdrop {
  background: rgba(2, 6, 14, 0.6);
  backdrop-filter: blur(6px);
}
.modal-card {
  margin: 0; display: flex; flex-direction: column;
  width: min(480px, 96vw);
  max-height: min(92vh, 92dvh);
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
}
.modal-card-sm   { width: min(420px, 96vw); }
.modal-card-wide { width: min(680px, 96vw); }
.modal-head, .modal-foot {
  padding: 14px 18px; display: flex; align-items: center;
  flex: 0 0 auto;
}
.modal-head { border-bottom: 1px solid var(--panel-line); }
.modal-foot { border-top: 1px solid var(--panel-line); gap: 10px; justify-content: flex-end; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close {
  margin-left: auto;
  background: transparent; border: none; cursor: pointer;
  color: var(--muted); font-size: 18px; line-height: 1; padding: 4px 8px;
}
.modal-close:hover { color: var(--err); }
/* body 占据剩余空间并内部滚动，保证 head / foot(确认取消) 始终可见 */
.modal-body { padding: 16px 18px; flex: 1 1 auto; min-height: 0; overflow: auto; }

.hint { color: var(--muted); font-size: 12.5px; margin-bottom: 10px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- 固件升级 OTA ---------- */
.ota-body { display: flex; flex-direction: column; gap: 14px; }
.card-head .btn-sm { margin-left: auto; flex-shrink: 0; }

/* 标题旁更新标记 */
.ota-title-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #1a1200;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  border-radius: 999px;
  vertical-align: middle;
  animation: ota-badge-pulse 2s ease-in-out infinite;
}
.ota-title-badge[hidden] {
  display: none !important;
  animation: none;
}
#otaCard.ota-card--update .card-head .card-title { color: var(--txt); }

@keyframes ota-badge-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.88; transform: scale(1.03); }
}

/* 版本概览条 */
.ota-ver-strip {
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px 20px;
  padding: 12px 16px;
  background: var(--panel-2);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-s);
}
.ota-ver-strip--update {
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.42);
  box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.06);
}
.ota-ver-strip--update .ota-ver-value--latest {
  color: #fde68a;
}
.ota-update-badge {
  font-size: 12px;
  padding: 3px 10px;
  animation: ota-badge-pulse 2s ease-in-out infinite;
}
.ota-hint--update {
  color: #fde68a;
  font-weight: 600;
}
.ota-pane--update {
  border-color: rgba(251, 191, 36, 0.45);
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.12), 0 8px 28px rgba(251, 191, 36, 0.08);
}
.ota-pane--update .ota-pane-head {
  background: rgba(251, 191, 36, 0.06);
  box-shadow: inset 3px 0 0 var(--warn);
}
#btnOtaCheckUpdate.ota-check--update {
  color: var(--warn);
  border-color: rgba(251, 191, 36, 0.45);
  animation: ota-badge-pulse 2s ease-in-out infinite;
}
.btn.ota-btn--update:not(:disabled) {
  background: linear-gradient(135deg, #fbbf24, #d97706) !important;
  border-color: rgba(251, 191, 36, 0.55) !important;
  color: #1a1200 !important;
  font-weight: 700;
  animation: ota-btn-pulse 2.2s ease-in-out infinite;
}
@keyframes ota-btn-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); }
  50%      { box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.18); }
}
.ota-ver-item {
  display: flex; flex-direction: column; gap: 3px; min-width: 0;
}
.ota-ver-item--status { margin-left: auto; align-items: flex-end; text-align: right; }
.ota-ver-label { font-size: 11px; color: var(--muted); letter-spacing: 0.02em; }
.ota-ver-value {
  font-family: var(--mono); font-size: 15px; font-weight: 600; color: var(--txt);
  line-height: 1.2;
}
.ota-ver-status { min-height: 22px; display: flex; align-items: center; justify-content: flex-end; }
.ota-ver-arrow { color: var(--muted-2); font-size: 16px; line-height: 1; user-select: none; }
.ota-hint {
  margin: -6px 0 0; padding: 0 2px;
  font-size: 12px; color: var(--muted); line-height: 1.45;
}

/* 历史固件与更新记录 */
.ota-history {
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 0;
  font-size: 13px;
}
.ota-history > summary {
  cursor: pointer; user-select: none;
  padding: 10px 12px;
  font-weight: 600; color: var(--txt);
  list-style: none;
}
.ota-history > summary::-webkit-details-marker { display: none; }
.ota-history > summary::before {
  content: '▸'; display: inline-block; margin-right: 6px;
  color: var(--muted); transition: transform .15s ease;
}
.ota-history[open] > summary::before { transform: rotate(90deg); }
.ota-history-count { color: var(--muted); font-weight: 400; font-size: 12px; }
.ota-history-list {
  max-height: 260px; overflow-y: auto;
  border-top: 1px solid var(--panel-line);
}
.ota-hist-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--panel-line);
}
.ota-hist-item:last-child { border-bottom: 0; }
.ota-hist-item.is-selected {
  background: color-mix(in srgb, var(--acc) 12%, transparent);
  box-shadow: inset 3px 0 0 var(--acc);
}
.ota-hist-main { flex: 1 1 auto; min-width: 0; }
.ota-hist-ver {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-weight: 600; color: var(--txt);
}
.ota-hist-badge { font-size: 11px; }
.ota-hist-meta { margin-top: 2px; font-size: 12px; color: var(--muted); }
.ota-hist-pick { flex: 0 0 auto; white-space: nowrap; }
.ota-notes-ver { color: var(--muted); font-weight: 400; }

/* 左右双栏 */
.ota-panes {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr);
  align-items: stretch;
  gap: 0;
}
.ota-pane {
  display: flex; flex-direction: column; min-width: 0; min-height: 200px;
  background: var(--panel-2);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  overflow: hidden;
}
.ota-pane-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--panel-line);
  background: rgba(255, 255, 255, 0.02);
}
.ota-pane--online .ota-pane-head { box-shadow: inset 3px 0 0 var(--acc); }
.ota-pane--local  .ota-pane-head { box-shadow: inset 3px 0 0 var(--pri); }
.ota-pane-mark {
  width: 36px; height: 36px; flex-shrink: 0; border-radius: 10px;
  background-position: center; background-repeat: no-repeat; background-size: 18px 18px;
}
.ota-pane-mark--online {
  background-color: rgba(167, 139, 250, 0.12);
  border: 1px solid rgba(167, 139, 250, 0.28);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a78bfa' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z'/%3E%3C/svg%3E");
}
.ota-pane-mark--local {
  background-color: rgba(34, 211, 238, 0.10);
  border: 1px solid rgba(34, 211, 238, 0.28);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2322d3ee' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z'/%3E%3Cpolyline points='14 2 14 8 20 8'/%3E%3C/svg%3E");
}
.ota-pane-head-text { min-width: 0; }
.ota-pane-title { margin: 0; font-size: 14px; font-weight: 600; color: var(--txt); }
.ota-pane-sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); line-height: 1.35; }
.ota-pane-body {
  flex: 1; display: flex; flex-direction: column; gap: 12px;
  padding: 14px;
}
.ota-pane-body > .btn-primary { margin-top: auto; width: 100%; justify-content: center; }

.ota-panes-sep {
  display: flex; align-items: center; justify-content: center;
  position: relative; align-self: stretch;
}
.ota-panes-sep::before {
  content: ""; position: absolute; inset: 12px 50%; width: 1px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, transparent, var(--panel-line) 15%, var(--panel-line) 85%, transparent);
}
.ota-panes-sep span {
  position: relative; z-index: 1;
  padding: 4px 10px; font-size: 11px; font-weight: 600; color: var(--muted);
  background: var(--bg-1); border: 1px solid var(--panel-line); border-radius: 999px;
}

.ota-notes { font-size: 12.5px; color: var(--muted); }
.ota-notes summary { cursor: pointer; color: var(--acc); user-select: none; }
.ota-notes-scroll {
  margin: 8px 0 0;
  max-height: min(220px, 36vh);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-s);
  background: rgba(0, 0, 0, 0.18);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.22) rgba(255, 255, 255, 0.04);
}
.ota-notes-scroll::-webkit-scrollbar { width: 8px; }
.ota-notes-scroll::-webkit-scrollbar-track {
  margin: 4px 0;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 999px;
}
.ota-notes-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.22);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}
.ota-notes-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.32);
  background-clip: padding-box;
}
.ota-notes-body {
  margin: 0;
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  line-height: 1.55;
  color: var(--txt-soft);
  font-family: inherit;
}

.ota-file-row { display: flex; flex-direction: column; gap: 8px; flex: 1; }
.ota-file-name {
  padding: 10px 12px; min-height: 40px;
  display: flex; align-items: center;
  font-size: 12px; font-family: var(--mono); color: var(--muted);
  background: rgba(0, 0, 0, 0.15);
  border: 1px dashed rgba(148, 163, 184, 0.28);
  border-radius: var(--radius-s);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ota-file-name.is-ready {
  color: var(--ok); border-style: solid;
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(52, 211, 153, 0.06);
}
.ota-file-btn { align-self: flex-start; cursor: pointer; margin: 0; }
.ota-file-btn.is-disabled { opacity: 0.45; pointer-events: none; }
.ota-file-input {
  position: absolute; width: 0.1px; height: 0.1px; opacity: 0; overflow: hidden; z-index: -1;
}

.ota-foot {
  display: flex; flex-direction: column; gap: 10px;
  padding-top: 12px; border-top: 1px solid var(--panel-line);
}
.ota-foot-opts {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 20px;
}
.ota-opt { font-size: 12.5px; color: var(--muted); }
.ota-progress { margin: 0; }
.ota-stat, .import-stat { color: var(--muted); font-size: 12.5px; }
.import-meta { color: var(--muted); font-size: 13px; margin-bottom: 12px; }
.import-meta--err { color: var(--err); font-size: 13px; }

/* ---------- 帮助 "?" + 悬浮说明（全站唯一说明入口） ---------- */
.help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  flex: none;
  border-radius: 50%;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: rgba(15, 23, 42, 0.85);
  color: var(--muted);
  font: 700 11px/1 var(--sans);
  cursor: help;
  user-select: none;
  vertical-align: middle;
  transition: color 0.15s, border-color 0.15s, background 0.15s, transform 0.1s;
}
.help:hover, .help:focus-visible {
  color: var(--pri);
  border-color: rgba(34, 211, 238, 0.55);
  background: rgba(34, 211, 238, 0.12);
  outline: none;
  transform: scale(1.06);
}
.help-pop {
  position: fixed;
  z-index: 10000;
  max-width: min(340px, calc(100vw - 24px));
  padding: 10px 13px;
  background: rgba(15, 23, 42, 0.96);
  color: var(--txt-soft);
  border: 1px solid rgba(34, 211, 238, 0.25);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
  font: 400 12.5px/1.55 var(--sans);
  pointer-events: auto;
  white-space: pre-line;
  word-break: break-word;
}
.help-pop[hidden] { display: none; }
.help-pop--below {
  border-color: rgba(167, 139, 250, 0.3);
}

.modal-title {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 16px;
}
.modal-lead {
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}
.modal-lead .help { flex: none; }

.dash .hint,
.dash .hint-sub,
.dash .warn-text { display: none !important; }

.footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.checkbox .help { margin-left: 2px; }

.picker-search {
  display: flex;
  align-items: center;
  gap: 8px;
}
.picker-search input { flex: 1; min-width: 0; }
.picker-empty { color: var(--muted); font-size: 12px; padding: 8px; }

.evt-rng-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.evt-rng-label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.step-count {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.quick summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.custom-hex summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.field-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* ---------- Step 列表（按键编辑器） ---------- */
.step-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.step-row {
  display: grid;
  grid-template-columns: 28px 1fr 152px 32px 32px;
  gap: 8px; align-items: center;
  padding: 8px 10px;
  background: var(--panel-2);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  transition: border-color 0.15s, background 0.15s;
}
.step-row.dragover { border-color: var(--pri); background: rgba(34,211,238,0.08); }
.step-row .handle {
  cursor: grab; color: var(--muted-2); text-align: center;
  user-select: none; font-size: 16px; padding: 2px;
}
.step-row .handle:active { cursor: grabbing; }
.step-pick {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--panel-line);
  color: var(--txt);
  padding: 6px 10px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  font: inherit; cursor: pointer;
  overflow: hidden;
}
.step-pick:hover { border-color: rgba(34,211,238,0.4); }
.step-pick .pick-label { color: var(--txt); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.step-pick .pick-code  { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.step-pick.empty .pick-label { color: var(--muted); }
.step-delay-wrap { display: flex; align-items: center; gap: 4px; }
.step-delay-wrap input { width: 54px; min-width: 0; }
.step-delay-wrap .d-sep { color: var(--muted); font-size: 12px; }
.step-delay-wrap .unit { color: var(--muted); font-size: 11px; }

/* ---------- 随机时长 / 按住范围 面板 ---------- */
.evt-rng {
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  background: rgba(255,255,255,0.02);
}
.evt-rng.is-random { border-color: rgba(96,165,250,0.45); }
.evt-rng-toggle {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: 13px; line-height: 1.4;
}
.evt-rng-toggle input { width: 16px; height: 16px; flex: none; }
.evt-rng-row {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 10px;
}
.evt-rng-label { color: var(--muted); font-size: 12.5px; min-width: 60px; }
.evt-rng-input { width: 72px; min-width: 0; }
.evt-rng-sep { color: var(--muted); }
.evt-rng .unit { color: var(--muted); font-size: 11px; }
.hint-sub { margin: 8px 0 0; font-size: 11.5px; }
.step-act {
  background: transparent; border: 1px solid var(--panel-line);
  color: var(--muted); cursor: pointer; border-radius: 8px; padding: 6px 0;
}
.step-act:hover { color: var(--err); border-color: rgba(251,113,133,0.4); }
.step-act:disabled { opacity: 0.4; cursor: not-allowed; }

.step-actions {
  display: flex; align-items: center; gap: 10px; margin-top: 12px;
}
.step-actions .step-count { margin-left: auto; color: var(--muted); font-size: 12px; }

.quick { margin-top: 14px; }
.quick summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
.quick-grid {
  margin-top: 10px;
  display: grid; gap: 6px;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
}
.quick-grid button {
  background: var(--panel-2);
  border: 1px solid var(--panel-line);
  color: var(--txt-soft);
  padding: 6px 8px;
  font-size: 12px;
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
}
.quick-grid button:hover { border-color: rgba(34,211,238,0.4); color: var(--txt); }

/* ---------- HID Picker ---------- */
.picker-search { margin-bottom: 12px; }
.picker-search input { width: 100%; }

.picker-layout {
  display: grid; grid-template-columns: 160px 1fr; gap: 12px;
  min-height: 320px;
}
.picker-tabs { display: flex; flex-direction: column; gap: 4px; }
.picker-tab {
  background: transparent; color: var(--txt-soft);
  border: 1px solid transparent;
  padding: 7px 10px; border-radius: 8px;
  text-align: left; font-size: 12.5px; cursor: pointer;
}
.picker-tab:hover { background: rgba(255,255,255,0.05); color: var(--txt); }
.picker-tab.selected {
  background: rgba(34,211,238,0.10);
  border-color: rgba(34,211,238,0.30);
  color: var(--txt);
}

.picker-list { display: flex; flex-direction: column; gap: 4px; max-height: 360px; overflow: auto; padding-right: 4px; }
.picker-item {
  display: grid; grid-template-columns: 1fr 88px;
  gap: 8px;
  background: var(--panel-2);
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  padding: 7px 10px;
  cursor: pointer; user-select: none;
  font-size: 12.5px;
  color: var(--txt);
}
.picker-item:hover { border-color: rgba(34,211,238,0.4); background: rgba(34,211,238,0.06); }
.picker-item.selected {
  border-color: var(--pri);
  background: rgba(34,211,238,0.14);
  box-shadow: 0 0 0 1px var(--pri) inset;
}
.picker-item .pi-label { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.picker-item .pi-name  { font-weight: 600; color: var(--txt); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-item .pi-desc  { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-item .pi-code  { color: var(--pri); font: 11px var(--mono); justify-self: end; align-self: center; }

.picker-preview {
  margin-top: 12px; padding: 8px 12px;
  background: rgba(34,211,238,0.08);
  border: 1px solid rgba(34,211,238,0.30);
  border-radius: 10px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px;
}
.picker-preview .pp-label { color: var(--muted); font-size: 12px; }
.picker-preview .pp-name { color: var(--txt); font-weight: 600; flex: 1; }
.picker-preview .pp-code { color: var(--pri); font-family: var(--mono); font-size: 12px; }

.custom-hex { margin-top: 14px; padding-top: 10px; border-top: 1px dashed var(--panel-line); }
.custom-hex summary { color: var(--muted); cursor: pointer; font-size: 12.5px; }
.custom-hex .row { margin-top: 8px; }
.custom-hex input { width: 110px; font-family: var(--mono); text-transform: uppercase; }

/* ====================================================================
 *  未连接 disabled overlay
 *  - body.disconnected 时,所有 .card-disable-when-off 半透明,
 *    内部所有 [data-need-conn] 控件已经 disabled。
 *  - 用 ::after 浮一层蒙板加强提示
 * ==================================================================== */
.dash {
  position: relative;
}
.card-disable-when-off {
  position: relative;
  transition: opacity 0.2s;
}
body.disconnected .card-disable-when-off {
  opacity: 0.7;
}
body.disconnected .card-disable-when-off::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: var(--radius-l);
  background: repeating-linear-gradient(
    45deg,
    transparent 0 8px,
    rgba(255,255,255,0.025) 8px 16px);
  pointer-events: none;
}
body.disconnected .slot-btn,
body.disconnected .timing-row .tr-input,
body.disconnected .timing-row .tr-save,
body.disconnected .profile-actions .btn,
body.disconnected .mouse-row input,
body.disconnected .mouse-actions .btn {
  cursor: not-allowed;
}

/* ====================================================================
 *  Admin 页面
 * ==================================================================== */

.admin-page { display: flex; flex-direction: column; gap: 18px; }
.admin-meta {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--muted);
  font-family: var(--mono);
}
.table-empty {
  text-align: center;
  color: var(--muted);
  padding: 24px 12px;
  font-size: 13px;
}
.pager-info {
  color: var(--muted);
  font-size: 12.5px;
  padding: 0 8px;
}
.row-note {
  color: var(--muted-2);
  font-size: 12px;
}

.admin-new-form {
  display: grid;
  grid-template-columns: 1.2fr 1.4fr auto auto auto;
  gap: 8px;
  align-items: center;
}
.admin-new-form .checkbox {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.filter-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 10px;
}
.filter-row .tm-input { min-width: 180px; }

.table-wrap { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: collapse;
  font-size: 13px;
}
.data-table th, .data-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--panel-line);
  text-align: left;
  vertical-align: middle;
}
.data-table thead th {
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  font-weight: 600;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--panel-line);
}
.data-table tbody tr:hover { background: rgba(255,255,255,0.025); }
.data-table tr.row-disabled { opacity: 0.55; }
.data-table td.mono, .mono { font-family: var(--mono); font-size: 12px; }
.data-table .ua-cell {
  max-width: 220px; color: var(--muted);
  font-size: 11px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.data-table .col-actions { width: 280px; }
.data-table .col-actions .inline { display: inline-block; margin: 1px 2px; }
.data-table .col-actions .inline + .inline { margin-left: 4px; }
.data-table .btn-ghost.danger:hover { color: var(--err); border-color: rgba(251,113,133,0.4); }

.badge {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--panel-line);
  color: var(--txt-soft);
  letter-spacing: 0.4px;
  margin-left: 4px;
  vertical-align: middle;
}
.badge.muted  { color: var(--muted); }
.badge.green  { background: rgba(52,211,153,0.12); color: var(--ok);   border-color: rgba(52,211,153,0.35); }
.badge.red    { background: rgba(251,113,133,0.12); color: var(--err);  border-color: rgba(251,113,133,0.35); }
.badge.warn   { background: rgba(251,191,36,0.12); color: var(--warn); border-color: rgba(251,191,36,0.35); }
.badge.purple { background: rgba(167,139,250,0.12); color: var(--acc); border-color: rgba(167,139,250,0.35); }

.pager { display: flex; align-items: center; gap: 10px; margin-top: 12px; justify-content: center; }

/* ---------- 导入进度条 ---------- */
.import-progress { margin-top: 14px; }
.progress-bar {
  height: 8px; border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--panel-line);
  overflow: hidden;
  margin-bottom: 6px;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--pri), var(--acc));
  transition: width 0.2s ease;
}
.warn-text { color: var(--warn); }
.field-label { color: var(--muted); font-size: 12px; margin-bottom: 4px; display: block; }

/* ====================================================================
 *  Responsive — 手机 / 平板 / 桌面
 * ==================================================================== */

/* 大屏：略放宽内容区 */
@media (min-width: 1280px) {
  :root { --page-max: 1180px; }
  .card-head--split { gap: 32px; }
  .timing-grid { grid-template-columns: 1fr 1fr; gap: 12px 20px; }
}

/* 平板及以下 */
@media (max-width: 960px) {
  .card-head--split { grid-template-columns: 1fr; }
  .head-block--info {
    margin-top: 4px;
    padding-top: 16px;
    border-top: 1px solid var(--panel-line);
  }
  .info-grid { grid-template-columns: 1fr 1fr; }
  .timing-grid { grid-template-columns: 1fr; }
  .mouse-row { grid-template-columns: 1fr; gap: 10px; }
  .mouse-row-slider { grid-template-columns: 1fr 88px; }
  .picker-layout { grid-template-columns: 1fr; }
  .picker-tabs { flex-direction: row; flex-wrap: wrap; }
  .profile-actions { margin-left: 0; width: 100%; justify-content: flex-start; }

  .ota-panes {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
  }
  .ota-pane { min-height: 0; }
  .ota-pane--online { border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
  .ota-pane--local {
    border-top-left-radius: 0; border-top-right-radius: 0;
    margin-top: -1px;
  }
  .ota-panes-sep { min-height: 44px; }
  .ota-panes-sep::before {
    inset: 50% 16px; width: auto; height: 1px; transform: translateY(-50%);
    background: linear-gradient(90deg, transparent, var(--panel-line) 8%, var(--panel-line) 92%, transparent);
  }
  .ota-ver-item--status { margin-left: 0; }
}

/* 手机 */
@media (max-width: 640px) {
  .topbar { gap: 8px; padding-top: 10px; padding-bottom: 10px; }
  .brand-text em { display: none; }
  .topnav {
    width: 100%;
    margin-left: 0;
    gap: 6px;
  }
  .navlink { padding: 8px 10px; font-size: 12px; }
  .userchip { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .toast-stack {
    top: auto;
    bottom: calc(12px + var(--safe-bottom));
    right: calc(var(--page-pad) + var(--safe-right));
    left: calc(var(--page-pad) + var(--safe-left));
    width: auto;
  }

  .main { padding-top: 14px; }
  .dash { gap: 14px; }
  .card { padding: 14px 14px; border-radius: var(--radius); }
  .card-title { font-size: 16px; }
  .card-sub { font-size: 12px; line-height: 1.5; }

  .hero-left .hero-status {
    flex-wrap: wrap;
    width: 100%;
  }
  .hero-mode { flex-wrap: wrap; max-width: 100%; }
  .hero-actions { width: 100%; }
  .hero-actions .btn { flex: 1 1 calc(50% - 5px); min-width: 0; }

  .info-grid { grid-template-columns: 1fr; gap: 4px 0; }
  .info-grid dt { margin-top: 6px; }
  .info-grid dd { margin-bottom: 2px; }

  .profile-row { flex-direction: column; align-items: stretch; }
  .profile-tabs { width: 100%; }
  .profile-tab { flex: 1 1 calc(50% - 4px); justify-content: center; min-width: 0; }
  .profile-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .profile-actions .btn { width: 100%; justify-content: center; min-height: 44px; }
  .profile-actions .btn-danger { grid-column: 1 / -1; }

  .dpad { gap: 12px; padding: 0; }
  .dpad-grid {
    width: min(100%, 380px);
    max-height: none;
    margin: 0 auto;
  }
  .keytile { padding: 8px 6px; border-radius: 12px; gap: 6px; }
  .keytile-hd { gap: 4px; }
  .kt-arrow { font-size: 18px; }
  .kt-name { font-size: 10px; }
  .slot-btn { padding: 8px; min-height: 44px; }
  .slot-tag { flex: 0 0 34px; font-size: 10px; padding: 2px 4px; }
  .slot-summary { font-size: 10.5px; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .dpad-tips { padding: 10px 12px; font-size: 12px; }
  .tips-list { padding-left: 16px; font-size: 12px; line-height: 1.65; }

  .timing-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .timing-row .tr-input { width: 100%; }
  .timing-row .tr-save { width: 100%; justify-content: center; min-height: 44px; }

  .mouse-row-checks { gap: 8px 12px; }
  .mouse-row-slider { grid-template-columns: 1fr; gap: 8px; }
  .mouse-row-slider input[type=number] { max-width: 120px; }
  .mouse-actions { justify-content: stretch; }
  .mouse-actions .btn { flex: 1 1 100%; min-height: 44px; }

  .ota-ver-strip {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px;
  }
  .ota-ver-arrow { display: none; }
  .ota-ver-item--status {
    grid-column: 1 / -1; flex-direction: row; align-items: center;
    justify-content: space-between; text-align: left;
  }
  .ota-ver-status { justify-content: flex-start; }

  .log { height: min(220px, 35vh); font-size: 11px; }

  .btn { min-height: 44px; padding: 10px 14px; }
  .btn-sm { min-height: 36px; padding: 7px 10px; }

  dialog.modal[open] {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    width: 100vw;
    max-width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    margin: 0;
    padding: 0;
  }
  .modal-card,
  .modal-card-wide,
  .modal-card-sm {
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - 24px);
    border-radius: var(--radius-l) var(--radius-l) 0 0;
  }
  .modal-head, .modal-foot { padding: 12px 14px; }
  .modal-body { padding: 12px 14px; flex: 1 1 auto; min-height: 0; overflow: auto; }

  .step-row {
    grid-template-columns: 28px 1fr 40px 40px;
    grid-template-rows: auto auto;
    gap: 6px 8px;
  }
  .step-row .handle { grid-row: 1 / 3; align-self: center; }
  .step-row .step-pick { grid-column: 2 / 5; }
  .step-row .step-delay-wrap { grid-column: 2; grid-row: 2; }
  .step-row .step-act:nth-child(4) { grid-column: 3; grid-row: 2; }
  .step-row .step-act:nth-child(5) { grid-column: 4; grid-row: 2; min-height: 40px; }

  .picker-list { max-height: min(360px, 45vh); }
  .picker-item { grid-template-columns: 1fr; gap: 4px; }
  .picker-item .pi-code { justify-self: start; }

  .footer { font-size: 11px; padding-left: 12px; padding-right: 12px; }
}

/* 超小屏 */
@media (max-width: 380px) {
  .profile-tab { flex: 1 1 100%; }
  .profile-actions { grid-template-columns: 1fr; }
  .hero-actions .btn { flex: 1 1 100%; }
  .dpad-grid { width: 100%; }
}

/* Admin 页面 */
@media (max-width: 960px) {
  .admin-new-form { grid-template-columns: 1fr 1fr; }
  .admin-new-form .btn { grid-column: 1 / -1; }
  .data-table .col-actions { width: auto; }
}
@media (max-width: 640px) {
  .admin-new-form { grid-template-columns: 1fr; }
  .filter-row .tm-input { min-width: 0; flex: 1 1 100%; }
  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 8px 6px; }
}

/* ---------- 信号诊断 (RSSI) ---------- */
.rssi-readout { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.rssi-now {
  font: 700 22px var(--mono);
  color: var(--txt);
  letter-spacing: 0.5px;
}
.rssi-meta { margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.rssi-meta #rssiDiscReason { color: var(--txt-soft); }
.rssi-loop-ok  { color: var(--ok); font-family: var(--mono); }
.rssi-loop-bad { color: var(--err); font-family: var(--mono); font-weight: 700; }
.rssi-chart-wrap {
  margin-top: 12px;
  padding: 8px;
  background: var(--panel-2);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius-s);
}
.rssi-chart {
  display: block;
  width: 100%;
  height: 160px;
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
  border: 2px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); background-clip: padding-box; }
