/* ==========================================================================
   Chernarus Tactical Map — оформление
   ========================================================================== */

:root {
  --bg: #080c09;
  --panel: #10150f;
  --panel-2: #151b13;
  --panel-3: #1b2219;
  --line: #2a3326;
  --line-soft: #222a1f;
  --text: #e8ebdf;
  --muted: #8d9887;
  --muted-2: #6c7667;
  --accent: #c8e06a;
  --accent-2: #e8b44a;
  --blue: #4da3ff;
  --danger: #ff6b6b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 14px 40px rgba(0, 0, 0, .5);
  --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "Consolas", "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

input, textarea, select {
  background: #0b100a;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
}

input:focus, textarea:focus, select:focus {
  border-color: #5d7038;
  box-shadow: 0 0 0 3px rgba(200, 224, 106, .09);
}

textarea {
  resize: vertical;
  min-height: 64px;
  line-height: 1.45;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #2b3527;
  border-radius: 10px;
  border: 2px solid var(--panel);
}
::-webkit-scrollbar-thumb:hover { background: #3a4834; }

::selection { background: rgba(200, 224, 106, .28); }

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.ico {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  fill: currentColor;
  stroke: none;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Верхняя панель
   -------------------------------------------------------------------------- */
.topbar {
  height: 60px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 16px;
  background:
    linear-gradient(180deg, rgba(28, 35, 23, .96), rgba(14, 19, 12, .98)),
    repeating-linear-gradient(135deg, rgba(255,255,255,.015) 0 8px, transparent 8px 16px);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 40;
}

.topbar::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(200, 224, 106, .35), transparent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  flex: 0 0 auto;
  min-width: 205px;
}

.brand-badge {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -.5px;
  color: #0d120a;
  background: linear-gradient(145deg, var(--accent), #8ea83c);
  box-shadow: 0 4px 14px rgba(200, 224, 106, .2), inset 0 1px 0 rgba(255,255,255,.35);
}

.brand-text h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.1;
  letter-spacing: 2.4px;
  font-weight: 700;
}

.brand-text span {
  display: block;
  font-size: 10.5px;
  letter-spacing: 1.4px;
  color: var(--muted);
  text-transform: uppercase;
  margin-top: 2px;
}

.coords {
  display: flex;
  align-items: stretch;
  gap: 2px;
  background: rgba(0, 0, 0, .28);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 4px;
  flex: 0 1 auto;
}

.coord {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 2px 12px;
  min-width: 72px;
  border-radius: 7px;
  background: rgba(255, 255, 255, .02);
}

.coord span {
  font-size: 9px;
  letter-spacing: 1.2px;
  color: var(--muted-2);
  text-transform: uppercase;
  line-height: 1;
  margin-bottom: 3px;
}

.coord b {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: #d7dfc7;
  line-height: 1.1;
}

.coord.grid-coord b { color: var(--accent-2); }

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 7px;
}

.top-divider {
  width: 1px;
  height: 24px;
  background: var(--line);
  margin: 0 3px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #b9c3ae;
  position: relative;
  transition: background .15s, color .15s, transform .1s;
}

.icon-btn:hover:not(:disabled) {
  background: rgba(255, 255, 255, .07);
  color: var(--text);
}

.icon-btn:active:not(:disabled) { transform: scale(.94); }

.icon-btn:disabled {
  opacity: .32;
  cursor: default;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, transform .1s;
}

.btn:active { transform: translateY(1px); }

.btn .ico { width: 17px; height: 17px; }

.btn.ghost {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .025);
  color: #cdd5c2;
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, .07);
  border-color: #3b4734;
}

.btn.primary {
  background: linear-gradient(180deg, #cfe678, #a9c44f);
  color: #131a0b;
  border: 1px solid #d8eb8d;
  box-shadow: 0 4px 16px rgba(200, 224, 106, .17);
}

.btn.primary:hover { filter: brightness(1.06); }

.btn.danger-ghost {
  border: 1px solid rgba(255, 107, 107, .25);
  background: rgba(255, 107, 107, .06);
  color: #ff9d9d;
}

.btn.danger-ghost:hover {
  background: rgba(255, 107, 107, .13);
  border-color: rgba(255, 107, 107, .45);
}

.sync-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .03);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  margin-left: 4px;
  max-width: 150px;
}

