:root {
  color-scheme: light dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: #f4f6fb;
  color: #1f2933;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.6;
}

.page-header,
.page-footer {
  padding: 2rem clamp(1rem, 5vw, 4rem);
  background: #ffffff;
  color: #1f2933;
  text-align: center;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

.page-footer {
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  border-bottom: none;
  background: #f8fafc;
}

.page-header h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(2rem, 4vw, 2.75rem);
}

.page-header .tagline {
  margin: 0;
  font-size: clamp(1rem, 2.5vw, 1.25rem);
}

main {
  flex: 1;
  padding: clamp(1.5rem, 4vw, 3rem);
  max-width: 960px;
  margin: 0 auto;
  width: 100%;
  box-sizing: border-box;
}

h2,
h3 {
  margin-top: 0;
  color: #0b3d91;
}

.tester {
  background: #fff;
  border-radius: 12px;
  padding: clamp(1.5rem, 4vw, 2.5rem);
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.1);
  display: grid;
  gap: clamp(1rem, 3vw, 1.5rem);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
}

.controls input[type="range"] {
  width: min(280px, 100%);
}

#thresholdValue {
  font-variant-numeric: tabular-nums;
  color: #0b3d91;
}

#resetButton {
  margin-left: auto;
  background: #ff7675;
  border: none;
  color: #fff;
  padding: 0.6rem 1rem;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#resetButton:hover,
#resetButton:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 8px 16px rgba(255, 118, 117, 0.35);
}

#testPad {
  font-size: clamp(1.25rem, 3vw, 2rem);
  padding: clamp(2rem, 7vw, 3.5rem);
  border-radius: 18px;
  border: none;
  background: #22c55e;
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  box-shadow: 0 18px 30px rgba(34, 197, 94, 0.35);
}

#testPad:active {
  transform: scale(0.97);
  box-shadow: 0 12px 22px rgba(34, 197, 94, 0.4);
}

#testPad.flash-red {
  background: #ef4444;
  box-shadow: 0 18px 30px rgba(239, 68, 68, 0.35);
}

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

.stats div {
  background: #f1f5ff;
  padding: 1rem;
  border-radius: 10px;
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 0.9rem;
  color: #52606d;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  color: #0b3d91;
  font-variant-numeric: tabular-nums;
}

.log {
  background: #f7f9fc;
  border-radius: 10px;
  padding: 1rem;
  max-height: clamp(260px, 55vh, 420px);
  overflow-y: auto;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.log h3 {
  margin: 0 0 0.75rem;
}

.log ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.5rem;
}

.log li {
  padding: 0.75rem;
  border-radius: 8px;
  background: #fff;
  border-left: 4px solid transparent;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.05);
}

.log li.placeholder {
  font-style: italic;
  color: #52606d;
  text-align: center;
  background: transparent;
  border: 1px dashed rgba(82, 96, 109, 0.4);
  box-shadow: none;
}

.log li.double {
  border-left-color: #ff6b6b;
  background: rgba(255, 107, 107, 0.08);
}

.log time {
  display: block;
  font-size: 0.85rem;
  color: #52606d;
}

.page-footer {
  font-size: 0.95rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    background-color: #05070d;
    color: #e0e6f5;
  }

  .tester,
  .log li {
    background: #111827;
    color: #e0e6f5;
  }

  #testPad {
    background: #15803d;
    box-shadow: 0 18px 30px rgba(21, 128, 61, 0.4);
  }

  #testPad:active {
    box-shadow: 0 12px 22px rgba(21, 128, 61, 0.45);
  }

  #testPad.flash-red {
    background: #f87171;
    box-shadow: 0 18px 30px rgba(248, 113, 113, 0.45);
  }

  .page-header,
  .page-footer {
    background: #0f172a;
    color: #e2e8f0;
    border-color: rgba(148, 163, 184, 0.2);
  }

  .page-footer {
    background: #111c2f;
    border-top: 1px solid rgba(148, 163, 184, 0.2);
  }

  .stats div {
    background: #1d2a44;
  }

  .stat-label {
    color: #9aa5c1;
  }

  .stat-value {
    color: #55efc4;
  }

  .log {
    background: #0b1221;
    border-color: rgba(84, 110, 175, 0.3);
  }

  .log li {
    background: #1d2a44;
  }

  .log li.placeholder {
    color: #9aa5c1;
    border-color: rgba(154, 165, 193, 0.3);
  }

  .log li.double {
    background: rgba(239, 68, 68, 0.12);
  }
}
