/* Shared colors, reading hierarchy, and control sizes. */
:root {
  --ui-ink: #263b33;
  --ui-muted: #58665d;
  --ui-brand: #28543e;
  --ui-brand-strong: #173d33;
  --ui-brand-soft: #edf2e9;
  --ui-brand-pressed: #e1e9db;
  --ui-on-accent: #fff;
  --ui-surface: #fffdf7;
  --ui-surface-control: #fffdf7;
  --ui-surface-muted: #f2f3ec;
  --ui-border: #d7ded3;
  --ui-border-subtle: #e7eae1;
  --ui-page: #e9ede7;
  --ui-disabled-surface: #eef1ed;
  --ui-disabled-ink: #59675e;
  --ui-disabled-border: #d5ddd7;
  --ui-switch-off: #909d91;
  --ui-warning-surface: #fff5dc;
  --ui-warning-soft: #faf7ed;
  --ui-warning-ink: #614615;
  --ui-warning-border: #e5cf93;
  --ui-warning-border-soft: #e9dfc5;
  --ui-danger: #b91c1c;
  --ui-danger-soft: #fff1f0;
  --ui-donation: #ff3030;
  --ui-focus: #b9872c;
  --ui-focus-soft: #28543e22;
  --ui-focus-reduced: #92baa0;
  --ui-entry-border: #e5f3e9;
  --ui-backdrop: #10231c52;
  --ui-photo-surface: #07111a;
  --ui-photo-control: #263946;
  --ui-photo-border: #657b88;
  --ui-photo-muted: #d4dde4;
  --ui-photo-placeholder: #e7eee8;
  --ui-volunteer: #1669c4;
  --ui-volunteer-soft: #eef5ff;
  --ui-space-1: 4px;
  --ui-space-2: 8px;
  --ui-space-3: 12px;
  --ui-space-4: 16px;
  --ui-space-5: 20px;
  --ui-space-6: 24px;
  --ui-font-body: 17px;
  --ui-font-action: 16px;
  --ui-font-support: 15px;
  --ui-font-title: 20px;
  --ui-control-size: 52px;
  --ui-control-radius: 12px;
  --ui-group-radius: 16px;
  --ui-panel-radius: 24px;
  --ui-focus-width: 3px;
  --ui-focus-offset: 3px;
  --ui-shadow: 0 3px 12px #172b2226;
  --ui-shadow-subtle: 0 1px 3px #172b2214;
  --ui-header-shadow: 0 1px 0 #243d331a,0 2px 8px #172b2212;
  --ui-panel-shadow: 0 12px 36px #172b222b;
  --ui-entry-halo-rest: 0 2px 9px #001b3150,0 0 0 0 #ffffff00,0 0 0 0 #29724c00;
  --ui-entry-halo-peak: 0 2px 9px #001b3150,0 0 0 2px #fffffff2,0 0 0 5px #29724ce6;
  --ui-entry-halo-fade: 0 2px 9px #001b3150,0 0 0 2px #ffffffb3,0 0 0 8px #29724cb3;
  --ui-entry-halo-end: 0 2px 9px #001b3150,0 0 0 2px #ffffff00,0 0 0 12px #29724c00;
  --ui-motion-fast: 160ms;
  --ui-motion-panel: 220ms;
  --ui-motion-spinner: 800ms;
  --ui-ease: cubic-bezier(.2,.7,.2,1);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--ui-page);
  color: var(--ui-ink);
  font: 16px/1.65 -apple-system,BlinkMacSystemFont,"Segoe UI","Microsoft YaHei",sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: scale var(--ui-motion-fast) var(--ui-ease),background-color var(--ui-motion-fast) var(--ui-ease),border-color var(--ui-motion-fast) var(--ui-ease);
}

button:not(:disabled):active {
  scale: .96;
}

button:disabled {
  cursor: default;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: var(--ui-focus-width) solid var(--ui-focus);
  outline-offset: var(--ui-focus-offset);
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Brand and donation messages share one fixed-height row. */
.topbar {
  position: relative;
  z-index: 1000;
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: var(--ui-space-2);
  box-sizing: content-box;
  height: 56px;
  padding: env(safe-area-inset-top) var(--ui-space-3) 0;
  overflow: hidden;
  background: var(--ui-surface);
  box-shadow: var(--ui-header-shadow);
  touch-action: none;
}

.topbar h1 {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 6px;
  min-width: 0;
  margin: 0 0 0 5px;
  color: var(--ui-brand-strong);
  font-size: 17px;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0;
  text-align: left;
  white-space: nowrap;
}

.brand-icon {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  object-fit: contain;
}

.topbar.brand-donation h1 {
  margin-left: 0;
}

.brand-heart {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  stroke-width: 1.8;
}

.brand-heart,
#donate-button.donation-active svg {
  color: var(--ui-donation);
  fill: currentColor;
  stroke: currentColor;
}

#donate-button.donation-pulsing svg {
  animation: donation-heartbeat 1s ease-in-out 3;
  transform-origin: center;
}

/* Map surface, cached tiles, scale, and range boundary. */
.map-frame {
  position: relative;
  flex: 1;
  min-height: 0;
  touch-action: pan-x pan-y;
}

#map {
  position: absolute;
  inset: 0;
  background: #d5dfd2;
  touch-action: none;
}

.leaflet-container {
  font: inherit;
}

.leaflet-control-attribution {
  max-width: 75%;
  font-size: 9px !important;
  opacity: .8;
}

