:root {
  color-scheme: light;
  --bg: #f4f7f6;
  --panel: #ffffff;
  --ink: #16211d;
  --muted: #66736d;
  --line: #dce5e0;
  --brand: #0f7b6c;
  --brand-strong: #095b50;
  --accent: #c8563a;
  --map-water: #dbecea;
  --shadow: 0 18px 45px rgba(24, 40, 35, 0.13);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.shell {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
}

.directory {
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  padding: 14px clamp(14px, 3vw, 34px) 12px;
  position: relative;
  z-index: 5;
}

.directory__topline {
  display: block;
  text-align: center;
}

h1 {
  margin: 0;
  font-size: clamp(30px, 4vw, 48px);
  line-height: 1.12;
  letter-spacing: 0;
}

.place-search {
  position: relative;
  z-index: 20;
  width: min(420px, 100%);
  margin-top: 8px;
  text-align: left;
}

.place-search::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 13px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--muted);
  border-radius: 999px;
  z-index: 1;
  pointer-events: none;
}

.place-search::after {
  content: "";
  position: absolute;
  left: 23px;
  top: 25px;
  width: 7px;
  height: 2px;
  border-radius: 999px;
  background: var(--muted);
  transform: rotate(45deg);
  transform-origin: left center;
  z-index: 1;
  pointer-events: none;
}

.place-search__label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.place-search input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfdfc;
  color: var(--ink);
  padding: 0 12px 0 38px;
  outline: none;
  box-shadow: 0 6px 16px rgba(17, 31, 27, 0.06);
}

.place-search input:focus {
  border-color: #8dc3b7;
  box-shadow: 0 0 0 3px rgba(15, 123, 108, 0.12);
}

.place-search__results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: none;
  max-height: min(320px, 54vh);
  overflow: auto;
  border: 1px solid rgba(220, 229, 224, 0.95);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 16px 36px rgba(17, 31, 27, 0.16);
  padding: 6px;
}

.place-search__results.is-open {
  display: grid;
  gap: 4px;
}

.search-result,
.search-result-empty {
  width: 100%;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  padding: 8px 9px;
  text-align: left;
}

.search-result {
  cursor: pointer;
}

.search-result:hover,
.search-result:focus {
  background: #eef8f5;
  color: var(--brand-strong);
  outline: none;
}

.search-result__name {
  display: block;
  font-weight: 900;
  line-height: 1.35;
}

.search-result__path,
.search-result-empty {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 10px;
  min-height: 24px;
}

.breadcrumb button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 4px 0;
  cursor: pointer;
}

.breadcrumb button:hover {
  color: var(--brand);
}

.breadcrumb span {
  color: #9ba8a2;
}

.top-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}

.home-button,
.secondary-button {
  height: 34px;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 800;
  padding: 0 16px;
}

.home-button {
  background: var(--brand);
  color: #fff;
}

.home-button:hover {
  background: var(--brand-strong);
}

.secondary-button {
  background: #edf2f0;
  color: var(--brand-strong);
}

.secondary-button:hover {
  background: #dfe9e5;
}

.secondary-button.is-disabled {
  cursor: default;
  opacity: 0.46;
}

.chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
  gap: 6px;
  margin-top: 10px;
  max-height: 128px;
  overflow: auto;
  padding-right: 4px;
}

.chip {
  min-height: 50px;
  border: 1px solid var(--line);
  background: #fbfdfc;
  color: var(--ink);
  border-radius: 7px;
  padding: 6px 8px;
  cursor: pointer;
  text-align: left;
  display: grid;
  grid-template-rows: auto auto;
  justify-content: stretch;
  align-items: center;
  gap: 6px;
  overflow: visible;
}

.chip__name {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  white-space: normal;
  word-break: keep-all;
}

.chip:hover,
.chip.is-active {
  border-color: #8dc3b7;
  background: #eef8f5;
  color: var(--brand-strong);
}

.chip small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
  text-align: left;
  white-space: normal;
  word-break: keep-all;
}

.map-stage {
  min-height: 520px;
  position: relative;
  padding: 18px clamp(16px, 4vw, 48px) 36px;
  isolation: isolate;
}

.map-back {
  position: absolute;
  left: 58px;
  top: 12px;
  z-index: 10000;
  height: 34px;
  border: 1px solid rgba(15, 123, 108, 0.22);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 22px rgba(17, 31, 27, 0.14);
  color: var(--brand-strong);
  cursor: pointer;
  font-size: 13px;
  font-weight: 900;
  padding: 0 12px;
}

.map-back:hover {
  background: #eef8f5;
}

.map-back.is-hidden {
  display: none;
}

