html, body {
  margin: 0; padding: 0; height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #222;
}

#map { position: absolute; inset: 0; }

#panel {
  position: absolute; top: 12px; left: 12px; z-index: 1;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 6px; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  padding: 12px 14px 10px; max-width: 270px; font-size: 13px; line-height: 1.35;
  max-height: calc(100vh - 24px); overflow-y: auto;
}

#panel h1 {
  font-size: 15px; margin: 0 0 4px; font-weight: 600; color: #1f3a5f; padding-right: 24px;
}
#panel .intro { margin: 0 0 10px; color: #555; font-size: 12px; }

#panel-toggle {
  position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; padding: 0;
  border: 1px solid #d0d4d9; background: #f6f7f8; border-radius: 4px; cursor: pointer;
  font-size: 15px; line-height: 1; color: #555; font-family: system-ui, sans-serif;
}
#panel-toggle:hover { background: #e8eaec; color: #1f3a5f; }

#panel.collapsed fieldset,
#panel.collapsed .attribution,
#panel.collapsed .intro { display: none; }
#panel.collapsed h1 { margin-bottom: 0; }

#panel fieldset { border: none; padding: 0; margin: 0 0 10px; }
#panel legend {
  font-weight: 600; font-size: 12px; color: #555; text-transform: uppercase;
  letter-spacing: 0.03em; margin-bottom: 4px;
}
#panel label { display: flex; align-items: center; gap: 6px; padding: 2px 0; cursor: pointer; user-select: none; }
#panel input[type="radio"], #panel input[type="checkbox"] { margin: 0; cursor: pointer; }

.legend-row { display: flex; align-items: center; gap: 6px; padding: 1px 0; font-size: 12px; color: #444; }
.swatch {
  display: inline-block; width: 12px; height: 12px; background: var(--c);
  border: 1px solid rgba(0, 0, 0, 0.25); border-radius: 2px; flex-shrink: 0;
}
.line-swatch {
  display: inline-block; width: 14px; height: 0; background: none;
  border-top: 3px solid var(--c); flex-shrink: 0;
}

/* Bulk-download + popup link lists */
.links { list-style: none; margin: 4px 0 0; padding: 0; }
.links li { padding: 2px 0; }
.links a { color: #2166ac; text-decoration: none; }
.links a:hover { text-decoration: underline; }
.links li.pending { color: #999; }
.sz { color: #888; font-size: 11px; }
.muted { color: #999; }

.bulk-group { margin-bottom: 8px; font-size: 12px; }
.bulk-group summary { cursor: pointer; font-weight: 600; color: #444; }
details.bulk-group ul { max-height: 200px; overflow-y: auto; }

#loading {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 2;
  background: rgba(255, 255, 255, 0.95); padding: 10px 18px; border-radius: 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15); font-size: 13px; color: #555;
  pointer-events: none; transition: opacity 0.3s ease;
}
#loading.hidden { opacity: 0; }
#loading::before {
  content: ''; display: inline-block; width: 10px; height: 10px; margin-right: 8px; vertical-align: -1px;
  border: 2px solid #c0c0c0; border-top-color: #1f3a5f; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.attribution {
  margin: 8px 0 0; padding-top: 8px; border-top: 1px solid #eee; font-size: 11px; color: #666;
}
.attribution a { color: #3b6e8f; }

/* Popups */
.maplibregl-popup-content { font-size: 13px; padding: 8px 12px; max-height: 320px; overflow-y: auto; }
.maplibregl-popup-content h3 {
  margin: 0 0 6px; font-size: 13px; color: #1f3a5f; border-bottom: 1px solid #eee; padding-bottom: 4px;
}
.maplibregl-popup-content h3 .huc { color: #999; font-weight: 400; font-size: 11px; }
.maplibregl-popup-content .forest {
  margin-top: 8px; padding-top: 6px; border-top: 1px solid #eee; font-size: 12px;
}
.maplibregl-popup-content .viz { margin-top: 8px; font-size: 12px; color: #555; }
.viewbtn {
  margin-left: 4px; padding: 2px 8px; border: 1px solid #c9c9c9; border-radius: 4px;
  background: #f6f7f8; color: #1f3a5f; font-size: 12px; cursor: pointer;
}
.viewbtn:hover { background: #e8eaec; border-color: #aab; }

/* Transient loading toast (e.g. while fetching an overlay) */
#toast {
  position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 3;
  background: rgba(31, 58, 95, 0.92); color: #fff; padding: 8px 16px; border-radius: 18px;
  font-size: 12px; box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  opacity: 0; pointer-events: none; transition: opacity 0.2s ease;
}
#toast.show { opacity: 1; }

@media (max-width: 600px) {
  #panel { max-width: calc(100vw - 24px); font-size: 12px; }
}

/* ---- Intro / about splash ---- */
.splash-overlay {
  position: absolute; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: rgba(20, 30, 40, 0.55); backdrop-filter: blur(2px);
  transition: opacity 0.25s ease;
}
.splash-overlay.hidden { opacity: 0; pointer-events: none; }
.splash-card {
  position: relative; background: #fff; border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  max-width: 540px; width: calc(100% - 32px); max-height: 85vh; overflow-y: auto;
  padding: 26px 30px 24px; font-size: 14px; line-height: 1.5; color: #2a2a2a;
}
.splash-card h2 {
  margin: 0 0 10px; font-size: 21px; color: #1f3a5f; font-weight: 700;
  padding-right: 28px;
}
.splash-card h3 {
  margin: 18px 0 4px; font-size: 14px; color: #1f3a5f;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.splash-card p { margin: 0 0 8px; }
.splash-lead { font-size: 15px; color: #333; }
.splash-pubs { margin: 4px 0 0; padding-left: 20px; }
.splash-pubs li { margin: 3px 0; }
.splash-pubs a { color: #2166ac; }
.splash-close {
  position: absolute; top: 12px; right: 14px; width: 28px; height: 28px; padding: 0;
  border: none; background: transparent; font-size: 24px; line-height: 1; color: #888;
  cursor: pointer; border-radius: 4px;
}
.splash-close:hover { color: #1f3a5f; background: #f0f1f3; }
.splash-enter {
  margin-top: 20px; padding: 9px 20px; border: none; border-radius: 6px;
  background: #1f3a5f; color: #fff; font-size: 14px; font-weight: 600; cursor: pointer;
}
.splash-enter:hover { background: #284b78; }
#about-link { color: #3b6e8f; cursor: pointer; }

@media (max-width: 600px) {
  .splash-card { padding: 20px 18px; font-size: 13px; }
  .splash-card h2 { font-size: 18px; }
}