.leaflet-bottom.leaflet-left {
  bottom: calc(18px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
}

.leaflet-control-scale {
  margin-bottom: 0 !important;
  margin-left: 0 !important;
}

.leaflet-control-scale-line {
  border-color: #fff;
  background: #213629b3;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  text-shadow: none;
}

.cache-tile {
  overflow: hidden;
  background: transparent;
}

.cache-tile > img {
  position: absolute;
  top: 0;
  left: 0;
  width: 256px;
  height: 256px;
  max-width: none !important;
  max-height: none !important;
  pointer-events: none;
}

.range-label {
  position: absolute;
  z-index: 450;
  padding: 3px 10px;
  border: 2px solid #fff;
  border-radius: 8px;
  background: #ffe08a;
  color: #243746;
  box-shadow: 0 0 0 1px #6d572b,0 2px 6px #0005;
  font-size: 17px;
  font-weight: 700;
  line-height: 26px;
  white-space: nowrap;
  transform: translate(-50%,-100%);
  pointer-events: none;
}

/* Two tool columns retain their established map positions. */
.map-actions {
  position: absolute;
  z-index: 800;
  bottom: calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: var(--ui-space-1);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-group-radius);
  background: var(--ui-surface-control);
  box-shadow: var(--ui-shadow);
  max-height: calc(100dvh - 110px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  touch-action: pan-y;
}

.map-actions::-webkit-scrollbar {
  display: none;
}

.map-actions-info {
  right: auto;
  left: max(12px,env(safe-area-inset-left));
}

.map-actions-navigation {
  right: max(12px,env(safe-area-inset-right));
}

.map-button {
  position: relative;
  display: flex;
  flex: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: var(--ui-control-size);
  height: var(--ui-control-size);
  padding: 3px 0;
  border: 0;
  border-radius: var(--ui-control-radius);
  background: var(--ui-surface-control);
  color: var(--ui-brand);
  box-shadow: none;
}

.map-button + .map-button::before {
  position: absolute;
  top: 0;
  right: var(--ui-space-3);
  left: var(--ui-space-3);
  height: 1px;
  background: var(--ui-border-subtle);
  content: "";
  pointer-events: none;
}

.map-button svg {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map-button-label {
  font-size: 14px;
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
}

.map-button:not(:disabled):active {
  background: var(--ui-brand-soft);
}

.map-button:focus-visible {
  outline-offset: calc(-1 * var(--ui-focus-width));
}

.map-button[aria-pressed=true] {
  border: 2px solid var(--ui-danger);
  background: var(--ui-danger-soft);
  color: var(--ui-danger);
}

#layers-button[aria-expanded=true] {
  background: var(--ui-brand-soft);
  color: var(--ui-brand-strong);
  box-shadow: inset 0 0 0 1px var(--ui-brand);
}

.map-button:disabled {
  border-color: var(--ui-disabled-border);
  background: var(--ui-disabled-surface);
  color: var(--ui-disabled-ink);
  box-shadow: none;
  opacity: 1;
}

/* Permission entry and welcome copy before the first location fix. */
.locate-entry-group {
  position: absolute;
  z-index: 900;
  bottom: calc(62px + env(safe-area-inset-bottom));
  left: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: calc(100% - 144px);
  max-width: 320px;
  transform: translateX(-50%);
}

.locate-entry {
  max-width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 10px 14px;
  border: 2px solid var(--ui-entry-border);
  border-radius: var(--ui-control-radius);
  background: var(--ui-brand-strong);
  color: var(--ui-on-accent);
  box-shadow: var(--ui-shadow);
  font-size: var(--ui-font-action);
  font-weight: 700;
  line-height: 1.4;
  text-align: center;
  white-space: normal;
  touch-action: none;
}

.locate-entry.attention {
  animation: entry-halo 8s ease-out 3s infinite;
}

.locate-entry.attention.attention-intro {
  animation: entry-intro .65s ease-in-out 1s 2,entry-halo 8s ease-out 3s infinite;
}

.locate-entry.attention-paused {
  animation-play-state: paused !important;
}

.welcome-guide {
  position: absolute;
  z-index: 450;
  top: 13%;
  left: 50%;
  width: max-content;
  max-width: 88%;
  padding: var(--ui-space-5);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-panel-radius);
  background: var(--ui-surface-control);
  color: var(--ui-ink);
  box-shadow: var(--ui-shadow);
  font-size: 18px;
  line-height: 1.6;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transform: translateX(-50%);
  transition: opacity var(--ui-motion-panel) var(--ui-ease),visibility var(--ui-motion-panel);
  pointer-events: none;
}

.welcome-symbol {
  display: block;
  width: 36px;
  height: 36px;
  margin: 0 auto var(--ui-space-2);
  border-radius: var(--ui-control-radius);
  object-fit: contain;
}

.welcome-guide.is-visible {
  opacity: 1;
  visibility: visible;
}

.welcome-guide strong {
  color: var(--ui-brand-strong);
  font-weight: 700;
}

.welcome-kicker,
.welcome-free {
  color: var(--ui-muted);
  font-size: var(--ui-font-support);
  font-weight: 400;
}

.welcome-free {
  color: var(--ui-brand);
}

/* Screen feedback remains above the map and below modal sheets. */
.auto-center-notice {
  position: absolute;
  z-index: 950;
  top: 12px;
  left: 50%;
  max-width: calc(100% - 32px);
  padding: 9px 16px;
  border: 1px solid var(--ui-brand-strong);
  border-radius: var(--ui-control-radius);
  background: var(--ui-brand-strong);
  color: var(--ui-on-accent);
  box-shadow: var(--ui-shadow);
  font-size: var(--ui-font-body);
  font-weight: 700;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  text-align: center;
  transform: translateX(-50%);
  pointer-events: none;
}

.map-notice {
  position: absolute;
  z-index: 800;
  top: 76px;
  left: 50%;
  width: max-content;
  max-width: calc(100% - 32px);
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--ui-warning-border);
  border-radius: var(--ui-control-radius);
  background: var(--ui-warning-surface);
  color: var(--ui-warning-ink);
  box-shadow: var(--ui-shadow);
  font-size: var(--ui-font-action);
  line-height: 1.5;
  white-space: normal;
  transform: translateX(-50%);
}

.preview-label {
  position: absolute;
  z-index: 800;
  top: 12px;
  left: 12px;
  padding: 5px 10px;
  border: 1px solid var(--ui-warning-border);
  border-radius: 8px;
  background: var(--ui-warning-surface);
  color: var(--ui-warning-ink);
  font-size: 12px;
}

.preview-label a {
  margin-left: 8px;
  color: inherit;
}

