:root {
  --void: #0c0a08;
  --ember: #1a1410;
  --ash: #2a2420;
  --mist: #c4bcb4;
  --paper: #f0ebe4;
  --idle: #7eb8d9;
  --track: #e8a54b;
  --fall: #e85d5c;
  --glow-idle: rgba(126, 184, 217, 0.35);
  --glow-track: rgba(232, 165, 75, 0.4);
  --glow-fall: rgba(232, 93, 92, 0.55);
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--void);
  color: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  background:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(232, 165, 75, 0.08), transparent 50%),
    radial-gradient(ellipse 80% 50% at 100% 100%, rgba(126, 184, 217, 0.06), transparent 45%),
    linear-gradient(165deg, var(--void) 0%, var(--ember) 55%, #080706 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  z-index: 0;
}

.wrap {
  position: relative;
  z-index: 1;
  max-width: 1320px;
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2.5rem);
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.site-header {
  margin-bottom: clamp(1.5rem, 4vw, 2.25rem);
  animation: riseIn 0.7s ease-out both;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--mist);
  opacity: 0.85;
  margin: 0 0 0.5rem;
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 700;
  font-optical-sizing: auto;
  margin: 0;
  letter-spacing: -0.02em;
  color: var(--paper);
  transition: color 0.35s ease, text-shadow 0.35s ease;
}

h1.fallen-title {
  color: var(--fall);
  text-shadow: 0 0 40px var(--glow-fall);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(280px, 380px);
  gap: clamp(1.25rem, 3.5vw, 2rem);
  align-items: stretch;
  animation: riseIn 0.75s ease-out 0.08s both;
}

@media (max-width: 880px) {
  .layout { grid-template-columns: 1fr; }
}

.thermal-card {
  position: relative;
  border-radius: 14px;
  padding: 1px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.12), rgba(255,255,255,0.02));
  box-shadow:
    0 24px 48px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.thermal-card::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 13px;
  background: linear-gradient(180deg, #141210 0%, #0a0908 100%);
  z-index: 0;
}

.thermal-chrome {
  position: relative;
  z-index: 1;
  padding: clamp(0.75rem, 2vw, 1.25rem);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  flex: 1;
  min-height: min(58vh, 560px);
}

.thermal-viewport {
  width: 100%;
  max-width: min(100%, 840px);
  aspect-ratio: 32 / 24;
  display: flex;
  align-items: center;
  justify-content: center;
}

canvas#mainCanvas {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: min(72vh, 640px);
  border-radius: 8px;
  image-rendering: auto;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 12px 32px rgba(0, 0, 0, 0.5);
}

.thermal-caption {
  position: relative;
  z-index: 1;
  margin: 0.75rem 0 0;
  padding: 0 0.25rem;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  color: var(--mist);
  opacity: 0.75;
}

.telemetry {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  justify-content: flex-start;
  min-height: 100%;
}

.telemetry .hud {
  flex: 1;
  min-height: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: transform 0.25s ease, box-shadow 0.35s ease;
}

.badge--idle { box-shadow: 0 0 24px var(--glow-idle); }
.badge--track { box-shadow: 0 0 28px var(--glow-track); color: #1a1208 !important; }
.badge--fall {
  animation: alarmPulse 1.2s ease-in-out infinite;
  box-shadow: 0 0 36px var(--glow-fall);
  border-color: rgba(232, 93, 92, 0.5);
}

@keyframes alarmPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.02); opacity: 0.95; }
}

.hud {
  border-radius: 12px;
  padding: 1rem 1.1rem;
  background: rgba(8, 7, 6, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3px solid var(--idle);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  transition: border-left-color 0.35s ease, box-shadow 0.35s ease;
}

.hud.fallen {
  border-left-color: var(--fall);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    0 0 40px rgba(232, 93, 92, 0.12);
}

.hud-metrics {
  margin: 0;
  display: grid;
  gap: 0.55rem;
}

.hud-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.75rem;
  align-items: baseline;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.hud-row:last-child { border-bottom: none; padding-bottom: 0; }

.hud-k {
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mist);
  opacity: 0.8;
}

.hud-v {
  font-weight: 500;
  color: var(--paper);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.hud-v--accent { color: var(--idle); }

.hud-note {
  font-size: 0.6rem;
  letter-spacing: 0.06em;
  color: var(--mist);
  opacity: 0.75;
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  line-height: 1.4;
}

.recordings-panel {
  margin-top: clamp(1.75rem, 5vw, 2.5rem);
  padding: 1.25rem 1.35rem;
  border-radius: 14px;
  background: rgba(20, 18, 16, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.07);
  animation: riseIn 0.85s ease-out 0.15s both;
}

.recordings-panel h2 {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 1rem;
  letter-spacing: -0.01em;
  color: var(--paper);
}

.rec-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 220px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--ash) transparent;
}

.rec-list li {
  margin: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.rec-list li:last-child { border-bottom: none; }

.rec-list a {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.35rem;
  color: var(--idle);
  text-decoration: none;
  font-size: 0.75rem;
  border-radius: 6px;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.rec-list a:hover {
  background: rgba(126, 184, 217, 0.08);
  color: var(--paper);
}

.rec-list a:focus-visible {
  outline: 2px solid var(--track);
  outline-offset: 2px;
}

.rec-meta {
  font-size: 0.65rem;
  color: var(--mist);
  opacity: 0.85;
  font-variant-numeric: tabular-nums;
}

.conn-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  font-size: 0.7rem;
  color: var(--mist);
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mist);
  opacity: 0.5;
}

.conn-dot--live {
  background: var(--track);
  opacity: 1;
  box-shadow: 0 0 12px var(--glow-track);
  animation: dotPulse 2s ease-in-out infinite;
}

@keyframes dotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.55; }
}
