:root {
  --spartan-green: #006b3f;
  --spartan-green-bright: #00a86b;
  --spartan-green-dark: #002f21;
  --spartan-gold: #d9b44a;
  --ink: #f4fff9;
  --muted: #a9c7ba;
  --panel: rgba(7, 25, 19, 0.78);
  --panel-border: rgba(154, 255, 210, 0.18);
  --key: rgba(255, 255, 255, 0.07);
  --key-border: rgba(255, 255, 255, 0.16);
  --tested-key: rgba(255, 255, 255, 0.92);
  --tested-ink: #063324;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(0, 168, 107, 0.32), transparent 36rem),
    linear-gradient(135deg, #04110d 0%, #071d15 48%, #00190f 100%);
  color: var(--ink);
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
}

button,
textarea {
  font: inherit;
}

.bg-glow {
  position: fixed;
  border-radius: 999px;
  filter: blur(35px);
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
}

.bg-glow-one {
  width: 24rem;
  height: 24rem;
  background: var(--spartan-green-bright);
  top: -8rem;
  right: 4rem;
}

.bg-glow-two {
  width: 20rem;
  height: 20rem;
  background: var(--spartan-gold);
  bottom: -10rem;
  left: 5rem;
  opacity: 0.18;
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1500px, calc(100% - 32px));
  margin: 0 auto;
  padding: 42px 0;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
}

.eyebrow {
  display: inline-block;
  margin: 0 0 10px;
  color: var(--spartan-gold);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-decoration: none;
}

.gateway-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  border: 1px solid rgba(0, 255, 160, 0.62);
  border-radius: 999px;
  padding: 8px 13px;
  background:
    linear-gradient(135deg, rgba(0, 168, 107, 0.20), rgba(0, 47, 33, 0.42)),
    rgba(255, 255, 255, 0.045);
  box-shadow:
    0 0 0 1px rgba(0, 255, 160, 0.10),
    0 0 24px rgba(0, 168, 107, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  transition: color 160ms ease, text-shadow 160ms ease, transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.gateway-link::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--spartan-green-bright);
  box-shadow: 0 0 12px rgba(0, 255, 160, 0.9);
}

.gateway-link:hover {
  color: #ffe27a;
  border-color: rgba(217, 180, 74, 0.75);
  background:
    linear-gradient(135deg, rgba(217, 180, 74, 0.18), rgba(0, 168, 107, 0.32)),
    rgba(255, 255, 255, 0.065);
  box-shadow:
    0 0 0 1px rgba(217, 180, 74, 0.12),
    0 0 28px rgba(217, 180, 74, 0.30),
    0 0 34px rgba(0, 168, 107, 0.24);
  text-shadow: 0 0 18px rgba(217, 180, 74, 0.55);
  transform: translateY(-1px);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2.4rem, 5vw, 5.2rem);
  letter-spacing: -0.07em;
  line-height: 0.95;
}

h2 {
  margin-bottom: 4px;
  font-size: 1.15rem;
}

.subtitle {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.04rem;
  line-height: 1.6;
}

.status-card,
.metric-card,
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.status-card {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 240px;
  padding: 16px 18px;
  border-radius: 22px;
}

.status-card small,
.metric-card span,
.panel p,
.diagnostics span {
  color: var(--muted);
}

.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--spartan-gold);
  box-shadow: 0 0 0 6px rgba(217, 180, 74, 0.13);
}

.status-dot.active {
  background: var(--spartan-green-bright);
  box-shadow: 0 0 0 6px rgba(0, 168, 107, 0.18), 0 0 28px rgba(0, 168, 107, 0.8);
}

.dashboard {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 16px;
}

.metric-card {
  padding: 18px;
  border-radius: 24px;
}