.toast {
  position: fixed;
  z-index: 4000;
  bottom: calc(100px + env(safe-area-inset-bottom));
  left: 50%;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 10px 18px;
  border-radius: var(--ui-control-radius);
  background: var(--ui-brand-strong);
  color: var(--ui-on-accent);
  box-shadow: var(--ui-shadow);
  font-size: var(--ui-font-action);
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
  overflow-wrap: anywhere;
  transform: translateX(-50%);
  pointer-events: none;
}

body:has(#contact-sheet:not([hidden])) .toast {
  top: calc(68px + env(safe-area-inset-top));
  bottom: auto;
}

/* The layer selector is an independently scrollable floating panel. */
.layers-panel {
  position: fixed;
  z-index: 1200;
  top: 50%;
  left: 50%;
  width: 280px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  padding: 0 var(--ui-space-4) var(--ui-space-4);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-panel-radius);
  background: var(--ui-surface);
  color: var(--ui-ink);
  box-shadow: var(--ui-panel-shadow);
  transform: translate(-50%,-50%);
}

.layers-heading {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
  padding: 12px 0 8px;
  background: var(--ui-surface);
}

.layers-heading h2 {
  margin: 0;
  font-size: var(--ui-font-title);
  font-weight: 700;
  line-height: 1.4;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
  min-height: 48px;
  font-size: var(--ui-font-action);
  font-weight: 600;
}

.toggle-row + .toggle-row {
  border-top: 1px solid var(--ui-border);
}

.toggle-row input {
  position: relative;
  flex-shrink: 0;
  width: 44px;
  height: 26px;
  margin: 0;
  border: 0;
  border-radius: 20px;
  background: var(--ui-switch-off);
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}

.toggle-row input::before {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ui-on-accent);
  box-shadow: var(--ui-shadow-subtle);
  content: "";
  transition: transform var(--ui-motion-fast) var(--ui-ease);
}

.toggle-row input:checked {
  background: var(--ui-brand);
}

.toggle-row input:checked::before {
  transform: translateX(18px);
}

.poi-filters {
  min-width: 0;
  margin: 12px 0 0;
  padding: 8px 0 0;
  border: 0;
  border-top: 1px solid var(--ui-border);
}

.poi-filters legend {
  padding-right: 8px;
  color: var(--ui-muted);
  font-size: var(--ui-font-support);
}

.poi-filter-grid {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 0 8px;
}

.poi-filter-grid label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  font-size: var(--ui-font-support);
  cursor: pointer;
}

.poi-filter-grid input {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--ui-brand);
}

.poi-filters:disabled {
  color: var(--ui-disabled-ink);
  opacity: 1;
}

/* Shared opaque sheets, buttons, and text roles. */
.sheet-backdrop {
  position: fixed;
  z-index: 2000;
  inset: 0;
  background: var(--ui-backdrop);
}

.sheet {
  position: fixed;
  z-index: 2100;
  bottom: 0;
  left: 50%;
  width: 100%;
  max-width: 480px;
  max-height: 86vh;
  max-height: min(86dvh,calc(100dvh - env(safe-area-inset-top) - 12px));
  padding: 0 var(--ui-space-5) calc(var(--ui-space-5) + env(safe-area-inset-bottom));
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--ui-border);
  border-bottom: 0;
  scroll-padding: 80px 0 20px;
  border-radius: var(--ui-panel-radius) var(--ui-panel-radius) 0 0;
  background: var(--ui-surface);
  color: var(--ui-ink);
  box-shadow: var(--ui-panel-shadow);
  font-size: var(--ui-font-body);
  transform: translateX(-50%);
  -webkit-overflow-scrolling: touch;
}

.sheet:not([hidden]),
.layers-panel:not([hidden]),
.measure-panel:not([hidden]),
.sheet-backdrop:not([hidden]) {
  animation: panel-appear var(--ui-motion-panel) var(--ui-ease);
}

.sheet h2 {
  margin: 0 0 12px;
  font-size: var(--ui-font-title);
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.sheet p {
  margin: var(--ui-space-3) 0;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.sheet-top {
  position: sticky;
  z-index: 2;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ui-space-2);
  padding: var(--ui-space-4) 0 var(--ui-space-3);
  border-bottom: 1px solid var(--ui-border-subtle);
  background: var(--ui-surface);
}

.sheet-top > div {
  min-width: 0;
}

.sheet-top h2 {
  margin: 0;
}

.close-sheet,
#layers-close,
.measure-panel button {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--ui-border);
  border-radius: 50%;
  background: var(--ui-surface-muted);
  color: var(--ui-muted);
  font-size: 24px;
  line-height: 1;
}

.close-icon {
  display: block;
  flex: none;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.primary-button,
.secondary-button {
  display: block;
  width: 100%;
  min-height: 48px;
  margin-top: 12px;
  padding: 10px 15px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-control-radius);
  font-size: var(--ui-font-action);
  font-weight: 600;
  line-height: 1.5;
  text-align: center;
}

.primary-button {
  border-color: var(--ui-brand);
  background: var(--ui-brand);
  color: var(--ui-on-accent);
}

.secondary-button {
  background: var(--ui-brand-soft);
  color: var(--ui-brand);
}

.primary-button:not(:disabled):active {
  background: var(--ui-brand-strong);
}

.secondary-button:not(:disabled):active {
  background: var(--ui-brand-pressed);
}

.primary-button:disabled {
  border-color: var(--ui-disabled-border);
  background: var(--ui-disabled-surface);
  color: var(--ui-disabled-ink);
}

.eyebrow {
  margin: 0 0 6px !important;
  color: var(--ui-muted);
  font-size: var(--ui-font-support);
  line-height: 1.4;
}

.inline-message {
  color: var(--ui-warning-ink);
  font-size: var(--ui-font-body);
}

.inline-message:empty {
  display: none;
}

.distance {
  color: var(--ui-brand);
  font-weight: 600;
}

.description {
  color: var(--ui-ink);
  font-size: var(--ui-font-body);
  line-height: 1.65;
  white-space: pre-wrap;
}

