/* ================================================================
   POLARIS — Station Terminal
   Deep-space UI. Dark, glowing, alive.
   ================================================================ */

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

:root {
  --bg:         #050a12;
  --bg-panel:   #0a1222;
  --bg-card:    #0e1a2e;
  --bg-card-h:  #12203a;
  --border:     #162a48;
  --border-h:   #1e3a60;

  --cyan:       #00d4ff;
  --cyan-dim:   rgba(0,212,255,0.10);
  --cyan-mid:   rgba(0,212,255,0.25);
  --cyan-glow:  rgba(0,212,255,0.50);
  --green:      #00ff88;
  --green-dim:  rgba(0,255,136,0.10);
  --green-mid:  rgba(0,255,136,0.25);
  --yellow:     #ffbe0b;
  --yellow-dim: rgba(255,190,11,0.10);
  --red:        #ff4444;
  --red-dim:    rgba(255,68,68,0.10);
  --purple:     #b388ff;
  --purple-dim: rgba(179,136,255,0.10);

  --text:       #b0c4de;
  --text-dim:   #4a6580;
  --text-bright:#eaf0f6;

  --mono: 'JetBrains Mono','Fira Code','SF Mono','Consolas',monospace;
  --sans: 'Inter','SF Pro Display','Segoe UI',system-ui,sans-serif;
  --radius: 10px;
  --radius-sm: 6px;
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ================================================================
   STARFIELD CANVAS (behind everything)
   ================================================================ */

#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* Scanline overlay */
.scanlines {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 9998;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 3px,
    rgba(0,0,0,0.025) 3px, rgba(0,0,0,0.025) 4px
  );
  mix-blend-mode: multiply;
}

/* ================================================================
   LOGIN PAGE
   ================================================================ */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.login-container {
  text-align: center;
  max-width: 520px;
  width: 92%;
  position: relative;
  z-index: 2;
}

.login-logo { margin-bottom: 2rem; position: relative; }

.logo-glow {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  width: 160px; height: 160px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--cyan-dim) 0%, transparent 70%);
  animation: glow-breathe 4s ease-in-out infinite;
}

@keyframes glow-breathe {
  0%,100% { opacity: 0.3; transform: translate(-50%,-50%) scale(1); }
  50%     { opacity: 0.7; transform: translate(-50%,-50%) scale(1.3); }
}

.logo-star { color: var(--cyan); position: relative; filter: drop-shadow(0 0 8px var(--cyan-glow)); }
.logo-star-sm { color: var(--cyan); flex-shrink: 0; filter: drop-shadow(0 0 4px var(--cyan-glow)); }

.login-logo h1 {
  font-family: var(--mono);
  font-size: 2.4rem;
  letter-spacing: 12px;
  color: var(--text-bright);
  margin-top: 1.2rem;
  text-shadow: 0 0 40px var(--cyan-glow), 0 0 80px rgba(0,212,255,0.15);
}

.login-subtitle {
  font-size: 0.65rem;
  letter-spacing: 3px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-top: 0.6rem;
}

.login-form {
  background: linear-gradient(135deg, var(--bg-panel), var(--bg-card));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 3rem;
  backdrop-filter: blur(10px);
}

.login-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 3px;
  color: var(--text-dim);
  margin-bottom: 1rem;
}

.login-input-row { display: flex; gap: 8px; }

.login-input-row input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 1.1rem;
  padding: 14px 18px;
  border-radius: var(--radius);
  outline: none;
  transition: all 0.3s;
  letter-spacing: 3px;
}

.login-input-row input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 20px var(--cyan-dim), inset 0 0 20px var(--cyan-dim);
}

.login-input-row input::placeholder { color: var(--text-dim); letter-spacing: 1px; font-size: 0.85rem; }

.login-input-row button {
  background: linear-gradient(135deg, var(--cyan-dim), var(--cyan-mid));
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 0.85rem;
  padding: 14px 24px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.3s;
  white-space: nowrap;
  text-shadow: 0 0 10px var(--cyan-glow);
}

.login-input-row button:hover {
  background: var(--cyan);
  color: var(--bg);
  box-shadow: 0 0 30px var(--cyan-glow);
  text-shadow: none;
}

.login-error {
  color: var(--red);
  font-family: var(--mono);
  font-size: 0.75rem;
  margin-top: 0.75rem;
  min-height: 0;
}

.login-error:empty { display: none; }

.login-footer {
  margin-top: 1.5rem;
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--text-dim);
  letter-spacing: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.blink { animation: blink 1.5s step-end infinite; color: var(--green); font-size: 0.7rem; }
@keyframes blink { 50% { opacity: 0; } }

/* ================================================================
   APP LAYOUT
   ================================================================ */

.app { display: flex; min-height: 100vh; position: relative; z-index: 1; }

/* ================================================================
   SIDEBAR
   ================================================================ */

.sidebar {
  width: 210px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
  overflow-y: auto;
  z-index: 10;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 1.3rem 1rem;
  border-bottom: 1px solid var(--border);
}

.sidebar-title {
  font-family: var(--mono);
  font-size: 1rem;
  letter-spacing: 5px;
  color: var(--text-bright);
  text-transform: uppercase;
  text-shadow: 0 0 15px var(--cyan-glow);
}

.sidebar-shift {
  padding: 10px 1rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.sidebar-nav { flex: 1; padding: 0.6rem 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 1.2rem;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
  border-left: 3px solid transparent;
  position: relative;
}

.nav-item:hover {
  color: var(--text);
  background: rgba(255,255,255,0.02);
}

.nav-item.active {
  color: var(--cyan);
  border-left-color: var(--cyan);
  background: var(--cyan-dim);
  text-shadow: 0 0 8px var(--cyan-glow);
}

.nav-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  opacity: 0.7;
}

