#fullmap-modal .fullmap-header { anchor-name: --hk-atlas-header; }

.hk-venue-atlas {
  --venue-paper: #f9efd9;
  --venue-ink: #2d2721;
  --venue-line: #a5957a;
  --venue-jade: #21675f;
  position: absolute;
  z-index: 3;
  top: 86px;
  bottom: 84px;
  left: max(16px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  pointer-events: none;
  color: var(--venue-ink);
  font: 600 13px/1.4 system-ui, sans-serif;
}
.hk-venue-atlas > * { pointer-events: auto; }
.hk-venue-toggle { flex-shrink: 0; }

.hk-venue-atlas .hk-venue-toggle,
.hk-venue-panel button,
.hk-venue-panel input[type='search'],
.hk-venue-panel select {
  box-sizing: border-box;
  min-height: 44px;
  max-width: 100%;
  padding: 6px 10px;
  color: var(--venue-ink);
  background: #efe2c8;
  border: 1px solid var(--venue-line);
  border-radius: 7px;
  font: inherit;
}
.hk-venue-atlas button { cursor: pointer; }
.hk-venue-atlas button:disabled { cursor: default; opacity: .55; }
.hk-venue-atlas .hk-venue-toggle[aria-expanded='true'],
#hk-venue-route:not(:disabled) {
  color: #fff9ea;
  background: var(--venue-jade);
  border-color: var(--venue-jade);
}
.hk-venue-atlas :is(button, a, input, select, [tabindex]):focus-visible {
  outline: 2px solid #155c55;
  outline-offset: 2px;
}

.hk-venue-panel {
  box-sizing: border-box;
  width: min(370px, calc(100vw - 86px));
  max-height: min(66dvh, calc(100dvh - 150px));
  min-height: 0;
  margin-top: 6px;
  padding: 12px;
  overflow: auto;
  overscroll-behavior: contain;
  color: var(--venue-ink);
  background: var(--venue-paper);
  border-color: var(--venue-line);
  touch-action: pan-y;
}
.hk-venue-panel [hidden] { display: none; }
.hk-venue-panel h3, .hk-venue-panel h4 { margin: 0; font-size: 15px; line-height: 1.25; }
.hk-venue-panel p { margin: 4px 0; }
.hk-venue-layers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 3px;
  min-inline-size: 0;
  margin: 9px 0;
  padding: 5px;
  border: 1px solid var(--venue-line);
  border-radius: 8px;
}
.hk-venue-layers legend { padding-inline: 5px; font-size: 12px; }
.hk-venue-layers label {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  font-size: 12px;
  overflow-wrap: anywhere;
  cursor: pointer;
}
.hk-venue-layers small { display: block; color: #65533e; }
.hk-venue-layers input { accent-color: var(--venue-jade); }
.hk-venue-key {
  display: inline-grid;
  flex: 0 0 17px;
  height: 17px;
  place-items: center;
  border-radius: 50%;
  background: var(--venue-ink);
  color: #17232d;
  border: 1px solid #17232d;
  font-size: 10px;
}
.hk-venue-area, .hk-venue-actions, .hk-venue-detail-head {
  display: flex;
  align-items: center;
  gap: 6px;
}
.hk-venue-area, .hk-venue-actions { flex-wrap: wrap; }
.hk-venue-search { display: grid; gap: 3px; margin-top: 8px; }
.hk-venue-search input { width: 100%; }
#hk-venue-status, #hk-venue-source, #hk-venue-address { color: #64513e; font-size: 12px; }
#hk-venue-source[href] { display: inline-flex; align-items: center; min-height: 44px; }
#hk-venue-detail { margin-block: 8px; padding: 9px; border: 1px solid var(--venue-line); border-radius: 8px; }
.hk-venue-detail-head { justify-content: space-between; }
#hk-venue-detail-close { flex: 0 0 44px; padding: 0; font-size: 19px; }
.hk-venue-actions { margin-top: 6px; }
#hk-venue-results { display: grid; gap: 4px; margin: 7px 0 0; padding: 0; list-style: none; }
#hk-venue-results button { width: 100%; text-align: left; }
#hk-venue-dseek { display: inline-flex; align-items: center; min-height: 44px; color: #14574d; underline-offset: 3px; }

@media (max-width: 620px) {
  .hk-venue-atlas {
    top: calc(max(0px, env(safe-area-inset-top)) + 182px);
    bottom: calc(max(0px, env(safe-area-inset-bottom)) + 160px);
    left: max(8px, env(safe-area-inset-left));
  }
  #fullmap-modal .hk-address-results { top: max(182px, calc(env(safe-area-inset-top) + 182px)); }
  #hud-toolbar.street-hud-toolbar--shared { gap: 2px; padding: 3px; }
  #hud-toolbar #hk-challenges-button,
  #hud-toolbar #btn-toggle-hud[aria-pressed='false'] { font-size: 0; }
  #hud-toolbar #hk-challenges-button::after { content: '挑戰'; }
  #hud-toolbar #btn-toggle-hud[aria-pressed='false']::after { content: '介面'; }
  #hud-toolbar #hk-challenges-button::after,
  #hud-toolbar #btn-toggle-hud[aria-pressed='false']::after { font-size: 12px; }
}

@supports (top: anchor(--hk-atlas-header bottom)) {
  .hk-venue-atlas, #fullmap-modal .hk-address-results { top: calc(anchor(--hk-atlas-header bottom) + 8px); }
}

@supports (bottom: anchor(--hk-atlas-legend top)) {
  #fullmap-modal .fullmap-legend { anchor-name: --hk-atlas-legend; }
  .hk-venue-atlas { bottom: calc(anchor(--hk-atlas-legend top, 152px) + 8px); }
}

@media (max-height: 520px) {
  .hk-venue-atlas { bottom: max(8px, env(safe-area-inset-bottom)); }
}
