:root {
  color-scheme: dark;
  --bg: #02030a;
  --panel: rgba(5, 13, 24, 0.72);
  --panel-strong: rgba(8, 24, 32, 0.88);
  --line: rgba(105, 244, 235, 0.34);
  --line-hot: rgba(255, 196, 95, 0.72);
  --text: #ecfbff;
  --muted: #8fa8b8;
  --cyan: #65fff2;
  --amber: #ffc65f;
  --rose: #ff6f9c;
  --green: #7dffae;
  --violet: #b894ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, "Segoe UI", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont,
    sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #02030a;
}

#space-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

#space-canvas:active {
  cursor: grabbing;
}

.map-reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 4;
  width: 58px;
  height: 58px;
  pointer-events: none;
  border: 1px solid rgba(101, 255, 242, 0.62);
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.92);
  transition:
    opacity 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease;
}

.map-reticle::before,
.map-reticle::after {
  content: "";
  position: absolute;
  background: rgba(101, 255, 242, 0.72);
}

.map-reticle::before {
  left: 50%;
  top: -9px;
  width: 1px;
  height: 76px;
}

.map-reticle::after {
  left: -9px;
  top: 50%;
  width: 76px;
  height: 1px;
}

.map-reticle.visible {
  opacity: 0.9;
  transform: translate(-50%, -50%) scale(1);
}

.map-reticle.target-ready {
  border-color: rgba(125, 255, 174, 0.92);
  box-shadow: 0 0 26px rgba(125, 255, 174, 0.25);
}

.map-reticle.confirm {
  border-color: rgba(255, 198, 95, 0.95);
  box-shadow:
    0 0 0 10px rgba(255, 198, 95, 0.1),
    0 0 32px rgba(255, 198, 95, 0.36);
}

.label-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.space-label {
  position: absolute;
  min-width: 128px;
  max-width: 180px;
  display: grid;
  gap: 3px;
  padding: 7px 9px;
  border: 1px solid rgba(101, 255, 242, 0.24);
  border-radius: 6px;
  background: rgba(3, 10, 18, 0.62);
  color: var(--muted);
  opacity: 0;
  transform: translate3d(-50%, -50%, 0) scale(0.94);
  transition:
    opacity 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
  backdrop-filter: blur(8px);
}

.space-label.visible {
  opacity: 0.86;
}

.space-label.selected {
  border-color: rgba(255, 198, 95, 0.78);
  color: var(--amber);
  opacity: 1;
  transform: translate3d(-50%, -50%, 0) scale(1);
}

.space-label.real-object {
  border-color: rgba(125, 255, 174, 0.24);
}

.space-label.real-object.selected {
  border-color: rgba(125, 255, 174, 0.76);
  color: var(--green);
}

.space-label strong {
  color: inherit;
  font-size: 12px;
  line-height: 1.15;
  font-weight: 700;
}

.space-label span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.hud {
  position: absolute;
  z-index: 5;
  color: var(--text);
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(8, 29, 36, 0.84), rgba(11, 8, 21, 0.66)),
    var(--panel);
  box-shadow: 0 0 28px rgba(57, 234, 225, 0.12);
  backdrop-filter: blur(14px);
}

.hud-top {
  top: 22px;
  left: 28px;
  right: 28px;
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 20px;
  border-radius: 8px;
}

.brand-block {
  display: grid;
  gap: 4px;
}

.brand-kicker,
.panel-header span,
.route-readout span,
.range-track span,
.telemetry span,
.status-pill,
dt {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: var(--text);
  font-size: 28px;
  line-height: 1;
  font-weight: 650;
}

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

.status-pill {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(101, 255, 242, 0.28);
  border-radius: 6px;
  padding: 0 12px;
  background: rgba(6, 20, 29, 0.76);
  color: var(--cyan);
  white-space: nowrap;
}

.status-pill.offline {
  border-color: rgba(255, 111, 156, 0.45);
  color: var(--rose);
}

.side-panel {
  top: 132px;
  left: 28px;
  width: min(360px, calc(100vw - 56px));
  padding: 18px;
  border-radius: 8px;
}

.panel-header {
  display: grid;
  gap: 7px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(101, 255, 242, 0.22);
}

.panel-header strong {
  color: var(--amber);
  font-size: 20px;
  line-height: 1.1;
  font-weight: 650;
}

.metric-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 13px;
  margin: 17px 0;
}

.metric-grid div {
  min-width: 0;
}

dt {
  margin-bottom: 5px;
}

