html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: Arial, Helvetica, sans-serif;
  overflow: hidden;
}

body {
  position: relative;
}

#map {
  width: 100%;
  height: 100dvh;
  min-height: 100dvh;
  background: #f5f5f5;
}

.constituency-label {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #ccc;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  color: #111;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
}

.leaflet-tooltip-top:before,
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
  display: none;
}

.info.legend {
  width: max-content;          /* as wide as its longest row; the note wraps to that width */
  max-width: calc(100vw - 40px);
  box-sizing: border-box;
  background: white;
  padding: 12px 14px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  font-size: 13px;
  line-height: 22px;
  color: #222;
}

.info.legend h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
}

.legend-row {
  white-space: nowrap;
}

.info.legend hr {
  margin: 6px 0;
}

.info.legend .legend-note {
  /* contributes no width of its own, so the rows set the box width */
  width: 0;
  min-width: 100%;
  margin: 0;
  font-size: 12px;
  line-height: 16px;
  color: #555;
}

.legend-line {
  display: inline-block;
  width: 18px;
  border-top: 4px solid #555;
  margin-right: 8px;
  vertical-align: middle;
}

.neighbour-swatch {
  display: inline-block;
  width: 14px;
  height: 12px;
  margin-right: 8px;
  border: 1px solid #555;
  background: rgba(255, 255, 255, 0.2);
  vertical-align: middle;
}

.neighbour-label {
  width: 0;
  height: 0;
  pointer-events: none;
}

.neighbour-label span {
  position: absolute;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  font-size: 10px;
  font-weight: 700;
  color: #222;
  text-shadow: 0 0 3px #fff, 0 0 3px #fff, 0 0 2px #fff;
  pointer-events: none;
}

.legend-color {
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 8px;
  border-radius: 2px;
}

.district-line {
  display: inline-block;
  width: 18px;
  border-top: 3px solid #111;
  margin-right: 8px;
  position: relative;
  top: -2px;
}

.leaflet-control-search {
  background: white;
  border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.leaflet-control-search input {
  width: 220px;
  padding: 6px 10px;
  border: none;
  font-size: 14px;
}

#title-card {
  position: absolute;
  top: 15px;
  left: 60px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(6px);
  padding: 12px 16px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  transition: transform 0.25s ease, opacity 0.25s ease, width 0.25s ease, padding 0.25s ease;
}

#title-card.title-card--compact {
  padding: 8px 10px;
  width: min(170px, calc(100vw - 120px));
}

#title-card.title-card--compact h2 {
  font-size: 15px;
  line-height: 1.2;
}

#title-card.title-card--compact p,
#title-card.title-card--compact small {
  display: none;
}

#title-card h2 {
  margin: 0;
  font-size: 22px;
}

#title-card p {
  margin: 5px 0;
  color: #555;
}

#title-card small {
  color: #888;
}

.browse-sidebar {
  position: absolute;
  top: 120px;
  left: 20px;
  z-index: 1000;
  box-sizing: border-box;
  width: min(220px, calc(100vw - 40px));
  background: rgba(255, 255, 255, 0.97);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.browse-sidebar__toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: none;
  background: #f7f7f7;
  color: #222;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}

.browse-sidebar__toggle-icon {
  font-size: 16px;
  line-height: 1;
}

.browse-sidebar__body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px 14px;
}

.browse-sidebar.is-collapsed .browse-sidebar__body {
  display: none;
}

.browse-sidebar__section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.browse-sidebar__section label {
  font-size: 13px;
  font-weight: 700;
  color: #444;
}

.browse-sidebar__section select {
  box-sizing: border-box;
  width: 100%;
  min-width: 0;
  text-overflow: ellipsis;
  padding: 8px 10px;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  font-size: 13px;
  color: #222;
  background: white;
}

.browse-sidebar__section select:disabled {
  background: #f2f2f2;
  color: #777;
}

.mobile-menu-toggle {
  position: fixed;
  left: 12px;
  bottom: 58px;
  z-index: 1800;
  display: none;
  align-items: center;
  gap: 8px;
  border: none;
  padding: 9px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(6px);
  color: #222;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.mobile-menu {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 78px;
  max-height: min(72dvh, 480px);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(6px);
  z-index: 1700;
  transform: translateY(calc(100% + 120px));   /* fully off screen, past its bottom offset */
  transition: transform 0.25s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.24);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 18px 18px 0 0;
}

