.world-map {
  position: relative;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #151918;
  color: var(--text);
}

.world-map__toolbar {
  position: absolute;
  z-index: 3;
  top: 0.7rem;
  right: 0.7rem;
  display: block;
  pointer-events: none;
}

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

.world-map__tools {
  display: flex;
  flex: 0 0 auto;
  gap: 0.42rem;
  pointer-events: auto;
}

.world-map__tools button {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(43, 49, 47, 0.92);
  color: #eef4f1;
  font: inherit;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.world-map__tool-icon {
  width: 0.95rem;
  height: 0.95rem;
  display: block;
}

.world-map__tools button:hover,
.world-map__tools button:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.world-map__viewport {
  position: relative;
  height: min(72vh, 760px);
  min-height: 420px;
  overflow: hidden;
  background: #0d1110;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.world-map__viewport.is-dragging {
  cursor: grabbing;
}

.world-map--static .world-map__viewport {
  cursor: default;
  touch-action: auto;
}

.world-map__world {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.world-map__image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

.world-map__canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.world-map__image {
  object-fit: fill;
  pointer-events: none;
}

.entity-view-switch {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(5rem, 1fr));
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-table);
  overflow: hidden;
}

.entity-view-switch button {
  min-height: 2.35rem;
  padding: 0.4rem 0.9rem;
  border: 0;
  border-right: 1px solid var(--border);
  background: #252a28;
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
}

.entity-view-switch button:last-child {
  border-right: 0;
}

.entity-view-switch button.is-active {
  background: rgba(43, 217, 139, 0.13);
  color: var(--accent);
  font-weight: 700;
}

.entity-map-section {
  position: relative;
  margin-top: 1.35rem;
}

.entity-map-section[hidden] {
  display: none;
}

.entity-page-panel.is-entity-map-view > :not(.entity-header):not(.entity-view-switch):not(.entity-map-section):not(.quest-detail-shell),
.page-panel.is-entity-map-view > :not(.entity-header):not(.entity-view-switch):not(.entity-map-section):not(.quest-detail-shell) {
  display: none;
}

.entity-page-panel.is-entity-map-view .quest-detail-shell,
.entity-page-panel.is-entity-map-view .quest-detail-shell.is-map-open,
.page-panel.is-entity-map-view .quest-detail-shell,
.page-panel.is-entity-map-view .quest-detail-shell.is-map-open {
  display: block;
}

.entity-page-panel.is-entity-map-view .quest-detail-content > :not(.entity-header):not(.entity-view-switch),
.entity-page-panel.is-entity-map-view .quest-map-drawer,
.page-panel.is-entity-map-view .quest-detail-content > :not(.entity-header):not(.entity-view-switch),
.page-panel.is-entity-map-view .quest-map-drawer {
  display: none;
}

.entity-map-steps {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  padding: 0 0 0.65rem;
  scrollbar-width: none;
}

.entity-map-steps::-webkit-scrollbar {
  display: none;
}

.entity-map-steps button {
  flex: 0 0 auto;
  min-height: 2.2rem;
  padding: 0.4rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #252a28;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.84rem;
  cursor: pointer;
}

.entity-map-steps button.is-active {
  border-color: rgba(43, 217, 139, 0.55);
  color: var(--accent);
}

.entity-world-map .world-map__viewport {
  height: min(68vh, 700px);
}

.entity-map-context {
  position: absolute;
  z-index: 8;
  top: 3.1rem;
  right: 0.75rem;
  display: grid;
  width: min(310px, calc(100% - 1.5rem));
  gap: 0.5rem;
}

.entity-map-context[hidden] {
  display: none;
}

.entity-map-context__card {
  position: relative;
  padding: 0.8rem;
  border: 1px solid rgba(43, 217, 139, 0.35);
  border-radius: 5px;
  background: rgba(7, 18, 12, 0.94);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(10px);
}

.entity-map-context__card--npc {
  border-color: rgba(255, 194, 71, 0.38);
}

.entity-map-context__eyebrow,
.entity-map-context__card h2,
.entity-map-context__card p {
  margin: 0;
}

.entity-map-context__eyebrow {
  color: var(--accent);
  font-size: 0.7rem;
}

.entity-map-context__card h2 {
  margin-top: 0.25rem;
  font-size: 1rem;
}

.entity-map-context__card > p:not(.entity-map-context__eyebrow) {
  margin-top: 0.4rem;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.45;
}

.entity-map-context__npc {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin-top: 0.35rem;
}

