html,
body {
  height: 100%;
  margin: 0;
  font-family: var(--pico-font-family-sans-serif);
  color: var(--pico-color);
  background: #eef3f0;
  overflow: hidden;
}

:root {
  --app-panel-background: rgba(255, 255, 255, 0.94);
  --app-panel-border: rgba(44, 62, 80, 0.16);
  --app-panel-shadow: 0 18px 44px rgba(32, 47, 61, 0.18);
  --app-muted: #60717f;
  --app-strong: #1f2f3d;
  --app-accent: #227c8d;
}

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

.loading-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 48px;
  padding: 4px 11px 4px 4px;
  border: 1px solid var(--app-panel-border);
  border-radius: 10px;
  background: var(--app-panel-background);
  box-shadow: 0 10px 26px rgba(32, 47, 61, 0.16);
  backdrop-filter: blur(12px) saturate(1.04);
  pointer-events: none;
  transform: translate(-50%, -50%);
  transition: opacity 120ms ease, visibility 120ms ease, transform 120ms ease;
}

.loading-indicator.is-hidden {
  opacity: 0;
  visibility: hidden;
  transform: translate(-50%, calc(-50% - 6px));
}

.loading-frog {
  display: block;
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.loading-message {
  color: var(--app-strong);
  font: 650 12px/1.2 var(--pico-font-family-sans-serif);
  white-space: nowrap;
}

body.rectangle-mode,
body.rectangle-mode #map,
body.rectangle-mode .maplibregl-map,
body.rectangle-mode .maplibregl-canvas-container,
body.rectangle-mode .maplibregl-canvas-container.maplibregl-interactive,
body.rectangle-mode .maplibregl-canvas {
  cursor: crosshair !important;
}

.maplibregl-ctrl button,
.maplibregl-ctrl button:hover,
.maplibregl-ctrl button:focus {
  width: 29px;
  height: 29px;
  min-width: 0;
  margin: 0;
  padding: 0;
  display: block;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: inherit;
  font: inherit;
  line-height: normal;
  outline: none;
  cursor: pointer;
}

.maplibregl-ctrl-group {
  border-radius: 4px;
  background: #fff;
}

.maplibregl-ctrl-group button + button {
  border-top: 1px solid #ddd;
}

.maplibregl-ctrl button .maplibregl-ctrl-icon {
  width: 100%;
  height: 100%;
  display: block;
  background-position: 50%;
  background-repeat: no-repeat;
}

.maplibregl-ctrl button:disabled {
  cursor: not-allowed;
}

.panel {
  position: absolute;
  width: min(276px, calc(100vw - 32px));
  background: var(--app-panel-background);
  border: 1px solid var(--app-panel-border);
  border-radius: 8px;
  box-shadow: var(--app-panel-shadow);
  backdrop-filter: blur(12px) saturate(1.04);
  padding: 10px 11px;
  z-index: 2;
  cursor: grab;
  touch-action: none;
  margin: 0;
}

.panel-controls {
  --cell-switch-column: 116px;
  top: 16px;
  left: 16px;
  width: auto;
  max-width: calc(100vw - 32px);
  padding: 3px 5px;
  cursor: auto;
  touch-action: auto;
  overflow: visible;
}

.panel-status {
  top: 510px;
  left: 16px;
}

.control-menu {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 100%;
}

.control-menu-item {
  position: relative;
  display: flex;
  flex: 0 0 auto;
}

.control-menu-button {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  height: 26px;
  min-height: 26px;
  margin: 0;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--app-strong);
  box-shadow: none;
  font: 650 12px/1 var(--pico-font-family-sans-serif);
  letter-spacing: 0;
  white-space: nowrap;
  cursor: pointer;
}

.control-menu-button:hover,
.control-menu-button:focus-visible,
.control-menu-button.is-active {
  border-color: rgba(34, 124, 141, 0.24);
  background: rgba(247, 251, 252, 0.98);
  color: var(--app-accent);
}

.control-menu-button:focus-visible {
  outline: 2px solid rgba(34, 124, 141, 0.28);
  outline-offset: 2px;
}