.sync-pill:hover { background: rgba(255, 255, 255, .07); }

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #737d6e;
  box-shadow: 0 0 0 3px rgba(115, 125, 110, .13);
  flex: 0 0 auto;
}

.sync-pill.online { color: #cfe8a2; border-color: rgba(140, 190, 80, .35); }
.sync-pill.online .status-dot { background: #8bd450; box-shadow: 0 0 0 3px rgba(139, 212, 80, .16), 0 0 10px rgba(139, 212, 80, .55); }
.sync-pill.connecting .status-dot { background: var(--accent-2); animation: pulse 1.1s infinite; }
.sync-pill.error { color: #ffaaaa; border-color: rgba(255, 107, 107, .3); }
.sync-pill.error .status-dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(255, 107, 107, .15); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .3; }
}

/* Подсказки --------------------------------------------------------------- */
[data-tip] { position: relative; }

.tool-btn::after, .icon-btn::after {
  content: attr(data-tip);
  position: absolute;
  z-index: 100;
  padding: 6px 9px;
  border-radius: 6px;
  background: #1d261a;
  border: 1px solid #364430;
  color: #e3e9d9;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(3px);
  transition: opacity .12s, transform .12s;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .4);
}

.icon-btn::after {
  top: calc(100% + 7px);
  right: 0;
}

.tool-btn::after {
  left: calc(100% + 12px);
  top: 50%;
  transform: translateY(-50%) translateX(-3px);
}

.icon-btn:hover::after, .tool-btn:hover::after {
  opacity: 1;
  transform: translateY(0);
}

.tool-btn:hover::after {
  transform: translateY(-50%) translateX(0);
}

/* --------------------------------------------------------------------------
   Каркас
   -------------------------------------------------------------------------- */
#app {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.workspace {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

/* --------------------------------------------------------------------------
   Боковая панель
   -------------------------------------------------------------------------- */
.sidebar {
  width: 326px;
  flex: 0 0 326px;
  background:
    linear-gradient(180deg, rgba(21, 27, 19, .97), rgba(13, 18, 11, .99));
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 30;
  transition: transform .22s ease;
}

.sidebar-head {
  padding: 10px 10px 0;
  border-bottom: 1px solid var(--line-soft);
}

.tabs {
  display: flex;
  gap: 3px;
  padding: 4px;
  background: rgba(0, 0, 0, .22);
  border-radius: 10px;
}

.tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  position: relative;
  transition: background .15s, color .15s;
}

.tab .ico { width: 16px; height: 16px; }

.tab:hover { color: #d8e0cd; background: rgba(255, 255, 255, .04); }
.tab.active {
  background: rgba(200, 224, 106, .11);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(200, 224, 106, .16);
}

.tab-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #8bd450;
  box-shadow: 0 0 6px rgba(139, 212, 80, .8);
}

.sidebar-close { display: none; }

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 12px 18px;
  min-height: 0;
  overscroll-behavior: contain;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeIn .2s ease; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

.side-section {
  margin-bottom: 16px;
}

.side-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--muted-2);
  font-weight: 700;
  margin: 0 2px 8px;
}

.count {
  font-family: var(--mono);
  font-size: 10.5px;
  background: rgba(255, 255, 255, .06);
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--muted);
  letter-spacing: 0;
}

/* Поиск ------------------------------------------------------------------- */
.search-field {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 8px 0 10px;
  height: 40px;
  background: #0b100a;
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: border-color .15s, box-shadow .15s;
}

.search-field:focus-within {
  border-color: #5d7038;
  box-shadow: 0 0 0 3px rgba(200, 224, 106, .08);
}

.search-field > .ico { width: 17px; height: 17px; color: var(--muted-2); }

.search-field input {
  flex: 1;
  border: 0;
  background: none;
  padding: 0;
  height: 100%;
  font-size: 13px;
  box-shadow: none;
  min-width: 0;
}

.search-field input:focus { box-shadow: none; border: 0; }
.search-field input::-webkit-search-cancel-button { display: none; }

