/* ────────────────────────────────────────────────────────────
   APEX — pit-wall strategy copilot
   Pure-black canvas, single amber accent, IBM Plex Mono for data.
   ──────────────────────────────────────────────────────────── */

:root {
  --ax-bg:        #000000;
  --ax-surface:   #0B0B0B;
  --ax-surface-2: #121212;
  --ax-surface-3: #181818;
  --ax-border:    #1F1F1F;
  --ax-border-2:  #2A2A2A;
  --ax-text-1:    #FAFAFA;
  --ax-text-2:    #A0A0A0;
  --ax-text-3:    #6B6B6B;
  --ax-text-4:    #4A4A4A;
  --ax-amber:     #FFB020;
  --ax-amber-dim: #FFB02022;
  --ax-red:       #FF3B30;
  --ax-green:     #4ADE80;
  --ax-cyan:      #7AE2FF;
  --ax-purple:    #C0A8FF;
  --ax-gain:      #4ADE80;
  --ax-loss:      #FF3B30;

  --ax-font-sans: "Inter", "Geist", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ax-font-mono: "IBM Plex Mono", "JetBrains Mono", "Geist Mono", ui-monospace, monospace;

  --ax-radius: 4px;
  --ax-radius-lg: 6px;
  --ax-gap: 12px;
  --ax-pad: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--ax-bg);
  color: var(--ax-text-1);
  font-family: var(--ax-font-sans);
  font-size: 13px;
  line-height: 1.4;
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button { font-family: inherit; }

.mono { font-family: var(--ax-font-mono); font-feature-settings: "tnum", "zero"; }

/* ────────────────────────────────────────────────────────────
   App shell — 4-row: topbar / section-nav / main / playback
   ──────────────────────────────────────────────────────────── */
.ax-app {
  display: grid;
  grid-template-rows: 52px 36px 1fr 36px;
  height: 100vh;
  min-height: 720px;
  background: var(--ax-bg);
}

.ax-app[data-density="compact"] { font-size: 12px; --ax-pad: 10px; --ax-gap: 8px; }

/* ────────────────────────────────────────────────────────────
   Top bar
   ──────────────────────────────────────────────────────────── */
.ax-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid var(--ax-border);
  background: linear-gradient(to bottom, #0a0a0a, #050505);
  gap: 24px;
  height: 52px;
}

.ax-top-l { display: flex; align-items: center; }
.ax-top-c { display: flex; justify-content: center; }
.ax-top-r { display: flex; justify-content: flex-end; align-items: center; gap: 18px; }

.ax-brand { display: flex; align-items: center; gap: 10px; }
.ax-brand-word {
  font-weight: 700; letter-spacing: 0.18em; font-size: 13px;
  color: var(--ax-text-1);
}
.ax-brand-dot {
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--ax-amber);
  box-shadow: 0 0 8px var(--ax-amber);
  animation: ax-pulse 2.4s ease-in-out infinite;
}
@keyframes ax-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.85); }
}
.ax-brand-tag {
  font-size: 10px; letter-spacing: 0.12em;
  color: var(--ax-text-3); margin-left: 4px;
  white-space: nowrap;
}
@media (max-width: 1100px) { .ax-brand-tag { display: none; } }

.ax-session { display: flex; align-items: center; gap: 14px; }
.ax-session-event { font-size: 11px; letter-spacing: 0.12em; color: var(--ax-text-2); }
.ax-session-divider { width: 1px; height: 16px; background: var(--ax-border-2); }
.ax-session-lap { display: flex; align-items: baseline; gap: 4px; }
.lap-current { font-size: 18px; font-weight: 600; color: var(--ax-text-1); letter-spacing: -0.01em; }
.lap-of { font-size: 11px; color: var(--ax-text-3); }
.ax-session-flag { font-size: 10px; letter-spacing: 0.12em; color: var(--ax-green); display: flex; align-items: center; gap: 6px; }
.ax-flag-dot { width: 6px; height: 6px; border-radius: 50%; }
.ax-flag-green { background: var(--ax-green); box-shadow: 0 0 6px var(--ax-green); }

.ax-driver-sel { display: flex; align-items: center; gap: 8px; }
.ax-driver-label { font-size: 10px; letter-spacing: 0.12em; color: var(--ax-text-3); }
.ax-driver-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 10px 4px 0;
  background: var(--ax-surface-2);
  border: 1px solid var(--ax-border-2);
  border-radius: var(--ax-radius);
  position: relative;
  overflow: hidden;
}
.ax-driver-bar { width: 3px; height: 22px; }
.ax-driver-num { font-size: 11px; color: var(--ax-text-3); margin-left: 6px; }
.ax-driver-code { font-weight: 600; letter-spacing: 0.04em; }

