/* The remote monitor is not viewed through the operator's goggle tubes.
   Do not toggle NIGHTGEAR or its emissive registry: the physical operator's
   presentation resumes immediately when viewChanged removes this class. */
body.reaper-view #nvg { display: none !important; }
.mq9-root {
  position: absolute;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

/* Console Panel (Pre-Deploy) */
.mq9-panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(90%, 520px);
  max-height: calc(100vh - 32px);
  background: rgba(6, 10, 7, 0.96);
  border: 1px solid rgba(141, 255, 158, 0.3);
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.9);
  display: flex;
  flex-direction: column;
  color: var(--phos, #c6ffce);
  font-family: "JetBrains Mono", monospace;
  pointer-events: auto;
  outline: none;
  overflow: hidden;
}

.mq9-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgba(141, 255, 158, 0.1);
  border-bottom: 1px solid rgba(141, 255, 158, 0.2);
}

.mq9-panel-title {
  font-family: "Oswald", Impact, sans-serif;
  letter-spacing: 0.12em;
  font-size: 18px;
}

.mq9-btn-close {
  background: transparent;
  border: none;
  color: var(--phos, #c6ffce);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.mq9-btn-close:hover {
  color: #fff;
}

.mq9-panel-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.mq9-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mq9-status-box {
  border: 1px solid rgba(141, 255, 158, 0.2);
  padding: 16px;
  text-align: center;
  background: rgba(0, 0, 0, 0.4);
}

.mq9-status-label {
  font-size: 11px;
  opacity: 0.7;
  letter-spacing: 0.1em;
}

.mq9-status-val {
  font-size: 18px;
  font-weight: bold;
  margin-top: 6px;
  color: var(--phos, #c6ffce);
}
.mq9-status-val.error {
  color: #ff6a5a;
}

.mq9-status-reason {
  font-size: 11px;
  color: #ff6a5a;
  margin-top: 6px;
}

.mq9-hint-text {
  font-size: 12px;
  line-height: 1.5;
  opacity: 0.8;
  color: var(--phos-dim, rgba(141, 255, 158, 0.7));
  text-align: center;
  white-space: pre-wrap;
}

/* Base Buttons */
.mq9-btn {
  background: rgba(141, 255, 158, 0.1);
  border: 1px solid rgba(141, 255, 158, 0.4);
  color: var(--phos, #c6ffce);
  font-family: "Oswald", Impact, sans-serif;
  letter-spacing: 0.05em;
  font-size: 14px;
  padding: 0 8px;
  cursor: pointer;
  text-transform: uppercase;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  transition: background 0.1s;
}

.mq9-btn:hover:not(:disabled) {
  background: rgba(141, 255, 158, 0.25);
}

.mq9-btn:active:not(:disabled) {
  background: rgba(141, 255, 158, 0.3);
}

.mq9-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.mq9-btn.active {
  background: var(--phos, #c6ffce);
  color: #06110a;
}

.mq9-btn-large {
  width: 100%;
  font-size: 16px;
  padding: 12px;
}

.mq9-btn-primary {
  background: rgba(141, 255, 158, 0.2);
  border-color: var(--phos, #c6ffce);
}

.mq9-danger {
  border-color: rgba(255, 106, 90, 0.6);
  color: #ff8a7a;
  background: rgba(255, 106, 90, 0.08);
}
.mq9-danger:hover:not(:disabled) {
  background: #ff6a5a;
  color: #170604;
}

.mq9-action-row {
  display: flex;
  gap: 12px;
}
.mq9-action-row > * {
  flex: 1;
}

/* HUD View Overlay */
.mq9-sensor {
  position: absolute;
  inset: 0;
  display: flex;
  pointer-events: none;
  outline: none;
}

.mq9-hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  font-family: "JetBrains Mono", monospace;
  font-size: 13px;
  color: rgba(200, 230, 200, 0.8);
  text-shadow: 0 0 4px rgba(0, 0, 0, 0.8);
  z-index: 2;
}

.mq9-hud > div {
  position: absolute;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mq9-hud > .mq9-feed-status {
  top: max(env(safe-area-inset-top, 16px), 16px);
  left: 50%;
  transform: translateX(-50%);
  display: block;
  max-width: 40vw;
  padding: 5px 9px;
  border: 1px solid rgba(200, 230, 200, 0.38);
  background: rgba(6, 10, 7, 0.78);
  color: rgba(225, 240, 225, 0.9);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-align: center;
  white-space: nowrap;
}

.mq9-hud > .mq9-feed-status.assisted {
  border-color: rgba(141, 255, 158, .7);
  color: var(--phos, #c6ffce);
}

.mq9-hud-tl { top: max(env(safe-area-inset-top, 16px), 16px); left: max(env(safe-area-inset-left, 16px), 16px); }
.mq9-hud-tr { top: max(env(safe-area-inset-top, 16px), 16px); right: max(env(safe-area-inset-right, 16px), 16px); text-align: right; }
.mq9-hud-bl { bottom: max(env(safe-area-inset-bottom, 16px) + 64px, 80px); left: max(env(safe-area-inset-left, 16px), 16px); }
.mq9-hud-br { bottom: max(env(safe-area-inset-bottom, 16px) + 64px, 80px); right: max(env(safe-area-inset-right, 16px), 16px); text-align: right; }

.mq9-warnings {
  position: absolute;
  top: 65%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #ff6a5a;
  font-family: "Oswald", Impact, sans-serif;
  font-size: 26px;
  letter-spacing: 0.12em;
  text-align: center;
  width: 100%;
}

.mq9-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100px;
  height: 100px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 2;
}
.mq9-ch-h-l, .mq9-ch-h-r, .mq9-ch-v-t, .mq9-ch-v-b {
  position: absolute;
  background: rgba(141, 255, 158, 0.5);
}
.mq9-ch-h-l { top: 49px; left: 0; width: 40px; height: 2px; }
.mq9-ch-h-r { top: 49px; right: 0; width: 40px; height: 2px; }
.mq9-ch-v-t { left: 49px; top: 0; width: 2px; height: 40px; }
.mq9-ch-v-b { left: 49px; bottom: 0; width: 2px; height: 40px; }
.mq9-ch-center {
  position: absolute;
  top: 48px; left: 48px; width: 4px; height: 4px;
  background: var(--phos, #c6ffce);
}

.mq9-slew-area {
  position: absolute;
  inset: 0;
  z-index: 3;
  touch-action: none;
  cursor: crosshair;
  pointer-events: auto;
}

/* Always-Visible Quick Bar */
.mq9-sensor-controls {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.mq9-quick-bar {
  position: absolute;
  bottom: max(env(safe-area-inset-bottom, 16px), 16px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  background: rgba(6, 10, 7, 0.9);
  border: 1px solid rgba(141, 255, 158, 0.4);
  padding: 6px;
  pointer-events: auto;
  align-items: center;
  box-sizing: border-box;
  max-width: calc(100vw - max(env(safe-area-inset-left, 0px), 0px) - max(env(safe-area-inset-right, 0px), 0px) - 12px);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.mq9-quick-bar::-webkit-scrollbar { display: none; }

.mq9-bar-separator {
  width: 1px;
  height: 32px;
  background: rgba(141, 255, 158, 0.3);
  margin: 0 4px;
  flex-shrink: 0;
}

/* Collapsible Settings Panel */
.mq9-settings-panel {
  position: absolute;
  top: max(env(safe-area-inset-top, 16px), 16px);
  right: max(env(safe-area-inset-right, 16px), 16px);
  bottom: max(env(safe-area-inset-bottom, 16px) + 72px, 80px);
  width: min(320px, calc(100vw - 32px));
  background: rgba(6, 10, 7, 0.96);
  border: 1px solid rgba(141, 255, 158, 0.4);
  display: none;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  overflow-y: auto;
  pointer-events: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.mq9-settings-panel.open {
  display: flex;
}

.mq9-sp-section {
  display: flex;
  flex-direction: column;
}

.mq9-sp-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--phos-dim, rgba(141, 255, 158, 0.8));
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}

.mq9-sp-sublabel {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--phos-dim, rgba(141, 255, 158, 0.6));
  margin-bottom: 4px;
}

.mq9-hotkeys {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--phos-dim, rgba(141, 255, 158, 0.7));
  line-height: 1.4;
  background: rgba(141, 255, 158, 0.05);
  padding: 8px;
  border: 1px solid rgba(141, 255, 158, 0.2);
}

.mq9-btn-grid {
  display: grid;
  gap: 4px;
}

.mq9-fmode-opts {
  background: rgba(141, 255, 158, 0.05);
  border: 1px solid rgba(141, 255, 158, 0.2);
  padding: 8px;
}

.mq9-num-input {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(141, 255, 158, 0.4);
  color: var(--phos, #c6ffce);
  font-family: "JetBrains Mono", monospace;
  font-size: 16px;
  text-align: center;
  min-height: 44px;
  width: 100%;
  outline: none;
}
.mq9-num-input:focus {
  border-color: var(--phos, #c6ffce);
}

.mq9-radar-map {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: #000;
  border: 1px solid rgba(141, 255, 158, 0.4);
  touch-action: none;
  cursor: crosshair;
}

/* Flight Stick */
.mq9-flight-stick {
  position: absolute;
  left: max(env(safe-area-inset-left, 16px) + 24px, 24px);
  bottom: max(env(safe-area-inset-bottom, 16px) + 90px, 90px);
  width: 120px;
  height: 120px;
  border: 2px solid rgba(141, 255, 158, 0.3);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
  touch-action: none;
  z-index: 5;
  display: none;
  pointer-events: auto;
}
.mq9-flight-stick-nub {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  margin-top: -22px;
  margin-left: -22px;
  border-radius: 50%;
  background: rgba(141, 255, 158, 0.6);
  pointer-events: none;
}

@media (max-width: 600px) {
  .mq9-hud { font-size: 11px; }
  .mq9-hud > div:not(.mq9-warnings) { max-width: calc(50% - 20px); }
  .mq9-hud-bl, .mq9-hud-br { bottom: max(env(safe-area-inset-bottom, 16px) + 64px, 72px); }

  .mq9-quick-bar {
    width: calc(100vw - max(env(safe-area-inset-left, 0px), 0px) - max(env(safe-area-inset-right, 0px), 0px) - 16px);
    justify-content: flex-start;
  }

  .mq9-hud > .mq9-feed-status {
    top: max(env(safe-area-inset-top, 8px), 8px);
    max-width: 48vw;
    font-size: 9px;
  }

  .mq9-settings-panel {
    left: max(env(safe-area-inset-left, 8px), 8px);
    right: max(env(safe-area-inset-right, 8px), 8px);
    width: auto;
    padding: 12px;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .mq9-hud { font-size: 10px; }
  .mq9-hud > div:not(.mq9-warnings) { max-width: calc(50% - 24px); }

  .mq9-warnings { top: 50%; font-size: 20px; }
}
