/**
 * Guardian Angel — Mission Control layout.
 *
 * Full-viewport command deck. Three-column grid + top strip + bottom signal
 * stream. No scrolling at the body level; each panel scrolls inside itself.
 */

:root {
  --m-gutter: 20px;
  --m-radius: 14px;
  --m-bg: #04060e;
  --m-panel: #0a0e18;
  --m-panel-2: #0d1320;
  --m-line: rgba(122, 166, 255, 0.10);
  --m-line-strong: rgba(122, 166, 255, 0.28);
  --m-text: #e8ecf4;
  --m-dim: #8f9bb3;
  --m-sub: #5c6578;
  --m-accent: #7aa6ff;
  --m-accent-rgb: 122, 166, 255;
  --m-warn: #fbbf24;
  --m-crit: #f87171;
  --m-ok: #34d399;
  --m-info: #38bdf8;
}

html, body {
  min-height: 100%;
  /* Match the deepest body bg so overscroll bounce never flashes white. */
  background-color: #03050b;
}
body.mission {
  margin: 0;
  background: var(--m-bg);
  color: var(--m-text);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 14px;
  overflow-x: hidden;       /* allow page-level vertical scroll */
  min-height: 100vh;
}
body.mission .mono { font-family: "JetBrains Mono", ui-monospace, monospace; }

/* Master grid: header + ticker + 3-col + signal stream + footer.
 * Uses min-height (not height) so on short viewports the page scrolls
 * naturally, and on tall ones the deck still fills the screen. The 3-col
 * .m-main is flex-driven inside, with each panel scrolling its own body. */
.m-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto minmax(420px, 1fr) auto auto;
  gap: var(--m-gutter);
  padding: var(--m-gutter);
}

/* ─── Header strip ──────────────────────────────────────────────────── */
.m-header {
  display: grid;
  grid-template-columns: minmax(220px, auto) 1fr auto;
  gap: 20px;
  align-items: center;
  padding: 16px 22px;
  border: 1px solid color-mix(in srgb, var(--m-accent) 30%, var(--m-line-strong));
  border-radius: var(--m-radius);
  background:
    linear-gradient(180deg,
      rgba(var(--m-accent-rgb), 0.12) 0%,
      var(--m-panel) 60%,
      rgba(10, 14, 24, 0.9) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 0 0 1px rgba(var(--m-accent-rgb), 0.16),
    0 18px 48px rgba(0, 0, 0, 0.5);
  position: relative;
}
.m-header::before {
  content: "";
  position: absolute;
  top: 0; left: 22px; right: 22px;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%, rgba(var(--m-accent-rgb), 0.55) 50%, transparent 100%);
}
.m-brand {
  display: flex; align-items: center; gap: 12px;
}
.m-brand img { width: 30px; height: 30px; filter: drop-shadow(0 0 12px rgba(var(--m-accent-rgb), 0.55)); }
.m-brand .m-title {
  font-family: "Outfit", sans-serif;
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
  background: linear-gradient(110deg, #fff 0%, #cfd9f0 50%, var(--m-accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}
.m-brand .m-sub {
  display: block;
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--m-sub);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-top: 2px;
}
.m-header-stats {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}
.m-stat {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  min-width: 80px;
  padding: 0 14px;
  border-left: 1px solid var(--m-line);
}
.m-stat:first-child { border-left: 0; }
.m-stat-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--m-sub);
}
.m-stat-value {
  font-family: "Outfit", sans-serif;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--m-text);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.m-stat-value.kinetic { transition: transform 0.18s ease; }