.ax-scen { display: flex; align-items: center; gap: 8px; }
.ax-scen-label { font-size: 10px; letter-spacing: 0.12em; color: var(--ax-text-3); }
.ax-scen-group {
  display: flex; gap: 0;
  border: 1px solid var(--ax-border-2);
  border-radius: var(--ax-radius);
  overflow: hidden;
}
.ax-scen-btn {
  background: transparent;
  border: none;
  border-right: 1px solid var(--ax-border-2);
  color: var(--ax-text-2);
  padding: 6px 10px;
  font-size: 10px;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 120ms ease;
}
.ax-scen-btn:last-child { border-right: none; }
.ax-scen-btn:hover { background: var(--ax-surface-2); color: var(--ax-text-1); }
.ax-scen-btn.active {
  background: var(--ax-amber-dim);
  color: var(--ax-amber);
}

/* ────────────────────────────────────────────────────────────
   Section nav — tab bar below topbar
   ──────────────────────────────────────────────────────────── */
.ax-section-nav {
  display: flex; align-items: stretch; justify-content: space-between;
  padding: 0 16px;
  background: #030303;
  border-bottom: 1px solid var(--ax-border);
  height: 36px;
  flex-shrink: 0;
  gap: 0;
}
.ax-section-tabs { display: flex; align-items: stretch; }
.ax-section-tab {
  padding: 0 14px;
  background: none; border: none;
  border-bottom: 2px solid transparent;
  color: var(--ax-text-3);
  font-size: 10px; letter-spacing: 0.12em;
  cursor: pointer;
  transition: color 120ms, border-color 120ms;
  margin-bottom: -1px;
  white-space: nowrap;
}
.ax-section-tab:hover { color: var(--ax-text-2); }
.ax-section-tab.active { color: var(--ax-amber); border-bottom-color: var(--ax-amber); }

.ax-section-meta { display: flex; align-items: center; gap: 12px; }
.ax-section-time { font-size: 10px; color: var(--ax-text-4); letter-spacing: 0.06em; }

/* Live badge */
.ax-live-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 6px;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.22);
  border-radius: 3px;
  font-size: 9px; letter-spacing: 0.12em;
  color: #ef4444;
}
.ax-live-pulse {
  width: 5px; height: 5px; border-radius: 50%;
  background: #ef4444;
  box-shadow: 0 0 5px #ef4444;
  animation: ax-live-ring 2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes ax-live-ring {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,.7); transform: scale(1); }
  55%       { box-shadow: 0 0 0 4px rgba(239,68,68,0); transform: scale(1.1); }
}

/* Section labels */
.ax-section-label {
  font-family: var(--ax-font-mono);
  font-size: 9px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ax-text-4);
  margin-bottom: 8px; padding-bottom: 6px;
  border-bottom: 1px solid var(--ax-border);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.ax-slabel-badge {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--ax-amber); font-size: 9px; letter-spacing: 0.12em;
  margin-left: auto;
}

/* Home button */
.ax-home-btn {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: var(--ax-radius);
  background: var(--ax-surface-2);
  border: 1px solid var(--ax-border-2);
  color: var(--ax-text-2); margin-right: 6px;
  transition: all 120ms;
}
.ax-home-btn:hover { color: var(--ax-text-1); background: var(--ax-surface-3); border-color: var(--ax-border-2); }

/* ────────────────────────────────────────────────────────────
   Main area — scrolls per tab
   ──────────────────────────────────────────────────────────── */
.ax-main {
  overflow: auto;
  min-height: 0;
  display: flex; flex-direction: column;
}

/* ────────────────────────────────────────────────────────────
   STRATEGY TAB
   ──────────────────────────────────────────────────────────── */
.ax-strategy-view {
  display: flex; flex-direction: column;
  height: 100%; min-height: 0; padding: var(--ax-gap);
  gap: var(--ax-gap);
}
.ax-kpi-row { flex-shrink: 0; }

.ax-strategy-cols {
  display: flex; gap: var(--ax-gap);
  flex: 1 1 auto; min-height: 0;
}
.ax-strategy-data {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column;
  gap: var(--ax-gap);
  overflow-y: auto;
  padding-right: 2px;
}
.ax-strategy-engineer {
  flex: 0 0 360px; min-width: 0;
  display: flex; flex-direction: column;
  min-height: 0;
}
.ax-strategy-engineer .ax-engineer { flex: 1 1 auto; min-height: 0; }

