:root {
  --bg-base: #0b0f17;
  --bg-surface: #07090d;
  --bg-card: rgba(18, 24, 36, 0.85);
  --bg-card-hover: rgba(28, 38, 56, 0.85);
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(255, 107, 53, 0.5);
  
  --accent: #ff6b35;
  --accent-hover: #e55a2b;
  --accent-glow: rgba(255, 107, 53, 0.25);
  --status-green: #10b981;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --font-impact: 'Norwester', 'Plus Jakarta Sans', sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: var(--font-body);
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   TOP NAVBAR (DASHBOARD BRANDING)
   ========================================================================== */
#navbar {
  height: 52px;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 1000;
  flex-shrink: 0;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  user-select: none;
}

.logo-main {
  font-family: var(--font-impact);
  font-size: 1.35rem;
  letter-spacing: 0.05em;
  color: #ffffff;
  line-height: 1;
}

.logo-accent {
  font-family: var(--font-impact);
  font-size: 1.05rem;
  letter-spacing: 0.05em;
  color: var(--accent);
  padding: 3px 8px;
  border: 1.5px solid rgba(255, 107, 53, 0.5);
  background: rgba(255, 107, 53, 0.12);
  border-radius: 5px;
  line-height: 1;
}

.telemetry-meta {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 10px;
}
.telemetry-meta span { 
  color: #f0f6fc; 
  font-weight: 700; 
}
.telemetry-meta .divider { 
  color: rgba(255, 255, 255, 0.15); 
}

/* ==========================================================================
   BENTO GRID WORKSPACE
   ========================================================================== */
#app-workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 210px 1fr 310px;
  gap: 14px;
  padding: 12px 18px 14px 18px;
  max-width: 1720px;
  margin: 0 auto;
  width: 100%;
  height: calc(100vh - 52px);
  overflow: hidden;
}

.bento-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

/* Sidebar Left */
.section-label {
  font-size: 0.68rem;
  font-weight: 800;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-top: 4px;
}
.section-label:first-child { margin-top: 0; }

.btn-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bento-btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 0.80rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}
.bento-btn:hover:not(.disabled) {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
  color: var(--text-main);
}
.bento-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.bento-btn .meta {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-main);
}
.bento-btn.disabled { opacity: 0.35; cursor: not-allowed; }

.shortcut-card {
  margin-top: auto;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-size: 0.70rem;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.shortcut-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.key-badge {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--text-muted);
}

/* ==========================================================================
   CENTER STAGE & GESTAPELDE KAART LAYOUT
   ========================================================================== */
#stage-card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* 1. Header Bovenin */
.stage-header {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(11, 15, 23, 0.85);
  flex-shrink: 0;
}

.title-group {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.map-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-info-pop {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.70rem;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-info-pop:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.map-time {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.35);
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}
.map-time span.highlight {
  color: var(--accent);
  font-weight: 800;
}

/* 2. Kaart Midden (100% Volledige Breedte) */
.map-viewport {
  flex: 1;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0;
  overflow: hidden;
  background: var(--bg-base);
}

#active-frame {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0;
  user-select: none;
  cursor: crosshair;
}

/* Tooltip */
#map-tooltip {
  position: absolute;
  display: none;
  background: rgba(11, 15, 23, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-focus);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 8px;
  pointer-events: none;
  z-index: 60;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.7);
  min-width: 170px;
}
.tt-header {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 2px;
}
.tt-value-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.tt-value {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--accent);
}
.tt-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 3px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 4px;
  line-height: 1.25;
}

/* 3. Stage Footer (Gestapeld: Legenda + Dock) */
.stage-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(11, 15, 23, 0.90);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Losstaande Brede Legenda */
.legend-box {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.legend-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.legend-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 700;
}

.legend-bar {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.legend-ticks {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-dim);
  font-weight: 600;
}

/* Speler & Scrubber Dock */
#player-dock {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(22, 28, 38, 0.75);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 12px;
}

.dock-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text-main);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  transition: all 0.15s;
}
.dock-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
.dock-btn.active { background: var(--accent); color: #fff; box-shadow: 0 0 12px var(--accent-glow); }

.slider-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.slider-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--text-dim);
  padding: 0 2px;
}

#time-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
  height: 6px;
}