.mobile-menu.is-open {
  transform: translateY(0);
}

.mobile-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 1500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.mobile-menu-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.mobile-menu__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 12px;
  border-bottom: 1px solid #e9ecef;
}

.mobile-menu__header h3 {
  margin: 0;
  font-size: 18px;
}

.mobile-menu__close {
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
}

.mobile-menu__content {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px 16px;
  overflow-y: auto;
  flex: 1;
}

.mobile-menu__search {
  display: flex;
  gap: 8px;
  align-items: center;
}

.mobile-menu__search input {
  flex: 1;
  border: 1px solid #d0d0d0;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}

.mobile-menu__search button {
  border: none;
  border-radius: 8px;
  background: #1e88e5;
  color: white;
  padding: 8px 10px;
  font-size: 13px;
  cursor: pointer;
}

.mobile-menu__section {
  border: 1px solid #e9ecef;
  border-radius: 10px;
  background: #fcfcfd;
  overflow: hidden;
}

.mobile-menu__section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  border: none;
  background: transparent;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 700;
  text-align: left;
  color: #222;
  cursor: pointer;
}

.mobile-menu__section-icon {
  transition: transform 0.2s ease;
}

.mobile-menu__section.is-open .mobile-menu__section-icon {
  transform: rotate(180deg);
}

.mobile-menu__panel {
  display: none;
  padding: 0 14px 12px;
}

.mobile-menu__section.is-open .mobile-menu__panel {
  display: block;
}

.mobile-menu__panel--text {
  display: none;
  font-size: 13px;
  color: #424242;
}

.mobile-menu__section.is-open .mobile-menu__panel--text {
  display: block;
}

.mobile-menu__panel--text h4 {
  margin: 0 0 6px;
  font-size: 14px;
  color: #111;
}

.mobile-menu__panel--text p,
.mobile-menu__panel--text ul {
  margin: 0 0 8px;
}

.mobile-menu__legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 4px;
}

.mobile-menu__legend-heading {
  font-size: 14px;
  font-weight: 700;
  color: #111;
}

.mobile-menu__legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #444;
}

.mobile-menu__legend-row > span:first-child {
  flex: 0 0 18px;
  margin-right: 0;
}

.mobile-menu__hint {
  margin: 0;
  font-size: 12px;
  color: #666;
}

.mobile-menu__contact-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mobile-menu__contact-card a {
  color: #1565c0;
  text-decoration: none;
}

#aboutButton {
  position: absolute;
  bottom: 20px;
  left: 15px;
  z-index: 2000;
  padding: 10px 14px;
  background: white;
  border: none;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  font-size: 14px;
}

#learnButton {
  position: absolute;
  bottom: 20px;
  left: 105px;
  z-index: 2000;
  padding: 10px 14px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  color: #222;
  font-size: 14px;
  text-decoration: none;
}

.mobile-menu__link {
  color: #1565c0;
  font-weight: 700;
  text-decoration: none;
}

#aboutPanel {
  position: absolute;
  bottom: 70px;
  left: 15px;
  width: 320px;
  max-height: 70vh;
  overflow-y: auto;
  background: white;
  padding: 18px;
  border-radius: 10px;
  z-index: 2000;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.25);
  font-size: 14px;
}

.hidden {
  display: none;
}

#authorCard {
  position: absolute;
  bottom: 50px;
  right: 30px;
  z-index: 2000;
  background: rgba(255, 255, 255, 0.95);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  line-height: 1.5;
}

#authorCard a {
  text-decoration: none;
}

#authorCard hr {
  margin: 6px 0;
}

#authorCard h4 {
  margin: 0 0 6px 0;
  font-size: 17px;
}

#authorCard p {
  margin: 0;
}

.leaflet-bottom.leaflet-right .info.legend {
  margin-bottom: 200px;
  margin-right: 30px;
}

@media (min-width: 769px) {
  .mobile-menu,
  .mobile-menu-backdrop {
    display: none;
  }
}

