/* === Reset & Base === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg:          #0a0a0f;
  --sidebar-bg:  #12121a;
  --border:      #1a1a2e;
  --text:        #b0b0c0;
  --text-dim:    #606078;
  --accent:      #00d4aa;
  --accent-glow: rgba(0, 212, 170, 0.35);
  --sidebar-w:   260px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  overflow: hidden;
}

/* === Layout === */
#sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100%;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
  overflow-y: auto;
  z-index: 10;
}

#canvas-wrap {
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* === Sidebar === */
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.logo {
  font-size: 18px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 1px;
  margin-bottom: 0;
}

#btn-collapse {
  width: 28px;
  height: 28px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, border-color 0.15s;
  line-height: 1;
}

#btn-collapse:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* Collapsed sidebar on desktop */
body.sidebar-collapsed #sidebar {
  display: none;
}

body.sidebar-collapsed #canvas-wrap {
  margin-left: 0;
  width: 100%;
}

/* Expand button (hidden by default, shown when collapsed) */
#btn-expand {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 50;
  width: 28px;
  height: 28px;
  background: rgba(18, 18, 26, 0.7);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  line-height: 1;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: color 0.15s, border-color 0.15s;
}

#btn-expand:hover {
  color: var(--accent);
  border-color: var(--accent);
}

body.sidebar-collapsed #btn-expand {
  display: flex;
}

.sidebar-section {
  margin-bottom: 20px;
}

.sidebar-section h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin-bottom: 10px;
}

#sim-title {
  color: var(--accent);
  font-size: 13px;
}

.sim-desc {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 12px;
}

/* Simulation list */
#sim-list {
  list-style: none;
}

#sim-list li {
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.15s;
}

#sim-list li:hover {
  background: rgba(255, 255, 255, 0.04);
}

#sim-list li.active {
  background: rgba(0, 212, 170, 0.1);
  color: var(--accent);
}

/* Controls */
#controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control-group label {
  font-size: 11px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  display: flex;
  justify-content: space-between;
}

.control-group label span {
  color: var(--accent);
}

.control-group input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  outline: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}

/* Transport */
.transport {
  display: flex;
  flex-direction: row;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.transport button {
  flex: 1;
  padding: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.transport button:hover {
  background: rgba(0, 212, 170, 0.1);
  border-color: var(--accent);
  color: var(--accent);
}

/* Stats footer */
.sidebar-footer {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-dim);
}

/* === Mobile-only elements (hidden on desktop) === */
.mobile-only {
  display: none;
}

/* === Mobile === */
@media (max-width: 768px) {
  /* Show mobile-only elements */
  .mobile-only {
    display: flex;
  }

  /* Canvas takes full viewport */
  #canvas-wrap {
    margin-left: 0;
    width: 100%;
    height: 100%;
  }

  /* Sidebar hidden by default, fullscreen when open */
  #sidebar {
    display: none;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 100;
    padding: 20px 16px;
    overflow-y: auto;
  }

  body.sidebar-open #sidebar {
    display: flex;
  }

  /* Hamburger button */
  #btn-hamburger {
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 50;
    width: 44px;
    height: 44px;
    background: rgba(18, 18, 26, 0.7);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 22px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  #btn-hamburger:active {
    background: rgba(0, 212, 170, 0.2);
    color: var(--accent);
  }

  /* Hide hamburger when sidebar is open */
  body.sidebar-open #btn-hamburger {
    display: none;
  }

  /* Hide collapse/expand on mobile (use hamburger instead) */
  #btn-collapse,
  #btn-expand {
    display: none !important;
  }

  /* Show desktop transport in sidebar on mobile */
  .transport {
    display: flex !important;
  }

  /* Mobile transport bar */
  #mobile-transport {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    gap: 8px;
    background: rgba(18, 18, 26, 0.7);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 8px 12px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
  }

  #mobile-transport button {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 18px;
    cursor: pointer;
  }

  #mobile-transport button:active {
    background: rgba(0, 212, 170, 0.2);
    border-color: var(--accent);
    color: var(--accent);
  }

  /* Hide mobile transport when sidebar is open */
  body.sidebar-open #mobile-transport {
    display: none;
  }

}
