/* ==========================================================================
   HWCheck – UI Design System
   Conforming strictly to UI-CONSTRAINTS.md and YeuCauGiaoDien.md
   Light theme only | Pure solid colors | Zero gradients | Zero neon | Zero glow
   ========================================================================== */

:root {
  /* Visual Rules (Hard) */
  --bg: #F6F7F9;
  --surface: #FFFFFF;
  --border: #E1E4E9;

  /* Single Accent Colour */
  --accent: #2F5BD3;
  --accent-tint: #E8EEFC;
  --accent-text: #1F43A6;
  --accent-hover: #264bb3;

  /* State Colours */
  --success: #1B6B43;
  --success-banner: #E4F3EB;
  --success-border: #BEE4D0;

  --warning: #7A4F00;
  --warning-banner: #FBEFD5;
  --warning-border: #F3DFB0;

  --danger: #B91C1C;
  --danger-banner: #FEE2E2;
  --danger-border: #FECACA;

  /* Typography & Text */
  --text-main: #111827;
  --text-muted: #5B6472;
  /* Contrast >= 4.5:1 on white */
  --text-inverse: #FFFFFF;

  --font-sans: 'Roboto', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* Radius Rules */
  --radius-sm: 8px;
  /* Small controls, inputs, chips */
  --radius-btn: 10px;
  /* Buttons */
  --radius-card: 14px;
  /* Cards (12-16px) */
  --radius-tag: 999px;
  /* Tags only */

  /* Spacing */
  --spacing-section-desktop: 64px;
  --spacing-section-mobile: 32px;
  --max-content-desktop: 880px;
  --header-height-desktop: 68px;
  --header-height-mobile: 60px;

  /* Legacy token aliases (older pages reference these names) */
  --primary: var(--accent);
  --primary-light: var(--accent-tint);
  --surface-muted: var(--bg);
  --text-subtle: var(--text-muted);
  --unit-brand: var(--accent);
  --unit-primary: var(--accent);
  --unit-primary-light: var(--accent-tint);
  --unit-surface: var(--surface);
  --unit-surface-muted: var(--bg);
  --unit-border: var(--border);
  --unit-text-main: var(--text-main);
  --unit-text-muted: var(--text-muted);
  --unit-text-subtle: var(--text-muted);
  --unit-success: var(--success);
  --unit-radius-md: var(--radius-btn);
  --unit-font-mono: var(--font-mono);
}

/* Base Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  /* Forbidden: transitions and decorative animation */
  transition: none !important;
  animation-duration: 0s !important;
}

html {
  font-size: 16px;
  line-height: 1.5;
  background-color: var(--bg);
  color: var(--text-main);
  scroll-behavior: auto;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Typography Hierarchy */
h1 {
  font-size: 32px;
  line-height: 1.2;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

h2 {
  font-size: 26px;
  line-height: 1.25;
  font-weight: 600;
  color: var(--text-main);
  letter-spacing: -0.01em;
  margin-bottom: 16px;
}

h3 {
  font-size: 20px;
  line-height: 1.3;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
}

p,
li,
table {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-main);
}

.text-muted {
  color: var(--text-muted);
}

.prose {
  max-width: 720px;
  line-height: 1.5;
}

.prose p {
  margin-bottom: 16px;
}

/* Accessibility Focus Ring (Hard Rule) */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* Header (Desktop 68px, Mobile 60px) */
.hw-header {
  height: var(--header-height-desktop);
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
}

.hw-header-inner {
  max-width: 1200px;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: nowrap;
}

.hw-brand {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

.hw-brand-logo {
  height: 38px;
  width: auto;
  display: block;
}

.hw-nav-desktop {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.hw-nav-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.hw-nav-link:hover {
  color: var(--text-main);
  background-color: var(--bg);
  text-decoration: none;
}

.hw-nav-link.active {
  color: var(--accent-text);
  background-color: var(--accent-tint);
  font-weight: 600;
}

.hw-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.hw-lang-selector-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.hw-lang-select {
  height: 36px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--bg);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.hw-lang-tag {
  display: none !important;
}

.hw-mobile-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-main);
}

/* Mobile Drawer */
.hw-mobile-drawer {
  display: none;
  position: fixed;
  top: var(--header-height-mobile);
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 60;
  padding: 16px;
  overflow-y: auto;
}

.hw-mobile-drawer.open {
  display: block;
}

.hw-mobile-drawer a {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-main);
  border-radius: var(--radius-sm);
  min-height: 44px;
}

.hw-mobile-drawer a.active {
  background-color: var(--accent-tint);
  color: var(--accent-text);
  font-weight: 600;
}

/* Main Container */
.hw-main {
  flex: 1;
  width: 100%;
}

/* First-Screen Section (Strictly fits inside 760px desktop & 844px mobile) */
.hw-first-screen {
  max-width: var(--max-content-desktop);
  margin: 0 auto;
  padding: 20px 20px 0 20px;
  display: flex;
  flex-direction: column;
}

.hw-hero-title {
  margin-bottom: 6px;
}

.hw-hero-intro {
  font-size: 15px;
  line-height: 1.5;
  color: var(--text-muted);
  margin-bottom: 14px;
}

/* Device Tabs Bar (Removed duplicate second row as requested) */
.hw-tabs-wrap {
  display: none !important;
}

.hw-tabs {
  display: inline-flex;
  gap: 8px;
  white-space: nowrap;
}

.hw-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  text-decoration: none;
  min-height: 44px;
}

.hw-tab:hover {
  color: var(--text-main);
  border-color: #cbd5e1;
  text-decoration: none;
}

.hw-tab.active {
  color: var(--accent-text);
  background-color: var(--accent-tint);
  border-color: var(--accent);
  font-weight: 600;
}

/* Tool Card (State-driven, 14px radius, 1px solid border, zero shadows) */
.hw-tool-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 24px;
  margin-bottom: 20px;
  position: relative;
  min-height: 340px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* State Visibility Engine */
.hw-state {
  display: none;
  width: 100%;
}

.hw-state.active {
  display: flex;
  flex-direction: column;
}

/* Common State Components */
.hw-state-idle {
  align-items: center;
  text-align: center;
  padding: 12px 8px;
}

