/* 世界地圖 */
body[data-page="worldmap"] .al2-footer { display: none; }
.wm { display: grid; grid-template-columns: minmax(0, 1fr) 440px; height: calc(100vh - 65px); min-height: 520px; border-top: 1px solid var(--line); }
.wm__stage { position: relative; overflow: hidden; background:
  radial-gradient(circle at 30% 20%, var(--glow), transparent 50%),
  repeating-linear-gradient(0deg, transparent 0 59px, color-mix(in srgb, var(--line) 50%, transparent) 59px 60px),
  repeating-linear-gradient(90deg, transparent 0 59px, color-mix(in srgb, var(--line) 50%, transparent) 59px 60px), var(--bg-deep); }
.wm__svg { width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; user-select: none; }
.wm__svg.is-drag { cursor: grabbing; }

/* 區域 */
.rg-bg { fill: color-mix(in srgb, var(--surface) 70%, transparent); stroke: var(--line-strong); stroke-width: 1.5; }
.rg-name { fill: var(--muted); font: 800 30px var(--font); letter-spacing: .06em; }
.rg-sub { fill: var(--faint); font: 600 17px var(--font); }

/* 連線 */
.e { fill: none; stroke-linecap: round; }
.e--chain { stroke: color-mix(in srgb, var(--accent) 55%, transparent); stroke-width: 2.5; }
.e--entry { stroke: var(--line-strong); stroke-width: 1.5; stroke-dasharray: 3 6; }
.e--road { stroke: color-mix(in srgb, var(--amber) 70%, transparent); stroke-width: 3; }
.e--link { stroke: var(--line-strong); stroke-width: 1.5; }
.e--cross { stroke: color-mix(in srgb, var(--amber) 60%, transparent); stroke-width: 3; stroke-dasharray: 10 8; }
.e--route { stroke: #ff5fd2; stroke-width: 7; opacity: .9; }
.dim .e:not(.e--route) { opacity: .25; }

/* 節點 */
.n { cursor: pointer; }
.n circle { stroke: var(--bg); stroke-width: 3; transition: r .15s; }
.n--city circle { fill: var(--text); r: 22px; }
.n--stage circle { fill: var(--accent); r: 10px; }
.n--boss circle { fill: var(--r-太古); r: 12px; }
.n--road circle { fill: var(--amber); r: 10px; }
.n--other circle { fill: var(--faint); r: 8px; }
.n text { fill: var(--text); font: 600 15px var(--font); paint-order: stroke; stroke: var(--bg-deep); stroke-width: 5px; stroke-linejoin: round; }
.n--city text { font-size: 22px; font-weight: 800; }
.n text.lv { fill: var(--faint); font: 600 12px var(--mono); }
.n:hover circle { stroke: var(--text); }
.n.is-sel circle { stroke: #ff5fd2; stroke-width: 6; }
.n.is-start circle { stroke: #7cf29a; stroke-width: 6; }
.n.is-hit circle { stroke: var(--amber); stroke-width: 7; animation: pulse 1.4s ease-in-out infinite; }
.n.is-route circle { stroke: #ff5fd2; stroke-width: 5; }
.n.is-match circle { stroke: var(--text); stroke-width: 5; }
.dim .n:not(.is-hit):not(.is-route):not(.is-sel):not(.is-start):not(.n--city) { opacity: .35; }
@keyframes pulse { 50% { stroke-width: 12; } }
@media (prefers-reduced-motion: reduce) { .n.is-hit circle { animation: none; } }
.zoom-far .n:not(.n--city):not(.is-hit):not(.is-sel):not(.is-route):not(.is-start) text { display: none; }
.zoom-far .n text.lv { display: none; }

/* 工具列與面板 */
.wm__tools { position: absolute; left: 14px; top: 14px; z-index: 5; display: flex; gap: 8px; align-items: center; padding: 8px; width: min(520px, calc(100% - 28px)); box-shadow: var(--shadow); }
.wm__find { position: relative; flex: 1; }
.wm__results { position: absolute; left: 0; right: 0; top: calc(100% + 6px); max-height: 50vh; overflow-y: auto; margin: 0; padding: 4px; list-style: none; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; box-shadow: var(--shadow); }
.wm__results button { display: flex; justify-content: space-between; gap: 8px; width: 100%; padding: 8px 10px; border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer; }
.wm__results button:hover, .wm__results button:focus { background: var(--accent-soft); }
.wm__results small { color: var(--faint); }
.wm__dropbtn { height: 44px; padding: 0 14px; font-size: 14px; }
.wm__dropbtn svg { width: 18px; height: 18px; }
.wm__dropbtn[aria-expanded="true"] { background: var(--amber); border-color: var(--amber); color: #1a1200; }

.wm__zoom { position: absolute; right: 14px; bottom: 14px; z-index: 5; display: grid; gap: 6px; }
.wm__zoom button { width: 42px; height: 42px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); font-size: 18px; font-weight: 800; cursor: pointer; box-shadow: var(--shadow); }
.wm__zoom button:hover { border-color: var(--accent); color: var(--accent); }
.wm__legend { position: absolute; left: 14px; bottom: 14px; z-index: 4; display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 8px 12px; border-radius: 10px; background: color-mix(in srgb, var(--surface) 85%, transparent); color: var(--muted); font-size: 12.5px; max-width: calc(100% - 90px); }
.lg { display: inline-block; width: 11px; height: 11px; margin-right: 5px; border-radius: 50%; vertical-align: -1px; }
.lg--city { background: var(--text); } .lg--stage { background: var(--accent); } .lg--boss { background: var(--r-太古); } .lg--road { background: var(--amber); } .lg--other { background: var(--faint); }

.wm__drop { position: absolute; left: 14px; top: 82px; bottom: 60px; z-index: 6; display: flex; flex-direction: column; width: min(420px, calc(100% - 28px)); padding: 14px; box-shadow: var(--shadow); }
.wm__drop header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.wm__drop h2 { margin: 0; font-size: 17px; }
.x { width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; font-size: 22px; cursor: pointer; color: var(--muted); }
.x:hover { background: var(--surface-2); color: var(--text); }
.wm__dropbody { flex: 1; overflow-y: auto; margin-top: 10px; scrollbar-width: thin; }
.ditem { display: flex; justify-content: space-between; gap: 8px; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: none; text-align: left; cursor: pointer; margin-bottom: 6px; }
.ditem:hover { border-color: var(--amber); }
.ditem[aria-pressed="true"] { border-color: var(--amber); background: color-mix(in srgb, var(--amber) 14%, transparent); }
.ditem small { color: var(--faint); white-space: nowrap; }
.dmon { padding: 10px 0; border-bottom: 1px solid var(--line); }
.dmon__top { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-weight: 700; }
.dmon__maps { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.dmon__maps button { padding: 3px 9px; border: 1px solid var(--line-strong); border-radius: 999px; background: none; font-size: 12.5px; cursor: pointer; }
.dmon__maps button:hover { border-color: var(--accent); color: var(--accent); }
.sec-h { margin: 14px 0 6px; color: var(--muted); font-size: 13px; font-weight: 700; }
.muted { color: var(--faint); font-size: 13.5px; }

/* 右側資訊 */
.wm__side { overflow-y: auto; padding: 0; border-left: 1px solid var(--line); background: var(--surface); scrollbar-width: thin; }
.wm__side h2 { margin: 0; font-size: 22px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; }
.desc { margin: 10px 0 0; color: var(--muted); font-size: 14px; white-space: pre-line; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.btn { height: 36px; padding: 0 14px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface-2); font-weight: 700; font-size: 13.5px; cursor: pointer; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn--go { background: #ff5fd2; border-color: #ff5fd2; color: #1a0016; }
.btn--go:hover { color: #1a0016; filter: brightness(1.1); }
.btn--start { border-color: #7cf29a; color: #7cf29a; }
html:is([data-theme="light"],[data-theme="paper"]) .btn--start { color: #128a3a; border-color: #128a3a; }
.route { margin: 6px 0 0; padding: 0; list-style: none; counter-reset: s; }
.route li { counter-increment: s; position: relative; padding: 6px 0 6px 30px; font-size: 14px; }
.route li::before { content: counter(s); position: absolute; left: 0; top: 6px; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-3); font: 700 11px var(--mono); }
.route li small { color: var(--faint); }
.mlist { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.mlist td { padding: 6px 2px; border-bottom: 1px solid var(--line); }
.mlist td.n { text-align: right; font-weight: 700; white-space: nowrap; }
.weak { display: inline-flex; height: 18px; align-items: center; margin-left: 3px; padding: 0 5px; border-radius: 4px; background: color-mix(in srgb, var(--r-太古) 16%, transparent); color: var(--r-太古); font-size: 11px; font-weight: 700; }
.badge--boss { background: color-mix(in srgb, var(--r-太古) 20%, transparent); color: var(--r-太古); }
.links { display: flex; flex-wrap: wrap; gap: 5px; }
.links button { padding: 3px 10px; border: 1px solid var(--line-strong); border-radius: 999px; background: none; font-size: 13px; cursor: pointer; }
.links button:hover { border-color: var(--accent); color: var(--accent); }
.side-empty h2 { font-size: 18px; }
.side-empty p { color: var(--muted); font-size: 14px; }
.side-empty ol { padding-left: 20px; color: var(--muted); font-size: 14px; }

@media (max-width: 960px) {
  .wm { grid-template-columns: 1fr; grid-template-rows: 62vh auto; height: auto; }
  .wm__side { border-left: 0; border-top: 1px solid var(--line); }
  .wm__drop { top: 76px; bottom: 12px; }
  .wm__legend { display: none; }
}

.wm__drop[hidden], .wm__results[hidden] { display: none; }
.linkish { padding: 0; border: 0; background: none; color: var(--accent); font: inherit; font-weight: 700; cursor: pointer; text-align: left; }
.linkish:hover { text-decoration: underline; }

/* 縮小時文字維持可讀：依縮放倍率反向放大 */
.rg-name { font-size: max(30px, calc(15px * var(--inv, 1))); }
.rg-sub { font-size: max(17px, calc(11px * var(--inv, 1))); }
.cont-name { fill: var(--accent); font-size: max(44px, calc(18px * var(--inv, 1))); }
.n--city text { font-size: max(22px, calc(12px * var(--inv, 1))); }
.zoom-far .n--city circle { r: max(22px, calc(6px * var(--inv, 1))); }
.zoom-far .n--city text, .zoom-far .rg-sub { display: none; }
.zoom-far .rg-name:not(.cont-name) { dominant-baseline: middle; }
.zoom-far .rg-bg { cursor: zoom-in; }
.zoom-far .rg-bg:hover { stroke: var(--accent); }

/* ===== v3：兩層式 ===== */
.wm__svg *:focus { outline: none; }
.wm__svg .n:focus-visible circle, .wm__svg .pill:focus-visible rect { stroke: var(--accent); stroke-width: 5; }
.wm__stage, .wm__svg { -webkit-user-select: none; user-select: none; }
.wm__crumb { position: absolute; left: 14px; top: 78px; z-index: 4; display: flex; align-items: center; gap: 8px; padding: 8px 12px; box-shadow: var(--shadow); font-size: 14px; }
.crumb__now { font-weight: 800; }
.crumb__hint { color: var(--faint); font-size: 12.5px; }
.crumb__back { padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface-2); font-weight: 700; cursor: pointer; }
.crumb__back:hover { border-color: var(--accent); color: var(--accent); }
.crumb__sep { color: var(--faint); }
.wm__drop { top: 132px; }

.w-cont { fill: var(--accent); font: 800 30px var(--font); letter-spacing: .04em; }
.w-edge { fill: none; stroke: color-mix(in srgb, var(--amber) 55%, transparent); stroke-width: 6; stroke-linecap: round; }
.w-edge.is-route { stroke: #ff5fd2; stroke-width: 10; }
.pill { cursor: pointer; }
.pill rect { fill: var(--surface); stroke: var(--line-strong); stroke-width: 2.5; transition: stroke .15s; }
.pill:hover rect { stroke: var(--accent); stroke-width: 4; }
.pill__name { fill: var(--text); font: 800 28px var(--font); }
.pill__sub { fill: var(--muted); font: 600 17px var(--font); }
.pill.is-route rect { stroke: #ff5fd2; stroke-width: 5; }
.pill.is-start rect { stroke: #7cf29a; stroke-width: 5; }
.pill.is-hit rect { fill: color-mix(in srgb, var(--amber) 16%, var(--surface)); stroke: var(--amber); stroke-width: 4; }
.pill--special rect { stroke-dasharray: 8 6; }
.pill__badge circle { fill: var(--amber); }
.pill__badge text { fill: #1a1200; font: 800 18px var(--font); }
.stub { cursor: pointer; }
.stub rect { fill: color-mix(in srgb, var(--amber) 18%, var(--surface)); stroke: var(--amber); stroke-width: 2; }
.stub text { fill: var(--text); font: 700 16px var(--font); }
.stub:hover rect { stroke-width: 4; }
.rlist { margin: 4px 0 0; padding: 0; list-style: none; }
.rlist li { padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.rlist small { color: var(--faint); }
.hitrow td { background: color-mix(in srgb, var(--amber) 14%, transparent); }
.crumb-mini { margin: 0 0 4px; font-size: 13px; }
.dmon__maps small { color: var(--faint); }
.btn { display: inline-flex; align-items: center; text-decoration: none; }

/* ===== v4：右側三分頁（地圖資訊／怪物屬性／掉落物尋找） ===== */
.wm__tabs { position: sticky; top: 0; z-index: 3; display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 10px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.wm__tabs button { height: 40px; border: 1px solid transparent; border-radius: 9px; background: transparent; color: var(--muted); font-weight: 800; font-size: 14.5px; cursor: pointer; }
.wm__tabs button:hover { color: var(--text); background: var(--surface-2); }
.wm__tabs button[aria-selected="true"] { background: var(--accent); color: var(--bg); }
.wm__pane { padding: 16px 18px 28px; }
.wm__pane[hidden], .wm__side [hidden] { display: none !important; }
.wm__dropbtn[aria-pressed="true"] { background: var(--amber); border-color: var(--amber); color: #1a1200; }
.wm__dropbody { margin-top: 12px; overflow: visible; }
.sec-more { float: right; font-size: 12.5px; }
.seg--full { display: grid; grid-template-columns: 1fr 1fr; margin-bottom: 14px; padding: 3px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-2); }
.seg--full button { height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; }
.seg--full button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 0 0 1px var(--line-strong); }
.monfind { display: grid; gap: 8px; margin-bottom: 12px; }
.monfind__row { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.lvrange { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13.5px; }
.input--sm { width: 72px; height: 36px; padding: 0 10px; }
.select { height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13.5px; cursor: pointer; white-space: nowrap; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }
.count { margin: 0 0 6px; color: var(--faint); font-size: 12.5px; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; width: 100%; padding: 9px 10px; border: 0; border-bottom: 1px solid var(--line); background: transparent; color: var(--text); text-align: left; font: inherit; cursor: pointer; }
.row:hover { background: var(--surface-2); }
.row__name { font-weight: 700; overflow-wrap: anywhere; }
.row__lv { justify-self: end; font: 700 13px var(--mono); color: var(--muted); }
.row__sub { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; color: var(--faint); font-size: 12.5px; }
.row__sub .weak { margin-left: 0; }
.more { display: block; width: 100%; margin: 10px 0; height: 38px; border: 1px dashed var(--line-strong); border-radius: 10px; background: transparent; color: var(--accent); font-weight: 700; cursor: pointer; }
.fam { display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 5px; background: var(--surface-3); color: var(--muted); font-size: 11.5px; font-weight: 700; }
.stat { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13.5px; }
.stat > span { display: inline-flex; align-items: center; gap: 4px; }
.stat .weak { margin-left: 0; }
.moblist { width: 100%; border-collapse: collapse; font-size: 14px; }
.moblist th, .moblist td { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.moblist th { color: var(--faint); font-size: 12px; font-weight: 600; }
.moblist td.n { white-space: nowrap; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.moblist tr[data-mon], .moblist tr[data-gomap] { cursor: pointer; }
.moblist tr[data-mon]:hover td, .moblist tr[data-gomap]:hover td { background: var(--surface-2); }
.moblist .sub { margin-top: 2px; color: var(--faint); font-size: 12.5px; }
.moblist tr.is-here td { background: var(--accent-soft); }
.back { display: inline-flex; margin-bottom: 12px; padding: 6px 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface-2); font-weight: 700; font-size: 13.5px; cursor: pointer; }
.back:hover { border-color: var(--accent); color: var(--accent); }
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; margin: 12px 0 0; }
.kpi { padding: 8px 10px; border-radius: 9px; background: var(--surface-2); }
.kpi dt { color: var(--faint); font-size: 12px; }
.kpi dd { margin: 2px 0 0; font: 800 16px var(--font); font-variant-numeric: tabular-nums; }
.elems { display: grid; gap: 7px; }
.elem { display: grid; grid-template-columns: 40px 1fr 60px; align-items: center; gap: 10px; font-size: 13.5px; }
.elem__bar { position: relative; height: 10px; border-radius: 5px; background: var(--surface-3); overflow: hidden; }
.elem__bar i { position: absolute; top: 0; bottom: 0; left: 50%; border-radius: 5px; }
.elem__bar::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--line-strong); }
.elem__v { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.elem.weak-row .elem__v { color: var(--r-太古); }
.elem.strong .elem__v { color: var(--r-英雄); }
.hint { margin: 8px 0 0; color: var(--faint); font-size: 12.5px; }
.tags { display: flex; flex-wrap: wrap; gap: 5px; }
.dropset + .dropset { margin-top: 12px; }
.dropset h4 { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; margin: 0 0 6px; font-size: 14px; }
.dropset h4 small { color: var(--faint); font-weight: 500; }
.items { display: flex; flex-wrap: wrap; gap: 6px; }
.item { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; background: none; color: var(--text); font: inherit; font-size: 13.5px; cursor: pointer; }
.item:hover { border-color: var(--amber); }
.item small { color: var(--faint); font-size: 11.5px; }
.item--hit { border-color: var(--amber); background: color-mix(in srgb, var(--amber) 14%, transparent); font-weight: 700; }
details.common { margin-top: 8px; }
details.common summary, details.more-stats summary { color: var(--faint); font-size: 12.5px; cursor: pointer; }
details.common .items { margin-top: 8px; opacity: .85; }
details.more-stats { margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--line); }
details.more-stats summary { font-size: 13.5px; font-weight: 700; color: var(--muted); }
.kv { width: 100%; margin-top: 8px; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.kv td { padding: 5px 2px; border-bottom: 1px solid var(--line); }
.kv td:first-child { color: var(--muted); }
.kv td:last-child { text-align: right; font-weight: 600; }
.ditems { display: grid; gap: 4px; }
.dmon__top .weak { margin-left: 0; }
@media (max-width: 960px) {
  .wm__side { overflow: visible; }
  .wm__tabs { top: 64px; }
}

/* ===== v5：統一搜尋 ===== */
.wm__tools { width: min(460px, calc(100% - 28px)); }
.wm__results { max-height: min(70vh, 640px); }
.wm__results .res-h { display: flex; align-items: baseline; gap: 8px; margin: 6px 0 2px; padding: 8px 10px 4px; border-top: 1px solid var(--line); color: var(--accent); font-size: 12.5px; font-weight: 800; letter-spacing: .04em; }
.wm__results .res-h:first-child { border-top: 0; margin-top: 0; }
.wm__results .res-h small { color: var(--faint); font-weight: 600; }
.wm__results .res-more { justify-content: center; color: var(--accent); font-size: 13px; font-weight: 700; }
.qchip { display: inline-flex; align-items: center; gap: 6px; margin: 0 0 8px; padding: 3px 4px 3px 10px; border: 1px solid var(--accent); border-radius: 999px; color: var(--accent); font-size: 13px; font-weight: 700; }
.qchip button { width: 22px; height: 22px; border: 0; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 800; cursor: pointer; }
.wm__results .res-tip { padding: 8px 10px 2px; color: var(--faint); font-size: 12px; }
