:root {
  --void: #071018;
  --ink: #eef4f7;
  --muted: #94b6c2;
  --panel: rgba(7, 22, 31, 0.9);
  --panel-strong: rgba(12, 32, 43, 0.96);
  --line: rgba(115, 215, 238, 0.24);
  --acid: #9dff00;
  --blue: #17c8ff;
  --gold: #9dff00;
  --green: #9dff00;
  --cyan-soft: #6de7ff;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
  background:
    linear-gradient(rgba(7, 16, 24, 0.84), rgba(7, 16, 24, 0.92)),
    url("https://images-assets.nasa.gov/image/iss056e201248/iss056e201248~large.jpg")
      center / cover fixed;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: linear-gradient(to bottom, black 0%, transparent 88%);
}

.app-shell {
  width: min(1500px, 100%);
  margin: 0 auto;
  padding: 10px;
}

.topbar {
  display: grid;
  grid-template-columns: 205px minmax(0, 1fr) 230px;
  gap: 18px;
  align-items: center;
  margin-bottom: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: rgba(5, 12, 18, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.enth-logo {
  width: 140px;
  max-width: 100%;
  height: auto;
  display: block;
}

.brand-link {
  display: grid;
  gap: 3px;
  width: 150px;
  max-width: 100%;
  color: var(--muted) !important;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 8px;
  line-height: 1;
  text-decoration: none !important;
  text-transform: uppercase;
}

.brand-link small {
  color: var(--muted);
  font-size: 8px;
  line-height: 1;
  text-transform: uppercase;
}

.brand-link:link,
.brand-link:visited {
  color: var(--muted) !important;
}

.brand-link:hover {
  color: var(--green);
}

.brand-link span {
  display: block;
  overflow: hidden;
  color: inherit !important;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-title {
  display: flex;
  gap: 10px;
  align-items: center;
  min-width: 0;
}

.mission-id,
.eyebrow,
.tagline,
.panel-header,
.instrument-title,
.metric span,
.tiny-note,
.stick-readout,
.controller-meta,
.button-tile small,
.raw-packet {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

.mission-id {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  width: fit-content;
  padding: 7px 10px;
  border: 1px solid var(--line);
  background: rgba(5, 12, 18, 0.7);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.signal-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 18px var(--acid);
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 340px);
  gap: 18px;
  align-items: end;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--gold);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

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

h1 {
  max-width: 900px;
  margin: 0;
  font-size: clamp(22px, 2.7vw, 42px);
  line-height: 0.9;
  letter-spacing: 0;
  text-transform: uppercase;
}

.subtitle {
  max-width: 780px;
  margin-bottom: 0;
  color: #c8d5da;
  font-size: clamp(14px, 1.4vw, 17px);
  line-height: 1.35;
}

.tagline {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}

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

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

.status-card {
  min-height: 48px;
  padding: 8px;
}

.status-card span,
.metric span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
}

.status-card strong {
  display: block;
  margin-top: 4px;
  color: var(--green);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 15px;
}

.live-mini {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 9px;
  line-height: 1;
  text-transform: uppercase;
}

.live-mini b {
  color: var(--green);
}

.console-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.panel {
  padding: 10px;
}

.connection-panel {
  position: sticky;
  top: 20px;
}

.panel-header,
.instrument-title {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.panel-header strong,
.instrument-title strong {
  color: var(--ink);
  text-align: right;
  overflow-wrap: anywhere;
}

.controller-list {
  display: grid;
  gap: 6px;
  min-height: 64px;
}

.controller-card {
  width: 100%;
  padding: 8px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.controller-card.active {
  border-color: var(--blue);
  outline: 2px solid rgba(11, 139, 220, 0.26);
}

.controller-card strong {
  display: block;
  overflow-wrap: anywhere;
  font-size: 12px;
}

.controller-meta {
  display: flex;
  gap: 10px;
  margin-top: 5px;
  color: var(--muted);
  font-size: 10px;
}

.profile-select {
  display: grid;
  gap: 5px;
  margin-top: 8px;
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.profile-select select {
  width: 100%;
  min-height: 30px;
  border: 1px solid var(--line);
  background: rgba(7, 22, 31, 0.95);
  color: var(--ink);
  font: inherit;
  outline: none;
}

.profile-select select:focus {
  border-color: var(--green);
}

button {
  font: inherit;
}

.primary-button,
.secondary-button {
  min-height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: white;
  cursor: pointer;
  font-weight: 800;
  text-transform: uppercase;
}

.primary-button {
  width: 100%;
  margin-top: 8px;
  background: linear-gradient(90deg, #006d8f, #0ea5c6);
}

.app-version {
  margin-top: 7px;
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 9px;
  text-align: right;
}

.input-note {
  margin: 9px 0 0;
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 9px;
  line-height: 1.35;
}

.secondary-button {
  background: rgba(23, 200, 255, 0.24);
}

.primary-button:hover,
.secondary-button:hover {
  filter: brightness(1.12);
}

.main-panel {
  min-height: 0;
}

.empty-state {
  min-height: 320px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  text-align: center;
}

.empty-state h2 {
  margin-bottom: 0;
  font-size: clamp(26px, 4vw, 48px);
  text-transform: uppercase;
}

.empty-state p {
  max-width: 560px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.orbit-ring {
  width: 132px;
  height: 132px;
  border: 2px solid rgba(157, 255, 0, 0.34);
  border-radius: 50%;
  background:
    radial-gradient(circle at center, rgba(157, 255, 0, 0.9) 0 7px, transparent 8px),
    repeating-conic-gradient(from 8deg, rgba(238, 244, 247, 0.38) 0 8deg, transparent 8deg 22deg);
  animation: rotate 8s linear infinite;
}

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

.hidden {
  display: none;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1.45fr 0.75fr 0.4fr 0.7fr 0.8fr 0.65fr;
  gap: 6px;
}

.metric {
  min-height: 50px;
  padding: 8px;
  background: var(--panel-strong);
}

.metric strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.2;
}

.visual-grid {
  display: grid;
  grid-template-columns: minmax(165px, 0.5fr) minmax(300px, 1.15fr) minmax(205px, 0.55fr);
  gap: 8px;
  align-items: stretch;
}

.stick-instrument {
  grid-column: auto;
}

.instrument {
  padding: 8px;
  background: rgba(8, 20, 28, 0.78);
}

.stick-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: start;
}

.stick-module {
  display: grid;
  place-items: center;
  gap: 5px;
}

.stick {
  position: relative;
  width: min(118px, 100%);
  aspect-ratio: 1;
  border: 1px solid rgba(238, 244, 247, 0.24);
  border-radius: 50%;
  background:
    linear-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.06) 1px, transparent 1px),
    radial-gradient(circle at center, transparent 0 18%, rgba(11, 139, 220, 0.13) 19% 100%);
  background-size: 100% 50%, 50% 100%, auto;
}

.stick span {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 22px rgba(157, 255, 0, 0.72);
  transform: translate(-50%, -50%);
}

.stick-readout {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  color: var(--muted);
  font-size: 10px;
}

.stick-readout b {
  color: var(--ink);
}

.tiny-note {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
}

.drift-details {
  color: var(--muted);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
  line-height: 1.35;
}

[data-tone="ok"] {
  color: var(--green);
}

[data-tone="warn"] {
  color: var(--cyan-soft);
}

[data-tone="bad"] {
  color: #d6ff5c;
}

.dpad-module {
  width: 140px;
  height: 140px;
  max-width: 100%;
  margin: 0 auto;
  display: grid;
  place-items: center;
}

.dpad-svg {
  width: 140px;
  height: 140px;
  overflow: visible;
}

.dpad-svg .dpad-key {
  stroke-width: 1;
}

.dpad-svg .dpad-center {
  stroke: rgba(23, 200, 255, 0.45);
  stroke-width: 1;
}

.dpad-svg text {
  fill: var(--ink);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  pointer-events: none;
}

.readout-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(260px, 0.65fr);
  gap: 8px;
}

.buttons-instrument {
  grid-row: span 2;
}

.button-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 5px;
}

.button-grid.four-column-layout {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.button-tile {
  min-height: 46px;
  padding: 6px;
  border: 1px solid rgba(238, 244, 247, 0.18);
  background: rgba(255, 255, 255, 0.045);
}

.button-spacer {
  visibility: hidden;
  pointer-events: none;
}

.button-tile.pressed {
  border-color: var(--green);
  background: rgba(157, 255, 0, 0.14);
  box-shadow: inset 0 0 0 1px rgba(157, 255, 0, 0.22), 0 0 18px rgba(157, 255, 0, 0.1);
}

.button-tile.touched {
  border-color: var(--cyan-soft);
}

.button-tile strong {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 5px;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  min-width: 0;
}

.button-name {
  min-width: 0;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.button-tile small {
  color: var(--muted);
  font-size: 9px;
}

.value-bar {
  height: 4px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
}

.value-bar span {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--green), var(--gold));
}

.axis-bars {
  display: grid;
  gap: 5px;
}

.axis-row {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) 58px;
  gap: 7px;
  align-items: center;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 10px;
}