.hw-device-icon-box {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  background-color: var(--accent-tint);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.hw-state-heading {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.hw-state-sub {
  font-size: 14px;
  color: var(--text-muted);
  max-width: 500px;
  margin-bottom: 18px;
}

.hw-device-picker-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 18px;
  font-size: 14px;
  color: var(--text-main);
  flex-wrap: wrap;
}

.hw-device-name-badge {
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-weight: 500;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Text link button ("Change") */
.hw-link-btn {
  background: none;
  border: none;
  color: var(--accent);
  text-decoration: underline;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 12px;
  min-height: 44px;
  min-width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.hw-link-btn:hover {
  color: var(--accent-hover);
}

.hw-privacy-note {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Buttons */
.hw-btn-primary {
  height: 60px;
  width: 100%;
  max-width: 420px;
  background-color: var(--accent);
  color: var(--text-inverse);
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius-btn);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0 auto;
}

.hw-btn-primary:hover {
  background-color: var(--accent-hover);
}

.hw-btn-secondary {
  height: 48px;
  padding: 0 20px;
  background-color: var(--surface);
  color: var(--text-main);
  font-size: 15px;
  font-weight: 500;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
}

.hw-btn-secondary:hover {
  background-color: var(--bg);
  border-color: #cbd5e1;
}

.hw-btn-secondary.active {
  background-color: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent-text);
}

/* State 2: Listening / Testing */
.hw-state-testing {
  width: 100%;
}

.hw-testing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}

.hw-tag-listening {
  background-color: var(--accent-tint);
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: var(--radius-tag);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hw-prompt-phrase {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-main);
}

/* Level Meter (16px high, solid fill, dB scale below) */
.hw-meter-wrap {
  margin-bottom: 16px;
  width: 100%;
}

.hw-meter-track {
  height: 16px;
  background-color: #E1E4E9;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  width: 100%;
}

.hw-meter-fill {
  height: 100%;
  width: 0%;
  background-color: var(--accent);
}

.hw-meter-fill.clipping {
  background-color: var(--warning);
}

.hw-meter-scale {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 4px;
  padding: 0 2px;
}

.hw-meter-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  font-size: 13px;
}

.hw-db-readout {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--text-main);
}

/* Waveform Canvas / SVG Container */
.hw-waveform-stage {
  height: 140px;
  background-color: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  margin-bottom: 16px;
  overflow: hidden;
  position: relative;
}

.hw-waveform-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Video Stage (Webcam) */
.hw-video-stage {
  width: 100%;
  max-height: 250px;
  aspect-ratio: 16 / 9;
  background-color: #0F172A;
  border-radius: var(--radius-btn);
  overflow: hidden;
  position: relative;
  margin-bottom: 14px;
}

.hw-video-feed,
#hw-video-feed {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background-color: #0F172A;
}

/* Testing Actions Row */
.hw-testing-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 6px;
}

/* State 3: Result */
.hw-state-result {
  width: 100%;
}

/* Verdict Banner */
.hw-verdict-banner {
  background-color: var(--success-banner);
  border: 1px solid var(--success-border);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.hw-verdict-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.hw-verdict-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background-color: var(--success);
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.hw-verdict-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--success);
  margin-bottom: 2px;
}

.hw-verdict-desc {
  font-size: 14px;
  color: var(--text-main);
}

.hw-verdict-score {
  font-size: 24px;
  font-weight: 700;
  color: var(--success);
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* Verdict Banner Variants (Warning / Alert / Error) */
.hw-verdict-banner.warning {
  background-color: var(--warning-banner);
  border-color: var(--warning-border);
}

.hw-verdict-banner.warning .hw-verdict-icon {
  background-color: var(--warning);
}

.hw-verdict-banner.warning .hw-verdict-title,
.hw-verdict-banner.warning .hw-verdict-score {
  color: var(--warning);
}

.hw-verdict-banner.error {
  background-color: #FEF2F2;
  border-color: #FECACA;
}

.hw-verdict-banner.error .hw-verdict-icon {
  background-color: #DC2626;
}

.hw-verdict-banner.error .hw-verdict-title,
.hw-verdict-banner.error .hw-verdict-score {
  color: #DC2626;
}

/* Tip Box (Max 1 tip at a time, warning tint) */
.hw-tip-box {
  background-color: var(--warning-banner);
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-btn);
  padding: 12px 16px;
  color: var(--warning);
  font-size: 14px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}

.hw-tip-icon {
  flex-shrink: 0;
  margin-top: 1px;
}

/* Result Actions */
.hw-result-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

/* Details Disclosure (Closed by default) */
.hw-details-disclosure {
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background-color: var(--surface);
  margin-top: 10px;
  overflow: hidden;
}

.hw-details-summary {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
  background-color: var(--bg);
}

.hw-details-summary::-webkit-details-marker {
  display: none;
}

.hw-details-summary svg {
  transition: transform 0.2s ease;
}

.hw-details-disclosure[open]>.hw-details-summary svg {
  transform: rotate(180deg);
}

.hw-details-content {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}

.hw-details-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.hw-details-table tr:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

.hw-details-table th,
.hw-details-table td {
  padding: 8px 6px;
  text-align: left;
}

.hw-details-table th {
  color: var(--text-muted);
  font-weight: 500;
  width: 50%;
}

.hw-details-table td {
  color: var(--text-main);
  font-weight: 600;
  font-family: var(--font-mono);
}

/* State 4: Permission Denied */
.hw-state-denied {
  align-items: center;
  text-align: center;
  padding: 12px 8px;
}

.hw-denied-icon-box,
.hw-denied-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  background-color: var(--danger-banner);
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

/* Browser Chips (Chrome/Edge, Safari, Firefox) */
.hw-browser-chips,
.hw-chip-tabs {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.hw-chip-btn {
  height: 44px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background-color: var(--surface);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hw-chip-btn.active {
  background-color: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
}

/* Numbered Steps Box (Max 3 items, short sentences) */
.hw-steps-box {
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 16px 20px;
  text-align: left;
  max-width: 520px;
  width: 100%;
  margin: 0 auto 18px auto;
}

.hw-step-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 14px;
}

.hw-step-item:last-child {
  margin-bottom: 0;
}

.hw-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background-color: var(--border);
  color: var(--text-main);
  font-weight: 600;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

/* State 5: No Device */
.hw-state-nodevice {
  align-items: center;
  text-align: center;
  padding: 12px 8px;
}

.hw-nodevice-icon-box,
.hw-nodevice-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  background-color: var(--warning-banner);
  color: var(--warning);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

/* State Preview Switcher Bar (Hidden by default for clean production UX, enabled only via ?dev=1 or #dev) */
.hw-dev-state-switcher,
.hw-state-switcher {
  display: none !important;
}

body.dev-mode .hw-dev-state-switcher,
body.dev-mode .hw-state-switcher {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding-top: 14px;
  margin-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
  flex-wrap: wrap;
  width: 100%;
}

.hw-dev-state-switcher .hw-switcher-label,
.hw-state-switcher .hw-switcher-label,
.hw-dev-state-switcher>span,
.hw-state-switcher>span {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-right: 4px;
  display: inline-flex;
  align-items: center;
  user-select: none;
}

.hw-state-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-tag);
  padding: 3px 10px;
  font-size: 11.5px;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 500;
  font-family: inherit;
  line-height: 1.35;
  transition: all 0.15s ease;
  user-select: none;
  min-height: 26px;
}