.mini-btn {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  flex: 0 0 auto;
  transition: background .15s, color .15s;
}

.mini-btn .ico { width: 15px; height: 15px; }
.mini-btn:hover { background: rgba(255, 255, 255, .08); color: var(--text); }

/* Чипы категорий ---------------------------------------------------------- */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 29px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, .02);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  transition: all .15s;
  user-select: none;
}

.chip .chip-emoji { font-size: 13px; line-height: 1; }
.chip .chip-count {
  font-size: 10px;
  font-family: var(--mono);
  opacity: .55;
}

.chip:hover { border-color: #3c4a35; color: #d5ddca; }

.chip.active {
  color: var(--chip-color, var(--accent));
  border-color: color-mix(in srgb, var(--chip-color, var(--accent)) 42%, transparent);
  background: color-mix(in srgb, var(--chip-color, var(--accent)) 13%, transparent);
}

.chip.active .chip-emoji { filter: none; }
.chip:not(.active) .chip-emoji { filter: grayscale(1); opacity: .5; }

/* Слои -------------------------------------------------------------------- */
.layer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, .015);
  font-size: 12px;
  color: #c5ceba;
  cursor: pointer;
  user-select: none;
  transition: background .15s, border-color .15s;
}

.check-row:hover { background: rgba(255, 255, 255, .045); border-color: #364430; }

.check-row input[type="checkbox"] {
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 4px;
  border: 1px solid #46543e;
  background: #0b100a;
  display: grid;
  place-items: center;
  padding: 0;
  flex: 0 0 auto;
  cursor: pointer;
  transition: all .15s;
}

.check-row input[type="checkbox"]::after {
  content: "";
  width: 7px;
  height: 4px;
  border-left: 2px solid #131a0b;
  border-bottom: 2px solid #131a0b;
  transform: rotate(-45deg) translateY(-1px) scale(0);
  transition: transform .13s;
}

.check-row input[type="checkbox"]:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.check-row input[type="checkbox"]:checked::after { transform: rotate(-45deg) translateY(-1px) scale(1); }

/* Список объектов --------------------------------------------------------- */
.list-section { margin-bottom: 10px; }

.object-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.obj-row {
  display: flex;
  align-items: stretch;
  border-radius: 9px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, .022);
  transition: background .13s, border-color .13s;
  overflow: hidden;
}

.obj-row:hover { background: rgba(255, 255, 255, .055); }

.obj-row.selected {
  border-color: rgba(200, 224, 106, .35);
  background: rgba(200, 224, 106, .08);
}

.obj-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  text-align: left;
  min-width: 0;
}

