:root {
  color-scheme: dark;
  --bg: #020503;
  --panel: rgba(3, 18, 9, 0.88);
  --panel-strong: rgba(5, 28, 13, 0.96);
  --line: rgba(50, 255, 94, 0.32);
  --green: #31ff5f;
  --green-soft: #99ff7d;
  --red: #ff3434;
  --amber: #ffd166;
  --text: #e9fff0;
  --muted: #8db99a;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: rgba(49, 255, 95, 0.16);
}

html {
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  color: var(--text);
  font-family: "Avenir Next", "Trebuchet MS", Arial, sans-serif;
  background:
    linear-gradient(rgba(0, 255, 70, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 50% 16%, rgba(28, 255, 80, 0.12), transparent 46%),
    #010301;
  background-size: 100% 5px, cover, cover;
}

button,
input,
select {
  font: inherit;
}

a {
  color: var(--green-soft);
}

.shell {
  width: min(100%, 520px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(10px, env(safe-area-inset-top)) 10px max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 0 22px rgba(32, 255, 76, 0.12), inset 0 0 24px rgba(32, 255, 76, 0.05);
  backdrop-filter: blur(10px);
}

.radar-wrap {
  order: 1;
  position: sticky;
  top: 0;
  z-index: 5;
  padding-top: 2px;
  background: linear-gradient(180deg, #010301 0%, rgba(1, 3, 1, 0.92) 84%, transparent 100%);
}

.command-panel {
  order: 2;
  padding: 12px;
}

.results-panel {
  order: 3;
  padding: 12px;
}

.brand {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
}

.brand img {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.13em;
  font-size: 0.62rem;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 2.15rem;
  line-height: 0.88;
}

h2 {
  font-size: 1rem;
}

.search {
  display: grid;
  gap: 7px;
}

.search label,
.control-grid span {
  color: var(--green-soft);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr 72px 64px;
  gap: 7px;
}

.search > input {
  margin-bottom: 3px;
}

input,
select {
  width: 100%;
  min-height: 48px;
  color: var(--text);
  border: 1px solid rgba(49, 255, 95, 0.34);
  background: rgba(0, 8, 2, 0.84);
  padding: 0 12px;
  outline: none;
  border-radius: 0;
  font-size: 16px;
}

input:focus,
select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(49, 255, 95, 0.14);
}

button {
  min-height: 48px;
  border: 1px solid rgba(49, 255, 95, 0.64);
  border-radius: 0;
  color: #001f09;
  background: linear-gradient(180deg, #b5ff72, #21ec57);
  cursor: pointer;
  font-weight: 800;
  touch-action: manipulation;
}

button.secondary {
  color: var(--green-soft);
  background: rgba(5, 18, 9, 0.95);
}

.voice-button {
  color: var(--amber);
  background: rgba(28, 17, 2, 0.95);
  border-color: rgba(255, 209, 102, 0.68);
}

.voice-button.listening {
  color: #211400;
  background: linear-gradient(180deg, #ffe38a, #ffba3b);
  box-shadow: 0 0 18px rgba(255, 209, 102, 0.48);
}

button:active {
  filter: brightness(1.2);
  transform: translateY(1px);
}

.control-grid {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.control-grid label {
  display: grid;
  gap: 6px;
  grid-column: 1 / -1;
}

#dataButton {
  grid-column: 1 / -1;
}

.network-status {
  grid-column: 1 / -1;
  padding: 7px 9px;
  border: 1px solid rgba(49, 255, 95, 0.22);
  color: var(--muted);
  background: rgba(0, 8, 2, 0.48);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
}

.status {
  min-height: 46px;
  margin-top: 10px;
  padding: 10px;
  border-left: 3px solid var(--green);
  color: var(--green-soft);
  background: rgba(49, 255, 95, 0.08);
  font-size: 0.92rem;
  line-height: 1.28;
}

.selected-card {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 209, 102, 0.34);
  background: rgba(255, 209, 102, 0.08);
}

.selected-card h2 {
  margin-bottom: 5px;
  color: var(--amber);
}

.selected-card p:last-of-type {
  margin: 0 0 10px;
  color: #d7f7de;
}

.guidance {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
  align-items: center;
  margin: 10px 0 12px;
  padding: 10px;
  border: 1px solid rgba(49, 255, 95, 0.26);
  background: rgba(0, 8, 2, 0.48);
}

.guidance-dial {
  position: relative;
  width: 56px;
  height: 56px;
  border: 1px solid rgba(49, 255, 95, 0.46);
  border-radius: 50%;
  background:
    linear-gradient(90deg, transparent 49%, rgba(49, 255, 95, 0.4) 50%, transparent 51%),
    linear-gradient(0deg, transparent 49%, rgba(49, 255, 95, 0.4) 50%, transparent 51%),
    rgba(49, 255, 95, 0.06);
  box-shadow: inset 0 0 18px rgba(49, 255, 95, 0.1);
}

.guidance-arrow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-bottom: 28px solid var(--amber);
  filter: drop-shadow(0 0 8px rgba(255, 209, 102, 0.9));
  transform-origin: 50% 64%;
  transition: transform 260ms ease;
}

.guidance strong {
  display: block;
  color: var(--amber);
  margin-bottom: 3px;
}

.guidance p {
  margin: 0 0 6px;
  color: #d7f7de;
  font-size: 0.84rem;
  line-height: 1.28;
}

.guidance span {
  color: var(--green-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
}

.link-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.link-row a,
.result a {
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

.radar-frame {
  width: 100%;
}

.radar {
  position: relative;
  width: min(100%, calc(100svh - 310px), 500px);
  min-width: 300px;
  aspect-ratio: 1;
  margin: 0 auto;
  overflow: hidden;
  border: 2px solid rgba(49, 255, 95, 0.55);
  border-radius: 50%;
  background:
    radial-gradient(circle, rgba(23, 255, 72, 0.18) 0 1px, transparent 1.5px),
    radial-gradient(circle at center, rgba(5, 32, 14, 0.9), rgba(0, 8, 3, 0.98) 64%, #010301 100%);
  background-size: 12px 12px, cover;
  box-shadow: 0 0 42px rgba(49, 255, 95, 0.2), inset 0 0 56px rgba(49, 255, 95, 0.1);
}

.ring,
.axis,
.center-dot,
.contacts,
.noise,
.sweep {
  position: absolute;
}

.ring {
  inset: 50%;
  border: 1px solid rgba(49, 255, 95, 0.38);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.r1 { width: 22%; height: 22%; }
.r2 { width: 42%; height: 42%; }
.r3 { width: 64%; height: 64%; }
.r4 { width: 84%; height: 84%; }

.axis {
  background: rgba(49, 255, 95, 0.38);
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.axis-v {
  width: 1px;
  height: 100%;
}

.axis-h {
  width: 100%;
  height: 1px;
}

.center-dot {
  width: 16px;
  height: 16px;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--green-soft);
  box-shadow: 0 0 18px var(--green);
  z-index: 4;
}

.sweep {
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, rgba(49, 255, 95, 0.72), rgba(49, 255, 95, 0.18) 22deg, transparent 58deg);
  mix-blend-mode: screen;
  animation: sweep 4.2s linear infinite;
  z-index: 1;
}

.noise {
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0 4px, rgba(149, 255, 165, 0.035) 5px 6px);
  z-index: 8;
}

.contacts {
  inset: 0;
  z-index: 5;
}

.radar-guidance {
  position: absolute;
  inset: 0;
  z-index: 9;
  pointer-events: none;
}

.radar-arrow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 9px;
  height: 34%;
  border-radius: 999px;
  background: linear-gradient(0deg, rgba(255, 209, 102, 0.04), rgba(255, 209, 102, 0.9));
  box-shadow: 0 0 18px rgba(255, 209, 102, 0.9);
  transform-origin: 50% 100%;
  transition: transform 240ms ease;
}

.radar-arrow::before {
  content: "";
  position: absolute;
  left: 50%;
  top: -14px;
  width: 0;
  height: 0;
  border-left: 15px solid transparent;
  border-right: 15px solid transparent;
  border-bottom: 28px solid var(--amber);
  filter: drop-shadow(0 0 10px rgba(255, 209, 102, 0.95));
  transform: translateX(-50%);
}

.radar-hint {
  position: absolute;
  left: 50%;
  bottom: 10%;
  transform: translateX(-50%);
  max-width: 78%;
  padding: 5px 9px;
  border: 1px solid rgba(255, 209, 102, 0.48);
  color: var(--amber);
  background: rgba(2, 5, 3, 0.78);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.73rem;
  text-align: center;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact {
  position: absolute;
  left: calc(var(--x) * 1%);
  top: calc(var(--y) * 1%);
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  border: 0;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 14px rgba(255, 52, 52, 0.95);
  min-height: 0;
  padding: 0;
  z-index: 6;
}

.contact::after {
  content: attr(data-label);
  position: absolute;
  left: 21px;
  top: calc(-7px + var(--label-y, 0px));
  max-width: 104px;
  padding: 2px 4px;
  color: #ffd4d4;
  background: rgba(2, 5, 3, 0.76);
  font-size: 0.62rem;
  line-height: 1.05;
  text-align: left;
  text-shadow: 0 0 8px #000;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact.left-label::after {
  left: auto;
  right: 21px;
  text-align: right;
}

.contact.active {
  width: 24px;
  height: 24px;
  background: var(--amber);
  box-shadow: 0 0 24px var(--amber);
  z-index: 7;
}

.contact[data-label=""]::after {
  display: none;
}

.readout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
  padding: 8px 2px 0;
  color: var(--green-soft);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
}

.readout span:first-child {
  grid-column: 1 / -1;
}

.list-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

#sourceBadge {
  padding: 4px 8px;
  border: 1px solid rgba(49, 255, 95, 0.32);
  color: var(--green-soft);
  font-size: 0.7rem;
  white-space: nowrap;
}

.results {
  display: grid;
  gap: 8px;
}

.result {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(49, 255, 95, 0.22);
  background: rgba(0, 8, 2, 0.62);
  text-align: left;
  color: var(--text);
  cursor: pointer;
}

.result.active {
  border-color: var(--amber);
  background: rgba(255, 209, 102, 0.1);
}

.result-title {
  color: #ffdede;
  font-weight: 800;
}

.result-meta {
  color: var(--muted);
  font-size: 0.8rem;
}

.empty {
  padding: 14px;
  color: var(--muted);
  border: 1px dashed rgba(49, 255, 95, 0.28);
}

@keyframes sweep {
  to { transform: rotate(360deg); }
}

@media (min-width: 720px) {
  .shell {
    padding-top: 18px;
  }

  .radar {
    width: min(100%, 500px);
  }

  .command-panel,
  .results-panel {
    padding: 16px;
  }
}
