/* ==========================================================================
   PeriCheck — Teste de Mouse e Teclado — Estilos
   Tema escuro, responsivo, animações leves
   ========================================================================== */

:root {
  --bg-0: #070a0f;
  --bg-1: #0d1219;
  --bg-2: #141b24;
  --bg-3: #1c2532;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #e8eef6;
  --text-muted: #8b9bb0;
  --text-dim: #5f7085;
  --accent: #22d3a6;
  --accent-2: #7c5cff;
  --accent-3: #3b82f6;
  --danger: #f87171;
  --warn: #fbbf24;
  --ok: #34d399;
  --dbl: #60a5fa;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-0);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.keyboard-lock {
  overflow: hidden;
}

.app-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, rgba(34, 211, 166, 0.12), transparent 55%),
    radial-gradient(ellipse 70% 45% at 90% 10%, rgba(124, 92, 255, 0.14), transparent 50%),
    radial-gradient(ellipse 60% 40% at 50% 100%, rgba(59, 130, 246, 0.08), transparent 50%),
    var(--bg-0);
}

.container {
  width: min(1280px, calc(100% - 2rem));
  margin-inline: auto;
}

/* —— Header —— */
.site-header {
  padding: 1.5rem 0 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(7, 10, 15, 0.65);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.25rem;
}

.brand {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  max-width: 720px;
}

.brand-logo {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  filter: drop-shadow(0 8px 20px rgba(34, 211, 166, 0.25));
}

.brand-logo svg {
  width: 100%;
  height: 100%;
  display: block;
}

.brand-text h1 {
  margin: 0 0 0.35rem;
  font-size: clamp(1.35rem, 2.5vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, var(--text) 40%, var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
}

.status-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pill-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.2);
  animation: pulse-dot 2s ease infinite;
}

.pill-dot.idle {
  background: var(--text-dim);
  box-shadow: none;
  animation: none;
}

.pill-dot.active {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 211, 166, 0.25);
}

.pill-dot.offline {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(248, 113, 113, 0.2);
  animation: none;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: flex-end;
}

/* —— Buttons —— */
.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--bg-3);
  color: var(--text);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s var(--ease), background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.btn:hover {
  background: #243041;
  border-color: rgba(255, 255, 255, 0.22);
}

.btn:active {
  transform: scale(0.97);
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
}

.btn-ghost {
  background: transparent;
}

.btn-danger {
  border-color: rgba(248, 113, 113, 0.35);
  color: #fecaca;
  background: rgba(248, 113, 113, 0.1);
}

.btn-danger:hover {
  background: rgba(248, 113, 113, 0.2);
}

/* —— Tabs —— */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin: 1.5rem 0 1.25rem;
  padding: 0.35rem;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 999px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}

.tab {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.7rem 1.25rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}

.tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
}