.hw-state-pill:hover {
  color: var(--text-main);
  border-color: #CBD5E1;
  background-color: var(--bg);
}

.hw-state-pill:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.hw-state-pill.active {
  background-color: var(--accent-tint);
  color: var(--accent-text);
  border-color: var(--accent);
  font-weight: 600;
}

.hw-next-tool {
  max-width: var(--max-content-desktop);
  margin: 0 auto 32px auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-muted);
}

.hw-next-tool a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
}

.hw-next-tool a:hover {
  text-decoration: underline;
}

/* Next-Tool Link Card (Appears after result or below tool card) */
.hw-next-tool-card {
  max-width: var(--max-content-desktop);
  margin: 0 auto 32px auto;
  padding: 0 20px;
}

.hw-next-tool-inner {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  text-decoration: none;
}

.hw-next-tool-inner:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.hw-next-tool-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
}

.hw-next-tool-arrow {
  color: var(--accent);
  font-weight: 700;
}

/* Below-the-fold content sections */
.hw-content-wrap {
  max-width: var(--max-content-desktop);
  margin: 0 auto;
  padding: 0 20px;
}

.hw-section {
  margin-bottom: var(--spacing-section-desktop);
}

/* Breadcrumb (Visually small, below tool card as per section 4) */
.hw-breadcrumb,
.hw-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.hw-breadcrumb a,
.hw-breadcrumbs a {
  color: var(--text-muted);
}

.hw-breadcrumb a:hover,
.hw-breadcrumbs a:hover {
  color: var(--accent);
}

.hw-breadcrumb-sep,
.hw-sep {
  color: #cbd5e1;
}

/* Troubleshooting Table (Min 4 rows, clean 1px border) */
.hw-table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  background-color: var(--surface);
  margin-top: 14px;
}

.hw-troubleshoot-table,
.hw-trouble-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.hw-troubleshoot-table th,
.hw-trouble-table th {
  background-color: var(--bg);
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hw-troubleshoot-table td,
.hw-trouble-table td {
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.5;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.hw-troubleshoot-table tr:last-child td,
.hw-trouble-table tr:last-child td {
  border-bottom: none;
}

.hw-troubleshoot-table td.symptom,
.hw-trouble-table td.symptom {
  font-weight: 600;
  color: var(--text-main);
  width: 25%;
}

.hw-troubleshoot-table td.cause,
.hw-trouble-table td.cause {
  color: var(--text-muted);
  width: 35%;
}

.hw-troubleshoot-table td.solution,
.hw-trouble-table td.solution {
  color: var(--text-main);
  width: 40%;
}

/* Other Tools Grid (4 columns desktop, 2 columns mobile) */
.hw-tools-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-top: 16px;
}

.hw-tool-item {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 16px;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  min-height: 130px;
}

.hw-tool-item:hover {
  border-color: var(--accent);
  text-decoration: none;
}

.hw-tool-item-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background-color: var(--accent-tint);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.hw-tool-item-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 4px;
}

.hw-tool-item-desc {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* FAQ (Native <details>, first item open, min height 44px) */
.hw-faq-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}

.hw-faq-item {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  overflow: hidden;
}

.hw-faq-summary,
.hw-faq-question {
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  user-select: none;
}

.hw-faq-summary::-webkit-details-marker,
.hw-faq-question::-webkit-details-marker {
  display: none;
}

.hw-faq-content,
.hw-faq-answer {
  padding: 0 18px 16px 18px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
}

/* Footer (Clean, modern, responsive) */
.hw-footer {
  background-color: var(--surface);
  border-top: 1px solid var(--border);
  padding: 32px 20px 24px 20px;
  margin-top: auto;
}

.hw-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hw-footer-links {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.hw-footer-links a {
  font-size: 13px;
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.hw-footer-links a:hover {
  color: var(--accent);
}

.hw-footer-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.hw-footer-copy {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Footer Drop-Up Language Selector */
.hw-lang-dropup {
  position: relative;
  display: inline-block;
  font-family: var(--font-sans);
}

.hw-lang-dropup-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background-color: var(--surface);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn, 8px);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease;
  user-select: none;
  line-height: 1.4;
}

.hw-lang-dropup-btn:hover {
  background-color: #F8FAFC;
  border-color: var(--accent);
  color: var(--accent);
}

.hw-lang-dropup-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.hw-lang-icon {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: color 0.18s ease;
}

.hw-lang-dropup-btn:hover .hw-lang-icon {
  color: var(--accent);
}

.hw-dropup-chevron {
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.18s ease;
}

.hw-lang-dropup-btn:hover .hw-dropup-chevron {
  color: var(--accent);
}

/* Drop-Up State (Open) */
.hw-lang-dropup.open .hw-dropup-chevron {
  transform: rotate(180deg);
  color: var(--accent);
}

.hw-lang-dropup.open .hw-lang-dropup-btn {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 91, 211, 0.12);
  color: var(--accent);
}

.hw-lang-dropup.open .hw-lang-icon {
  color: var(--accent);
}

/* Drop-Up Menu: floats upwards above the button */
.hw-lang-dropup-menu {
  position: absolute;
  bottom: calc(100% + 8px);
  right: 0;
  min-width: 170px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 10px 25px -5px rgba(15, 23, 42, 0.12), 0 8px 10px -6px rgba(15, 23, 42, 0.08);
  z-index: 1050;
  opacity: 0;
  visibility: hidden;
  transform: translateY(6px);
  transition: opacity 0.18s cubic-bezier(0.16, 1, 0.3, 1), transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.18s ease;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hw-lang-dropup.open .hw-lang-dropup-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.hw-lang-dropup:focus-within .hw-lang-dropup-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  pointer-events: auto;
}

.hw-lang-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-main);
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
  cursor: pointer;
  white-space: nowrap;
}

.hw-lang-option:hover {
  background-color: #F1F5F9;
  color: var(--accent);
}

.hw-lang-option.active {
  background-color: var(--accent-tint, #E8EEFC);
  color: var(--accent-text, #1F43A6);
  font-weight: 600;
  cursor: default;
}

.hw-lang-check {
  color: var(--accent);
  flex-shrink: 0;
}

/* Speaker / Headphone Channel Test Buttons */
.hw-channel-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.hw-chan-btn {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  min-height: 90px;
  text-align: center;
}

.hw-chan-btn:hover {
  border-color: var(--accent);
}

.hw-chan-btn.active {
  background-color: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent-text);
}

.hw-chan-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background-color: var(--bg);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
}

