/* ====================================================
   STARK INDUSTRIES — IRON MAN THEME
   ==================================================== */

/* ---- CSS Variables ---- */
:root {
  --sw-black:      #05080a;
  --sw-dark:       #080c10;
  --sw-darker:     #030508;
  --sw-panel:      rgba(15, 20, 25, 0.25);
  --sw-panel-edge: rgba(180, 160, 100, 0.4);
  --sw-gold:       #c4b68c; 
  --sw-gold-dim:   #9ca086;
  --sw-blue:       #cc6666; 
  --sw-cyan:       #c4b68c; 
  --sw-red:        #cc5555;
  --sw-green:      #55cc88;
  --sw-yellow:     #ccaa55;
  --sw-text:       #d8dfde;
  --sw-text-dim:   #8a9e9a;
  --glow-red:      0 0 10px rgba(204,85,85,0.8), 0 0 20px rgba(204,85,85,0.4);
  --glow-green:    0 0 10px rgba(85,204,136,0.8), 0 0 20px rgba(85,204,136,0.4);
  --glow-yellow:   0 0 10px rgba(204,170,85,0.8), 0 0 20px rgba(204,170,85,0.4);
  --glow-gold:     0 0 10px rgba(196,182,140,0.6);
  --glow-blue:     0 0 10px rgba(204,102,102,0.6);
  --font-sw:       'Chakra Petch', sans-serif;
  --font-body:     'Rajdhani', sans-serif;
  --border-r:      8px;
  --transition:    0.25s ease;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.hidden { display: none !important; }

html {
  font-size: 16px; /* Increased from 14px for scale */
  scroll-behavior: smooth;
}

body {
  background: var(--sw-black);
  color: var(--sw-text);
  font-family: var(--font-body);
  min-height: 100vh;
  overflow-x: hidden;
}
body::after {
  content: '';
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    rgba(255, 255, 255, 0.015),
    rgba(255, 255, 255, 0.015) 1px,
    transparent 1px,
    transparent 3px
  );
  z-index: 9999;
}

/* Background starfield canvas removed */

/* ---- Connection Badge ---- */
.connection-badge {
  position: fixed;
  top: 12px; right: 16px;
  font-family: var(--font-sw);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--sw-panel-edge);
  background: var(--sw-panel);
  z-index: 1000;
  letter-spacing: 0.05em;
  transition: var(--transition);
}
[data-status="connected"] { color: var(--sw-green); border-color: var(--sw-green); text-shadow: var(--glow-green); }
[data-status="simulated"] { color: var(--sw-gold); border-color: var(--sw-gold); }
[data-status="error"]     { color: var(--sw-red);  border-color: var(--sw-red);  }

/* ---- Header ---- */
.main-header {
  position: relative;
  z-index: 10;
  background: rgba(15, 20, 25, 0.3);
  border-bottom: 1px solid var(--sw-gold);
  box-shadow: 0 5px 25px rgba(0, 0, 0, 0.3);
  padding: 0 1.5rem;
  backdrop-filter: blur(12px);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 15px 100%, 0 calc(100% - 15px));
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
  min-height: 76px;
  flex-wrap: wrap;
  padding: 10px 0;
}
.logo-block {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}
.imperial-cog {
  font-size: 2.2rem;
  color: var(--sw-gold);
  text-shadow: var(--glow-gold);
  animation: cogSpin 12s linear infinite;
}
@keyframes cogSpin { to { transform: rotate(360deg); } }
.logo-text { display: flex; flex-direction: column; }
.logo-title {
  font-family: var(--font-sw);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--sw-gold);
  letter-spacing: 0.15em;
  text-shadow: var(--glow-gold);
}
.header-arc {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--sw-gold);
  box-shadow: var(--glow-gold), inset 0 0 10px var(--sw-gold);
  background: radial-gradient(circle, rgba(255,215,0,0.8), transparent 70%);
}
.logo-sub {
  font-size: 0.85rem;
  color: var(--sw-text-dim);
  letter-spacing: 0.1em;
  font-weight: 600;
}
.mode-tabs {
  display: flex;
  gap: 0.5rem;
  background: rgba(255,255,255,0.03);
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--sw-panel-edge);
}
.mode-tab {
  font-family: var(--font-sw);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: 7px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--sw-text-dim);
  cursor: pointer;
  letter-spacing: 0.08em;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}
