/*
 * Интерактивный атлас. Страница открывается во встроенном окне внутри вики (iframe) и берёт цвета из tokens.css:
 * светлая и тёмная темы переключаются классом .dark, который страница вики передаёт в окно. Без градиентов и свечений.
 */
:root {
  --panel: rgb(var(--ether-surface));
  --panel2: rgb(var(--ether-raised));
  --line: rgb(var(--ether-border));
  --text: rgb(var(--ether-text));
  --mute: rgb(var(--ether-muted));
  --acc: rgb(var(--ether-accent));
  --on-acc: rgb(var(--on-brand));
  --map-bg: rgb(var(--ether-bg));
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--map-bg); color: var(--text); font: 15px/1.5 system-ui, 'Segoe UI', Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; color: inherit; }
.mute { color: var(--mute); }
.small { font-size: 0.82rem; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel2); color: var(--text); cursor: pointer; transition: border-color 0.15s, background-color 0.15s; }
.btn:hover { border-color: var(--acc); }
.btn--sm { font-size: 0.86rem; }
.btn--ghost { background: transparent; }

.mapx { display: grid; grid-template-columns: 360px minmax(0, 1fr); gap: 12px; align-items: start; height: 100vh; padding: 12px; }
.mapx__side { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 14px; height: 100%; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; gap: 14px; scrollbar-width: thin; }
.mapx__regions { display: flex; flex-direction: column; gap: 10px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.mapx__rgrp small { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--mute); }
.mapx__rgrp small::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.mapx__rgrp > div { display: flex; flex-wrap: wrap; gap: 6px; }
.mapx__rg { padding: 6px 12px; border-radius: 4px; border: 1px solid var(--line); background: var(--panel2); font-size: 0.86rem; cursor: pointer; transition: border-color 0.15s; }
.mapx__rg:hover { border-color: var(--acc); }
.mapx__rg.on { background: var(--acc); border-color: var(--acc); color: var(--on-acc); font-weight: 600; }
.mapx__rg.nomap:not(.on) { opacity: 0.55; }
.mapx__find { width: 100%; padding: 10px 12px; border-radius: 6px; border: 1px solid var(--line); background: var(--map-bg); }
.mapx__find:focus { outline: 2px solid var(--acc); outline-offset: 1px; }
.mapx__hits { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; padding: 4px; }
.mapx__hits[hidden] { display: none; }
.mapx__btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mapx__btns .btn { justify-content: center; margin: 0; }
.mapx__btns #mnames { grid-column: 1 / -1; }
.mapx__btns [aria-pressed='true'] { background: var(--acc); color: var(--on-acc); border-color: var(--acc); }

.mapx__grp { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 10px 12px; }
.mapx__grp header { display: flex; align-items: center; justify-content: space-between; margin: 0 0 8px; padding: 0 2px; }
.mapx__gt { display: flex; gap: 8px; align-items: baseline; background: none; border: 0; padding: 2px 0; cursor: pointer; }
.mapx__gt b { font-size: 1rem; font-weight: 700; }
.mapx__gt small { background: var(--panel2); border-radius: 4px; padding: 1px 8px; align-self: center; color: var(--mute); font-size: 0.75rem; }
.mapx__gall { background: var(--panel2); border: 1px solid var(--line); color: var(--mute); border-radius: 4px; width: 26px; height: 26px; cursor: pointer; line-height: 1; }
.mapx__gall:hover { color: var(--acc); border-color: var(--acc); }
.mapx__grp.closed .mapx__cl { display: none; }
.mapx__cl { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.mapx__cat { display: grid; grid-template-columns: 30px 1fr; grid-template-rows: auto auto; column-gap: 9px; align-items: center; padding: 8px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--map-bg); text-align: left; cursor: pointer; min-width: 0; position: relative; overflow: hidden; transition: border-color 0.15s; }
.mapx__cat::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--c); }
.mapx__cat:hover { border-color: var(--acc); }
.mapx__cat img, .mapx__cat i { grid-row: 1 / 3; width: 30px; height: 30px; object-fit: contain; }
.mapx__cat i { border-radius: 50%; background: var(--c); transform: scale(0.5); }
.mapx__cat span { grid-column: 2; font-size: 0.82rem; font-weight: 600; line-height: 1.15; overflow-wrap: break-word; }
.mapx__cat small { grid-column: 2; font-size: 0.72rem; color: var(--mute); font-variant-numeric: tabular-nums; }
.mapx__cat.off { opacity: 0.45; }
.mapx__cat.off::before { background: var(--mute); }
.mapx__fav h3, .mapx__prog h3, .mapx__admin h3 { font-size: 1rem; margin: 0 0 8px; }
.mapx__row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border-radius: 4px; border: 0; background: none; font-size: 0.84rem; text-align: left; cursor: pointer; }
.mapx__row:hover { background: var(--panel2); }
.mapx__row img { width: 22px; height: 22px; object-fit: contain; }
.mapx__row small { margin-left: auto; color: var(--mute); }
.mapx__pr { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: 0.84rem; margin-bottom: 8px; }
.mapx__pr i { grid-column: 1 / -1; height: 5px; border-radius: 3px; background: var(--panel2); overflow: hidden; position: relative; }
.mapx__pr i::after { content: ''; position: absolute; inset: 0; width: var(--p); background: var(--acc); }
.mapx__abtns { display: flex; flex-wrap: wrap; gap: 6px; }

