@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;600;700&family=Syne:wght@400;700;800&display=swap");

:root {
  --bg: #0a0b0e;
  --surface: #111318;
  --surface2: #181b22;
  --border: #1f2330;
  --border2: #2a2f40;
  --accent: #00e5ff;
  --accent2: #7c3aed;
  --green: #00ff88;
  --red: #ff3d5a;
  --gray: #4a5068;
  --text: #c8cfe8;
  --text-dim: #5a6180;
  --mono: "JetBrains Mono", monospace;
  --display: "Syne", sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
  min-height: 100vh;
  padding: 0;
  overflow-x: hidden;

  /* subtle grid texture */
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 40px 40px;
  background-position: center center;
}

/* ── HEADER ─────────────────────────────────────────── */
header {
  position: relative;
  padding: 56px 40px 40px;
  text-align: center;
  border-bottom: 1px solid var(--border2);
  background: linear-gradient(
    180deg,
    rgba(0, 229, 255, 0.04) 0%,
    transparent 100%
  );
}

header::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 360px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  background: rgba(0, 229, 255, 0.08);
  border: 1px solid rgba(0, 229, 255, 0.2);
  border-radius: 4px;
  padding: 4px 10px;
  margin-bottom: 18px;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent);
  animation: pulse 2s ease-in-out infinite;
}

h1 {
  font-family: var(--display);
  font-size: clamp(1.6rem, 4vw, 2.8rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #eef0fa;
  line-height: 1.1;
  margin-bottom: 10px;
}

h1 span {
  color: var(--accent);
}

.subtitle {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  max-width: 520px;
  margin: 0 auto;
  line-height: 1.7;
}

/* ── MAIN CONTENT WRAPPER ────────────────────────────── */
main {
  max-width: 860px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ── CARD ────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 10px;
  overflow: hidden;
  position: relative;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
}

.card-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.card-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.card-body {
  padding: 20px;
}

/* ── DELAY CONTROL ───────────────────────────────────── */
.control-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.control-label {
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  flex-shrink: 0;
}

.slider-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 160px;
}

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border2);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.5);
  cursor: pointer;
  transition: box-shadow 0.2s;
}

input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 18px rgba(0, 229, 255, 0.8);
}

input[type="number"]#delayInput {
  width: 76px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--accent);
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  padding: 7px 8px;
  outline: none;
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
  -moz-appearance: textfield;
}

input[type="number"]#delayInput::-webkit-outer-spin-button,
input[type="number"]#delayInput::-webkit-inner-spin-button {
  display: none;
}

input[type="number"]#delayInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0, 229, 255, 0.12);
}

.unit {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

/* ── TEXTAREA ────────────────────────────────────────── */
#testKeys {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  text-align: center;
  padding: 20px;
  outline: none;
  resize: none;
  line-height: 1.5;
  transition:
    border-color 0.25s,
    box-shadow 0.25s;
  caret-color: var(--accent);
}

#testKeys::placeholder {
  color: var(--text-dim);
}

#testKeys:focus {
  border-color: rgba(0, 229, 255, 0.4);
  box-shadow:
    0 0 0 3px rgba(0, 229, 255, 0.08),
    inset 0 0 20px rgba(0, 229, 255, 0.03);
}

/* ── LEGEND ──────────────────────────────────────────── */
.legend {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-green {
  background: var(--green);
  box-shadow: 0 0 6px var(--green);
}
.dot-red {
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
}
.dot-gray {
  background: var(--gray);
}

/* ── LOG ─────────────────────────────────────────────── */
#log {
  height: 340px;
  overflow-y: auto;
  padding: 4px 0;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#log::-webkit-scrollbar {
  width: 4px;
}
#log::-webkit-scrollbar-track {
  background: transparent;
}
#log::-webkit-scrollbar-thumb {
  background: var(--border2);
  border-radius: 2px;
}

/* ── BAR ROWS ────────────────────────────────────────── */
.bar-container {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  animation: slideIn 0.15s ease;
}

.label {
  min-width: 260px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  flex-shrink: 0;
}

.bar {
  height: 14px;
  min-width: 3px;
  border-radius: 2px;
  transition: width 0.1s ease;
}

/* status classes */
.registered {
  color: var(--green);
}
.blocked {
  color: var(--red);
}
.keyup {
  color: var(--gray);
}
.ms {
  font-weight: 700;
}

.bar-registered {
  background: linear-gradient(90deg, var(--green), rgba(0, 255, 136, 0.3));
  box-shadow: 0 0 8px rgba(0, 255, 136, 0.3);
}
.bar-blocked {
  background: linear-gradient(90deg, var(--red), rgba(255, 61, 90, 0.3));
  box-shadow: 0 0 8px rgba(255, 61, 90, 0.3);
}
.bar-keyup {
  background: var(--border2);
}

/* ── KEYBOARD TABLE ──────────────────────────────────── */
h2 {
  font-family: var(--display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #eef0fa;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

thead tr {
  border-bottom: 1px solid var(--border2);
}

th {
  text-align: left;
  padding: 10px 14px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  transition: background 0.15s;
}

tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}

td {
  padding: 12px 14px;
  vertical-align: middle;
  color: var(--text);
}

td:first-child {
  font-weight: 600;
  color: #eef0fa;
}

.severity {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
}

.sev-high {
  background: rgba(255, 61, 90, 0.15);
  color: var(--red);
  border: 1px solid rgba(255, 61, 90, 0.3);
}
.sev-medium {
  background: rgba(255, 165, 0, 0.12);
  color: #ffaa2b;
  border: 1px solid rgba(255, 165, 0, 0.3);
}
.sev-low {
  background: rgba(0, 255, 136, 0.1);
  color: var(--green);
  border: 1px solid rgba(0, 255, 136, 0.3);
}

/* ── ANIMATIONS ──────────────────────────────────────── */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-6px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

header {
  animation: fadeUp 0.5s ease both;
}
.card {
  animation: fadeUp 0.5s ease both;
}
.card:nth-child(2) {
  animation-delay: 0.08s;
}
.card:nth-child(3) {
  animation-delay: 0.14s;
}
.card:nth-child(4) {
  animation-delay: 0.2s;
}
.btn-confirm {
  animation: fadeUp 0.5s ease both;
}

.hidden {
  display: none !important;
}