.mode-tab:hover {
  color: var(--sw-gold);
  border-color: var(--sw-panel-edge);
}
.mode-tab.active {
  background: rgba(255, 215, 0, 0.15);
  border-color: var(--sw-gold);
  color: var(--sw-gold);
  text-shadow: var(--glow-gold);
}
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
}
.esp32-config {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-sw);
  font-size: 0.85rem;
  color: var(--sw-text-dim);
}
.ip-input {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--sw-panel-edge);
  color: var(--sw-text);
  border-radius: 5px;
  padding: 6px 10px;
  font-family: var(--font-sw);
  font-size: 0.9rem;
  width: 140px;
  outline: none;
  transition: var(--transition);
}
.ip-input:focus { border-color: var(--sw-gold); box-shadow: var(--glow-gold); }
.btn-small {
  background: rgba(255, 215, 0, 0.15);
  border: 1px solid var(--sw-gold);
  color: var(--sw-gold);
  border-radius: 5px;
  padding: 6px 14px;
  font-family: var(--font-sw);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: var(--transition);
}
.btn-small:hover {
  background: rgba(255, 215, 0, 0.25);
  box-shadow: var(--glow-gold);
}

/* Red Map Button */
.btn-map-red {
  background: rgba(255, 50, 50, 0.2) !important;
  border: 1px solid #ff3333 !important;
  color: #ff3333 !important;
  text-shadow: 0 0 6px rgba(255, 50, 50, 0.4);
  position: relative;
  overflow: hidden;
}
.btn-map-red::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,50,50,0.1), transparent 60%);
  pointer-events: none;
}
.btn-map-red:hover {
  background: rgba(255, 50, 50, 0.35) !important;
  box-shadow: 0 0 12px rgba(255, 50, 50, 0.5), 0 0 24px rgba(255, 50, 50, 0.2) !important;
  transform: scale(1.05);
}
.btn-map-red.active {
  background: rgba(255, 50, 50, 0.35) !important;
  box-shadow: 0 0 15px rgba(255, 50, 50, 0.6), 0 0 30px rgba(255, 50, 50, 0.3), inset 0 0 10px rgba(255, 50, 50, 0.2) !important;
  animation: pulse-map-red 2s ease-in-out infinite;
}
@keyframes pulse-map-red {
  0%, 100% { box-shadow: 0 0 12px rgba(255,50,50,0.5), 0 0 24px rgba(255,50,50,0.2); }
  50% { box-shadow: 0 0 20px rgba(255,50,50,0.7), 0 0 40px rgba(255,50,50,0.3); }
}

/* ---- Map Controls Overlay ---- */
#map-controls {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0;
  pointer-events: none;
}
#map-controls > * { pointer-events: auto; }

/* Search Bar */
.map-search-bar {
  display: flex;
  align-items: center;
  margin: 10px 10px 0;
  background: rgba(5, 8, 10, 0.85);
  border: 1px solid rgba(255, 50, 50, 0.4);
  border-radius: 8px;
  overflow: hidden;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  transition: border-color 0.3s;
}
.map-search-bar:focus-within {
  border-color: #ff3333;
  box-shadow: 0 0 15px rgba(255, 50, 50, 0.3), 0 4px 20px rgba(0,0,0,0.5);
}
.map-search-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--sw-text);
  font-family: var(--font-sw);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 10px 14px;
  outline: none;
  letter-spacing: 0.04em;
}
.map-search-input::placeholder {
  color: var(--sw-text-dim);
  font-weight: 500;
}
.map-search-btn {
  background: rgba(255, 50, 50, 0.2);
  border: none;
  border-left: 1px solid rgba(255, 50, 50, 0.3);
  color: #ff3333;
  cursor: pointer;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.map-search-btn:hover {
  background: rgba(255, 50, 50, 0.35);
}

/* Map Mode Toolbar */
.map-mode-toolbar {
  display: flex;
  gap: 2px;
  margin: 6px 10px 0;
  background: rgba(5, 8, 10, 0.85);
  border: 1px solid rgba(180, 160, 100, 0.25);
  border-radius: 8px;
  padding: 3px;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
  overflow-x: auto;
}
.map-mode-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--sw-text-dim);
  font-family: var(--font-sw);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  flex-shrink: 0;
}
.map-mode-btn:hover {
  color: var(--sw-text);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.1);
}
.map-mode-btn.active {
  color: #ff3333;
  background: rgba(255, 50, 50, 0.15);
  border-color: rgba(255, 50, 50, 0.5);
  text-shadow: 0 0 8px rgba(255, 50, 50, 0.4);
  box-shadow: 0 0 8px rgba(255, 50, 50, 0.15);
}
.map-mode-btn svg { flex-shrink: 0; }

