:root {
  color-scheme: light;
  --header-height: 68px;
  --navy-950: #09182b;
  --navy-900: #10243d;
  --navy-800: #173552;
  --blue-600: #1769aa;
  --blue-100: #e8f2fa;
  --green-600: #18885f;
  --ink: #172334;
  --muted: #667587;
  --border: #d9e1e8;
  --surface: rgba(255, 255, 255, 0.97);
  --shadow: 0 14px 36px rgba(13, 30, 51, 0.17);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #dfe8ee;
  color: var(--ink);
}

button,
input,
output {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible {
  outline: 3px solid rgba(23, 105, 170, 0.35);
  outline-offset: 2px;
}

.topbar {
  position: fixed;
  z-index: 1000;
  inset: 0 0 auto;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 24px;
  background: linear-gradient(105deg, var(--navy-950), var(--navy-900));
  color: #ffffff;
  box-shadow: 0 4px 20px rgba(8, 20, 36, 0.24);
}

.site-title {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
}


#siteTitle {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.header-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 13px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.82);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.header-button:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff;
}

.language-button.active {
  border-color: rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.13);
  color: #ffffff;
  font-weight: 700;
}

.language-button {
  min-width: 42px;
  padding-inline: 10px;
  letter-spacing: 0.04em;
}

.about-button {
  width: 40px;
  min-width: 40px;
  padding: 0;
  margin-left: 6px;
}

.about-button svg {
  width: 19px;
  height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.map-workspace {
  position: fixed;
  inset: var(--header-height) 0 0;
}

.map {
  position: absolute;
  inset: 0;
  background: #dce5eb;
}

.map-toolbar {
  position: absolute;
  z-index: 700;
  top: 18px;
  left: 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 7px;
  border: 1px solid rgba(195, 206, 216, 0.9);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
}

.map-tool-button {
  position: relative;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #29394b;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

.map-tool-button:hover {
  border-color: #cdd9e2;
  background: #f2f6f9;
  color: var(--blue-600);
}

.map-tool-button:active {
  transform: scale(0.96);
}

.map-tool-button.active {
  border-color: #a9c9df;
  background: var(--blue-100);
  color: var(--blue-600);
}

#areaMeasureButton.active {
  border-color: #afd5c6;
  background: #e8f5ef;
  color: var(--green-600);
}

.map-tool-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map-tool-button::after {
  content: attr(data-tooltip);
  position: absolute;
  z-index: 900;
  top: 50%;
  left: calc(100% + 12px);
  max-width: 220px;
  padding: 7px 10px;
  border-radius: 7px;
  background: rgba(9, 24, 43, 0.95);
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-4px, -50%);
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.map-tool-button:hover::after,
.map-tool-button:focus-visible::after {
  opacity: 1;
  transform: translate(0, -50%);
}

.toolbar-separator {
  width: 28px;
  height: 1px;
  margin: 2px auto;
  background: #dce4ea;
}

.layer-panel {
  position: absolute;
  z-index: 690;
  top: 18px;
  right: 18px;
  width: 224px;
  padding: 14px;
  border: 1px solid rgba(206, 216, 225, 0.95);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(9px);
}

.layer-panel-heading {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-bottom: 11px;
  border-bottom: 1px solid #e2e8ed;
  font-size: 14px;
}

.layer-panel-heading svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--blue-600);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}


.layer-list {
  display: grid;
  gap: 4px;
}

.layer-entry {
  position: relative;
  padding: 3px 5px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  transition: border-color 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.layer-entry:hover {
  border-color: #dbe4eb;
  background: #f7f9fb;
}

.layer-entry.is-dragging {
  z-index: 2;
  border-color: #8eb9d7;
  border-style: dashed;
  background: var(--blue-100);
  opacity: 0.78;
}

.layer-item {
  display: grid;
  grid-template-columns: 24px 18px 18px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  min-height: 40px;
  color: #33475b;
  font-size: 12px;
}

.layer-drag-handle {
  width: 24px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #8391a0;
  cursor: grab;
  touch-action: none;
}

.layer-drag-handle:hover,
.layer-drag-handle:focus-visible {
  background: #eaf0f4;
  color: var(--blue-600);
}

.layer-drag-handle:active,
.layer-entry.is-dragging .layer-drag-handle {
  cursor: grabbing;
}

.layer-drag-handle svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

body.layer-reordering,
body.layer-reordering * {
  cursor: grabbing !important;
  user-select: none !important;
}

.layer-item input[type="checkbox"] {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--blue-600);
}

.layer-item input:disabled,
.layer-opacity-slider:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.layer-swatch {
  width: 18px;
  height: 12px;
  border: 1px solid rgba(33, 50, 68, 0.16);
  border-radius: 3px;
}

