/* ==========================================================================
   Syria Interactive Vector Map — syria.gisarabia.org
   RTL Arabic, Light/Dark themes, calm cartographic harmony with GISarabia
   ========================================================================== */

:root,
:root[data-theme="light"] {
  --bg-surface: rgba(255, 255, 255, 0.94);
  --bg-surface-solid: #FFFFFF;
  --bg-subtle: #F4F4F0;
  --bg-hover: #EAEAE4;
  --text-primary: #111315;
  --text-secondary: #4B525C;
  --text-muted: #6C7480;
  --border: rgba(17, 19, 21, 0.14);
  --border-strong: rgba(17, 19, 21, 0.28);
  --accent: #18867B;
  --accent-bright: #23A094;
  --accent-soft: rgba(35, 160, 148, 0.13);
  --accent-ink: #FFFFFF;
  --gold: #FFC900;
  --gold-ink: #111315;
  --danger: #D13438;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 14px 36px rgba(0, 0, 0, 0.16);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-pill: 9999px;
  --font-ar: "Noto Kufi Arabic", -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

:root[data-theme="dark"] {
  --bg-surface: rgba(22, 24, 29, 0.92);
  --bg-surface-solid: #16181D;
  --bg-subtle: #20242C;
  --bg-hover: #2A303B;
  --text-primary: #F4F4F0;
  --text-secondary: #B8C0CC;
  --text-muted: #8B94A3;
  --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.24);
  --accent: #2EC4B6;
  --accent-bright: #36D6C7;
  --accent-soft: rgba(46, 196, 182, 0.16);
  --accent-ink: #0C1514;
  --gold: #FFC900;
  --gold-ink: #111315;
  --danger: #FF6B6B;
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 28px rgba(0, 0, 0, 0.48);
  --shadow-lg: 0 14px 40px rgba(0, 0, 0, 0.6);
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-ar);
  background: #E8ECEF;
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

:root[data-theme="dark"] body {
  background: #0F131A;
}

button, input {
  font-family: inherit;
}

.hidden {
  display: none !important;
}

.mobile-only {
  display: none !important;
}

/* ---------- Map Canvas ---------- */
#map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* MapLibre controls position & theme harmony */
.maplibregl-ctrl-bottom-right {
  bottom: 48px !important;
  right: 14px !important;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.maplibregl-ctrl-bottom-right .maplibregl-ctrl {
  margin: 0 !important;
}

.maplibregl-ctrl-group {
  background: var(--bg-surface) !important;
  backdrop-filter: blur(12px);
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-sm) !important;
  overflow: hidden;
}

.maplibregl-ctrl-group button {
  color: var(--text-primary) !important;
}

:root[data-theme="dark"] .maplibregl-ctrl-icon {
  filter: invert(0.92);
}

.maplibregl-ctrl-scale {
  background: var(--bg-surface) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-strong) !important;
  font-family: var(--font-mono);
  font-size: 11px;
  border-radius: 4px;
  padding: 1px 6px;
}

.maplibregl-ctrl-attrib {
  background: var(--bg-surface) !important;
  color: var(--text-muted) !important;
  font-size: 10.5px !important;
  border-radius: 6px !important;
}

.maplibregl-ctrl-attrib a {
  color: var(--accent) !important;
}

/* ---------- Top-Right: Brand & Search ---------- */
.floating-header {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(390px, calc(100vw - 28px));
  pointer-events: none;
}

.floating-header > * {
  pointer-events: auto;
}

.brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  align-self: flex-start;
  background: var(--bg-surface);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 6px 14px 6px 16px;
  box-shadow: var(--shadow-sm);
}

.brand-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--accent-bright);
  box-shadow: 0 0 0 3px var(--accent-soft);
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}

.brand-text h1 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Search Box */
.search-box {
  position: relative;
  width: 100%;
}

.search-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  height: 44px;
  box-shadow: var(--shadow-md);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow-md);
}

.icon-search {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

#searchInput {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  min-width: 0;
}

#searchInput::placeholder {
  color: var(--text-muted);
}

.icon-btn-sm {
  border: none;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 11px;
  transition: background 0.15s;
}

.icon-btn-sm:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  max-height: min(420px, 60vh);
  overflow-y: auto;
  background: var(--bg-surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
}

.search-section-title {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 6px 10px 4px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.search-item {
  width: 100%;
  border: none;
  background: transparent;
  text-align: right;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-primary);
  transition: background 0.12s;
}