.obj-ico {
  width: 27px;
  height: 27px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 14px;
  line-height: 1;
  flex: 0 0 auto;
  background: color-mix(in srgb, var(--c, #889) 15%, transparent);
  border: 1px solid color-mix(in srgb, var(--c, #889) 35%, transparent);
}

.obj-ico.shape-ico {
  font-size: 12px;
  color: var(--c, #aaa);
  font-weight: 800;
  font-family: var(--mono);
}

.obj-text {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.obj-text b {
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #dde4d3;
}

.obj-text small {
  font-size: 10.5px;
  color: var(--muted-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--mono);
}

.obj-del {
  width: 30px;
  height: auto;
  border-radius: 0;
  opacity: 0;
}

.obj-row:hover .obj-del { opacity: 1; }
.obj-del:hover { color: var(--danger); background: rgba(255, 107, 107, .1); }

.obj-group-title {
  font-size: 10px;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--muted-2);
  font-weight: 700;
  margin: 9px 2px 4px;
}

.obj-group-title:first-child { margin-top: 0; }

.landmark .obj-ico {
  background: rgba(200, 224, 106, .07);
  border-color: rgba(200, 224, 106, .18);
}

.empty-note {
  padding: 14px 12px;
  border: 1px dashed var(--line);
  border-radius: 9px;
  color: var(--muted-2);
  font-size: 12px;
  text-align: center;
  line-height: 1.5;
}

/* Свойства ---------------------------------------------------------------- */
.properties {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(28, 35, 23, .65), rgba(15, 20, 13, .9));
  padding: 12px;
  animation: fadeIn .18s ease;
}

.prop-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}

.prop-head .obj-ico { width: 34px; height: 34px; font-size: 17px; }

.prop-titles { flex: 1; min-width: 0; }
.prop-titles b { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prop-titles small { font-family: var(--mono); font-size: 10.5px; color: var(--muted-2); }

.field { margin-bottom: 10px; }

.field label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--muted-2);
  font-weight: 700;
  margin: 0 1px 5px;
}

.field input, .field textarea { font-size: 12.5px; padding: 8px 10px; }

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.swatch {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 2px solid transparent;
  position: relative;
  transition: transform .12s;
}

.swatch:hover { transform: scale(1.12); }
.swatch.active { border-color: #eef4e2; box-shadow: 0 0 0 2px rgba(0, 0, 0, .55); }

.range-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.range-row input[type="range"] {
  padding: 0;
  border: 0;
  background: none;
  height: 20px;
  accent-color: var(--accent);
}

.range-row output {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  min-width: 28px;
  text-align: right;
}

.prop-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  background: rgba(0, 0, 0, .25);
  border-radius: 7px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--muted);
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.prop-meta button {
  margin-left: auto;
  color: var(--accent);
  font-size: 10.5px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
}

.prop-meta button .ico { width: 13px; height: 13px; }

.prop-actions { display: flex; gap: 7px; margin-top: 2px; }
.prop-actions .btn { flex: 1; height: 32px; font-size: 12px; }

/* Нижняя часть панели ----------------------------------------------------- */
.sidebar-foot {
  border-top: 1px solid var(--line-soft);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: rgba(0, 0, 0, .18);
}

.sidebar-foot .btn { height: 32px; font-size: 12px; }

.save-note {
  font-size: 10px;
  color: var(--muted-2);
  text-align: center;
  letter-spacing: .3px;
}

/* --------------------------------------------------------------------------
   Синхронизация
   -------------------------------------------------------------------------- */
.sync-hero {
  display: flex;
  gap: 11px;
  padding: 12px;
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(200, 224, 106, .08), rgba(200, 224, 106, .015));
  border: 1px solid rgba(200, 224, 106, .14);
  margin-bottom: 12px;
}

.sync-hero-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(200, 224, 106, .11);
  color: var(--accent);
  flex: 0 0 auto;
}

.sync-hero-icon .ico { width: 19px; height: 19px; }
.sync-hero b { display: block; font-size: 13px; margin-bottom: 3px; }
.sync-hero p { margin: 0; font-size: 11.5px; line-height: 1.45; color: var(--muted); }

.status-card {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 3px 10px;
  background: rgba(0, 0, 0, .2);
  margin-bottom: 16px;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  font-size: 11.5px;
  color: var(--muted);
  border-bottom: 1px solid rgba(255, 255, 255, .035);
}

.status-row:last-child { border-bottom: 0; }
.status-row b { color: #d6dfca; font-weight: 600; font-size: 11.5px; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 190px; }

.badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .06);
  font-size: 10.5px !important;
}

