:root {
  color-scheme: dark;
  --ag-bg: #03050e;
  --ag-panel: rgba(7, 11, 24, 0.92);
  --ag-panel-solid: #080d1b;
  --ag-ink: #eef4ff;
  --ag-muted: #9cadc9;
  --ag-faint: #7183a1;
  --ag-line: rgba(139, 165, 213, 0.24);
  --ag-line-strong: rgba(119, 231, 246, 0.48);
  --ag-cyan: #77e7f6;
  --ag-violet: #a88cff;
}

* {
  box-sizing: border-box;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
canvas:focus-visible {
  outline: 2px solid var(--ag-cyan);
  outline-offset: 3px;
}

.srOnly {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

#map {
  touch-action: none;
  background:
    radial-gradient(circle at 50% 45%, rgba(34, 46, 93, 0.13), transparent 43%),
    var(--ag-bg);
}

#panel {
  width: 374px;
  padding: 16px;
  border-color: var(--ag-line);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(9, 14, 31, 0.96), rgba(5, 8, 19, 0.91));
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(16px) saturate(1.15);
}

.panelTop {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto auto;
  gap: 10px;
  align-items: center;
}

.panelHome,
.panelToggle {
  display: grid;
  width: 32px;
  height: 32px;
  padding: 0;
  color: #c9d8ef;
  border: 1px solid var(--ag-line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.035);
  text-decoration: none;
  cursor: pointer;
  place-items: center;
}

.panelHome:hover,
.panelToggle:hover {
  color: #fff;
  border-color: var(--ag-line-strong);
  background: rgba(119, 231, 246, 0.08);
}

.panelIdentity {
  min-width: 0;
}

.panelKicker {
  display: block;
  margin-bottom: 2px;
  color: var(--ag-cyan);
  font-size: 8px;
  font-weight: 760;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

#panel h1 {
  overflow: hidden;
  margin: 0;
  font-size: 18px;
  font-weight: 720;
  line-height: 1.1;
  letter-spacing: 0.055em;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.mobileLayer,
.panelToggle {
  display: none;
}

#panelBody {
  padding-top: 12px;
}

#panel .sub {
  color: #a9b8d2;
  font-size: 11px;
  line-height: 1.48;
}

.layerMeta {
  margin-top: 8px;
  color: var(--ag-faint);
  font-size: 9px;
  letter-spacing: 0.05em;
}

#panel .layers {
  gap: 5px;
  margin: 12px 0 5px;
}

.layerButton,
.featureBrowserLayer,
.photoLayerButton {
  min-height: 30px;
  transition: border-color 140ms ease, color 140ms ease, background 140ms ease, transform 140ms ease;
}

.layerButton:hover,
.featureBrowserLayer:hover,
.photoLayerButton:hover {
  color: #edfaff;
  border-color: rgba(119, 231, 246, 0.38);
  transform: translateY(-1px);
}

.layerButton.active,
.featureBrowserLayer.active,
.photoLayerButton.active {
  border-color: var(--ag-cyan);
  background: rgba(51, 174, 194, 0.16);
  box-shadow: inset 0 0 22px rgba(58, 203, 232, 0.09);
}

.panelActions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 7px;
  margin-top: 9px;
}

#panel .browserLaunch,
.helpLaunch {
  width: 100%;
  min-height: 38px;
  margin: 0;
  padding: 8px 10px;
  color: #dffaff;
  border: 1px solid #48617f;
  border-radius: 9px;
  background: linear-gradient(90deg, #101c31, #102b35);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  cursor: pointer;
}

.helpLaunch {
  color: #b9c8de;
  background: rgba(255, 255, 255, 0.025);
}

#panel .browserLaunch:hover,
.helpLaunch:hover {
  color: white;
  border-color: var(--ag-cyan);
}

#panel input {
  min-height: 39px;
  margin-top: 8px;
  border-color: var(--ag-line);
  background: rgba(9, 15, 33, 0.86);
}

#panel input[aria-invalid="true"] {
  border-color: #ff7f9d;
  box-shadow: 0 0 0 2px rgba(255, 127, 157, 0.12);
}

#panel .hint {
  margin-top: 8px;
  color: #7187aa;
  font-size: 9px;
  line-height: 1.55;
}

#mapControls {
  position: fixed;
  z-index: 5;
  right: 18px;
  bottom: 17px;
  display: grid;
  grid-template-columns: 42px 48px 42px;
  gap: 5px;
  padding: 5px;
  border: 1px solid var(--ag-line);
  border-radius: 12px;
  background: rgba(6, 10, 23, 0.9);
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.42);
  backdrop-filter: blur(12px);
}