.control-menu-panel {
  position: absolute;
  box-sizing: border-box;
  top: calc(100% + 6px);
  left: 0;
  width: min(300px, calc(100vw - 32px));
  max-height: calc(100vh - 90px);
  overflow: auto;
  overscroll-behavior: contain;
  margin: 0;
  padding: 12px;
  border: 1px solid var(--app-panel-border);
  border-radius: 8px;
  background: var(--app-panel-background);
  box-shadow: var(--app-panel-shadow);
  backdrop-filter: blur(12px) saturate(1.04);
  cursor: auto;
  touch-action: auto;
  z-index: 4;
}

.control-menu-panel.is-hidden {
  display: none;
}

#area-control-panel {
  width: min(430px, calc(100vw - 32px));
}

.control-status-panel {
  width: min(380px, calc(100vw - 32px));
}

.control-menu-panel .control-group {
  padding: 0;
}

.panel.is-dragging {
  cursor: grabbing;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel h2,
.help-panel h2 {
  margin: 0 0 10px;
  line-height: 1.2;
  color: var(--app-muted);
  font-weight: 700;
}

.panel h2 {
  font-size: 14px;
}

.help-panel h2 {
  font-size: 13px;
}

.panel-header h2 {
  margin-bottom: 0;
}

.panel-toggle {
  position: relative;
  width: 24px;
  height: 24px;
  min-width: 24px;
  margin: 0;
  padding: 0;
  border: 1px solid rgba(44, 62, 80, 0.14);
  border-radius: 6px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(239, 244, 248, 0.94));
  color: transparent;
  font-size: 0;
  box-shadow: 0 2px 6px rgba(32, 47, 61, 0.08);
  cursor: pointer;
}

.panel-toggle::before,
.panel-toggle::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 8px;
  height: 2px;
  border-radius: 999px;
  background: #3d4f5e;
  transform: translate(-50%, -50%);
}

.panel-toggle::after {
  opacity: 0;
  transform: translate(-50%, -50%) rotate(90deg);
}

.panel-toggle[aria-label^="Restore"]::after {
  opacity: 1;
}

.panel-body {
  margin-top: 0;
}

.panel.is-minimized {
  width: 172px;
  padding: 8px 10px;
}

.panel.is-minimized .panel-body {
  display: none;
}

.control-stack {
  display: grid;
  gap: 0;
}

.control-group {
  display: grid;
  gap: 7px;
  padding: 2px 0;
}

.control-group + .control-group {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(44, 62, 80, 0.22);
}


.control-stack > label,
.cell-size-label,
.checkbox-row {
  font-size: 12px;
  font-weight: 650;
  color: var(--app-strong);
  margin: 0;
}

.control-heading,
.control-subheader {
  font-size: 12px;
  font-weight: 650;
  color: var(--app-strong);
  margin: 0;
}

.control-subsection {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid rgba(44, 62, 80, 0.16);
}

.control-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 22px;
}

.control-heading-row .checkbox-row {
  flex: 0 0 auto;
  justify-content: flex-end;
}

.checkbox-row {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 22px;
  cursor: pointer;
  user-select: none;
}

.control-section {
  display: grid;
  gap: 7px;
  padding-top: 2px;
}

.control-section h3 {
  margin: 0;
  font-size: 13px;
  line-height: 1.2;
  color: var(--app-strong);
  font-weight: 700;
}

.checkbox-row input[type="checkbox"][role="switch"] {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}

.switch-control {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: #c5cfdb;
  box-shadow: inset 0 0 0 1px rgba(44, 62, 80, 0.08);
  flex: 0 0 auto;
  overflow: hidden;
  transition: background-color 120ms ease;
}

.switch-control::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(32, 47, 61, 0.22);
  transition: transform 120ms ease;
}

.checkbox-row input[type="checkbox"][role="switch"]:checked + .switch-control {
  background: #1684b5;
}

.checkbox-row input[type="checkbox"][role="switch"]:checked + .switch-control::before {
  transform: translateX(14px);
}

.checkbox-row input[type="checkbox"][role="switch"]:focus-visible + .switch-control {
  outline: 2px solid rgba(34, 124, 141, 0.35);
  outline-offset: 2px;
}

.checkbox-row span:not(.switch-control) {
  cursor: pointer;
}

.cell-size-label {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  white-space: nowrap;
  font-family: var(--pico-font-family-sans-serif);
  font-size: 12px;
  font-weight: 650;
  line-height: 18px;
  letter-spacing: 0;
}

.cell-size-title {
  color: var(--app-strong);
  font: inherit;
  line-height: inherit;
  letter-spacing: 0;
}