.tab.active {
  color: var(--bg-0);
  background: linear-gradient(135deg, var(--accent), #5eead4);
  box-shadow: 0 8px 24px rgba(34, 211, 166, 0.25);
}

.tab-icon {
  font-size: 1rem;
}

/* —— Panels & cards —— */
.panel {
  display: none;
  animation: fade-in 0.35s var(--ease);
}

.panel.active {
  display: block;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.card {
  background: linear-gradient(180deg, rgba(28, 37, 50, 0.9), rgba(20, 27, 36, 0.95));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.card-header {
  margin-bottom: 1rem;
}

.card-header h2,
.card-header h3 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.card-header h3 {
  font-size: 1rem;
}

.row-between {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.hint {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.grid {
  display: grid;
  gap: 1.25rem;
}

.mouse-grid,
.keyboard-grid {
  grid-template-columns: 1.35fr 1fr;
  align-items: start;
}

.side-stack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* —— Mouse test area —— */
.mouse-test-area {
  position: relative;
  min-height: 580px;
  border-radius: var(--radius);
  border: 1px solid rgba(34, 211, 166, 0.22);
  background:
    radial-gradient(ellipse 70% 55% at 50% 45%, rgba(34, 211, 166, 0.1), transparent 60%),
    radial-gradient(ellipse 40% 35% at 15% 80%, rgba(124, 92, 255, 0.08), transparent 50%),
    radial-gradient(ellipse 40% 35% at 85% 20%, rgba(59, 130, 246, 0.08), transparent 50%),
    linear-gradient(180deg, rgba(20, 27, 36, 0.4), rgba(13, 18, 25, 0.2)),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 23px,
      rgba(255, 255, 255, 0.018) 24px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 23px,
      rgba(255, 255, 255, 0.018) 24px
    ),
    var(--bg-1);
  display: flex;
  flex-direction: column;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  transition: border-color 0.25s, box-shadow 0.25s;
  padding: 0.85rem;
  gap: 0.5rem;
}

.mouse-test-area::before,
.mouse-test-area::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(34, 211, 166, 0.35);
  pointer-events: none;
  z-index: 1;
}

.mouse-test-area::before {
  top: 10px;
  left: 10px;
  border-right: none;
  border-bottom: none;
}

.mouse-test-area::after {
  bottom: 10px;
  right: 10px;
  border-left: none;
  border-top: none;
}

.mouse-test-area:focus-visible,
.mouse-test-area.pointer-inside {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(34, 211, 166, 0.2), 0 0 40px rgba(34, 211, 166, 0.08);
}

.area-hud {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr;
  gap: 0.55rem;
  z-index: 2;
  pointer-events: none;
}

.hud-item {
  background: rgba(7, 10, 15, 0.55);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.55rem 0.75rem;
  backdrop-filter: blur(8px);
}

.hud-item.hud-center {
  text-align: center;
  border-color: rgba(34, 211, 166, 0.2);
}

.hud-item.hud-right {
  text-align: right;
}

.hud-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 0.15rem;
}

.hud-value {
  display: block;
  font-family: var(--mono);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-stats {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.45rem;
  z-index: 2;
  pointer-events: none;
}

.live-stat {
  background: rgba(7, 10, 15, 0.58);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.55rem 0.35rem;
  text-align: center;
  backdrop-filter: blur(8px);
}

.live-stat.accent {
  border-color: rgba(96, 165, 250, 0.4);
  background: rgba(96, 165, 250, 0.1);
}

.live-stat.warn {
  border-color: rgba(251, 191, 36, 0.4);
  background: rgba(251, 191, 36, 0.1);
}

.ls-val {
  display: block;
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}

.ls-lab {
  display: block;
  margin-top: 0.15rem;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.interval-meter {
  z-index: 2;
  pointer-events: none;
  background: rgba(7, 10, 15, 0.5);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.65rem 0.8rem 0.75rem;
}

.interval-meter-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}

.interval-meter-head strong {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.75rem;
}

.interval-track {
  position: relative;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: linear-gradient(
    90deg,
    rgba(248, 113, 113, 0.45) 0%,
    rgba(248, 113, 113, 0.45) 18%,
    rgba(251, 191, 36, 0.4) 18%,
    rgba(251, 191, 36, 0.4) 28%,
    rgba(52, 211, 153, 0.35) 28%,
    rgba(52, 211, 153, 0.35) 100%
  );
  border: 1px solid var(--border);
}

.interval-zones {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: 18% 10% 72%;
  font-size: 0.58rem;
  font-weight: 700;
  color: rgba(7, 10, 15, 0.75);
  pointer-events: none;
}

.interval-zones span {
  display: grid;
  place-items: center;
}

.interval-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 0%;
  background: rgba(255, 255, 255, 0.12);
  transition: width 0.2s var(--ease);
}

.interval-marker {
  position: absolute;
  top: -3px;
  bottom: -3px;
  left: 0%;
  width: 3px;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.7);
  transform: translateX(-50%);
  transition: left 0.2s var(--ease);
  opacity: 0;
}

.interval-marker.visible {
  opacity: 1;
}

.mouse-stage {
  position: relative;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto minmax(120px, 1fr);
  align-items: center;
  justify-items: center;
  gap: 0.75rem;
  min-height: 380px;
  padding: 0.75rem 0.25rem;
}

.stage-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(300px, 70%);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgba(34, 211, 166, 0.12);
  pointer-events: none;
  animation: ring-pulse 4s ease-in-out infinite;
}

.stage-ring.delay {
  width: min(380px, 85%);
  border-color: rgba(124, 92, 255, 0.1);
  animation-delay: 1.2s;
}

@keyframes ring-pulse {
  0%, 100% { opacity: 0.45; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 0.9; transform: translate(-50%, -50%) scale(1.03); }
}

.side-tips {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: 100%;
  max-width: 190px;
  z-index: 2;
  pointer-events: none;
}

.left-tips {
  justify-self: end;
  align-items: flex-end;
}