.wechat-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ui-brand);
  font-size: var(--ui-font-body);
  line-height: 1.5;
  text-align: left;
}

.wechat-button > span {
  flex-shrink: 0;
  color: var(--ui-brand);
  font-size: var(--ui-font-support);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Search stays attached to the visual viewport above the keyboard. */
.search-sheet {
  top: calc(env(safe-area-inset-top) + 12px);
  bottom: auto;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - env(safe-area-inset-top) - 24px);
  padding: 12px;
  overflow: hidden;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-panel-radius);
}

.search-toolbar {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 6px;
}

#search-form {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.search-field {
  display: flex;
  flex: 1;
  align-items: center;
  min-width: 0;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-control-radius);
  background: var(--ui-surface-muted);
}

.search-field-icon {
  display: block;
  flex: none;
  width: 20px;
  height: 20px;
  margin-left: var(--ui-space-3);
  color: var(--ui-muted);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.search-field:focus-within {
  border-color: var(--ui-brand);
  box-shadow: 0 0 0 3px var(--ui-focus-soft);
}

.search-field input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 8px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ui-ink);
  font-size: var(--ui-font-action);
  line-height: 24px;
}

.search-field input::placeholder {
  color: var(--ui-muted);
  opacity: 1;
}

.search-field input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.search-field button {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ui-muted);
  font-size: 24px;
}

#search-submit {
  min-width: 48px;
  height: 44px;
  padding: 0 6px;
  border: 0;
  border-radius: var(--ui-control-radius);
  background: var(--ui-brand);
  color: var(--ui-on-accent);
  font-size: var(--ui-font-action);
  font-weight: 600;
}

.search-toolbar .close-sheet {
  border-radius: 10px;
}

.sheet .search-status {
  flex-shrink: 0;
  margin: 8px 0;
  color: var(--ui-muted);
  font-size: var(--ui-font-support);
  line-height: 1.5;
}

.search-status[data-loading=true]::before {
  display: inline-block;
  box-sizing: border-box;
  width: 12px;
  height: 12px;
  margin-right: var(--ui-space-2);
  border: 2px solid var(--ui-border);
  border-top-color: var(--ui-brand);
  border-radius: 50%;
  content: "";
  vertical-align: -1px;
  animation: status-spin var(--ui-motion-spinner) linear infinite;
}

.search-results {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.search-result {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 54px;
  padding: 4px 2px;
  border: 0;
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-surface);
  color: var(--ui-ink);
  text-align: left;
}

.search-result:active {
  background: var(--ui-brand-soft);
}

.search-result-icon {
  position: relative;
  display: block;
  flex-shrink: 0;
  width: 36px;
  height: 46px;
}

.search-result-icon .poi-label {
  display: none;
}

.search-result-copy {
  display: grid;
  flex: 1;
  grid-template-columns: minmax(0,1fr) auto;
  align-items: center;
  column-gap: 8px;
  min-width: 0;
}

.search-result-copy strong {
  display: block;
  min-width: 0;
  font-size: var(--ui-font-action);
  font-weight: 700;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.search-result-copy small {
  display: block;
  grid-column: 1 / -1;
  margin: 0;
  color: var(--ui-muted);
  font-size: var(--ui-font-support);
  line-height: 1.5;
}

.search-result-distance {
  color: var(--ui-brand);
  font-size: var(--ui-font-support);
  font-weight: 600;
  line-height: 1.65;
  white-space: nowrap;
}

.search-result-arrow {
  color: var(--ui-muted);
  font-size: 25px;
}

.search-sheet > .secondary-button {
  flex-shrink: 0;
  min-height: 44px;
  margin-top: 8px;
  padding: 8px;
}

.search-direction {
  animation: search-direction-hint 3s linear both;
  pointer-events: none;
}

.search-direction-target {
  border: 0 !important;
  background: none !important;
  pointer-events: none !important;
}

/* Measurement uses the map center and a compact top readout. */
.measure-crosshair {
  position: absolute;
  z-index: 900;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  transform: translate(-50%,-50%);
  filter: drop-shadow(0 0 1px white);
  pointer-events: none;
}

.measure-crosshair::before,
.measure-crosshair::after {
  position: absolute;
  background: #dc2626;
  box-shadow: 0 0 0 1px white;
  content: "";
}

.measure-crosshair::before {
  top: 0;
  left: 14px;
  width: 2px;
  height: 30px;
}

.measure-crosshair::after {
  top: 14px;
  left: 0;
  width: 30px;
  height: 2px;
}

.measure-panel {
  position: absolute;
  z-index: 950;
  top: 12px;
  left: 50%;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  width: calc(100% - 24px);
  max-width: 420px;
  padding: 12px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-panel-radius);
  background: var(--ui-surface);
  color: var(--ui-ink);
  box-shadow: var(--ui-shadow);
  transform: translateX(-50%);
}

.measure-panel > div {
  flex: 1;
  min-width: 0;
}

.measure-panel strong {
  display: block;
  font-size: var(--ui-font-body);
  font-weight: 600;
  line-height: 1.5;
}

.measure-panel strong > span {
  display: block;
}

.measure-panel strong > .measure-value {
  margin-top: 2px;
  color: var(--ui-ink);
  font-size: 30px;
  font-weight: 800;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.measure-panel strong > .measure-status {
  color: var(--ui-muted);
  font-size: var(--ui-font-support);
  font-weight: 400;
}

.measure-panel small {
  display: block;
  margin-top: 4px;
  color: var(--ui-muted);
  font-size: var(--ui-font-support);
  line-height: 1.5;
}

.measure-panel button {
  margin-left: auto;
}

/* Help text and illustrations share the real toolbar icon shapes. */
#help-sheet {
  scroll-padding-top: 80px;
}

#help-sheet p {
  margin: var(--ui-space-3) 0;
  color: var(--ui-ink);
  font-size: var(--ui-font-body);
  line-height: 1.7;
}

#help-sheet .help-intro {
  margin: var(--ui-space-5) 0 var(--ui-space-6);
}

