/* ─────────────────────────────────────────────
   Device Test 2026 — modern UI styles
   ───────────────────────────────────────────── */

/* === THEMES === */
:root, [data-theme="dark"] {
  --bg: #0a0d14;
  --bg-2: #0f131c;
  --card: #161a26;
  --card-hover: #1c2030;
  --card2: #1e2333;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.13);
  --text: #e6e9f0;
  --text-soft: #c4cad6;
  --muted: #7b8294;
  --accent: #818cf8;
  --accent-strong: #6366f1;
  --accent-soft: rgba(129, 140, 248, 0.12);
  --emerald: #34d399;
  --emerald-soft: rgba(52, 211, 153, 0.13);
  --rose: #f87171;
  --rose-soft: rgba(248, 113, 113, 0.13);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, 0.13);
  --blue: #60a5fa;
  --blue-soft: rgba(96, 165, 250, 0.13);
  --violet: #a78bfa;
  --cyan: #22d3ee;
  --btn-bg: #232938;
  --btn-bg-hover: #2c3344;
  --btn-border: rgba(255, 255, 255, 0.08);
  --input-bg: #1a1e2a;
  --canvas-bg: #0c0f17;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.5);
  --kb-key-bg: #2d3242;
  --kb-key-border: #434957;
  --kb-key-bottom: #1c1f29;
  --kb-key-text: #d6d9e2;
  --header-bg: rgba(10, 13, 20, 0.78);
}

[data-theme="light"] {
  --bg: #eef1f7;
  --bg-2: #f5f7fb;
  --card: #ffffff;
  --card-hover: #fafbfd;
  --card2: #f3f5f9;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text: #1e293b;
  --text-soft: #334155;
  --muted: #64748b;
  --accent: #6366f1;
  --accent-strong: #4f46e5;
  --accent-soft: rgba(99, 102, 241, 0.10);
  --emerald: #059669;
  --emerald-soft: rgba(5, 150, 105, 0.10);
  --rose: #dc2626;
  --rose-soft: rgba(220, 38, 38, 0.10);
  --amber: #d97706;
  --amber-soft: rgba(217, 119, 6, 0.10);
  --blue: #2563eb;
  --blue-soft: rgba(37, 99, 235, 0.10);
  --violet: #7c3aed;
  --cyan: #0891b2;
  --btn-bg: #f8fafc;
  --btn-bg-hover: #eef2f8;
  --btn-border: rgba(15, 23, 42, 0.12);
  --input-bg: #f8fafc;
  --canvas-bg: #e9ecf3;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 2px 8px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.10);
  --kb-key-bg: #ffffff;
  --kb-key-border: #cbd5e1;
  --kb-key-bottom: #94a3b8;
  --kb-key-text: #0f172a;
  --header-bg: rgba(238, 241, 247, 0.85);
}

/* === RESET === */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, 'Segoe UI', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; }
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
::-webkit-scrollbar-track { background: transparent; }
img { max-width: 100%; display: block; }

/* === LAYOUT === */
.container { max-width: 1180px; margin: 0 auto; padding: 0 1rem; }
.main { padding: 1.5rem 1rem 4rem; }

/* utility classes (kept compatible with HTML) */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 4px; } .gap-2 { gap: 8px; } .gap-3 { gap: 12px; } .gap-4 { gap: 16px; } .gap-5 { gap: 20px; }
.text-center { text-align: center; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.w-full { width: 100%; }
.mt-1 { margin-top: 4px; } .mt-2 { margin-top: 8px; } .mt-3 { margin-top: 12px; } .mt-4 { margin-top: 16px; }
.mb-1 { margin-bottom: 4px; } .mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; } .mb-4 { margin-bottom: 16px; }

