/* blmap — веб-карта. Токены цвета в :root, тёмная тема по умолчанию, светлая — по системе или переключателю. */
:root {
  --bg: #0b0e13;
  --panel: rgba(16, 20, 27, 0.82);
  --panel-solid: #12161d;
  --panel-2: rgba(255, 255, 255, 0.045);
  --panel-3: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --border-2: rgba(255, 255, 255, 0.14);
  --text: #e8ebf1;
  --text-2: #a3acbb;
  --text-3: #6f7889;
  --accent: #7bd88f;
  --accent-2: #3fb760;
  --accent-soft: rgba(123, 216, 143, 0.14);
  --warn: #f2b84b;
  --danger: #f2706b;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.3);
  --radius: 16px;
  --radius-sm: 10px;
  --blur: blur(14px) saturate(140%);
  --font: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #e9ecef;
    --panel: rgba(255, 255, 255, 0.84);
    --panel-solid: #ffffff;
    --panel-2: rgba(15, 23, 42, 0.04);
    --panel-3: rgba(15, 23, 42, 0.08);
    --border: rgba(15, 23, 42, 0.08);
    --border-2: rgba(15, 23, 42, 0.16);
    --text: #141a24;
    --text-2: #4b5567;
    --text-3: #8790a0;
    --accent: #2f9e4f;
    --accent-2: #23853f;
    --accent-soft: rgba(47, 158, 79, 0.12);
    --shadow: 0 10px 40px rgba(15, 23, 42, 0.16), 0 2px 8px rgba(15, 23, 42, 0.08);
    color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #e9ecef;
  --panel: rgba(255, 255, 255, 0.84);
  --panel-solid: #ffffff;
  --panel-2: rgba(15, 23, 42, 0.04);
  --panel-3: rgba(15, 23, 42, 0.08);
  --border: rgba(15, 23, 42, 0.08);
  --border-2: rgba(15, 23, 42, 0.16);
  --text: #141a24;
  --text-2: #4b5567;
  --text-3: #8790a0;
  --accent: #2f9e4f;
  --accent-2: #23853f;
  --accent-soft: rgba(47, 158, 79, 0.12);
  --shadow: 0 10px 40px rgba(15, 23, 42, 0.16), 0 2px 8px rgba(15, 23, 42, 0.08);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text);
  font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#map { position: absolute; inset: 0; background: var(--bg); }
.leaflet-container { background: var(--bg); font: inherit; outline: none; }
.leaflet-tile { image-rendering: pixelated; }
.leaflet-layer.day { transition: filter 0.35s ease; }
body.base-night .leaflet-layer.day { filter: brightness(0.52) saturate(0.7) contrast(1.12) hue-rotate(-12deg); }
body.base-night #map { background: #05070b; }
body.base-parchment .leaflet-layer.day { filter: sepia(0.72) saturate(0.62) contrast(0.92) brightness(1.06); }
body.base-parchment #map { background: #d9c9a3; }
#vignette { position: absolute; inset: 0; z-index: 401; pointer-events: none; opacity: 0; transition: opacity 0.35s;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(80, 52, 20, 0.38) 100%); }
body.base-parchment #vignette { opacity: 1; }
body.base-night #vignette { opacity: 1; background: radial-gradient(ellipse at center, transparent 50%, rgba(0, 0, 10, 0.55) 100%); }

.glass { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); }

/* ---------- боковая панель ---------- */
#side { position: absolute; z-index: 1000; top: 16px; left: 16px; bottom: 16px; width: 344px;
  display: flex; flex-direction: column; overflow: hidden; transition: transform 0.3s cubic-bezier(.2, .8, .2, 1); }