.help-block {
  padding: var(--ui-space-6) 0;
  border-top: 1px solid var(--ui-border-subtle);
}

.help-block h3 {
  margin: 0 0 var(--ui-space-3);
  color: var(--ui-brand-strong);
  font-size: 18px;
  line-height: 1.5;
}

.help-icon-row {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 48px;
  font-size: var(--ui-font-body);
}

.help-location,
.help-heading {
  position: relative;
  display: inline-block;
  flex: none;
  width: 44px;
  height: 44px;
}

.help-location .position-dot {
  top: 13px;
  left: 13px;
}

.help-tool {
  display: inline-flex;
  width: 27px;
  height: 27px;
  margin: 0 4px;
  color: var(--ui-brand);
  vertical-align: middle;
}

.help-tool svg {
  width: 100%;
  height: 100%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.help-function {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: var(--ui-space-4) 0;
  border-bottom: 1px solid var(--ui-border-subtle);
}

.help-function:last-child {
  border-bottom: 0;
}

.help-function > div {
  min-width: 0;
}

.help-tool-sample {
  flex: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 52px;
  height: 52px;
  margin: 0;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-control-radius);
  background: var(--ui-surface);
}

.help-tool-sample svg {
  order: -1;
  flex: none;
  width: 22px;
  height: 22px;
}

.help-tool-label {
  font-size: 14px;
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
}

.help-function h4 {
  margin: 0;
  color: var(--ui-ink);
  font-size: 18px;
  line-height: 1.4;
}

#help-sheet .help-function p {
  margin: 6px 0 0;
}

.help-heat-example {
  display: block;
  width: 100%;
  height: auto;
  margin: 8px 0;
}

.help-legend-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-control-radius);
  background: var(--ui-brand-soft);
  color: var(--ui-brand);
  font-size: var(--ui-font-action);
  font-weight: 600;
}

#help-legend-items {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 8px;
  padding-top: 14px;
}

.help-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  color: var(--ui-ink);
  font-size: var(--ui-font-action);
}

.help-poi-icon {
  position: relative;
  display: block;
  flex: none;
  width: 36px;
  height: 46px;
}

.help-poi-icon .poi-label {
  display: none;
}

#help-sheet .help-secondary {
  color: var(--ui-muted);
  font-size: var(--ui-font-support);
}

#help-network {
  scroll-margin-top: 80px;
}

#help-sheet .help-network-warning {
  margin: var(--ui-space-4) 0;
  padding: var(--ui-space-4);
  border: 1px solid var(--ui-warning-border-soft);
  border-radius: var(--ui-group-radius);
  background: var(--ui-warning-soft);
}

.help-network-warning h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ui-warning-ink);
}

#help-sheet .help-network-warning p {
  color: var(--ui-warning-ink);
  font-family: inherit;
  font-size: var(--ui-font-body);
  line-height: 1.7;
}

.help-network-warning h3 svg {
  flex: none;
  width: 23px;
  height: 23px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Safety acknowledgement and the later offline-map reminder. */
.safety-sheet {
  top: 50%;
  bottom: auto;
  width: calc(100% - 32px);
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  padding: 20px;
  border: 1px solid var(--ui-warning-border);
  border-radius: var(--ui-panel-radius);
  transform: translate(-50%,-50%);
}

.safety-sheet h2,
.help-safety h3 {
  color: var(--ui-warning-ink);
}

.safety-copy ol {
  margin: 12px 0;
  padding-left: 1.5em;
}

.safety-copy li {
  margin: 10px 0;
  color: var(--ui-ink);
  font-size: var(--ui-font-body);
  line-height: 1.65;
}

.help-safety {
  margin-top: var(--ui-space-5);
  padding: var(--ui-space-4);
  border: 1px solid var(--ui-warning-border-soft);
  border-radius: var(--ui-group-radius);
  background: var(--ui-warning-soft);
}

.help-safety h3 {
  margin: 0;
  font-size: 18px;
}

.help-safety .safety-copy ol {
  margin: 8px 0;
  padding-left: 1.5em;
}

.help-safety .safety-copy li {
  margin: 8px 0;
  font-size: 16px;
  line-height: 1.6;
}

.cache-reminder-sheet p {
  color: var(--ui-ink);
  font-size: var(--ui-font-body);
  line-height: 1.65;
}

.cache-reminder-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  margin: 12px 0;
  font-size: var(--ui-font-body);
}

.cache-reminder-option input {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  accent-color: var(--ui-brand);
}

#safety-sheet {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  padding: 18px;
  overflow: hidden;
}

#safety-sheet h2 {
  flex-shrink: 0;
  margin: 0 0 8px;
}

#safety-sheet .safety-copy {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

#safety-sheet ol {
  margin: 0;
  padding-left: 1.4em;
}

#safety-sheet li {
  margin: 6px 0;
  font-size: 17px;
  line-height: 1.45;
}

#safety-sheet .safety-reminder-option {
  flex-shrink: 0;
  min-height: 44px;
  margin: 6px 0 0;
}

#safety-sheet .primary-button {
  flex-shrink: 0;
  margin-top: 10px;
}

#safety-sheet .primary-button:disabled {
  cursor: wait;
}

/* Permission recovery retains the device-specific instruction order. */
.authorization-sheet .inline-message {
  margin: 16px 0;
  color: var(--ui-ink);
  font-size: var(--ui-font-body);
  line-height: 1.65;
}

.authorization-sheet .guide-intro {
  font-size: var(--ui-font-body);
  line-height: 1.6;
}

.guide-card {
  margin: 0;
  padding: 16px 0;
  border-top: 1px solid var(--ui-border-subtle);
}

.guide-card h3 {
  margin: 0 0 10px;
  color: var(--ui-brand-strong);
  font-size: var(--ui-font-body);
  line-height: 1.5;
}

.settings-diagram {
  margin: 0;
  padding: 0 0 0 24px;
  list-style: decimal;
}

.settings-diagram li {
  padding: 6px 0;
  font-size: var(--ui-font-body);
  line-height: 1.6;
}

