:root {
  --bg: #0a0a09;
  --panel: #141412;
  --panel-2: #1c1c19;
  --border: #2c2b25;
  --text: #e9e6d8;
  --muted: #9a9a86;
  --accent: #d4c24f;
  --accent-dim: #8a7f3e;
  --danger: #c8553d;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }
button {
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 6px;
  padding: 5px 10px; cursor: pointer;
}
button:hover { border-color: var(--accent-dim); }
button.on, button.primary { background: var(--accent); color: #151510; border-color: var(--accent); }
button.danger { color: var(--danger); }
input[type=text], input[type=search], input[type=password], input:not([type]), select, textarea {
  background: #151512; border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; width: 100%;
}
.grow { flex: 1; }
.err { color: var(--danger); margin: 6px 0; }
[hidden] { display: none !important; }

.sh { flex: none; height: 56px; padding: 0 8px 0 16px; }
.sh .sh-brand { font-size: 26px; }
.sh .sh-brand img { height: 26px; }
/* editor toolbar under the site header (only while editing on a desktop) */
.mbar { display: none; }
body.editing .mbar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px; flex: none;
  padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.ed-slot { flex-wrap: wrap; gap: 6px; align-items: center; }
.ed-toolbar { flex-wrap: wrap; }
.mapwrap { flex: 1; min-height: 0; display: flex; position: relative; }
.mbar button, .mbar select { white-space: nowrap; }
.mbar .ed-status { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
/* dark zoom control, like the rest of the site */
.leaflet-bar, .leaflet-touch .leaflet-bar { border: 1px solid var(--border); border-radius: 8px; background: rgba(18, 18, 16, .94); box-shadow: 0 2px 10px rgba(0, 0, 0, .5); }
.leaflet-bar a, .leaflet-bar a:hover, .leaflet-touch .leaflet-bar a {
  background: transparent; color: var(--text); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
}
.leaflet-bar a:hover { color: var(--accent); }
.leaflet-bar a:last-child { border-bottom: 0; }
.map { flex: 1; min-width: 0; background: #0c0c0b; position: relative; }
.map.crosshair, .map.crosshair .leaflet-interactive { cursor: crosshair; }

.results { list-style: none; margin: 4px 0 0; padding: 0; }
.results button { width: 100%; text-align: left; border-radius: 0; border-width: 0 0 1px; }
.cats-head { display: flex; align-items: center; gap: 6px; margin: 14px 0 6px; color: var(--muted); }
.cats-head button { padding: 1px 8px; font-size: 12px; }
.cats { list-style: none; margin: 0; padding: 0; }
.cats li {
  display: flex; align-items: center; gap: 8px; padding: 5px 6px;
  border-radius: 6px; border: 1px solid transparent; cursor: pointer;
}
.cats li:hover { background: var(--panel-2); }
.cats li.active { border-color: var(--accent); }
.cats .cat-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cats .cat-n { color: var(--muted); font-size: 12px; }
.ico { display: inline-flex; width: 18px; height: 18px; }
.ico svg { width: 100%; height: 100%; }

.mk {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--panel); color: var(--c, var(--accent));
  border: 2px solid var(--c, var(--accent)); box-shadow: 0 1px 4px rgba(0, 0, 0, .6);
}
.mk .ico { width: 18px; height: 18px; }
.mk.sel { box-shadow: 0 0 0 3px rgba(212, 194, 79, .6); }

.leaflet-popup.card-popup .leaflet-popup-content-wrapper {
  background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 10px;
}
.leaflet-popup.card-popup .leaflet-popup-tip { background: var(--panel); }
.leaflet-popup.card-popup .leaflet-popup-content { margin: 12px 14px; }
.card { max-height: 320px; overflow: auto; }
.card h3 { margin: 0 0 2px; font-size: 16px; }
.card-cat { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.card-text { white-space: pre-wrap; margin: 0 0 8px; }
.card-photos { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.card-photos img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; display: block; }

.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1200; max-height: 60vh; overflow: auto;
  padding: 14px 16px 18px; background: var(--panel); border-top: 1px solid var(--accent-dim);
  border-radius: 14px 14px 0 0;
}
.sheet .card-x { position: absolute; top: 6px; right: 8px; font-size: 20px; line-height: 1; padding: 2px 9px; }
.notice {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%); z-index: 1300;
  background: var(--panel); border: 1px solid var(--accent-dim); border-radius: 8px; padding: 10px 16px;
  max-width: 90vw;
}

.dlg { background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 10px; padding: 18px; }
.dlg::backdrop { background: rgba(0, 0, 0, .6); }
.dlg label { display: block; margin: 8px 0; }
.dlg .row { display: flex; gap: 8px; margin-top: 12px; }
.hint { color: var(--muted); font-size: 12px; }

/* editor */
.ed-slot { display: none; }
body.editing .ed-slot { display: flex; }
.ed-toolbar { display: flex; align-items: center; gap: 6px; }
.ed-sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.ed-status { color: var(--muted); font-size: 12px; margin-left: 8px; }
.ed-status.error { color: var(--danger); }
.ed-status.ok { color: #8fbf6a; }
#props-slot { display: none; }
body.editing #props-slot { display: block; }
.ed-props { width: 310px; height: 100%; overflow: auto; padding: 12px; background: var(--panel); border-left: 1px solid var(--border); }
.ed-props h2 { font-size: 15px; margin: 0 0 10px; }
.ed-props label { display: block; margin: 10px 0 2px; color: var(--muted); font-size: 12px; }
.ed-props .row { display: flex; gap: 8px; align-items: center; }
.ed-props input[type=color] { width: 44px; height: 30px; padding: 0; border: 1px solid var(--border); background: none; }
.ed-photos { display: flex; flex-wrap: wrap; gap: 6px; }
.ed-photos .ph { position: relative; width: 64px; height: 64px; }
.ed-photos .ph img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.ed-photos .ph button { position: absolute; top: -6px; right: -6px; padding: 0 6px; line-height: 18px; border-radius: 50%; }
.dlg-list { max-height: 55vh; overflow: auto; min-width: min(640px, 80vw); }
.dlg-row { display: flex; gap: 6px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); }
.dlg-row input[type=text], .dlg-row select { width: auto; flex: 1; min-width: 0; }
.dlg-row { flex-wrap: wrap; }

/* icon picker (categories, personal marks) */
.ip-btn { display: inline-flex; align-items: center; gap: 6px; min-width: 0; max-width: 170px; }
.ip-btn.open { border-color: var(--accent); }
.ip-btn .ico { width: 20px; height: 20px; flex: none; }
.ip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ip-grid {
  flex-basis: 100%; display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); gap: 4px;
  max-height: 260px; overflow: auto; margin-top: 6px; padding: 6px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px;
}
.ip-grid[hidden] { display: none; }
.ip-group { grid-column: 1 / -1; color: var(--muted); font-size: 11px; margin: 4px 0 0; }
.ip-group:first-child { margin-top: 0; }
.ip-tile { display: flex; align-items: center; justify-content: center; height: 36px; padding: 0; }
.ip-tile .ico { width: 22px; height: 22px; }
.ip-tile.sel { border-color: var(--accent); color: var(--accent); }
.ed-props .ip-btn { max-width: 100%; }

/* personal marks */
.marks-row { display: flex; align-items: center; gap: 8px; padding: 5px 6px; cursor: pointer; }
.marks-row .cat-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.marks-row .cat-n { color: var(--muted); font-size: 12px; }
.marks-slot .hint { margin: 14px 0 0; }
.ed-mode { display: flex; gap: 4px; margin-right: 10px; }

/* proposals and reports */
.mk.pending { opacity: .65; border-style: dashed; }
.card-status { margin: 0 0 8px; padding: 2px 8px; border-radius: 6px; font-size: 12px; background: #2a2a1c; color: var(--accent); }
.card-status.rejected { background: #2e1c18; color: var(--danger); }
.report { margin-top: 10px; }
.report .link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; }
.report-form { margin-top: 6px; }
.report-form textarea { width: 100%; }
.ok { color: #8fbf6a; margin: 6px 0; }
.mod-row { align-items: flex-start; flex-wrap: wrap; }
.mod-info { flex: 1 1 260px; min-width: 0; }
.mod-text { white-space: pre-wrap; margin-top: 4px; }
.chip { display: inline-block; margin-top: 4px; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #2e1c18; color: var(--danger); }

/* floating panels over the map */
.mob { display: block; }
.mob-panel {
  position: absolute; z-index: 1050; left: 10px;
  background: rgba(18, 18, 16, .94); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .5);
}
.mob-title { top: 10px; width: 320px; display: flex; align-items: center; padding: 4px 10px; min-height: 44px; }
.mob-title-slot { flex: 1; min-width: 0; display: flex; }
.mob-title #map-select {
  max-width: none; min-width: 0; flex: 1 1 auto; width: 100%; background: transparent; border: 0; padding: 4px 0;
  font-size: 17px; font-weight: 600; appearance: none; -webkit-appearance: none; cursor: pointer;
  padding-right: 24px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239a9a86' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 2px center / 18px;
}
.mob-title #map-select option { background: var(--panel); }
.mob-ico { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 36px; padding: 0; background: #26261f; border-radius: 6px; }
.mob-ico .ico { width: 20px; height: 20px; }
.mob-tools { top: 64px; display: flex; gap: 6px; padding: 6px; }
.mob-tools .mob-ico { color: var(--accent); }
.mob-tools .mob-ico.off { color: var(--muted); }
#mob-mod { position: relative; }
#mob-mod[data-n]:not([data-n=""])::after {
  content: attr(data-n); position: absolute; top: -6px; right: -6px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 8px; background: var(--accent); color: #151510; font-size: 11px; line-height: 16px; text-align: center;
}
.mob-filters { top: 124px; display: flex; align-items: center; gap: 8px; padding: 8px 12px; min-width: 130px; }
.mob-filters .ico { width: 18px; height: 18px; color: var(--accent); }

/* filters dropdown */
.side {
  position: absolute; z-index: 1100; top: 168px; left: 10px; width: 320px; overflow: auto; padding: 10px;
  background: var(--panel);
  max-height: calc(100% - 180px); display: none;
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 4px 16px rgba(0, 0, 0, .6);
}
.side.open { display: block; }

/* zoom control as a dark floating panel */
.leaflet-top.leaflet-left { left: auto; right: 0; top: 10px; }
.leaflet-top.leaflet-left .leaflet-control { float: right; margin: 0 10px 0 0; }
.leaflet-bar a, .leaflet-touch .leaflet-bar a { width: 40px; height: 40px; line-height: 40px; }
.leaflet-control-zoom .mob-fit { display: flex; }
.mob-fit .ico { width: 20px; height: 20px; }

/* the editor has its own «Модерация» button */
body.editing #mob-mod { display: none !important; }

@media (max-width: 720px) {
  .desk-only { display: none; }
  .sh { height: 52px; }
  body.editing .mbar { display: none; }
  .mob-title { right: 10px; width: auto; }
  .side { right: 10px; width: auto; }
  .leaflet-top.leaflet-left { top: 64px; }
  .sheet { max-height: 55vh; }
}

/* tactics mode */
.mob-ico.on { background: var(--accent); color: #151510; }
body.tactics #side, body.tactics .mbar, body.tactics #mob-search, body.tactics #mob-marks,
body.tactics #mob-filters, body.tactics #mob-mod { display: none !important; }
.tac-panel {
  position: absolute; z-index: 1100; top: 124px; left: 10px; width: 320px; max-height: calc(100% - 140px); overflow: auto;
  padding: 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .6);
}
.tac-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.tac-state { color: var(--muted); font-size: 12px; }
.tac-state.bad { color: var(--danger); }
.tac-plan-btns { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.tac-squads { list-style: none; margin: 8px 0 0; padding: 0; }
.tac-row { display: flex; align-items: center; gap: 8px; padding: 4px 2px; cursor: pointer; }
.tac-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; }
@media (max-width: 720px) {
  .tac-panel { right: 10px; width: auto; top: 124px; }
}
.map.tac-pencil, .map.tac-pencil .leaflet-interactive { cursor: crosshair; }
.tac-editor { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.tac-editor label { display: block; margin: 8px 0 2px; color: var(--muted); font-size: 12px; }
.tac-editor.disabled .tac-controls { opacity: .5; pointer-events: none; }
.tac-tools, .tac-widths, .tac-retry { display: flex; gap: 6px; flex-wrap: wrap; }
.tac-tools button.on, .tac-widths button.on { background: var(--accent); color: #151510; }
.tac-status { min-height: 18px; }

/* Tactics: arrows, zones, markers and text (stage 3) */
.tac-mk { border-width: 2px; }
.tac-text-wrap { background: none; border: 0; }
.tac-text {
  display: inline-block; max-width: 220px; padding: 2px 6px; font-weight: 600; font-size: 13px; line-height: 1.25;
  background: rgba(10, 10, 9, .72); border-radius: 4px; white-space: pre-wrap; transform: translate(-50%, -50%);
  text-shadow: 0 1px 2px #000;
}
.tac-head-wrap { background: none; border: 0; }
.tac-head svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .7)); }
.leaflet-tooltip.tac-label {
  background: rgba(10, 10, 9, .78); color: var(--text); border: 0; box-shadow: none; padding: 1px 6px; font-size: 12px;
}
.leaflet-tooltip.tac-label::before { display: none; }
.tac-editor input[type=text] { margin-bottom: 2px; }
.tac-tools button { flex: 1 1 auto; }
.tac-panel select { margin-bottom: 6px; }

/* crowd-sourced map notice */
.crowd-note {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 1060;
  display: flex; align-items: flex-start; gap: 10px; max-width: min(560px, calc(100vw - 20px));
  padding: 8px 10px 8px 14px; font-size: 13px; line-height: 1.4;
  background: rgba(18, 18, 16, .94); border: 1px solid var(--accent-dim); border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .5);
}
.crowd-note[hidden] { display: none; }
.crowd-note b { color: var(--accent); }
.crowd-note button { flex: none; font-size: 18px; line-height: 1; padding: 0 8px; }