.metric-card span {
  display: block;
  margin-bottom: 10px;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.metric-card strong {
  display: block;
  min-height: 1.18em;
  overflow: hidden;
  font-size: clamp(1.25rem, 2.1vw, 2rem);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.panel {
  padding: 22px;
  border-radius: 28px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-header.compact {
  margin-bottom: 14px;
}

.panel-header p {
  margin-bottom: 0;
}

.controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

#resetBtn {
  color: var(--ink);
  cursor: pointer;
  border: 1px solid rgba(217, 180, 74, 0.4);
  border-radius: 999px;
  padding: 11px 16px;
  background: linear-gradient(135deg, rgba(217, 180, 74, 0.22), rgba(0, 107, 63, 0.28));
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

#resetBtn:hover {
  border-color: var(--spartan-gold);
  transform: translateY(-1px);
}

.sound-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  cursor: pointer;
  border: 1px solid rgba(154, 255, 210, 0.18);
  border-radius: 999px;
  padding: 9px 13px;
  background: rgba(255, 255, 255, 0.055);
  font-size: 0.92rem;
  font-weight: 700;
}

.sound-toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  display: inline-flex;
  align-items: center;
  width: 42px;
  height: 24px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  padding: 2px;
  background: rgba(0, 0, 0, 0.32);
  transition: background 160ms ease, border-color 160ms ease;
}

.toggle-thumb {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: var(--muted);
  transition: transform 160ms ease, background 160ms ease;
}

.sound-toggle input:checked + .toggle-track {
  border-color: rgba(0, 255, 160, 0.55);
  background: rgba(0, 168, 107, 0.38);
}

.sound-toggle input:checked + .toggle-track .toggle-thumb {
  transform: translateX(18px);
  background: var(--spartan-green-bright);
}

.sound-note {
  display: none;
}

.keyboard-typing-area {
  margin: 0 0 18px;
}

.keyboard-typing-area textarea {
  min-height: 86px;
}

.keyboard-scroll {
  overflow-x: auto;
  padding: 2px 2px 10px;
}

.keyboard {
  display: grid;
  gap: 12px;
  min-width: 1320px;
  user-select: none;
}

.keyboard-section {
  display: grid;
  gap: 8px;
}

.function-row,
.key-row {
  display: flex;
  gap: 8px;
}

.keyboard-body {
  display: grid;
  grid-template-columns: 14fr 3fr 4fr;
  gap: 14px;
  align-items: start;
}

.key-gap {
  width: 20px;
  flex: 0 0 20px;
}

.key {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  min-height: 52px;
  flex: 1 1 0;
  color: var(--ink);
  cursor: default;
  border: 1px solid var(--key-border);
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.095), rgba(255, 255, 255, 0.035)),
    var(--key);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 10px 18px rgba(0, 0, 0, 0.18);
  line-height: 1.05;
  text-align: center;
  transition:
    transform 90ms ease,
    border-color 90ms ease,
    background 90ms ease,
    box-shadow 90ms ease,
    color 90ms ease;
}

.key small {
  color: currentColor;
  font-size: 0.62rem;
  opacity: 0.72;
}

.key::after {
  content: attr(data-count);
  position: absolute;
  right: 8px;
  bottom: 5px;
  color: rgba(255, 255, 255, 0.54);
  font-size: 0.65rem;
}

.key.tested {
  color: var(--tested-ink);
  border-color: rgba(255, 255, 255, 0.82);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(219, 255, 238, 0.88)),
    var(--tested-key);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.28),
    0 0 22px rgba(255, 255, 255, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.75);
}

.key.tested::after {
  color: rgba(0, 47, 33, 0.58);
}

.key.pressed {
  color: #ffffff;
  border-color: rgba(0, 255, 160, 0.9);
  background:
    radial-gradient(circle at top, rgba(0, 255, 160, 0.42), transparent 70%),
    linear-gradient(180deg, rgba(0, 168, 107, 0.96), rgba(0, 79, 47, 0.98));
  box-shadow:
    0 0 0 1px rgba(0, 255, 160, 0.28),
    0 0 26px rgba(0, 168, 107, 0.62),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: translateY(2px) scale(0.985);
}

.key.hit {
  animation: keyPulse 260ms ease;
}

.key-wide {
  flex: 2.2;
}

.key-tab {
  flex: 1.5;
}

.key-caps {
  flex: 1.85;
}

.key-enter {
  flex: 2.25;
}

.key-shift {
  flex: 2.6;
}