.sheet .guide-caption {
  margin: 9px 0 0;
  color: var(--ui-muted);
  font-size: var(--ui-font-support);
  line-height: 1.6;
}

.guide-image {
  display: block;
  width: 100%;
  height: auto;
  max-width: 360px;
  margin: 10px auto;
  border-radius: 8px;
}

.guide-step-image {
  position: relative;
  width: 100%;
  height: 0;
  margin: 8px 0 12px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--ui-surface-muted);
}

.guide-step-image .guide-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  max-width: none;
  height: auto;
  margin-bottom: 0;
  border-radius: 0;
}

.guide-return {
  padding: 12px 0;
  color: var(--ui-ink);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.6;
}

/* Contact identity and the donation reading flow. */
.contact-sheet p {
  font-size: var(--ui-font-body);
  line-height: 1.7;
}

.contact-lead {
  white-space: nowrap;
}

.contact-sheet .wechat-button {
  display: flex;
  align-items: center;
  gap: var(--ui-space-3);
  width: 100%;
  min-height: 80px;
  margin-top: var(--ui-space-5);
  padding: var(--ui-space-4);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-group-radius);
  background: var(--ui-surface-muted);
}

.contact-sheet .contact-account {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: var(--ui-space-1);
  min-width: 0;
  color: var(--ui-ink);
  text-decoration: none;
}

.contact-account strong {
  font-size: var(--ui-font-body);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.contact-handle {
  display: block;
  color: var(--ui-brand);
  font-size: var(--ui-font-action);
  overflow-wrap: anywhere;
  user-select: all;
  -webkit-user-select: all;
}

.contact-sheet .contact-copy-action {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  padding: 0 var(--ui-space-3);
  border-radius: var(--ui-control-radius);
  background: var(--ui-brand);
  color: var(--ui-on-accent);
  font-size: var(--ui-font-action);
  font-weight: 600;
  text-decoration: none;
}

#donate-sheet {
  max-height: calc(100vh - 24px);
  max-height: calc(100dvh - 24px - env(safe-area-inset-top));
}

#donate-sheet p {
  margin: 12px 0;
  font-size: var(--ui-font-body);
  line-height: 1.6;
}

#donate-payment {
  margin: var(--ui-space-5) 0;
  padding: var(--ui-space-4);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-group-radius);
  background: var(--ui-on-accent);
  text-align: center;
}

.donate-qr-frame {
  width: 180px;
  max-width: 100%;
  margin: 12px auto;
  overflow: hidden;
  aspect-ratio: 1;
  background: var(--ui-on-accent);
}

#donate-qr {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
  background: var(--ui-on-accent);
  -webkit-touch-callout: default;
  user-select: auto;
}

#donate-payment .donate-instructions {
  color: var(--ui-muted);
  font-size: var(--ui-font-support);
  line-height: 1.65;
}

#donate-unavailable {
  position: relative;
  width: 180px;
  max-width: 100%;
  margin: 12px auto;
  text-align: center;
}

.donate-placeholder {
  display: block;
  width: 100%;
  height: auto;
  margin: 0;
}

.donate-placeholder-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ui-muted);
  font-size: var(--ui-font-support);
}

.donate-emphasis {
  text-align: center;
}

#donate-sheet .donate-thanks {
  padding-top: var(--ui-space-4);
  border-top: 1px solid var(--ui-border-subtle);
  color: var(--ui-muted);
  font-size: var(--ui-font-action);
}

.donate-thanks-emoji {
  display: inline-block;
  margin-left: var(--ui-space-1);
  font-size: 18px;
  line-height: 1;
  vertical-align: -1px;
}

/* Geographic POI tips remain at (18,44) inside a 36 by 46 marker. */
.poi-marker,
.poi-cluster {
  border: 0 !important;
  background: none !important;
}