dd {
  margin: 0;
  color: var(--text);
  font-size: 15px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.object-details {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: -2px 0 14px;
  padding: 11px;
  border: 1px solid rgba(101, 255, 242, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.object-details[hidden] {
  display: none;
}

.object-details div {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.object-details span {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.1;
  text-transform: uppercase;
}

.object-details strong {
  min-width: 0;
  color: var(--text);
  font-size: 12px;
  line-height: 1.15;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.route-readout {
  min-height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 14px;
  border: 1px solid rgba(255, 198, 95, 0.32);
  border-radius: 8px;
  background: rgba(28, 21, 8, 0.48);
}

.route-readout strong {
  min-width: 0;
  color: var(--amber);
  font-size: 14px;
  text-align: right;
  overflow-wrap: anywhere;
}

.route-bars {
  display: grid;
  gap: 10px;
  margin-top: 13px;
}

.route-bar {
  display: grid;
  gap: 6px;
}

.route-bar div,
.route-eta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.route-bar span,
.route-eta span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.route-bar strong,
.route-eta strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.2;
}

.route-bar i {
  position: relative;
  width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(143, 168, 184, 0.14);
}

.route-bar b {
  position: absolute;
  inset: 0 auto 0 0;
  width: 50%;
  border-radius: inherit;
  background: var(--cyan);
  box-shadow: 0 0 16px rgba(101, 255, 242, 0.28);
}

#energy-bar {
  background: var(--amber);
  box-shadow: 0 0 16px rgba(255, 198, 95, 0.34);
}

#risk-bar {
  background: var(--rose);
  box-shadow: 0 0 16px rgba(255, 111, 156, 0.3);
}

#signal-bar {
  background: var(--green);
  box-shadow: 0 0 16px rgba(125, 255, 174, 0.28);
}

.route-eta {
  min-height: 32px;
  padding: 8px 10px;
  border: 1px solid rgba(101, 255, 242, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.03);
}

.solar-roster {
  top: 132px;
  right: 28px;
  width: 266px;
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
}

.roster-kicker {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
  text-transform: uppercase;
}

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

.solar-item {
  min-width: 0;
  min-height: 42px;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(101, 255, 242, 0.16);
  border-radius: 6px;
  padding: 7px 8px;
  color: var(--text);
  background: rgba(3, 12, 18, 0.6);
  cursor: pointer;
}

.solar-item:hover,
.solar-item.selected {
  border-color: rgba(255, 198, 95, 0.72);
  background: rgba(255, 198, 95, 0.1);
}

.solar-item.routed {
  box-shadow: inset 0 0 0 1px rgba(101, 255, 242, 0.18);
}

.solar-item i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--body-color);
  box-shadow: 0 0 12px var(--body-color);
}

.solar-item span {
  min-width: 0;
  display: grid;
  gap: 2px;
  text-align: left;
}

.solar-item strong,
.solar-item small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.solar-item strong {
  font-size: 12px;
  line-height: 1.1;
  font-weight: 650;
}

.solar-item small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.1;
}

.camera-panel {
  right: 28px;
  bottom: 104px;
  width: 266px;
  padding: 12px;
  border-radius: 8px;
}

.camera-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 1px solid rgba(101, 255, 242, 0.32);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.5);
}

#camera-feed,
#hand-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#camera-feed {
  object-fit: cover;
  transform: scaleX(-1);
  opacity: 0.72;
}

#hand-canvas {
  pointer-events: none;
}

.reticle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 198, 95, 0.72);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 140ms ease;
}

.reticle::before,
.reticle::after {
  content: "";
  position: absolute;
  background: rgba(255, 198, 95, 0.78);
}

.reticle::before {
  left: 50%;
  top: -6px;
  width: 1px;
  height: 54px;
}

.reticle::after {
  left: -6px;
  top: 50%;
  width: 54px;
  height: 1px;
}

.reticle.visible {
  opacity: 1;
}

.reticle.target-ready {
  border-color: rgba(125, 255, 174, 0.9);
  box-shadow: 0 0 22px rgba(125, 255, 174, 0.28);
}

.reticle.confirm {
  border-color: rgba(255, 198, 95, 0.95);
  box-shadow:
    0 0 0 8px rgba(255, 198, 95, 0.12),
    0 0 26px rgba(255, 198, 95, 0.36);
}

#start-gesture {
  width: 100%;
  min-height: 42px;
  margin-top: 10px;
  border: 1px solid rgba(101, 255, 242, 0.48);
  border-radius: 8px;
  background: rgba(13, 54, 62, 0.9);
  color: var(--text);
  cursor: pointer;
}

#start-gesture:hover {
  border-color: rgba(255, 198, 95, 0.78);
  color: var(--amber);
}

#start-gesture:disabled {
  color: var(--muted);
  cursor: wait;
  opacity: 0.72;
}

.camera-diagnostics {
  display: grid;
  grid-template-columns: 1fr;
  gap: 5px;
  margin-top: 9px;
}