/* Route Info Panel */
.route-info-panel {
  margin: 6px 10px 0;
  background: rgba(5, 8, 10, 0.9);
  border: 1px solid rgba(255, 50, 50, 0.4);
  border-radius: 8px;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  overflow: hidden;
}
.route-info-panel.hidden { display: none; }
.route-info-header {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #ff3333;
  font-family: var(--font-sw);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 50, 50, 0.2);
}
.route-clear-btn {
  margin-left: auto;
  background: rgba(255, 50, 50, 0.15);
  border: 1px solid rgba(255, 50, 50, 0.3);
  color: #ff3333;
  border-radius: 4px;
  width: 22px; height: 22px;
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}
.route-clear-btn:hover { background: rgba(255, 50, 50, 0.3); }
.route-info-content {
  padding: 10px 12px;
}
.route-hint {
  color: var(--sw-text-dim);
  font-family: var(--font-sw);
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.04em;
}
.route-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.route-stat-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 50, 50, 0.15);
  border-radius: 6px;
  padding: 8px 10px;
  text-align: center;
}
.route-stat-value {
  font-family: var(--font-sw);
  font-size: 1.3rem;
  font-weight: 900;
  color: #ff3333;
  text-shadow: 0 0 8px rgba(255, 50, 50, 0.4);
  line-height: 1.2;
}
.route-stat-label {
  font-family: var(--font-sw);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--sw-text-dim);
  letter-spacing: 0.08em;
  margin-top: 2px;
}
.route-destination {
  margin-top: 6px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 4px;
  font-family: var(--font-sw);
  font-size: 0.7rem;
  color: var(--sw-text-dim);
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.route-destination .dest-label { color: #ff3333; font-weight: 700; }

/* Street View Back Button */
.streetview-back-btn {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
  background: rgba(5, 8, 10, 0.9);
  border: 1px solid #ff3333;
  color: #ff3333;
  font-family: var(--font-sw);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 10px 24px;
  border-radius: 8px;
  cursor: pointer;
  backdrop-filter: blur(12px);
  box-shadow: 0 0 15px rgba(255, 50, 50, 0.3), 0 6px 20px rgba(0,0,0,0.6);
  transition: var(--transition);
}
.streetview-back-btn:hover {
  background: rgba(255, 50, 50, 0.25);
  box-shadow: 0 0 20px rgba(255, 50, 50, 0.5), 0 6px 20px rgba(0,0,0,0.6);
  transform: translateX(-50%) translateY(-2px);
}
.streetview-back-btn.hidden { display: none; }

/* Map Container */
#map-container {
  overflow: hidden;
}
#map-container .maplibregl-canvas { border-radius: 8px; }
.maplibregl-ctrl-attrib { display: none !important; }

/* ---- Main Grid ---- */
.main-grid {
  display: grid;
  grid-template-columns: 280px 1fr 340px;
  gap: 1.2rem;
  padding: 1.2rem 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
  position: relative;
  z-index: 5;
}

/* ---- Panel ---- */
.panel {
  background: var(--sw-panel);
  border: 1px solid var(--sw-panel-edge);
  border-radius: 0;
  backdrop-filter: blur(6px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  clip-path: polygon(0 15px, 15px 0, 100% 0, 100% calc(100% - 15px), calc(100% - 15px) 100%, 0 100%);
}
.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(255, 215, 0, 0.08);
  border-bottom: 2px solid var(--sw-panel-edge);
  font-family: var(--font-sw);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--sw-gold);
}
.panel-icon-box {
  display: inline-block;
  width: 8px;
  height: 8px;
  border: 1px solid var(--sw-gold);
  background: rgba(255, 215, 0, 0.2);
}