.right-tips {
  justify-self: start;
  align-items: flex-start;
}

.tip-chip {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  background: rgba(7, 10, 15, 0.6);
  border: 1px solid var(--border);
  backdrop-filter: blur(8px);
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s, background 0.2s;
}

.tip-chip strong {
  display: block;
  font-size: 0.82rem;
  margin-bottom: 0.1rem;
  color: var(--text);
}

.tip-chip span {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.tip-chip.active,
.tip-chip.flash {
  border-color: rgba(34, 211, 166, 0.55);
  background: rgba(34, 211, 166, 0.12);
  box-shadow: 0 0 20px rgba(34, 211, 166, 0.15);
  transform: translateY(-1px);
}

.tip-chip[data-tip="middle"].active,
.tip-chip[data-tip="middle"].flash {
  border-color: rgba(124, 92, 255, 0.55);
  background: rgba(124, 92, 255, 0.12);
  box-shadow: 0 0 20px rgba(124, 92, 255, 0.15);
}

.tip-chip[data-tip="back"].active,
.tip-chip[data-tip="back"].flash,
.tip-chip[data-tip="forward"].active,
.tip-chip[data-tip="forward"].flash {
  border-color: rgba(59, 130, 246, 0.55);
  background: rgba(59, 130, 246, 0.12);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.15);
}

.tip-chip[data-tip="dbl"].flash {
  border-color: rgba(96, 165, 250, 0.6);
  background: rgba(96, 165, 250, 0.15);
}

.mouse-illustration {
  position: relative;
  width: min(300px, 52vw);
  z-index: 2;
}

.click-ripples {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.ripple {
  position: absolute;
  left: 50%;
  top: 38%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  animation: ripple-out 0.55s var(--ease) forwards;
}

@keyframes ripple-out {
  to {
    transform: scale(4.5);
    opacity: 0;
  }
}

.mouse-svg {
  width: 100%;
  height: auto;
  display: block;
  filter: drop-shadow(0 18px 36px rgba(0, 0, 0, 0.55));
}

.mouse-body {
  fill: #1a222e;
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 2;
}

.mouse-part {
  fill: #243041;
  stroke: rgba(255, 255, 255, 0.1);
  stroke-width: 1.5;
  transition: fill 0.12s, filter 0.12s;
}

.mouse-part.active {
  fill: var(--accent);
  filter: drop-shadow(0 0 12px rgba(34, 211, 166, 0.65));
}

.mouse-part.btn-middle.active {
  fill: var(--accent-2);
  filter: drop-shadow(0 0 12px rgba(124, 92, 255, 0.65));
}

.mouse-part.btn-side.active {
  fill: var(--accent-3);
  filter: drop-shadow(0 0 10px rgba(59, 130, 246, 0.65));
}

.mouse-divider {
  stroke: rgba(255, 255, 255, 0.15);
  stroke-width: 1.5;
}

.mouse-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.mlabel {
  position: absolute;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: rgba(232, 238, 246, 0.45);
  text-transform: uppercase;
}

.mlabel.left { top: 22%; left: 18%; }
.mlabel.right { top: 22%; right: 18%; }
.mlabel.middle { top: 14%; left: 50%; transform: translateX(-50%); font-size: 0.58rem; }

.click-feedback {
  position: absolute;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  z-index: 3;
  min-height: 2rem;
}

.area-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  z-index: 2;
  pointer-events: none;
  padding-bottom: 0.25rem;
}

.action-pills {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
}

.action-pill {
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  background: rgba(7, 10, 15, 0.5);
  border: 1px solid var(--border);
}

.area-hint {
  margin: 0;
  color: var(--text-dim);
  font-size: 0.85rem;
  text-align: center;
}

.feedback-toast {
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  animation: toast-in 0.35s var(--ease), toast-out 0.35s var(--ease) 1.4s forwards;
  white-space: nowrap;
}

.feedback-toast.real {
  background: rgba(34, 211, 166, 0.2);
  border: 1px solid rgba(34, 211, 166, 0.45);
  color: #99f6e4;
}

.feedback-toast.dbl {
  background: rgba(96, 165, 250, 0.2);
  border: 1px solid rgba(96, 165, 250, 0.45);
  color: #bfdbfe;
}

.feedback-toast.warn {
  background: rgba(251, 191, 36, 0.2);
  border: 1px solid rgba(251, 191, 36, 0.45);
  color: #fde68a;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.95); }
  to { opacity: 1; transform: none; }
}