.key-mod {
  flex: 1.25;
}

.key-space {
  flex: 6;
}

.nav-grid,
.arrow-grid,
.numpad-grid {
  display: grid;
  gap: 8px;
}

.nav-grid {
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 68px;
}

.arrow-grid {
  grid-template-columns: repeat(3, 1fr);
}

.numpad-grid {
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 52px;
}

.numpad-grid .key {
  min-width: 58px;
  min-height: 52px;
}

.key-tall {
  grid-row: span 2;
}

.key-zero {
  grid-column: span 2;
}

.lower-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}

.pill {
  color: var(--spartan-gold);
  border: 1px solid rgba(217, 180, 74, 0.32);
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(217, 180, 74, 0.08);
  font-size: 0.78rem;
  font-weight: 800;
}

.history {
  display: grid;
  align-content: start;
  max-height: 275px;
  overflow: auto;
  gap: 8px;
  padding-right: 4px;
}

.history-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.045);
}

.history-item strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-item span {
  color: var(--muted);
  font-size: 0.82rem;
}

.empty {
  color: var(--muted);
  padding: 12px;
}

.diagnostics {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.diagnostics div {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
}

.diagnostics span,
.diagnostics strong {
  display: block;
}

.diagnostics strong {
  margin-top: 5px;
  word-break: break-word;
}

.test-input-label {
  display: block;
  color: var(--spartan-gold);
  margin-bottom: 8px;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 18px;
  outline: none;
  padding: 14px;
  background: rgba(0, 0, 0, 0.22);
}

textarea:focus {
  border-color: rgba(0, 255, 160, 0.58);
  box-shadow: 0 0 0 4px rgba(0, 168, 107, 0.14);
}

@keyframes keyPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.045); }
  100% { transform: scale(1); }
}

@media (max-width: 1120px) {
  .hero {
    align-items: stretch;
    flex-direction: column;
  }

  .dashboard {
    grid-template-columns: repeat(3, 1fr);
  }

  .lower-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 1500px);
    padding: 24px 0;
  }

  .dashboard {
    grid-template-columns: 1fr;
  }

  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .controls {
    justify-content: flex-start;
  }

  .status-card {
    min-width: 0;
  }
}

.site-nav {
  display: flex;
  gap: 10px;
  margin: -6px 0 18px;
  flex-wrap: wrap;
}

.site-nav a {
  color: var(--ink);
  border: 1px solid rgba(154, 255, 210, 0.18);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.055);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 800;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.site-nav a:hover,
.site-nav a.active {
  border-color: rgba(0, 255, 160, 0.55);
  background: rgba(0, 168, 107, 0.28);
  transform: translateY(-1px);
}

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

.device-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.device-panel {
  min-height: 100%;
}

.permission-note-panel {
  margin-top: 16px;
}

.permission-note-panel p {
  margin-bottom: 0;
}

.device-select {
  width: 100%;
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 16px;
  outline: none;
  padding: 12px 14px;
  background: rgba(0, 0, 0, 0.28);
  margin-bottom: 16px;
}

.device-select option {
  color: #06140f;
}

.left-controls {
  justify-content: flex-start;
  margin-top: 16px;
}

.utility-btn {
  color: var(--ink);
  cursor: pointer;
  border: 1px solid rgba(217, 180, 74, 0.4);
  border-radius: 999px;
  padding: 11px 16px;
  background: linear-gradient(135deg, rgba(217, 180, 74, 0.22), rgba(0, 107, 63, 0.28));
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.utility-btn:hover {
  border-color: var(--spartan-gold);
  transform: translateY(-1px);
}

.utility-btn.secondary {
  border-color: rgba(154, 255, 210, 0.18);
  background: rgba(255, 255, 255, 0.055);
}

.level-wrap {
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.045);
}

.level-bar {
  height: 28px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

#micLevelBar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(0, 168, 107, 0.9), rgba(217, 180, 74, 0.95));
  transition: width 80ms linear;
}

.level-scale {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 8px;
}

.video-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 340px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 22px;
  background:
    radial-gradient(circle at center, rgba(0, 168, 107, 0.16), transparent 65%),
    rgba(0, 0, 0, 0.32);
}