.hw-chan-btn.active .hw-chan-circle {
  background-color: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent);
}

.hw-chan-label {
  font-weight: 600;
  font-size: 14px;
  color: var(--text-main);
}

/* Screen Reader Notification (Accessibility requirement) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* Responsive Rules */
@media (max-width: 1023px) {
  :root {
    --header-height-desktop: var(--header-height-mobile);
  }

  .hw-header {
    height: var(--header-height-mobile);
  }

  .hw-nav-desktop {
    display: none !important;
  }

  .hw-mobile-toggle {
    display: inline-flex !important;
  }

  .hw-tools-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 639px) {
  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 22px;
  }

  .hw-first-screen {
    padding: 16px 16px 0 16px;
  }

  .hw-tool-card {
    padding: 16px;
    border-radius: 12px;
  }

  .hw-btn-primary {
    max-width: 100%;
  }

  .hw-verdict-banner {
    flex-direction: column;
    align-items: flex-start;
  }

  .hw-verdict-score {
    margin-top: 8px;
    align-self: flex-start;
  }

  .hw-section {
    margin-bottom: var(--spacing-section-mobile);
  }

  .hw-channel-grid {
    grid-template-columns: 1fr;
  }

  .hw-footer-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .hw-footer-bottom {
    flex-direction: column-reverse;
    align-items: flex-start;
    gap: 14px;
    padding-top: 14px;
  }

  .hw-lang-dropup-menu {
    right: auto;
    left: 0;
  }
}

/* Motion Preferences */
@media (prefers-reduced-motion: reduce) {
  .hw-meter-fill {
    transition: none !important;
  }
}

/* ==========================================================================
   Compatibility Styling for Secondary Diagnostic Tools
   Styled with pure solid colors, Light theme, zero gradients, 1px borders
   ========================================================================== */
.unit-topbar {
  display: none !important;
}

.unit-header {
  height: var(--header-height-desktop);
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
}

.unit-header-inner {
  max-width: 1200px;
  height: 100%;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.unit-brand-logo {
  height: 38px;
  width: auto;
  display: block;
}

.unit-nav-desktop {
  display: flex;
  align-items: center;
  gap: 8px;
}

.unit-nav-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.unit-nav-link:hover {
  color: var(--text-main);
  background-color: var(--bg);
  text-decoration: none;
}

.unit-nav-link.active {
  color: var(--accent-text);
  background-color: var(--accent-tint);
  font-weight: 600;
}

.unit-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.unit-lang-pill {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background-color: var(--bg);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: var(--radius-tag);
}

.unit-mobile-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-main);
}

.unit-mobile-menu {
  display: none;
}

.unit-main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 48px 20px;
  width: 100%;
}

.unit-hero {
  margin-bottom: 24px;
}

.unit-hero-title {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
}

.unit-hero-subtitle {
  font-size: 15px;
  color: var(--text-muted);
  max-width: 720px;
  line-height: 1.5;
}

.unit-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.unit-pill-tag {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-text);
  background-color: var(--accent-tint);
  padding: 4px 10px;
  border-radius: var(--radius-tag);
  display: inline-block;
  margin-left: 8px;
}

.unit-workbench {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  margin-bottom: 32px;
}

@media (max-width: 860px) {
  .unit-workbench {
    grid-template-columns: 1fr;
  }
}

.unit-viewport-card,
.unit-card,
.unit-info-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 20px;
  margin-bottom: 16px;
}

.unit-viewport-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.unit-viewport-title {
  font-weight: 600;
  font-size: 16px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.unit-chip {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-tag);
  background-color: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.unit-chip.live {
  background-color: var(--accent-tint);
  color: var(--accent-text);
  border-color: var(--accent);
}

.unit-btn {
  height: 48px;
  padding: 0 20px;
  border-radius: var(--radius-btn);
  font-size: 15px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  border: none;
  text-decoration: none;
}

.unit-btn-primary {
  background-color: var(--accent);
  color: #FFFFFF;
}

.unit-btn-primary:hover {
  background-color: var(--accent-hover);
  text-decoration: none;
}

.unit-btn-secondary {
  background-color: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-main);
}

.unit-btn-secondary:hover {
  background-color: var(--bg);
  text-decoration: none;
}

.unit-btn-sm {
  height: 38px;
  padding: 0 14px;
  font-size: 13px;
}

.unit-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
  gap: 12px;
  flex-wrap: wrap;
}

.unit-controls-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.unit-screen-stage {
  background-color: #0F172A;
  border-radius: var(--radius-btn);
  overflow: hidden;
  position: relative;
}

.unit-video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.unit-video.mirror {
  transform: scaleX(-1);
}

.unit-idle-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  background-color: rgba(15, 23, 42, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  color: #FFFFFF;
}

.unit-idle-overlay.hidden {
  display: none !important;
}

.unit-idle-icon {
  margin-bottom: 12px;
  color: #94A3B8;
}

.unit-idle-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 6px;
}

.unit-idle-copy {
  font-size: 14px;
  color: #94A3B8;
  max-width: 400px;
}

.unit-footer {
  background-color: var(--surface);
  border-top: 1px solid var(--border);
  padding: 32px 20px;
  margin-top: auto;
}

.unit-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.unit-footer-links {
  display: flex;
  gap: 16px;
}

.unit-footer-links a {
  font-size: 13px;
  color: var(--text-muted);
}

.unit-footer-copy {
  font-size: 13px;
  color: var(--text-muted);
}

/* ==========================================================================
   Phase 2 & Phase 3 Component Styles (Keyboard, Mouse, Screen, Gamepad, Touch, etc.)
   ========================================================================== */

/* Keyboard Test Component */
.hw-keyboard-wrap {
  width: 100%;
  overflow-x: auto;
  padding: 12px 0;
  -webkit-overflow-scrolling: touch;
}

.hw-keyboard {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 680px;
  margin: 0 auto;
  user-select: none;
}

.hw-keyboard-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.hw-key {
  height: 40px;
  min-width: 36px;
  padding: 0 8px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.hw-key.active {
  background-color: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent);
}

.hw-key.tested {
  background-color: var(--success-banner);
  border-color: var(--success-border);
  color: var(--success);
}

.hw-key-space {
  flex: 5;
}

.hw-key-wide {
  flex: 1.8;
}

.hw-key-extra-wide {
  flex: 2.2;
}

/* Mouse Test Component */
.hw-mouse-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  padding: 24px;
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.hw-mouse-btn-box {
  width: 90px;
  height: 110px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  color: var(--text-muted);
  user-select: none;
}