/* ---- LEFT PANEL: Traffic Light ---- */
.panel-left {
  align-items: center;
  padding-bottom: 1.5rem;
}
.traffic-light-housing {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5rem 0 0;
  gap: 0;
  transform: scale(1.1);
  transform-origin: top center;
}
.tl-pole-top {
  width: 40px;
  height: 30px;
  background: linear-gradient(90deg, #111, #333, #111);
  border: 1px solid var(--sw-panel-edge);
  clip-path: polygon(25% 0, 75% 0, 100% 100%, 0 100%);
}
.traffic-light {
  background: rgba(15, 20, 25, 0.5);
  border: 1px solid var(--sw-panel-edge);
  backdrop-filter: blur(10px);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: inset 0 0 15px rgba(204,170,85,0.05);
  clip-path: polygon(20px 0, 100% 0, 100% calc(100% - 20px), calc(100% - 20px) 100%, 0 100%, 0 20px);
  width: 104px;
}
.light-socket {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.light-bulb {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  position: relative;
  cursor: default;
  transition: all 0.4s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
}

/* Arc reactor base structure */
.arc-ring-1 {
  position: absolute;
  inset: 2px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.05);
  transition: all 0.4s ease;
}
.arc-ring-2 {
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  border: 2px dashed rgba(255, 255, 255, 0.05);
  transition: all 0.4s ease;
}
.arc-core {
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  transition: all 0.4s ease;
}

/* Red Arc */
.light-bulb.red .arc-ring-1 { border-color: rgba(255, 42, 42, 0.1); }
.light-bulb.red.active .arc-ring-1 { border-color: var(--sw-red); box-shadow: inset 0 0 10px var(--sw-red), 0 0 15px var(--sw-red); }
.light-bulb.red.active .arc-ring-2 { border-color: #ff8888; animation: spin-slow 4s linear infinite; }
.light-bulb.red.active .arc-core { background: var(--sw-red); box-shadow: 0 0 20px var(--sw-red), 0 0 40px rgba(255,42,42,0.5); }

/* Yellow Arc */
.light-bulb.yellow .arc-ring-1 { border-color: rgba(255, 167, 0, 0.1); }
.light-bulb.yellow.active .arc-ring-1 { border-color: var(--sw-yellow); box-shadow: inset 0 0 10px var(--sw-yellow), 0 0 15px var(--sw-yellow); }
.light-bulb.yellow.active .arc-ring-2 { border-color: #ffcc66; animation: spin-slow 4s linear infinite; }
.light-bulb.yellow.active .arc-core { background: var(--sw-yellow); box-shadow: 0 0 20px var(--sw-yellow), 0 0 40px rgba(255,167,0,0.5); }

/* Green Arc */
.light-bulb.green .arc-ring-1 { border-color: rgba(0, 255, 135, 0.1); }
.light-bulb.green.active .arc-ring-1 { border-color: var(--sw-green); box-shadow: inset 0 0 10px var(--sw-green), 0 0 15px var(--sw-green); }
.light-bulb.green.active .arc-ring-2 { border-color: #66ffb2; animation: spin-slow 4s linear infinite; }
.light-bulb.green.active .arc-core { background: var(--sw-green); box-shadow: 0 0 20px var(--sw-green), 0 0 40px rgba(0,255,135,0.5); }

@keyframes spin-slow { 100% { transform: rotate(360deg); } }
.light-label {
  font-family: var(--font-sw);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--sw-gold);
  letter-spacing: 0.12em;
}
.tl-pole {
  width: 28px;
  height: 60px;
  background: linear-gradient(90deg, #111, #444, #111);
  border-left: 1px solid var(--sw-panel-edge);
  border-right: 1px solid var(--sw-panel-edge);
  position: relative;
}
.tl-pole::after {
  content: '';
  position: absolute;
  top: 10px; bottom: 10px; left: 8px; right: 8px;
  background: repeating-linear-gradient(
    0deg,
    #222,
    #222 4px,
    transparent 4px,
    transparent 8px
  );
}
.tl-base {
  width: 80px;
  height: 20px;
  background: linear-gradient(90deg, #111, #333, #111);
  border: 1px solid var(--sw-panel-edge);
  clip-path: polygon(0 100%, 15px 0, calc(100% - 15px) 0, 100% 100%);
}

/* Countdown */
.countdown-block {
  width: 100%;
  padding: 1.2rem;
  text-align: center;
  margin-top: 1rem;
}
.countdown-label {
  font-family: var(--font-sw);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--sw-text-dim);
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}
.countdown-timer {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
}
#countdown-display {
  font-family: var(--font-sw);
  font-size: 3.5rem;
  font-weight: 900;
  color: var(--sw-gold);
  text-shadow: var(--glow-gold);
  line-height: 1;
  min-width: 3ch;
  display: inline-block;
  text-align: center;
  transition: color 0.3s;
}
.countdown-unit {
  font-family: var(--font-sw);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--sw-gold-dim);
}
.countdown-bar-track {
  margin-top: 12px;
  height: 6px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
}
.countdown-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--sw-red), var(--sw-gold));
  border-radius: 3px;
  width: 100%;
  transition: width 1s linear;
}