.nav-item.active .nav-icon { opacity: 1; }

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: 0.65rem;
  font-family: var(--mono);
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}

.sidebar-logout {
  border-top: 1px solid var(--border);
}

.sidebar-logout .nav-item {
  color: var(--text-dim);
  font-size: 0.75rem;
}

.sidebar-logout .nav-item:hover {
  color: var(--red);
}

.sidebar-power {
  padding: 1rem;
  border-top: 1px solid var(--border);
}

.power-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.power-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 4px;
  border: 1px solid var(--border);
  overflow: hidden;
}

.power-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--yellow) 50%, var(--green));
  border-radius: 4px;
  transition: width 2s cubic-bezier(0.4, 0, 0.2, 1);
  width: 0%;
  box-shadow: 0 0 8px var(--green-dim);
}

.power-value {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--cyan);
  text-align: right;
  margin-top: 6px;
  text-shadow: 0 0 6px var(--cyan-dim);
}

/* ================================================================
   MAIN
   ================================================================ */

.main {
  flex: 1;
  padding: 2rem 2.5rem;
  max-width: 1000px;
  position: relative;
}

/* ================================================================
   SECTOR AMBIENT BACKGROUNDS
   Applied via body.sector-N class when DM navigates crew
   ================================================================ */

/* Base ambient layer — full viewport via .app::before */
body[class*="sector-"] .app::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0;
  animation: ambient-in 1s ease-out forwards;
}
body[class*="sector-"] .sidebar,
body[class*="sector-"] .main { position: relative; z-index: 1; }

@keyframes ambient-in {
  0% { opacity: 0; }
  100% { opacity: 1; }
}

/* Sector 1 — Můstek: bright cyan HUD grid + strong center glow */
body.sector-1 .app::before {
  background:
    repeating-linear-gradient(0deg, transparent, transparent 49px, rgba(0, 255, 255, 0.06) 49px, rgba(0, 255, 255, 0.06) 50px),
    repeating-linear-gradient(90deg, transparent, transparent 49px, rgba(0, 255, 255, 0.06) 49px, rgba(0, 255, 255, 0.06) 50px),
    radial-gradient(ellipse at 50% 20%, rgba(0, 255, 255, 0.18) 0%, transparent 60%);
}
body.sector-1 .sidebar { border-right-color: rgba(0, 255, 255, 0.3); }

/* Sector 2 — Obytný: warm amber glow from below, cozy */
body.sector-2 .app::before {
  background:
    radial-gradient(ellipse at 50% 100%, rgba(255, 160, 50, 0.2) 0%, transparent 55%),
    radial-gradient(ellipse at 20% 60%, rgba(255, 200, 100, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 40%, rgba(200, 150, 60, 0.06) 0%, transparent 50%);
}
body.sector-2 .sidebar { border-right-color: rgba(255, 160, 50, 0.3); }

/* Sector 3 — Laboratoř: green matrix dots + tech glow */
body.sector-3 .app::before {
  background:
    radial-gradient(circle at 1px 1px, rgba(0, 255, 100, 0.08) 1px, transparent 1px),
    radial-gradient(ellipse at 60% 30%, rgba(0, 255, 80, 0.15) 0%, transparent 55%),
    radial-gradient(ellipse at 30% 80%, rgba(0, 200, 60, 0.08) 0%, transparent 40%);
  background-size: 20px 20px, 100% 100%, 100% 100%;
}
body.sector-3 .sidebar { border-right-color: rgba(0, 255, 100, 0.3); }

/* Sector 4 — Strojovna: heavy orange/red heat from below, pulsing */
body.sector-4 .app::before {
  background:
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255, 100, 0, 0.03) 2px, rgba(255, 100, 0, 0.03) 3px),
    radial-gradient(ellipse at 50% 120%, rgba(255, 60, 0, 0.3) 0%, rgba(255, 40, 0, 0.1) 35%, transparent 65%),
    radial-gradient(ellipse at 30% 80%, rgba(255, 120, 0, 0.08) 0%, transparent 40%);
  animation: ambient-in 1s ease-out forwards, engine-pulse 3s ease-in-out infinite;
}
body.sector-4 .sidebar { border-right-color: rgba(255, 80, 0, 0.4); }
@keyframes engine-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

/* Sector 5 — Komunikace: purple/blue with visible signal wave lines */
body.sector-5 .app::before {
  background:
    repeating-linear-gradient(0deg, transparent, transparent 7px, rgba(140, 80, 255, 0.05) 7px, rgba(140, 80, 255, 0.05) 8px),
    radial-gradient(ellipse at 50% 40%, rgba(120, 60, 255, 0.2) 0%, transparent 55%),
    radial-gradient(ellipse at 70% 80%, rgba(80, 40, 200, 0.1) 0%, transparent 40%);
}
body.sector-5 .sidebar { border-right-color: rgba(140, 80, 255, 0.4); }

/* Sector 6 — Kryosál: heavy frost, cold blue vignette from edges */
body.sector-6 .app::before {
  background:
    radial-gradient(ellipse at 50% 50%, transparent 30%, rgba(150, 220, 255, 0.12) 60%, rgba(200, 240, 255, 0.2) 100%),
    radial-gradient(ellipse at 50% 0%, rgba(180, 240, 255, 0.15) 0%, transparent 40%),
    radial-gradient(ellipse at 50% 100%, rgba(180, 240, 255, 0.15) 0%, transparent 40%),
    linear-gradient(180deg, rgba(100, 200, 255, 0.05) 0%, transparent 30%, transparent 70%, rgba(100, 200, 255, 0.05) 100%);
}
body.sector-6 .sidebar { border-right-color: rgba(150, 220, 255, 0.4); }