.text-xs { font-size: .72rem; }
.text-sm { font-size: .82rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.1rem; }
.text-xl { font-size: 1.4rem; }
.text-2xl { font-size: 1.8rem; }
.font-medium { font-weight: 500; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.text-emerald { color: var(--emerald); }
.text-rose { color: var(--rose); }
.text-amber { color: var(--amber); }
.text-accent { color: var(--accent); }

/* === HEADER — glass sticky === */
.header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--header-bg);
  backdrop-filter: saturate(140%) blur(16px);
  -webkit-backdrop-filter: saturate(140%) blur(16px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}
.header-title h1 {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.header-title p { font-size: .72rem; color: var(--muted); margin: 0; }
.header-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.lang-switch, .theme-switch {
  display: flex; gap: 2px;
  background: var(--card2);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border);
}
.lang-btn, .theme-btn {
  padding: 5px 10px;
  border-radius: 7px;
  font-size: .68rem;
  font-weight: 600;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, background .15s;
}
.lang-btn:hover, .theme-btn:hover { color: var(--text); }
.lang-btn.active, .theme-btn.active {
  background: var(--accent-strong);
  color: #fff;
  box-shadow: 0 1px 3px rgba(99, 102, 241, .35);
}

.dev-tabs {
  display: flex;
  gap: 4px;
  background: var(--card2);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.tab-btn {
  padding: 7px 14px;
  border-radius: 9px;
  font-size: .82rem;
  font-weight: 500;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  transition: all .18s;
}
.tab-btn:hover { color: var(--text); background: rgba(255, 255, 255, .03); }
[data-theme="light"] .tab-btn:hover { background: rgba(15, 23, 42, .04); }
.tab-btn.active {
  background: var(--accent-strong);
  color: #fff;
  box-shadow: 0 2px 6px rgba(99, 102, 241, .35);
}

/* === DEVICE TABS === */
.device-tab { display: none; }
.device-tab.active { display: block; animation: fadeUp .3s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* === TEST GRID — modern cards === */
.tests-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
.test-btn {
  padding: 16px 8px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  text-align: center;
  font-size: .76rem;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: transform .18s, box-shadow .18s, border-color .18s, background .18s;
}
.test-btn:hover {
  transform: translateY(-2px);
  background: var(--card-hover);
  border-color: var(--accent);
  box-shadow: var(--shadow), inset 0 0 24px var(--accent-soft);
}
#tab-mob .test-btn:hover {
  border-color: var(--emerald);
  box-shadow: var(--shadow), inset 0 0 24px var(--emerald-soft);
}
.test-btn:active { transform: translateY(0); }
.test-btn .test-emoji {
  font-size: 1.4rem;
  transition: transform .2s;
}
.test-btn:hover .test-emoji { transform: scale(1.1); }
.test-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent), 0 4px 16px rgba(99, 102, 241, .25);
}
#tab-mob .test-btn.active {
  border-color: var(--emerald);
  background: var(--emerald-soft);
  box-shadow: 0 0 0 1px var(--emerald), 0 4px 16px rgba(52, 211, 153, .25);
}