/* Status Block */
.status-block {
  width: 100%;
  padding: 0 1.2rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: rgba(255,255,255,0.04);
  border-radius: 5px;
  border-left: 3px solid var(--sw-panel-edge);
}
.status-key {
  font-family: var(--font-sw);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--sw-text-dim);
  letter-spacing: 0.1em;
}
.status-val {
  font-family: var(--font-sw);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--sw-gold);
}
.power-on { color: var(--sw-green) !important; }
.power-off { color: var(--sw-red) !important; }

/* ---- CENTER PANEL: Canvas ---- */
.panel-center { flex: 1; min-width: 0; }
.canvas-wrapper {
  position: relative;
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  background: rgba(0,0,0,0.5);
  min-height: 340px;
}
#scene-canvas {
  width: 100%;
  height: auto;
  max-height: 480px;
  border-radius: 8px;
  display: block;
}
.sound-toggle { margin-left: auto; }
.btn-icon-sm {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--sw-panel-edge);
  color: var(--sw-text);
  border-radius: 5px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 1rem;
  transition: var(--transition);
}
.btn-icon-sm:hover { background: rgba(255, 215, 0, 0.15); border-color: var(--sw-gold); }
.scene-legend {
  display: flex;
  gap: 1.5rem;
  padding: 12px 16px;
  border-top: 1px solid var(--sw-panel-edge);
  flex-wrap: wrap;
  justify-content: center;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--sw-text-dim);
  letter-spacing: 0.05em;
}

/* ---- RIGHT PANEL: Controls ---- */
.panel-right { overflow-y: auto; }
.control-panel { padding: 1.2rem; display: flex; flex-direction: column; gap: 0.8rem; }
.control-panel.hidden { display: none; }
.ctrl-section-title {
  font-family: var(--font-sw);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--sw-gold-dim);
  border-bottom: 1px solid var(--sw-panel-edge);
  padding-bottom: 6px;
  margin-bottom: 8px;
}

/* Duration Grid */
.duration-grid { display: flex; flex-direction: column; gap: 10px; }
.duration-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.05);
}
.dur-label {
  font-family: var(--font-sw);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  flex: 1;
  min-width: 0;
}
.red-label    { color: var(--sw-red); }
.yellow-label { color: var(--sw-yellow); }
.green-label  { color: var(--sw-green); }
.dur-input {
  width: 70px;
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--sw-panel-edge);
  color: var(--sw-gold);
  border-radius: 5px;
  padding: 6px 8px;
  font-family: var(--font-sw);
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  outline: none;
  transition: var(--transition);
}
.dur-input:focus { border-color: var(--sw-gold); box-shadow: var(--glow-gold); }
.dur-unit { font-size: 0.75rem; color: var(--sw-text-dim); font-weight: 600; }