body.side-closed #side { transform: translateX(calc(-100% - 24px)); }
#side header { position: relative; padding: 16px 16px 12px; display: flex; gap: 12px; align-items: center; }
.logo { width: 40px; height: 40px; border-radius: 12px; flex: none; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #2f8f9e); color: #08130c; box-shadow: 0 4px 14px rgba(63, 183, 96, 0.35); }
.logo svg.i { width: 22px; height: 22px; stroke-width: 2.2; }
#side h1 { margin: 0; font-size: 16px; font-weight: 800; letter-spacing: -0.01em; line-height: 1.2;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--text-2); margin-top: 2px; min-width: 0; }
.status span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; }
.status.run .dot { background: var(--accent); animation: pulse 2s infinite; }
.status.wait .dot { background: var(--warn); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(123, 216, 143, 0.55); } 70% { box-shadow: 0 0 0 7px rgba(123, 216, 143, 0); } 100% { box-shadow: 0 0 0 0 rgba(123, 216, 143, 0); } }
.progress { height: 3px; margin: 0 16px 10px; border-radius: 3px; background: var(--panel-3); overflow: hidden; display: none; }
.progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent-2), var(--accent)); transition: width 0.6s; }
.head-btn { margin-left: auto; width: 34px; height: 34px; border-radius: 10px; border: 0; background: transparent; color: var(--text-2);
  display: grid; place-items: center; flex: none; }
.head-btn:hover { background: var(--panel-3); color: var(--text); }

.search { margin: 0 16px; position: relative; }
.search svg.i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 16px; height: 16px; }
.search input { width: 100%; height: 40px; border-radius: 12px; border: 1px solid var(--border); background: var(--panel-2);
  padding: 0 12px 0 36px; outline: none; transition: border-color 0.2s, background 0.2s; }
.search input::placeholder { color: var(--text-3); }
.search input:focus { border-color: var(--accent); background: var(--panel-3); }

.tabs { display: flex; gap: 4px; margin: 12px 16px 6px; padding: 4px; border-radius: 12px; background: var(--panel-2); }
.tabs button { flex: 1; border: 0; background: transparent; color: var(--text-2); height: 32px; border-radius: 9px;
  font-weight: 600; font-size: 13px; display: flex; align-items: center; justify-content: center; gap: 6px; transition: background 0.2s, color 0.2s; }
.tabs button b { font-weight: 700; font-size: 11px; min-width: 18px; padding: 0 5px; height: 18px; border-radius: 9px; display: inline-grid; place-items: center;
  background: var(--panel-3); color: var(--text-2); }
.tabs button.on { background: var(--panel-solid); color: var(--text); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18); }
.tabs button.on b { background: var(--accent-soft); color: var(--accent); }

.list { flex: 1; overflow-y: auto; padding: 4px 8px 8px; scrollbar-width: thin; scrollbar-color: var(--panel-3) transparent; }
.row { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 12px; cursor: pointer;
  transition: background 0.15s; border: 1px solid transparent; }