.m-stat-value.bumping { animation: m-bump 0.45s ease-out; }
@keyframes m-bump {
  0% { transform: translateY(0) scale(1); color: var(--m-text); }
  35% { transform: translateY(-3px) scale(1.06); color: var(--m-accent); }
  100% { transform: translateY(0) scale(1); }
}
.m-header-actions { display: flex; align-items: center; gap: 10px; }
.m-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 999px;
  background: var(--m-panel-2); border: 1px solid var(--m-line-strong);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px; letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--m-dim);
}
.m-pill .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--m-sub);
  transition: background 0.18s ease, box-shadow 0.18s ease;
}
.m-pill.ok .dot   { background: var(--m-ok);   box-shadow: 0 0 14px var(--m-ok); }
.m-pill.warn .dot { background: var(--m-warn); box-shadow: 0 0 14px var(--m-warn); }
.m-pill.error .dot{ background: var(--m-crit); box-shadow: 0 0 14px var(--m-crit); }
.m-pill.cadence-hot {
  color: var(--m-warn);
  border-color: rgba(251, 191, 36, 0.45);
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.20), 0 0 22px rgba(251, 191, 36, 0.18);
  animation: m-hot-pulse 1.6s ease-in-out infinite;
}
@keyframes m-hot-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.20), 0 0 22px rgba(251, 191, 36, 0.18); }
  50%      { box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.45), 0 0 36px rgba(251, 191, 36, 0.35); }
}
.m-toggle {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 999px;
  background: var(--m-panel-2); border: 1px solid var(--m-line-strong);
  color: var(--m-dim); cursor: pointer;
  font: inherit; font-family: "JetBrains Mono", monospace;
  font-size: 11px; letter-spacing: 0.10em; text-transform: uppercase;
  transition: all 0.18s ease;
}
.m-toggle:hover { color: var(--m-text); border-color: rgba(var(--m-accent-rgb), 0.55); }
.m-toggle.is-on {
  color: var(--m-text); border-color: var(--m-accent);
  box-shadow: 0 0 0 1px rgba(var(--m-accent-rgb), 0.45), 0 0 22px rgba(var(--m-accent-rgb), 0.30);
  background: linear-gradient(180deg, rgba(var(--m-accent-rgb), 0.18) 0%, var(--m-panel-2) 100%);
}
.m-toggle.is-on .m-bell { animation: m-bell-shake 1.4s ease-in-out infinite; }
@keyframes m-bell-shake {
  0%, 60%, 100% { transform: rotate(0); }
  10% { transform: rotate(-12deg); } 20% { transform: rotate(10deg); }
  30% { transform: rotate(-8deg); }  40% { transform: rotate(6deg); }
  50% { transform: rotate(-4deg); }
}

/* ─── Ticker tape (sub-strip under header) ─────────────────────────── */
.m-ticker {
  position: relative;
  overflow: hidden;
  height: 36px;
  border: 1px solid var(--m-line);
  border-radius: 10px;
  background: var(--m-panel);
}
.m-ticker-track {
  display: inline-flex;
  gap: 32px;
  white-space: nowrap;
  height: 100%;
  align-items: center;
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  /* Two duplicated runs (rendered by JS) + translate from 0 to -50% =
     the second run lands exactly where the first started, giving a
     seamless infinite loop with no visual gap on restart. */
  animation: m-ticker-scroll 80s linear infinite;
  will-change: transform;
}
.m-ticker:hover .m-ticker-track { animation-play-state: paused; }
.m-ticker-item { display: inline-flex; gap: 8px; align-items: baseline; padding-right: 0; }
.m-ticker-sym { color: var(--m-text); font-weight: 500; }
.m-ticker-val { color: var(--m-dim); }
.m-ticker-up   { color: var(--m-ok); }
.m-ticker-down { color: var(--m-crit); }
.m-ticker-flat { color: var(--m-sub); }
@keyframes m-ticker-scroll {
  from { transform: translate3d(0, 0, 0); }
  to   { transform: translate3d(-50%, 0, 0); }
}

/* ─── Main 3-column deck ────────────────────────────────────────────── */
.m-main {
  display: grid;
  grid-template-columns: minmax(280px, 320px) 1fr minmax(300px, 360px);
  gap: var(--m-gutter);
  min-height: 0;
}

/* Cap each panel to viewport-fit on desktop so the roster (60+ rows) scrolls
 * INSIDE its panel-body instead of growing the whole row to its full height
 * (which left a giant blank gap around the globe). On mobile this cap is
 * removed in the stacked layout below so each panel can size naturally. */
.m-main > .m-panel {
  max-height: calc(100vh - 280px);
  min-height: 360px;
}

.m-panel {
  border: 1px solid var(--m-line);
  border-radius: var(--m-radius);
  background: var(--m-panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.40);
}
.m-panel:hover { border-color: var(--m-line-strong); }
.m-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--m-line);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--m-dim);
  background: linear-gradient(180deg, rgba(var(--m-accent-rgb), 0.04) 0%, transparent 100%);
}
.m-panel-head .m-head-tag {
  font-size: 10px; color: var(--m-sub);
}
.m-panel-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 8px 12px 12px;
}
.m-panel-body::-webkit-scrollbar { width: 6px; }
.m-panel-body::-webkit-scrollbar-thumb { background: rgba(var(--m-accent-rgb), 0.18); border-radius: 3px; }