.poi-pin {
  position: relative;
  display: block;
  width: 36px;
  height: 46px;
  border: 0;
  border-radius: 0;
  background: none;
  color: #475569;
  filter: drop-shadow(0 2px 2px #0009);
}

.poi-pin svg {
  width: 36px;
  height: 46px;
  fill: currentColor;
  stroke: #fff;
  stroke-width: 2;
  stroke-linejoin: round;
}

.poi-pin span {
  position: absolute;
  top: 2px;
  left: 0;
  width: 36px;
  color: #fff;
  font-size: 14px;
  font-weight: 850;
  line-height: 32px;
  text-align: center;
  text-shadow: 0 1px 1px #0006;
}

.poi-start {
  color: #166534;
}

.poi-junction {
  color: #7c3aed;
}

.poi-danger {
  color: #b91c1c;
}

.poi-cliff {
  color: #991b1b;
}

.poi-cave {
  color: #6b5678;
}

.poi-checkpoint {
  color: #334155;
}

.poi-water {
  color: #0e7490;
}

.poi-level1 {
  color: #737373;
}

.poi-level2 {
  color: #64748b;
}

.poi-level3 {
  color: #2563eb;
}

.poi-level4 {
  color: #c2410c;
}

.poi-level5 {
  color: #db2777;
}

.poi-label,
.cluster-label {
  position: absolute;
  top: -36px;
  left: 50%;
  max-width: 180px;
  padding: 2px 8px;
  overflow: hidden;
  border: 1px solid #c1b597;
  border-radius: 5px;
  background: #fff4da;
  color: #243746;
  box-shadow: 0 1px 3px #0003;
  font-size: 16px;
  font-weight: 700;
  line-height: 24px;
  white-space: nowrap;
  text-overflow: ellipsis;
  transform: translateX(-50%);
  cursor: pointer;
  pointer-events: auto;
}

.poi-label.label-suppressed,
.cluster-label.label-suppressed {
  visibility: hidden;
  pointer-events: none;
}

.cluster-count {
  position: absolute;
  top: -6px;
  right: -9px;
  min-width: 21px;
  height: 21px;
  padding: 0 4px;
  border: 2px solid #18382b;
  border-radius: 11px;
  background: #fff;
  color: #142b22;
  box-shadow: 0 1px 3px #0007;
  font-size: 11px;
  font-weight: 800;
  line-height: 17px;
  text-align: center;
}

.cluster-item {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 14px 2px;
  border: 0;
  border-bottom: 1px solid var(--ui-border);
  background: var(--ui-surface);
  color: var(--ui-ink);
  font-size: var(--ui-font-body);
  text-align: left;
}

.cluster-item span {
  display: block;
  margin-top: 2px;
  color: var(--ui-muted);
  font-size: var(--ui-font-support);
}

/* Position and heading preserve their high-contrast geographic marker. */
.position-icon {
  border: 0;
  background: none;
  pointer-events: none !important;
}

.position-ring {
  position: absolute;
  inset: 1px;
  border: 2px solid #ff3030;
  border-radius: 50%;
  background: transparent;
  pointer-events: none;
}

.position-north {
  position: absolute;
  top: -12px;
  left: 18px;
  width: 12px;
  background: none;
  color: #ff3030;
  font-size: 14px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
  text-shadow: -1px -1px 0 white,1px -1px 0 white,-1px 1px 0 white,1px 1px 0 white;
}

.position-dot {
  position: absolute;
  z-index: 2;
  top: 17px;
  left: 17px;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: #0066ff;
  box-shadow: 0 0 0 1px #10233f;
}

.position-arrow {
  position: absolute;
  z-index: 1;
  inset: 0;
  width: 48px;
  height: 48px;
  transform-origin: 24px 24px;
}

.position-arrow svg {
  width: 48px;
  height: 48px;
}

.position-icon.stale .position-dot {
  background: #777;
}

.position-arrow.held-heading {
  opacity: .6;
}

.position-icon.sensor-retrying .position-ring {
  border-style: dashed;
}

/* POI photographs and the full-screen viewer. */
.photo-gallery {
  display: flex;
  gap: 10px;
  padding: 16px 0 6px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.photo-card {
  position: relative;
  flex: 0 0 88%;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-group-radius);
  background: var(--ui-surface-muted);
  color: var(--ui-ink);
  scroll-snap-align: start;
}

.photo-card:only-child {
  flex-basis: 100%;
}

.photo-card .photo-crop {
  height: 220px;
  aspect-ratio: auto !important;
}

.photo-crop {
  position: relative;
  display: block;
  width: 100%;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  background: var(--ui-photo-placeholder);
}

.photo-crop img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-label {
  display: block;
  padding: 8px;
  font-size: var(--ui-font-support);
  line-height: 1.5;
}

.photo-error {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  color: var(--ui-brand);
}

.photo-crop.photo-pending::before,
.photo-stage[aria-busy=true]:empty::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 42px;
  height: 34px;
  background: center/contain no-repeat url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='42' height='34' viewBox='0 0 42 34'%3E%3Cg fill='none' stroke='%2383938a' stroke-width='2'%3E%3Crect x='2' y='2' width='38' height='30' rx='4'/%3E%3Ccircle cx='13' cy='11' r='3'/%3E%3Cpath d='m3 27 10-10 7 6 7-10 12 14'/%3E%3C/g%3E%3C/svg%3E");
  content: "";
  transform: translate(-50%,-50%);
  pointer-events: none;
}

.photo-viewer {
  position: fixed;
  z-index: 3000;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
  background: var(--ui-photo-surface);
  color: var(--ui-on-accent);
}

.photo-toolbar,
.photo-navigation {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
}

.photo-viewer button {
  min-width: 44px;
  min-height: 44px;
  padding: 6px 17px;
  border: 1px solid var(--ui-photo-border);
  border-radius: var(--ui-control-radius);
  background: var(--ui-photo-control);
  color: var(--ui-on-accent);
  font-size: var(--ui-font-action);
}

.photo-toolbar button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
}

#photo-count {
  font-size: var(--ui-font-action);
  font-variant-numeric: tabular-nums;
}

.photo-stage {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
}

.photo-stage .photo-crop {
  flex-shrink: 0;
  width: auto;
  height: 100%;
  max-width: 720px;
  max-height: 100%;
  transform-origin: center center;
}

.photo-stage img {
  object-fit: fill;
  user-select: none;
  -webkit-user-drag: none;
}

.photo-navigation {
  justify-content: center;
}

.photo-load-status {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 50%;
  max-width: calc(100% - 32px);
  transform: translate(-50%,-50%);
}

.photo-viewer .photo-load-status {
  font-size: var(--ui-font-support);
}

.photo-load-status:disabled {
  color: var(--ui-photo-muted);
  opacity: 1;
}

/* Pro-mode filters and route navigation keep the center-bottom area available. */
.publicity-tracks-canvas {
  position: absolute;
  pointer-events: none;
}

#publicity-button[aria-pressed=true]:not(:disabled) {
  border: 2px solid var(--ui-volunteer);
  background: var(--ui-volunteer-soft);
  color: var(--ui-volunteer);
}

.publicity-panel {
  top: 50%;
  bottom: auto;
  display: flex;
  flex-direction: column;
  width: min(360px,calc(100% - 32px));
  max-height: 80vh;
  max-height: 80dvh;
  padding: 0 16px 16px;
  overflow: hidden;
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-panel-radius);
  transform: translate(-50%,-50%);
}

.publicity-panel > .sheet-top {
  flex-shrink: 0;
  margin-bottom: 12px;
}

.publicity-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 0;
}

.publicity-options label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 8px;
  border: 1px solid var(--ui-border);
  border-radius: 10px;
  background: var(--ui-surface-muted);
  color: var(--ui-ink);
  font-size: var(--ui-font-body);
  white-space: nowrap;
  cursor: pointer;
}

.publicity-options input {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--ui-volunteer);
}

.publicity-options label:has(input:checked) {
  border-color: var(--ui-volunteer);
  background: var(--ui-volunteer-soft);
}

.publicity-empty {
  flex-shrink: 0;
  margin: 12px 0 0;
  color: var(--ui-muted);
  font-size: var(--ui-font-action);
}