.row:hover { background: var(--panel-2); }
.row.on { background: var(--accent-soft); border-color: rgba(123, 216, 143, 0.25); }
.row .av { width: 34px; height: 34px; border-radius: 9px; flex: none; image-rendering: pixelated; background: var(--panel-3);
  box-shadow: inset 0 0 0 1px var(--border); display: grid; place-items: center; color: #fff; }
.row .av svg.i { width: 18px; height: 18px; }
.row .meta { min-width: 0; flex: 1; }
.row .t { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { font-size: 12px; color: var(--text-3); font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .tag { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: var(--panel-3); color: var(--text-2); flex: none; }
.row .swatch { width: 12px; height: 12px; border-radius: 4px; flex: none; }
.section-title { font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; padding: 12px 10px 4px; }
.empty { text-align: center; color: var(--text-3); padding: 34px 20px; font-size: 13px; }
.empty svg.i { width: 30px; height: 30px; margin-bottom: 8px; opacity: 0.6; }
.hint { margin: 0 16px 16px; padding: 10px 12px; border-radius: 12px; background: var(--panel-2); color: var(--text-2); font-size: 12.5px; }
.hint code { font-family: var(--mono); font-size: 11.5px; padding: 1px 6px; border-radius: 6px; background: var(--panel-3); color: var(--text); white-space: nowrap; }

#open-side { position: absolute; z-index: 999; top: 16px; left: 16px; height: 44px; padding: 0 14px 0 10px; display: none;
  align-items: center; gap: 10px; border: 1px solid var(--border); font-weight: 700; }
#open-side .logo { width: 28px; height: 28px; border-radius: 8px; }
#open-side .logo svg.i { width: 16px; height: 16px; }
body.side-closed #open-side { display: flex; }

/* ---------- инструменты справа ---------- */
#tools { position: absolute; z-index: 1000; top: 16px; right: 16px; display: flex; flex-direction: column; gap: 10px; }
.stack { display: flex; flex-direction: column; overflow: hidden; }
.stack button { width: 44px; height: 44px; border: 0; background: transparent; color: var(--text); display: grid; place-items: center; transition: background 0.15s; }
.stack button + button { border-top: 1px solid var(--border); }
.stack button:hover { background: var(--panel-3); }
.stack button.on { color: var(--accent); }

#layers { position: absolute; z-index: 1001; top: 16px; right: 72px; width: 316px; padding: 14px; display: none; max-height: calc(100% - 32px); overflow-y: auto; }
#layers.open { display: block; animation: pop 0.18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(0.98); } to { opacity: 1; transform: none; } }
#layers h3 { margin: 2px 2px 10px; font-size: 11px; font-weight: 700; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.08em; }
#layers h3 + h3, #layers .grp + h3 { margin-top: 16px; }
.bases { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.base { border: 1px solid var(--border); background: var(--panel-2); border-radius: 12px; padding: 6px; display: flex; flex-direction: column; gap: 6px;
  align-items: stretch; font-size: 12px; font-weight: 650; color: var(--text-2); transition: border-color 0.15s, transform 0.15s; }
.base:hover { transform: translateY(-1px); border-color: var(--border-2); }
.base.on { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 3px var(--accent-soft); }
.base i { display: block; height: 52px; border-radius: 8px; background-size: cover; background-position: center; image-rendering: pixelated; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border); background: var(--panel-2); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; font-weight: 650; color: var(--text-2); }
.chip.on { background: var(--accent-soft); border-color: rgba(123, 216, 143, 0.4); color: var(--accent); }
.toggle { display: flex; align-items: center; gap: 12px; padding: 8px 4px; cursor: pointer; user-select: none; }
.toggle .ti { width: 30px; height: 30px; border-radius: 9px; background: var(--panel-3); display: grid; place-items: center; color: var(--text-2); flex: none; }
.toggle .ti svg.i { width: 16px; height: 16px; }
.toggle .tl { flex: 1; font-weight: 600; }
.toggle .tl small { display: block; font-weight: 500; color: var(--text-3); font-size: 11.5px; }
.sw { width: 36px; height: 21px; border-radius: 11px; background: var(--panel-3); position: relative; flex: none; transition: background 0.2s; }
.sw::after { content: ""; position: absolute; top: 3px; left: 3px; width: 15px; height: 15px; border-radius: 50%; background: #fff; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); }
.toggle.on .sw { background: var(--accent-2); }
.toggle.on .sw::after { transform: translateX(15px); }
.toggle.on .ti { color: var(--accent); background: var(--accent-soft); }

/* ---------- низ: координаты и масштаб ---------- */
#coords { position: absolute; z-index: 1000; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; align-items: center;
  gap: 2px; padding: 5px; font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; }
#coords span { padding: 5px 10px; border-radius: 10px; }
#coords span b { color: var(--text-3); font-weight: 500; margin-right: 6px; }
#coords button { border: 0; background: transparent; color: var(--text-2); width: 32px; height: 30px; border-radius: 9px; display: grid; place-items: center; }
#coords button:hover { background: var(--panel-3); color: var(--text); }
#coords button svg.i { width: 15px; height: 15px; }
body:not(.side-closed) #coords { left: calc(50% + 188px); }
#scale { position: absolute; z-index: 1000; bottom: 22px; right: 16px; font-family: var(--mono); font-size: 11.5px; color: var(--text-2);
  padding: 5px 10px 6px; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
#scale i { display: block; height: 6px; border: 2px solid var(--text-2); border-top: 0; border-radius: 0 0 2px 2px; }

#follow { position: absolute; z-index: 1000; top: 16px; left: 50%; transform: translateX(-50%); display: none; align-items: center; gap: 10px;
  padding: 6px 6px 6px 8px; font-weight: 650; }
#follow.show { display: flex; animation: pop 0.2s ease-out; }
#follow img { width: 26px; height: 26px; border-radius: 7px; image-rendering: pixelated; }
#follow button { border: 0; background: var(--panel-3); width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
body:not(.side-closed) #follow { left: calc(50% + 188px); }

#toast { position: absolute; z-index: 1300; bottom: 76px; left: 50%; transform: translateX(-50%) translateY(10px); padding: 10px 16px;
  font-weight: 600; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; white-space: nowrap; }