.hw-mouse-btn-box.active {
  background-color: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent-text);
}

.hw-mouse-wheel-track {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-family: var(--font-mono);
}

/* Screen Test Component */
.hw-screen-auto-bar {
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 12px 16px;
  margin-bottom: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hw-screen-speed-select {
  height: 38px;
  padding: 0 12px;
  border-radius: var(--radius-btn);
  border: 1px solid var(--border);
  background-color: var(--surface);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
}

.hw-color-picker-input {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
  background-color: transparent;
  vertical-align: middle;
  overflow: hidden;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  box-sizing: border-box;
  display: inline-block;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.hw-color-picker-input:hover {
  transform: scale(1.08);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.hw-color-picker-input::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: 50%;
}

.hw-color-picker-input::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
  padding: 0;
}

.hw-color-picker-input::-moz-color-swatch {
  border: none;
  border-radius: 50%;
  padding: 0;
}

.hw-screen-swatches {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.hw-swatch-btn {
  height: 44px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background-color: var(--surface);
  color: var(--text-main);
  transition: all 0.15s ease;
  text-align: left;
}

.hw-swatch-btn:hover {
  background-color: var(--bg);
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

.hw-swatch-btn.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-tint);
}

.hw-swatch-color-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.18);
  flex-shrink: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Fullscreen Mode & Total Scrollbar Suppression */
html.hw-screen-active,
body.hw-screen-active {
  overflow: hidden !important;
  height: 100% !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

html.hw-screen-active::-webkit-scrollbar,
body.hw-screen-active::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

.hw-screen-fullscreen {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  z-index: 999999;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden !important;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  border: none;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

.hw-screen-fullscreen.active {
  display: flex;
}

.hw-screen-fullscreen::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

:fullscreen,
::backdrop,
:fullscreen body,
html:fullscreen,
body:fullscreen,
.hw-screen-fullscreen:fullscreen {
  overflow: hidden !important;
  scrollbar-width: none !important;
  -ms-overflow-style: none !important;
}

:fullscreen::-webkit-scrollbar,
html:fullscreen::-webkit-scrollbar,
body:fullscreen::-webkit-scrollbar,
.hw-screen-fullscreen:fullscreen::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

/* Fullscreen HUD */
.hw-screen-hud {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(17, 24, 39, 0.90);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: #FFFFFF;
  padding: 10px 18px;
  border-radius: 9999px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.15);
  z-index: 1000000;
  transition: opacity 0.35s ease, transform 0.35s ease;
  user-select: none;
  pointer-events: auto;
  max-width: 92vw;
  flex-wrap: wrap;
  justify-content: center;
}

.hw-screen-hud.hw-hud-hidden {
  opacity: 0;
  pointer-events: none;
  transform: translateX(-50%) translateY(14px);
}

.hw-hud-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

.hw-hud-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.7);
  display: inline-block;
  flex-shrink: 0;
}

.hw-hud-title {
  color: #FFFFFF;
  font-weight: 600;
  white-space: nowrap;
}

.hw-hud-counter {
  color: #94a3b8;
  font-size: 11px;
  background-color: rgba(255, 255, 255, 0.12);
  padding: 2px 7px;
  border-radius: 9999px;
  white-space: nowrap;
}

.hw-hud-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hw-hud-btn {
  background-color: rgba(255, 255, 255, 0.14);
  color: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 9999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.15s ease;
}

.hw-hud-btn:hover {
  background-color: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.4);
}

.hw-hud-btn-primary {
  background-color: var(--accent);
  border-color: var(--accent);
}

.hw-hud-btn-primary:hover {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
}

.hw-hud-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  border-left: 1px solid rgba(255, 255, 255, 0.18);
  padding-left: 12px;
}

.hw-hud-hint {
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
}

.hw-hud-exit-btn {
  background-color: rgba(239, 68, 68, 0.85);
  color: #FFFFFF;
  border: none;
  border-radius: 9999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background-color 0.15s ease;
}

.hw-hud-exit-btn:hover {
  background-color: rgb(220, 38, 38);
}

/* Gamepad Component */
.hw-gamepad-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.hw-gamepad-box {
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 16px;
}

.hw-gamepad-btn-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-tag);
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  margin: 4px;
}

.hw-gamepad-btn-pill.pressed {
  background-color: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent);
}

/* Touchscreen Canvas */
.hw-touch-stage {
  width: 100%;
  height: 240px;
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  position: relative;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.hw-touch-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Network Speed, Battery & USB Components */
.hw-metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.hw-metric-grid.cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 639px) {
  .hw-metric-grid.cols-4 {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }
}

.hw-fps-canvas-wrap {
  background-color: #F8FAFC;
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 10px 14px;
  margin-bottom: 12px;
}

.hw-fps-canvas {
  width: 100%;
  height: 70px;
  display: block;
}

.hw-metric-card {
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 16px;
  text-align: center;
}

.hw-metric-val {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
  font-family: var(--font-mono);
  margin-top: 4px;
}

.hw-metric-lbl {
  font-size: 13px;
  color: var(--text-muted);
}

/* Diagnostic Scan Progress Bar */
.hw-scan-progress-wrap {
  margin: 16px 0 20px 0;
  width: 100%;
}

.hw-scan-progress-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
}

.hw-scan-progress-stage {
  font-weight: 500;
  color: var(--text-main);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.hw-scan-progress-pct {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent);
}

.hw-scan-progress-track {
  height: 8px;
  background-color: var(--border);
  border-radius: var(--radius-tag);
  overflow: hidden;
  width: 100%;
}

.hw-scan-progress-fill {
  height: 100%;
  width: 0%;
  background-color: var(--accent);
  border-radius: var(--radius-tag);
  transition: width 0.08s linear;
}

/* Resolution Matrix Table */
.hw-matrix-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.hw-matrix-table th {
  background-color: var(--bg);
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hw-matrix-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-main);
  vertical-align: middle;
}

.hw-matrix-table tr:last-child td {
  border-bottom: none;
}

.hw-chip-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-tag);
}

.hw-chip-status.supported {
  background-color: var(--success-banner);
  color: var(--success);
  border: 1px solid var(--success-border);
}

.hw-chip-status.unsupported {
  background-color: var(--bg);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.hw-chip-status.probing {
  background-color: var(--accent-tint);
  color: var(--accent-text);
  border: 1px solid var(--accent);
}

/* ==========================================================================
   Added: styles for classes used by pages but previously undefined
   ========================================================================== */

/* Mobile drawer must never show on desktop widths */
@media (min-width: 1024px) {

  .hw-mobile-drawer,
  .hw-mobile-drawer.open {
    display: none;
  }
}

.hw-browser-instructions {
  display: none;
  text-align: left;
  max-width: 520px;
  width: 100%;
  margin: 0 auto 18px auto;
}

.hw-browser-instructions.active {
  display: block;
}

.hw-step-list {
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  padding: 16px 20px 16px 38px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-main);
}