.btn-apply {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 215, 0, 0.05));
  border: 1px solid var(--sw-gold);
  color: var(--sw-gold);
  border-radius: 8px;
  font-family: var(--font-sw);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 6px;
}
.btn-apply:hover {
  background: rgba(255, 215, 0, 0.3);
  box-shadow: var(--glow-gold);
  transform: translateY(-2px);
}
.btn-apply:active { transform: translateY(0); }

/* Sim Buttons */
.sim-btns { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-ctrl {
  flex: 1;
  padding: 10px 6px;
  border-radius: 7px;
  font-family: var(--font-sw);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  border: 1px solid;
  transition: var(--transition);
  min-width: 75px;
}
.btn-ctrl:hover { transform: translateY(-2px); filter: brightness(1.2); }
.btn-ctrl:active { transform: translateY(0); }
.btn-start     { background: rgba(0,255,135,0.15); border-color: var(--sw-green); color: var(--sw-green); }
.btn-stop-sim  { background: rgba(255,179,0,0.15); border-color: var(--sw-yellow); color: var(--sw-yellow); }
.btn-skip      { background: rgba(79,195,247,0.15); border-color: #4fc3f7; color: #4fc3f7; }

/* Power Buttons */
.power-btns { display: flex; gap: 10px; }
.btn-power {
  flex: 1;
  padding: 14px 10px;
  border-radius: 8px;
  font-family: var(--font-sw);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  cursor: pointer;
  border: 2px solid;
  transition: var(--transition);
  opacity: 0.6;
}
.btn-power:hover { opacity: 1; transform: translateY(-2px); }
.btn-power:active { transform: translateY(0); }
.btn-power.active { opacity: 1; box-shadow: 0 0 15px currentColor; border-width: 2px; }
.btn-power-on  { background: rgba(0,255,135,0.15); border-color: var(--sw-green); color: var(--sw-green); }
.btn-power-off { background: rgba(255,51,51,0.15); border-color: var(--sw-red); color: var(--sw-red); }

/* Manual Light Select */
.manual-light-btns { display: flex; gap: 10px; }
.btn-light {
  flex: 1;
  padding: 12px 6px;
  border-radius: 8px;
  font-family: var(--font-sw);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
  border: 1px solid;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  opacity: 0.6;
}
.btn-light:hover { opacity: 1; transform: translateY(-2px); }
.btn-light.active { opacity: 1; border-width: 2px; }
.btn-bulb-icon {
  width: 28px; height: 28px;
  border-radius: 50%;
  opacity: 0.5;
  transition: var(--transition);
}
.btn-light.active .btn-bulb-icon { opacity: 1; box-shadow: 0 0 15px currentColor; }
.red-bg    { background: var(--sw-red); }
.yellow-bg { background: var(--sw-yellow); }
.green-bg  { background: var(--sw-green); }
.btn-light-red    { background: rgba(255,51,51,0.15);   border-color: var(--sw-red);    color: var(--sw-red); }
.btn-light-yellow { background: rgba(255,179,0,0.15);   border-color: var(--sw-yellow); color: var(--sw-yellow); }
.btn-light-green  { background: rgba(0,255,135,0.15);   border-color: var(--sw-green);  color: var(--sw-green); }
.btn-light-red.active    { box-shadow: var(--glow-red); }
.btn-light-yellow.active { box-shadow: var(--glow-yellow); }
.btn-light-green.active  { box-shadow: var(--glow-green); }

/* Brightness */
.brightness-group { display: flex; flex-direction: column; gap: 10px; }
.bright-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
}
.bright-label {
  font-family: var(--font-sw);
  font-size: 0.8rem;
  font-weight: 600;
  min-width: 40px;
  letter-spacing: 0.06em;
}
.bright-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}
.red-slider    { background: linear-gradient(90deg, #3a0000, var(--sw-red)); }
.yellow-slider { background: linear-gradient(90deg, #3a2200, var(--sw-yellow)); }
.green-slider  { background: linear-gradient(90deg, #002208, var(--sw-green)); }
.bright-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--sw-gold);
  cursor: pointer;
  box-shadow: 0 0 8px var(--sw-gold);
}
.bright-val {
  font-family: var(--font-sw);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--sw-text-dim);
  min-width: 35px;
  text-align: right;
}

/* Blink */
.blink-group { display: flex; flex-direction: column; gap: 10px; }
.blink-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.04);
  border-radius: 6px;
}
.blink-label {
  font-family: var(--font-sw);
  font-size: 0.8rem;
  font-weight: 600;
  min-width: 40px;
  letter-spacing: 0.06em;
}
.blink-input {
  width: 70px;
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--sw-panel-edge);
  color: var(--sw-gold);
  border-radius: 5px;
  padding: 6px;
  font-family: var(--font-sw);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  outline: none;
}
.blink-unit {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--sw-text-dim);
}