#toast.show { opacity: 1; transform: translateX(-50%); }

/* ---------- контекстное меню и окно метки ---------- */
#ctx { position: absolute; z-index: 1200; min-width: 230px; padding: 6px; display: none; }
#ctx.open { display: block; animation: pop 0.14s ease-out; }
#ctx .ch { padding: 8px 10px 6px; font-family: var(--mono); font-size: 12px; color: var(--text-3); }
#ctx button { width: 100%; display: flex; align-items: center; gap: 10px; border: 0; background: transparent; padding: 9px 10px; border-radius: 9px;
  text-align: left; font-weight: 600; }
#ctx button:hover { background: var(--panel-3); }
#ctx button svg.i { width: 16px; height: 16px; color: var(--text-2); }

#modal-bg { position: absolute; inset: 0; z-index: 1250; background: rgba(0, 0, 0, 0.45); display: none; align-items: center; justify-content: center; padding: 16px; }
#modal-bg.open { display: flex; }
#modal { width: 100%; max-width: 380px; padding: 20px; animation: pop 0.18s ease-out; background: var(--panel-solid); }
#modal h2 { margin: 0 0 4px; font-size: 18px; font-weight: 800; }
#modal p { margin: 0 0 14px; color: var(--text-3); font-size: 12.5px; font-family: var(--mono); }
#modal label { display: block; font-size: 12px; font-weight: 700; color: var(--text-2); margin: 12px 0 6px; }
#modal input[type=text] { width: 100%; height: 42px; border-radius: 12px; border: 1px solid var(--border-2); background: var(--panel-2); padding: 0 12px; outline: none; }
#modal input[type=text]:focus { border-color: var(--accent); }
.icon-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.icon-grid button { aspect-ratio: 1; border-radius: 10px; border: 1px solid var(--border); background: var(--panel-2); display: grid; place-items: center; color: var(--text-2); }
.icon-grid button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.modal-actions { display: flex; gap: 8px; margin-top: 18px; }
.btn { flex: 1; height: 42px; border-radius: 12px; border: 1px solid var(--border-2); background: var(--panel-2); font-weight: 700; }
.btn.primary { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn:hover { background: var(--panel-3); }

/* ---------- значки на карте ---------- */
.pm { position: relative; width: 0; height: 0; }
.pm .face { position: absolute; left: -15px; top: -15px; width: 30px; height: 30px; border-radius: 9px; image-rendering: pixelated;
  border: 2px solid #fff; box-shadow: 0 3px 10px rgba(0, 0, 0, 0.5); background: #333; }
.pm .dir { position: absolute; left: -21px; top: -21px; width: 42px; height: 42px; pointer-events: none; transition: transform 0.9s linear; }
.pm .dir::before { content: ""; position: absolute; left: 50%; top: -13px; transform: translateX(-50%); border: 6px solid transparent; border-bottom: 8px solid #fff;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5)); }
.pm .nm { position: absolute; top: 19px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 12px; font-weight: 700; color: #fff;
  padding: 2px 8px; border-radius: 7px; background: rgba(10, 12, 16, 0.78); }
.pm.me .face { border-color: var(--accent); }
.leaflet-marker-icon.player { transition: transform 0.9s linear; }
.leaflet-zoom-anim .leaflet-marker-icon.player, .no-anim .leaflet-marker-icon.player { transition: none; }

.mk { position: relative; width: 0; height: 0; }
.mk .pin { position: absolute; left: -15px; top: -38px; width: 30px; height: 38px; filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.45)); }
.mk .pin svg.shape { width: 30px; height: 38px; display: block; }
.mk .pin svg.i { position: absolute; left: 7px; top: 6px; width: 16px; height: 16px; color: #fff; stroke-width: 2.3; }
.mk .lbl { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); white-space: nowrap; font-size: 11.5px; font-weight: 700;
  padding: 1px 7px; border-radius: 6px; background: rgba(10, 12, 16, 0.72); color: #fff; display: none; }
.zoom-labels .mk .lbl { display: block; }
.mk.mine .pin { filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.45)) saturate(0.9); }
.mk.mine .pin::after { content: ""; position: absolute; right: -3px; top: -3px; width: 11px; height: 11px; border-radius: 50%; background: #fff;
  box-shadow: inset 0 0 0 3px var(--accent-2); }