.layer-swatch-map {
  background: linear-gradient(135deg, #dce8d4 0 32%, #f3e9ce 32% 64%, #cfe0ec 64%);
}

.layer-swatch-imagery {
  background: linear-gradient(135deg, #6d765f, #c3b79c 52%, #667f85);
}

.layer-details {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.layer-name-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 5px;
}

.layer-name-row label {
  min-width: 0;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.2;
  white-space: normal;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.layer-name-row output {
  flex: 0 0 auto;
  min-width: 31px;
  color: var(--muted);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.layer-opacity-slider {
  width: 100%;
  height: 15px;
  margin: 0;
  accent-color: var(--blue-600);
  cursor: pointer;
}

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

.measurement-panel {
  position: absolute;
  z-index: 690;
  top: 18px;
  left: 84px;
  width: min(330px, calc(100vw - 120px));
  padding: 17px;
  border: 1px solid rgba(206, 216, 225, 0.95);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(9px);
}

.measurement-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.measurement-heading > div {
  min-width: 0;
  display: block;
}

.dialog-kicker {
  color: var(--blue-600);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.measurement-heading strong {
  display: block;
  font-size: 18px;
  line-height: 1.35;
  white-space: nowrap;
}

.panel-close,
.dialog-close {
  border: 0;
  background: transparent;
  color: #667587;
  cursor: pointer;
}

.panel-close {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  font-size: 24px;
  line-height: 1;
}

.panel-close:hover {
  background: #edf2f6;
  color: #213244;
}

.measurement-instruction {
  margin: 15px 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.measurement-result {
  min-height: 54px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border: 1px solid #dfe7ed;
  border-radius: 9px;
  background: #f5f8fa;
  color: #172b40;
  font-size: 22px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}


.measurement-vertex-icon {
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  cursor: grab;
}

.measurement-vertex-icon:active,
.measurement-point-dragging .measurement-vertex-icon {
  cursor: grabbing;
}

.measurement-vertex {
  width: 14px;
  height: 14px;
  display: block;
  border: 2px solid #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 7px rgba(9, 24, 43, 0.42);
  transition: transform 0.14s ease, box-shadow 0.14s ease;
  pointer-events: none;
}

.measurement-vertex-distance {
  background: var(--blue-600);
}

.measurement-vertex-area {
  background: var(--green-600);
}

.measurement-vertex-icon:hover .measurement-vertex,
.measurement-vertex-icon:focus-visible .measurement-vertex {
  transform: scale(1.25);
  box-shadow: 0 3px 10px rgba(9, 24, 43, 0.5);
}

.measurement-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 12px;
}

.measurement-actions button,
.dialog-primary {
  min-height: 39px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
}

.primary-action,
.dialog-primary {
  border: 1px solid var(--blue-600);
  background: var(--blue-600);
  color: #ffffff;
}

.primary-action:hover,
.dialog-primary:hover {
  background: #115c97;
}

.secondary-action {
  border: 1px solid #d6e0e7;
  background: #ffffff;
  color: #33475b;
}

.secondary-action:hover {
  background: #f2f6f8;
}

.copyright-notice {
  position: absolute;
  z-index: 650;
  left: 16px;
  bottom: 16px;
  max-width: calc(100vw - 32px);
  padding: 6px 9px;
  border: 1px solid rgba(190, 202, 212, 0.72);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: 0 4px 14px rgba(16, 36, 61, 0.1);
  color: #526274;
  font-size: 10px;
  font-weight: 400;
  line-height: 1.3;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.map-status {
  position: absolute;
  z-index: 650;
  right: 16px;
  bottom: 16px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border: 1px solid rgba(190, 202, 212, 0.8);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: 0 4px 14px rgba(16, 36, 61, 0.12);
  color: #526274;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

.status-divider {
  width: 1px;
  height: 15px;
  background: #ccd7df;
}

.toast {
  position: absolute;
  z-index: 1200;
  left: 50%;
  bottom: 24px;
  max-width: min(430px, calc(100vw - 32px));
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(9, 24, 43, 0.95);
  box-shadow: var(--shadow);
  color: #ffffff;
  font-size: 13px;
  text-align: center;
  transform: translateX(-50%);
}

.about-dialog {
  width: min(760px, calc(100vw - 32px));
  max-height: calc(100vh - 40px);
  border: 0;
  border-radius: 15px;
  padding: 0;
  overflow: hidden;
  box-shadow: 0 28px 80px rgba(6, 18, 33, 0.3);
}

.about-dialog::backdrop {
  background: rgba(7, 20, 36, 0.58);
  backdrop-filter: blur(3px);
}

.about-dialog form {
  position: relative;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 52px 54px 38px;
}

.dialog-close {
  position: absolute;
  top: 15px;
  right: 17px;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  font-size: 26px;
}

.dialog-close:hover {
  background: #edf2f6;
}

.about-dialog h1 {
  margin: 0 48px 18px 0;
  font-size: clamp(23px, 4vw, 31px);
  line-height: 1.2;
}

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

.about-dialog p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.75;
}

.about-dialog .about-credit {
  margin-top: 4px;
  color: var(--navy-900);
  font-weight: 400;
}

.about-dialog .about-copyright {
  color: var(--muted);
  font-size: 13px;
  font-weight: 400;
}

.dialog-primary {
  min-width: 110px;
  margin-top: 24px;
  padding: 0 18px;
}

.leaflet-container {
  font: inherit;
}

.leaflet-control-attribution {
  border-radius: 5px 0 0 0;
  font-size: 10px;
}

/* Arabic text uses right-to-left alignment while the main page layout stays fixed. */
body.language-arabic #siteTitle,
body.language-arabic .about-dialog h1,
body.language-arabic .about-dialog p,
body.language-arabic .measurement-heading > div,
body.language-arabic .measurement-instruction,
body.language-arabic .measurement-result,
body.language-arabic .layer-panel-heading strong,
body.language-arabic .layer-name-row label {
  direction: rtl;
  text-align: right;
}

body.language-arabic .layer-item {
  grid-template-columns: minmax(0, 1fr) 18px 18px 24px;
}

body.language-arabic .layer-details {
  grid-column: 1;
}

body.language-arabic .layer-swatch {
  grid-column: 2;
}

body.language-arabic .layer-item input[type="checkbox"] {
  grid-column: 3;
}

body.language-arabic .layer-drag-handle {
  grid-column: 4;
}

body.language-arabic .layer-name-row {
  grid-template-columns: auto minmax(0, 1fr);
}

body.language-arabic .layer-name-row label {
  grid-column: 2;
}

body.language-arabic .layer-name-row output {
  grid-column: 1;
  grid-row: 1;
  text-align: left;
}

body.language-arabic .measurement-heading {
  flex-direction: row-reverse;
}

body.language-arabic .dialog-kicker {
  letter-spacing: 0;
  text-transform: none;
}

body.language-arabic .map-tool-button::after {
  direction: rtl;
}

@media (max-width: 720px), (max-height: 560px) and (pointer: coarse) {
  :root {
    --header-height: 62px;
  }

  .topbar {
    gap: 10px;
    padding: 0 12px;
  }

  .site-title {
    max-width: 48vw;
    font-size: 13px;
  }

  .header-actions {
    gap: 3px;
  }

  .header-button {
    min-height: 37px;
    padding: 0 8px;
    font-size: 12px;
  }

  .about-button {
    margin-left: 0;
  }

  .about-button svg {
    display: none;
  }

  .about-dialog form {
    padding: 48px 28px 30px;
  }

  .about-dialog h1 {
    margin-right: 42px;
  }

  .map-toolbar {
    top: 12px;
    left: 12px;
  }

  .layer-panel {
    top: 12px;
    right: 12px;
    width: 200px;
  }

  .measurement-panel {
    top: 12px;
    left: 74px;
    width: min(330px, calc(100vw - 306px));
  }

  .map-status {
    right: 10px;
    bottom: 10px;
  }

  .copyright-notice {
    left: 10px;
    bottom: 10px;
  }
}

@media (max-width: 460px) {
  .site-title {
    max-width: 34vw;
  }

  .header-button {
    padding: 0 6px;
    font-size: 11px;
  }

  .about-dialog {
    width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
  }

  .about-dialog form {
    max-height: calc(100vh - 20px);
    padding: 46px 20px 24px;
  }

  .about-dialog h1 {
    margin-right: 38px;
  }

  .layer-panel {
    top: auto;
    right: 10px;
    bottom: 48px;
    width: min(210px, calc(100vw - 20px));
    padding: 12px;
  }

  .measurement-panel {
    left: 67px;
    width: calc(100vw - 79px);
    padding: 14px;
  }

  .measurement-actions {
    grid-template-columns: 1fr;
  }

  .map-status {
    max-width: calc(100vw - 20px);
  }

  .copyright-notice {
    max-width: calc(100vw - 20px);
  }
}

@media (hover: none) {
  .map-tool-button::after {
    display: none;
  }
}

/* Responsive layer control and mobile map refinements. */
.layer-panel-heading {
  justify-content: space-between;
}

.layer-panel-title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
}

.layer-panel-close,
.layers-toggle-button,
.panel-backdrop {
  display: none;
}

.layer-panel-close {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #667587;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.layer-panel-close:hover {
  background: #edf2f6;
  color: #213244;
}

.layers-toggle-button {
  position: absolute;
  z-index: 730;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid rgba(195, 206, 216, 0.92);
  border-radius: 11px;
  background: var(--surface);
  box-shadow: var(--shadow);
  color: #29394b;
  font-weight: 750;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.layers-toggle-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: var(--blue-600);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.layers-toggle-button[aria-expanded="true"] {
  border-color: #a9c9df;
  background: var(--blue-100);
  color: var(--blue-600);
}

.panel-backdrop {
  position: absolute;
  z-index: 705;
  inset: 0;
  background: rgba(9, 24, 43, 0.18);
  backdrop-filter: blur(1px);
}

@media (max-width: 720px), (max-height: 560px) and (pointer: coarse) {
  .topbar {
    padding-right: max(12px, env(safe-area-inset-right));
    padding-left: max(12px, env(safe-area-inset-left));
  }

  .site-title {
    flex: 1 1 auto;
    max-width: none;
  }

  .header-actions {
    flex: 0 0 auto;
  }

  .map-toolbar {
    top: 10px;
    left: max(10px, env(safe-area-inset-left));
    gap: 4px;
    padding: 5px;
    border-radius: 11px;
  }

  .map-tool-button {
    width: 40px;
    height: 40px;
  }

  .toolbar-separator {
    width: 26px;
    margin: 1px auto;
  }

  .layers-toggle-button {
    top: 10px;
    right: max(10px, env(safe-area-inset-right));
    display: inline-flex;
  }

  .panel-backdrop:not([hidden]) {
    display: block;
  }

  .layer-panel {
    z-index: 740;
    top: auto;
    right: max(10px, env(safe-area-inset-right));
    bottom: max(10px, env(safe-area-inset-bottom));
    left: max(10px, env(safe-area-inset-left));
    width: auto;
    max-height: min(62vh, 420px);
    padding: 14px 15px 15px;
    overflow-y: auto;
    border-radius: 16px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(calc(100% + 24px));
    transition: transform 0.22s ease, opacity 0.18s ease;
  }

  .layer-panel::before {
    content: "";
    display: block;
    width: 42px;
    height: 4px;
    margin: -4px auto 10px;
    border-radius: 999px;
    background: #d3dde5;
  }


  .layer-entry {
    padding: 4px 6px;
  }

  .layer-drag-handle {
    width: 30px;
    height: 40px;
  }

  .layer-item {
    grid-template-columns: 30px 20px 18px minmax(0, 1fr);
    min-height: 44px;
  }

  .layer-opacity-slider {
    height: 18px;
  }

  .layer-panel.is-open {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }

  .layer-panel-close {
    display: grid;
    place-items: center;
  }

  .measurement-panel {
    top: 10px;
    right: max(10px, env(safe-area-inset-right));
    left: 62px;
    width: auto;
    max-height: calc(100% - 20px);
    padding: 14px;
    overflow-y: auto;
  }

  .measurement-instruction {
    margin: 11px 0 8px;
  }

  .measurement-result {
    min-height: 48px;
    font-size: 20px;
  }

  .measurement-actions {
    grid-template-columns: 1fr 1fr;
  }

  body.measurement-active .layers-toggle-button {
    display: none;
  }

  .map-status,
  .copyright-notice {
    bottom: max(28px, calc(env(safe-area-inset-bottom) + 22px));
    transition: opacity 0.15s ease, visibility 0.15s ease;
  }

  body.mobile-layer-panel-open .map-status,
  body.mobile-layer-panel-open .copyright-notice {
    visibility: hidden;
    opacity: 0;
  }

  .toast {
    bottom: max(66px, calc(env(safe-area-inset-bottom) + 58px));
  }

  .leaflet-control-attribution {
    max-width: 100%;
    overflow: hidden;
    font-size: 9px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@media (max-width: 460px) {
  .topbar {
    gap: 7px;
    padding-right: max(9px, env(safe-area-inset-right));
    padding-left: max(9px, env(safe-area-inset-left));
  }

  .site-title {
    max-width: none;
    font-size: 12px;
  }

  .header-actions {
    gap: 2px;
  }

  .header-button {
    min-height: 36px;
    padding: 0 6px;
    font-size: 11px;
  }

  .about-button {
    width: 36px;
    padding: 0;
  }

  .about-button svg {
    display: block;
    width: 18px;
    height: 18px;
  }

  .layers-toggle-button {
    min-width: 42px;
    width: 42px;
    padding: 0;
  }

  .layers-toggle-button span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .measurement-panel {
    left: 62px;
    width: auto;
  }

  .measurement-actions {
    grid-template-columns: 1fr 1fr;
  }

  .map-status {
    right: max(8px, env(safe-area-inset-right));
    left: auto;
    max-width: none;
  }

  #coordinateReadout,
  .status-divider {
    display: none;
  }

  .copyright-notice {
    right: auto;
    left: max(8px, env(safe-area-inset-left));
    max-width: calc(100vw - 102px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

body.language-arabic .layer-panel-heading {
  justify-content: flex-end;
}

body.language-arabic .layer-panel-title {
  flex-direction: row-reverse;
}

@media (max-width: 720px), (max-height: 560px) and (pointer: coarse) {
  body.language-arabic .layer-panel-heading {
    flex-direction: row-reverse;
    justify-content: space-between;
  }
}


@supports (height: 100dvh) {
  html,
  body {
    height: 100dvh;
  }
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  overscroll-behavior: none;
}

/* Keep the complete title visible without making the mobile banner taller. */
@media (max-width: 520px) and (orientation: portrait) {
  :root {
    --header-height: 48px;
  }

  .topbar {
    display: flex;
    align-items: center;
    gap: 5px;
    padding-top: 0;
    padding-right: max(7px, env(safe-area-inset-right));
    padding-bottom: 0;
    padding-left: max(7px, env(safe-area-inset-left));
  }

  .site-title {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    font-size: clamp(9.5px, 2.7vw, 10.5px);
    line-height: 1.02;
    letter-spacing: 0;
  }

  #siteTitle {
    display: -webkit-box;
    overflow: hidden;
    white-space: normal;
    text-wrap: balance;
    text-overflow: clip;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .header-actions {
    flex: 0 0 auto;
    width: auto;
    gap: 1px;
    justify-content: flex-end;
  }

  .header-button {
    min-height: 30px;
    padding-right: 4px;
    padding-left: 4px;
    border-radius: 7px;
    font-size: 10px;
  }

  .about-button {
    width: 30px;
    min-width: 30px;
  }
}

@media (max-width: 350px) and (orientation: portrait) {
  :root {
    --header-height: 46px;
  }

  .site-title {
    font-size: 9px;
  }

  .header-button {
    min-height: 28px;
    padding-right: 3px;
    padding-left: 3px;
    font-size: 9.5px;
  }

  .about-button {
    width: 28px;
    min-width: 28px;
  }
}

/* Preserve a compact single-row header when a phone is rotated. */
@media (max-height: 560px) and (orientation: landscape) and (pointer: coarse) {
  .site-title {
    font-size: clamp(10px, 1.8vw, 12px);
    letter-spacing: 0;
  }

  .header-button {
    padding-right: 6px;
    padding-left: 6px;
  }

  .about-button {
    width: 36px;
    padding: 0;
  }

  .about-button svg {
    display: block;
  }

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

/* Final compact mobile header sizing. */
@media (min-width: 521px) and (max-width: 720px) {
  :root {
    --header-height: 52px;
  }

  .header-button {
    min-height: 32px;
  }
}

@media (max-width: 340px) {
  .measurement-heading strong {
    white-space: normal;
  }
}

/* Compact single-line layer rows in Arabic mode. */
body.language-arabic .layer-entry {
  padding: 3px 5px;
}

body.language-arabic .layer-item {
  grid-template-columns: 28px 44px minmax(0, 1fr) 16px 15px 21px;
  grid-template-rows: 32px;
  gap: 4px;
  min-height: 32px;
}

body.language-arabic .layer-details,
body.language-arabic .layer-name-row {
  display: contents;
}

body.language-arabic .layer-name-row output {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
  align-self: center;
  font-size: 9.5px;
  line-height: 1;
  text-align: left;
  white-space: nowrap;
}

body.language-arabic .layer-opacity-slider {
  grid-column: 2;
  grid-row: 1;
  width: 44px;
  height: 14px;
  align-self: center;
}

body.language-arabic .layer-name-row label {
  grid-column: 3;
  grid-row: 1;
  align-self: center;
  overflow: visible;
  font-size: 10px;
  line-height: 1;
  text-align: right;
  white-space: nowrap;
  overflow-wrap: normal;
}

body.language-arabic .layer-swatch {
  grid-column: 4;
  grid-row: 1;
  width: 16px;
  height: 10px;
}

body.language-arabic .layer-item input[type="checkbox"] {
  grid-column: 5;
  grid-row: 1;
  width: 15px;
  height: 15px;
}

body.language-arabic .layer-drag-handle {
  grid-column: 6;
  grid-row: 1;
  width: 21px;
  height: 30px;
}

body.language-arabic .layer-drag-handle svg {
  width: 16px;
  height: 16px;
}

@media (min-width: 721px) and (min-height: 561px) {
  body.language-arabic .layer-panel {
    width: 240px;
  }
}

@media (max-width: 720px), (max-height: 560px) and (pointer: coarse) {
  body.language-arabic .layer-panel {
    width: auto;
  }

  body.language-arabic .layer-entry {
    padding: 3px 5px;
  }

  body.language-arabic .layer-item {
    grid-template-columns: 30px minmax(52px, 72px) minmax(0, 1fr) 18px 18px 26px;
    grid-template-rows: 34px;
    min-height: 34px;
    gap: 5px;
  }

  body.language-arabic .layer-opacity-slider {
    width: 100%;
    height: 15px;
  }

  body.language-arabic .layer-name-row label {
    font-size: 11px;
  }

  body.language-arabic .layer-drag-handle {
    width: 26px;
    height: 32px;
  }
}

/* One shared opacity control for the top layer only. */
.layer-item {
  grid-template-columns: 24px 18px 18px minmax(0, 1fr);
  min-height: 36px;
}

.layer-name {
  min-width: 0;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
}

.layer-entry.is-top-layer {
  border-color: #d7e4ed;
  background: #f6f9fb;
}

.top-layer-opacity-control {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 36px;
  align-items: center;
  gap: 7px;
  margin-top: 6px;
  padding: 8px 5px 1px;
  border-top: 1px solid #e2e8ed;
  color: var(--muted);
}

.top-layer-opacity-control label {
  font-size: 10.5px;
  font-weight: 650;
  white-space: nowrap;
}

.top-layer-opacity-control .layer-opacity-slider {
  grid-column: 2;
  width: 100%;
  height: 15px;
  margin: 0;
}

.top-layer-opacity-control output {
  min-width: 34px;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

/* Keep Arabic layer entries thin and on one line. */
body.language-arabic .layer-item {
  grid-template-columns: minmax(0, 1fr) 18px 18px 24px;
  grid-template-rows: 36px;
  gap: 7px;
  min-height: 36px;
}

body.language-arabic .layer-name {
  grid-column: 1;
  grid-row: 1;
  align-self: center;
  direction: rtl;
  text-align: right;
  font-size: 12.5px;
  white-space: nowrap;
}

body.language-arabic .layer-swatch {
  grid-column: 2;
  grid-row: 1;
}

body.language-arabic .layer-item input[type="checkbox"] {
  grid-column: 3;
  grid-row: 1;
}

body.language-arabic .layer-drag-handle {
  grid-column: 4;
  grid-row: 1;
  width: 24px;
  height: 34px;
}

body.language-arabic .top-layer-opacity-control {
  grid-template-columns: 36px minmax(0, 1fr) 52px;
}

body.language-arabic .top-layer-opacity-control label {
  grid-column: 3;
  direction: rtl;
  text-align: right;
}

body.language-arabic .top-layer-opacity-control .layer-opacity-slider {
  grid-column: 2;
  width: 100%;
  height: 15px;
}

body.language-arabic .top-layer-opacity-control output {
  grid-column: 1;
  text-align: left;
}

@media (max-width: 720px), (max-height: 560px) and (pointer: coarse) {
  .layer-item,
  body.language-arabic .layer-item {
    min-height: 38px;
    grid-template-rows: 38px;
  }

  .layer-name,
  body.language-arabic .layer-name {
    font-size: 13px;
  }
}

/* Keep the shared opacity control on one line in Arabic mode. */
body.language-arabic .top-layer-opacity-control {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  flex-wrap: nowrap;
  gap: 7px;
  width: 100%;
}

body.language-arabic .top-layer-opacity-control label {
  flex: 0 0 auto;
  margin: 0;
  direction: rtl;
  text-align: right;
  white-space: nowrap;
}

body.language-arabic .top-layer-opacity-control .layer-opacity-slider {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  margin: 0;
}

body.language-arabic .top-layer-opacity-control output {
  flex: 0 0 36px;
  min-width: 36px;
  margin: 0;
  direction: ltr;
  text-align: left;
  white-space: nowrap;
}

/* One shared slider controls the layer selected from its six-dot handle. */
.layer-item {
  grid-template-columns: 24px 18px 18px minmax(0, 1fr) 38px;
}

.layer-opacity-value {
  grid-column: 5;
  min-width: 36px;
  color: var(--muted);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  text-align: right;
  white-space: nowrap;
}

.layer-entry.is-opacity-selected {
  border-color: #b9d3e5;
  background: #f1f7fb;
}

.selected-layer-opacity-control {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 7px;
  margin-top: 6px;
  padding: 8px 5px 1px;
  border-top: 1px solid #e2e8ed;
  color: var(--muted);
}

.selected-layer-opacity-control label {
  font-size: 10.5px;
  font-weight: 650;
  white-space: nowrap;
}

.selected-layer-opacity-control .layer-opacity-slider {
  width: 100%;
  height: 15px;
  margin: 0;
}

.selected-layer-opacity-control output {
  min-width: 36px;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  text-align: right;
  white-space: nowrap;
}

/* Arabic: percentage at the far left, handle at the far right. */
body.language-arabic .layer-item {
  grid-template-columns: 38px minmax(0, 1fr) 18px 18px 24px;
  grid-template-rows: 36px;
}

body.language-arabic .layer-opacity-value {
  grid-column: 1;
  grid-row: 1;
  text-align: left;
}

body.language-arabic .layer-name {
  grid-column: 2;
  grid-row: 1;
}

body.language-arabic .layer-swatch {
  grid-column: 3;
  grid-row: 1;
}

body.language-arabic .layer-item input[type="checkbox"] {
  grid-column: 4;
  grid-row: 1;
}

body.language-arabic .layer-drag-handle {
  grid-column: 5;
  grid-row: 1;
}

body.language-arabic .selected-layer-opacity-control {
  grid-template-columns: 38px minmax(0, 1fr) 52px;
}

body.language-arabic .selected-layer-opacity-control output {
  grid-column: 1;
  grid-row: 1;
  text-align: left;
}

body.language-arabic .selected-layer-opacity-control .layer-opacity-slider {
  grid-column: 2;
  grid-row: 1;
}

body.language-arabic .selected-layer-opacity-control label {
  grid-column: 3;
  grid-row: 1;
  direction: rtl;
  text-align: right;
}

/* Preserve readable layer names after adding per-row percentage readouts. */
@media (min-width: 721px) and (min-height: 561px) {
  .layer-panel {
    width: 268px;
  }
}


/* Select opacity by clicking anywhere in a layer row; visibility is checkbox-only. */
.layer-item {
  cursor: pointer;
}

.layer-item:focus-visible {
  outline: 3px solid rgba(23, 105, 170, 0.28);
  outline-offset: 1px;
  border-radius: 8px;
}

.layer-item input[type="checkbox"] {
  cursor: pointer;
}

.layer-drag-handle {
  cursor: grab;
}

.layer-drag-handle:active,
.layer-entry.is-dragging .layer-drag-handle {
  cursor: grabbing;
}

/* Final opacity-row layout: keep the value, slider, and label aligned on one line. */
.selected-layer-opacity-control {
  display: grid;
  grid-template-columns: minmax(42px, auto) minmax(0, 1fr) minmax(52px, auto);
  align-items: center;
  column-gap: 12px;
  width: 100%;
}

.selected-layer-opacity-control > output {
  grid-column: 3;
  min-width: 42px;
}

.selected-layer-opacity-control > .layer-opacity-slider {
  grid-column: 2;
  display: block;
  inline-size: 100% !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
  margin: 0 !important;
}

.selected-layer-opacity-control > label {
  grid-column: 1;
  justify-self: start;
}

body.language-arabic .selected-layer-opacity-control {
  direction: ltr;
  grid-template-columns: minmax(42px, auto) minmax(0, 1fr) minmax(58px, auto);
}

body.language-arabic .selected-layer-opacity-control > output {
  grid-column: 1;
  grid-row: 1;
  justify-self: start;
  text-align: left;
  direction: ltr;
}

body.language-arabic .selected-layer-opacity-control > .layer-opacity-slider {
  grid-column: 2;
  grid-row: 1;
  inline-size: 100% !important;
  width: 100% !important;
  min-width: 0 !important;
}

body.language-arabic .selected-layer-opacity-control > label {
  grid-column: 3;
  grid-row: 1;
  justify-self: end;
  direction: rtl;
  text-align: right;
}

/* Give Arabic names and their per-layer percentages clear separation. */
body.language-arabic .layer-item {
  column-gap: 9px;
}

@media (min-width: 721px) and (min-height: 561px) {
  .layer-panel {
    width: 286px;
  }
}

/* Reserve a separate percentage column so it never crowds the layer name. */
.layer-item {
  grid-template-columns: 24px 18px 18px minmax(0, 1fr) 56px;
  column-gap: 10px;
}

.layer-opacity-value {
  box-sizing: border-box;
  width: 56px;
  min-width: 56px;
  padding-left: 10px;
  border-left: 1px solid #dfe7ed;
  text-align: right;
}

body.language-arabic .layer-item {
  grid-template-columns: 56px minmax(0, 1fr) 18px 18px 24px;
  column-gap: 10px;
}

body.language-arabic .layer-opacity-value {
  width: 56px;
  min-width: 56px;
  padding-right: 10px;
  padding-left: 0;
  border-right: 1px solid #dfe7ed;
  border-left: 0;
  text-align: left;
}

@media (min-width: 721px) and (min-height: 561px) {
  .layer-panel {
    width: 300px;
  }
}


/* Final safety rules: keep Arabic layer values and names in separate cells. */
.layer-panel,
.layer-list,
.layer-entry,
.layer-item {
  min-width: 0;
}

.layer-name {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layer-opacity-value {
  position: relative;
  z-index: 1;
  overflow: hidden;
  background: inherit;
}

body.language-arabic .layer-item {
  direction: ltr;
  grid-template-columns: 64px minmax(0, 1fr) 18px 18px 24px;
  column-gap: 11px;
}

body.language-arabic .layer-opacity-value {
  grid-column: 1;
  width: 64px;
  min-width: 64px;
  padding: 0 12px 0 0;
  border-right: 1px solid #dfe7ed;
  border-left: 0;
  direction: ltr;
  text-align: left;
}

body.language-arabic .layer-name {
  grid-column: 2;
  direction: rtl;
  text-align: right;
}

/* The app owns all touch gestures; Leaflet handles gestures inside the map. */
html,
body {
  touch-action: none;
}

.topbar,
.layer-panel,
.measurement-panel,
.about-dialog,
.map-toolbar,
.layers-toggle-button {
  touch-action: manipulation;
}

/* Final Arabic layer-row balance: preserve the complete name on one line. */
body.language-arabic .layer-item {
  grid-template-columns: 46px minmax(0, 1fr) 16px 16px 20px;
  column-gap: 7px;
}

body.language-arabic .layer-opacity-value {
  width: 46px;
  min-width: 46px;
  padding: 0 6px 0 0;
  font-size: 10px;
}

body.language-arabic .layer-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: clip;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1.2;
}

body.language-arabic .layer-swatch {
  width: 16px;
}

body.language-arabic .layer-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
}

body.language-arabic .layer-drag-handle {
  width: 20px;
  height: 34px;
}

body.language-arabic .layer-drag-handle svg {
  width: 16px;
  height: 16px;
}

@media (min-width: 721px) and (min-height: 561px) {
  .layer-panel {
    width: 316px;
  }
}

@media (max-width: 420px) {
  body.language-arabic .layer-item {
    grid-template-columns: 43px minmax(0, 1fr) 15px 15px 19px;
    column-gap: 6px;
  }

  body.language-arabic .layer-opacity-value {
    width: 43px;
    min-width: 43px;
    padding-right: 5px;
    font-size: 9.5px;
  }

  body.language-arabic .layer-name {
    font-size: 11.5px;
  }
}


/* Desktop layer-panel width adjustment. Drag the left edge; mobile stays full width. */
.layer-panel-resize-handle {
  position: absolute;
  z-index: 5;
  top: 56px;
  bottom: 12px;
  left: -9px;
  width: 18px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: ew-resize;
  touch-action: none;
}

.layer-panel-resize-handle::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 8px;
  width: 3px;
  height: 44px;
  border-radius: 999px;
  background: #c7d5df;
  opacity: 0.72;
  transform: translateY(-50%);
  transition: width 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.layer-panel-resize-handle:hover::before,
.layer-panel-resize-handle:focus-visible::before,
body.layer-panel-resizing .layer-panel-resize-handle::before {
  width: 4px;
  background: var(--blue-600);
  opacity: 1;
}

.layer-panel-resize-handle:focus-visible {
  outline: 3px solid rgba(23, 105, 170, 0.28);
  outline-offset: 1px;
  border-radius: 999px;
}

body.layer-panel-resizing,
body.layer-panel-resizing * {
  cursor: ew-resize !important;
  user-select: none !important;
}

@media (min-width: 721px) and (min-height: 561px) {
  .layer-panel {
    min-width: 260px;
    max-width: min(520px, calc(100vw - 36px));
  }
}

@media (max-width: 720px), (max-height: 560px) and (pointer: coarse) {
  .layer-panel-resize-handle {
    display: none;
  }
}

/* Refine the Arabic percentage cell and align the resize guide with the panel edge. */
body.language-arabic .layer-item {
  grid-template-columns: 38px minmax(0, 1fr) 16px 16px 20px;
  column-gap: 7px;
}

body.language-arabic .layer-opacity-value {
  width: 38px;
  min-width: 38px;
  padding-right: 3px;
  border-right-color: #d7e2ea;
}

.layer-panel-resize-handle {
  top: 14px;
  bottom: 14px;
  left: -10px;
  width: 20px;
}

.layer-panel-resize-handle::before {
  top: 0;
  bottom: 0;
  left: 9px;
  width: 2px;
  height: auto;
  border-radius: 999px;
  background: rgba(23, 105, 170, 0.34);
  opacity: 1;
  transform: none;
}

.layer-panel-resize-handle:hover::before,
.layer-panel-resize-handle:focus-visible::before,
body.layer-panel-resizing .layer-panel-resize-handle::before {
  width: 3px;
  background: rgba(23, 105, 170, 0.82);
}

@media (max-width: 420px) {
  body.language-arabic .layer-item {
    grid-template-columns: 36px minmax(0, 1fr) 15px 15px 19px;
    column-gap: 6px;
  }

  body.language-arabic .layer-opacity-value {
    width: 36px;
    min-width: 36px;
    padding-right: 2px;
  }
}

/* Keep the English percentage separator identical to the compact Arabic one. */
.layer-item {
  grid-template-columns: 24px 18px 18px minmax(0, 1fr) 38px;
  column-gap: 7px;
}

.layer-opacity-value {
  width: 38px;
  min-width: 38px;
  padding-left: 3px;
  border-left-color: #d7e2ea;
}

@media (max-width: 420px) {
  .layer-item {
    grid-template-columns: 24px 18px 18px minmax(0, 1fr) 36px;
    column-gap: 6px;
  }

  .layer-opacity-value {
    width: 36px;
    min-width: 36px;
    padding-left: 2px;
  }
}

/* Prevent Arabic glyphs and their descenders from being clipped in layer names. */
body.language-arabic .layer-name {
  padding-block: 3px;
  padding-inline: 2px;
  line-height: 1.45;
  overflow: hidden;
  text-overflow: clip;
}

/* Prevent English layer labels from being vertically clipped on mobile. */
@media (max-width: 720px), (max-height: 560px) and (pointer: coarse) {
  body:not(.language-arabic) .layer-name {
    align-self: center;
    padding-block: 3px;
    padding-inline: 2px;
    line-height: 1.45;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