/* ─── Left: protocol roster ────────────────────────────────────────── */
.m-roster-row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.m-roster-row:hover {
  background: rgba(var(--m-accent-rgb), 0.06);
  border-color: var(--m-line);
}
.m-roster-rank {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--m-sub);
  text-align: right;
}
.m-roster-name {
  font-weight: 500;
  color: var(--m-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m-roster-chain {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--m-sub);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.10em;
}
.m-roster-tvl {
  font-family: "JetBrains Mono", monospace;
  font-size: 12px;
  color: var(--m-text);
  text-align: right;
}
.m-roster-bar {
  grid-column: 1 / -1;
  height: 3px;
  margin-top: 6px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--m-accent) 0%, rgba(var(--m-accent-rgb), 0.10) 100%);
  opacity: 0.65;
}

.m-chain-tabs {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 8px 12px 0;
}
.m-chain-tab {
  font: inherit; font-family: "JetBrains Mono", monospace;
  font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 5px 8px; border-radius: 6px;
  background: transparent; border: 1px solid var(--m-line);
  color: var(--m-sub); cursor: pointer;
  transition: all 0.15s ease;
}
.m-chain-tab:hover { color: var(--m-text); border-color: var(--m-line-strong); }
.m-chain-tab[aria-selected="true"] {
  color: var(--m-text); background: rgba(var(--m-accent-rgb), 0.16);
  border-color: var(--m-accent);
  box-shadow: 0 0 12px rgba(var(--m-accent-rgb), 0.30);
}
/* CEX tab visually distinct from DeFi chains — different accent so the
 * informational-only nature is obvious before the user even clicks. */
.m-chain-tab.m-tab-cex {
  color: var(--m-warn);
  border-color: rgba(251, 191, 36, 0.40);
}
.m-chain-tab.m-tab-cex:hover { border-color: var(--m-warn); }
.m-chain-tab.m-tab-cex[aria-selected="true"] {
  background: rgba(251, 191, 36, 0.14);
  border-color: var(--m-warn);
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.28);
  color: var(--m-text);
}
.m-roster-note {
  margin: 8px 12px 4px;
  padding: 8px 10px;
  border-left: 2px solid rgba(251, 191, 36, 0.55);
  border-radius: 0 6px 6px 0;
  background: rgba(251, 191, 36, 0.06);
  color: var(--m-dim);
  font-size: 11px;
  line-height: 1.45;
}

/* ─── Center: command deck ─────────────────────────────────────────── */
/* Deck panel is fully transparent — the globe floats over the body grid/mesh
 * background with zero visible container. Every visual property the base
 * .m-panel sets is overridden here. */
.m-panel.m-deck {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: stretch;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0;
}
.m-panel.m-deck:hover {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}
.m-panel.m-deck::before { display: none !important; }
.m-globe-stage {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  min-height: 0;
  overflow: hidden;        /* hard clip so a tall globe never bleeds into readout */
  padding: 18px;
}
/* Fixed pixel size — no % calculation, so neighbouring panels resizing
 * (scrollbar appearing on hover, roster row reflowing) cannot make the
 * globe pulse. Breakpoints below adjust at common screen widths.
 *
 * NOTE: do NOT add `contain: paint` here — the .m-globe element has an
 * outer box-shadow glow that extends ~80px beyond the sphere; paint
 * containment clips that glow at the wrap's square edge and draws a
 * literal rectangle around the globe. `contain: layout` alone is fine
 * for isolating from sibling reflows, but the fixed pixel size already
 * makes that unnecessary. */
