:root {
  --bg: #fff;
  --fg: #000;
  --sidebar-bg: #f0f0f0;
  --menu-bg: #eee;
  --canvas-bg: #fff;
  --grid-color: #ccc;
  --overlay-bg: rgba(0, 0, 0, 0.4);
  --button-bg: #ddd;
}

[data-theme="dark"] {
  --bg: #282c34;
  --fg: #fff;
  --sidebar-bg: #20232a;
  --menu-bg: #20232a;
  --canvas-bg: #000;
  --grid-color: #444;
  --overlay-bg: rgba(0, 0, 0, 0.6);
  --button-bg: #333;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  font-family: 'Trebuchet MS', sans-serif;
  background: var(--bg);
  color: var(--fg);
}

main {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

#canvasContainer {
  flex: 1;
  position: relative;
  overflow: hidden;
}

#plotCanvas {
  width: 100%;
  height: 100%;
  background: var(--canvas-bg);
  cursor: grab;
  touch-action: none;
}

#glCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#altLegend {
  position: absolute;
  bottom: 10px;
  left: 10px;
  display: none;
  align-items: center;
  font-size: 0.75rem;
  background: var(--sidebar-bg);
  color: var(--fg);
  padding: 2px 6px;
  border-radius: 4px;
}

#altLegend .gradient {
  width: 100px;
  height: 10px;
  margin: 0 6px;
  background: linear-gradient(to right, hsl(240,100%,50%) 0%, hsl(0,100%,50%) 100%);
  border: 1px solid var(--grid-color);
}

#menuToggle {
  position: fixed;
  top: 10px;
  right: 10px;
  left: auto;
  z-index: 30;
  background: var(--menu-bg);
  color: var(--fg);
  border: none;
  padding: 0.5rem;
  border-radius: 4px;
  font-size: 1.4rem;
  cursor: pointer;
  display: none;
  width: auto;
}

#backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--overlay-bg);
  z-index: 20;
}

#sidebar {
  width: 250px;
  background: var(--sidebar-bg);
  padding: 1rem;
  box-sizing: border-box;
  overflow-y: auto;
  z-index: 25;
  color: var(--fg);
}

#trackList {
  list-style: none;
  padding: 0;
  margin: 0 0 1rem 0;
}

#trackList li {
  margin-bottom: 0.5rem;
}

.swatch {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin: 0 0.25rem;
  vertical-align: middle;
}

#sidebar button,
#sidebar input[type="file"] {
  width: 100%;
  margin-top: 0.5rem;
  background: var(--button-bg);
  color: var(--fg);
  border: none;
  padding: 0.25rem 0.5rem;
}

#sidebar .legacyLink {
  margin-top: 0.75rem;
  font-size: 0.8rem;
}

#sidebar .legacyLink a {
  color: var(--fg);
}

#sidebar .infoBtn {
  width: auto;
  margin-left: 0.5rem;
  display: inline-block;
  padding: 0.1rem 0.3rem;
}

#trackInfo {
  max-height: 150px;
  overflow-y: auto;
  font-size: 0.8rem;
  margin-bottom: 1rem;
}
#trackInfo ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

#trackInfo li {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid var(--grid-color);
  padding: 0.1rem 0.2rem;
}

#trackInfo button {
  margin-top: 0.5rem;
  width: 100%;
}

.zoomControls {
  margin-top: 1rem;
}

@media (max-width: 600px) {
  #menuToggle {
    display: block;
  }
  #sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    right: 0;
    left: auto;
    width: 80vw;
    max-width: 300px;
    transform: translateX(100%);
    transition: transform 0.3s ease;
  }
  #sidebar.open {
    transform: translateX(0);
  }
  #backdrop.show {
    display: block;
  }
}