#mapControls button {
  min-width: 0;
  height: 36px;
  padding: 0;
  color: #c8d8ed;
  border: 1px solid transparent;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.035);
  font-size: 18px;
  cursor: pointer;
}

#mapControls #resetMap {
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#mapControls button:hover {
  color: #fff;
  border-color: rgba(119, 231, 246, 0.35);
  background: rgba(119, 231, 246, 0.08);
}

#status {
  right: 166px;
  bottom: 22px;
  max-width: min(480px, calc(100vw - 560px));
  overflow: hidden;
  color: #8fa3c2;
  border: 1px solid rgba(139, 165, 213, 0.12);
  background: rgba(5, 9, 21, 0.78);
  text-overflow: ellipsis;
  white-space: nowrap;
  backdrop-filter: blur(8px);
}

.mobileHint {
  display: none;
}

#toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: 78px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 10px 14px;
  color: #eaf6ff;
  border: 1px solid rgba(119, 231, 246, 0.38);
  border-radius: 10px;
  background: rgba(8, 17, 31, 0.96);
  box-shadow: 0 15px 45px rgba(0, 0, 0, 0.5);
  font-size: 12px;
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, 8px);
  transition: opacity 160ms ease, transform 160ms ease, visibility 160ms;
  pointer-events: none;
}

#toast.visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

#scrim {
  position: fixed;
  z-index: 6;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: rgba(1, 3, 9, 0.46);
  backdrop-filter: blur(1px);
  cursor: default;
}

#inspect {
  z-index: 7;
  border-color: rgba(139, 165, 213, 0.38);
  background: rgba(5, 9, 20, 0.95);
}

#tip {
  border-color: rgba(119, 231, 246, 0.3);
  background: rgba(6, 11, 24, 0.96);
  backdrop-filter: blur(10px);
}

#evidence,
#featureBrowser {
  border-color: rgba(139, 165, 213, 0.38);
  background: rgba(6, 10, 20, 0.985);
  box-shadow: 0 35px 120px rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(18px);
}

#evidence {
  z-index: 9;
  width: min(660px, 49vw);
  padding: 19px;
}

#featureBrowser {
  z-index: 10;
  width: min(600px, 49vw);
  padding: 19px;
}

.featureBrowserControls {
  grid-template-columns: minmax(180px, 1fr) minmax(205px, 220px);
}

#evidenceClose,
#featureBrowserClose,
#helpClose {
  transition: color 140ms ease, border-color 140ms ease, background 140ms ease, transform 140ms ease;
}

#evidenceClose:hover,
#featureBrowserClose:hover,
#helpClose:hover {
  color: #fff;
  border-color: var(--ag-cyan);
  background: rgba(119, 231, 246, 0.1);
  transform: rotate(4deg);
}

.evidenceQuickActions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: -2px 42px 14px 0;
}

.evidenceAction {
  display: inline-flex;
  min-height: 29px;
  padding: 0 9px;
  align-items: center;
  color: #c7d9ef;
  border: 1px solid #3e5272;
  border-radius: 7px;
  background: #0d1728;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.035em;
  text-decoration: none;
  text-transform: uppercase;
  cursor: pointer;
}

.evidenceAction:hover {
  color: #fff;
  border-color: var(--ag-cyan);
}

.evidenceCard,
.featureRow,
.photoFeatureButton,
.crossButton {
  transition: border-color 130ms ease, background 130ms ease, transform 130ms ease;
}

.evidenceCard:hover,
.featureRow:hover,
.photoFeatureButton:hover,
.crossButton:hover {
  transform: translateY(-1px);
}

.imageFailed {
  opacity: 0.35;
  filter: grayscale(1);
}

.featureRow:focus-visible,
.photoFeatureButton:focus-visible,
.crossButton:focus-visible,
.evidenceVisual:focus-visible {
  outline: 2px solid var(--ag-cyan);
  outline-offset: 1px;
}

#helpDialog {
  position: fixed;
  z-index: 12;
  top: 50%;
  left: 50%;
  width: min(760px, calc(100vw - 36px));
  max-height: min(760px, calc(100dvh - 36px));
  padding: clamp(24px, 4vw, 38px);
  overflow: auto;
  color: var(--ag-ink);
  border: 1px solid rgba(139, 165, 213, 0.4);
  border-radius: 20px;
  background:
    radial-gradient(circle at 90% 0, rgba(109, 91, 230, 0.17), transparent 22rem),
    #080d1b;
  box-shadow: 0 40px 140px rgba(0, 0, 0, 0.8);
  transform: translate(-50%, -50%);
}

