/* Antenna Tap Lab - instrument-panel look.
   Display font: Unbounded. Data font: IBM Plex Mono. */

:root[data-theme="dark"] {
  --bg: #0c0e09;
  --bg-glow: rgba(198, 245, 63, 0.05);
  --panel: #14170f;
  --panel-2: #191d12;
  --ink: #eef2e2;
  --muted: #99a288;
  --accent: #c6f53f;
  --accent-soft: rgba(198, 245, 63, 0.16);
  --gold: #f5c542;
  --warn: #f56d42;
  --line: #2a2f1e;
  --needle: #f4f7ea;
  --shadow: rgba(0, 0, 0, 0.55);
}

:root[data-theme="light"] {
  --bg: #f1efe4;
  --bg-glow: rgba(95, 125, 0, 0.06);
  --panel: #faf9f1;
  --panel-2: #f3f1e5;
  --ink: #22261b;
  --muted: #6d7460;
  --accent: #5f7d00;
  --accent-soft: rgba(95, 125, 0, 0.14);
  --gold: #a87b0f;
  --warn: #c74a1f;
  --line: #d9d6c2;
  --needle: #22261b;
  --shadow: rgba(60, 60, 40, 0.18);
}

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

html,
body {
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* faint scanlines + centered glow, the "scope" atmosphere */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 90% 50% at 50% 18%, var(--bg-glow), transparent 70%),
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(0, 0, 0, 0.05) 3px 4px);
  z-index: 0;
}

#root {
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: 0.9rem 0.9rem calc(1.2rem + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-height: 100%;
}

/* ---------- header ---------- */

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.2rem 0.15rem;
}

.wordmark {
  font-family: "Unbounded", sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.06em;
}

.wordmark em {
  font-style: normal;
  color: var(--accent);
}

.chips {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chip {
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.28rem 0.55rem;
  color: var(--muted);
  background: var(--panel);
  white-space: nowrap;
}

.chip.ok {
  color: var(--accent);
  border-color: var(--accent-soft);
}

.chip.warn {
  color: var(--warn);
  border-color: var(--warn);
  cursor: pointer;
}

/* ---------- gauge card ---------- */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 12px 30px -18px var(--shadow);
  padding: 0.9rem;
}

.gauge-wrap {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
}

.gauge-wrap svg {
  display: block;
  width: 100%;
  height: auto;
}

.dial-track {
  stroke: var(--line);
}

.dial-band {
  stroke: var(--accent);
  filter: drop-shadow(0 0 6px var(--accent-soft));
}

.dial-tick {
  stroke: var(--muted);
  opacity: 0.55;
}

.dial-label {
  fill: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 9px;
}

.needle-line {
  stroke: var(--needle);
  stroke-width: 2.4;
  stroke-linecap: round;
}

.needle-hub {
  fill: var(--needle);
}

#needle {
  transition: none;
}

.gauge-count {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 26%;
  text-align: center;
  pointer-events: none;
}

.gauge-count .n {
  font-family: "Unbounded", sans-serif;
  font-weight: 700;
  font-size: 2.6rem;
  line-height: 1;
}

.gauge-count .n.pulse {
  animation: pulse 0.45s ease-out;
}

.gauge-count .cap {
  font-size: 0.6rem;
  letter-spacing: 0.35em;
  color: var(--muted);
  margin-top: 0.25rem;
}

@keyframes pulse {
  0% { transform: scale(1); }
  25% { transform: scale(1.35); color: var(--accent); }
  100% { transform: scale(1); }
}

/* tap ripples */
.ripple {
  position: absolute;
  left: 50%;
  top: 58%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0.9;
  pointer-events: none;
  animation: ripple 1.6s cubic-bezier(0.1, 0.6, 0.3, 1) forwards;
}

.ripple.gold {
  border-color: var(--gold);
}

@keyframes ripple {
  0% { transform: scale(0.4); opacity: 0.95; }
  100% { transform: scale(16); opacity: 0; }
}

