/* Keyboard test styles */

.keyboard-tool {
  --kb-surface: #ffffff;
  --kb-surface-muted: #f5f7fb;
  --kb-border: #e2e8f0;
  --kb-text: #0f172a;
  --kb-muted: #64748b;
  --kb-accent: #2563eb;
  --kb-accent-strong: #1d4ed8;
  --kb-active: #22c55e;
  --kb-tested: #f59e0b;
  --kb-shadow: 0 16px 40px rgba(15, 23, 42, 0.08);
  color: var(--kb-text);
}

html.dark-mode .keyboard-tool {
  --kb-surface: #0f172a;
  --kb-surface-muted: #111827;
  --kb-border: #1f2937;
  --kb-text: #e5e7eb;
  --kb-muted: #94a3b8;
  --kb-accent: #60a5fa;
  --kb-accent-strong: #3b82f6;
  --kb-active: #34d399;
  --kb-tested: #fbbf24;
  --kb-shadow: 0 16px 42px rgba(0, 0, 0, 0.45);
}

.keyboard-tool .tool-body {
  display: grid;
  gap: 1.5rem;
}

.status-grid {
  display: grid;
  gap: 1rem;
}

@media (min-width: 900px) {
  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }
}

.panel {
  background: linear-gradient(180deg, var(--kb-surface-muted), var(--kb-surface));
  border: 1px solid var(--kb-border);
  border-radius: 18px;
  padding: 1.25rem;
  box-shadow: var(--kb-shadow);
  display: grid;
  gap: 1rem;
  min-height: 100%;
}

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

.panel__title {
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.panel__pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.12);
  color: var(--kb-accent-strong);
  border: 1px solid rgba(37, 99, 235, 0.2);
  font-weight: 700;
  min-width: 76px;
  text-align: center;
}

.panel__pill.is-active {
  background: rgba(34, 197, 94, 0.14);
  border-color: rgba(34, 197, 94, 0.3);
  color: #15803d;
}

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

.event-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem 1rem;
}

.event-grid dt {
  margin: 0;
  color: var(--kb-muted);
  font-weight: 600;
  font-size: 0.9rem;
}

.event-grid dd {
  margin: 0;
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
}

.pressed-panel {
  gap: 0.75rem;
}

.pressed-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  min-height: 42px;
}

.pressed-keys .pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.75rem;
  border-radius: 12px;
  border: 1px solid var(--kb-border);
  background: var(--kb-surface-muted);
  font-weight: 700;
}

.pressed-keys .pill__meta {
  color: var(--kb-muted);
  font-size: 0.85rem;
}

.panel__actions {
  display: flex;
  justify-content: flex-end;
}

.keyboard-wrapper {
  background: linear-gradient(180deg, var(--kb-surface-muted), var(--kb-surface));
  border: 1px solid var(--kb-border);
  border-radius: 18px;
  padding: clamp(1rem, 0.5rem + 1.5vw, 1.75rem);
  box-shadow: var(--kb-shadow);
  display: grid;
  gap: 1rem;
}

.keyboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.keyboard-label {
  margin: 0;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.keyboard-hint {
  margin: 0.15rem 0 0;
  color: var(--kb-muted);
}

.keyboard-status {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  background: var(--kb-surface-muted);
  border: 1px solid var(--kb-border);
  font-weight: 700;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--kb-active);
  box-shadow: 0 0 0 6px rgba(52, 211, 153, 0.16);
}

.keyboard-grid {
  background: var(--kb-surface);
  border: 1px dashed var(--kb-border);
  border-radius: 16px;
  padding: clamp(0.75rem, 0.5rem + 1vw, 1.25rem);
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}

@media (min-width: 960px) {
  .keyboard-grid {
    grid-template-columns: minmax(0, 3fr) minmax(240px, 1.25fr);
    align-items: start;
  }
}

.keyboard-main,
.keyboard-side {
  display: grid;
  gap: 0.35rem;
}

.keyboard-side {
  gap: 0.6rem;
}

.keyboard-grid.is-blurred {
  opacity: 0.75;
}

.key-row {
  display: flex;
  gap: 0.35rem;
  flex-wrap: nowrap;
}

.key-row--function {
  align-items: stretch;
}

.key-row--bottom {
  align-items: center;
}

.key-row--nav {
  justify-content: center;
}

.arrow-cluster {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
  gap: 0.4rem;
  max-width: 220px;
  margin-inline: auto;
}

.key {
  background: var(--kb-surface-muted);
  border: 1px solid var(--kb-border);
  border-radius: 12px;
  padding: 0.65rem 0.35rem;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
  user-select: none;
  transition: transform 0.08s ease, border-color 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
  box-shadow: inset 0 -2px 0 rgba(15, 23, 42, 0.06);
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 2.8rem;
  min-width: max(3rem, max-content);
}

.key--wide {
  flex: 1.5 1 3.5rem;
}

.key--spacer {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  pointer-events: none;
}

.key--ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  pointer-events: none;
}

.key--wider {
  flex: 2 1 4rem;
}

.key--space {
  flex: 2.8 1 6rem;
}

.numpad-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.4rem;
}

.numpad-grid .key--tall {
  grid-row: span 2;
  height: 100%;
}

.numpad-grid .key--wide {
  grid-column: span 2;
}

.arrow-cluster .key:nth-child(2) {
  grid-column: 2;
}

.arrow-cluster .key:nth-child(4) {
  grid-column: 1;
}

.arrow-cluster .key:nth-child(5) {
  grid-column: 2;
}

.arrow-cluster .key:nth-child(6) {
  grid-column: 3;
}

.key.is-pressed {
  border-color: rgba(34, 197, 94, 0.65);
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.16), rgba(34, 197, 94, 0.08));
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
  transform: translateY(1px);
}

.key.is-tested {
  border-color: rgba(245, 158, 11, 0.7);
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.16), rgba(245, 158, 11, 0.1));
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

@media (max-width: 680px) {
  .keyboard-grid {
    padding: 0.75rem;
  }

  .key-row {
    gap: 0.25rem;
  }

  .key {
    padding: 0.5rem 0.25rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 540px) {
  .key-row {
    grid-template-columns: repeat(12, minmax(0, 1fr));
  }

  .key-row--arrows {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: minmax(0, 1fr);
  }

  .key-row--arrows .cluster {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .key-row--arrows .cluster.arrows {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .key--space {
    grid-column: span 5;
  }
}