.spawn { width: 0; height: 0; position: relative; }
.spawn i { position: absolute; left: -9px; top: -9px; width: 18px; height: 18px; border-radius: 50%; border: 3px solid #fff; background: #e85d75; box-shadow: 0 0 0 4px rgba(232, 93, 117, 0.3), 0 2px 8px rgba(0, 0, 0, 0.5); }

.claim-label { background: transparent; border: 0; box-shadow: none; color: #fff; font-weight: 800; font-size: 12px; letter-spacing: 0.02em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85), 0 0 8px rgba(0, 0, 0, 0.5); padding: 0; white-space: nowrap; }
.claim-label::before { display: none; }

.leaflet-popup-content-wrapper { background: var(--panel-solid); color: var(--text); border-radius: 14px; box-shadow: var(--shadow); border: 1px solid var(--border); }
.leaflet-popup-tip { background: var(--panel-solid); }
.leaflet-popup-content { margin: 14px 16px; font: inherit; min-width: 200px; }
.leaflet-container a.leaflet-popup-close-button { color: var(--text-3); top: 6px; right: 6px; }
.pop h4 { margin: 0 0 2px; font-size: 15px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.pop .sub { color: var(--text-3); font-size: 12px; margin-bottom: 8px; }
.pop .xyz { font-family: var(--mono); font-size: 12.5px; color: var(--text-2); }
.pop .acts { display: flex; gap: 6px; margin-top: 12px; }
.pop .acts button { flex: 1; height: 32px; border-radius: 9px; border: 1px solid var(--border-2); background: var(--panel-2); font-weight: 650; font-size: 12.5px; }
.pop .acts button:hover { background: var(--panel-3); }
.pop .acts button.del { color: var(--danger); }

/* ---------- телефон: панель — шторка снизу ---------- */
@media (max-width: 720px) {
  #side { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; height: 52vh; border-radius: 20px; }
  body.side-closed #side { transform: translateY(calc(100% - 66px)); }
  body.side-closed #open-side { display: none; }
  #side header { cursor: pointer; }
  #side header::before { content: ""; position: absolute; top: 6px; left: 50%; transform: translateX(-50%); width: 38px; height: 4px; border-radius: 2px; background: var(--border-2); }
  #tools { top: 12px; right: 12px; }
  #layers { top: 12px; right: 64px; left: 12px; width: auto; max-height: calc(48vh - 24px); }
  #coords, body:not(.side-closed) #coords { top: 12px; bottom: auto; left: 12px; transform: none; }
  #coords span { padding: 4px 6px; }
  #scale { display: none; }
  #follow, body:not(.side-closed) #follow { top: 60px; left: 12px; transform: none; }
  #toast { bottom: auto; top: 64px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
