:root {
  --bg: #0b1220;
  --panel: #101a2f;
  --card: #121f3a;
  --text: #e8eefc;
  --muted: #a9b6d5;
  --accent: #6aa6ff;
  --accent2: #51d6c7;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.35);

  --danger: rgba(231, 111, 81, 0.95);
  --warn: rgba(255, 209, 102, 0.95);

  --radius-lg: 14px;
  --radius-md: 12px;
  --radius-sm: 10px;

  --focus: rgba(106, 166, 255, 0.9);
  --focus-shadow: rgba(106, 166, 255, 0.14);

  --space-1: 6px;
  --space-2: 10px;
  --space-3: 14px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
    "Apple Color Emoji", "Segoe UI Emoji";
  background: radial-gradient(1200px 800px at 20% 0%, #111d3a, var(--bg));
  color: var(--text);
  line-height: 1.35;
}

.noscript {
  margin: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 209, 102, 0.35);
  background: rgba(11, 18, 32, 0.55);
  color: var(--muted);
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 10px;
  z-index: 100;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(106, 166, 255, 0.95);
  color: #08101f;
  font-weight: 800;
  text-decoration: none;
}

.skip-link:focus {
  left: 10px;
  outline: 2px solid rgba(255, 255, 255, 0.65);
  outline-offset: 2px;
}

.cvg-global-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

/* Active state for the standardized /elevation navigation */
.cvg-global-nav a.cvg-pill[data-nav] {
  opacity: 0.95;
}

.cvg-global-nav[data-active="explorer"] a.cvg-pill[data-nav="explorer"],
.cvg-global-nav[data-active="use-cases"] a.cvg-pill[data-nav="use-cases"],
.cvg-global-nav[data-active="datum"] a.cvg-pill[data-nav="datum"],
.cvg-global-nav[data-active="resources"] a.cvg-pill[data-nav="resources"],
.cvg-global-nav[data-active="troubleshooting"] a.cvg-pill[data-nav="troubleshooting"] {
  background: rgba(106, 166, 255, 0.18);
  border-color: rgba(106, 166, 255, 0.55);
  color: var(--text);
  opacity: 1;
}

.cvg-global-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 16px;
}

.cvg-global-nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #ffffff;
  font-weight: 800;
}

.cvg-global-icon {
  font-size: 18px;
}

.cvg-global-nav-links {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.cvg-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  color: #ffffff;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.18);
  font-size: 13px;
  font-weight: 700;
}

.cvg-pill:hover {
  background: rgba(255, 255, 255, 0.25);
}