#helpDialog[hidden] {
  display: none;
}

#helpClose {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 34px;
  height: 34px;
  color: #dce8fb;
  border: 1px solid #465979;
  border-radius: 50%;
  background: #10182a;
  font-size: 20px;
  cursor: pointer;
}

.helpKicker {
  margin: 0 0 7px;
  color: var(--ag-cyan);
  font-size: 10px;
  font-weight: 760;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

#helpDialog h2 {
  max-width: 600px;
  margin: 0 48px 28px 0;
  font-size: clamp(30px, 5vw, 46px);
  line-height: 1;
  letter-spacing: -0.045em;
}

.helpGrid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.helpGrid article {
  padding: 18px;
  border: 1px solid var(--ag-line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
}

.helpGrid article > span {
  color: var(--ag-cyan);
  font-size: 9px;
  font-weight: 760;
  letter-spacing: 0.08em;
}

.helpGrid h3 {
  margin: 20px 0 8px;
  font-size: 15px;
}

.helpGrid p {
  margin: 0;
  color: var(--ag-muted);
  font-size: 12px;
  line-height: 1.58;
}

.helpShortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--ag-line);
}

.helpShortcuts strong,
.helpShortcuts span {
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 9px;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.helpShortcuts strong {
  padding-left: 0;
  color: var(--ag-cyan);
}

.helpShortcuts span {
  color: #a9b9d2;
  background: rgba(255, 255, 255, 0.04);
}

@media (max-width: 1100px) {
  #evidence,
  #featureBrowser {
    left: 3vw;
    right: auto;
    top: 3dvh;
    bottom: 3dvh;
    width: 94vw;
  }

  #status {
    max-width: calc(100vw - 560px);
  }
}

@media (max-width: 850px) {
  #panel {
    top: max(12px, env(safe-area-inset-top));
    left: 12px;
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px - env(safe-area-inset-top));
    overflow: auto;
  }

  .mobileLayer,
  .panelToggle {
    display: grid;
  }

  .mobileLayer {
    min-width: 34px;
    height: 28px;
    align-items: center;
    justify-content: center;
    color: var(--ag-cyan);
    border: 1px solid rgba(119, 231, 246, 0.3);
    border-radius: 7px;
    background: rgba(119, 231, 246, 0.06);
    font-size: 10px;
    font-weight: 800;
  }

  body.panelCollapsed #panel {
    padding: 10px;
    overflow: hidden;
  }

  body.panelCollapsed #panelBody {
    display: none;
  }

  body.panelCollapsed .panelToggle span {
    transform: rotate(0deg);
  }

  #panel .layers {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  #mapControls {
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
  }

  #status {
    right: 12px;
    bottom: calc(66px + env(safe-area-inset-bottom));
    max-width: calc(100vw - 24px);
    font-size: 9px;
  }

  .mobileHint {
    position: fixed;
    z-index: 4;
    bottom: calc(24px + env(safe-area-inset-bottom));
    left: 12px;
    display: none;
    max-width: calc(100vw - 180px);
    padding: 9px 10px;
    color: #8395b2;
    border: 1px solid rgba(139, 165, 213, 0.12);
    border-radius: 8px;
    background: rgba(5, 9, 21, 0.74);
    font-size: 9px;
    backdrop-filter: blur(8px);
  }

  body.panelCollapsed .mobileHint {
    display: block;
  }

  #inspect {
    width: min(92vw, calc(100dvh - 110px));
  }
}

@media (max-width: 560px) {
  .featureBrowserControls {
    grid-template-columns: 1fr;
  }

  .panelActions {
    grid-template-columns: 1fr 108px;
  }

  #panel .hint {
    font-size: 8.5px;
  }

  #evidence,
  #featureBrowser {
    left: 10px;
    top: max(10px, env(safe-area-inset-top));
    bottom: max(10px, env(safe-area-inset-bottom));
    width: calc(100vw - 20px);
    padding: 17px;
    border-radius: 14px;
  }

  .evidenceQuickActions {
    margin-right: 38px;
  }

  #helpDialog {
    width: calc(100vw - 20px);
    max-height: calc(100dvh - 20px);
    padding: 24px 20px;
    border-radius: 16px;
  }

  .helpGrid {
    grid-template-columns: 1fr;
  }

  #toast {
    bottom: calc(75px + env(safe-area-inset-bottom));
  }
}

@media (max-height: 690px) and (min-width: 851px) {
  #panel .hint {
    display: none;
  }

  #panel {
    top: 12px;
  }
}

@media (hover: none) {
  #tip {
    display: none !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