.hw-step-list li+li {
  margin-top: 8px;
}

.hw-checklist {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 520px;
  width: 100%;
  margin: 0 auto 18px auto;
  text-align: left;
}

.hw-checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-main);
}

.hw-checklist-item svg {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--accent);
}

.hw-steps-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.hw-step-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 18px;
}

.hw-step-card .hw-step-num {
  margin: 0 0 10px 0;
  background-color: var(--accent-tint);
  color: var(--accent-text);
}

.hw-step-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.hw-step-desc {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-muted);
}

.hw-content-area {
  max-width: var(--max-content-desktop);
  margin: 0 auto;
  padding: 0 20px;
}

.hw-prose-section {
  margin-bottom: var(--spacing-section-desktop);
}

.hw-prose-section h2 {
  margin-bottom: 12px;
}

.hw-prose-section p {
  margin-bottom: 12px;
  color: var(--text-muted);
  line-height: 1.65;
}

.hw-tip-text {
  flex: 1;
}

.tpl-chip,
.aspect-btn {
  cursor: pointer;
}

.hw-filter-slider {
  width: 100%;
  accent-color: var(--accent);
}

/* Legacy "unit-*" page layout (about, contact, privacy, terms, camera viewer/mirror, audio recorder) */
.unit-content-section {
  max-width: var(--max-content-desktop);
  margin: 0 auto 48px auto;
  padding: 0 20px;
  color: var(--text-main);
}

.unit-content-section h2 {
  font-size: 24px;
  line-height: 1.3;
  margin: 32px 0 12px 0;
}

.unit-content-section h3 {
  font-size: 18px;
  line-height: 1.4;
  margin: 24px 0 8px 0;
}

.unit-content-section p,
.unit-content-section li {
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 12px;
}

.unit-content-section ul,
.unit-content-section ol {
  padding-left: 22px;
  margin-bottom: 12px;
}

.unit-breadcrumbs-separator {
  color: #94A3B8;
  margin: 0 6px;
}

.unit-hero-title-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.unit-card-heading {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 12px;
}

.unit-sidebar-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 18px;
}

.unit-specs-list {
  display: flex;
  flex-direction: column;
}

.unit-specs-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.unit-specs-row:last-child {
  border-bottom: none;
}

.unit-specs-key {
  color: var(--text-muted);
}

.unit-specs-val {
  color: var(--text-main);
  font-weight: 600;
  text-align: right;
}

.unit-select {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  color: var(--text-main);
  font-family: inherit;
  font-size: 14px;
}

.btn-rot {
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--surface);
  color: var(--text-main);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
}

.unit-chip.stopped {
  background-color: var(--bg);
  color: var(--text-muted);
  border-color: var(--border);
}

.unit-footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
}

.unit-footer-col h4 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-main);
  margin-bottom: 12px;
}

.unit-footer-col ul {
  list-style: none;
}

.unit-footer-col li {
  margin-bottom: 8px;
  font-size: 14px;
}

.unit-footer-col a {
  color: var(--text-muted);
}

.unit-footer-col a:hover {
  color: var(--accent);
}

.unit-footer-bottom {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-muted);
}

@keyframes hwSpin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.hw-spin {
  animation: hwSpin 0.85s linear infinite;
  display: inline-block;
}

.hw-metric-card.hw-card-scanning {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 2px var(--accent-tint) !important;
  transition: all 0.2s ease;
}

.hw-audit-unlock-banner {
  background-color: var(--accent-tint);
  border: 1px solid var(--accent);
  border-radius: var(--radius-btn);
  padding: 14px 18px;
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* Peripheral Device Row Action Buttons */
.hw-dev-action-btn {
  height: 32px !important;
  min-height: 32px !important;
  padding: 0 14px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  border-radius: 9999px !important;
  white-space: nowrap !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 5px !important;
  text-decoration: none !important;
  cursor: pointer !important;
  transition: all 0.15s ease !important;
  flex-shrink: 0 !important;
  box-sizing: border-box !important;
  line-height: 1 !important;
}

.hw-dev-action-btn-primary {
  background-color: var(--accent) !important;
  color: #ffffff !important;
  border: 1px solid var(--accent) !important;
}

.hw-dev-action-btn-primary:hover {
  background-color: var(--accent-hover) !important;
  border-color: var(--accent-hover) !important;
  color: #ffffff !important;
  text-decoration: none !important;
}

.hw-dev-action-btn-secondary {
  background-color: var(--surface) !important;
  color: var(--text-main) !important;
  border: 1px solid var(--border) !important;
}

.hw-dev-action-btn-secondary:hover {
  background-color: var(--accent-tint) !important;
  border-color: var(--accent) !important;
  color: var(--accent-text) !important;
  text-decoration: none !important;
}

@media (max-width: 860px) {
  .hw-steps-grid {
    grid-template-columns: 1fr;
  }

  .unit-footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .unit-footer-grid {
    grid-template-columns: 1fr;
  }

  .unit-specs-row {
    flex-direction: column;
    gap: 2px;
  }

  .unit-specs-val {
    text-align: left;
  }
}


/* ==========================================================================
   Extended Mini Tools & Hardware Benchmark UI Components
   ========================================================================== */

/* Universal Result & Status Banners */
.hw-result-banner {
  padding: 16px 20px;
  border-radius: var(--radius-card);
  margin-bottom: 24px;
  font-size: 15px;
  line-height: 1.5;
  border: 1px solid transparent;
  transition: opacity 0.2s ease;
}

.hw-result-banner strong {
  font-weight: 600;
}

.hw-banner-success {
  background-color: var(--success-banner);
  border-color: var(--success-border);
  color: #14532D;
}

.hw-banner-running {
  background-color: var(--accent-tint);
  border-color: #BFDBFE;
  color: var(--accent-text);
}

.hw-banner-warning {
  background-color: var(--warning-banner);
  border-color: var(--warning-border);
  color: #78350F;
}

.hw-banner-danger {
  background-color: var(--danger-banner);
  border-color: var(--danger-border);
  color: #991B1B;
}

.hw-banner-info {
  background-color: #F1F5F9;
  border-color: #CBD5E1;
  color: var(--text-main);
}

/* Status Badges & Tags */
.hw-tag-success {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-tag);
  background: var(--success-banner);
  color: var(--success);
  font-size: 13px;
  font-weight: 600;
}