.step-badge {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 44px;
  text-align: center;
  background: rgba(0, 0, 0, 0.4);
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.speed-btn {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 4px 7px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.speed-btn:hover { color: var(--text-main); border-color: rgba(255, 255, 255, 0.2); }

/* Right Sidebar */
.theme-selector {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  background: rgba(0, 0, 0, 0.25);
  padding: 3px;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 6px;
}
.theme-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.70rem;
  font-weight: 700;
  padding: 6px 4px;
  border-radius: 6px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}
.theme-btn.active {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.param-card {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: all 0.15s;
}
.param-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
}
.param-card.active {
  background: rgba(255, 107, 53, 0.12);
  border-color: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}
.param-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.param-name {
  font-size: 0.80rem;
  font-weight: 700;
  color: var(--text-main);
}
.param-unit {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-dim);
  background: rgba(0, 0, 0, 0.35);
  padding: 1px 5px;
  border-radius: 4px;
}
.param-subtitle {
  font-size: 0.70rem;
  color: var(--text-muted);
  line-height: 1.2;
}

/* Modal Drawer */
#info-modal {
  position: absolute;
  top: 0; right: 0; bottom: 0; width: 380px;
  background: rgba(14, 19, 28, 0.96);
  backdrop-filter: blur(30px);
  border-left: 1px solid var(--border);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 2000;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.8);
  overflow-y: auto;
}
#info-modal.open { transform: translateX(0); }
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}
.modal-title { font-size: 1.05rem; font-weight: 800; }
.btn-close-modal {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-main);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.info-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.info-label {
  font-size: 0.70rem;
  font-weight: 800;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.info-body {
  font-size: 0.80rem;
  color: var(--text-muted);
  line-height: 1.45;
}
.threshold-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.74rem;
  margin-top: 4px;
}
.threshold-table td {
  padding: 4px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.threshold-table td.val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-main);
  width: 35%;
}
.threshold-table td.meaning { color: var(--text-muted); }

/* Loader */
#loader {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: var(--bg-base);
  display: flex;
  flex-direction: column;
  gap: 12px;
  justify-content: center;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
  z-index: 3000;
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   RESPONSIVE (MOBIELE 2-KOLOMS LAYOUT)
   ========================================================================== */
@media (max-width: 1080px) {
  #app-workspace {
    grid-template-columns: 1fr 280px;
  }
  #sidebar-left { display: none; }
}

@media (max-width: 820px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
  }

  #navbar {
    height: 46px;
    padding: 0 14px;
    position: sticky;
    top: 0;
    z-index: 1000;
  }
  .logo-main { font-size: 1.15rem; }
  .logo-accent { font-size: 0.85rem; padding: 2px 6px; }
  .telemetry-meta { font-size: 0.65rem; gap: 6px; }
  .telemetry-meta .divider { display: none; }
  #header-meta span:last-child { display: none; }

  #app-workspace {
    display: flex;
    flex-direction: column;
    height: auto;
    padding: 0 0 30px 0;
    gap: 12px;
    max-width: 100vw;
  }

  #stage-card {
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--border);
    width: 100vw;
    height: auto;
    background: var(--bg-base);
  }

  .stage-header {
    padding: 8px 12px;
  }

  /* Kaart vult exact 58vh op mobiel zonder scroll */
  .map-viewport {
    width: 100vw;
    height: 58vh;
    min-height: 380px;
  }

  .stage-footer {
    padding: 8px 12px;
    gap: 6px;
  }

  .legend-box {
    padding: 0 2px;
  }

  #player-dock {
    padding: 6px 10px;
    gap: 8px;
  }
  .dock-btn {
    width: 36px;
    height: 36px;
    font-size: 0.90rem;
  }
  #time-slider { height: 8px; }
  .step-badge {
    font-size: 0.80rem;
    min-width: 44px;
  }
  .speed-btn { display: none; }

  #sidebar-right {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0 14px;
    overflow: visible;
    gap: 10px;
  }
  .theme-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    margin-bottom: 2px;
  }
  .theme-btn {
    padding: 8px;
    font-size: 0.74rem;
  }

  .btn-stack {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .param-card {
    padding: 10px;
    border-radius: 10px;
    min-height: 64px;
    justify-content: center;
  }
  .param-name { font-size: 0.78rem; font-weight: 700; }
  .param-unit { font-size: 0.62rem; padding: 1px 4px; }
  .param-subtitle { font-size: 0.66rem; line-height: 1.15; margin-top: 2px; }

  #info-modal {
    width: 100vw;
  }
}