/* Sector 7 — Sklady/Skleník: organic green bioluminescence */
body.sector-7 .app::before {
  background:
    radial-gradient(ellipse at 25% 75%, rgba(60, 220, 80, 0.14) 0%, transparent 45%),
    radial-gradient(ellipse at 75% 25%, rgba(40, 200, 60, 0.1) 0%, transparent 40%),
    radial-gradient(ellipse at 50% 100%, rgba(80, 240, 100, 0.12) 0%, transparent 45%),
    radial-gradient(ellipse at 60% 50%, rgba(0, 180, 40, 0.06) 0%, transparent 60%);
}
body.sector-7 .sidebar { border-right-color: rgba(60, 220, 80, 0.4); }

/* Sector 0 — Sektor nula: deep red, ominous, flickering */
body.sector-0 .app::before {
  background:
    radial-gradient(ellipse at 50% 50%, rgba(255, 0, 0, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(200, 0, 0, 0.2) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 0%, rgba(150, 0, 0, 0.1) 0%, transparent 40%);
  animation: ambient-in 1s ease-out forwards, sector0-flicker 2.5s steps(1) infinite;
}
body.sector-0 .sidebar { border-right-color: rgba(255, 0, 0, 0.4); }
@keyframes sector0-flicker {
  0% { opacity: 0.9; }
  4% { opacity: 0.3; }
  6% { opacity: 1; }
  10% { opacity: 0.5; }
  12% { opacity: 1; }
  100% { opacity: 1; }
}

.page { display: none; animation: fadeIn 0.3s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.page-title {
  font-family: var(--mono);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 4px;
  color: var(--text-bright);
  padding-bottom: 1rem;
  margin-bottom: 1.8rem;
  border-bottom: 1px solid var(--border);
  text-shadow: 0 0 10px rgba(255,255,255,0.05);
}

/* ================================================================
   SHIP MAP
   ================================================================ */

.ship-map {
  margin-bottom: 1.5rem;
}

.ship-hull {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
  position: relative;
}

/* Ship silhouette shape hint via pseudo-elements */
.ship-hull::before {
  content: 'LOĎ POLARIS — Schéma sektorů';
  display: block;
  grid-column: 1 / -1;
  font-family: var(--mono);
  font-size: 0.55rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text-dim);
  text-align: center;
  padding: 4px 0 6px;
}

.sector {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s;
  position: relative;
}

.sector:hover {
  border-color: var(--cyan);
  background: var(--bg-card-h);
  transform: translateY(-1px);
}

.sector.selected {
  border-color: var(--cyan);
  box-shadow: 0 0 12px var(--cyan-dim), inset 0 0 12px var(--cyan-dim);
}

.sector-locked {
  background: linear-gradient(135deg, rgba(255,68,68,0.05), var(--bg-card));
  border-color: rgba(255,68,68,0.2);
}

.sector-locked:hover {
  border-color: var(--red);
  box-shadow: 0 0 12px var(--red-dim);
}

.sector-locked.selected {
  border-color: var(--red);
  box-shadow: 0 0 12px var(--red-dim), inset 0 0 12px var(--red-dim);
}

.sector-num {
  display: block;
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--cyan);
  margin-bottom: 2px;
}

.sector-locked .sector-num { color: var(--red); }

.sector-label {
  display: block;
  font-family: var(--mono);
  font-size: 0.55rem;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.lock-icon {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.65rem;
}

.sector-info {
  display: none;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-top: 8px;
  animation: fadeIn 0.3s ease;
}

.sector-info-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.sector-info-name {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--text-bright);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.sector-info-status {
  font-family: var(--mono);
  font-size: 0.6rem;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  letter-spacing: 1px;
}

.sector-info-status.status-online  { background: var(--green-dim); color: var(--green); }
.sector-info-status.status-warning { background: var(--yellow-dim); color: var(--yellow); }
.sector-info-status.status-offline { background: var(--red-dim); color: var(--red); }
.sector-info-status.status-locked  { background: rgba(179,136,255,0.1); color: var(--purple); }

.sector-info-desc {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-line;
}

/* ================================================================
   SYSTEMS GRID (Dashboard)
   ================================================================ */

.systems-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}

.system-card {
  background: linear-gradient(135deg, var(--bg-card), var(--bg-card-h));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  transition: all 0.3s;
}

.system-card:hover {
  border-color: var(--border-h);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.system-name {
  font-family: var(--mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.system-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text);
}

.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-online  { background: var(--green);  box-shadow: 0 0 8px var(--green), 0 0 16px var(--green-dim); }
.dot-warning { background: var(--yellow); box-shadow: 0 0 8px var(--yellow); animation: dot-pulse 2s infinite; }
.dot-offline { background: var(--red);    box-shadow: 0 0 8px var(--red);    animation: dot-pulse 1.2s infinite; }
.dot-locked  { background: var(--purple); box-shadow: 0 0 8px var(--purple); }
@keyframes dot-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.25; } }

.system-detail { font-size: 0.7rem; color: var(--text-dim); margin-top: 8px; }

/* ================================================================
   TASKS
   ================================================================ */

.task-card {
  background: linear-gradient(135deg, var(--bg-card), var(--bg-card-h));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
  transition: all 0.3s;
}

.task-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 3px;
}

.task-card.active::before { background: var(--yellow); box-shadow: 0 0 8px var(--yellow-dim); }
.task-card.completed::before { background: var(--green); box-shadow: 0 0 8px var(--green-dim); }

.task-card.completed {
  opacity: 0.65;
}

.task-status-tag {
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  padding: 3px 10px;
  border-radius: var(--radius-sm);
  display: inline-block;
  margin-bottom: 10px;
}

.tag-active    { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(255,190,11,0.2); }
.tag-completed { background: var(--green-dim);  color: var(--green);  border: 1px solid rgba(0,255,136,0.2); }

.task-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-bright);
  margin-bottom: 8px;
}