.cell-size-meta {
  color: var(--app-muted);
  font: inherit;
  line-height: inherit;
  letter-spacing: 0;
}

.cell-size-heading-row,
.cell-size-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--cell-switch-column);
  align-items: center;
  gap: 12px;
}

.cell-size-heading-row .checkbox-row,
.cell-size-row .checkbox-row {
  justify-self: start;
  align-self: center;
}

.range-with-ticks {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.cell-size-ticks {
  display: grid;
  grid-template-columns: repeat(var(--tick-count, 6), minmax(0, 1fr));
  align-items: start;
  height: 6px;
  margin: -1px 6px 0;
  pointer-events: none;
}

.cell-size-ticks span {
  justify-self: center;
  width: 1px;
  height: 5px;
  border-radius: 999px;
  background: rgba(44, 62, 80, 0.28);
}

.cell-size-ticks span.is-active {
  width: 2px;
  height: 6px;
  background: var(--app-accent);
}

select {
  width: 100%;
  min-height: 34px;
  margin: 0;
  border: 1px solid rgba(44, 62, 80, 0.22);
  border-radius: 6px;
  background-color: #fff;
  color: var(--app-strong);
  font-size: 12px;
  line-height: 1.22;
  padding-top: 5px;
  padding-bottom: 5px;
  white-space: normal;
  text-overflow: clip;
}

option {
  white-space: normal;
  overflow-wrap: anywhere;
}

option.category-option {
  color: #17202a;
  font-weight: 650;
}

option.subcategory-option {
  color: #7a8792;
  font-weight: 450;
}

select,
input,
label {
  cursor: auto;
}

input[type="range"] {
  width: 100%;
  min-width: 0;
  margin: 0;
  accent-color: var(--app-accent);
}

.transparency-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
}

.layer-control-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  gap: 7px;
}

.layer-slider-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}

.layer-slider-stack label {
  font-size: 12px;
  font-weight: 650;
  color: var(--app-strong);
  margin: 0;
}

.layer-slider-stack.is-hidden {
  display: none;
}

.layer-slider-stack.is-disabled {
  opacity: 0.56;
}

.layer-slider-stack.is-disabled,
.layer-slider-stack.is-disabled label,
.layer-slider-stack.is-disabled input {
  cursor: not-allowed;
}

input[type="range"]:disabled {
  opacity: 0.56;
}

.stats {
  min-height: 156px;
  font-size: 12px;
  line-height: 1.45;
  color: #3d4f5e;
}

.status-grid {
  display: grid;
  gap: 7px;
}

.status-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 8px;
}

.status-row span {
  color: var(--app-muted);
  font-weight: 650;
}

.status-row strong {
  color: var(--app-strong);
  font-weight: 550;
}

.status-note {
  margin-top: 2px;
  color: #516574;
}

.rectangle-controls {
  display: block;
}

.rectangle-controls button,
.about-button,
.help-button,
.legal-button,
.donate-button,
.contacts-button,
.help-close {
  margin: 0;
  border: 1px solid rgba(44, 62, 80, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--app-strong);
  font: 650 12px/1 var(--pico-font-family-sans-serif);
  padding: 8px 10px;
  box-shadow: 0 8px 20px rgba(32, 47, 61, 0.12);
  cursor: pointer;
}

.contact-email-link,
.details-link {
  font-weight: 700;
}

.region-button {
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 32px;
  white-space: normal;
  text-align: center;
}

.region-button span {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.18;
}

.region-icon {
  width: 20px;
  height: 16px;
  opacity: 0.84;
  flex: 0 0 auto;
}

.rectangle-controls button:hover,
.about-button:hover,
.help-button:hover,
.legal-button:hover,
.donate-button:hover,
.contacts-button:hover,
.help-close:hover,
.panel-toggle:hover {
  border-color: rgba(34, 124, 141, 0.36);
  background: rgba(247, 251, 252, 0.98);
}

.utility-buttons {
  position: absolute;
  right: 14px;
  bottom: 38px;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
  max-width: calc(100vw - 28px);
}

.rectangle-controls button.is-active {
  border-color: var(--app-accent);
  background: var(--app-accent);
  color: #ffffff;
}

.rectangle-controls button:disabled {
  opacity: 0.46;
  cursor: not-allowed;
}

.help-button,
.about-button,
.legal-button,
.donate-button,
.contacts-button {
  color: #b84a3a;
}