/* ────────────────────────────────────────────────────────────
   TELEMETRY TAB
   ──────────────────────────────────────────────────────────── */
.ax-telemetry-view {
  padding: var(--ax-gap);
  display: flex; flex-direction: column;
  gap: var(--ax-gap); height: 100%;
}
.ax-telemetry-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  grid-template-rows: auto auto;
  gap: var(--ax-gap);
  flex: 1 1 auto;
}
.ax-telem-main  { grid-column: 1 / -1; }
.ax-telem-sectors {}
.ax-telem-track {}

/* ────────────────────────────────────────────────────────────
   STANDINGS TAB
   ──────────────────────────────────────────────────────────── */
.ax-standings-view {
  padding: var(--ax-gap);
  display: flex; flex-direction: column;
  gap: var(--ax-gap); height: 100%;
}
.ax-standings-grid {
  display: grid; grid-template-columns: 1.5fr 1fr;
  gap: var(--ax-gap); flex: 1 1 auto; min-height: 0;
}
.ax-stand-main { min-height: 0; }
.ax-driver-panel {}

/* Driver stats */
.ax-dstats { display: flex; flex-direction: column; gap: 0; }
.ax-dstat-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid #111;
  font-size: 11px;
}
.ax-dstat-row:last-child { border-bottom: none; }
.ax-dstat-k { color: var(--ax-text-3); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; }
.ax-dstat-v { color: var(--ax-text-1); }

/* ────────────────────────────────────────────────────────────
   RACE LOG TAB
   ──────────────────────────────────────────────────────────── */
.ax-racelog-view {
  padding: var(--ax-gap);
  display: flex; flex-direction: column;
  gap: var(--ax-gap); max-width: 800px;
}

/* ────────────────────────────────────────────────────────────
   Card
   ──────────────────────────────────────────────────────────── */
.ax-card {
  background: var(--ax-surface);
  border: 1px solid var(--ax-border);
  border-radius: var(--ax-radius-lg);
  display: flex; flex-direction: column;
  min-height: 0;
  min-width: 0;
  position: relative;
}
.ax-card-hd {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px var(--ax-pad);
  border-bottom: 1px solid var(--ax-border);
  flex: 0 0 auto;
}
.ax-card-hd-l { display: flex; flex-direction: column; gap: 1px; }
.ax-card-hd-r { display: flex; align-items: center; gap: 8px; }
.ax-kicker {
  font-family: var(--ax-font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--ax-text-3);
  text-transform: uppercase;
}
.ax-card-title {
  margin: 0;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--ax-text-1);
}
.ax-card-bd { padding: var(--ax-pad); overflow: hidden; flex: 1 1 auto; min-height: 0; }
.ax-card-bd-flush { flex: 1 1 auto; min-height: 0; overflow: hidden; }

/* ────────────────────────────────────────────────────────────
   KPI strip
   ──────────────────────────────────────────────────────────── */
.ax-kpi-card { width: 100%; }
.ax-kpi-strip {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 0;
}
.ax-kpi {
  padding: 10px 14px;
  border-right: 1px solid var(--ax-border);
  display: flex; flex-direction: column; gap: 4px;
}
.ax-kpi:last-child { border-right: none; }
.ax-kpi-label {
  font-family: var(--ax-font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--ax-text-3);
  text-transform: uppercase;
}
.ax-kpi-value {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--ax-text-1);
}
.ax-kpi-value.mono { font-family: var(--ax-font-mono); font-weight: 400; }
.ax-kpi-unit {
  font-size: 11px;
  color: var(--ax-text-3);
  margin-left: 2px;
  font-weight: 400;
}

/* ────────────────────────────────────────────────────────────
   Pills / badges
   ──────────────────────────────────────────────────────────── */