.axis-track {
  position: relative;
  height: 7px;
  background: rgba(255, 255, 255, 0.11);
}

.axis-track::before {
  position: absolute;
  left: 50%;
  top: -4px;
  width: 1px;
  height: 15px;
  content: "";
  background: rgba(255, 255, 255, 0.32);
}

.axis-fill {
  position: absolute;
  top: 0;
  height: 100%;
  background: var(--blue);
}

.raw-packet {
  max-height: 112px;
  margin: 0;
  padding: 7px;
  overflow: auto;
  color: #cce4ed;
  border: 1px solid rgba(238, 244, 247, 0.12);
  background: rgba(0, 0, 0, 0.32);
  font-size: 9px;
  line-height: 1.18;
}

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

@media (max-width: 940px) {
  .topbar,
  .hero-grid,
  .console-layout,
  .visual-grid,
  .metrics-grid,
  .readout-grid {
    grid-template-columns: 1fr;
  }

  .connection-panel {
    position: static;
  }

  .buttons-instrument {
    grid-row: auto;
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 8px;
  }

  .topbar {
    gap: 8px;
  }

  .enth-logo {
    width: 110px;
  }

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

  .dpad-module {
    width: 138px;
    height: 138px;
  }

  .axis-row {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  .axis-row output {
    grid-column: 2;
  }
}