.m-globe-wrap {
  position: relative;
  width: 300px;
  height: 300px;
  max-width: 100%;
  max-height: 100%;
  margin: auto;
}
@media (max-width: 1180px) { .m-globe-wrap { width: 260px; height: 260px; } }
@media (max-width: 980px)  { .m-globe-wrap { width: 240px; height: 240px; } }
@media (max-width: 480px)  { .m-globe-wrap { width: 220px; height: 220px; } }
.m-globe {
  position: absolute; inset: 0;
  border-radius: 50%;
  overflow: hidden;
  background:
    radial-gradient(circle at 34% 30%, rgba(255,255,255,0.20) 0%, transparent 22%),
    radial-gradient(circle at 50% 55%, rgba(var(--m-accent-rgb), 0.45) 0%, rgba(6,10,20,0.96) 68%);
  box-shadow:
    inset 0 0 80px rgba(var(--m-accent-rgb), 0.40),
    inset 0 0 160px rgba(0,0,0,0.65),
    0 0 80px rgba(var(--m-accent-rgb), 0.35),
    0 0 0 1px rgba(var(--m-accent-rgb), 0.22);
}
.m-globe::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  background: repeating-linear-gradient(
    to bottom, transparent 0, transparent 26px,
    rgba(var(--m-accent-rgb), 0.13) 26px, rgba(var(--m-accent-rgb), 0.13) 27px);
  mask: radial-gradient(circle at 50% 50%, black 60%, transparent 80%);
  -webkit-mask: radial-gradient(circle at 50% 50%, black 60%, transparent 80%);
}
.m-globe::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  background: repeating-linear-gradient(
    to right, transparent 0, transparent 32px,
    rgba(var(--m-accent-rgb), 0.16) 32px, rgba(var(--m-accent-rgb), 0.16) 33px);
  mask: radial-gradient(circle at 50% 50%, black 50%, transparent 78%);
  -webkit-mask: radial-gradient(circle at 50% 50%, black 50%, transparent 78%);
  animation: m-globe-drift 24s linear infinite;
}
@keyframes m-globe-drift {
  from { background-position: 0 0; }
  to   { background-position: 64px 0; }
}
.m-radar {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg,
    rgba(var(--m-accent-rgb), 0.30) 0deg,
    rgba(var(--m-accent-rgb), 0.06) 26deg,
    transparent 50deg, transparent 360deg);
  mix-blend-mode: screen;
  opacity: 0.40;
  animation: m-radar-spin 6s linear infinite;
}
@keyframes m-radar-spin { to { transform: rotate(360deg); } }
.m-shine {
  position: absolute; inset: 0;
  border-radius: 50%;
  pointer-events: none;
  background: radial-gradient(circle at 30% 25%, rgba(255,255,255,0.22) 0%, rgba(255,255,255,0.04) 18%, transparent 38%);
}
/* Orbits hug the sphere closer + flatter rotateX so the overall silhouette
   reads round, not oval. Removed the wide alt ring entirely. */
.m-orbit {
  position: absolute; inset: -8px;
  border-radius: 50%;
  border: 1px solid rgba(var(--m-accent-rgb), 0.28);
  animation: m-orbit-spin 22s linear infinite;
}
.m-orbit.alt {
  inset: -18px;
  border-color: rgba(var(--m-accent-rgb), 0.14);
  border-style: dashed;
  animation: m-orbit-spin 36s linear infinite reverse;
}
@keyframes m-orbit-spin {
  from { transform: rotateX(78deg) rotateZ(0deg); }
  to   { transform: rotateX(78deg) rotateZ(360deg); }
}
.m-pip {
  position: absolute; top: 50%; left: 0;
  width: 12px; height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: var(--m-accent);
  box-shadow: 0 0 18px var(--m-accent), 0 0 32px rgba(var(--m-accent-rgb), 0.7);
}
.m-pip.warn { background: var(--m-warn); box-shadow: 0 0 18px var(--m-warn); }
.m-pip.crit { background: var(--m-crit); box-shadow: 0 0 22px var(--m-crit), 0 0 40px rgba(248, 113, 113, 0.7); }
.m-globe-ping {
  position: absolute; width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--m-accent);
  box-shadow: 0 0 0 0 rgba(var(--m-accent-rgb), 0.65);
  animation: m-globe-ping 1.8s ease-out forwards;
  pointer-events: none;
  z-index: 2;
}
@keyframes m-globe-ping {
  0% { box-shadow: 0 0 0 0 rgba(var(--m-accent-rgb), 0.65); opacity: 1; transform: scale(0.5); }
  100% { box-shadow: 0 0 0 26px rgba(var(--m-accent-rgb), 0); opacity: 0; transform: scale(1.2); }
}