.badge.online { background: rgba(139, 212, 80, .14); color: #b9e88d !important; }
.badge.error { background: rgba(255, 107, 107, .13); color: #ffa5a5 !important; }
.badge.connecting { background: rgba(232, 180, 74, .14); color: #f3cc85 !important; }

.sync-actions { display: flex; gap: 7px; margin-top: 4px; }
.sync-actions .btn { flex: 1; height: 34px; font-size: 12px; }

.online-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.user-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .025);
  font-size: 12px;
  color: #cfd7c4;
}

.user-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c, #8bd450);
  box-shadow: 0 0 8px color-mix(in srgb, var(--c, #8bd450) 70%, transparent);
  flex: 0 0 auto;
}

.user-row .you {
  font-size: 9.5px;
  color: var(--muted-2);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: auto;
}

.side-note {
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.55;
  background: rgba(255, 255, 255, .012);
}

.side-note b { color: #cfd8c4; font-size: 12px; }
.side-note ol { margin: 7px 0; padding-left: 18px; }
.side-note li { margin-bottom: 4px; }
.side-note p { margin: 7px 0 0; }
.side-note code {
  font-family: var(--mono);
  font-size: 10.5px;
  background: rgba(0, 0, 0, .4);
  border: 1px solid var(--line-soft);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--accent-2);
  word-break: break-all;
}

/* --------------------------------------------------------------------------
   Карта
   -------------------------------------------------------------------------- */
.map-area {
  flex: 1;
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 60% 40%, #0e1710 0%, #070b08 70%, #040604 100%);
  touch-action: none;
}

#map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

#map.tool-marker, #map.tool-line, #map.tool-polygon, #map.tool-circle,
#map.tool-text, #map.tool-ruler, #map.tool-eraser {
  cursor: crosshair;
}

#map.tool-pan { cursor: grab; }
#map.grabbing { cursor: grabbing !important; }

#map::after { content: ""; }

.map-mobile-menu {
  display: none;
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 20;
  background: rgba(14, 20, 12, .9);
  border: 1px solid var(--line);
  border-radius: 10px;
  backdrop-filter: blur(8px);
}

.tool-rail {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px;
  border-radius: 14px;
  background: rgba(14, 20, 12, .88);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  z-index: 20;
}

.tool-btn {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a9b49f;
  position: relative;
  transition: background .14s, color .14s, transform .1s;
}

.tool-btn .ico { width: 20px; height: 20px; }

.tool-btn:hover {
  background: rgba(255, 255, 255, .08);
  color: #eef3e6;
}

.tool-btn:active { transform: scale(.92); }

.tool-btn.active {
  background: rgba(200, 224, 106, .16);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(200, 224, 106, .22);
}

.rail-sep {
  width: 24px;
  height: 1px;
  background: var(--line);
  margin: 4px 0;
}

.zoom-rail {
  position: absolute;
  right: 14px;
  top: 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 6px;
  border-radius: 13px;
  background: rgba(14, 20, 12, .88);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  z-index: 20;
}

.zoom-rail .tool-btn { width: 36px; height: 36px; }
.zoom-rail .tool-btn::after {
  left: auto;
  right: calc(100% + 12px);
}

.online-bar {
  position: absolute;
  top: 14px;
  right: 74px;
  display: flex;
  gap: 5px;
  z-index: 20;
  max-width: 45%;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(14, 20, 12, .9);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
  color: #d2dbca;
  backdrop-filter: blur(8px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .3);
}

.user-pill .user-dot { width: 7px; height: 7px; }

/* Категории при рисовании ------------------------------------------------- */
.cat-bar {
  position: absolute;
  left: 50%;
  bottom: 58px;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
  padding: 6px;
  border-radius: 12px;
  background: rgba(14, 20, 12, .93);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  z-index: 20;
  max-width: min(92vw, 640px);
  overflow-x: auto;
}

.cat-bar button {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  min-width: 48px;
  padding: 5px 7px;
  border-radius: 8px;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  transition: all .14s;
}

.cat-bar button span:first-child { font-size: 16px; line-height: 1; filter: grayscale(.8); }
.cat-bar button:hover { background: rgba(255, 255, 255, .06); color: #dfe6d5; }
.cat-bar button.active {
  background: color-mix(in srgb, var(--c) 15%, transparent);
  border-color: color-mix(in srgb, var(--c) 40%, transparent);
  color: var(--c);
}
.cat-bar button.active span:first-child { filter: none; }

/* HUD --------------------------------------------------------------------- */
.map-hud {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 198px 14px 16px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  pointer-events: none;
  z-index: 10;
}

.scalebar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(10, 14, 8, .72);
  border: 1px solid rgba(255, 255, 255, .07);
  backdrop-filter: blur(6px);
  min-width: 90px;
}

.scalebar-line {
  height: 5px;
  border-left: 1px solid rgba(255, 255, 255, .7);
  border-right: 1px solid rgba(255, 255, 255, .7);
  border-bottom: 1px solid rgba(255, 255, 255, .7);
  width: 100px;
  transition: width .15s;
}

.scalebar span {
  font-family: var(--mono);
  font-size: 10px;
  color: #c3cdb9;
  text-align: center;
}

.hint {
  margin-left: auto;
  padding: 7px 12px;
  border-radius: 8px;
  background: rgba(10, 14, 8, .74);
  border: 1px solid rgba(255, 255, 255, .06);
  color: #9faa95;
  font-size: 11px;
  line-height: 1.4;
  backdrop-filter: blur(6px);
  max-width: 480px;
  text-align: center;
  transition: opacity .2s;
}

.hint b { color: var(--accent); font-weight: 600; }

/* Мини-карта -------------------------------------------------------------- */
.minimap {
  position: absolute;
  right: 14px;
  bottom: 14px;
  width: 168px;
  height: 168px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #070b08;
  box-shadow: var(--shadow);
  z-index: 15;
  transition: transform .15s;
}

.minimap canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: pointer;
}