.task-desc {
  font-size: 0.85rem;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 1.2rem;
  white-space: pre-line;
}

.task-submit-row { display: flex; gap: 8px; }

.task-submit-row input {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-bright);
  font-family: var(--mono);
  font-size: 0.9rem;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: all 0.3s;
}

.task-submit-row input:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 12px var(--cyan-dim);
}

.task-submit-row button, .msg-compose button, .aria-input-row button {
  background: linear-gradient(135deg, var(--cyan-dim), var(--cyan-mid));
  border: 1px solid var(--cyan);
  color: var(--cyan);
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.25s;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.task-submit-row button:hover, .msg-compose button:hover, .aria-input-row button:hover {
  background: var(--cyan);
  color: var(--bg);
  box-shadow: 0 0 20px var(--cyan-glow);
}

.task-feedback {
  font-family: var(--mono);
  font-size: 0.75rem;
  margin-top: 10px;
  min-height: 1.2em;
}

.task-feedback.success { color: var(--green); text-shadow: 0 0 6px var(--green-dim); }
.task-feedback.fail    { color: var(--red); }

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 0.85rem;
  letter-spacing: 1px;
}

/* ================================================================
   ARIA CHAT
   ================================================================ */

.aria-chat {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 10rem);
  max-height: 650px;
}

.aria-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
}

.aria-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.aria-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--cyan-dim);
  border: 2px solid var(--cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--cyan);
  font-weight: 700;
  letter-spacing: 1px;
}

.aria-avatar.thinking {
  animation: avatar-pulse 1s ease-in-out infinite;
}

@keyframes avatar-pulse {
  0%,100% { box-shadow: 0 0 0 0 var(--cyan-glow); }
  50%     { box-shadow: 0 0 0 8px transparent; }
}

.aria-header-name {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--text-bright);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.aria-header-status {
  font-size: 0.6rem;
  color: var(--green);
  display: flex;
  align-items: center;
  gap: 4px;
}

.aria-header-status .dot { width: 5px; height: 5px; }

.tts-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 1rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.tts-toggle.active {
  color: var(--cyan);
  border-color: var(--cyan);
  background: var(--cyan-dim);
}

.aria-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-top: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.aria-msg {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  line-height: 1.6;
  max-width: 82%;
  animation: msgAppear 0.3s ease;
}

@keyframes msgAppear { from { opacity: 0; transform: translateY(8px); } }

.aria-msg.aria-system {
  color: var(--text-dim);
  font-style: italic;
  font-size: 0.75rem;
  max-width: 100%;
  text-align: center;
  font-family: var(--mono);
}

.aria-msg.from-crew {
  background: var(--cyan-dim);
  border: 1px solid rgba(0,212,255,0.15);
  color: var(--text);
  align-self: flex-end;
  border-radius: var(--radius) var(--radius) 4px var(--radius);
}

.aria-msg.from-aria {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  align-self: flex-start;
  border-radius: var(--radius) var(--radius) var(--radius) 4px;
}

.aria-label {
  font-family: var(--mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 4px;
  opacity: 0.6;
}

.aria-msg.from-crew .aria-label { color: var(--cyan); }
.aria-msg.from-aria .aria-label { color: var(--yellow); }

.aria-typing-indicator {
  align-self: flex-start;
  padding: 10px 16px;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.typing-dots span {
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--cyan);
  animation: typeDot 1.4s ease-in-out infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typeDot {
  0%,60%,100% { opacity: 0.2; transform: translateY(0); }
  30%         { opacity: 1;   transform: translateY(-4px); }
}

.aria-input-row {
  display: flex;
  gap: 0;
}

.aria-input-row input {
  flex: 1;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-right: none;
  border-radius: 0 0 0 var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  padding: 14px 18px;
  outline: none;
  transition: border-color 0.3s;
}

.aria-input-row input:focus { border-color: var(--cyan); }
.aria-input-row button { border-radius: 0 0 var(--radius) 0; }

/* ================================================================
   CREW
   ================================================================ */

.crew-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.crew-card {
  background: linear-gradient(135deg, var(--bg-card), var(--bg-card-h));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}

.crew-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.crew-card:hover {
  border-color: var(--border-h);
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.crew-card:hover::after { opacity: 1; }

.crew-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 2px solid var(--cyan);
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
  font-size: 1.3rem;
  box-shadow: 0 0 12px var(--cyan-dim);
}

.crew-name { font-weight: 600; color: var(--text-bright); margin-bottom: 4px; font-size: 1rem; }

.crew-role {
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--cyan);
}

/* ================================================================
   SKILL TREE — Horizontal tech-tree tracks
   ================================================================ */

.skill-tree {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.skill-branch {
  background: linear-gradient(135deg, var(--bg-card), var(--bg-card-h));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem 1.5rem;
  overflow: hidden;
}

.branch-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 1rem;
}

.branch-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--cyan-dim);
  border: 1px solid rgba(0,212,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.branch-name {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 2px;
  color: var(--text-bright);
  text-transform: uppercase;
}

.branch-counter {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--text-dim);
  letter-spacing: 1px;
}

/* The horizontal track */
.skill-track {
  display: flex;
  align-items: flex-start;
  overflow-x: auto;
  padding: 4px 0 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.track-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  min-width: 64px;
}

.node-dot {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  transition: all 0.4s;
  position: relative;
}

.track-node.locked .node-dot {
  opacity: 0.25;
  border-color: var(--text-dim);
  color: var(--text-dim);
}

.track-node.available .node-dot {
  border-color: var(--cyan);
  color: var(--cyan);
  box-shadow: 0 0 12px var(--cyan-dim), 0 0 24px rgba(0,212,255,0.08);
  animation: node-glow 2.5s ease-in-out infinite;
}

