/* ===== 测试页专用样式 ===== */
#test {
  width: 2000px;
  min-height: 800px;
  padding: 20px;
  margin: 0 auto;
}
.test-page-title {
  font-size: 22px; font-weight: 600; color: #333;
  margin: 0 0 20px; padding-bottom: 20px; border-bottom: 1px solid #e8e8e8;
}
.test-header-line {
  display: flex; align-items: center; gap: 16px; margin-bottom: 24px;
}
.test-device-tag {
  display: inline-block; padding: 8px 24px; background: #f5f5f5;
  border-radius: 24px; font-size: 18px; color: #666;
  width: fit-content; 
  line-height: 1.5; white-space: nowrap;
}
.test-activate-hint {
  font-size: 14px; color: #999;
}
.test-main-grid { display: grid; grid-template-columns: 1.3fr 1fr; gap: 28px; }
.test-card {
  background: #fff; border-radius: 12px; padding: 24px 28px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05); box-sizing: border-box; border: 1px solid #f0f0f0;
}

/* ---- 左侧：手柄测试区 ---- */
.gamepad-test-area {
  display: flex; align-items: flex-start; justify-content: space-between;
  min-height: 400px; margin-bottom: 24px;
}
.trigger-bar-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  width: 40px; flex-shrink: 0;
}
.trigger-bar-label { font-size: 14px; color: #666; line-height: 1; font-family: monospace; }
.trigger-bar {
  width: 6px; height: 360px; background: #f0f0f0; border-radius: 3px;
  position: relative; overflow: hidden;
}
.trigger-bar-fill {
  position: absolute; bottom: 0; left: 0; width: 100%; height: 0%;
  background: #1677ff; border-radius: 3px;
}
.gamepad-preview {
  flex: 1; display: flex; justify-content: center; align-items: center; height: 380px;
}
.gp-wrap {
  position: relative; height: 100%; aspect-ratio: 1.6 / 1;
  display: flex; align-items: center; justify-content: center;
}
.gamepad-bg-img { max-height: 100%; max-width: 100%; object-fit: contain; user-select: none; -webkit-user-drag: none; }
.gp-layer { position: absolute; inset: 0; pointer-events: none; }
.gp-key {
  position: absolute; transform: translate(-50%, -50%); width: 9%;
  opacity: 0.25; filter: grayscale(1); transition: opacity 0.08s, filter: 0.08s;
}
.gp-key.on {
  opacity: 1;
  filter: brightness(0) saturate(100%) invert(36%) sepia(89%) saturate(2874%) hue-rotate(201deg) brightness(101%) contrast(101%);
}
.gp-key.gp-trigger {
  filter: brightness(0) saturate(100%) invert(36%) sepia(89%) saturate(2874%) hue-rotate(201deg) brightness(101%) contrast(101%);
}
.gp-key.gp-circle {
  aspect-ratio: 1 / 1; border-radius: 50%;
  background: transparent; opacity: 1; filter: none;
}
.gp-key.gp-circle.on {
  background: #1677ff; opacity: 1; filter: none;
}
.test-btn-group { display: flex; align-items: center; gap: 12px; justify-content: center; flex-wrap: wrap; }
.test-group-label { font-size: 14px; color: #333; margin-right: 4px; }
.test-btn {
  padding: 6px 20px; border: 1px solid #e8e8e8; border-radius: 8px;
  background: #fff; color: #333; font-size: 14px; cursor: pointer; transition: all 0.2s;
}
.test-btn:hover { border-color: #1677ff; color: #1677ff; }
.test-switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; color: #666; }
.test-switch input { display: none; }
.switch-slider {
  position: relative; width: 34px; height: 18px; background: #ccc;
  border-radius: 9px; transition: background 0.2s; flex-shrink: 0;
}
.switch-slider::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
  background: #fff; border-radius: 50%; transition: transform 0.2s;
}
.test-switch input:checked + .switch-slider { background: #1677ff; }
.test-switch input:checked + .switch-slider::after { transform: translateX(16px); }

/* ---- 右侧：摇杆测试区 ---- */
.sticks-test-area { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 20px; height: 100%; width: 100%; }
.stick-row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; width: 100%; }
.stick-item { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.stick-value {
  font-size: 13px; color: #666; background: #f5f5f5; padding: 4px 10px;
  border-radius: 6px; font-family: monospace; line-height: 1.4; text-align: center;
}
.stick-circle {
  position: relative; width: 180px; height: 180px; border: 1px solid #d9d9d9;
  border-radius: 50%; background: #fff; flex-shrink: 0;
}
.stick-cross-h, .stick-cross-v { position: absolute; background: #d9d9d9; }
.stick-cross-h { top: 50%; left: 0; right: 0; height: 1px; transform: translateY(-50%); }
.stick-cross-v { left: 50%; top: 0; bottom: 0; width: 1px; transform: translateX(-50%); }
.stick-center-dot {
  position: absolute; width: 10px; height: 10px; background: #1677ff;
  border-radius: 50%; transform: translate(-50%, -50%); z-index: 2; top: 50%; left: 50%;
}
.stick-dot {
  position: absolute; width: 8px; height: 8px; background: #ef5350;
  border: 1.5px solid #fff; box-sizing: content-box;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.15);
  border-radius: 50%; transform: translate(-50%, -50%); z-index: 2; top: 50%; left: 50%;
}
.stick-dot-line {
  position: absolute; top: 50%; left: 50%; width: 35%; height: 1px;
  background: #1677ff; transform-origin: left center; transform: translateY(-50%) rotate(0deg);
}
.stick-rect {
  position: absolute; width: 0; height: 0;
  background: rgba(128,128,128,0.2); pointer-events: none; z-index: 1;
}
.stick-bottom-switch { display: flex; justify-content: center; align-items: center; gap: 8px; font-size: 14px; color: #333; width: 100%; }
.test-hint { font-size: 13px; color: #999; text-align: center; margin-top: 8px; }
.stick-error-canvas {
  position: absolute; left: 50%; top: 50%; width: 400px; height: 400px;
  transform: translate(-50%, -50%); pointer-events: none; display: none; z-index: 3;
}
.stick-error-canvas.show { display: block; }
.stick-switch-item { white-space: nowrap; }
.stick-switch-divider { width: 1px; height: 18px; background: #e0e0e0; margin: 0 6px; flex-shrink: 0; }

/* 摇杆缩放控件 */
.stick-zoom-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  width: 100%;
}
.zoom-label {
  font-size: 14px;
  color: #333;
  margin-right: 4px;
}
.zoom-btn {
  width: 28px;
  height: 28px;
  border: 1px solid #e8e8e8;
  border-radius: 6px;
  background: #fff;
  font-size: 16px;
  color: #333;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: all 0.2s;
}
.zoom-btn:hover {
  border-color: #1677ff;
  color: #1677ff;
}
.zoom-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.zoom-value {
  min-width: 28px;
  text-align: center;
  font-size: 14px;
  font-family: monospace;
  color: #333;
  font-weight: 500;
}

/* ===== 深色主题适配 ===== */
body.dark-theme .test-page-title { color: #e5e7eb; border-color: #3a3a3a; }
body.dark-theme .test-device-tag { background: #21262d; color: #8b949e; }
body.dark-theme .test-activate-hint { color: #6b7280; }
body.dark-theme .test-card { background: #1f1f1f; border-color: #3a3a3a; box-shadow: none; }
body.dark-theme .test-group-label,
body.dark-theme .stick-bottom-switch { color: #e5e7eb; }
body.dark-theme .stick-switch-divider { background: #3a3a3a; }
body.dark-theme .test-btn { background: #2a2a2a; color: #d1d5db; border-color: #3a3a3a; }
body.dark-theme .test-btn:hover { border-color: #1677ff; color: #1677ff; }
body.dark-theme .test-switch { color: #9ca3af; }
body.dark-theme .switch-slider { background: #4b4b4b; }
body.dark-theme .trigger-bar { background: #2a2a2a; }
body.dark-theme .trigger-bar-label { color: #8b949e; }
body.dark-theme .stick-value { background: #21262d; color: #8b949e; }
body.dark-theme .stick-circle { background: #1f1f1f; border-color: #3a3a3a; }
body.dark-theme .stick-cross-h,
body.dark-theme .stick-cross-v { background: #3a3a3a; }
body.dark-theme .test-hint { color: #8b949e; }
body.dark-theme .zoom-label { color: #e5e7eb; }
body.dark-theme .zoom-btn {
  background: #2a2a2a;
  border-color: #3a3a3a;
  color: #d1d5db;
}
body.dark-theme .zoom-btn:hover {
  border-color: #1677ff;
  color: #1677ff;
}
body.dark-theme .zoom-value { color: #e5e7eb; }

/* ===== 震动测试 卡片（马达波形 + 手动测试） ===== */
.vibration-test-card { margin-top: 24px; }
.vib-test-title {
  font-size: 18px; font-weight: 600; color: #333;
  margin: 0 0 20px;
}
/* 标题行：标题在左，协议相关提示紧跟在标题右侧 */
.vib-title-row {
  display: flex; align-items: baseline; justify-content: flex-start;
  gap: 12px; margin-bottom: 20px;
}
.vib-title-row .vib-test-title { margin: 0; }
.vib-title-hint {
  font-size: 13px; color: #d46b08; line-height: 1.5;
}
.vib-test-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 24px;
  align-items: stretch;
}
.vib-section-label {
  font-size: 14px; color: #666; margin-bottom: 10px;
}
.vib-wave-container {
  width: 100%;
  height: 300px;      /* 固定波形高度 */
  flex: none;
  background: #fff;
  border: 1px solid #f0f0f0;
  border-radius: 8px;
  box-sizing: border-box;
  overflow: hidden;
  position: relative;
}
#vibWaveCanvas { display: block; width: 100%; height: 100%; }

.vib-control-section { display: flex; flex-direction: column; gap: 16px; }
/* 马达波形 / 手动测试 / 预设效果 各一张卡片 */
.vib-wave-section { display: flex; align-self: stretch; }
.vib-wave-card,
.vib-manual-card,
.vib-preset-card {
  display: flex; flex-direction: column; gap: 14px;
  background: #fff; border: 1px solid #e9edf3; border-radius: 12px;
  padding: 20px; box-sizing: border-box;
  box-shadow: 0 2px 10px rgba(16, 24, 40, 0.05);
}
.vib-wave-card { flex: 1; min-width: 0; }
.vib-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 12px; border-bottom: 1px solid #f0f0f0;
}
.vib-card-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 600; color: #333; line-height: 1;
}
.vib-card-title::before {
  content: ''; width: 3px; height: 15px; border-radius: 2px;
  background: #1677ff; flex-shrink: 0;
}
.vib-slider-row {
  display: grid;
  grid-template-columns: 60px 1fr 60px;
  align-items: center;
  gap: 12px;
}
.vib-slider-label { font-size: 14px; color: #333; }
.vib-slider {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; background: #e8e8e8; border-radius: 2px; outline: none; margin: 0;
}
.vib-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; background: #1677ff; border-radius: 50%;
  cursor: pointer; border: 2px solid #fff;
  box-shadow: 0 0 0 1px #d9d9d9;
}
.vib-slider::-moz-range-thumb {
  width: 14px; height: 14px; background: #1677ff; border-radius: 50%;
  cursor: pointer; border: 2px solid #fff;
  box-shadow: 0 0 0 1px #d9d9d9;
}
.vib-slider-val {
  width: 100%; height: 28px; text-align: center; font-size: 14px; color: #333;
  background: #f5f5f5; border: 1px solid #e8e8e8; border-radius: 6px;
  box-sizing: border-box; padding: 0; -moz-appearance: textfield;
}
.vib-slider-val::-webkit-outer-spin-button,
.vib-slider-val::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.vib-btn-row { display: flex; gap: 12px; margin-top: 4px; }
.vib-primary-btn {
  flex: 1; height: 36px; border: none; border-radius: 8px;
  background: #1677ff; color: #fff; font-size: 14px; cursor: pointer;
  transition: background 0.2s;
}
.vib-primary-btn:hover { background: #4096ff; }
.vib-secondary-btn {
  flex: 1; height: 36px; border: 1px solid #e8e8e8; border-radius: 8px;
  background: #fff; color: #333; font-size: 14px; cursor: pointer;
  transition: all 0.2s;
}
.vib-secondary-btn:hover { border-color: #1677ff; color: #1677ff; }

.vib-preset-buttons {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.vib-preset-btn {
  height: 36px; border: 1px solid #1677ff; border-radius: 8px;
  background: #fff; color: #1677ff; font-size: 14px; cursor: pointer;
  transition: all 0.2s;
}
.vib-preset-btn:hover { background: #1677ff; color: #fff; }
.vib-preset-btn.active { background: #1677ff; color: #fff; }

.vib-bottom-row {
  display: flex; align-items: center; gap: 14px; margin-top: 24px;
  padding-top: 16px; border-top: 1px solid #f0f0f0;
  flex-wrap: wrap;
}
.vib-bottom-row .vib-bottom-label { font-size: 14px; color: #333; }
.vib-not-supported {
  display: none; padding: 8px 12px; border-radius: 6px;
  background: #fff2f0; color: #cf1322; font-size: 13px; margin-top: 8px;
}
.vib-not-supported.show { display: block; }

body.dark-theme .vib-test-title { color: #e5e7eb; }
body.dark-theme .vib-title-hint { color: #ffc069; }
body.dark-theme .vib-section-label,
body.dark-theme .vib-slider-label,
body.dark-theme .vib-bottom-row .vib-bottom-label { color: #e5e7eb; }
body.dark-theme .vib-wave-container { background: #1f1f1f; border-color: #3a3a3a; }
body.dark-theme .vib-slider { background: #3a3a3a; }
body.dark-theme .vib-slider-val { background: #21262d; color: #d1d5db; border-color: #3a3a3a; }
body.dark-theme .vib-primary-btn { background: #1677ff; }
body.dark-theme .vib-secondary-btn { background: #2a2a2a; color: #d1d5db; border-color: #3a3a3a; }
body.dark-theme .vib-secondary-btn:hover { border-color: #1677ff; color: #1677ff; }
body.dark-theme .vib-wave-card,
body.dark-theme .vib-manual-card,
body.dark-theme .vib-preset-card { background: #21262d; border-color: #3a3a3a; box-shadow: none; }
body.dark-theme .vib-card-title { color: #e5e7eb; }
body.dark-theme .vib-card-header { border-color: #3a3a3a; }
body.dark-theme .vib-preset-btn { background: #1f1f1f; }
body.dark-theme .vib-preset-btn:hover,
body.dark-theme .vib-preset-btn.active { background: #1677ff; color: #fff; }
body.dark-theme .vib-bottom-row { border-color: #3a3a3a; }
body.dark-theme .vib-not-supported { background: #2a1212; color: #ff7875; }