.m-deck-readout {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 14px 18px 4px;
  background: transparent;
  border-top: 0;
}
.m-deck-readout .m-readout-row {
  display: flex; justify-content: center; gap: 22px;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--m-dim);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 8px;
}
.m-deck-readout .m-readout-row span strong {
  color: var(--m-text);
  font-weight: 600;
  margin-right: 6px;
}
.m-headline {
  font-family: "Outfit", sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  background: linear-gradient(110deg, #fff 0%, #cfd9f0 50%, var(--m-accent) 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.m-subline { color: var(--m-dim); margin-top: 4px; font-size: 13px; }

/* ─── Right: chatter feed ───────────────────────────────────────────── */
.m-chat-row {
  padding: 12px 8px;
  border-bottom: 1px dashed var(--m-line);
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: start;
}
.m-chat-row:last-child { border-bottom: 0; }
.m-chat-handle {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--m-accent);
  font-weight: 500;
}
.m-chat-time {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--m-sub);
}
.m-chat-text {
  grid-column: 1 / -1;
  margin-top: 4px;
  color: var(--m-text);
  font-size: 13px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.m-chat-empty {
  color: var(--m-sub);
  text-align: center;
  font-size: 12px;
  padding: 24px 8px;
  font-family: "JetBrains Mono", monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ─── Bottom: streaming signal feed ────────────────────────────────── */
.m-stream {
  border: 1px solid var(--m-line);
  border-radius: var(--m-radius);
  background: var(--m-panel);
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 140px;
  max-height: 200px;
  overflow: hidden;
}
.m-stream-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--m-line);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--m-dim);
  background: linear-gradient(90deg, rgba(var(--m-accent-rgb), 0.10) 0%, transparent 60%);
}
.m-stream-body {
  overflow: auto;
  padding: 6px 10px 10px;
}
.m-signal {
  position: relative;
  display: grid;
  grid-template-columns: 80px 80px 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 8px 12px 8px 18px;
  border-bottom: 1px solid var(--m-line);
}
.m-signal:last-child { border-bottom: 0; }
.m-signal::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 2px;
  background: var(--m-sub);
}
.m-signal.sev-info::before    { background: var(--m-info); box-shadow: 0 0 10px var(--m-info); }
.m-signal.sev-warn::before    { background: var(--m-warn); box-shadow: 0 0 12px var(--m-warn); animation: m-row-pulse 2.4s ease-in-out infinite; }
.m-signal.sev-critical::before{ background: var(--m-crit); box-shadow: 0 0 14px var(--m-crit); animation: m-row-pulse 1.4s ease-in-out infinite; }
@keyframes m-row-pulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.6); } }
.m-signal.fresh { animation: m-signal-pop 1.6s ease-out 1; }
@keyframes m-signal-pop {
  0% { background: rgba(var(--m-accent-rgb), 0.18); transform: translateY(-4px); }
  100% { background: transparent; transform: translateY(0); }
}
.m-signal-sev {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.m-signal.sev-info    .m-signal-sev { color: var(--m-info); }
.m-signal.sev-warn    .m-signal-sev { color: var(--m-warn); }
.m-signal.sev-critical .m-signal-sev { color: var(--m-crit); }
.m-signal-time {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--m-sub);
}
.m-signal-reason {
  color: var(--m-text);
  font-size: 13px;
  line-height: 1.4;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.m-signal-reason strong { color: var(--m-accent); font-weight: 600; }
.m-signal-action {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  color: var(--m-sub);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ─── Footer ─────────────────────────────────────────────────────────── */
.m-footer {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px;
  padding: 12px 20px;
  border: 1px solid var(--m-line);
  border-radius: var(--m-radius);
  background: linear-gradient(180deg, var(--m-panel) 0%, rgba(4,6,14,0.9) 100%);
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--m-sub);
}
.m-footer a {
  color: var(--m-accent);
  text-decoration: none;
  transition: color 0.18s ease, text-shadow 0.18s ease;
}
.m-footer a:hover {
  color: var(--m-text);
  text-shadow: 0 0 12px rgba(var(--m-accent-rgb), 0.55);
}

/* ─── Particle canvas ────────────────────────────────────────────────── */
#mParticles {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.40;
}

/* ─── Scanline overlay ──────────────────────────────────────────────── */
body.mission::before {
  content: "";
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 999;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.014) 0 1px,
    transparent 1px 3px);
  mix-blend-mode: overlay;
  opacity: 0.55;
}