@keyframes node-glow {
  0%,100% { box-shadow: 0 0 12px var(--cyan-dim); }
  50%     { box-shadow: 0 0 20px var(--cyan-mid), 0 0 40px var(--cyan-dim); }
}

.track-node.completed .node-dot {
  border-color: var(--green);
  color: var(--green);
  background: var(--green-dim);
  box-shadow: 0 0 10px var(--green-dim);
}

.node-name {
  font-size: 0.65rem;
  color: var(--text-dim);
  text-align: center;
  max-width: 72px;
  line-height: 1.3;
  font-family: var(--mono);
}

.track-node.completed .node-name { color: var(--green); }
.track-node.available .node-name { color: var(--cyan); }

.track-line {
  width: 24px;
  height: 2px;
  background: var(--border);
  margin-top: 20px; /* center with node-dot */
  flex-shrink: 0;
  border-radius: 1px;
}

.track-line.done {
  background: var(--green);
  box-shadow: 0 0 6px var(--green-dim);
}

/* ================================================================
   MESSAGES
   ================================================================ */

.msg-entry {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
  margin-bottom: 8px;
  transition: all 0.2s;
}

.msg-entry:hover { border-color: var(--border-h); }

.msg-entry.from-alpha { border-left: 3px solid var(--cyan); }
.msg-entry.from-aria  { border-left: 3px solid var(--yellow); background: rgba(255,190,11,0.02); }

.msg-sender {
  font-family: var(--mono);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 6px;
}

.msg-entry.from-alpha .msg-sender { color: var(--cyan); }
.msg-entry.from-aria  .msg-sender { color: var(--yellow); }

.msg-text { font-size: 0.9rem; line-height: 1.6; }

.msg-time {
  font-family: var(--mono);
  font-size: 0.6rem;
  color: var(--text-dim);
  margin-top: 6px;
}

.msg-compose { display: flex; gap: 8px; margin-top: 1.2rem; }

.msg-compose input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  outline: none;
  font-size: 0.9rem;
  transition: border-color 0.3s;
}

.msg-compose input:focus { border-color: var(--cyan); }

/* Section card */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
}

.section-card h3 {
  font-family: var(--mono);
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

/* ================================================================
   BOOT SEQUENCE OVERLAY
   ================================================================ */

.boot-overlay {
  position: fixed; inset: 0;
  background: var(--bg);
  z-index: 9997;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.8s ease;
}

.boot-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.boot-text {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--cyan);
  letter-spacing: 2px;
  text-shadow: 0 0 10px var(--cyan-glow);
}

/* ================================================================
   TASK COMPLETION FLASH
   ================================================================ */

@keyframes taskComplete {
  0%   { box-shadow: 0 0 0 0 var(--green-mid); }
  50%  { box-shadow: 0 0 30px 5px var(--green-mid); }
  100% { box-shadow: none; }
}

.task-card.just-completed {
  animation: taskComplete 1s ease;
}

/* ================================================================
   STATION ALERTS
   ================================================================ */

.station-alert {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 9999;
  display: flex;
  justify-content: center;
  padding: 1.2rem;
  animation: alertSlideIn 0.4s ease;
  transition: opacity 0.8s;
}

.station-alert.fading { opacity: 0; }

.station-alert.alert-red {
  background: linear-gradient(180deg, rgba(255,68,68,0.2), transparent);
}

.station-alert.alert-yellow {
  background: linear-gradient(180deg, rgba(255,190,11,0.15), transparent);
}

@keyframes alertSlideIn {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

.alert-content {
  text-align: center;
}

.alert-icon {
  font-size: 2rem;
  margin-bottom: 4px;
  animation: alertPulse 0.6s ease-in-out 3;
}

@keyframes alertPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.5; transform: scale(1.2); }
}

