:root {
  --bg-primary: #000000; /* pure black = transparent on additive display */
  --bg-secondary: #0a0a0f;
  --bg-tertiary: #14141f;
  --bg-card: #1a1a2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent-primary: #00d4ff;
  --accent-secondary: #00ff88;
  --accent-warm: #ff9f43;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --success: #00ff88;
  --warning: #ffaa00;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  width: 600px;
  height: 600px;
  overflow: hidden;
}

#app { width: 100%; height: 100%; position: relative; }

/* --- Screens --- */
.screen {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  position: absolute;
  top: 0;
  left: 0;
}
.screen.hidden { display: none; }

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  padding: 14px 20px;
  background: var(--bg-secondary);
  gap: 12px;
  flex-shrink: 0;
}
.header h1 { font-size: 22px; font-weight: 700; flex: 1; }
.header-meta {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 7px;
}
.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-muted);
  box-shadow: 0 0 0 0 transparent;
}
.status-dot.live {
  background: var(--success);
  box-shadow: 0 0 10px var(--success);
}
.status-dot.demo {
  background: var(--warning);
  box-shadow: 0 0 10px var(--warning);
}

/* --- Content --- */
.content {
  flex: 1;
  padding: 12px 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- Focus states (critical for EMG/D-pad) --- */
.focusable {
  transition: all 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer;
  min-height: 44px;
}
.focusable:focus {
  outline: none;
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

/* ==================== ATTITUDE INDICATOR ==================== */
.attitude {
  position: relative;
  width: 200px;
  height: 200px;
  margin: 0 auto;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--bg-tertiary);
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.attitude-disc {
  position: absolute;
  inset: 0;
  transform-origin: 50% 50%;
  transition: transform 0.05s linear;
  will-change: transform;
}
.horizon-group {
  position: absolute;
  left: -50%;
  top: -50%;
  width: 200%;
  height: 200%;
  transition: transform 0.05s linear;
  will-change: transform;
}
.sky {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 50%;
  background: linear-gradient(to bottom, rgba(0,170,255,0.22), rgba(0,170,255,0.06));
}
.ground {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 50%;
  background: linear-gradient(to top, rgba(255,159,67,0.20), rgba(255,159,67,0.05));
}
.horizon-line {
  position: absolute;
  left: 0; right: 0;
  top: 50%;
  height: 2px;
  background: var(--text-primary);
  box-shadow: 0 0 6px rgba(255,255,255,0.6);
}
.pitch-ladder {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translateX(-50%);
}
.pitch-tick {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  width: 60px;
  text-align: center;
  border-top: 1px solid rgba(255,255,255,0.35);
  padding-top: 1px;
}
/* fixed roll pointer at top */
.roll-pointer {
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 10px solid var(--accent-secondary);
  z-index: 4;
}
/* fixed aircraft-style crosshair */
.attitude-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 5;
}
.cross-wing {
  width: 34px;
  height: 4px;
  background: var(--accent-primary);
  border-radius: 2px;
  box-shadow: 0 0 8px var(--focus-glow);
}
.cross-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-primary);
  box-shadow: 0 0 8px var(--focus-glow);
}
.heading-badge {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-tertiary);
  border-radius: 20px;
  padding: 3px 14px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  z-index: 6;
  display: flex;
  align-items: baseline;
  gap: 5px;
}
.heading-badge small {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-secondary);
}

/* ==================== TABS ==================== */
.tab-bar {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  flex-shrink: 0;
}
.tab-item {
  flex: 1;
  padding: 10px 8px;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
}
.tab-item.active { background: var(--bg-tertiary); color: var(--text-primary); }
.tab-item:focus { background: var(--bg-card); color: var(--text-primary); }

/* ==================== DATA GRID ==================== */
.data-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.panel { flex-shrink: 0; }
.panel.hidden { display: none; }
.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 8px 14px;
  border: 2px solid transparent;
}
.card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 1px;
}
.card-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.card-value.text-accent { color: var(--accent-primary); }
.card-unit { font-size: 11px; color: var(--text-muted); margin-top: 1px; }

/* ==================== NAV BAR ==================== */
.nav-bar {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.nav-item {
  flex: 1;
  padding: 14px 16px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 600;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-item:focus { background: var(--bg-card); }
.nav-item.primary { background: var(--accent-primary); color: #06121a; }
.nav-item.primary:focus { background: #33ddff; }
.nav-item.active-stop { background: var(--danger); color: #fff; }
.nav-item.active-stop:focus { background: #ff6680; }

/* ==================== TOAST ==================== */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-120px);
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 12px 24px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  border: 1px solid var(--accent-primary);
  transition: transform 0.3s ease;
  z-index: 100;
  pointer-events: none;
}
.toast.visible { transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--danger); }
.toast.success { border-color: var(--success); }

/* --- Utility --- */
.hidden { display: none !important; }
.text-accent { color: var(--accent-primary); }