/* Background grid + radial mesh on the body. */
body.mission {
  background:
    linear-gradient(rgba(255,255,255,0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.018) 1px, transparent 1px),
    radial-gradient(1100px 560px at 8% 0%, rgba(var(--m-accent-rgb), 0.18) 0%, transparent 60%),
    radial-gradient(820px 460px at 92% 8%, rgba(var(--m-accent-rgb), 0.10) 0%, transparent 58%),
    radial-gradient(1000px 700px at 50% 110%, rgba(56, 189, 248, 0.07) 0%, transparent 58%),
    linear-gradient(180deg, #03050b 0%, var(--m-bg) 100%);
  background-size: 44px 44px, 44px 44px, auto, auto, auto, auto;
  animation: m-grid-pan 60s linear infinite;
}
@keyframes m-grid-pan {
  to { background-position: 44px 44px, -44px 44px, 0 0, 0 0, 0 0, 0 0; }
}

/* ─── Roster row hover/click affordance ─────────────────────────────── */
.m-roster-row { cursor: pointer; }
.m-roster-row:hover .m-roster-name { color: var(--m-accent); }

/* ─── Endless-scroll sentinel rows (also click/tap to load) ─────────── */
.m-loading {
  display: block;
  width: calc(100% - 16px);
  margin: 10px auto 6px;
  padding: 10px 14px;
  text-align: center;
  background: rgba(var(--m-accent-rgb), 0.06);
  border: 1px dashed color-mix(in srgb, var(--m-accent) 40%, var(--m-line-strong));
  border-radius: 10px;
  color: var(--m-dim);
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.m-loading:hover, .m-loading:focus {
  color: var(--m-text);
  background: rgba(var(--m-accent-rgb), 0.12);
  border-color: var(--m-accent);
  outline: none;
}
.m-loading.is-loading { cursor: progress; opacity: 0.7; }
.m-loading.is-loading::after {
  content: " ⟳";
  display: inline-block;
  margin-left: 6px;
  animation: m-spin 1s linear infinite;
}
.m-loading::after {
  content: " ↓";
  display: inline-block;
  margin-left: 6px;
  animation: m-loading-bounce 1.4s ease-in-out infinite;
}
@keyframes m-loading-bounce {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50%      { transform: translateY(-3px); opacity: 1; }
}
@keyframes m-spin {
  to { transform: rotate(360deg); }
}

/* ─── Protocol-detail modal ─────────────────────────────────────────── */
.m-modal-backdrop {
  position: fixed; inset: 0;
  z-index: 1000;
  background: rgba(2, 4, 10, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.m-modal-backdrop.open { opacity: 1; pointer-events: auto; }
.m-modal {
  width: min(720px, 100%);
  max-height: min(80vh, 720px);
  display: flex;
  flex-direction: column;
  border-radius: var(--m-radius);
  border: 1px solid var(--m-line-strong);
  background: var(--m-panel);
  box-shadow:
    0 0 0 1px rgba(var(--m-accent-rgb), 0.18),
    0 32px 80px rgba(0, 0, 0, 0.6);
  transform: scale(0.96) translateY(8px);
  transition: transform 0.22s cubic-bezier(0.34, 1.4, 0.56, 1);
  overflow: hidden;
}
.m-modal-backdrop.open .m-modal { transform: scale(1) translateY(0); }
.m-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--m-line);
  background: linear-gradient(180deg, rgba(var(--m-accent-rgb), 0.08) 0%, transparent 100%);
}
.m-modal-title {
  display: flex; flex-direction: column; gap: 4px;
}
.m-modal-title strong {
  font-family: "Outfit", sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--m-text);
  letter-spacing: -0.01em;
}
.m-modal-title span {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--m-sub);
  text-transform: uppercase;
  letter-spacing: 0.14em;
}
.m-modal-close {
  font: inherit;
  font-family: "JetBrains Mono", monospace;
  font-size: 18px;
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--m-panel-2);
  border: 1px solid var(--m-line);
  color: var(--m-dim);
  cursor: pointer;
  transition: all 0.15s ease;
}
.m-modal-close:hover {
  color: var(--m-text);
  border-color: rgba(var(--m-accent-rgb), 0.5);
  background: rgba(var(--m-accent-rgb), 0.10);
}
.m-modal-body { padding: 16px 18px 18px; overflow: auto; min-height: 0; }
.m-modal-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 14px;
}
.m-modal-stat {
  padding: 10px 12px;
  border: 1px solid var(--m-line);
  border-radius: 10px;
  background: rgba(var(--m-accent-rgb), 0.04);
}
.m-modal-stat-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 9px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--m-sub);
}
.m-modal-stat-value {
  font-family: "Outfit", sans-serif;
  font-weight: 700; font-size: 1.1rem;
  color: var(--m-text);
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.m-chart {
  width: 100%; height: 200px;
  border: 1px solid var(--m-line);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.30);
  margin-bottom: 12px;
}
.m-chart-empty {
  display: flex; align-items: center; justify-content: center;
  height: 100%;
  color: var(--m-sub); font-family: "JetBrains Mono", monospace;
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
}
.m-modal-meta {
  display: flex; gap: 14px; flex-wrap: wrap;
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--m-dim);
}
.m-modal-meta a { color: var(--m-accent); text-decoration: none; }
.m-modal-meta a:hover { color: var(--m-text); }