.ax-pill {
  font-family: var(--ax-font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  padding: 3px 7px;
  border-radius: 3px;
  border: 1px solid var(--ax-border-2);
  color: var(--ax-text-2);
  display: inline-flex; align-items: center; gap: 4px;
}
.ax-pill-amber { color: var(--ax-amber); border-color: var(--ax-amber); background: var(--ax-amber-dim); }
.ax-pill-red { color: var(--ax-red); border-color: var(--ax-red); background: #FF3B3015; }
.ax-pill-green { color: var(--ax-green); border-color: var(--ax-green); background: #4ADE8015; }

/* ────────────────────────────────────────────────────────────
   Pit window strip
   ──────────────────────────────────────────────────────────── */
.ax-pitwin {
  position: relative;
  padding: 18px 0 22px;
}
.ax-pitwin-track {
  position: relative;
  height: 28px;
  background: var(--ax-surface-3);
  border: 1px solid var(--ax-border);
  border-radius: 2px;
}
.ax-pitwin-window {
  position: absolute;
  top: 0; bottom: 0;
  background: var(--ax-amber-dim);
  border-left: 1px solid var(--ax-amber);
  border-right: 1px solid var(--ax-amber);
}
.ax-pitwin-optimal {
  position: absolute;
  top: -4px; bottom: -4px;
  width: 2px;
  background: var(--ax-amber);
  box-shadow: 0 0 6px var(--ax-amber);
  transform: translateX(-1px);
}
.ax-pitwin-now {
  position: absolute;
  top: -8px; bottom: -8px;
  width: 0;
  border-left: 1px dashed var(--ax-text-1);
}
.ax-pitwin-now-dot {
  position: absolute;
  top: -2px; left: -3px;
  width: 6px; height: 6px;
  background: var(--ax-text-1);
  border-radius: 50%;
}
.ax-pitwin-now-label {
  position: absolute;
  top: -18px; left: 0;
  transform: translateX(-50%);
  font-family: var(--ax-font-mono);
  font-size: 9px;
  color: var(--ax-text-1);
  white-space: nowrap;
}
.ax-pitwin-axis {
  position: relative;
  height: 14px;
  font-family: var(--ax-font-mono);
  font-size: 9px;
  color: var(--ax-text-3);
  margin-top: 8px;
}
.ax-pitwin-meta {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--ax-border);
}
.ax-pitwin-meta > div, .ax-weather-meta > div {
  display: flex; flex-direction: column; gap: 2px;
}
.ax-meta-lbl { font-size: 9px; letter-spacing: 0.14em; color: var(--ax-text-3); }
.ax-meta-val { font-size: 11px; color: var(--ax-text-1); }
.ax-weather-meta {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--ax-border);
}

/* ────────────────────────────────────────────────────────────
   Micro-sectors
   ──────────────────────────────────────────────────────────── */
.ax-microsec { padding: 8px 0; }
.ax-microsec-row {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 1px;
  height: 80px;
  border-top: 1px dashed var(--ax-border);
  border-bottom: 1px dashed var(--ax-border);
  position: relative;
}
.ax-microsec-row::before {
  content: "";
  position: absolute;
  top: 50%; left: 0; right: 0;
  border-top: 1px solid var(--ax-border);
}
.ax-microsec-cell {
  display: flex; flex-direction: column;
  justify-content: center;
  position: relative;
  background: var(--ax-surface-2);
}
.ax-microsec-fill {
  width: 100%;
  min-height: 1px;
}
.ax-microsec-fill.loss { background: var(--ax-loss); margin-top: 50%; }
.ax-microsec-fill.gain { background: var(--ax-gain); margin-bottom: 50%; transform: translateY(50%); }
.ax-microsec-axis {
  display: flex;
  justify-content: space-around;
  margin-top: 8px;
  font-family: var(--ax-font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--ax-text-3);
}
.ax-mono-meta { font-size: 9px; letter-spacing: 0.1em; color: var(--ax-text-3); }
.ax-leg {
  display: inline-block;
  width: 8px; height: 8px;
  vertical-align: middle;
  margin-right: 2px;
}
.ax-leg.gain { background: var(--ax-gain); }
.ax-leg.loss { background: var(--ax-loss); }

/* ────────────────────────────────────────────────────────────
   Standings
   ──────────────────────────────────────────────────────────── */
.ax-stand {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100%;
}
.ax-stand-hd {
  display: grid;
  grid-template-columns: 36px 1fr 90px 80px 80px 90px;
  padding: 6px 10px 8px;
  font-family: var(--ax-font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--ax-text-3);
  border-bottom: 1px solid var(--ax-border);
}
.ax-stand-row {
  display: grid;
  grid-template-columns: 36px 1fr 90px 80px 80px 90px;
  align-items: center;
  padding: 8px 10px;
  background: none;
  border: none;
  border-bottom: 1px solid #131313;
  color: var(--ax-text-1);
  cursor: pointer;
  text-align: left;
  transition: background 100ms;
}
.ax-stand-row:hover { background: var(--ax-surface-2); }
.ax-stand-row.focus { background: var(--ax-amber-dim); }
.ax-stand-row.focus .ax-stand-pos { color: var(--ax-amber); }
.ax-stand-pos { font-family: var(--ax-font-mono); font-size: 13px; color: var(--ax-text-2); }
.ax-stand-drv { display: flex; align-items: center; gap: 8px; }
.ax-stand-bar { width: 3px; height: 18px; }
.ax-stand-code { font-weight: 600; letter-spacing: 0.04em; font-size: 12px; }
.ax-stand-gap, .ax-stand-int, .ax-stand-last { font-size: 11px; color: var(--ax-text-2); }
.ax-stand-tire { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--ax-text-2); }