@keyframes toast-pop {
  0% { opacity: 0; transform: scale(0.7); }
  60% { transform: scale(1.06); }
  100% { opacity: 1; transform: scale(1); }
}

@keyframes toast-out {
  to { opacity: 0; transform: translateY(-6px); }
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.65rem;
}

.stat {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  transition: border-color 0.2s, transform 0.15s;
}

.stat.flash {
  border-color: rgba(34, 211, 166, 0.5);
  transform: scale(1.02);
}

.stat.highlight {
  grid-column: span 1;
  border-color: rgba(124, 92, 255, 0.35);
  background: linear-gradient(160deg, rgba(124, 92, 255, 0.12), var(--bg-1));
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
}

/* Diagnosis */
.diagnosis {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  font-weight: 600;
  border: 1px solid transparent;
}

.diagnosis[data-level="ok"] {
  background: rgba(52, 211, 153, 0.1);
  border-color: rgba(52, 211, 153, 0.3);
  color: #6ee7b7;
}

.diagnosis[data-level="low"] {
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.3);
  color: #fcd34d;
}

.diagnosis[data-level="possible"] {
  background: rgba(251, 146, 60, 0.12);
  border-color: rgba(251, 146, 60, 0.35);
  color: #fdba74;
}

.diagnosis[data-level="high"] {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.35);
  color: #fca5a5;
}

.diagnosis-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
  font-size: 0.9rem;
  flex-shrink: 0;
}

.alert {
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  line-height: 1.45;
}

.alert.warning {
  background: rgba(251, 191, 36, 0.08);
  border: 1px solid rgba(251, 191, 36, 0.28);
  color: #fde68a;
}

.alert.info {
  background: rgba(251, 146, 60, 0.1);
  border: 1px solid rgba(251, 146, 60, 0.35);
  color: #fdba74;
  margin-bottom: 0.75rem;
  animation: toast-pop 0.4s var(--ease);
}

.alert[hidden] {
  display: none !important;
}

.legend {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.legend .dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 0.45rem;
  vertical-align: middle;
}

.legend .dot.real { background: var(--accent); }
.legend .dot.dbl { background: var(--dbl); }
.legend .dot.warn-dot { background: var(--warn); }

/* History */
.history-card-wide {
  margin-top: 1.25rem;
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-3) transparent;
}

.history-list-horizontal {
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  max-height: none;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 0.65rem;
  padding: 0.15rem 0.1rem 0.55rem;
  scroll-snap-type: x proximity;
}

.history-list li {
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.55rem 0.7rem;
  border-radius: 8px;
  background: var(--bg-1);
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
  animation: fade-in 0.25s var(--ease);
}