.map-tone-panel {
  position: absolute;
  right: 14px;
  top: 14px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: 58px;
  padding: 10px;
  border: 1px solid rgba(220, 229, 224, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 28px rgba(17, 31, 27, 0.14);
}

.map-tone-panel__title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.tone-button,
.tone-color {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid rgba(15, 123, 108, 0.2);
  border-radius: 7px;
  background: #ffffff;
  color: var(--brand-strong);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.tone-button:hover,
.tone-color:hover {
  background: #eef8f5;
}

.tone-button.is-active,
.tone-color.is-active {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 14%, #ffffff);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--brand) 18%, transparent);
}

.tone-color {
  flex-direction: column;
  gap: 5px;
  padding: 6px 4px;
}

.tone-color input {
  width: 28px;
  height: 22px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.map {
  position: relative;
  z-index: 1;
  height: min(66vh, 720px);
  min-height: 500px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--map-water);
  box-shadow: var(--shadow);
}

.map .leaflet-top,
.map .leaflet-bottom {
  z-index: 10000;
}

.map .leaflet-control {
  position: relative;
  z-index: 10001;
}

.hainan-inset {
  position: absolute;
  right: clamp(28px, 5vw, 70px);
  left: auto;
  bottom: 54px;
  z-index: 4;
  width: 150px;
  border: 1px solid rgba(15, 123, 108, 0.28);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 28px rgba(17, 31, 27, 0.14);
  color: var(--brand-strong);
  padding: 9px;
}

.hainan-inset[data-clickable] {
  cursor: grab;
}

.hainan-inset[data-clickable]:hover {
  background: #eef8f5;
}

.hainan-inset.is-dragging {
  cursor: grabbing;
  user-select: none;
}

.hainan-inset.is-hidden {
  display: none;
}

.hainan-inset__title {
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 6px;
  text-align: center;
}

.hainan-inset__box {
  height: 86px;
  border: 1px solid #8dc3b7;
  background: #e4f1ef;
  position: relative;
}

.hainan-inset__box span {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--accent);
}

.hainan-inset__box span:nth-child(1) {
  left: 42%;
  top: 18%;
}

.hainan-inset__box span:nth-child(2) {
  left: 58%;
  top: 38%;
}

.hainan-inset__box span:nth-child(3) {
  left: 36%;
  top: 58%;
}

.hainan-inset__box span:nth-child(4) {
  left: 66%;
  top: 70%;
}

.hainan-inset__caption {
  margin-top: 5px;
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.leaflet-container {
  background: var(--map-water);
  font: inherit;
}

.region-marker {
  border: 2px solid #fff;
  background: var(--brand);
  box-shadow: 0 4px 14px rgba(4, 64, 56, 0.28);
}

.admin-boundary {
  cursor: pointer;
}

.region-label {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.region-label__button {
  background: rgba(255, 255, 255, 0.92);
  color: var(--brand-strong);
  border: 1px solid rgba(15, 123, 108, 0.22);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 5px 16px rgba(13, 40, 35, 0.16);
  white-space: nowrap;
}

.region-label__button--small {
  padding: 2px 6px;
  font-size: 10px;
  box-shadow: 0 4px 12px rgba(13, 40, 35, 0.12);
}

.region-label__button--tiny {
  padding: 2px 5px;
  font-size: 9px;
  box-shadow: 0 3px 10px rgba(13, 40, 35, 0.1);
}

.info-panel {
  position: absolute;
  right: clamp(26px, 5vw, 68px);
  bottom: 58px;
  width: min(320px, calc(100vw - 52px));
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(220, 229, 224, 0.86);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(17, 31, 27, 0.15);
  padding: 16px;
  z-index: 3;
}

.info-panel.is-collapsed {
  width: auto;
  padding: 10px;
}

.info-panel__title {
  font-size: 20px;
  font-weight: 900;
}

.info-panel__meta {
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.5;
}

.info-panel__note {
  color: #7b5b52;
  background: #fff5ef;
  border: 1px solid #f0d4c7;
  border-radius: 7px;
  margin-top: 12px;
  padding: 10px;
  font-size: 13px;
  line-height: 1.45;
}

.info-panel__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  min-height: 34px;
}

.copy-place-button,
.panel-toggle-button {
  border: 1px solid rgba(15, 123, 108, 0.24);
  border-radius: 7px;
  cursor: pointer;
  font-weight: 800;
  padding: 8px 12px;
  white-space: nowrap;
}

.copy-place-button {
  background: var(--brand);
  color: #ffffff;
  box-shadow: 0 7px 18px rgba(15, 123, 108, 0.18);
}

.copy-place-button:hover {
  background: var(--brand-strong);
}

.panel-toggle-button {
  background: #ffffff;
  color: var(--brand-strong);
}

.panel-toggle-button:hover {
  background: #eef8f5;
}

.panel-toggle-button--show {
  box-shadow: 0 7px 18px rgba(17, 31, 27, 0.12);
}

.info-panel__copy-status {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  min-width: 0;
}

.info-panel__copy-status.is-error {
  color: #b6422d;
}

.map-status {
  position: absolute;
  left: clamp(30px, 5vw, 68px);
  bottom: 58px;
  z-index: 3;
  border: 1px solid rgba(220, 229, 224, 0.9);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 10px 28px rgba(17, 31, 27, 0.14);
  color: var(--brand-strong);
  font-size: 13px;
  font-weight: 800;
  padding: 10px 12px;
}

@media (max-width: 720px) {
  .directory__topline {
    text-align: center;
  }

  .place-search {
    width: 100%;
  }

  .chips {
    grid-template-columns: repeat(auto-fill, minmax(118px, 1fr));
    max-height: 124px;
  }

  .map-stage {
    padding-inline: 10px;
  }

  .map-back {
    left: 56px;
    top: 10px;
  }

  .map-tone-panel {
    right: 10px;
    top: 10px;
    width: 52px;
    padding: 8px;
  }

  .map {
    min-height: 470px;
    height: 60vh;
  }

  .info-panel {
    left: 18px;
    right: 18px;
    bottom: 48px;
    width: auto;
  }

  .hainan-inset {
    right: 18px;
    left: auto;
    bottom: 188px;
    width: 132px;
  }

  .map-status {
    left: 18px;
    bottom: 180px;
  }
}
