:root {
  --sidebar-width: 320px;
  --sidebar-min-width: 240px;
  --sidebar-max-width: 520px;
  --map-control-background: hsl(221deg 14% 12%);
  --map-control-background-hover: hsl(221deg 14% 18%);
  --map-control-border: hsl(221deg 14% 28%);
  --map-control-color: hsl(0deg 0% 96%);
  --map-control-muted: hsl(0deg 0% 71%);
}

html,
body {
  width: 100%;
  height: 100%;
  background: var(--bulma-body-background-color);
  overflow: hidden;
}

body.is-resizing-sidebar {
  cursor: col-resize;
  user-select: none;
}

.app-shell {
  display: flex;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

.app-sidebar {
  position: relative;
  z-index: 3;
  flex: 0 0 var(--sidebar-width);
  width: var(--sidebar-width);
  min-width: var(--sidebar-min-width);
  max-width: var(--sidebar-max-width);
  height: 100vh;
  background: var(--bulma-body-background-color);
  border-right: 1px solid var(--bulma-border);
  transition: flex-basis 140ms ease, min-width 140ms ease, width 140ms ease;
}

.app-sidebar.is-collapsed {
  flex-basis: 0;
  width: 0;
  min-width: 0;
  border-right: 0;
}

body.is-resizing-sidebar .app-sidebar {
  transition: none;
}

.sidebar-content {
  width: 100%;
  min-width: 0;
  height: 100%;
  overflow: auto;
}

.sidebar-menu {
  display: grid;
}

.sidebar-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--bulma-border);
}

.sidebar-header {
  padding-top: 18px;
  padding-bottom: 16px;
}

.sidebar-menu .menu-label {
  margin-bottom: 8px;
}

.sidebar-menu .menu-list a {
  display: flex;
  align-items: center;
  gap: 8px;
  border-radius: 0;
}

.sidebar-checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-sidebar.is-collapsed .sidebar-content,
.app-sidebar.is-collapsed .sidebar-resize-handle {
  display: none;
}

.sidebar-toggle {
  position: absolute;
  top: 16px;
  right: -16px;
  z-index: 4;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
}

.app-sidebar.is-collapsed .sidebar-toggle {
  right: -39px;
}

.sidebar-toggle-icon {
  transition: transform 140ms ease;
}

.app-sidebar.is-collapsed .sidebar-toggle-icon {
  transform: rotate(180deg);
}

.sidebar-resize-handle {
  position: absolute;
  top: 0;
  right: -4px;
  bottom: 0;
  z-index: 3;
  width: 8px;
  cursor: col-resize;
  touch-action: none;
}

.sidebar-resize-handle::after {
  position: absolute;
  top: 0;
  right: 3px;
  bottom: 0;
  width: 2px;
  background: transparent;
  content: "";
}

.sidebar-resize-handle:hover::after,
.sidebar-resize-handle:focus-visible::after,
body.is-resizing-sidebar .sidebar-resize-handle::after {
  background: var(--bulma-primary);
}

.map-area {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  height: 100vh;
}

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

.map-crosshair {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 1;
  width: 28px;
  height: 28px;
  pointer-events: none;
  color: var(--bulma-text-strong);
  filter: drop-shadow(0 0 2px var(--bulma-body-background-color));
  transform: translate(-50%, -50%);
}

.map-crosshair::before,
.map-crosshair::after {
  position: absolute;
  background: currentcolor;
  content: "";
}

.map-crosshair::before {
  top: 50%;
  left: 0;
  width: 100%;
  height: 1px;
  transform: translateY(-50%);
}

.map-crosshair::after {
  top: 0;
  left: 50%;
  width: 1px;
  height: 100%;
  transform: translateX(-50%);
}

.map-search-panel {
  display: grid;
  gap: 8px;
}

.map-lookup-results {
  position: absolute;
  right: 12px;
  bottom: 48px;
  z-index: 2;
  width: min(360px, calc(100% - 24px));
  display: block;
  text-align: right;
}

.map-search {
  margin-bottom: 0;
}

.map-search-dropdown {
  position: relative;
}

.map-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 6;
  display: grid;
  width: 100%;
  max-height: min(280px, 42vh);
  margin: 0;
  overflow: auto;
}

.map-search-results.box,
.map-lookup-results.box {
  background: var(--bulma-scheme-main);
  border: 1px solid var(--bulma-border);
  box-shadow: var(--bulma-shadow);
  color: var(--bulma-text);
}

.map-search-results[hidden],
.location-status[hidden] {
  display: none;
}

.map-search-result-button {
  height: auto;
  white-space: normal;
}

.map-search-result-label {
  min-width: 0;
  overflow-wrap: anywhere;
}

.map-search-result-distance {
  white-space: nowrap;
}

.location-control {
  position: absolute;
  top: 122px;
  right: 26px;
  z-index: 1;
  display: grid;
  justify-items: end;
  gap: 8px;
  max-width: min(280px, calc(100% - 32px));
}