.entity-map-context__npc img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.entity-map-context__npc p {
  margin-top: 0.1rem;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.entity-map-context__card > a {
  display: inline-block;
  margin-top: 0.55rem;
  color: var(--accent);
  font-size: 0.78rem;
}

.entity-map-context__close {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #202724;
  color: var(--text-muted);
  font: inherit;
  cursor: pointer;
}

.layout--quest-map-open,
.layout--npc-map-open {
  max-width: var(--content-wide-table);
}

/* post/quest 页在 layout--wide 上：地图打开时同样放宽版心 */
.layout.layout--wide.layout--quest-map-open {
  max-width: min(100%, var(--content-wide-table));
}

/* guide-nav（任务链 TOC）开地图：外框保持全宽，勿被上面的 max-width 收窄 */
.layout.layout--guide-nav.layout--quest-map-open {
  max-width: none;
}

.quest-detail-shell {
  min-width: 0;
}

.quest-detail-shell.is-map-open {
  display: grid;
  /* 在既有正文轴内对切，勿用过大 minmax 撑破版心 */
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 0.85rem;
  align-items: start;
}

.quest-detail-shell.is-map-open > .quest-detail-content {
  min-width: 0;
}

/* 旁挂地图时属性/奖励改单列，避免半宽里挤成碎卡片 */
.quest-detail-shell.is-map-open .quest-property-stats,
.quest-detail-shell.is-map-open .quest-reward-groups {
  grid-template-columns: 1fr;
}

.quest-detail-content {
  min-width: 0;
}

.quest-map-drawer {
  position: sticky;
  z-index: 20;
  top: var(--gutter-sticky-top, 1rem);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: calc(100vh - var(--gutter-sticky-top, 1rem) - 1rem);
  min-height: 28rem;
  overflow: hidden;
  border: 1px solid rgba(51, 255, 167, 0.28);
  border-radius: var(--radius);
  background: #101513;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32);
}

.quest-map-drawer[hidden] {
  display: none;
}

.quest-map-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.25rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  background: #161c1a;
}

.quest-map-drawer__header p,
.quest-map-drawer__header h2 {
  margin: 0;
}

.quest-map-drawer__header p {
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.quest-map-drawer__header h2 {
  margin-top: 0.1rem;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.3;
}

.quest-map-drawer__close {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: #252d2a;
  color: var(--text-muted);
  font: inherit;
  font-size: 1.25rem;
  cursor: pointer;
}

.quest-map-drawer__close:hover,
.quest-map-drawer__close:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.quest-map-drawer__map {
  min-height: 0;
  border: 0;
}

.quest-map-drawer__map .world-map__viewport {
  height: 100%;
  min-height: 0;
}

.npc-map-drawer {
  position: sticky;
  z-index: 20;
  top: var(--gutter-sticky-top, 1rem);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: 100%;
  height: calc(100vh - var(--gutter-sticky-top, 1rem) - 1rem);
  min-height: 28rem;
  overflow: hidden;
  border: 1px solid rgba(51, 255, 167, 0.28);
  border-radius: var(--radius);
  background: #101513;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32);
  animation: npc-map-drawer-in 0.2s ease-out;
}

.npc-map-drawer[hidden] {
  display: none;
}

.npc-map-drawer__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 3.25rem;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  background: #161c1a;
}

.npc-map-drawer__header p,
.npc-map-drawer__header h2 {
  margin: 0;
}

.npc-map-drawer__header p {
  color: var(--accent);
  font-size: 0.68rem;
  font-weight: 800;
}

.npc-map-drawer__header h2 {
  margin-top: 0.12rem;
  font-size: 1rem;
}

.npc-map-drawer__close {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: #252d2a;
  color: var(--text-muted);
  font: inherit;
  font-size: 1.25rem;
  cursor: pointer;
}

.npc-map-drawer__close:hover,
.npc-map-drawer__close:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.npc-map-drawer__map {
  min-height: 0;
  border: 0;
}

.npc-map-drawer__map .world-map__viewport {
  height: 100%;
  min-height: 0;
}

@keyframes npc-map-drawer-in {
  from {
    opacity: 0;
    transform: translateX(1.5rem);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (max-width: 900px) {
  .quest-detail-shell.is-map-open {
    display: block;
  }

  .quest-map-drawer {
    position: fixed;
    z-index: 300;
    inset: 12vh 0 0;
    width: 100%;
    height: auto;
    min-height: 0;
    border: 0;
    border-top: 1px solid rgba(43, 217, 139, 0.35);
    border-radius: 0;
    box-shadow: 0 -18px 48px rgba(0, 0, 0, 0.6);
  }

  .npc-map-drawer {
    position: fixed;
    z-index: 300;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    border: 0;
    border-radius: 0;
    box-shadow: -18px 0 48px rgba(0, 0, 0, 0.6);
  }

  body.has-npc-map-drawer {
    overflow: hidden;
  }
}

@media (max-width: 720px) {
  .world-map__viewport,
  .entity-world-map .world-map__viewport {
    height: 64vh;
    min-height: 390px;
  }

  .entity-map-context {
    top: auto;
    right: 0.55rem;
    bottom: 0.55rem;
    left: 0.55rem;
    width: auto;
    max-height: 48%;
    overflow-y: auto;
  }

  .quest-map-drawer {
    border-left: 0;
  }

  .npc-map-drawer__header {
    padding-top: max(0.72rem, env(safe-area-inset-top));
  }
}
