:root {
  --color-bg: #fafafa;
  --color-header: #fbfbfb;
  --color-card: #f6f6f6;
  --color-card-strong: #eeeeee;
  --color-text: #323232;
  --color-text-secondary: #5f636d;
  --color-muted: #70757f;
  --color-muted-2: #8b8f98;
  --color-accent: #0099cc;
  --color-accent-hover: #007fa8;
  --color-border: #e2e2e2;
  --color-focus: rgba(47, 125, 246, .2);
  color: var(--color-text);
  background: #8bb0ec;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 300px 1fr;
  overflow: hidden;
}

body.sidebar-collapsed { grid-template-columns: 0 1fr; }
body.feature-open.sidebar-collapsed { grid-template-columns: 300px 1fr; }
body.feature-open:not(.sidebar-collapsed) { grid-template-columns: 600px 1fr; }

button, input { font: inherit; }

button { color: inherit; }

button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.sidebar {
  min-width: 0;
  height: 100vh;
  display: flex;
  flex-direction: row;
  padding: 0;
  background: var(--color-header);
  border-right: 1px dashed var(--color-border);
  overflow: hidden;
  z-index: 2;
}

.sidebar-catalog {
  display: flex;
  width: 300px;
  flex: 0 0 300px;
  min-height: 100%;
  flex-direction: column;
  gap: 24px;
  padding: 28px 24px 20px;
  overflow-y: auto;
}

body.sidebar-collapsed .sidebar-catalog { display: none; }
body.feature-open:not(.sidebar-collapsed) .sidebar-catalog { border-right: 1px dashed var(--color-border); }

body.sidebar-collapsed:not(.feature-open) .sidebar {
  transform: translateX(-100%);
  visibility: hidden;
  pointer-events: none;
}

h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -.02em;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

h2 {
  margin: 0;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-heading button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--color-muted);
  cursor: pointer;
  font-size: 12px;
}

.layer-list { border-top: 1px solid var(--color-border); }

.place-search {
  position: relative;
  flex: 1;
}

.place-search input {
  width: 100%;
  height: 42px;
  padding: 0 42px 0 13px;
  border: 0;
  border: 1px solid var(--color-border);
  border-left: 0;
  border-radius: 0 8px 8px 0;
  outline: 0;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2370757f' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-4-4'/%3E%3C/svg%3E") no-repeat calc(100% - 13px) center;
  color: var(--color-text);
  box-shadow: none;
  font-size: 14px;
}

.place-search input::placeholder { color: var(--color-muted-2); }
.place-search input:focus,
.place-search input:focus-visible {
  border-color: #d3d3d3;
  outline: 0;
  box-shadow: none;
}

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 5;
  display: none;
  max-height: 290px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-header);
  box-shadow: none;
}

.search-results.open { display: block; }

.search-result {
  display: block;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  border-bottom: 1px solid #e8edef;
  background: transparent;
  color: #31464c;
  cursor: pointer;
  text-align: left;
}

