:root {
  --navy: #021135;
  --navy-2: #0c2348;
  --ink: #162033;
  --line: #d7deea;
  --paper: #f6f8fb;
  --accent: #1d6fe0;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Segoe UI", "Avenir Next Hebrew", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

body {
  min-height: 100%;
}

main {
  position: relative;
  height: 100%;
}

.top-tools {
  position: absolute;
  top: 14px;
  inset-inline-start: 14px;
  z-index: 40;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  max-width: calc(100% - 28px);
}

#panel-toggle {
  flex: 0 0 auto;
  height: 44px;
  border: 0;
  background: #fff;
  color: var(--navy);
  border-radius: 999px;
  padding: 0 16px;
  font: inherit;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(16, 32, 64, 0.22);
  cursor: pointer;
}

.place-box {
  position: relative;
  width: min(340px, 58vw);
}

#place-search {
  width: 100%;
  height: 44px;
  border: 0;
  border-radius: 999px;
  padding: 0 16px;
  background: #fff;
  box-shadow: 0 8px 24px rgba(16, 32, 64, 0.22);
  font: inherit;
  color: var(--ink);
}

#place-search:focus {
  outline: 2px solid #8ea4cc;
}

#map {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #e7edf4;
}

#panel {
  position: absolute;
  top: 70px;
  bottom: 12px;
  inset-inline-start: 12px;
  width: min(360px, calc(100% - 24px));
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(16, 32, 64, 0.16);
  display: none;
  flex-direction: column;
  overflow: auto;
  z-index: 30;
}

#panel.open {
  display: flex;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-close {
  display: inline-flex;
  border: 0;
  background: #eef2f8;
  color: var(--navy);
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  cursor: pointer;
}

.panel-head, .panel-block {
  padding: 14px 14px 8px;
}

.panel-head h2, .panel-block h3 {
  margin: 0 0 8px;
  font-size: 15px;
}

input[type="search"], select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  font: inherit;
  background: white;
}

#layer-list { padding: 0 10px 8px; }

.group { margin-bottom: 8px; }

.group > summary, .solo {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px;
  font-weight: 650;
  cursor: pointer;
}

.group > summary input {
  margin: 0;
}

.layer {
  display: grid;
  grid-template-columns: 18px 1fr;
  gap: 4px 8px;
  align-items: center;
  padding: 6px 8px;
  border-radius: 10px;
}

.layer:hover { background: #f3f6fb; }

.layer label { cursor: pointer; font-size: 14px; }

.layer input[type="range"] {
  grid-column: 2;
  width: 100%;
  accent-color: var(--accent);
}

.hidden { display: none; }

#legend:empty::before {
  content: "הדליקו שכבה כדי לראות את המקרא";
  color: #6b7690;
  font-size: 13px;
}

.swatch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  margin: 4px 0;
}

.swatch {
  width: 18px;
  height: 14px;
  border-radius: 3px;
  flex: 0 0 auto;
  border: 1px solid rgba(0, 0, 0, 0.25);
}

.legend-title {
  margin: 8px 0 4px;
  font-size: 13px;
  font-weight: 700;
}

.tools label {
  display: block;
  font-size: 12px;
  color: #445;
  margin-bottom: 10px;
}

#place-results {
  list-style: none;
  margin: 8px 0 0;
  padding: 6px;
  position: absolute;
  inset-inline: 0;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(16, 32, 64, 0.18);
  max-height: min(320px, 50vh);
  overflow: auto;
}

#place-results:empty { display: none; }

#place-results button {
  width: 100%;
  text-align: start;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 9px 10px;
  cursor: pointer;
  font: inherit;
  line-height: 1.35;
}

#place-results button:hover { background: #f3f6fb; }

.credit {
  margin: auto 0 0;
  padding: 12px 14px 14px;
  font-size: 11.5px;
  line-height: 1.45;
  color: #5c6880;
}

.name-label {
  background: transparent;
  border: 0;
  width: auto !important;
  height: auto !important;
  pointer-events: none;
}

.name-label span {
  pointer-events: auto;
  display: inline-block;
  transform: translate(-50%, -50%);
  background: transparent;
  border: 0;
  padding: 0;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 1px 0 0 #fff, -1px 0 0 #fff, 0 1px 0 #fff, 0 -1px 0 #fff;
}

.name-label.israeli span { color: #1a4f9c; }
.name-label.palestinian span { color: #9a3412; }

.leaflet-popup-content {
  direction: rtl;
  text-align: right;
  margin: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
}

.leaflet-popup-content h4 {
  margin: 0 0 6px;
  font-size: 14px;
}

.leaflet-popup-content table {
  border-collapse: collapse;
  width: 100%;
}

.leaflet-popup-content td {
  padding: 2px 0;
  vertical-align: top;
}

.leaflet-popup-content td:first-child {
  color: #5c6880;
  padding-left: 10px;
  white-space: nowrap;
}

.leaflet-container { font-family: inherit; }

.welcome {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(2, 17, 53, 0.45);
}

.welcome[hidden] { display: none; }

.welcome-card {
  width: min(420px, 100%);
  background: #fff;
  color: var(--ink);
  border-radius: 18px;
  padding: 22px 22px 18px;
  box-shadow: 0 18px 50px rgba(2, 17, 53, 0.28);
}

.welcome-card h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.welcome-card p {
  margin: 0;
  line-height: 1.55;
  font-size: 15px;
}

.welcome-card button {
  margin-top: 16px;
  border: 0;
  background: var(--navy);
  color: #fff;
  border-radius: 999px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

@media (max-width: 800px) {
  #panel.open {
    top: 70px;
    bottom: 8px;
    inset-inline: 8px;
    width: auto;
  }
}
