* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: #1e1e24;
  color: #e8e8ec;
  min-height: 100vh;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  background: #26262e;
  border-bottom: 1px solid #333;
}

header h1 { font-size: 18px; font-weight: 600; }

.header-actions { display: flex; gap: 8px; }

.btn {
  background: #3a3a46;
  color: #e8e8ec;
  border: 1px solid #4a4a58;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
}
.btn:hover { background: #4a4a58; }
.btn-primary { background: #3478c9; border-color: #3478c9; }
.btn-primary:hover { background: #2a63a8; }

.status-bar {
  padding: 8px 20px;
  font-size: 13px;
  color: #9a9aa8;
  min-height: 20px;
}
.status-bar.error { color: #e8734a; }

.panel {
  margin: 16px 20px;
  padding: 20px;
  background: #26262e;
  border: 1px solid #333;
  border-radius: 10px;
  max-width: 480px;
}
.panel h2 { font-size: 15px; margin-bottom: 14px; }
.panel label { display: block; font-size: 13px; color: #b8b8c4; margin-bottom: 12px; }
.panel input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  background: #1a1a20;
  border: 1px solid #3a3a46;
  border-radius: 6px;
  color: #e8e8ec;
  font-size: 13px;
}
.settings-note { font-size: 12px; color: #7a7a88; margin-bottom: 14px; line-height: 1.6; }
.panel-actions { display: flex; gap: 10px; }

section { padding: 8px 20px 30px; }
section h2 { font-size: 15px; margin: 12px 0; }
.hint { font-size: 12px; color: #7a7a88; font-weight: normal; margin-left: 8px; }

.device-list { display: flex; flex-wrap: wrap; gap: 14px; }
.device-card {
  background: #26262e;
  border: 1px solid #333;
  border-radius: 10px;
  padding: 16px;
  width: 220px;
  cursor: pointer;
  transition: border-color .15s;
}
.device-card:hover { border-color: #3478c9; }
.device-name { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.device-meta { font-size: 12px; color: #9a9aa8; margin-top: 4px; }
.device-meta.online { color: #4caf7d; }
.device-meta.offline { color: #7a7a88; }

.preset-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 12px 0 16px;
}
.preset-header h2 { flex: 1; }

.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}
.preset-cell {
  height: 88px;
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-shadow: 0 1px 2px rgba(0,0,0,.4);
  transition: transform .1s, filter .1s;
}
.preset-cell:hover:not(:disabled) { transform: scale(1.04); filter: brightness(1.15); }
.preset-cell:active:not(:disabled) { transform: scale(.96); }
.preset-cell.unassigned,
.preset-cell:disabled { opacity: .25; cursor: not-allowed; }

.empty { color: #7a7a88; font-size: 13px; padding: 20px 0; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 60px;
  transform: translateX(-50%);
  background: #000c;
  color: #fff;
  padding: 10px 22px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 99;
}

.hidden { display: none !important; }

/* 扫码配对弹窗 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-box {
  background: #26262e;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 20px;
  width: min(420px, 92vw);
}
.modal-box h2 { font-size: 15px; margin-bottom: 10px; }
.scan-target { font-size: 12px; color: #9a9aa8; margin-bottom: 12px; }

#scanVideo {
  width: 100%;
  border-radius: 8px;
  background: #000;
  aspect-ratio: 4/3;
  object-fit: cover;
}
.scan-hint { font-size: 12px; color: #7a7a88; margin-top: 8px; text-align: center; }

.upload-box {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 120px;
  border: 1px dashed #4a4a58;
  border-radius: 8px;
  color: #9a9aa8;
  font-size: 13px;
  cursor: pointer;
}
.upload-box:hover { border-color: #3478c9; color: #e8e8ec; }
.upload-box input { display: none; }

.scan-status { font-size: 12px; color: #4caf7d; margin: 12px 0; min-height: 16px; line-height: 1.5; }
.scan-status.error { color: #e8734a; }

.btn-unpair,
.btn-rename {
  margin-top: 10px;
  padding: 4px 10px;
  font-size: 12px;
  background: transparent;
}
.btn-unpair { border-color: #5a3a3a; color: #c97a6a; }
.btn-unpair:hover { background: #3a2626; }
.btn-rename { border-color: #3a4a5a; color: #6a9ac9; }
.btn-rename:hover { background: #26303a; }
.device-actions { display: flex; gap: 8px; }
