/* =========================================================================
   Hardware testers — Keyboard · Microphone · Camera · Refresh rate
   Prefix: .hw- (shared scaffold) + per-tool prefixes (.kbt- .mct- .cmt- .rrt-)
   ========================================================================= */

/* ---------- Shared scaffold ---------- */
.hw-tool {
  height: 100%;
  overflow-y: auto;
  padding: 28px max(40px, calc((100% - 940px) / 2)) 64px;
}
.hw-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 22px;
}
.hw-head h1 {
  margin: 0; font-size: 22px; font-weight: 700;
  letter-spacing: -0.02em; color: var(--text-hi);
}
.hw-head p { margin: 5px 0 0; font-size: 13px; color: var(--text-muted); max-width: 56ch; }
.hw-head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.hw-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 22px;
}
.hw-panel + .hw-panel { margin-top: 16px; }

.hw-toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 18px;
}
.hw-spacer { flex: 1 1 auto; }

/* Segmented control (layout / mode switches) */
.hw-seg {
  display: inline-flex; padding: 3px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  gap: 2px;
}
.hw-seg button {
  appearance: none; border: 0; background: transparent;
  color: var(--text-lo); font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 7px 14px; border-radius: 6px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background var(--dur-fast), color var(--dur-fast);
}
.hw-seg button .material-symbols-outlined { font-size: 17px; }
.hw-seg button:hover { color: var(--text-hi); }
.hw-seg button.is-active {
  background: var(--color-surface);
  color: var(--text-hi);
  box-shadow: var(--shadow-sm);
}

/* Native select styled to match */
.hw-select {
  appearance: none;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--text-hi); font-family: inherit; font-size: 13px;
  padding: 9px 34px 9px 12px; cursor: pointer; max-width: 320px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 10px center;
}
.hw-select:focus { outline: none; border-color: var(--color-primary); }

/* Stat chips */
.hw-stats { display: flex; gap: 10px; flex-wrap: wrap; }
.hw-stat {
  flex: 1 1 0; min-width: 120px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 13px 15px;
}
.hw-stat-value {
  font-size: 22px; font-weight: 700; color: var(--text-hi);
  letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}
.hw-stat-label {
  font-size: 10.5px; color: var(--text-muted); margin-top: 3px;
  text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600;
}

/* Permission / error / idle banner */
.hw-banner {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 18px 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg);
}
.hw-banner .material-symbols-outlined { font-size: 26px; color: var(--text-lo); flex: none; margin-top: 1px; }
.hw-banner.is-error { border-color: rgba(248,113,113,0.4); background: rgba(248,113,113,0.06); }
.hw-banner.is-error .material-symbols-outlined { color: var(--color-error); }
.hw-banner-title { font-size: 14px; font-weight: 650; color: var(--text-hi); }
.hw-banner-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; line-height: 1.55; }

/* Live dot */
.hw-live {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; color: var(--text-lo);
}
.hw-live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-faint); }
.hw-live.is-on { color: var(--color-success); }
.hw-live.is-on .hw-live-dot { background: var(--color-success); box-shadow: 0 0 0 4px rgba(52,211,153,0.18); animation: hw-pulse 1.6s ease-in-out infinite; }
@keyframes hw-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }

/* =====================================================================
   KEYBOARD TESTER (.kbt-)
   ===================================================================== */
.kbt-board {
  display: flex; flex-direction: column; gap: 7px;
  user-select: none;
}
.kbt-row { display: flex; gap: 7px; }
.kbt-key {
  flex: 1 0 0;
  position: relative;
  min-width: 0;
  height: 50px;
  border: 1.5px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
  color: var(--text-lo);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; line-height: 1.1;
  padding: 2px 4px; text-align: center; overflow: hidden;
  transition: transform 60ms var(--ease-out), background 90ms, border-color 90ms, color 90ms;
}
.kbt-key .kbt-glyph { font-size: 15px; }
.kbt-key .kbt-sub { font-size: 9px; color: var(--text-faint); margin-top: 1px; font-weight: 600; }
.kbt-key.is-tested {
  border-color: rgba(52,211,153,0.5);
  background: rgba(52,211,153,0.10);
  color: var(--color-success);
}
.kbt-key.is-tested .kbt-sub { color: rgba(52,211,153,0.7); }
.kbt-key.is-down {
  border-color: var(--color-primary);
  background: var(--color-primary);
  color: #fff;
  transform: translateY(2px);
  box-shadow: 0 0 0 3px rgba(var(--primary-rgb,127,13,242),0.22);
}
.kbt-key.is-down .kbt-sub { color: rgba(255,255,255,0.8); }