.hw-tag-warning {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-tag);
  background: var(--warning-banner);
  color: var(--warning);
  font-size: 13px;
  font-weight: 600;
}

.hw-tag-danger {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-tag);
  background: var(--danger-banner);
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
}

.hw-tag-neutral {
  display: inline-block;
  padding: 2px 10px;
  border-radius: var(--radius-tag);
  background: var(--bg);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--border);
}

/* Button Interactive States */
.hw-btn-selected {
  background-color: var(--accent) !important;
  color: #FFFFFF !important;
  border-color: var(--accent) !important;
}

.hw-btn-active {
  background-color: #DC2626 !important;
  color: #FFFFFF !important;
  border-color: #DC2626 !important;
}

/* Keyboard Physical Key Chip */
.hw-key-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  height: 42px;
  padding: 0 12px;
  background: #FFFFFF;
  border: 1px solid var(--border);
  border-bottom: 3px solid #CBD5E1;
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* ==========================================================================
   Camera "waiting for picture" overlay (shown by HWCheck_ensureFrames) so a slow
   or silent camera never looks like a dead black box
   ========================================================================== */
.hw-video-wait {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  text-align: center;
  background: rgba(15, 23, 42, 0.78);
  color: #FFFFFF;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  pointer-events: none;
  border-radius: inherit;
}

.hw-video-wait::before {
  content: "";
  flex: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #FFFFFF;
  animation: hw-wait-spin 0.8s linear infinite;
}

@keyframes hw-wait-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .hw-video-wait::before {
    animation: none;
  }
}

/* Bigger touch / click area for sliders (the visible track is unchanged) */
input[type="range"] {
  min-height: 28px;
  cursor: pointer;
}

/* Long list items / links must wrap instead of widening the page on phones */
main li,
main a,
main p {
  overflow-wrap: anywhere;
}

/* Grid items default to min-content width and can push the page wider than a phone screen */
.toc-list>li {
  min-width: 0;
}

/* ==========================================================================
   Unified Extended Tool Components & Mobile-First Refinements
   ========================================================================== */

.hw-body {
  background-color: var(--bg);
  color: var(--text-main);
}

.hw-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
}

.hw-tool-body {
  width: 100%;
}

.hw-text-muted {
  color: var(--text-muted);
}

.hw-metrics-grid {
  display: grid;
  gap: 12px;
}

.hw-guide-section,
.hw-faq-section {
  width: 100%;
}

/* Extended button variants (.hw-btn, .hw-btn-outline, .hw-btn-danger, .hw-btn-success) */
.hw-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border-radius: var(--radius-btn);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid var(--border);
  background-color: var(--surface);
  color: var(--text-main);
  max-width: 100%;
}

.hw-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background-color: var(--accent-tint);
  text-decoration: none;
}

.hw-btn.hw-btn-primary {
  background-color: var(--accent);
  border-color: var(--accent);
  color: #FFFFFF;
}

.hw-btn.hw-btn-primary:hover {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #FFFFFF;
}

.hw-btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 14px;
  background-color: var(--surface);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.hw-btn-outline:hover {
  background-color: var(--accent-tint);
  border-color: var(--accent);
  color: var(--accent-text);
}

.hw-btn-danger {
  background-color: var(--danger) !important;
  border-color: var(--danger) !important;
  color: #FFFFFF !important;
}

.hw-btn-danger:hover {
  background-color: #991B1B !important;
  border-color: #991B1B !important;
  color: #FFFFFF !important;
}

.hw-btn-success {
  background-color: var(--success) !important;
  border-color: var(--success) !important;
  color: #FFFFFF !important;
}

.hw-btn-success:hover {
  background-color: #14532D !important;
  border-color: #14532D !important;
  color: #FFFFFF !important;
}

/* Form inputs & selects */
.hw-input,
.hw-select {
  min-height: 44px;
  padding: 8px 12px;
  background-color: var(--surface);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-btn);
  font-family: var(--font-sans);
  font-size: 14px;
  max-width: 100%;
}

.hw-input:focus,
.hw-select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}

/* Ensure device selector dropdowns and audit action buttons meet 44px touch target */
select.hw-device-name-badge {
  min-height: 44px;
  padding: 8px 12px;
  font-size: 14px;
}

.hw-dev-action-btn {
  min-height: 36px;
}

/* Compact Workbench Layout for First-Screen Compliance (1360x760 Desktop, 390x844 Mobile) */
.unit-main {
  padding-top: 12px;
}

.unit-hero {
  margin-bottom: 10px;
}

.unit-hero-title {
  font-size: 22px;
  margin-bottom: 4px;
}

.unit-hero-desc {
  font-size: 13px;
  line-height: 1.4;
}

.unit-workbench {
  gap: 14px;
  margin-bottom: 24px;
}

.unit-viewport-card {
  padding: 12px 16px;
}

.unit-viewport-header {
  margin-bottom: 8px;
  padding-bottom: 8px;
}

.unit-screen-stage {
  max-height: 260px;
  margin-bottom: 10px;
}

.unit-controls-bar {
  padding-top: 6px;
  gap: 8px;
}

.unit-sidebar-card {
  padding: 12px 14px;
}

.unit-sidebar-title {
  margin-bottom: 6px;
  padding-bottom: 6px;
}

.unit-specs-row {
  padding: 4px 0;
}

/* Mobile Drawer Categorized Navigation */
.hw-drawer-cat {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 12px 4px 12px;
  letter-spacing: 0.05em;
}

.hw-drawer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin-bottom: 6px;
}

@media (max-width: 359px) {
  .hw-drawer-grid {
    grid-template-columns: 1fr;
  }
}

.hw-mobile-drawer-inner a {
  min-height: 44px;
  display: flex;
  align-items: center;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.25;
}

/* Tablet & Mobile Responsive Safeguards */
@media (max-width: 960px) {
  .unit-workbench {
    gap: 10px;
  }

  .unit-screen-stage {
    max-height: 200px;
  }

  /* Compact sidebar on mobile so the primary tool viewport fits first-screen */
  .unit-workbench>aside.unit-sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .unit-sidebar-card {
    padding: 8px 10px;
  }

  .unit-sidebar-title {
    font-size: 11px;
    margin-bottom: 4px;
    padding-bottom: 4px;
  }

  .unit-specs-row {
    padding: 2px 0;
    font-size: 11px;
  }
}