/* Toggle Switch */
.sw-toggle { position: relative; display: inline-block; width: 44px; height: 22px; flex-shrink: 0; }
.sw-toggle input { opacity: 0; width: 0; height: 0; }
.sw-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(255,255,255,0.1);
  border: 1px solid var(--sw-panel-edge);
  border-radius: 22px;
  transition: var(--transition);
}
.sw-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  left: 3px; top: 2px;
  border-radius: 50%;
  background: var(--sw-text-dim);
  transition: var(--transition);
}
.sw-toggle input:checked + .sw-slider { background: rgba(255, 215, 0, 0.25); border-color: var(--sw-gold); }
.sw-toggle input:checked + .sw-slider::before {
  transform: translateX(20px);
  background: var(--sw-gold);
  box-shadow: 0 0 8px var(--sw-gold);
}

/* ---- BOTTOM GRID ---- */
.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  padding: 0 1.5rem 1.5rem;
  max-width: 1600px;
  margin: 0 auto;
  position: relative;
  z-index: 5;
}

/* Log Table */
.panel-log { overflow: hidden; }
.log-table-wrap { overflow-x: auto; overflow-y: auto; max-height: 300px; flex: 1; }
.log-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.log-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(20, 4, 4, 0.95);
  padding: 10px 12px;
  font-family: var(--font-sw);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--sw-gold-dim);
  letter-spacing: 0.1em;
  text-align: left;
  border-bottom: 2px solid var(--sw-panel-edge);
  backdrop-filter: blur(8px);
}
.log-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  color: var(--sw-text);
  font-family: var(--font-body);
  font-size: 0.9rem;
  vertical-align: middle;
}
.log-row-red    td:first-child { border-left: 3px solid var(--sw-red); }
.log-row-yellow td:first-child { border-left: 3px solid var(--sw-yellow); }
.log-row-green  td:first-child { border-left: 3px solid var(--sw-green); }
.log-row:hover td { background: rgba(255, 215, 0, 0.08); }
.log-empty { text-align: center; color: var(--sw-text-dim); padding: 2.5rem !important; font-style: italic; }