/* ---------- лёгкое движение (не мешает работе с картой) ---------- */
@keyframes m-in { from { opacity: 0; translate: 0 -6px; } to { opacity: 1; translate: none; } }
@keyframes m-pop { from { opacity: 0; scale: .96; } to { opacity: 1; scale: 1; } }
@keyframes m-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes m-up { from { translate: 0 100%; } to { translate: none; } }
@keyframes m-ring { 0% { box-shadow: 0 0 0 3px rgba(212, 194, 79, .6); } 70% { box-shadow: 0 0 0 9px rgba(212, 194, 79, 0); } 100% { box-shadow: 0 0 0 3px rgba(212, 194, 79, .6); } }

button { transition: border-color .15s, background .15s, color .15s; }
.mob-panel { animation: m-in .4s cubic-bezier(.2, .7, .2, 1) both; }
.mob-tools { animation-delay: .06s; }
.mob-filters { animation-delay: .12s; }
.leaflet-control-zoom { animation: m-in .4s .1s both; }
.side.open, .tac-panel { animation: m-in .22s ease-out both; }
.leaflet-popup.card-popup .leaflet-popup-content-wrapper { animation: m-pop .2s ease-out both; transform-origin: 50% 100%; }
.sheet { animation: m-up .28s cubic-bezier(.2, .7, .2, 1) both; }
.notice { animation: m-in .3s ease-out both; }
.dlg[open] { animation: m-pop .2s ease-out both; }
.dlg[open]::backdrop { animation: m-fade .2s ease-out both; }
.cats li, .marks-row, .tac-row, .results button { transition: background .15s, border-color .15s; }
.mk { transition: scale .15s ease-out; }
.mk:hover { scale: 1.15; }
.mk.sel { animation: m-ring 1.8s ease-out infinite; }
.leaflet-bar a { transition: color .15s, background .15s; }

@media (prefers-reduced-motion: reduce) {
  .mob-panel, .leaflet-control-zoom, .side.open, .tac-panel, .leaflet-popup.card-popup .leaflet-popup-content-wrapper,
  .sheet, .notice, .dlg[open], .dlg[open]::backdrop, .mk.sel { animation: none; }
  .mk { transition: none; }
  .mk:hover { scale: none; }
}