.history-list-horizontal li {
  flex: 0 0 auto;
  width: min(220px, 72vw);
  min-height: 96px;
  border-left: none;
  border-top: 3px solid var(--accent);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  justify-content: center;
  scroll-snap-align: start;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.history-list-horizontal li .h-time {
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.history-list-horizontal li .h-title {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
}

.history-list-horizontal li .h-meta {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.history-list li.real { border-left-color: var(--accent); }
.history-list li.dbl { border-left-color: var(--dbl); }
.history-list li.warn { border-left-color: var(--warn); }

.history-list-horizontal li.real { border-top-color: var(--accent); }
.history-list-horizontal li.dbl {
  border-top-color: var(--dbl);
  background: rgba(96, 165, 250, 0.08);
}
.history-list-horizontal li.warn {
  border-top-color: var(--warn);
  background: rgba(251, 191, 36, 0.08);
}

.history-list li.empty {
  border-left-color: transparent;
  color: var(--text-dim);
  font-family: var(--font);
  text-align: center;
}

.history-list-horizontal li.empty {
  width: 100%;
  min-height: 72px;
  border-top-color: transparent;
  justify-content: center;
  box-shadow: none;
}

/* —— Keyboard —— */
.keyboard-test-area {
  outline: none;
  padding: 0.5rem 0;
  overflow-x: auto;
}

.virtual-keyboard {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  min-width: 720px;
  user-select: none;
}

.kb-row {
  display: flex;
  gap: 0.35rem;
  justify-content: center;
}

.kb-key {
  --key-w: 1;
  flex: var(--key-w) 1 0;
  min-width: 0;
  min-height: 42px;
  padding: 0.35rem 0.25rem;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: linear-gradient(180deg, #243041, #1a222e);
  color: var(--text);
  font-family: var(--font);
  font-size: 0.7rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
  transition: background 0.08s, border-color 0.08s, color 0.08s, transform 0.08s, box-shadow 0.08s;
  position: relative;
}

.kb-key .sub {
  font-size: 0.58rem;
  color: var(--text-dim);
  font-weight: 500;
}

.kb-key.pressed,
.kb-key.active {
  background: linear-gradient(180deg, var(--accent), #14b88a);
  border-color: #5eead4;
  color: #042f2e;
  transform: translateY(1px);
  box-shadow: 0 0 16px rgba(34, 211, 166, 0.4), 0 1px 0 rgba(0, 0, 0, 0.2);
}

.kb-key.pressed .sub,
.kb-key.active .sub {
  color: rgba(4, 47, 46, 0.7);
}

.kb-key.was-used:not(.pressed):not(.active) {
  border-color: rgba(34, 211, 166, 0.35);
}

.kb-key .count-badge {
  position: absolute;
  top: -6px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: 999px;
  background: var(--accent-2);
  color: #fff;
  font-size: 0.58rem;
  font-family: var(--mono);
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
}

.kb-key.was-used .count-badge {
  opacity: 1;
}

.kb-spacer {
  flex: 0.4 1 0;
}

.last-key-name {
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--bg-1);
  border: 1px solid var(--border);
  font-family: var(--mono);
  text-align: center;
  word-break: break-all;
}

.kv-list {
  margin: 0 0 1rem;
  display: grid;
  gap: 0.45rem;
}

.kv-list > div {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.45rem 0.6rem;
  background: var(--bg-1);
  border-radius: 8px;
  font-size: 0.82rem;
}

.kv-list dt {
  margin: 0;
  color: var(--text-muted);
}

.kv-list dd {
  margin: 0;
  font-family: var(--mono);
  text-align: right;
  color: var(--text);
  word-break: break-all;
}

.modifiers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.mod {
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-1);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-dim);
  transition: all 0.15s;
}

.mod.on {
  color: #042f2e;
  background: var(--accent);
  border-color: #5eead4;
  box-shadow: 0 0 12px rgba(34, 211, 166, 0.35);
}

/* Footer */
.site-footer {
  margin-top: 2.5rem;
  padding: 1.5rem 0 2rem;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 0.82rem;
  text-align: center;
}

/* Responsive */
@media (max-width: 980px) {
  .mouse-grid,
  .keyboard-grid {
    grid-template-columns: 1fr;
  }

  .header-actions {
    align-items: stretch;
    width: 100%;
  }

  .status-pills,
  .btn-row {
    justify-content: flex-start;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .live-stats {
    grid-template-columns: repeat(4, 1fr);
  }

  .mouse-stage {
    grid-template-columns: 1fr;
    gap: 1rem;
    min-height: auto;
  }

  .side-tips {
    flex-direction: row;
    flex-wrap: wrap;
    max-width: none;
    justify-content: center;
  }

  .left-tips,
  .right-tips {
    justify-self: center;
    align-items: stretch;
  }

  .tip-chip {
    width: auto;
    min-width: 140px;
    flex: 1 1 140px;
  }

  .area-hud {
    grid-template-columns: 1fr 1fr;
  }

  .hud-item.hud-center {
    grid-column: 1 / -1;
    order: -1;
  }
}

@media (max-width: 640px) {
  .container {
    width: calc(100% - 1.25rem);
  }

  .brand {
    gap: 0.75rem;
  }

  .brand-logo {
    width: 44px;
    height: 44px;
  }

  .tabs {
    width: 100%;
  }

  .tab {
    flex: 1;
    justify-content: center;
    padding: 0.65rem 0.75rem;
    font-size: 0.85rem;
  }

  .mouse-test-area {
    min-height: 420px;
    padding: 0.7rem;
  }

  .mouse-illustration {
    width: min(240px, 62vw);
  }

  .area-hud {
    grid-template-columns: 1fr;
  }

  .hud-item.hud-right {
    text-align: left;
  }

  .live-stats {
    grid-template-columns: repeat(2, 1fr);
  }

  .virtual-keyboard {
    min-width: 640px;
    gap: 0.3rem;
  }

  .kb-key {
    min-height: 36px;
    font-size: 0.62rem;
  }
}