.minimap:hover { transform: scale(1.02); }

.minimap-label {
  position: absolute;
  top: 6px;
  left: 8px;
  font-size: 8.5px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .55);
  text-shadow: 0 1px 3px #000;
  pointer-events: none;
  font-weight: 700;
}

.map-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #070b08;
  z-index: 50;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .5px;
  transition: opacity .4s;
}

.map-loading.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.spinner {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(200, 224, 106, .2);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* --------------------------------------------------------------------------
   Модальные окна
   -------------------------------------------------------------------------- */
.modal {
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--text);
  max-width: min(560px, calc(100vw - 28px));
  width: 100%;
  margin: auto;
}

.modal::backdrop {
  background: rgba(3, 5, 3, .72);
  backdrop-filter: blur(4px);
}

.modal-box {
  background: linear-gradient(180deg, #182015, #0f150d);
  border: 1px solid #33402d;
  border-radius: 16px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, .7);
  padding: 20px;
  animation: modalIn .2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: none; }
}

.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.modal-head .modal-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: rgba(200, 224, 106, .11);
  color: var(--accent);
  flex: 0 0 auto;
}

.modal-head h2 {
  margin: 0;
  font-size: 16px;
  letter-spacing: .3px;
  flex: 1;
}

.modal-head .icon-btn { flex: 0 0 auto; }

.modal-body {
  font-size: 13px;
  line-height: 1.6;
  color: #c3ccb8;
  max-height: min(62vh, 520px);
  overflow-y: auto;
}

.modal-body p { margin: 0 0 10px; }
.modal-body b { color: #e4ebda; }

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.modal-actions .btn { min-width: 100px; }

.help-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0 14px;
}

.help-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .03);
  border: 1px solid var(--line-soft);
  font-size: 12px;
}

.help-item kbd {
  font-family: var(--mono);
  font-size: 10px;
  background: #0a0e08;
  border: 1px solid #37422f;
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 2px 6px;
  color: var(--accent);
  flex: 0 0 auto;
  min-width: 24px;
  text-align: center;
}

.help-item span { color: #bcc6b1; }

.help-section-title {
  font-size: 10.5px;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  color: var(--muted-2);
  font-weight: 700;
  margin: 16px 0 8px;
}

.help-section-title:first-child { margin-top: 0; }

.help-list {
  padding-left: 18px;
  margin: 6px 0;
  color: #b9c3ae;
}

.help-list li { margin-bottom: 5px; }

.help-list code, .modal-body code {
  font-family: var(--mono);
  font-size: 11px;
  background: rgba(0, 0, 0, .4);
  border: 1px solid var(--line-soft);
  padding: 1px 5px;
  border-radius: 4px;
  color: var(--accent-2);
}

.modal-icon.danger { background: rgba(255, 107, 107, .12); color: var(--danger); }

/* --------------------------------------------------------------------------
   Тосты
   -------------------------------------------------------------------------- */
.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  z-index: 200;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 36px));
}

.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(24, 32, 20, .97);
  border: 1px solid #35422e;
  color: #d9e1ce;
  font-size: 12.5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
  animation: toastIn .2s ease;
  pointer-events: auto;
}

.toast.hide { animation: toastOut .2s ease forwards; }

.toast-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 12px;
  flex: 0 0 auto;
  background: rgba(200, 224, 106, .12);
  color: var(--accent);
}