.publicity-navigation {
  position: absolute;
  z-index: 800;
  bottom: calc(60px + env(safe-area-inset-bottom));
  left: 50%;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 2px;
  width: min(264px,calc(100% - 152px));
  padding: var(--ui-space-1);
  border: 1px solid var(--ui-border);
  border-radius: var(--ui-group-radius);
  background: var(--ui-surface-control);
  color: var(--ui-ink);
  box-shadow: var(--ui-shadow);
  transform: translateX(-50%);
}

.publicity-navigation button {
  min-width: 0;
  min-height: 44px;
  padding: 4px 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ui-ink);
  font-size: var(--ui-font-action);
  font-weight: 600;
  white-space: nowrap;
}

.publicity-navigation button:disabled {
  background: var(--ui-disabled-surface);
  color: var(--ui-disabled-ink);
}

.publicity-navigation button:not(:disabled):active {
  background: var(--ui-brand-soft);
}

.publicity-navigation span {
  min-width: 42px;
  font-size: var(--ui-font-support);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  white-space: nowrap;
}

/* Responsive rules are grouped to keep each component's base styles clear. */
@media (min-width:700px) {
  .sheet {
    bottom: 24px;
    border-bottom: 1px solid var(--ui-border);
    border-radius: var(--ui-panel-radius);
  }

  .search-sheet,
  .safety-sheet,
  .publicity-panel {
    bottom: auto;
  }

}

@media (max-width:360px) {
  .topbar {
    gap: 4px;
    padding-right: 8px;
    padding-left: 8px;
  }

  .topbar h1 {
    font-size: 15px;
  }

  .brand-icon {
    width: 30px;
    height: 30px;
  }

  .sheet {
    padding-right: 16px;
    padding-left: 16px;
  }

  .search-sheet {
    padding-right: 10px;
    padding-left: 10px;
  }

  .contact-sheet .wechat-button {
    gap: 8px;
    padding: 10px;
  }

}

@media (max-width:340px) {
  .help-legend-item {
    gap: 5px;
    font-size: var(--ui-font-support);
  }

}

@media (max-height:700px) {
  .donate-qr-frame {
    width: 160px;
    margin: 6px auto;
  }

  #donate-sheet {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }

  #donate-sheet p {
    margin: 6px 0;
  }

  #donate-payment {
    margin: 12px 0;
    padding: 10px;
  }

}

@media (max-height:600px) {
  #safety-sheet {
    padding: 14px;
  }

  #safety-sheet li {
    margin: 5px 0;
    font-size: 16px;
    line-height: 1.4;
  }

}

@media (max-height:520px) {
  :root {
    --ui-control-size: 48px;
  }

  .map-actions {
    bottom: calc(8px + env(safe-area-inset-bottom));
  }

  .map-button {
    gap: 1px;
    padding: 2px 0;
  }

  .layers-panel {
    padding-right: 12px;
    padding-bottom: 12px;
    padding-left: 12px;
  }

  .sheet-top {
    padding-top: 10px;
    padding-bottom: 8px;
  }

  .photo-toolbar,
  .photo-navigation {
    padding: 8px 0;
  }

}

@media (orientation:landscape) and (max-height:500px) {
  .topbar {
    height: 44px;
  }

  .brand-icon {
    width: 30px;
    height: 30px;
  }

  .map-button-label {
    font-size: 13px;
    line-height: 17px;
  }

  .locate-entry-group {
    bottom: calc(46px + env(safe-area-inset-bottom));
    flex-direction: row;
    justify-content: center;
    gap: 10px;
    max-width: 470px;
  }

  .locate-entry {
    flex: none;
    max-width: 180px;
  }

  .auto-center-notice {
    top: 6px;
    padding: 6px 12px;
    font-size: var(--ui-font-action);
  }

  body:has(#contact-sheet:not([hidden])) .toast {
    top: calc(56px + env(safe-area-inset-top));
  }

}

@media (orientation:landscape) and (min-width:600px) {
  #safety-sheet {
    max-width: 760px;
  }

  #safety-sheet ol {
    columns: 2;
    column-gap: 30px;
  }

  #safety-sheet li {
    break-inside: avoid;
  }

}

@media (max-height:450px) {
  .welcome-guide {
    padding: 7px 18px;
    font-size: 17px;
    line-height: 1.45;
  }

  .welcome-symbol {
    display: none;
  }

}

@media (orientation:landscape) and (max-height:360px) {
  .map-actions {
    max-height: calc(100dvh - 84px);
  }

}

/* Motion follows the existing timers and page-visibility state. */
@keyframes panel-appear {
  from {
    opacity: .01;
  }

  to {
    opacity: 1;
  }
}

@keyframes status-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes donation-heartbeat {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.12);
  }

}

@keyframes entry-intro {
  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.045);
  }

}

@keyframes entry-halo {
  0%,
  38%,
  100% {
    transform: scale(1);
    box-shadow: var(--ui-entry-halo-rest);
  }

  12% {
    transform: scale(1.06);
    box-shadow: var(--ui-entry-halo-peak);
  }

  24% {
    transform: scale(1.035);
    box-shadow: var(--ui-entry-halo-fade);
  }

  37.5% {
    transform: scale(1);
    box-shadow: var(--ui-entry-halo-end);
  }

}

@keyframes search-direction-hint {
  0% {
    opacity: 0;
  }

  7%,
  88% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }

}

@media (prefers-reduced-motion:reduce) {
  #donate-button.donation-pulsing svg,
  .search-direction,
  .locate-entry.attention,
  .locate-entry.attention.attention-intro,
  .sheet:not([hidden]),
  .layers-panel:not([hidden]),
  .measure-panel:not([hidden]),
  .sheet-backdrop:not([hidden]),
  .search-status[data-loading=true]::before {
    animation: none;
  }

  .locate-entry.attention {
    outline: 3px solid var(--ui-focus-reduced);
    outline-offset: 3px;
  }

  button,
  .toggle-row input::before,
  .welcome-guide {
    transition: none;
  }

  button:not(:disabled):active {
    scale: 1;
  }

}

.page-suspended *,
.page-suspended *::before,
.page-suspended *::after {
  animation-play-state: paused !important;
}
