* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.map-app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  color: #222;
  background: #f4f1ea;
}

.app-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: #3d2b1f;
  color: #fff;
}

.app-header h1 {
  font-size: 24px;
  margin-bottom: 6px;
}

.app-header p {
  font-size: 14px;
  opacity: 0.9;
}

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

.church-search {
  position: relative;
  flex: 0 1 380px;
  margin-left: auto;
}

.church-search input {
  width: 100%;
  padding: 9px 34px 9px 12px;
  border: 1px solid #d9c39a;
  border-radius: 3px;
  background: #fffaf3;
  color: #3d2b1f;
  font: inherit;
  font-size: 14px;
  outline: none;
}

.church-search input:focus {
  border-color: #e0b24a;
  box-shadow: 0 0 0 2px rgba(224, 178, 74, 0.28);
}

.church-search-results {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  z-index: 1300;
  width: min(420px, calc(100vw - 32px));
  max-height: min(420px, calc(100vh - 120px));
  overflow: auto;
  border: 1px solid #d9cbb8;
  border-radius: 3px;
  background: #fffaf3;
  color: #222;
  box-shadow: 0 8px 24px rgba(61, 43, 31, 0.24);
}

.church-search-results.is-hidden {
  display: none;
}

.church-search-result {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid #eee5d8;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.church-search-result:last-child {
  border-bottom: 0;
}

.church-search-result:hover,
.church-search-result:focus-visible,
.church-search-result.is-active {
  background: #fdf1d8;
}

.church-search-result strong,
.church-search-result span {
  display: block;
}

.church-search-result strong {
  font-size: 14px;
}

.church-search-result span,
.church-search-empty {
  margin-top: 3px;
  color: #7a6554;
  font-size: 12px;
  line-height: 1.45;
}

.church-search-empty {
  padding: 12px;
}

.app-main {
  position: relative;
  flex: 1;
  min-height: 0;
}

#map {
  width: 100%;
  height: 100%;
}

/* 高德自定义 Marker：保持同一图标节点，选中时只缩放外观。 */
.church-marker {
  width: 36px;
  height: 48px;
  color-scheme: only light;
  forced-color-adjust: none;
  transform-origin: bottom center;
  transition: transform 0.16s ease;
}

.unlocated-toggle {
  flex-shrink: 0;
  padding: 8px 13px;
  border: 1px solid #f4e3b2;
  background: transparent;
  color: #f4e3b2;
  font-size: 14px;
  cursor: pointer;
}

.unlocated-toggle:hover,
.unlocated-toggle[aria-expanded="true"] {
  background: rgba(244, 227, 178, 0.15);
}

.app-header a.unlocated-toggle {
  text-decoration: none;
}

.app-header .button {
  flex-shrink: 0;
  border-color: #f4e3b2;
  background: transparent;
  color: #f4e3b2;
  font: inherit;
  cursor: pointer;
}

.church-marker svg {
  display: block;
  width: 100%;
  height: 100%;
}

.church-marker svg path {
  fill: #3d2b1f;
}

.church-marker svg rect {
  fill: #f4e3b2;
}

.church-marker.is-selected {
  transform: scale(1.25);
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.95))
    drop-shadow(0 0 9px rgba(224, 178, 74, 0.95));
}

/* 高德 MarkerCluster 聚合点：延续页面的暖棕、米色和金色。 */
.church-cluster {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff4d6;
  border-radius: 50%;
  background: rgba(92, 62, 43, 0.9);
  color: #fff8e8;
  box-shadow: 0 3px 12px rgba(61, 43, 31, 0.34), inset 0 0 0 2px rgba(184, 134, 11, 0.48);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

/* 教堂数据加载失败时的提示条（默认隐藏，见 js/map.js） */
.map-error {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 1100;
  max-width: calc(100% - 32px);
  padding: 10px 14px;
  background: #fdf3f2;
  color: #8a2b2b;
  border: 1px solid #d9a3a0;
  font-size: 14px;
  line-height: 1.5;
}

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

.unlocated-panel {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 1100;
  width: 340px;
  max-width: calc(100% - 32px);
  max-height: calc(100% - 32px);
  overflow: auto;
  background: #fffaf3;
  border: 1px solid #d9cbb8;
  box-shadow: 0 8px 24px rgba(61, 43, 31, 0.18);
}

.unlocated-panel.is-hidden,
.unlocated-toggle.is-hidden,
.church-card-fields .is-hidden {
  display: none;
}

.unlocated-panel-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  background: #fffaf3;
  border-bottom: 1px solid #e6dccd;
}