.alert-label {
  font-family: var(--mono);
  font-size: 0.75rem;
  letter-spacing: 4px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.alert-red .alert-label { color: var(--red); text-shadow: 0 0 10px var(--red); }
.alert-yellow .alert-label { color: var(--yellow); text-shadow: 0 0 10px var(--yellow); }

.alert-message {
  font-size: 0.9rem;
  color: var(--text-bright);
}

/* === BLACKOUT EVENT === */

.alert-blackout {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: blackoutIn 0.3s ease;
}

@keyframes blackoutIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.blackout-screen {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.blackout-scanline {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px,
    rgba(255,0,0,0.03) 2px, rgba(255,0,0,0.03) 4px
  );
  pointer-events: none;
  animation: blackoutFlicker 0.15s infinite;
}

@keyframes blackoutFlicker {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

.blackout-text {
  font-family: var(--mono);
  font-size: 1.4rem;
  color: var(--red);
  text-align: center;
  max-width: 600px;
  line-height: 1.8;
  text-shadow: 0 0 20px var(--red), 0 0 60px rgba(255,68,68,0.3);
  animation: textGlitch 3s infinite;
  padding: 2rem;
}

@keyframes textGlitch {
  0%, 95%, 100% { transform: translate(0); }
  96% { transform: translate(-2px, 1px); }
  97% { transform: translate(2px, -1px); }
  98% { transform: translate(-1px, -1px); }
}

/* Alert border flash on body */
body.alert-flash-red {
  animation: borderFlashRed 0.5s ease-in-out 4;
}

body.alert-flash-yellow {
  animation: borderFlashYellow 0.5s ease-in-out 3;
}

@keyframes borderFlashRed {
  0%, 100% { box-shadow: inset 0 0 0 0 transparent; }
  50%      { box-shadow: inset 0 0 60px 4px rgba(255,68,68,0.15); }
}

@keyframes borderFlashYellow {
  0%, 100% { box-shadow: inset 0 0 0 0 transparent; }
  50%      { box-shadow: inset 0 0 40px 3px rgba(255,190,11,0.1); }
}

/* ================================================================
   RESPONSIVE
   ================================================================ */

@media (max-width: 900px) {
  .main { padding: 1.5rem; max-width: 100%; }
  .systems-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .crew-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

@media (max-width: 700px) {
  /* Login page mobile */
  .login-container { width: 96%; }
  .login-logo { margin-bottom: 1.5rem; }
  .login-logo h1 { font-size: 1.8rem; letter-spacing: 8px; }
  .login-subtitle { font-size: 0.6rem; letter-spacing: 2px; }
  .login-form { padding: 1.5rem; }
  .login-label { font-size: 0.65rem; letter-spacing: 2px; margin-bottom: 0.75rem; }
  .login-input-row { flex-direction: column; }
  .login-input-row input { font-size: 1rem; padding: 14px; letter-spacing: 2px; }
  .login-input-row button { padding: 14px; font-size: 0.9rem; }
  .login-footer { font-size: 0.6rem; letter-spacing: 1px; }
  .logo-star { width: 48px; height: 48px; }

  /* App layout mobile */
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: fixed;
    bottom: 0;
    top: auto;
    flex-direction: row;
    border-right: none;
    border-top: 1px solid var(--border);
    z-index: 100;
  }
  .sidebar-logo, .sidebar-shift, .sidebar-location, .sidebar-power { display: none; }
  .sidebar-logout { border-top: none; }
  .sidebar-logout .nav-item { font-size: 0.6rem; }
  .sidebar-nav {
    display: flex;
    flex-direction: row;
    width: 100%;
    padding: 0;
    overflow-x: auto;
  }
  .nav-item {
    flex: 1;
    justify-content: center;
    padding: 12px 4px;
    border-left: none;
    border-top: 3px solid transparent;
    flex-direction: column;
    gap: 2px;
    font-size: 0.6rem;
    min-width: 0;
  }
  .nav-item span:not(.nav-icon) { font-size: 0.55rem; }
  .nav-item.active { border-left-color: transparent; border-top-color: var(--cyan); }
  .nav-badge { position: absolute; top: 4px; right: 4px; }
  .main { padding: 1rem; padding-bottom: 5rem; max-width: 100%; }
  .systems-grid { grid-template-columns: 1fr 1fr; }
  .aria-chat { max-height: calc(100vh - 12rem); height: calc(100vh - 12rem); }
}

/* ================================================================
   ADMIN-TRIGGERED EFFECTS (via SSE)
   ================================================================ */

/* Shake — short screen vibration (e.g. collision, explosion) */
@keyframes fx-shake-anim {
  0%, 100% { transform: translate(0); }
  10% { transform: translate(-6px, 3px); }
  20% { transform: translate(5px, -4px); }
  30% { transform: translate(-4px, 2px); }
  40% { transform: translate(6px, -2px); }
  50% { transform: translate(-3px, 4px); }
  60% { transform: translate(4px, -3px); }
  70% { transform: translate(-5px, 1px); }
  80% { transform: translate(3px, -2px); }
  90% { transform: translate(-2px, 3px); }
}
body.fx-shake {
  animation: fx-shake-anim 0.6s ease;
}

/* Flash — brief white flash (e.g. power surge) */
@keyframes fx-flash-anim {
  0% { opacity: 0; }
  20% { opacity: 0.7; }
  100% { opacity: 0; }
}
body.fx-flash::after {
  content: '';
  position: fixed;
  inset: 0;
  background: white;
  pointer-events: none;
  z-index: 99999;
  animation: fx-flash-anim 0.4s ease-out forwards;
}

/* Glitch — screen corruption effect */
@keyframes fx-glitch-anim {
  0% { clip-path: inset(40% 0 61% 0); transform: translate(-2px); }
  5% { clip-path: inset(10% 0 85% 0); transform: translate(3px); }
  10% { clip-path: inset(80% 0 5% 0); transform: translate(-1px); }
  15% { clip-path: inset(25% 0 58% 0); transform: translate(2px); }
  20% { clip-path: inset(55% 0 30% 0); transform: translate(-3px); }
  25% { clip-path: inset(0); transform: translate(0); }
  30% { clip-path: inset(0); transform: translate(0); }
  35% { clip-path: inset(65% 0 15% 0); transform: translate(2px); }
  40% { clip-path: inset(0); transform: translate(0); }
  50% { clip-path: inset(0); transform: translate(0); }
  55% { clip-path: inset(30% 0 50% 0); transform: translate(-2px); }
  60% { clip-path: inset(0); transform: translate(0); }
  100% { clip-path: inset(0); transform: translate(0); }
}
body.fx-glitch .main {
  animation: fx-glitch-anim 2s steps(1) forwards;
}
body.fx-glitch::before {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(255, 0, 0, 0.03) 2px,
    rgba(255, 0, 0, 0.03) 4px
  );
  pointer-events: none;
  z-index: 99998;
}

/* Transit overlay — sector navigation */
.transit-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: transit-in 0.3s ease-out;
}
.transit-overlay.transit-fade {
  animation: transit-out 0.6s ease-in forwards;
}
@keyframes transit-in {
  0% { opacity: 0; }
  100% { opacity: 1; }
}
@keyframes transit-out {
  0% { opacity: 1; }
  100% { opacity: 0; }
}
.transit-scanline {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0, 255, 255, 0.02) 3px,
    rgba(0, 255, 255, 0.02) 6px
  );
  pointer-events: none;
}
.transit-content {
  text-align: center;
  animation: transit-text-in 0.5s ease-out 0.2s both;
}
@keyframes transit-text-in {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}
.transit-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.5rem;
}
.transit-sector {
  font-family: var(--mono);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: 6px;
  text-shadow: 0 0 30px rgba(0, 255, 255, 0.4);
}
.transit-name {
  font-family: var(--sans);
  font-size: 1.1rem;
  color: var(--text-bright);
  margin-top: 0.4rem;
  letter-spacing: 2px;
}