/* Arrow cluster — Up/Down stacked into a half-height column */
.kbt-arrows { display: flex; gap: 7px; flex: 2.2 0 0; }
.kbt-arrows .kbt-key { height: 50px; }
.kbt-arrow-col { display: flex; flex-direction: column; gap: 5px; flex: 1 0 0; }
.kbt-arrow-col .kbt-key { height: 22.5px; }

.kbt-readout {
  display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px;
}
.kbt-readout .hw-stat-value { font-size: 18px; }

.kbt-progress-track {
  height: 7px; border-radius: 999px; background: var(--color-bg);
  border: 1px solid var(--color-border); overflow: hidden; margin-top: 14px;
}
.kbt-progress-fill {
  height: 100%; background: var(--color-success);
  border-radius: 999px; transition: width 200ms var(--ease-out);
}

@media (max-width: 720px) {
  .kbt-key { height: 38px; font-size: 10px; }
  .kbt-key .kbt-glyph { font-size: 12px; }
  .kbt-arrows .kbt-key { height: 38px; }
  .kbt-arrow-col .kbt-key { height: 16.5px; }
}

/* =====================================================================
   MIC TESTER (.mct-)
   ===================================================================== */
.mct-canvas-wrap {
  position: relative;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden; height: 180px;
}
.mct-canvas { display: block; width: 100%; height: 100%; }

.mct-meter {
  display: flex; gap: 3px; align-items: flex-end;
  height: 56px; margin-top: 16px;
}
.mct-meter-seg {
  flex: 1 1 0; border-radius: 2px; background: var(--color-border);
  transition: background 60ms linear, opacity 60ms linear;
}
.mct-level-row { display: flex; align-items: center; gap: 14px; margin-top: 14px; }
.mct-level-num {
  font-family: var(--font-mono); font-size: 30px; font-weight: 700;
  color: var(--text-hi); letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
  min-width: 84px;
}
.mct-level-cap { font-size: 12px; color: var(--text-muted); }

/* =====================================================================
   CAMERA TESTER (.cmt-)
   ===================================================================== */
.cmt-stage {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  background: #000;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.cmt-video { width: 100%; height: 100%; object-fit: contain; display: block; }
.cmt-video.is-mirrored { transform: scaleX(-1); }
.cmt-badge {
  position: absolute; top: 12px; left: 12px;
  display: flex; gap: 8px;
}
.cmt-pill {
  background: rgba(0,0,0,0.6); color: #fff; backdrop-filter: blur(6px);
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 600;
  padding: 5px 10px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
}
.cmt-shot-wrap { margin-top: 16px; }
.cmt-shot-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 600; color: var(--text-muted); margin-bottom: 8px; }
.cmt-shot {
  width: 220px; max-width: 100%; border-radius: var(--radius-md);
  border: 1px solid var(--color-border); display: block;
}

/* =====================================================================
   REFRESH RATE (.rrt-)
   ===================================================================== */
.rrt-hero {
  display: flex; align-items: baseline; gap: 14px;
  padding: 8px 0 20px;
}
.rrt-hz {
  font-family: var(--font-mono); font-size: 84px; font-weight: 700;
  line-height: 0.9; letter-spacing: -0.04em; color: var(--text-hi);
  font-variant-numeric: tabular-nums;
}
.rrt-hz.is-idle { color: var(--text-faint); }
.rrt-unit { font-size: 24px; font-weight: 600; color: var(--text-lo); }
.rrt-graph-wrap {
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); overflow: hidden; height: 120px; margin-top: 6px;
}
.rrt-graph { display: block; width: 100%; height: 100%; }

/* Visual smoothness sweep */
.rrt-sweep-track {
  position: relative; height: 64px; margin-top: 16px;
  background: var(--color-bg); border: 1px solid var(--color-border);
  border-radius: var(--radius-lg); overflow: hidden;
}
.rrt-sweep-bar {
  position: absolute; top: 0; bottom: 0; width: 22%;
  background: linear-gradient(90deg, transparent, var(--color-primary), transparent);
  will-change: transform;
}
.rrt-note { font-size: 12px; color: var(--text-muted); margin-top: 10px; }