.unlocated-panel-head h2 {
  margin-bottom: 3px;
  font-size: 18px;
  color: #3d2b1f;
}

.unlocated-panel-head p {
  color: #7a6554;
  font-size: 12px;
  line-height: 1.5;
}

.unlocated-panel-head button {
  padding: 4px 9px;
  border: 1px solid #3d2b1f;
  background: #fff;
  color: #3d2b1f;
  cursor: pointer;
}

.unlocated-item {
  display: block;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid #eee5d8;
  background: transparent;
  color: #222;
  text-align: left;
  cursor: pointer;
}

.unlocated-item:hover,
.unlocated-item:focus-visible {
  background: #fdf1d8;
}

.unlocated-item strong,
.unlocated-item span {
  display: block;
}

.unlocated-item strong {
  margin-bottom: 3px;
  font-size: 14px;
}

.unlocated-item span {
  color: #7a6554;
  font-size: 12px;
  line-height: 1.5;
}

.church-card {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 1100;
  width: 320px;
  max-width: calc(100% - 32px);
  max-height: calc(100% - 32px);
  overflow: auto;
  padding: 20px 20px 16px;
  background: #fffaf3;
  color: #222;
  border: 1px solid #d9cbb8;
  box-shadow: 0 8px 24px rgba(61, 43, 31, 0.18);
}

.church-card.is-hidden {
  display: none;
}

.church-card-close {
  float: right;
  margin: 0 0 8px 12px;
  padding: 4px 10px;
  border: 1px solid #3d2b1f;
  background: #fff;
  color: #3d2b1f;
  font-size: 14px;
  cursor: pointer;
}

.church-card h2 {
  font-size: 20px;
  line-height: 1.4;
  margin-bottom: 16px;
  color: #3d2b1f;
}

.church-card-fields div {
  margin-bottom: 12px;
}

.church-card-fields dt {
  font-size: 12px;
  color: #7a6554;
  margin-bottom: 4px;
}

.church-card-fields dd {
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-line;
}

/* 未核实的高风险信息（弥撒时间、联系方式）与暂无资料的占位文字：灰色斜体 */
.church-card-fields dd.is-empty,
.church-card-fields dd.is-unconfirmed {
  color: #7a6554;
  font-style: italic;
}

@media (max-width: 900px) {
  .app-header {
    flex-wrap: wrap;
  }

  .church-search {
    order: 3;
    flex: 1 0 100%;
    margin-left: 0;
  }
}

@media (max-width: 640px) {
  .app-header {
    flex-wrap: wrap;
    align-items: center;
    padding: 12px 16px;
  }

  .app-header > div:first-child {
    flex: 1 1 auto;
  }

  .app-header h1 {
    font-size: 20px;
  }

  .app-header p {
    display: none;
  }

  .unlocated-toggle {
    padding: 6px 9px;
    font-size: 12px;
  }

  .church-search {
    order: 3;
    flex: 1 0 100%;
    margin-left: 0;
  }

  .church-search-results {
    right: auto;
    left: 0;
    width: 100%;
    max-height: min(340px, calc(100vh - 170px));
  }

  .unlocated-panel {
    top: 12px;
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
    max-height: 55%;
  }

  .church-card {
    top: auto;
    bottom: 16px;
    right: 16px;
    left: 16px;
    width: auto;
    max-height: 45%;
  }
}