.mode-badge {
  font-family: var(--font-sw);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.mode-simulation { background: rgba(79,195,247,0.15); border: 1px solid #4fc3f7; color: #4fc3f7; }
.mode-manual     { background: rgba(255, 215, 0, 0.15); border: 1px solid var(--sw-gold); color: var(--sw-gold); }

.color-dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}
.dot-red    { background: var(--sw-red);    box-shadow: 0 0 6px var(--sw-red); }
.dot-yellow { background: var(--sw-yellow); box-shadow: 0 0 6px var(--sw-yellow); }
.dot-green  { background: var(--sw-green);  box-shadow: 0 0 6px var(--sw-green); }

/* Chart */
.chart-wrap { padding: 1rem; flex: 1; display: flex; align-items: center; justify-content: center; min-height: 240px; }
#activity-chart { max-height: 280px; }

/* ---- Supabase Config Bar ---- */
.supabase-config-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 1.5rem;
  background: rgba(20, 4, 4, 0.8);
  border-top: 2px solid var(--sw-panel-edge);
  position: relative;
  z-index: 5;
  flex-wrap: wrap;
}
.supa-label {
  font-family: var(--font-sw);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--sw-green);
  white-space: nowrap;
}
.supa-input {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(0,255,135,0.3);
  color: var(--sw-green);
  border-radius: 5px;
  padding: 8px 12px;
  font-family: var(--font-sw);
  font-size: 0.85rem;
  font-weight: 600;
  outline: none;
  width: 240px;
  transition: var(--transition);
}
.supa-input:focus { border-color: var(--sw-green); box-shadow: var(--glow-green); }
.supa-status {
  font-family: var(--font-sw);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--sw-text-dim);
  margin-left: 12px;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 4, 4, 0.95);
  border: 2px solid var(--sw-gold);
  color: var(--sw-gold);
  font-family: var(--font-sw);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 12px 28px;
  border-radius: 8px;
  letter-spacing: 0.08em;
  box-shadow: var(--glow-gold), 0 10px 40px rgba(0,0,0,0.8);
  z-index: 9999;
  white-space: nowrap;
  animation: toastIn 0.3s ease;
}
.toast.hidden { display: none; }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(15px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ---- Modals ---- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(12px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 1;
  transition: opacity 0.3s ease;
}
.modal.hidden {
  opacity: 0;
  pointer-events: none;
}
.modal-content {
  background: rgba(20, 4, 4, 0.95);
  border: 2px solid var(--sw-gold);
  border-radius: 12px;
  box-shadow: 0 0 60px rgba(0,0,0,0.9), 0 0 30px rgba(255, 215, 0, 0.2);
  display: flex;
  flex-direction: column;
}

/* ---- Animations ---- */
@keyframes pulse-red {
  0%, 100% { box-shadow: var(--glow-red); }
  50%       { box-shadow: 0 0 40px #FF3333aa, 0 0 80px #FF333366; }
}
@keyframes pulse-green {
  0%, 100% { box-shadow: var(--glow-green); }
  50%       { box-shadow: 0 0 40px #00FF87aa, 0 0 80px #00FF8766; }
}
@keyframes pulse-yellow {
  0%, 100% { box-shadow: var(--glow-yellow); }
  50%       { box-shadow: 0 0 40px #FFB300aa, 0 0 80px #FFB30066; }
}
.light-bulb.red.active    { animation: pulse-red    2s ease-in-out infinite; }
.light-bulb.green.active  { animation: pulse-green  2s ease-in-out infinite; }
.light-bulb.yellow.active { animation: pulse-yellow 0.8s ease-in-out infinite; }

/* ===== SUPERIOR RESPONSIVE GRID ===== */
@media (max-width: 1200px) {
  .main-grid { grid-template-columns: 280px 1fr; grid-template-rows: auto auto; }
  .panel-right { grid-column: 1 / -1; }
}

@media (max-width: 950px) {
  .main-grid {
    grid-template-columns: 1fr; 
    grid-template-rows: auto auto auto;
  }
  .panel-center { grid-column: 1 / -1; order: -1; min-height: 400px; }
  .bottom-grid  { grid-template-columns: 1fr; }
}

@media (max-width: 650px) {
  .header-inner { height: auto; padding: 12px; flex-direction: column; align-items: stretch; gap: 12px; }
  .logo-block { justify-content: center; }
  .header-right { margin-left: 0; width: 100%; justify-content: center; }
  .esp32-config { flex-wrap: wrap; justify-content: center; }
  .logo-title { font-size: 1rem; }
  .supabase-config-bar { flex-direction: column; align-items: stretch; }
  .supa-input { width: 100%; }
  .bottom-grid { padding: 0 1rem 1rem; }
  .main-grid   { padding: 1rem; gap: 1rem; }
  .manual-light-btns { flex-direction: column; }
  .power-btns { flex-direction: column; }
  .sim-btns { flex-direction: column; }

  /* Increase touch targets on mobile */
  .btn-ctrl, .btn-power, .btn-light, .btn-apply { padding: 16px 12px; font-size: 1rem; }
  .mode-tab { padding: 12px 16px; font-size: 1rem; width: 100%; justify-content: center; }
  .mode-tabs { flex-direction: column; }
  
  .panel-log { min-width: 0; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: rgba(255,255,255,0.05); }
::-webkit-scrollbar-thumb { background: rgba(255, 215, 0, 0.4); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 215, 0, 0.6); }

/* Number input arrows */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { opacity: 1; filter: invert(1) brightness(0.7); }
