* {
  box-sizing: border-box;
}

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

body {
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1f2933;
  background: #f7faf8;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: #0f3d2e;
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 10000;
  border-radius: 0 0 4px 4px;
  text-decoration: none;
  font-weight: 600;
}

.skip-link:focus {
  top: 0;
}

.app-header {
  padding: 0.6rem 1.5rem;
  background: #0f3d2e;
  color: #ffffff;
  flex-shrink: 0;
}

.app-header h1 {
  margin: 0;
  font-size: 1.4rem;
}

.app-header__subtitle {
  margin: 0.2rem 0 0;
  opacity: 0.85;
  font-size: 0.85rem;
}

.app-layout {
  flex: 1;
  display: grid;
  grid-template-columns: 300px 1fr;
  overflow: hidden;
  position: relative;
}

.sidebar-toggle {
  display: none;
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 1000;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 4px;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  color: #1f2933;
  transition: background-color 0.15s ease;
}

.sidebar-toggle:hover {
  background: #f0f5f2;
}

.sidebar-overlay {
  display: none;
}

.sidebar {
  padding: 0;
  background: #ffffff;
  border-right: 1px solid #d9e2dd;
  overflow-y: auto;
  z-index: 900;
  transition: transform 0.25s ease;
}

.sidebar::-webkit-scrollbar {
  width: 6px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: #c5cec8;
  border-radius: 3px;
}

.sidebar__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #d9e2dd;
}

.sidebar__header h2 {
  margin: 0;
  color: #0f3d2e;
  font-size: 1.1rem;
}

.sidebar-close {
  display: none;
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #616e7c;
  padding: 0.2rem;
  line-height: 1;
  transition: color 0.15s ease;
}

.sidebar-close:hover {
  color: #1f2933;
}

.sidebar-section {
  border-bottom: 1px solid #e8ede9;
}

.sidebar-section summary {
  padding: 0.6rem 1rem;
  cursor: pointer;
  color: #0f3d2e;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background-color 0.15s ease;
  list-style: none;
}

.sidebar-section summary::-webkit-details-marker {
  display: none;
}

.sidebar-section summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.4rem;
  transition: transform 0.15s ease;
  font-size: 0.75rem;
}

.sidebar-section[open] summary::before {
  transform: rotate(90deg);
}

.sidebar-section summary:hover {
  background: #f0f5f2;
}

.sidebar-section p,
.sidebar-section ul {
  padding: 0 1rem;
  margin: 0.3rem 0 0.6rem;
  font-size: 0.85rem;
}

.sidebar-section .sidebar-hint {
  color: #616e7c;
  font-style: italic;
  font-size: 0.8rem;
}

.sidebar-section .variable-list {
  padding-left: 2rem;
  list-style-type: disc;
}

.variable-list li {
  padding: 0.15rem 0;
}

#map {
  width: 100%;
  height: 100%;
}

.layer-legend {
  padding: 0.3rem 1rem 0.6rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0;
  font-size: 0.85rem;
}

.legend-line {
  display: inline-block;
  width: 20px;
  height: 3px;
  border-radius: 1px;
  flex-shrink: 0;
}

.elevation-legend {
  padding: 0.3rem 1rem 0.6rem;
}

.elevation-gradient {
  height: 12px;
  border-radius: 3px;
  background: linear-gradient(to right,
    #228b22 0%,
    #90be32 15%,
    #dac320 30%,
    #e6782d 50%,
    #b43c1e 70%,
    #f0f0f0 100%
  );
}

.elevation-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: #616e7c;
  margin-top: 0.2rem;
}

.opacity-control {
  background: #fff;
  padding: 0.5rem 0.7rem;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  font-size: 0.8rem;
}

.opacity-control label {
  display: block;
  font-weight: 600;
  color: #0f3d2e;
  margin-bottom: 0.3rem;
  font-size: 0.75rem;
}

.opacity-slider {
  width: 100px;
  cursor: pointer;
  accent-color: #0f3d2e;
}

.popup-content {
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 0.85rem;
  line-height: 1.6;
}

.popup-content strong {
  font-size: 0.95rem;
  color: #0f3d2e;
}

.popup-label {
  color: #616e7c;
}

.coordinates-display {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  z-index: 800;
  background: rgba(255, 255, 255, 0.9);
  padding: 0.25rem 0.5rem;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.75rem;
  color: #3e4c59;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
  pointer-events: none;
}

.reset-view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: #fff;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  color: #333;
  transition: background-color 0.15s ease;
}

.reset-view-btn:hover {
  background: #f4f4f4;
}

@media (max-width: 800px) {
  .app-header {
    padding: 0.5rem 1rem;
  }

  .app-header h1 {
    font-size: 1.15rem;
  }

  .app-header__subtitle {
    display: none;
  }

  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    top: auto;
    bottom: 2rem;
    right: 0.6rem;
  }

  .sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: 280px;
    height: 100%;
    transform: translateX(-100%);
    box-shadow: none;
  }

  .sidebar.sidebar--open {
    transform: translateX(0);
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.15);
  }

  .sidebar-close {
    display: block;
  }

  .sidebar-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 899;
  }

  .sidebar-overlay.sidebar-overlay--visible {
    display: block;
  }

  .coordinates-display {
    display: none;
  }
}