@media (max-width: 639px) {
  .hw-dev-action-btn {
    height: 44px !important;
    min-height: 44px !important;
    padding: 0 12px !important;
  }

  /* Prevent inline min-width on buttons from overflowing 320px-390px cards */
  .hw-btn,
  .hw-btn-primary,
  .hw-btn-secondary,
  .hw-btn-outline,
  .unit-btn {
    min-width: 0 !important;
    max-width: 100%;
  }

  .hw-tool-card {
    padding: 12px !important;
  }

  .hw-result-banner {
    padding: 10px 12px;
    margin-bottom: 12px;
    font-size: 13px;
  }

  .unit-main {
    padding: 6px 12px 28px 12px;
  }

  .unit-breadcrumbs {
    margin-bottom: 4px !important;
    font-size: 11px !important;
  }

  .unit-hero {
    margin-bottom: 6px !important;
  }

  .unit-hero-title-group {
    margin-bottom: 2px !important;
  }

  .unit-hero-title {
    font-size: 17px !important;
    line-height: 1.25 !important;
    margin-bottom: 2px !important;
  }

  .unit-hero-desc,
  .unit-hero-subtitle {
    font-size: 12px !important;
    line-height: 1.35 !important;
    margin-bottom: 4px !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .unit-workbench {
    gap: 8px !important;
    margin-bottom: 16px !important;
  }

  .unit-viewport-card {
    padding: 8px 10px !important;
    margin-bottom: 0 !important;
  }

  .unit-viewport-header {
    margin-bottom: 6px !important;
    padding-bottom: 4px !important;
  }

  .unit-screen-stage {
    max-height: 115px !important;
    margin-bottom: 6px !important;
  }

  .unit-idle-overlay {
    padding: 8px 12px !important;
  }

  .unit-idle-icon {
    margin-bottom: 4px !important;
  }

  .unit-idle-title {
    font-size: 15px !important;
    margin-bottom: 2px !important;
  }

  .unit-idle-copy {
    font-size: 12px !important;
  }

  #audit-device-list {
    max-height: 550px !important;
  }

  .hw-first-screen {
    padding-top: 12px !important;
  }

  .hw-hero-title {
    font-size: 20px !important;
    margin-bottom: 4px !important;
  }

  .hw-hero-intro {
    font-size: 13px !important;
    margin-bottom: 10px !important;
  }

  .unit-controls-bar {
    margin-top: 6px !important;
    padding-top: 4px !important;
    gap: 6px !important;
  }

  .unit-controls-group {
    gap: 6px !important;
  }

  .unit-btn {
    min-height: 44px;
    height: 44px;
    padding: 0 10px;
    font-size: 12px;
  }

  .unit-select {
    min-height: 44px;
    height: 44px;
    padding: 0 8px;
    font-size: 12px;
  }

  .unit-sidebar-card {
    padding: 8px 10px !important;
    margin-bottom: 0 !important;
  }

  .unit-card-heading {
    margin-bottom: 6px !important;
    padding-bottom: 4px !important;
    font-size: 13px !important;
  }

  .hw-audit-subsystems-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px !important;
  }

  .hw-audit-subsystems-grid .hw-metric-card {
    padding: 8px 10px !important;
  }

  .hw-audit-subsystems-grid .hw-metric-val {
    font-size: 13px !important;
  }

  .hw-hide-mobile {
    display: none !important;
  }

  /* Ensure any 2-column or 3-column inline grid inside tool bodies stacks cleanly on small phones */
  .hw-metrics-grid {
    grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)) !important;
    gap: 8px !important;
  }

  canvas {
    max-width: 100%;
  }
}

/* ==========================================================================
   Cute Greeting Cards Studio UI Components
   ========================================================================== */

.gc-cat-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.gc-cat-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  max-width: 100%;
}

.gc-cat-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background-color: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.gc-cat-btn:hover {
  border-color: #F472B6;
  color: #DB2777;
  background-color: #FDF2F8;
}

.gc-cat-btn.active {
  background-color: #DB2777;
  border-color: #DB2777;
  color: #FFFFFF;
}

.gc-card-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 2px 8px 2px;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

.gc-thumb-btn {
  flex: 0 0 auto;
  width: 96px;
  padding: 5px;
  border-radius: 10px;
  border: 2px solid var(--border);
  background-color: var(--surface);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.gc-thumb-btn:hover {
  border-color: #F472B6;
  background-color: #FFF1F2;
}

.gc-thumb-btn.active {
  border-color: #DB2777;
  background-color: #FDF2F8;
}

.gc-thumb-preview {
  width: 82px;
  height: 46px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  background-color: #FFF1F2;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.gc-thumb-preview canvas,
.gc-thumb-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.gc-thumb-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  font-size: 8px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: 4px;
  background-color: #DB2777;
  color: #FFFFFF;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.gc-thumb-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.15;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gc-studio-layout {
  display: grid;
  grid-template-columns: 1fr 270px;
  gap: 12px;
  align-items: start;
}

.gc-stage-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  max-height: 255px;
  width: 100%;
  background-color: #FFF1F2;
  border: 2px solid #FBCFE8;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.gc-countdown-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: none;
  align-items: center;
  justify-content: center;
  background-color: rgba(15, 23, 42, 0.45);
  color: #FFFFFF;
  font-size: 64px;
  font-weight: 800;
  font-family: var(--font-mono);
  pointer-events: none;
}

.gc-controls-card {
  background-color: #FAFAFA;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.gc-control-group-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gc-sticker-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.gc-sticker-btn {
  min-height: 34px;
  padding: 0 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background-color: var(--surface);
  color: var(--text-main);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.gc-sticker-btn:hover {
  border-color: #F472B6;
  background-color: #FDF2F8;
}

.gc-sticker-btn.active {
  background-color: #FCE7F3;
  border-color: #DB2777;
  color: #9D174D;
}

.gc-preset-row {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.gc-preset-chip {
  min-height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid #FBCFE8;
  background-color: #FFF1F2;
  color: #9D174D;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.gc-preset-chip:hover {
  background-color: #FCE7F3;
  border-color: #DB2777;
}

/* Gallery strip below card */
.gc-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.gc-gallery-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  background-color: var(--surface);
  padding: 8px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gc-gallery-card:hover {
  border-color: #DB2777;
  background-color: #FFF1F2;
}

.gc-gallery-card.active {
  border: 2px solid #DB2777;
  background-color: #FDF2F8;
}

@media (max-width: 860px) {
  .gc-studio-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 639px) {
  .gc-cat-btn {
    min-height: 44px;
    padding: 0 12px;
  }

  .gc-thumb-btn {
    width: 88px;
    min-height: 64px;
  }

  .gc-sticker-btn,
  .gc-preset-chip {
    min-height: 44px;
    padding: 0 10px;
  }

  .gc-stage-wrap {
    max-height: 155px;
  }
}