@media (max-width: 768px) {
  :root {
    --mobile-edge-spacing: 16px;
    --mobile-menu-button-height: 36px;
    --mobile-control-spacing: 12px;
  }

  #title-card {
    top: auto;
    left: 50%;
    right: auto;
    bottom: calc(
      var(--mobile-edge-spacing) +
      var(--mobile-menu-button-height) +
      var(--mobile-control-spacing)
    );
    width: min(180px, calc(100vw - (2 * var(--mobile-edge-spacing))));
    padding: 8px 10px;
    max-width: 180px;
    transform: translateX(-50%);
  }

  #title-card h2 {
    font-size: 15px;
    line-height: 1.2;
  }

  #title-card p,
  #title-card small {
    display: none;
  }

  .mobile-menu-toggle {
    display: inline-flex;
    left: var(--mobile-edge-spacing);
    bottom: var(--mobile-edge-spacing);
    min-height: var(--mobile-menu-button-height);
  }

  .mobile-menu {
    bottom: calc(
      var(--mobile-edge-spacing) +
      var(--mobile-menu-button-height) +
      var(--mobile-control-spacing)
    );
  }

  .browse-sidebar {
    display: none;
  }

  #aboutButton,
  #learnButton,
  #aboutPanel,
  #authorCard {
    display: none !important;
  }

  .leaflet-bottom.leaflet-right .info.legend {
    display: none;
  }

  .leaflet-control-search {
    display: none !important;
  }

  .leaflet-top.leaflet-right {
    top: 12px;
    right: 12px;
  }

  .leaflet-control-layers {
    margin: 0;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(6px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
    font-size: 12px;
  }

  .leaflet-control-layers-expanded {
    padding: 8px 10px;
  }

  .leaflet-control-zoom {
    display: none;
  }
}

/* Block / district panchayat divisions */
.unpublished-swatch {
  display: inline-block;
  width: 14px;
  height: 12px;
  margin-right: 8px;
  border: 2px dashed #555;
  background: rgba(158, 158, 158, 0.25);
  vertical-align: middle;
}

.division-popup {
  font-size: 13px;
  line-height: 1.4;
}

.division-popup__note {
  margin: 8px 0;
  color: #444;
}

.division-popup__table {
  max-height: 220px;
  overflow-y: auto;
  border-top: 1px solid #ddd;
}

.division-popup table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.division-popup th,
.division-popup td {
  text-align: left;
  padding: 3px 6px 3px 0;
  border-bottom: 1px solid #eee;
  vertical-align: top;
}

.division-popup th {
  position: sticky;
  top: 0;
  background: #fff;
}

.division-popup .legend-color {
  width: 9px;
  height: 9px;
  margin-right: 4px;
}

/* District Administration layer */
.admin-swatch {
  display: inline-block;
  width: 14px;
  height: 12px;
  margin-right: 8px;
  border: 2px dashed #00695c;
  background: rgba(38, 166, 154, 0.25);
  vertical-align: middle;
}

.admin-popup {
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.admin-popup__role {
  margin: 2px 0 8px;
  color: #555;
  font-size: 12px;
}

.admin-popup__na {
  color: #888;
  font-style: italic;
}

.admin-popup__source {
  display: block;
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid #ddd;
  color: #555;
  line-height: 1.4;
}

/* Revenue taluk layer */
.taluk-swatch {
  display: inline-block;
  width: 14px;
  height: 12px;
  margin-right: 8px;
  border: 2px solid #6a1b9a;
  background: rgba(171, 71, 188, 0.25);
  vertical-align: middle;
}

.taluk-popup {
  font-size: 13px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.taluk-popup__ml {
  color: #555;
  font-size: 13px;
}

.taluk-popup__new {
  margin: 0 0 6px;
  padding: 3px 6px;
  background: #f3e5f5;
  border-radius: 4px;
  font-size: 12px;
}

.taluk-popup__list {
  max-height: 140px;
  overflow-y: auto;
  margin: 2px 0 8px;
  padding: 4px 6px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  background: #fafafa;
  font-size: 12px;
  line-height: 1.6;
}

.taluk-popup__list--short {
  max-height: 80px;
}