.toast.error { border-color: rgba(255, 107, 107, .35); }
.toast.error .toast-icon { background: rgba(255, 107, 107, .13); color: var(--danger); }
.toast.success .toast-icon { background: rgba(139, 212, 80, .14); color: #9be05e; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(6px); }
}

/* --------------------------------------------------------------------------
   Адаптивность
   -------------------------------------------------------------------------- */
@media (max-width: 1080px) {
  .brand { min-width: 0; }
  .brand-text span { display: none; }
  .btn-labeled span { display: none; }
  .btn-labeled { padding: 0 10px; }
  .coords .grid-coord { display: none; }
  .minimap { width: 140px; height: 140px; }
}

@media (max-width: 860px) {
  .topbar { gap: 8px; padding: 0 10px; height: 54px; }
  .brand-badge { width: 32px; height: 32px; font-size: 13px; }
  .brand-text h1 { font-size: 14px; letter-spacing: 1.6px; }
  .coords { padding: 3px; }
  .coord { min-width: 60px; padding: 1px 8px; }
  .coord b { font-size: 11.5px; }
  .top-divider, #btn-help, #btn-undo, #btn-redo { display: none; }
  .sync-pill { max-width: 110px; font-size: 10.5px; padding: 0 8px; height: 30px; }
  .sync-pill #sync-pill-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  .workspace { position: relative; }

  .sidebar {
    position: absolute;
    inset: 0 auto 0 0;
    width: min(86vw, 330px);
    flex-basis: auto;
    transform: translateX(-102%);
    box-shadow: 20px 0 60px rgba(0, 0, 0, .55);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-close { display: inline-flex; position: absolute; right: 6px; top: 14px; }
  .sidebar-head { padding-right: 44px; }

  .map-mobile-menu { display: block; }

  .tool-rail {
    left: 50%;
    top: auto;
    bottom: 12px;
    transform: translateX(-50%);
    flex-direction: row;
    padding: 5px;
    max-width: calc(100vw - 20px);
    overflow-x: auto;
    gap: 1px;
  }

  .tool-rail .tool-btn { width: 34px; height: 34px; }
  .tool-rail .tool-btn .ico { width: 18px; height: 18px; }
  .tool-rail .rail-sep { width: 1px; height: 20px; margin: 0 3px; flex: 0 0 auto; }
  .tool-rail .tool-btn::after { display: none; }

  .zoom-rail { top: 12px; right: 10px; bottom: auto; flex-direction: row; padding: 4px; }
  .zoom-rail .tool-btn { width: 32px; height: 32px; }

  .minimap { display: none; }

  .map-hud { bottom: 58px; padding: 0 10px 8px; flex-direction: column; align-items: stretch; gap: 6px; }
  .map-area.cat-bar-open .map-hud { bottom: 124px; }
  .hint { max-width: none; font-size: 10.5px; padding: 5px 9px; text-align: left; }
  .scalebar { align-self: flex-start; padding: 5px 8px; }
  .scalebar span { font-size: 9px; }
  .scalebar-line { height: 4px; }

  .cat-bar { bottom: 63px; max-width: calc(100vw - 20px); }
  .cat-bar button { min-width: 42px; }

  .online-bar { top: 12px; right: 132px; max-width: calc(100vw - 142px); }
  .user-pill { font-size: 10px; padding: 4px 8px; }
  .map-mobile-menu { top: 10px; }
}

@media (max-width: 560px) {
  .brand-text { display: none; }
  .brand { min-width: 38px; }
  .coords { flex: 1; }
  .coord { flex: 1; min-width: 0; }
  .top-actions { gap: 3px; }
  .btn-labeled { display: none; }
  .sync-pill #sync-pill-text { display: none; }
  .sync-pill { width: 30px; padding: 0; justify-content: center; }
  .sync-pill .status-dot { margin: 0; }
  .topbar { height: 50px; }
  .toasts { bottom: 86px; right: 10px; left: 10px; max-width: none; }
  .help-grid { grid-template-columns: 1fr; }
  .modal-box { padding: 16px; border-radius: 14px; }
}

@media (min-width: 861px) {
  .sidebar-close { display: none; }
}
