:root {
  --bg: #16181d;
  --bg-panel: #1e2128;
  --bg-panel-alt: #262a33;
  --border: #313641;
  --text: #e7e9ee;
  --text-dim: #9aa2b1;
  --accent: #4f8ef7;
  --sidebar-width: 300px;
  --profile-height: 170px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  display: flex;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
}

/* Sidebar ---------------------------------------------------------------- */

#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
}

#sidebar-header {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border);
}

#sidebar-header h1 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.basemap-label {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-dim);
}

.basemap-label select {
  width: 100%;
  padding: 5px 8px;
  font-size: 13px;
  color: var(--text);
  background: var(--bg-panel-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  outline: none;
}

.basemap-label select:focus {
  border-color: var(--accent);
}

.global-stats {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-dim);
}

#track-list {
  list-style: none;
  margin: 0;
  padding: 6px;
  overflow-y: auto;
  flex: 1;
}

.track-item {
  padding: 7px 8px;
  margin-bottom: 3px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
}

.track-item:hover {
  background: var(--bg-panel-alt);
}

.track-item.selected {
  background: var(--bg-panel-alt);
  border-color: var(--accent);
}

.track-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.track-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.track-swatch {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25) inset;
}

.track-label {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-item.off .track-label,
.track-item.off .track-stats {
  opacity: 0.4;
}

.track-stats {
  margin-top: 2px;
  margin-left: 38px;
  font-size: 11.5px;
  color: var(--text-dim);
  line-height: 1.3;
}

.track-stats .stat {
  white-space: nowrap;
}

.track-stats .stat + .stat::before {
  content: "·";
  margin: 0 4px;
  color: var(--border);
}

.track-item-error {
  cursor: default;
  background: rgba(248, 113, 113, 0.08);
  border-color: rgba(248, 113, 113, 0.35);
}

.track-item-error:hover {
  background: rgba(248, 113, 113, 0.12);
}

.track-item-error .track-label {
  color: #f87171;
}

.track-error-msg {
  margin-top: 4px;
  font-size: 11.5px;
  line-height: 1.45;
  color: #fca5a5;
  word-break: break-word;
}

/* Main area -------------------------------------------------------------- */

#main {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

#map {
  flex: 1;
  min-height: 0;
  background: #0d0f13;
}

/* Elevation profile ------------------------------------------------------ */

.profile {
  height: var(--profile-height);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
}

.profile.hidden {
  display: none;
}

.profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  font-size: 12px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

#profile-title {
  font-weight: 600;
  color: var(--text);
}

#profile-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}

#profile-close:hover {
  color: var(--text);
}

#profile-body {
  flex: 1;
  min-height: 0;
  position: relative;
}

#profile-body svg {
  display: block;
  width: 100%;
  height: 100%;
}

.profile-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(13, 15, 19, 0.92);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 7px;
  font-size: 11.5px;
  color: var(--text);
  white-space: nowrap;
  transform: translate(-50%, -100%);
  opacity: 0;
  transition: opacity 0.08s;
}

.profile-tooltip.visible {
  opacity: 1;
}

/* Leaflet tweaks --------------------------------------------------------- */

.leaflet-container {
  font-family: inherit;
  background: #0d0f13;
}

.leaflet-control-attribution {
  background: rgba(22, 24, 29, 0.75) !important;
  color: var(--text-dim) !important;
  font-size: 10px !important;
}

.leaflet-control-attribution a {
  color: var(--accent) !important;
}