.video-frame video {
  display: none;
  width: 100%;
  max-height: 480px;
  background: #000;
}

.video-frame video.active {
  display: block;
}

.video-frame video.mirrored {
  transform: scaleX(-1);
}

.video-placeholder {
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.mouse-pad,
.cps-click-zone {
  display: grid;
  place-items: center;
  min-height: 240px;
  color: var(--ink);
  border: 1px solid rgba(0, 255, 160, 0.28);
  border-radius: 24px;
  background:
    radial-gradient(circle at center, rgba(0, 168, 107, 0.24), transparent 70%),
    rgba(255, 255, 255, 0.045);
  text-align: center;
  cursor: crosshair;
  user-select: none;
}

.mouse-pad strong,
.cps-click-zone strong {
  display: block;
  font-size: clamp(1.4rem, 3vw, 2.4rem);
  letter-spacing: -0.04em;
}

.mouse-pad span,
.cps-click-zone span {
  display: block;
  color: var(--muted);
  margin-top: 8px;
}

.mouse-pad.active,
.cps-click-zone.active {
  border-color: rgba(0, 255, 160, 0.9);
  box-shadow: 0 0 32px rgba(0, 168, 107, 0.34);
}

.mouse-button-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 11px;
  margin-top: 16px;
}

.mouse-button-card {
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.045);
}

.mouse-button-card span,
.mouse-button-card strong {
  display: block;
}

.mouse-button-card span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mouse-button-card strong {
  margin-top: 6px;
  font-size: 1.45rem;
}

.mouse-button-card.active {
  color: var(--tested-ink);
  border-color: rgba(255, 255, 255, 0.82);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(219, 255, 238, 0.88));
}

.mouse-button-card.active span {
  color: rgba(0, 47, 33, 0.7);
}

.cps-dashboard {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 0 0 16px;
}

.cps-start-btn {
  width: 100%;
  margin-bottom: 16px;
}

.cps-click-zone {
  min-height: 260px;
  cursor: pointer;
}

@media (max-width: 980px) {
  .device-grid,
  .media-dashboard {
    grid-template-columns: 1fr;
  }

  .mouse-button-grid,
  .cps-dashboard {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .mouse-button-grid,
  .cps-dashboard {
    grid-template-columns: 1fr;
  }
}

.playback-box {
  display: grid;
  gap: 12px;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.045);
}

.playback-label {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.playback-box strong {
  display: block;
  margin-top: 5px;
}

.playback-box audio {
  width: 100%;
}

.playback-box-prominent {
  margin-top: 18px;
  border-color: rgba(217, 180, 74, 0.34);
  background:
    radial-gradient(circle at top left, rgba(217, 180, 74, 0.10), transparent 45%),
    rgba(255, 255, 255, 0.055);
}

.playback-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.playback-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  white-space: nowrap;
}

.playback-download.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.playback-speed-control {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px 14px;
  padding: 14px;
  border: 1px solid rgba(154, 255, 210, 0.14);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.18);
}

.playback-speed-control label {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.playback-speed-control input[type="range"] {
  width: 100%;
  accent-color: var(--spartan-green-bright);
}

.playback-speed-control strong {
  min-width: 58px;
  text-align: right;
  color: var(--spartan-gold);
}

.video-playback-box {
  margin-top: 18px;
}

.video-playback {
  display: block;
  width: 100%;
  max-height: 320px;
  border: 1px solid rgba(154, 255, 210, 0.14);
  border-radius: 16px;
  background: #000;
}

.video-playback:not([src]) {
  min-height: 120px;
}

.video-record-options {
  margin: 14px 0 0;
}

.video-audio-toggle {
  width: fit-content;
  border-color: rgba(0, 255, 160, 0.28);
  background:
    linear-gradient(135deg, rgba(0, 168, 107, 0.14), rgba(0, 47, 33, 0.24)),
    rgba(255, 255, 255, 0.045);
}

.playback-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

button.playback-download.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

@media (max-width: 560px) {
  .playback-actions {
    justify-content: flex-start;
    width: 100%;
  }
}