.mapx__stage { min-width: 0; height: 100%; display: flex; flex-direction: column; }
.mapx__view { position: relative; flex: 1; min-height: 320px; border-radius: 6px; overflow: hidden; background: var(--map-bg); border: 1px solid var(--line); touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; }
.mapx__view.grab { cursor: grabbing; }
.mapx__view.edit { cursor: crosshair; outline: 2px dashed var(--acc); outline-offset: -3px; }
.mapx__cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.mapx__cv[hidden] { display: none; }
.mapx__zoom { position: absolute; left: 12px; top: 12px; display: flex; flex-direction: column; gap: 2px; z-index: 6; }
.mapx__zoom button { width: 34px; height: 34px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font-size: 1.2rem; cursor: pointer; }
.mapx__zoom button:hover { border-color: var(--acc); }
.mapx__zoom button:first-child { border-radius: 6px 6px 0 0; }
.mapx__zoom button:last-child { border-radius: 0 0 6px 6px; }
.mapx__empty { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 8px; align-items: center; justify-content: center; text-align: center; padding: 24px; color: var(--mute); }
.mapx__empty b { font-size: 1.5rem; color: var(--text); }
.mapx__empty[hidden] { display: none; }
.mapx__hint { margin-top: 8px; font-size: 0.8rem; color: var(--mute); }

.mapx__pop { position: absolute; z-index: 8; right: 12px; top: 12px; bottom: 12px; width: min(340px, calc(100% - 24px)); padding: 18px 18px 22px; border-radius: 6px; background: var(--panel); border: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain; cursor: default; display: flex; flex-direction: column; gap: 10px; }
.mapx__pop[hidden] { display: none; }
.mapx__reg { color: var(--acc); font-weight: 600; font-size: 0.8rem; }
.mapx__big { width: 84px; height: 84px; border-radius: 6px; border: 3px solid var(--c, #5aa9ff); background: var(--map-bg); display: flex; align-items: center; justify-content: center; margin: 4px 0 2px; }
.mapx__big img { width: 68px; height: 68px; object-fit: contain; }
.mapx__big i { width: 26px; height: 26px; border-radius: 50%; background: var(--c); }
.mapx__cat2 { color: var(--acc); font-size: 0.88rem; }
.mapx__pop h3 { font-size: 1.4rem; line-height: 1.2; margin: 0; }
.mapx__area { margin: 0; color: var(--mute); font-size: 0.9rem; }
.mapx__xy { margin: 6px 0 4px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--map-bg); }
.mapx__xy small { display: block; color: var(--mute); font-size: 0.78rem; }
.mapx__xy b { font-size: 1.1rem; font-variant-numeric: tabular-nums; }
.mapx__xy i { font-style: normal; color: var(--mute); margin: 0 4px; }
.mapx__btn { width: 100%; padding: 12px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel2); font-weight: 600; cursor: pointer; transition: border-color 0.15s; }
.mapx__btn:hover { border-color: var(--acc); }
.mapx__btn--main { background: var(--acc); border-color: var(--acc); color: var(--on-acc); }
.mapx__btn--main.on { background: var(--panel2); color: var(--acc); }
.mapx__btn.on:not(.mapx__btn--main) { border-color: var(--acc); color: var(--acc); }
.mapx__note { width: 100%; padding: 12px 14px; border-radius: 6px; border: 1px solid var(--line); background: var(--map-bg); font-size: 0.92rem; resize: vertical; min-height: 84px; }
.mapx__pop h4 { font-size: 1rem; margin: 10px 0 0; }
.mapx__mute { margin: 0; color: var(--mute); font-size: 0.85rem; }
.mapx__tp { display: flex; justify-content: space-between; gap: 10px; width: 100%; padding: 11px 12px; border: 0; border-radius: 4px; background: var(--panel2); font-size: 0.9rem; text-align: left; cursor: pointer; }
.mapx__tp:hover { outline: 1px solid var(--acc); }
.mapx__tp small { color: var(--mute); white-space: nowrap; }
.mapx__x { position: absolute; right: 14px; top: 10px; border: 0; background: none; color: var(--mute); font-size: 1.7rem; cursor: pointer; line-height: 1; }
.mapx__x:hover { color: var(--text); }

@media (max-width: 900px) {
  .mapx { grid-template-columns: 1fr; height: auto; min-height: 100vh; }
  .mapx__side { height: auto; max-height: none; }
  .mapx__stage { order: -1; height: 72vh; }
  .mapx__pop { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 62%; }
}