/* ────────────────────────────────────────────────────────────
   Weather strip
   ──────────────────────────────────────────────────────────── */
.ax-weather { padding: 4px 0; }
.ax-weather-row {
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  gap: 2px;
  height: 56px;
  align-items: flex-end;
  border-bottom: 1px solid var(--ax-border);
}
.ax-weather-cell { position: relative; height: 100%; display: flex; align-items: flex-end; }
.ax-weather-bar {
  width: 100%;
  background: linear-gradient(to top, var(--ax-cyan), var(--ax-cyan) 60%, transparent);
  opacity: 0.6;
  min-height: 2px;
}
.ax-weather-axis {
  position: relative;
  margin-top: 6px;
  display: grid;
  grid-template-columns: repeat(16, 1fr);
  font-size: 9px;
  color: var(--ax-text-3);
  text-align: center;
}

/* ────────────────────────────────────────────────────────────
   Event log
   ──────────────────────────────────────────────────────────── */
.ax-log {
  display: flex; flex-direction: column;
  gap: 4px;
  max-height: 100%;
  overflow: auto;
}
.ax-log-row {
  display: grid;
  grid-template-columns: 30px 46px 70px 1fr;
  align-items: center;
  gap: 6px;
  padding: 5px 0;
  font-size: 11px;
  border-bottom: 1px solid #101010;
}
.ax-log-row:last-child { border-bottom: none; }
.ax-log-lap { color: var(--ax-text-3); font-size: 10px; }
.ax-log-time { color: var(--ax-text-3); font-size: 10px; }
.ax-log-tag {
  font-size: 9px;
  letter-spacing: 0.12em;
  padding: 2px 5px;
  border-radius: 2px;
  text-align: center;
  background: var(--ax-surface-3);
  color: var(--ax-text-2);
}
.ax-log-tag.type-incident { background: #FF3B3018; color: var(--ax-red); }
.ax-log-tag.type-warn { background: var(--ax-amber-dim); color: var(--ax-amber); }
.ax-log-tag.type-strategy { background: #C0A8FF15; color: var(--ax-purple); }
.ax-log-tag.type-ai { background: var(--ax-amber-dim); color: var(--ax-amber); }
.ax-log-tag.type-race { background: #4ADE8015; color: var(--ax-green); }
.ax-log-text { color: var(--ax-text-1); font-size: 11px; }

/* ────────────────────────────────────────────────────────────
   Engineer panel
   ──────────────────────────────────────────────────────────── */
.ax-engineer {
  display: flex; flex-direction: column;
  height: 100%;
  background: var(--ax-surface);
  border: 1px solid var(--ax-border);
  border-radius: var(--ax-radius-lg);
  overflow: hidden;
  position: relative;
}
.ax-engineer::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--ax-amber), transparent);
  opacity: 0.6;
}
.ax-engineer-hd {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px var(--ax-pad);
  border-bottom: 1px solid var(--ax-border);
  background: linear-gradient(to bottom, #0e0e0e, #0a0a0a);
}
.ax-engineer-title { display: flex; align-items: center; gap: 10px; }
.ax-engineer-mark {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  background: var(--ax-amber-dim);
  border: 1px solid var(--ax-amber);
  border-radius: 4px;
}
.ax-engineer-name { font-size: 12px; font-weight: 600; color: var(--ax-text-1); letter-spacing: 0.01em; }
.ax-engineer-sub { font-size: 9px; letter-spacing: 0.08em; color: var(--ax-text-3); }
.ax-engineer-status {
  display: flex; align-items: center; gap: 5px;
  font-size: 9px; letter-spacing: 0.12em;
  color: var(--ax-green);
}
.ax-engineer-status-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--ax-green);
  box-shadow: 0 0 6px var(--ax-green);
}

.ax-engineer-feed {
  flex: 1 1 auto;
  overflow: auto;
  padding: 12px var(--ax-pad);
  display: flex; flex-direction: column;
  gap: 14px;
  min-height: 0;
}
.ax-engineer-feed::-webkit-scrollbar { width: 6px; }
.ax-engineer-feed::-webkit-scrollbar-thumb { background: var(--ax-border-2); border-radius: 3px; }
.ax-engineer-feed::-webkit-scrollbar-track { background: transparent; }