.app-header {
  position: sticky;
  top: 44px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(11, 18, 32, 0.82);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

/* Better sticky behavior on iOS/Safari */
@supports (padding: max(0px)) {
  .app-header {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  .cvg-global-nav-inner {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
}

.brand-title {
  font-weight: 800;
  letter-spacing: 0.2px;
}

.brand-subtitle {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}


.header-actions .btn {
  white-space: nowrap;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Make header actions wrap into a neat grid at smaller widths */
@media (max-width: 860px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .header-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .header-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 420px) {
  .header-actions {
    grid-template-columns: 1fr;
  }
}

.layout {
  display: grid;
  grid-template-columns: 1fr 420px;
  min-height: calc(100vh - 56px);
}

.app-footer {
  border-top: 1px solid var(--border);
  background: rgba(11, 18, 32, 0.82);
  backdrop-filter: blur(8px);
}

.footer-inner {
  padding: 12px 16px;
}

.map-panel {
  position: relative;
  padding: 12px;
}

.map-crosshair {
  position: absolute;
  left: 50%;
  top: calc(50% + 12px);
  width: 22px;
  height: 22px;
  margin-left: -11px;
  margin-top: -11px;
  pointer-events: none;
  opacity: 0.9;
}

.map-crosshair::before,
.map-crosshair::after {
  content: "";
  position: absolute;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: 0 0 0 2px rgba(11, 18, 32, 0.35);
}

.map-crosshair::before {
  left: 50%;
  top: 0;
  width: 2px;
  height: 22px;
  margin-left: -1px;
}

.map-crosshair::after {
  top: 50%;
  left: 0;
  height: 2px;
  width: 22px;
  margin-top: -1px;
}

.map-coords {
  position: absolute;
  right: 22px;
  bottom: 22px;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(16, 26, 47, 0.78);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
}

.map {
  height: calc(100vh - 86px);
  min-height: 560px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

/* Hide the always-on crosshair on touch devices to reduce visual noise */
@media (pointer: coarse) {
  .map-crosshair {
    display: none;
  }
}

.map-hint {
  position: absolute;
  left: 22px;
  bottom: 22px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(16, 26, 47, 0.78);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.legend-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chip-color {
  gap: 8px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.18);
}

.legend {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.legend-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
}

.legend-item:first-child {
  border-top: none;
}

.legend-label {
  font-size: 12px;
  color: var(--muted);
}

.legend-range {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.spark {
  margin-top: 10px;
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(11, 18, 32, 0.4);
}

.side-panel {
  padding: 12px 12px 24px;
  background: linear-gradient(180deg, rgba(16, 26, 47, 0.65), rgba(16, 26, 47, 0.25));
  border-left: 1px solid var(--border);
}

.card {
  background: rgba(18, 31, 58, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 12px 12px 14px;
  margin-bottom: 12px;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

.card h3 {
  margin: 8px 0 6px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

/* Dense lists used for educational/support content */
.dense-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

.dense-list li {
  margin: 6px 0;
}

/* API catalog list (copy/paste friendly) */
.api-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.api-list li {
  padding: 10px 10px;
  border-top: 1px solid var(--border);
  background: rgba(16, 26, 47, 0.25);
}

.api-list li:first-child {
  border-top: none;
}

.api-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
}

.api-url {
  margin-top: 6px;
}

.api-url code {
  display: block;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(11, 18, 32, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow-x: auto;
  white-space: nowrap;
  font-size: 12px;
  color: rgba(232, 238, 252, 0.92);
}

.callout {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(81, 214, 199, 0.25);
  background: rgba(11, 18, 32, 0.45);
}

.callout-title {
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 4px;
  color: rgba(81, 214, 199, 0.95);
}

/* Use case blocks (subpages) */
.use-case {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.small {
  font-size: 12px;
  color: var(--muted);
}

.search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.field {
  display: grid;
  gap: 6px;
}

.label {
  font-size: 12px;
  color: var(--muted);
}

.input {
  width: 100%;
  padding: 10px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(11, 18, 32, 0.6);
  color: var(--text);
  outline: none;
}

.input:focus {
  border-color: rgba(106, 166, 255, 0.65);
  box-shadow: 0 0 0 3px var(--focus-shadow);
}

.btn {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(11, 18, 32, 0.6);
  color: var(--text);
  cursor: pointer;
}

.btn:active {
  transform: translateY(1px);
}

.btn[disabled] {
  cursor: not-allowed;
  opacity: 0.65;
}

.btn:hover {
  border-color: rgba(106, 166, 255, 0.55);
}

.btn:focus-visible,
.input:focus-visible,
.cvg-pill:focus-visible,
a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Compact buttons should still have a comfortable hit target */
.btn.btn-compact {
  min-height: 36px;
}

/* Provider toggles and checkboxes: align + expand click target */
.toggle,
.provider-row {
  min-height: 36px;
}

/* Sections: reduce divider harshness */
hr {
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  margin: 12px 0;
}

.btn.primary {
  background: linear-gradient(135deg, rgba(106, 166, 255, 0.95), rgba(81, 214, 199, 0.72));
  border-color: rgba(255, 255, 255, 0.16);
  color: #08101f;
  font-weight: 700;
}

/* Reduce motion (accessibility) */
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
  .spinner {
    animation: none;
  }
  .btn:active {
    transform: none;
  }
}

.kv {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 6px 10px;
  align-items: start;
}

.k {
  color: var(--muted);
  font-size: 12px;
}

.v {
  font-size: 13px;
  word-break: break-word;
}

.elev {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.elev-value {
  font-size: 34px;
  font-weight: 800;
}

.elev-units {
  color: var(--muted);
}

.status {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.units-row {
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.loading {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(11, 18, 32, 0.55);
  color: var(--muted);
  font-size: 12px;
}

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-top-color: rgba(106, 166, 255, 0.9);
  animation: spin 0.9s linear infinite;
}

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

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-actions {
  display: flex;
  gap: 8px;
}

.history {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  max-height: 220px;
  overflow-y: auto;
}

.history-row {
  cursor: pointer;
}

.history-row:hover {
  background: rgba(106, 166, 255, 0.06);
}

.history-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
}

.history-row:first-child {
  border-top: none;
}

.history-main {
  display: grid;
  gap: 2px;
}

.history-title {
  font-size: 12px;
  font-weight: 800;
}

.history-sub {
  font-size: 12px;
  color: var(--muted);
}

.history-meta {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.btn-compact {
  padding: 8px 10px;
  font-size: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(11, 18, 32, 0.55);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.chip[data-status="ok"] {
  border-color: rgba(81, 214, 199, 0.55);
  color: rgba(81, 214, 199, 0.95);
}

.chip[data-status="check"] {
  border-color: rgba(255, 209, 102, 0.55);
  color: rgba(255, 209, 102, 0.95);
}

.chip[data-status="insufficient_data"],
.chip[data-status="unknown"] {
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--muted);
}

/* Confidence chip */
.chip[data-confidence="high"] {
  border-color: rgba(81, 214, 199, 0.55);
  color: rgba(81, 214, 199, 0.95);
}

.chip[data-confidence="medium"] {
  border-color: rgba(255, 209, 102, 0.55);
  color: rgba(255, 209, 102, 0.95);
}

.chip[data-confidence="low"] {
  border-color: rgba(231, 111, 81, 0.55);
  color: rgba(231, 111, 81, 0.95);
}

.chip[data-confidence="unknown"] {
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--muted);
}

/* Alert banner */
.alert {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(11, 18, 32, 0.55);
}

.alert-title {
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 4px;
}

.alert-body {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.alert[data-level="warn"] {
  border-color: rgba(255, 209, 102, 0.35);
}

.toggle-row {
  margin-top: 10px;
}

.toggle {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  user-select: none;
  font-size: 12px;
  color: var(--muted);
}

.sources {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.provider-controls {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  background: rgba(11, 18, 32, 0.35);
}

.provider-note {
  font-size: 12px;
  color: var(--muted);
}

.provider-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 10px;
}

.provider-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(16, 26, 47, 0.35);
}

.provider-row .provider-meta {
  font-size: 12px;
  color: var(--muted);
}

.provider-row .provider-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
}

.provider-row .provider-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.provider-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

.provider-cred {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin-top: 10px;
}

.provider-cred .input {
  padding: 9px 10px;
}

.source-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
}

.source-row:first-child {
  border-top: none;
}

.source-name {
  font-size: 12px;
  color: var(--muted);
}

.source-value {
  font-weight: 700;
}

.source-meta {
  grid-column: 1 / -1;
  font-size: 12px;
  color: var(--muted);
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 12px 0;
}

a {
  color: var(--accent);
}

.link-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13px;
}

.link-list li {
  margin: 6px 0;
}

@media (max-width: 1020px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .map {
    height: 56vh;
  }
  .side-panel {
    border-left: none;
    border-top: 1px solid var(--border);
  }

  .app-header {
    top: 0;
    position: sticky;
  }
}

@media (max-width: 560px) {
  .cvg-pill {
    padding: 7px 10px;
    font-size: 12px;
  }
  .kv {
    grid-template-columns: 120px 1fr;
  }
  .elev-value {
    font-size: 30px;
  }
}