/* ================================================================
   SYSTEM DEGRADATION — terminal reflects ship damage
   ================================================================ */

/* --- Power level → flicker on .app wrapper --- */
body.power-low .app {
  animation: power-flicker 6s steps(1) infinite;
}
body.power-critical .app {
  animation: power-flicker-heavy 3s steps(1) infinite;
}
body.power-critical {
  filter: saturate(0.6) brightness(0.9);
}
@keyframes power-flicker {
  0% { opacity: 1; }
  82% { opacity: 1; }
  82.5% { opacity: 0.4; }
  83% { opacity: 0.9; }
  83.5% { opacity: 1; }
  91% { opacity: 1; }
  91.3% { opacity: 0.6; }
  91.6% { opacity: 1; }
  100% { opacity: 1; }
}
@keyframes power-flicker-heavy {
  0% { opacity: 1; }
  12% { opacity: 1; }
  12.3% { opacity: 0.2; }
  12.6% { opacity: 0.7; }
  13% { opacity: 1; }
  35% { opacity: 1; }
  35.3% { opacity: 0.3; }
  35.6% { opacity: 1; }
  62% { opacity: 1; }
  62.3% { opacity: 0.15; }
  62.8% { opacity: 0.6; }
  63.2% { opacity: 1; }
  85% { opacity: 1; }
  85.5% { opacity: 0.4; }
  86% { opacity: 1; }
  100% { opacity: 1; }
}

/* --- Damage sparks (injected by JS) --- */
.damage-spark {
  position: fixed;
  pointer-events: none;
  z-index: 99990;
}
.damage-spark .spark-particle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #ffdd44;
  box-shadow: 0 0 6px 2px #ff8800, 0 0 14px 4px rgba(255, 136, 0, 0.6), 0 0 20px 6px rgba(255, 80, 0, 0.2);
  animation: spark-fly var(--dur, 0.6s) ease-out forwards;
}
@keyframes spark-fly {
  0% { opacity: 1; transform: translate(0, 0) scale(1.2); }
  50% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx, 20px), var(--dy, -30px)) scale(0); }
}

/* --- Corruption blocks (injected by JS) --- */
.corruption-block {
  position: fixed;
  pointer-events: none;
  z-index: 99989;
  animation: corrupt-flash var(--dur, 0.15s) steps(1) forwards;
}
@keyframes corrupt-flash {
  0% { opacity: 1; }
  50% { opacity: 0.8; }
  100% { opacity: 0; }
}

/* --- Permanent damage overlay when power is low --- */
body.power-low .app::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99;
  background:
    linear-gradient(180deg,
      transparent 0%,
      transparent 20%,
      rgba(255, 0, 0, 0.02) 20.5%,
      transparent 21%,
      transparent 45%,
      rgba(255, 80, 0, 0.015) 45.5%,
      transparent 46%,
      transparent 73%,
      rgba(255, 0, 0, 0.02) 73.5%,
      transparent 74%,
      transparent 100%
    );
  animation: damage-lines-drift 8s linear infinite;
}
body.power-critical .app::after {
  background:
    linear-gradient(180deg,
      transparent 0%,
      transparent 15%,
      rgba(255, 0, 0, 0.04) 15.5%,
      transparent 16.5%,
      transparent 32%,
      rgba(255, 80, 0, 0.03) 32.5%,
      transparent 33.5%,
      transparent 55%,
      rgba(255, 0, 0, 0.05) 55.5%,
      transparent 56.5%,
      transparent 78%,
      rgba(255, 80, 0, 0.03) 78.5%,
      transparent 79.5%,
      transparent 100%
    );
}
@keyframes damage-lines-drift {
  0% { transform: translateY(0); }
  100% { transform: translateY(20px); }
}

/* --- Communications offline → ARIA chat heavy static --- */
body.sys-comms-offline #page-aria .aria-chat {
  position: relative;
}
body.sys-comms-offline #page-aria .aria-chat::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255, 255, 255, 0.04) 2px, rgba(255, 255, 255, 0.04) 4px);
  pointer-events: none;
  z-index: 10;
  animation: static-drift 0.3s steps(4) infinite;
  border-radius: inherit;
}
body.sys-comms-offline #page-aria .aria-messages {
  opacity: 0.4;
  filter: blur(0.3px);
}
body.sys-comms-offline #page-aria .aria-header-status {
  color: var(--red) !important;
}
body.sys-comms-offline #page-aria .aria-header-status .dot {
  background: var(--red) !important;
  box-shadow: 0 0 6px var(--red) !important;
}
body.sys-comms-offline #page-aria .aria-input-row {
  opacity: 0.5;
}
/* Comms warning — moderate interference */
body.sys-comms-warning #page-aria .aria-chat {
  position: relative;
}
body.sys-comms-warning #page-aria .aria-chat::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(255, 255, 255, 0.02) 3px, rgba(255, 255, 255, 0.02) 6px);
  pointer-events: none;
  z-index: 10;
  animation: static-drift 1s steps(3) infinite;
  border-radius: inherit;
}
@keyframes static-drift {
  0% { transform: translateY(0); }
  25% { transform: translateY(-2px); }
  50% { transform: translateY(1px); }
  75% { transform: translateY(-1px); }
  100% { transform: translateY(0); }
}