.ax-msg-meta {
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--ax-text-3);
  margin-bottom: 5px;
}
.ax-msg-user-bubble {
  background: var(--ax-surface-3);
  border: 1px solid var(--ax-border-2);
  border-radius: 4px;
  padding: 8px 11px;
  font-size: 12px;
  color: var(--ax-text-1);
  align-self: flex-end;
  max-width: 92%;
  margin-left: auto;
}
.ax-msg-user { display: flex; flex-direction: column; align-items: flex-end; }
.ax-msg-user .ax-msg-meta { text-align: right; }
.ax-msg-eng { display: flex; flex-direction: column; }

/* ────────────────────────────────────────────────────────────
   Strategy card
   ──────────────────────────────────────────────────────────── */
.ax-strat {
  background: var(--ax-surface-2);
  border: 1px solid var(--ax-border-2);
  border-radius: 5px;
  padding: 12px;
  position: relative;
  overflow: hidden;
}
.ax-strat::before {
  content: "";
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 2px;
  background: var(--ax-text-3);
}
.ax-strat-advisory::before { background: var(--ax-text-2); }
.ax-strat-action::before { background: var(--ax-amber); }
.ax-strat-critical::before { background: var(--ax-red); }
.ax-strat-critical { background: linear-gradient(to right, #FF3B3008, var(--ax-surface-2) 40%); }

.ax-strat-hd {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.ax-strat-meta { display: flex; align-items: center; gap: 8px; }
.ax-strat-sev {
  font-family: var(--ax-font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  padding: 2px 6px;
  border-radius: 2px;
}
.sev-advisory { background: var(--ax-surface-3); color: var(--ax-text-2); }
.sev-action { background: var(--ax-amber-dim); color: var(--ax-amber); }
.sev-critical { background: #FF3B3018; color: var(--ax-red); }
.ax-strat-driver { font-size: 9px; letter-spacing: 0.12em; color: var(--ax-text-3); }
.ax-strat-live {
  display: flex; align-items: center; gap: 4px;
  font-family: var(--ax-font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--ax-amber);
}
.ax-strat-live-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--ax-amber);
  box-shadow: 0 0 5px var(--ax-amber);
  animation: ax-pulse 1.4s ease-in-out infinite;
}
.ax-strat-conf {
  font-size: 12px;
  color: var(--ax-text-2);
  letter-spacing: 0.04em;
}

.ax-strat-headline {
  margin: 4px 0 10px;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--ax-text-1);
  text-wrap: pretty;
}

.ax-strat-call {
  display: flex; align-items: baseline; gap: 10px;
  margin-bottom: 12px;
  padding: 8px 10px;
  background: var(--ax-surface-3);
  border-radius: 3px;
}
.ax-strat-call-label {
  font-family: var(--ax-font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--ax-text-3);
}
.ax-strat-call-value {
  font-size: 14px;
  font-weight: 500;
  color: var(--ax-amber);
  letter-spacing: 0.04em;
}

.ax-strat-reasons {
  list-style: none;
  margin: 0; padding: 0;
  display: flex; flex-direction: column;
  gap: 6px;
}
.ax-strat-reasons li {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px;
  font-size: 11px;
}
.ax-strat-r-label {
  font-family: var(--ax-font-mono);
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--ax-text-3);
  padding-top: 2px;
}
.ax-strat-r-value { color: var(--ax-text-1); line-height: 1.45; text-wrap: pretty; }

.ax-strat-risk {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--ax-border-2);
  font-size: 11px;
}
.ax-strat-risk-label {
  font-family: var(--ax-font-mono);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--ax-red);
}

/* Thinking trace */
.ax-think {
  background: var(--ax-surface-2);
  border: 1px solid var(--ax-border-2);
  border-radius: 5px;
  padding: 10px 12px;
}
.ax-think-step {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px;
  padding: 3px 0;
  color: var(--ax-text-3);
  font-family: var(--ax-font-mono);
  letter-spacing: 0.01em;
}
.ax-think-step.done { color: var(--ax-text-1); }
.ax-think-step.done .ax-think-dot { background: var(--ax-amber); box-shadow: 0 0 5px var(--ax-amber); }
.ax-think-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--ax-text-4);
  transition: all 200ms;
  flex: 0 0 auto;
}
.ax-think-step.pending:nth-child(1) .ax-think-dot,
.ax-think-step.pending:not(.done):first-of-type .ax-think-dot {
  animation: ax-blink 0.8s ease-in-out infinite;
}
@keyframes ax-blink {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; background: var(--ax-amber); }
}
.ax-think-text { line-height: 1.4; }