.legal-button,
.donate-button,
.contacts-button {
  min-width: 34px;
  padding-inline: 10px;
}

.help-panel {
  position: absolute;
  right: 14px;
  bottom: 84px;
  width: min(360px, calc(100vw - 28px));
  max-height: min(520px, calc(100vh - 112px));
  overflow: auto;
  background: var(--app-panel-background);
  border: 1px solid var(--app-panel-border);
  border-radius: 8px;
  box-shadow: var(--app-panel-shadow);
  backdrop-filter: blur(12px) saturate(1.04);
  padding: 14px;
  z-index: 3;
  margin: 0;
}

.help-panel.is-hidden {
  display: none;
}

.help-panel p {
  margin: 0 0 10px;
  font-size: 12px;
  line-height: 1.45;
  color: #34495e;
}

.help-panel a {
  color: var(--app-accent);
}

.help-panel h3 {
  margin: 14px 0 7px;
  color: var(--app-strong);
  font-size: 12px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.vibe-badge {
  display: block;
  width: 75px;
  height: 75px;
  object-fit: contain;
}

.about-intro-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
}

.about-intro-row .help-summary {
  flex: 1 1 0;
  min-width: 0;
  max-width: none;
  margin-top: 0;
}

.about-badge {
  flex: 0 0 auto;
  margin: 0 0 10px auto;
}

.help-panel ul {
  margin: 0 0 10px;
  padding-left: 20px;
}

.help-panel li {
  margin-bottom: 5px;
  color: #34495e;
  font-size: 12px;
  line-height: 1.45;
}

.help-panel .help-summary,
.legal-panel .legal-summary,
.legal-panel .legal-warning {
  clear: both;
  margin-top: 8px;
  padding: 9px 10px;
  border-radius: 6px;
  background: rgba(34, 124, 141, 0.08);
}

.help-panel .about-intro-row .help-summary {
  clear: none;
  display: block;
  width: 100%;
  margin: 0 0 10px;
}

.legal-panel .legal-warning {
  border-left: 3px solid #b84a3a;
  background: rgba(184, 74, 58, 0.08);
}

.donate-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.donate-card {
  margin: 0;
  padding: 10px;
  border: 1px solid rgba(44, 62, 80, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.donate-card h3 {
  margin: 0 0 8px;
  text-transform: none;
  letter-spacing: 0;
  text-align: center;
}

.donate-note {
  margin-bottom: 8px;
  text-align: center;
}

.donate-qr {
  display: block;
  width: 144px;
  height: 144px;
  max-width: 100%;
  margin: 8px auto;
  border: 1px solid rgba(44, 62, 80, 0.16);
  border-radius: 6px;
  background: #fff;
  image-rendering: pixelated;
}

.donate-address {
  display: block;
  padding: 7px;
  border-radius: 6px;
  background: rgba(32, 47, 61, 0.06);
  color: var(--app-strong);
  font-size: 11px;
  line-height: 1.35;
  text-align: center;
  overflow-wrap: anywhere;
  white-space: normal;
}

.help-close {
  float: right;
  margin-bottom: 8px;
  padding: 7px 9px;
  box-shadow: none;
}

.selection-box {
  position: absolute;
  border: 2px solid rgba(23, 32, 42, 0.76);
  background: rgba(52, 152, 219, 0.12);
  pointer-events: none;
  z-index: 4;
}

.selection-box-close {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid rgba(23, 32, 42, 0.20);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(32, 47, 61, 0.18);
}

.selection-box-close::before,
.selection-box-close::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 2px;
  border-radius: 999px;
  background: var(--app-strong);
  transform-origin: center;
}

.selection-box-close::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.selection-box-close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.maplibregl-popup-content {
  max-width: 280px;
  font: 12px/1.4 var(--pico-font-family-sans-serif);
}

.poi-name-popup .maplibregl-popup-content {
  padding: 7px 9px;
  border-radius: 6px;
  box-shadow: 0 6px 18px rgba(32, 47, 61, 0.18);
}

.poi-popup-title {
  max-width: 190px;
  color: var(--app-strong);
  font-size: 12px;
  font-weight: 650;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

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

@media (max-width: 640px) {
  .panel {
    top: 10px;
    left: 10px;
    width: calc(100vw - 20px);
    padding: 10px;
  }


  .panel-status {
    top: 536px;
  }

  .help-panel {
    bottom: 118px;
  }

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