.camera-diagnostics span {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(101, 255, 242, 0.18);
  border-radius: 6px;
  padding: 0 8px;
  color: var(--muted);
  background: rgba(3, 12, 18, 0.55);
  font-size: 11px;
  line-height: 1.2;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.camera-diagnostics span.ok {
  border-color: rgba(125, 255, 174, 0.28);
  color: var(--green);
}

.camera-diagnostics span.warn {
  border-color: rgba(255, 198, 95, 0.34);
  color: var(--amber);
}

.camera-diagnostics span.error {
  border-color: rgba(255, 111, 156, 0.4);
  color: var(--rose);
}

.command-rail {
  left: 28px;
  right: 28px;
  bottom: 24px;
  min-height: 62px;
  display: grid;
  grid-template-columns: minmax(340px, 0.85fr) 1fr;
  align-items: center;
  gap: 20px;
  padding: 13px 16px;
  border-radius: 8px;
}

.range-track {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.range-track span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(143, 168, 184, 0.3);
  border-radius: 6px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
}

.range-track span.active {
  border-color: rgba(255, 198, 95, 0.78);
  color: var(--amber);
  background: rgba(255, 198, 95, 0.1);
}

.telemetry {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.telemetry span {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(101, 255, 242, 0.2);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--green);
  background: rgba(4, 17, 14, 0.6);
}

.scanline {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0.18;
  background-image: repeating-linear-gradient(
    to bottom,
    rgba(236, 251, 255, 0.08) 0,
    rgba(236, 251, 255, 0.08) 1px,
    transparent 1px,
    transparent 6px
  );
}

@media (max-width: 900px) {
  .hud-top {
    top: 14px;
    left: 14px;
    right: 14px;
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 24px;
  }

  .side-panel {
    top: 150px;
    left: 14px;
    width: calc(100vw - 28px);
    max-width: 360px;
  }

  .camera-panel {
    right: 14px;
    bottom: 96px;
    width: 220px;
  }

  .solar-roster {
    top: 150px;
    right: 14px;
    width: 220px;
  }

  .solar-list {
    grid-template-columns: 1fr;
  }

  .command-rail {
    left: 14px;
    right: 14px;
    bottom: 14px;
  }
}

@media (max-width: 560px) {
  .side-panel {
    top: 172px;
    max-width: none;
    padding: 14px;
  }

  .panel-header {
    gap: 5px;
    padding-bottom: 12px;
  }

  .panel-header strong {
    font-size: 18px;
  }

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

  dd {
    font-size: 14px;
  }

  .route-readout {
    min-height: 44px;
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
    padding: 9px 10px;
  }

  .route-readout strong {
    text-align: left;
  }

  .route-bars {
    display: none;
  }

  .object-details {
    display: none;
  }

  .camera-panel {
    left: 14px;
    right: auto;
    top: 426px;
    bottom: auto;
    width: min(184px, calc(100vw - 28px));
    padding: 10px;
  }

  .camera-diagnostics {
    gap: 4px;
    margin-top: 7px;
  }

  .camera-diagnostics span {
    min-height: 20px;
    padding: 0 7px;
    font-size: 10px;
  }

  #context-status {
    display: none;
  }

  #start-gesture {
    min-height: 38px;
    margin-top: 8px;
  }

  .solar-roster {
    left: 212px;
    right: 14px;
    top: 426px;
    width: auto;
    max-height: 236px;
    padding: 10px;
    overflow: hidden;
  }

  .solar-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 196px;
    overflow: auto;
  }

  .solar-item {
    min-height: 32px;
    grid-template-columns: 8px minmax(0, 1fr);
    gap: 4px;
    padding: 4px;
  }

  .solar-item i {
    width: 8px;
    height: 8px;
  }

  .solar-item strong {
    font-size: 10px;
  }

  .solar-item small {
    font-size: 8px;
  }

  .space-label {
    display: none;
  }

  .range-track {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .command-rail {
    grid-template-columns: 1fr;
    gap: 12px;
  }

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

@media (max-height: 680px) and (min-width: 700px) {
  .hud-top {
    min-height: 64px;
    padding: 12px 16px;
  }

  h1 {
    font-size: 23px;
  }

  .side-panel {
    top: 138px;
    width: 320px;
    padding: 14px;
  }

  .panel-header {
    padding-bottom: 12px;
  }

  .panel-header strong {
    font-size: 18px;
  }

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

  .route-readout {
    min-height: 44px;
    padding: 9px 10px;
  }

  .camera-panel {
    bottom: 88px;
    width: 232px;
  }

  .solar-roster {
    top: 112px;
    width: 232px;
  }

  .command-rail {
    min-height: 58px;
    padding: 11px 14px;
  }
}