/* --- Navigation offline → ship map heavy corruption --- */
body.sys-nav-offline .ship-map {
  position: relative;
}
body.sys-nav-offline .ship-map::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, transparent, transparent 1px, rgba(255, 0, 0, 0.06) 1px, rgba(255, 0, 0, 0.06) 2px);
  pointer-events: none;
  animation: map-corrupt 2s steps(1) infinite;
  z-index: 5;
}
body.sys-nav-offline .sector-label {
  animation: label-glitch 3s steps(1) infinite;
}
body.sys-nav-offline .ship-hull {
  filter: hue-rotate(15deg) saturate(0.7);
  animation: hull-shake 4s steps(1) infinite;
}
@keyframes map-corrupt {
  0% { clip-path: inset(0); opacity: 1; }
  15% { clip-path: inset(20% 0 70% 0); opacity: 1; }
  17% { clip-path: inset(0); }
  40% { clip-path: inset(0); }
  55% { clip-path: inset(60% 0 15% 0); opacity: 1; }
  57% { clip-path: inset(0); }
  75% { clip-path: inset(0); }
  80% { clip-path: inset(40% 0 40% 0); }
  82% { clip-path: inset(0); }
  100% { clip-path: inset(0); }
}
@keyframes label-glitch {
  0% { opacity: 1; transform: none; }
  78% { opacity: 1; transform: none; }
  79% { opacity: 0.2; transform: translateX(3px); }
  81% { opacity: 1; transform: translateX(-1px); }
  83% { opacity: 1; transform: none; }
  100% { opacity: 1; transform: none; }
}
@keyframes hull-shake {
  0% { transform: none; }
  92% { transform: none; }
  93% { transform: translateX(1px); }
  94% { transform: translateX(-1px); }
  95% { transform: translateX(2px); }
  96% { transform: none; }
  100% { transform: none; }
}
/* Nav warning — mild */
body.sys-nav-warning .ship-map {
  position: relative;
}
body.sys-nav-warning .ship-map::after {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(255, 200, 0, 0.025) 3px, rgba(255, 200, 0, 0.025) 6px);
  pointer-events: none;
  z-index: 5;
}

/* --- Life support warning → cold flicker + frost vignette --- */
body.sys-life-warning .sidebar {
  animation: life-cold-sidebar 5s ease-in-out infinite;
}
body.sys-life-offline .sidebar {
  animation: life-cold-sidebar 2.5s ease-in-out infinite;
}
body.sys-life-warning .main {
  animation: life-cold 5s ease-in-out infinite;
}
body.sys-life-offline .main {
  animation: life-cold-heavy 2.5s ease-in-out infinite;
}
@keyframes life-cold {
  0%, 100% { filter: none; }
  50% { filter: hue-rotate(-8deg) brightness(0.93); }
}
@keyframes life-cold-heavy {
  0%, 100% { filter: brightness(0.85) hue-rotate(-12deg); }
  50% { filter: brightness(0.7) hue-rotate(-18deg) saturate(0.8); }
}
@keyframes life-cold-sidebar {
  0%, 100% { filter: none; }
  50% { filter: brightness(0.85); }
}

/* --- Power system warning → power bar flicker + red tinge --- */
body.sys-power-warning .power-fill {
  animation: bar-flicker 2s steps(1) infinite;
}
body.sys-power-warning .power-value {
  animation: bar-flicker 2.5s steps(1) infinite;
  color: var(--red);
}
body.sys-power-warning .power-bar {
  box-shadow: 0 0 8px rgba(255, 0, 0, 0.15);
}
@keyframes bar-flicker {
  0% { opacity: 1; }
  60% { opacity: 1; }
  61% { opacity: 0.2; }
  64% { opacity: 1; }
  80% { opacity: 1; }
  81% { opacity: 0.3; }
  83% { opacity: 1; }
  100% { opacity: 1; }
}

/* --- System healed — strong green flash --- */
body.sys-healed::after {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0, 255, 100, 0.15);
  pointer-events: none;
  z-index: 99999;
  animation: heal-flash 1.5s ease-out forwards;
}
@keyframes heal-flash {
  0% { opacity: 1; }
  20% { opacity: 0.8; }
  100% { opacity: 0; }
}

/* Location badge in sidebar */
.sidebar-location {
  padding: 8px 1rem;
  font-family: var(--mono);
  font-size: 0.6rem;
  letter-spacing: 1px;
  text-align: center;
  color: var(--cyan);
  border-bottom: 1px solid var(--border);
  background: rgba(0, 255, 255, 0.03);
}

/* ================================================================
   ELENA — Purple-themed chat
   ================================================================ */

.elena-title { color: var(--purple) !important; }

.elena-header {
  border-top: 2px solid var(--purple) !important;
  background: linear-gradient(135deg, rgba(179,136,255,0.06), var(--bg-card)) !important;
}

.elena-avatar {
  background: var(--purple-dim) !important;
  border-color: var(--purple) !important;
  color: var(--purple) !important;
}

.elena-avatar.thinking {
  animation: elena-pulse 1s ease-in-out infinite !important;
}

@keyframes elena-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(179,136,255,0.5); }
  50%     { box-shadow: 0 0 0 8px transparent; }
}

.elena-header-name { color: var(--purple) !important; }

#page-elena .aria-msg.from-elena {
  border-left: 3px solid var(--purple);
}

#page-elena .aria-msg.from-elena .aria-label {
  color: var(--purple);
}

.elena-send-btn {
  border-color: var(--purple) !important;
  color: var(--purple) !important;
}
.elena-send-btn:hover {
  background: var(--purple) !important;
  color: var(--bg) !important;
}

#navElena {
  color: var(--purple);
  border-left: 2px solid transparent;
}
#navElena:hover, #navElena.active {
  border-left-color: var(--purple);
  background: var(--purple-dim);
}

@keyframes elena-unlock {
  0%   { box-shadow: 0 0 0 0 rgba(179,136,255,0.6); }
  50%  { box-shadow: 0 0 12px 4px rgba(179,136,255,0.3); }
  100% { box-shadow: none; }
}

#navElena.newly-unlocked {
  animation: elena-unlock 1.5s ease-out;
}