/* ─── Responsive collapse ────────────────────────────────────────────── */
@media (max-width: 1180px) {
  /* Three columns still — narrower roster + chatter so the deck survives. */
  .m-main { grid-template-columns: minmax(220px, 240px) 1fr minmax(240px, 280px); }
}
@media (max-width: 980px) {
  .m-header { grid-template-columns: 1fr; gap: 10px; padding: 12px 14px; }
  .m-header-stats { justify-content: space-between; flex-wrap: nowrap; overflow-x: auto; }
  .m-stat { min-width: 64px; padding: 0 10px; }
  .m-stat:first-child { padding-left: 0; }
  .m-header-actions { justify-content: flex-end; flex-wrap: wrap; }
}
@media (max-width: 820px) {
  .m-shell { padding: 12px; min-height: auto; grid-template-rows: auto auto auto auto auto; }
  :root { --m-gutter: 12px; }
  .m-main { grid-template-columns: 1fr; }
  /* Mobile: lift the desktop viewport-fit cap so each panel can size to its
   * own content (with reasonable max-height bounds for scroll inside). */
  .m-main > .m-panel { max-height: 520px; min-height: 320px; }
  .m-panel.m-deck { min-height: 360px; max-height: 480px; }
  .m-panel.m-roster, .m-panel.m-chatter { display: flex; }
  .m-stream { max-height: 460px; min-height: 240px; }
  .m-headline { font-size: 1.15rem; }
  .m-stat-value { font-size: 1.05rem; }
  .m-toggle, .m-pill { font-size: 10px; padding: 6px 10px; }
  .m-modal { max-height: 90vh; }
  .m-modal-stats { grid-template-columns: 1fr 1fr; }
  .m-footer { flex-direction: column; gap: 8px; text-align: center; }
  .m-globe-wrap { width: 220px; height: 220px; }
}
@media (max-width: 480px) {
  .m-shell { padding: 10px; gap: 10px; }
  .m-brand img { width: 26px; height: 26px; }
  .m-brand .m-title { font-size: 1rem; }
  .m-header { padding: 12px 14px; }
  .m-header-stats { gap: 12px; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .m-stat-label { font-size: 9px; }
  .m-stat-value { font-size: 0.95rem; }
  .m-ticker { height: 30px; }
  .m-ticker-track { font-size: 11px; gap: 22px; }
  .m-modal-stats { grid-template-columns: 1fr; }
  .m-signal { grid-template-columns: 56px 1fr; gap: 8px; padding-left: 14px; }
  .m-signal-time, .m-signal-action { display: none; }
  .m-globe-wrap { width: 180px; height: 180px; }
  .m-panel.m-roster, .m-panel.m-chatter { min-height: 280px; max-height: 420px; }
  .m-stream { max-height: 380px; }
  .m-orbit { inset: -6px; }
  .m-orbit.alt { inset: -14px; }
}

@media (prefers-reduced-motion: reduce) {
  body.mission, body.mission .m-globe::after, body.mission .m-radar,
  body.mission .m-orbit, body.mission .m-orbit.alt,
  body.mission .m-ticker-track, body.mission .m-pill.cadence-hot,
  body.mission .m-toggle.is-on .m-bell, body.mission .m-signal.sev-warn::before,
  body.mission .m-signal.sev-critical::before { animation: none !important; }
  body.mission::before { opacity: 0; }
}