.search-result:last-child { border-bottom: 0; }
.search-result:hover, .search-result.active { background: var(--color-card); }
.search-result strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.search-result span { display: block; margin-top: 2px; color: #7b898d; font-size: 10px; }
.search-empty { padding: 12px; color: #7b898d; font-size: 12px; }

.catalog-controls {
  display: grid;
  grid-template-columns: 1fr 92px;
  gap: 7px;
  margin-bottom: 12px;
}

.catalog-controls #layer-search { grid-column: 1 / -1; }

.catalog-controls input,
.catalog-controls select {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  outline: 0;
  background: #fff;
  color: var(--color-text);
  font-size: 12px;
}

.catalog-controls input:focus,
.catalog-controls select:focus { border-color: #579db7; box-shadow: 0 0 0 2px rgba(87, 157, 183, .12); }

.language-section h2 { margin-bottom: 12px; }

.language-section select {
  width: 100%;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: #fff;
  color: var(--color-text);
  font: inherit;
  font-size: 12px;
}

.layer-group {
  margin: 13px 0 4px;
  color: #8a989d;
  font-size: 10px;
  font-weight: 750;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.empty-layers {
  padding: 16px 0;
  color: #77817e;
  font-size: 12px;
}

.layer-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border-bottom: 1px solid #e5eaec;
  cursor: pointer;
  font-size: 14px;
}

.layer-row input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--color-accent);
}

.swatch {
  width: 8px;
  height: 8px;
  margin-left: auto;
  border: 1px solid rgba(45, 75, 84, .16);
  border-radius: 50%;
}

.loader {
  width: 12px;
  height: 12px;
  margin-left: auto;
  border: 2px solid rgba(52, 90, 103, .16);
  border-top-color: #4c96b1;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.drop-section h2 { margin-bottom: 12px; }

.drop-zone {
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 18px 12px;
  border: 1px dashed #9cbcc6;
  border-radius: 8px;
  color: #708188;
  cursor: pointer;
  font-size: 12px;
  text-align: center;
  transition: .2s ease;
}

.drop-zone strong { color: #31464c; font-size: 13px; }
.drop-zone.dragging { border-color: #4c96b1; background: #eef9fc; transform: scale(1.01); }
.drop-icon { color: #4c96b1; font-size: 24px; line-height: 1; }
#file-input { position: absolute; width: 1px; height: 1px; clip: rect(0 0 0 0); }
.custom-layers { margin-top: 10px; font-size: 12px; color: #687471; }

.map-shell {
  position: relative;
  height: 100vh;
  overflow: hidden;
  background: #8bb0ec;
}

#map {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

#map.interactive-hover { cursor: pointer; }
#map.dragging { cursor: grabbing; }

#viewport {
  transform-box: view-box;
  transform-origin: 0 0;
  will-change: transform;
}

.map-layer path, .map-layer circle {
  vector-effect: non-scaling-stroke;
  transition: opacity .15s ease;
}

.map-label {
  fill: #5f6a69;
  paint-order: stroke;
  stroke: rgba(255, 255, 255, .9);
  stroke-width: calc(2.5px * var(--inverse-scale, 1));
  stroke-linejoin: round;
  font-size: calc(var(--label-size, 10px) * var(--inverse-scale, 1));
  font-weight: 500;
  letter-spacing: calc(var(--label-spacing, 0px) * var(--inverse-scale, 1));
  pointer-events: none;
  text-anchor: middle;
}

.map-label.interactive {
  pointer-events: auto;
  cursor: pointer;
}

.map-label.interactive:hover,
.map-label.interactive:focus {
  fill: var(--color-accent-hover);
}

.feature-panel {
  position: relative;
  width: 300px;
  flex: 0 0 300px;
  height: 100%;
  overflow-y: auto;
  background: var(--color-header);
}

.feature-close {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 1;
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--color-border);
  border-radius: 50%;
  background: rgba(255, 255, 255, .94);
  color: var(--color-muted);
  cursor: pointer;
}

.feature-close svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2;
}

.feature-close:hover { background: var(--color-card-strong); color: var(--color-text); }

.feature-hero {
  position: relative;
  height: 190px;
  overflow: hidden;
  background: #fff;
}

.feature-image-attribution {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 1;
}

.feature-image-attribution > button {
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 50%;
  background: rgba(32, 36, 39, .48);
  color: rgba(255, 255, 255, .88);
  cursor: pointer;
  font: 600 13px/20px Georgia, serif;
}

.feature-image-credit {
  position: absolute;
  right: 36px;
  bottom: 30px;
  display: none;
  width: 220px;
  max-height: 120px;
  padding: 7px 8px;
  overflow-y: auto;
  border-radius: 5px;
  background: rgba(32, 36, 39, .76);
  color: rgba(255, 255, 255, .88);
  font-size: 10px;
  line-height: 1.35;
}

.feature-image-credit p { margin: 0 0 5px; }
.feature-image-credit p:last-child { margin-bottom: 0; }
.feature-image-credit a { color: inherit; }
.feature-image-attribution.open .feature-image-credit { display: block; }

.feature-hero.loading::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, #eeeeee 20%, #f7f7f7 40%, #eeeeee 60%);
  background-size: 200% 100%;
  animation: feature-skeleton 1.25s ease-in-out infinite;
}

@keyframes feature-skeleton {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

.feature-hero img {
  display: block;
  width: 100%;
  height: 190px;
  object-fit: cover;
}

@media (prefers-reduced-motion: reduce) {
  .feature-hero.loading::after { animation: none; }
}

.feature-body { padding: 24px; }
.feature-name { margin: 0; color: var(--color-text); font-size: 26px; font-weight: 600; letter-spacing: -.025em; text-transform: none; }
.feature-description { margin: 20px 0; color: var(--color-text-secondary); font-size: 14px; line-height: 1.55; }
.feature-metrics { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 14px 16px; margin: 0 0 20px; }
.feature-metrics[hidden] { display: none; }
.feature-metrics dt { color: var(--color-text-secondary); font-size: 11px; font-weight: 650; letter-spacing: .06em; text-transform: uppercase; }
.feature-metrics dd { margin: 3px 0 0; color: var(--color-text); font-size: 15px; font-variant-numeric: tabular-nums; }
.feature-links { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 16px; border-top: 1px solid var(--color-border); }
.feature-links a { padding: 8px 12px; border-radius: 8px; background: var(--color-card-strong); color: var(--color-accent-hover); font-size: 13px; text-decoration: none; }
.feature-links a:hover { text-decoration: underline; }

.label-country {
  fill: #3f4848;
  font-weight: 720;
}

.label-region {
  fill: #6c7775;
  font-weight: 620;
}

.label-city-major {
  fill: #303838;
  font-weight: 680;
}

.label-city { fill: #424c4b; }
.label-local { fill: #5f6968; }

.label-geographic {
  fill: #687b82;
  font-style: italic;
  font-weight: 480;
}

.point-marker {
  fill: none;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.map-toolbar {
  position: absolute;
  top: 18px;
  right: 18px;
  display: flex;
  z-index: 1;
  gap: 4px;
}

.map-search {
  position: absolute;
  top: 18px;
  left: 18px;
  z-index: 3;
  display: flex;
  width: min(440px, calc(100% - 190px));
}

.icon-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.map-search .menu-button {
  display: grid;
  flex: 0 0 48px;
  height: 42px;
  place-items: center;
  border: 0;
  border: 1px solid var(--color-border);
  border-right: 0;
  border-radius: 8px 0 0 8px;
  background: #fff;
  box-shadow: none;
  cursor: pointer;
}

.map-toolbar button {
  min-width: 38px;
  height: 38px;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 18px;
}

.map-toolbar .icon-button {
  display: grid;
  place-items: center;
}

.map-toolbar button:hover { background: var(--color-card-strong); }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.basemap-switcher {
  position: absolute;
  left: 18px;
  bottom: 18px;
  z-index: 2;
  display: flex;
  gap: 10px;
  margin: 0;
  padding: 12px;
  border: 0;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-header);
  box-shadow: none;
}

.basemap-switcher label {
  display: grid;
  width: 82px;
  gap: 6px;
  color: var(--color-muted);
  cursor: pointer;
  font-size: 11px;
  line-height: 1.15;
  text-align: center;
}

.basemap-switcher:not(.expanded) label:not(.selected) { display: none; }

.basemap-switcher input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.basemap-preview {
  width: 82px;
  height: 62px;
  border: 2px solid transparent;
  border-radius: 9px;
  background-position: center;
  background-size: cover;
  box-shadow: inset 0 0 0 1px rgba(42, 68, 76, .1);
}

.preview-vector {
  background:
    linear-gradient(135deg, transparent 46%, #8bb0ec 47% 54%, transparent 55%),
    linear-gradient(25deg, #d8edd2 0 45%, #f3efe5 46% 63%, #d8edd2 64%);
}

.preview-ne6-cross-blended { background-image: url('/rasters/NE6_HYP_HR_SR_OB_DR/0/0/0.jpg'); }
.preview-ne6-ne1 { background-image: url('/rasters/NE6_NE1_HR_SR_OB_DR/0/0/0.jpg'); }
.preview-blue-marble { background-image: url('/rasters/BMNG_TOPO_BATHY_200407/0/0/0.jpg?v=200407'); }

.basemap-switcher input:checked + .basemap-preview {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--color-accent);
}

.basemap-switcher label:hover .basemap-preview { filter: brightness(1.04); }

.location-accuracy {
  fill: rgba(33, 121, 219, .18);
  stroke: rgba(33, 121, 219, .35);
}

.location-dot {
  fill: #2179db;
  stroke: #fff;
}

.status, .coordinates {
  position: absolute;
  bottom: 18px;
  padding: 7px 10px;
  border-radius: 5px;
  background: rgba(255, 255, 255, .9);
  color: #63777e;
  box-shadow: 0 1px 5px rgba(45, 74, 85, .1);
  font-size: 11px;
  pointer-events: none;
}

.status { left: 18px; bottom: 132px; }
.status:empty { display: none; }
.coordinates { right: 18px; font-variant-numeric: tabular-nums; }
@media (max-width: 720px) {
  body, body.sidebar-collapsed { display: block; overflow: hidden; }
  .sidebar { position: absolute; inset: 0 auto 0 0; width: auto; max-width: calc(100vw - 54px); min-width: 0; height: 100vh; overflow-x: auto; }
  .sidebar-catalog, .feature-panel { width: min(300px, calc(100vw - 54px)); flex-basis: min(300px, calc(100vw - 54px)); }
  .sidebar-catalog { padding: 20px; }
  .map-shell { height: 100vh; min-height: 360px; }
  .map-search { width: calc(100% - 128px); }
  .map-toolbar { top: 76px; right: 12px; bottom: auto; flex-direction: column; }
  .map-toolbar button { border: 1px solid var(--color-border); }
  .basemap-switcher { right: 12px; left: 12px; bottom: 12px; gap: 8px; overflow-x: auto; }
  .basemap-switcher:not(.expanded) { right: auto; }
  .basemap-switcher label { width: 74px; }
  .basemap-preview { width: 74px; height: 54px; }
  .status { bottom: 122px; }
  .coordinates { bottom: 122px; }
}
