:root {
  color-scheme: dark;
  --bg: #111417;
  --panel: #181d22;
  --panel-2: #20262d;
  --line: #343d46;
  --text: #f2f6f8;
  --muted: #a7b1b8;
  --amber: #f2c84b;
  --green: #21f26c;
  --red: #ff5a55;
  --cyan: #62d7ff;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: radial-gradient(circle at 50% 0%, #27303a 0%, var(--bg) 42%, #090b0d 100%);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  position: relative;
  overflow: hidden;
}

.receiver {
  width: min(100%, 520px);
  min-height: calc(100vh - 32px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.topbar,
.panel-header,
.receiver-controls,
.telemetry {
  display: flex;
  align-items: center;
}

.topbar,
.panel-header {
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--amber);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1;
}

h1 {
  font-size: clamp(2rem, 9vw, 3.5rem);
}

h2 {
  font-size: 1.25rem;
}

.icon-button,
.action-button {
  border: 1px solid var(--line);
  background: #242b32;
  color: var(--text);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 1.4rem;
}

.icon-button:active,
.action-button:active {
  transform: scale(0.98);
}

.meter {
  width: min(100%, 72vh);
  aspect-ratio: 1;
  max-height: 540px;
  align-self: center;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(rgba(98, 215, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(98, 215, 255, 0.05) 1px, transparent 1px),
    #12171c;
  background-size: 32px 32px;
  overflow: hidden;
  box-shadow: inset 0 0 80px rgba(0, 0, 0, 0.44), 0 20px 60px rgba(0, 0, 0, 0.28);
}

#scope {
  width: 100%;
  height: 100%;
  display: block;
}

.needle-hub {
  position: absolute;
  inset: 50% auto auto 50%;
  width: 86px;
  height: 86px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid rgba(242, 200, 75, 0.55);
  background: rgba(15, 18, 21, 0.86);
  color: var(--amber);
  font-size: 1.15rem;
  font-weight: 800;
  transform: translate(-50%, -50%);
}

.flash-band {
  position: absolute;
  inset: auto 0 0;
  display: grid;
  min-height: 58px;
  place-items: center;
  background: var(--green);
  color: #021107;
  font-size: 1.35rem;
  font-weight: 950;
  opacity: 0;
  transform: translateY(100%);
  transition: opacity 120ms ease, transform 120ms ease;
}

.found .flash-band {
  opacity: 1;
  transform: translateY(0);
}

.found {
  animation: found-flash 620ms steps(2, jump-none) infinite;
}

@keyframes found-flash {
  0%,
  100% {
    filter: none;
  }
  50% {
    filter: drop-shadow(0 0 26px rgba(33, 242, 108, 0.9));
  }
}

.telemetry {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.readout {
  min-height: 76px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 29, 34, 0.92);
}

.readout span {
  display: block;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 750;
  text-transform: uppercase;
}

.readout strong {
  display: block;
  margin-top: 8px;
  font-size: clamp(1.25rem, 7vw, 2rem);
  line-height: 1;
  white-space: nowrap;
}

.readout.primary {
  grid-column: 1 / -1;
}

.readout.primary strong {
  font-size: clamp(2.2rem, 13vw, 4.25rem);
}

.readout.diagnostic {
  min-height: 58px;
}

.readout.diagnostic strong {
  font-size: 1rem;
  line-height: 1.2;
  white-space: normal;
}

.receiver-controls {
  gap: 10px;
}

.action-button {
  min-height: 54px;
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-radius: 8px;
  font-weight: 850;
}

.action-button.secondary[aria-pressed="true"] {
  border-color: rgba(33, 242, 108, 0.75);
  background: #143521;
}

.status {
  min-height: 40px;
  margin: auto 0 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
}

.settings-panel {
  position: fixed;
  z-index: 10;
  inset: auto 12px 12px;
  max-width: 520px;
  margin: 0 auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(24, 29, 34, 0.97);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  transform: translateY(calc(100% + 24px));
  transition: transform 220ms ease;
}

.settings-panel.open {
  transform: translateY(0);
}

.toggle-row,
.range-row {
  display: grid;
  gap: 8px;
  padding: 16px 0 0;
  color: var(--text);
  font-weight: 760;
}

.toggle-row {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.range-row {
  grid-template-columns: 1fr auto;
}

.range-row input {
  grid-column: 1 / -1;
}

input[type="checkbox"] {
  width: 46px;
  height: 26px;
  accent-color: var(--green);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--amber);
}

output {
  color: var(--amber);
}

@media (min-width: 760px) {
  .app-shell {
    grid-template-columns: minmax(420px, 520px) minmax(280px, 360px);
    justify-content: center;
    gap: 24px;
  }

  .receiver {
    min-height: calc(100vh - 32px);
  }

  .settings-panel {
    position: static;
    align-self: end;
    margin-bottom: 0;
    transform: none;
    display: none;
  }

  .settings-panel.open {
    display: block;
  }
}