/* Quick prompts */
.ax-engineer-quick {
  display: flex; flex-wrap: wrap;
  gap: 5px;
  padding: 8px var(--ax-pad);
  border-top: 1px solid var(--ax-border);
}
.ax-chip {
  background: var(--ax-surface-2);
  border: 1px solid var(--ax-border-2);
  border-radius: 3px;
  padding: 5px 9px;
  font-size: 10px;
  color: var(--ax-text-2);
  cursor: pointer;
  letter-spacing: 0.01em;
  transition: all 120ms;
}
.ax-chip:hover { background: var(--ax-amber-dim); color: var(--ax-amber); border-color: var(--ax-amber); }

/* Input */
.ax-engineer-input {
  display: flex; align-items: center; gap: 6px;
  padding: 8px var(--ax-pad);
  border-top: 1px solid var(--ax-border);
  background: var(--ax-bg);
}
.ax-engineer-input input {
  flex: 1;
  background: var(--ax-surface-2);
  border: 1px solid var(--ax-border-2);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 12px;
  color: var(--ax-text-1);
  font-family: inherit;
  outline: none;
  transition: border 120ms;
}
.ax-engineer-input input::placeholder { color: var(--ax-text-3); }
.ax-engineer-input input:focus { border-color: var(--ax-amber); }
.ax-engineer-send {
  background: var(--ax-amber);
  border: none;
  border-radius: 4px;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  color: #000;
  cursor: pointer;
  transition: all 100ms;
}
.ax-engineer-send:hover { background: #fff; }

/* ────────────────────────────────────────────────────────────
   Playback bar
   ──────────────────────────────────────────────────────────── */
.ax-playback {
  display: flex; align-items: center; gap: 12px;
  padding: 0 16px;
  background: linear-gradient(to top, #050505, #0a0a0a);
  border-top: 1px solid var(--ax-border);
  height: 36px;
}
.ax-pb-btn {
  background: var(--ax-amber);
  border: none;
  width: 22px; height: 22px;
  border-radius: 3px;
  display: flex; align-items: center; justify-content: center;
  color: #000;
  cursor: pointer;
  transition: all 120ms;
}
.ax-pb-btn:hover { background: #fff; }
.ax-pb-speeds { display: flex; gap: 0; border: 1px solid var(--ax-border-2); border-radius: 3px; overflow: hidden; }
.ax-pb-speed {
  background: transparent;
  border: none;
  border-right: 1px solid var(--ax-border-2);
  color: var(--ax-text-2);
  padding: 3px 8px;
  font-size: 10px;
  cursor: pointer;
  letter-spacing: 0.04em;
}
.ax-pb-speed:last-child { border-right: none; }
.ax-pb-speed:hover { background: var(--ax-surface-2); color: var(--ax-text-1); }
.ax-pb-speed.active { background: var(--ax-amber-dim); color: var(--ax-amber); }

.ax-pb-time { font-size: 10px; color: var(--ax-text-3); letter-spacing: 0.04em; }
.ax-pb-track {
  flex: 1;
  position: relative;
  height: 4px;
  background: var(--ax-surface-3);
  border-radius: 2px;
}
.ax-pb-track-bg { position: absolute; inset: 0; }
.ax-pb-track-fill {
  position: absolute; top: 0; bottom: 0; left: 0;
  background: linear-gradient(to right, #FFB02080, var(--ax-amber));
  border-radius: 2px;
}
.ax-pb-track-marker {
  position: absolute;
  top: -3px;
  width: 2px; height: 10px;
  background: var(--ax-amber);
  transform: translateX(-1px);
  box-shadow: 0 0 6px var(--ax-amber);
}

/* ────────────────────────────────────────────────────────────
   Responsive — single canonical set, no duplicates
   ──────────────────────────────────────────────────────────── */

/* ── 1280px: shrink engineer column ─────────────────────────── */
@media (max-width: 1280px) {
  .ax-strategy-engineer { flex: 0 0 300px; }
}

/* ── 1024px tablet: switch to scrollable page layout ────────── */
@media (max-width: 1024px) {
  /*
   * Critical: keep 4-row grid but switch from fixed 100vh to auto
   * height so the grid rows (all non-fr) size to their content and
   * the page itself scrolls. "1fr" is NOT used here — it collapses
   * to 0 in a height:auto grid.
   */
  .ax-app {
    height: auto;
    min-height: 100svh;
    grid-template-rows: 52px 36px auto 36px;
  }

  /* main: natural height, page-level scroll */
  .ax-main {
    overflow: visible;
    min-height: 0;
  }

  /* All tab views: natural document height */
  .ax-strategy-view  { height: auto; min-height: 0; }
  .ax-telemetry-view { height: auto; }
  .ax-standings-view { height: auto; }
  .ax-racelog-view   { height: auto; }

  /* Strategy: stack engineer below data */
  .ax-strategy-cols {
    flex-direction: column;
    flex: 0 0 auto;
    height: auto;
    min-height: 0;
  }
  .ax-strategy-data {
    flex: 0 0 auto;
    overflow-y: visible;
  }
  .ax-strategy-engineer {
    flex: 0 0 auto;
    width: 100%;
    height: 580px;
  }

  /* Telemetry: single column */
  .ax-telemetry-grid { grid-template-columns: 1fr; }
  .ax-telem-main     { grid-column: auto; }

  /* Standings: single column */
  .ax-standings-grid { grid-template-columns: 1fr; }

  /* KPI: horizontal scroll, hide native scrollbar */
  .ax-kpi-strip {
    grid-template-columns: repeat(8, minmax(90px, 1fr));
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .ax-kpi-strip::-webkit-scrollbar { display: none; }

  /* Section nav: drop timestamp */
  .ax-section-time { display: none; }
}

/* ── 768px phone / small tablet ─────────────────────────────── */
@media (max-width: 768px) {
  /* Topbar: drop center session block */
  .ax-top {
    grid-template-columns: 1fr auto;
    padding: 0 12px;
    gap: 12px;
  }
  .ax-top-c       { display: none; }
  .ax-top-r       { gap: 8px; }
  .ax-driver-sel  { display: none; }
  .ax-scen-label  { display: none; }
  .ax-session     { gap: 8px; }
  .ax-session-event { display: none; }

  /* Tab views: tighter padding */
  .ax-strategy-view,
  .ax-telemetry-view,
  .ax-standings-view,
  .ax-racelog-view { padding: 8px; }

  /* Engineer panel: shorter on phone */
  .ax-strategy-engineer { height: 500px; }

  /* KPI */
  .ax-kpi-strip {
    grid-template-columns: repeat(8, minmax(80px, 1fr));
    scrollbar-width: none;
  }
  .ax-kpi-strip::-webkit-scrollbar { display: none; }
  .ax-kpi-value { font-size: 16px; }

  /* Standings: hide compound + interval columns */
  .ax-stand-hd,
  .ax-stand-row {
    grid-template-columns: 28px 1fr 70px 70px;
  }
  .ax-stand-hd > :nth-child(5),
  .ax-stand-hd > :nth-child(6),
  .ax-stand-row > :nth-child(5),
  .ax-stand-row > :nth-child(6) { display: none; }
}

/* ── 480px phone (Galaxy S20 Ultra, iPhone 14, etc.) ─────────── */
@media (max-width: 480px) {
  :root { --ax-pad: 10px; --ax-gap: 8px; }

  .ax-top { padding: 0 10px; }
  .ax-scen { display: none; }
  .ax-section-tab { padding: 0 10px; font-size: 9px; }
  .ax-brand-tag   { display: none; }
  .ax-brand-word  { font-size: 12px; }

  /* Engineer panel */
  .ax-strategy-engineer { height: 460px; }
  .ax-engineer-quick    { gap: 4px; }
  .ax-chip { font-size: 9px; padding: 4px 7px; }

  /* KPI */
  .ax-kpi-strip  { grid-template-columns: repeat(8, minmax(80px, 1fr)); }
  .ax-kpi-value  { font-size: 15px; }

  /* Playback bar: minimal */
  .ax-pb-speeds { display: none; }
  .ax-pb-time   { font-size: 9px; }

  /* Micro sectors: 16 cols */
  .ax-microsec-row { grid-template-columns: repeat(16, 1fr); }
  .ax-microsec-row > :nth-child(n+17) { display: none; }

  /* Weather: 12 cols */
  .ax-weather-row,
  .ax-weather-axis { grid-template-columns: repeat(12, 1fr); }
  .ax-weather-row  > :nth-child(n+13),
  .ax-weather-axis > :nth-child(n+13) { display: none; }

  /* Strategy card */
  .ax-strat-reasons li,
  .ax-strat-risk { grid-template-columns: 70px 1fr; }
}