/* === TEST PANELS === */
.test-panel { display: none; }
.test-panel.active { display: block; animation: fadeUp .3s ease; }
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 22px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.panel h2 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 6px 0;
  letter-spacing: -0.01em;
  color: var(--text);
}
.panel-desc {
  font-size: .8rem;
  color: var(--muted);
  margin: 0 0 18px 0;
  line-height: 1.5;
}

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 10px;
  font-size: .8rem;
  font-weight: 500;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--text);
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .12s, box-shadow .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: var(--btn-bg-hover); border-color: var(--border-strong); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99, 102, 241, .25);
}
.btn-primary:hover { background: var(--accent); border-color: var(--accent); }
.btn-emerald { background: var(--emerald); border-color: var(--emerald); color: #fff; box-shadow: 0 2px 8px rgba(5, 150, 105, .25); }
.btn-emerald:hover { filter: brightness(1.08); }
.btn-rose { background: var(--rose); border-color: var(--rose); color: #fff; box-shadow: 0 2px 8px rgba(220, 38, 38, .25); }
.btn-rose:hover { filter: brightness(1.08); }
.btn-violet { background: var(--violet); border-color: var(--violet); color: #fff; box-shadow: 0 2px 8px rgba(124, 58, 237, .25); }
.btn-violet:hover { filter: brightness(1.08); }
.btn-blue { background: var(--blue); border-color: var(--blue); color: #fff; box-shadow: 0 2px 8px rgba(37, 99, 235, .25); }
.btn-blue:hover { filter: brightness(1.08); }
.btn-cyan { background: var(--cyan); border-color: var(--cyan); color: #fff; box-shadow: 0 2px 8px rgba(8, 145, 178, .25); }
.btn-cyan:hover { filter: brightness(1.08); }

/* === GRIDS === */
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); gap: 12px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } .grid-3 { grid-template-columns: 1fr; } }

/* === CARDS / IROW === */
.card2 {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  transition: background .15s;
}
.card2-title {
  font-size: .76rem;
  font-weight: 600;
  margin: 0 0 8px 0;
  color: var(--text);
}
.irow {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: .78rem;
}
.irow > span { color: var(--muted); }
.irow > b { font-weight: 600; text-align: right; word-break: break-word; }

/* Hide touch test on PC */
body[data-dev="pc"] .mobile-only { display: none !important; }

/* === KEYBOARD === */
.kb-outer { width: 100%; overflow: hidden; position: relative; }
.kb-scaler { display: block; transform-origin: top left; width: max-content; will-change: transform; }
.kb-flex { display: flex; gap: 10px; width: max-content; }
.kb-cols { display: flex; flex-direction: column; gap: 3px; }
.krow { display: flex; gap: 2px; align-items: flex-end; }
.k {
  background: var(--kb-key-bg);
  border: 1px solid var(--kb-key-border);
  border-bottom: 3px solid var(--kb-key-bottom);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9.5px;
  font-weight: 600;
  color: var(--kb-key-text);
  height: 34px;
  min-width: 34px;
  padding: 0 3px;
  user-select: none;
  transition: background .08s, color .08s, transform .04s;
  flex-shrink: 0;
  white-space: nowrap;
}
.k.pressed {
  background: var(--accent-strong) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
  border-bottom-color: var(--accent-strong) !important;
  box-shadow: 0 0 12px rgba(99, 102, 241, .55);
  transform: translateY(1px);
}
.k.missed {
  background: var(--rose-soft) !important;
  color: var(--rose) !important;
  border-color: var(--rose) !important;
}
.numpad {
  display: grid;
  grid-template-columns: repeat(4, 34px);
  grid-template-rows: repeat(5, 34px);
  gap: 2px;
  margin-top: 34px;
  align-content: start;
}
.numpad .k { width: 34px; height: 34px; min-width: unset; }
.np-plus, .np-enter { grid-row: span 2; height: 70px !important; }
.np-zero { grid-column: span 2; width: 70px !important; }

/* === MOUSE / TRACKPAD === */
#mouse-canvas {
  cursor: crosshair;
  display: block;
  width: 100%;
  background: var(--canvas-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
}
.mouse-stats { display: flex; gap: 16px; flex-wrap: wrap; font-size: .72rem; color: var(--muted); margin-top: 8px; }
.mouse-stats b { color: var(--accent); font-weight: 600; }
.mb-cluster { display: flex; gap: 6px; justify-content: center; margin-bottom: 16px; }
.mb-cell { text-align: center; }
.mb-key {
  width: 72px; height: 100px;
  background: var(--btn-bg);
  border: 2px solid var(--btn-border);
  display: flex; align-items: center; justify-content: center;
  font-size: .75rem; color: var(--muted);
  font-weight: 500;
  transition: all .15s;
}
.mb-key.mid { width: 32px; border-radius: 7px; font-size: .6rem; }
.mb-key.left { border-radius: 14px 0 0 14px; border-right: none; }
.mb-key.right { border-radius: 0 14px 14px 0; border-left: none; }
.mb-key.active { background: var(--accent-strong); color: #fff; border-color: var(--accent-strong); }
.mb-count { font-size: .72rem; color: var(--muted); margin-top: 4px; font-weight: 500; }
#dbl-zone {
  border: 1px dashed var(--border-strong);
  background: var(--card2);
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  font-size: .78rem;
  cursor: pointer;
  transition: all .2s;
}
#dbl-zone:hover { border-color: var(--accent); background: var(--accent-soft); }

.tp-canvas {
  display: block;
  cursor: crosshair;
  touch-action: none;
  border-radius: 12px;
  background: var(--canvas-bg);
  border: 1px solid var(--border-strong);
}
.tp-btns { display: flex; margin-top: 3px; }
.tp-btn {
  flex: 1; height: 28px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .12s;
  user-select: none;
}
.tp-btn:first-child { border-radius: 0 0 0 10px; }
.tp-btn:last-child { border-radius: 0 0 10px 0; border-left: none; }
.tp-btn.act { background: var(--accent-strong); color: #fff; }
.mode-btn {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: .68rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border-strong);
  background: var(--btn-bg);
  color: var(--muted);
  transition: all .15s;
}
.mode-btn:hover { color: var(--text); border-color: var(--accent); }
.mode-btn.active { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.mode-btn.danger { color: var(--rose); border-color: var(--rose-soft); }
.mode-btn.danger:hover { background: var(--rose-soft); }

.divider {
  margin: 22px 0 14px 0;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}
.section-label {
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

/* === SCREEN / FULLSCREEN === */
.fs-overlay {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .3s;
}
.fs-overlay.show { display: flex; }
#fs-label {
  color: rgba(255, 255, 255, .18);
  font-size: 1.5rem;
  font-weight: 700;
  pointer-events: none;
  user-select: none;
}

.subtle-exit {
  position: fixed;
  top: calc(14px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  background: rgba(0, 0, 0, .4);
  color: rgba(255, 255, 255, .65);
  border: 1px solid rgba(255, 255, 255, .18);
  border-radius: 50%;
  font-size: 15px;
  cursor: pointer;
  z-index: 10100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: all .18s;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.subtle-exit:hover, .subtle-exit:active {
  color: #fff;
  background: rgba(220, 38, 38, .85);
  border-color: rgba(255, 255, 255, .3);
  transform: translateX(-50%) scale(1.06);
}

/* === TOUCH GRID — hexagonal === */
#touch-grid {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 9998;
  display: none;
  background: #0a0a12;
  overflow: hidden;
  touch-action: none;
}
#touch-grid.show { display: block; }
.hex-cell {
  position: absolute;
  background: #2a2d3a;
  clip-path: polygon(50% 2%, 98% 27%, 98% 73%, 50% 98%, 2% 73%, 2% 27%);
  transition: background .15s;
  pointer-events: auto;
  will-change: background;
}
.hex-cell.touched { background: linear-gradient(135deg, #10b981, #06b6d4); }

/* === SWATCHES === */
.swatches { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.swatch {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .18s, box-shadow .18s;
  border: 1px solid var(--border);
}
.swatch:hover { transform: scale(1.08) translateY(-2px); box-shadow: var(--shadow); }
.swatch.dark { border: 1px solid rgba(255, 255, 255, .12); }
[data-theme="light"] .swatch.dark { border: 1px solid rgba(0, 0, 0, .25); }
.gradient-bar { height: 36px; border-radius: 10px; }
.rgb-bars { display: flex; gap: 8px; }
.rgb-bars > div { flex: 1; height: 30px; border-radius: 8px; }

/* === SOUND === */
.sound-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (max-width: 640px) { .sound-cards { grid-template-columns: 1fr; } }
.tone-btn {
  padding: 9px 13px;
  border-radius: 10px;
  font-size: .76rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--btn-bg);
  color: var(--text);
  text-align: left;
  transition: all .15s;
}
.tone-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  transform: translateX(2px);
}
.quick-check {
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, var(--emerald-soft), var(--blue-soft));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
}
.quick-check-icon { font-size: 1.7rem; }
.quick-check-text { flex: 1; }
.quick-check-title { font-size: .82rem; font-weight: 600; margin-bottom: 2px; }
.quick-check-desc { font-size: .72rem; color: var(--muted); }

#mic-canvas {
  width: 100%;
  border-radius: 14px;
  background: var(--canvas-bg);
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.mic-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.mic-timer { font-size: 1.4rem; font-weight: 700; color: var(--accent); letter-spacing: .02em; }
.mic-status { font-size: .74rem; color: var(--muted); margin-top: 2px; min-height: 1em; }

input[type="range"] {
  width: 100%;
  -webkit-appearance: none; appearance: none;
  background: transparent;
  margin: 6px 0;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  background: var(--btn-border);
  border-radius: 3px;
}
input[type="range"]::-moz-range-track {
  height: 5px;
  background: var(--btn-border);
  border-radius: 3px;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px;
  background: var(--accent-strong);
  border-radius: 50%;
  cursor: pointer;
  margin-top: -6px;
  box-shadow: 0 2px 6px rgba(99, 102, 241, .4);
  transition: transform .12s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px;
  background: var(--accent-strong);
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 2px 6px rgba(99, 102, 241, .4);
}

/* === WEBCAM === */
video {
  width: 100%;
  max-height: 420px;
  border-radius: 14px;
  background: var(--canvas-bg);
  object-fit: contain;
  display: block;
}
#snap-img {
  margin-top: 12px;
  border-radius: 14px;
  margin-left: auto; margin-right: auto;
  max-width: 280px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* === SENSORS === */
.axis-bar { height: 8px; background: var(--input-bg); border-radius: 4px; overflow: hidden; }
.axis-fill { height: 100%; border-radius: 4px; transition: width .12s; }
.axis-fill.r { background: linear-gradient(90deg, var(--rose), #fb7185); }
.axis-fill.g { background: linear-gradient(90deg, var(--emerald), #34d399); }
.axis-fill.b { background: linear-gradient(90deg, var(--blue), #60a5fa); }
.axis-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 8px; }
.axis-head { display: flex; justify-content: space-between; font-size: .72rem; color: var(--muted); font-weight: 500; }
.axis-head b.r { color: var(--rose); }
.axis-head b.g { color: var(--emerald); }
.axis-head b.b { color: var(--blue); }

.proximity-card {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.proximity-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--btn-border);
  transition: all .3s;
  flex-shrink: 0;
}

/* === VIBRATION === */
@keyframes vib {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}
.vib-icon { font-size: 3.4rem; text-align: center; margin-bottom: 18px; }

/* === BATTERY === */
.batt-body {
  width: 120px;
  height: 54px;
  border: 3px solid var(--btn-border);
  border-radius: 8px;
  position: relative;
  display: flex;
  align-items: center;
  padding: 4px;
}
.batt-body::after {
  content: '';
  position: absolute;
  right: -10px;
  top: 50%;
  transform: translateY(-50%);
  width: 7px;
  height: 22px;
  background: var(--btn-border);
  border-radius: 0 4px 4px 0;
}
.batt-fill { height: 100%; border-radius: 3px; transition: width .5s, background .5s; }

/* === PERMISSIONS === */
.perm-banner {
  grid-column: 1 / -1;
  background: var(--amber-soft);
  border: 1px solid var(--amber);
  border-left: 4px solid var(--amber);
  border-radius: 12px;
  padding: 14px 16px;
  font-size: .8rem;
  margin-bottom: 14px;
  line-height: 1.5;
}
.perm-banner strong { color: var(--amber); }
.perm-banner code {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 5px;
  padding: 2px 6px;
  font-size: .72rem;
  font-family: 'JetBrains Mono', Consolas, ui-monospace, monospace;
  color: var(--text);
}
.perm-banner .perm-banner-fix { margin-top: 8px; color: var(--text); font-size: .76rem; }

.perm-block { display: flex; flex-direction: column; gap: 6px; }
.perm-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 11px;
  font-size: .8rem;
  gap: 8px;
  transition: border-color .15s;
}
.perm-row:hover { border-color: var(--border-strong); }
.perm-row > span:first-child { flex: 1; min-width: 0; font-weight: 500; }
.perm-row .perm-controls { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.perm-status {
  font-size: .68rem;
  padding: 3px 9px;
  border-radius: 7px;
  font-weight: 600;
  white-space: nowrap;
}
.perm-granted { background: var(--emerald-soft); color: var(--emerald); }
.perm-denied { background: var(--rose-soft); color: var(--rose); }
.perm-prompt { background: var(--amber-soft); color: var(--amber); }
.perm-unsupported { background: var(--btn-bg); color: var(--muted); }
.perm-mini {
  padding: 5px 11px;
  font-size: .68rem;
  font-weight: 500;
  border-radius: 7px;
  border: 1px solid var(--btn-border);
  background: var(--btn-bg);
  color: var(--text);
  cursor: pointer;
  transition: all .15s;
}
.perm-mini:hover { background: var(--btn-bg-hover); }
.perm-mini:disabled { opacity: .5; cursor: not-allowed; }
.perm-mini.primary {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: #fff;
  box-shadow: 0 1px 3px rgba(99, 102, 241, .3);
}
.perm-mini.primary:hover { background: var(--accent); border-color: var(--accent); }

.perm-help.hidden { display: none; }
.perm-hint {
  font-size: .73rem;
  padding: 9px 13px;
  background: var(--amber-soft);
  border-left: 3px solid var(--amber);
  color: var(--amber);
  border-radius: 7px;
  line-height: 1.5;
}

/* === GAMEPAD === */
.gp-btn-cell {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 7px;
  font-size: 9px;
  font-weight: 700;
  margin: 2px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  color: var(--muted);
  transition: all .08s;
}
.gp-btn-cell.pressed {
  background: var(--accent-strong);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 10px rgba(99, 102, 241, .5);
}
.gp-card-title { font-size: .76rem; font-weight: 600; margin-bottom: 8px; color: var(--text); word-break: break-word; }
.gp-card-buttons { margin-bottom: 10px; }
.gp-axis { margin-bottom: 6px; }
.gp-axis-label { color: var(--muted); font-size: .68rem; font-weight: 500; }
.gp-axis-track { height: 6px; background: var(--input-bg); border-radius: 3px; overflow: hidden; margin-top: 3px; }
.gp-axis-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-strong)); border-radius: 3px; transition: width .04s; }

/* === NETWORK === */
.net-result {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 10px;
  font-size: .88rem;
  transition: border-color .15s;
}
.net-result:hover { border-color: var(--border-strong); }
.net-result .label { color: var(--muted); font-weight: 500; }
.net-result .value { font-weight: 600; }
.net-result .value.ok { color: var(--emerald); }
.net-result .value.fail { color: var(--rose); }
.net-result .value.warn { color: var(--amber); }

/* === TOASTS — large, always light tones === */
#toast-container {
  position: fixed;
  top: 86px;
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
  width: 380px;
  max-width: calc(100vw - 32px);
}
.toast {
  pointer-events: auto;
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-left: 5px solid #6366f1;
  border-radius: 14px;
  padding: 26px 14px 26px 22px;
  font-size: 1rem;
  min-height: 130px;
  box-shadow: 0 14px 36px rgba(15, 23, 42, .22);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  animation: toast-in .28s cubic-bezier(.2, .9, .3, 1.2);
}
.toast.success { background: #ecfdf5; border-color: #d1fae5; border-left-color: #059669; }
.toast.success .toast-icon { color: #059669; }
.toast.error { background: #fef2f2; border-color: #fecaca; border-left-color: #dc2626; }
.toast.error .toast-icon { color: #dc2626; }
.toast.warn { background: #fffbeb; border-color: #fde68a; border-left-color: #d97706; }
.toast.warn .toast-icon { color: #d97706; }
.toast.info { background: #eff6ff; border-color: #dbeafe; border-left-color: #2563eb; }
.toast.info .toast-icon { color: #2563eb; }
.toast-icon { font-size: 1.8rem; font-weight: 700; flex-shrink: 0; line-height: 1; padding-top: 2px; }
.toast-msg { flex: 1; min-width: 0; word-break: break-word; line-height: 1.45; padding-top: 4px; font-weight: 500; }
.toast-action {
  flex-shrink: 0;
  padding: 8px 14px;
  font-size: .78rem;
  background: #1e293b;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  align-self: center;
  transition: background .15s;
}
.toast-action:hover { background: #0f172a; }
.toast-close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: 6px;
  align-self: flex-start;
  transition: all .15s;
}
.toast-close:hover { color: #1e293b; background: rgba(15, 23, 42, .06); }
.toast.removing { animation: toast-out .22s forwards; }
@keyframes toast-in {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: none; opacity: 1; }
}
@keyframes toast-out {
  to { transform: translateX(120%); opacity: 0; }
}

@media (max-width: 640px) {
  #toast-container {
    top: auto;
    bottom: calc(12px + env(safe-area-inset-bottom));
    right: 12px;
    left: 12px;
    width: auto;
  }
  .toast { min-height: 110px; padding: 22px 12px 22px 18px; font-size: .92rem; }
  .toast-icon { font-size: 1.5rem; }
  @keyframes toast-in {
    from { transform: translateY(120%); opacity: 0; }
    to { transform: none; opacity: 1; }
  }
  @keyframes toast-out {
    to { transform: translateY(120%); opacity: 0; }
  }
}

/* === MODAL === */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10001;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity .2s;
}
.modal-overlay.show { opacity: 1; }
.modal-overlay.removing { opacity: 0; }
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  max-width: 540px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.modal-header h3 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
}
.modal-close {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.15rem;
  padding: 4px 10px;
  border-radius: 8px;
  transition: all .15s;
}
.modal-close:hover { color: var(--text); background: var(--btn-bg); }
.modal-body { padding: 20px; font-size: .85rem; line-height: 1.6; }
.modal-body ol { padding-left: 22px; margin: 8px 0 0 0; }
.modal-body li { margin-bottom: 8px; }
.modal-body code {
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  padding: 2px 6px;
  border-radius: 5px;
  font-family: 'JetBrains Mono', Consolas, ui-monospace, monospace;
  font-size: .82em;
  color: var(--text);
}
.modal-body p { margin: 0 0 10px 0; }
.modal-body p:last-child { margin-bottom: 0; }

/* === RESPONSIVE === */
@media (max-width: 640px) {
  .header-inner { gap: 10px; padding: 10px 14px; }
  .header-title h1 { font-size: .98rem; }
  .panel { padding: 16px; border-radius: 18px; }
  .panel h2 { font-size: 1.02rem; }
  .test-btn { padding: 12px 6px; font-size: .68rem; }
  .test-btn .test-emoji { font-size: 1.2rem; }
  .tests-grid { grid-template-columns: repeat(auto-fill, minmax(95px, 1fr)); gap: 8px; }
  .lang-switch, .theme-switch { padding: 2px; }
  .lang-btn, .theme-btn { padding: 4px 7px; font-size: .65rem; }
  .tab-btn { padding: 6px 10px; font-size: .76rem; }
}