.location-button {
  width: 28px;
  height: 28px;
  padding: 0;
}

.location-status {
  margin-bottom: 0;
  text-align: right;
}

.layer-control {
  display: grid;
  gap: 8px;
}

.layer-dropdown,
.layer-dropdown .dropdown-trigger,
.layer-dropdown .dropdown-menu {
  width: 100%;
}

.layer-dropdown .dropdown-content {
  max-height: min(320px, 48vh);
  overflow: auto;
}

.layer-toggle {
  justify-content: flex-start;
  height: auto;
  min-height: 48px;
  text-align: left;
  white-space: normal;
}

.layer-toggle-icon {
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
}

.layer-toggle-text {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.selected-layer {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-panel {
  padding-top: 4px;
}

.layer-option {
  display: flex;
  align-items: center;
  min-height: 40px;
  gap: 8px;
}

.coverage-filter-options {
  display: grid;
  gap: 8px;
}

.coverage-filter-option {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 8px;
}

.coverage-filter-option span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.cell-details-panel[hidden] {
  display: none;
}

.cell-details-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.cell-details-header .menu-label {
  margin-bottom: 0;
}

.cell-details-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cell-details-locate,
.cell-details-close {
  width: 28px;
  height: 28px;
  padding: 0;
}

.cell-details-content {
  display: grid;
  gap: 12px;
}

.cell-details-state {
  margin: 0;
}

.cell-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.cell-stat {
  padding: 8px;
  border: 1px solid var(--bulma-border);
  background: var(--bulma-scheme-main-bis);
}

.cell-stat-label {
  color: var(--bulma-text-weak);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.cell-stat-value {
  margin-top: 2px;
  color: var(--bulma-text-strong);
  font-size: 1.1rem;
  font-weight: 700;
}

.cell-histogram {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: end;
  min-height: 96px;
  gap: 6px;
}

.cell-histogram-bar {
  display: grid;
  align-content: end;
  min-height: 96px;
  gap: 4px;
}

.cell-histogram-fill {
  min-height: 3px;
  border-radius: 2px 2px 0 0;
}

.cell-histogram-label {
  color: var(--bulma-text-weak);
  font-size: 0.68rem;
  text-align: center;
}

.cell-sample-list {
  display: grid;
  gap: 6px;
}

.cell-sample {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
  padding: 8px;
  border: 1px solid var(--bulma-border);
  background: var(--bulma-scheme-main-bis);
}

.cell-sample-value {
  grid-row: span 2;
  align-self: center;
  font-weight: 700;
}

.cell-sample-meta,
.cell-sample-time {
  min-width: 0;
  color: var(--bulma-text-weak);
  font-size: 0.75rem;
  overflow-wrap: anywhere;
}

.maplibregl-ctrl-group,
.maplibregl-ctrl-scale {
  background: var(--map-control-background);
  border: 1px solid var(--map-control-border);
  box-shadow: var(--bulma-shadow);
  color: var(--map-control-color);
}

.maplibregl-ctrl-group button {
  background-color: var(--map-control-background);
  color: var(--map-control-color);
}

.maplibregl-ctrl-group button:hover {
  background-color: var(--map-control-background-hover);
}

.maplibregl-ctrl-group button + button {
  border-top-color: var(--map-control-border);
}

.maplibregl-ctrl-group button .maplibregl-ctrl-icon {
  filter: invert(1) brightness(1.7);
}

.maplibregl-ctrl-group button:disabled .maplibregl-ctrl-icon {
  filter: invert(1) brightness(0.75);
  opacity: 0.45;
}

.maplibregl-ctrl-attrib,
.maplibregl-ctrl-attrib.maplibregl-compact,
.maplibregl-ctrl-attrib.maplibregl-compact-show {
  background-color: hsl(221deg 14% 12% / 86%);
  color: var(--map-control-muted);
}

.maplibregl-ctrl-attrib a {
  color: var(--bulma-link-text);
}

.maplibregl-ctrl-attrib button,
.maplibregl-ctrl-attrib.maplibregl-compact button {
  background-color: var(--map-control-background);
  background-image: none;
  border: 1px solid var(--map-control-border);
  color: var(--map-control-color);
}

.maplibregl-ctrl-attrib button:hover,
.maplibregl-ctrl-attrib.maplibregl-compact button:hover {
  background-color: var(--map-control-background-hover);
}

.maplibregl-ctrl-attrib button::before,
.maplibregl-ctrl-attrib.maplibregl-compact button::before {
  display: grid;
  width: 100%;
  height: 100%;
  place-items: center;
  color: var(--map-control-color);
  content: "i";
  font: 700 14px/1 Arial, sans-serif;
}

.maplibregl-ctrl-scale {
  border-top: 0;
  border-right: 0;
  border-left: 0;
}

.maplibregl-ctrl-top-right {
  top: 16px;
  right: 16px;
}

@media (max-width: 520px) {
  :root {
    --sidebar-min-width: min(220px, calc(100vw - 64px));
    --sidebar-max-width: calc(100vw - 48px);
  }

}