.search-item:hover,
.search-item.active {
  background: var(--accent-soft);
}

.search-item-main {
  min-width: 0;
  flex: 1;
}

.search-item-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.search-item-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  flex-shrink: 0;
  margin-top: 2px;
}

.search-tag.adm1 { background: rgba(35, 160, 148, 0.16); color: var(--accent); }
.search-tag.adm2 { background: rgba(255, 201, 0, 0.25); color: #8A6A00; }
:root[data-theme="dark"] .search-tag.adm2 { color: #FFD84D; }
.search-tag.landmark { background: rgba(217, 119, 6, 0.16); color: #C25E00; }
:root[data-theme="dark"] .search-tag.landmark { color: #FDBA74; }

.search-empty {
  padding: 14px 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

/* ---------- Top-Left: Controls ---------- */
.floating-top-left {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.pill-group {
  display: inline-flex;
  background: var(--bg-surface);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px;
  box-shadow: var(--shadow-sm);
}

.pill-btn {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.15s ease;
}

.pill-btn:hover {
  color: var(--text-primary);
}

.pill-btn.active {
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.action-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 7px 13px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s ease;
}

.action-pill:hover {
  border-color: var(--accent);
}

.action-pill.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.action-pill svg {
  width: 15px;
  height: 15px;
}

.badge-dot {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.action-pill.active .badge-dot {
  background: rgba(255, 255, 255, 0.22);
  color: inherit;
}

/* ---------- Floating Panels (Layers & Inspector) ---------- */
.floating-panel {
  position: fixed;
  z-index: 25;
  background: var(--bg-surface);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: panelFade 0.18s ease-out;
}

@keyframes panelFade {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.layers-panel {
  top: 58px;
  left: 14px;
  width: min(280px, calc(100vw - 28px));
  max-height: calc(100vh - 120px);
}

.layers-panel .panel-header {
  padding: 9px 12px 7px;
}

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

.layers-panel .panel-body {
  padding: 8px 12px 10px;
  gap: 7px;
}

.layers-panel .panel-section {
  gap: 2px;
}

.layers-panel .panel-section + .panel-section {
  padding-top: 7px;
}

.layers-panel .panel-section h3 {
  font-size: 10.5px;
  margin-bottom: 2px;
}

.layers-panel .toggle-row {
  padding: 2px 4px;
  gap: 7px;
  font-size: 11.5px;
  line-height: 1.35;
}

.layers-panel .toggle-row input[type="checkbox"] {
  width: 13.5px;
  height: 13.5px;
}

.layers-panel .swatch {
  width: 10px;
  height: 10px;
}

.layers-panel .quick-layer-btn {
  padding: 5px 8px;
  font-size: 11px;
}

.layers-panel .chip-grid {
  gap: 4px;
}

.layers-panel .filter-chip {
  padding: 2.5px 8px;
  font-size: 10.5px;
}

.layers-panel .hint-text {
  font-size: 10.5px;
  line-height: 1.4;
}

.layers-panel .primary-btn,
.layers-panel .ghost-btn {
  padding: 6px 10px;
  font-size: 11px;
}

.inspector-panel {
  top: 136px;
  right: 14px;
  width: min(390px, calc(100vw - 28px));
  max-height: calc(100vh - 194px);
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.4;
}

.close-btn {
  border: none;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 12px;
  flex-shrink: 0;
  transition: background 0.15s;
}

.close-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.panel-body {
  padding: 12px 16px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

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

.quick-layer-btn {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-size: 11.5px;
  font-weight: 700;
  padding: 7px 10px;
  border-radius: 9px;
  cursor: pointer;
  transition: all 0.14s ease;
}

.quick-layer-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.quick-layer-btn.accent {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: transparent;
}

.quick-layer-btn.accent:hover {
  background: var(--accent);
  color: var(--accent-ink);
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-section + .panel-section {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.panel-section h3 {
  margin: 0;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 8px;
  transition: background 0.12s;
}

.toggle-row:hover {
  background: var(--bg-subtle);
}

.toggle-row input[type="checkbox"] {
  accent-color: var(--accent);
  width: 15px;
  height: 15px;
  cursor: pointer;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}

.swatch-adm1 { background: #18867B; border: 1.5px solid #0E5C54; }
.swatch-adm1-fill { background: linear-gradient(135deg, #23A094 50%, #F59E0B 50%); opacity: 0.7; }
.swatch-adm2 { background: #D97706; border: 1px dashed #92400E; }
.swatch-adm3 { background: #6366F1; opacity: 0.75; }
.swatch-mask { background: #94A3B8; opacity: 0.6; }
.swatch-villages-pts { background: #0EA5E9; border: 1.5px solid #FFFFFF; border-radius: 50%; }
.swatch-villages-poly { background: #F97316; opacity: 0.45; border: 1px solid #EA580C; }
.swatch-water { background: #0284C7; }
.swatch-roads { background: #E11D48; }
.swatch-places { background: #0284C7; }
.swatch-3d { background: #7C3AED; }
.swatch-landmarks { background: #FFC900; border: 1.5px solid #111; border-radius: 50%; }

/* Filter Chips */
.chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-chip {
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.14s;
}

.filter-chip:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.filter-chip.active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

/* Overpass Section */
.hint-text {
  margin: 0;
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--text-secondary);
}

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

.primary-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: none;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 700;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: filter 0.15s;
}

.primary-btn:hover {
  filter: brightness(1.06);
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.primary-btn svg {
  width: 15px;
  height: 15px;
}

.ghost-btn {
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.ghost-btn:hover {
  background: var(--bg-hover);
}

.status-note {
  font-size: 11.5px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--text-primary);
  line-height: 1.5;
}

/* ---------- Inspector Details ---------- */
.inspector-title-wrap {
  min-width: 0;
  flex: 1;
}

.type-badge {
  display: inline-block;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  margin-bottom: 5px;
}

.inspector-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
  direction: ltr;
  text-align: right;
}

.hierarchy-chain {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding: 8px 10px;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  font-size: 11.5px;
}

.hierarchy-crumb {
  border: none;
  background: transparent;
  color: var(--accent);
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 11.5px;
}

.hierarchy-crumb:hover {
  background: var(--accent-soft);
  text-decoration: underline;
}

.hierarchy-sep {
  color: var(--text-muted);
  font-size: 10px;
}

.inspector-desc {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--text-secondary);
}

.kv-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.kv-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 6px 10px;
  background: var(--bg-subtle);
  border-radius: 8px;
  font-size: 12px;
}

.kv-key {
  color: var(--text-muted);
  font-weight: 600;
  flex-shrink: 0;
}

.kv-val {
  color: var(--text-primary);
  font-weight: 600;
  text-align: left;
  word-break: break-word;
}

.kv-val.mono {
  font-family: var(--font-mono);
  font-size: 11.5px;
  direction: ltr;
}

.inspector-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.inspector-btn {
  flex: 1 1 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-size: 11.5px;
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.14s;
}

.inspector-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.inspector-btn.primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

.inspector-btn.primary:hover {
  filter: brightness(1.06);
  color: var(--accent-ink);
}

/* ---------- Bottom-Left: GIS Toolbar ---------- */
.gis-toolbar {
  position: fixed;
  bottom: 14px;
  left: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 4px;
  box-shadow: var(--shadow-md);
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.14s;
}

.tool-btn svg {
  width: 15px;
  height: 15px;
}

.tool-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.tool-btn.active {
  background: var(--gold);
  color: var(--gold-ink);
}

/* ---------- Measurement HUD ---------- */
.measure-hud {
  position: fixed;
  bottom: 64px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 26;
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-surface-solid);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius-pill);
  padding: 8px 14px 8px 16px;
  box-shadow: var(--shadow-lg);
}

.measure-info {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 12.5px;
}

.measure-info strong {
  color: var(--accent);
}

.measure-actions {
  display: flex;
  gap: 5px;
}

.mini-btn {
  border: 1px solid var(--border);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.mini-btn.accent {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

/* ---------- Bottom-Right: Coords & Status Bar ---------- */
.coords-bar {
  position: fixed;
  bottom: 14px;
  right: 14px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 5px 13px;
  font-size: 11px;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  user-select: none;
}

.coords-bar:hover {
  border-color: var(--accent);
}

#coordsText {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-primary);
}

.coords-sep {
  opacity: 0.35;
}

/* ---------- On-Map Measurement Badges ---------- */
.measure-seg-badge {
  background: #FFF9DB;
  color: #111315;
  border: 1.5px solid #111315;
  border-radius: 999px;
  padding: 2px 8px;
  font-family: var(--font-ar);
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

.measure-area-badge {
  background: rgba(14, 107, 98, 0.94);
  color: #FFFFFF;
  border: 2px solid #FFFFFF;
  border-radius: 12px;
  padding: 5px 11px;
  font-family: var(--font-ar);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

.measure-area-badge .ma-sub {
  display: block;
  font-size: 10.5px;
  font-weight: 500;
  opacity: 0.92;
}

/* ---------- Live Hover Tooltip ---------- */
.hover-tooltip {
  position: fixed;
  z-index: 30;
  pointer-events: none;
  background: var(--bg-surface-solid);
  color: var(--text-primary);
  border: 1.5px solid var(--accent);
  border-radius: 10px;
  padding: 5px 10px;
  font-size: 11.5px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
  transform: translate(-50%, calc(-100% - 14px));
}

.hover-tooltip .ht-level {
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}

.hover-tooltip .ht-parent {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-muted);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  background: #111315;
  color: #FFFFFF;
  font-size: 12.5px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-lg);
}

/* ---------- Loading Overlay ---------- */
.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(244, 244, 240, 0.85);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  transition: opacity 0.3s ease;
}

:root[data-theme="dark"] .loading-overlay {
  background: rgba(15, 19, 26, 0.88);
}

.loading-overlay.fade-out {
  opacity: 0;
  pointer-events: none;
}

.loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: var(--bg-surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 28px;
  box-shadow: var(--shadow-lg);
}

.loading-card p {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

/* Disable hover tooltip on touch-only devices */
@media (hover: none) {
  .hover-tooltip {
    display: none !important;
  }
}

/* ---------- Responsive (Mobile & Tablet <= 900px) ---------- */
@media (max-width: 900px) {
  .mobile-only {
    display: inline-flex !important;
  }

  .floating-header {
    top: 10px;
    right: 10px;
    left: 10px;
    width: auto;
    gap: 6px;
  }

  .brand-pill {
    padding: 4px 11px;
  }

  .brand-text h1 {
    font-size: 12.5px;
  }

  .brand-sub {
    display: none;
  }

  .search-input-wrap {
    height: 40px;
    padding: 0 10px;
  }

  #searchInput {
    font-size: 12.5px;
  }

  /* Compact scrollable pills bar directly under search on mobile */
  .floating-top-left {
    top: 96px;
    left: 10px;
    right: 10px;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    padding-bottom: 2px;
  }

  .floating-top-left::-webkit-scrollbar {
    display: none;
  }

  .pill-group {
    flex-shrink: 0;
  }

  .pill-btn {
    padding: 5px 10px;
    font-size: 11.5px;
  }

  .gis-toolbar {
    bottom: max(10px, env(safe-area-inset-bottom));
    left: 10px;
    right: 10px;
    justify-content: space-around;
    padding: 4px 6px;
  }

  .tool-btn {
    flex-direction: column;
    gap: 2px;
    padding: 5px 8px;
    font-size: 10px;
    border-radius: 12px;
  }

  .tool-btn svg {
    width: 16px;
    height: 16px;
  }

  .coords-bar {
    display: none;
  }

  /* Bottom Sheet Panels on Mobile */
  .layers-panel {
    display: none;
    top: auto;
    bottom: calc(64px + env(safe-area-inset-bottom));
    left: 10px;
    right: 10px;
    width: auto;
    max-height: 62vh;
  }

  .layers-panel.mobile-open {
    display: flex;
  }

  .inspector-panel {
    top: auto;
    bottom: calc(64px + env(safe-area-inset-bottom));
    left: 10px;
    right: 10px;
    width: auto;
    max-height: 40vh;
  }

  .measure-hud {
    bottom: calc(68px + env(safe-area-inset-bottom));
    left: 10px;
    right: 10px;
    transform: none;
    border-radius: 14px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 9px 12px;
  }

  .measure-info {
    justify-content: space-between;
    font-size: 11.5px;
  }

  .measure-actions {
    justify-content: flex-end;
  }

  .maplibregl-ctrl-bottom-left {
    bottom: calc(70px + env(safe-area-inset-bottom)) !important;
    left: 10px !important;
  }

  .maplibregl-ctrl-bottom-right {
    bottom: calc(66px + env(safe-area-inset-bottom)) !important;
    right: 10px !important;
  }
}