/* live numbers under the dial */
.readouts {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.6rem;
  font-size: 0.72rem;
  color: var(--muted);
}

.readouts b {
  color: var(--ink);
  font-weight: 600;
}

.readouts .inband b {
  color: var(--accent);
}

/* l-condition bar */
.lbar {
  position: relative;
  height: 6px;
  margin-top: 0.65rem;
  border-radius: 3px;
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.lbar .win {
  position: absolute;
  top: -1px;
  bottom: -1px;
  border-radius: 3px;
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  opacity: 0.8;
}

.lbar .mark {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 14px;
  background: var(--needle);
  border-radius: 1px;
}

.lbar-cap {
  margin-top: 0.35rem;
  font-size: 0.58rem;
  letter-spacing: 0.12em;
  color: var(--muted);
  text-align: right;
}

/* ---------- handshake strip ---------- */

.strip .dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.2rem 0 0.55rem;
}

.dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--muted);
  transition: all 0.15s ease-out;
}

.dot.on {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 10px var(--accent-soft);
}

.dot.locked {
  background: var(--gold);
  border-color: var(--gold);
}

.sep {
  width: 10px;
  height: 10px;
  transform: rotate(45deg);
  border: 2px solid var(--muted);
  margin: 0 0.2rem;
  transition: all 0.15s ease-out;
}

.sep.on {
  background: var(--gold);
  border-color: var(--gold);
  box-shadow: 0 0 12px var(--gold);
}

.phase {
  text-align: center;
  font-size: 0.78rem;
  min-height: 1.2em;
  letter-spacing: 0.03em;
}

.phase.gold {
  color: var(--gold);
  font-family: "Unbounded", sans-serif;
  font-size: 0.85rem;
}

.phase.warn {
  color: var(--warn);
}

.window {
  height: 4px;
  margin-top: 0.55rem;
  border-radius: 2px;
  background: var(--panel-2);
  overflow: hidden;
}

.window .fill {
  height: 100%;
  width: 0%;
  background: var(--gold);
  border-radius: 2px;
}

/* ---------- tap log ---------- */

.log-card h2 {
  font-family: "Unbounded", sans-serif;
  font-weight: 500;
  font-size: 0.7rem;
  letter-spacing: 0.3em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.log {
  list-style: none;
  max-height: 32vh;
  overflow-y: auto;
  font-size: 0.74rem;
}

.log li {
  display: flex;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.32rem 0.1rem;
  border-bottom: 1px dashed var(--line);
  animation: slidein 0.25s ease-out;
}

.log li .idx {
  color: var(--accent);
  font-weight: 600;
}

.log li .gap {
  color: var(--muted);
}

.log li .gap.fast {
  color: var(--ink);
  font-weight: 600;
}

.log .empty {
  border: none;
  color: var(--muted);
  justify-content: center;
  padding: 0.8rem 0;
}

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

/* ---------- overlays ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(6px);
  text-align: center;
  padding: 1.5rem;
  transition: opacity 0.4s ease;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay .big {
  font-family: "Unbounded", sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
}

.overlay .count {
  font-family: "Unbounded", sans-serif;
  font-weight: 700;
  font-size: 4rem;
  color: var(--accent);
}

.overlay .sub {
  color: var(--muted);
  font-size: 0.8rem;
  max-width: 26ch;
}

#flash {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 40%, var(--gold), transparent 65%);
}

#flash.go {
  animation: flash 1.1s ease-out forwards;
}

@keyframes flash {
  0% { opacity: 0.85; }
  100% { opacity: 0; }
}

/* stats */
.stats {
  display: flex;
  justify-content: center;
  gap: 1.6rem;
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.stats b {
  color: var(--ink);
  font-size: 0.85rem;
}

@media (min-width: 560px) {
  #root { max-width: 560px; }
  .log { max-height: 26vh; }
}
