/* Полотно: головний елемент застосунку. */
.stage {
  position: relative; overflow: hidden; touch-action: none;
  background: var(--surface); height: 100%; cursor: grab;
}
.stage.dragging { cursor: grabbing; }
.stage.placing { cursor: crosshair; }
/* Межа плану: без неї порожнє поле навколо читається як збій, а не як
   «план закінчився». Тінь робить план аркушем, що лежить на столі. */
.stage-inner {
  position: absolute; top: 0; left: 0; transform-origin: 0 0; will-change: transform;
  outline: 1px solid var(--line-str); box-shadow: 0 0 0 100vmax rgba(0,0,0,.22);
}
.stage-inner img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; user-select: none; }
.stage-inner .grid { position: absolute; inset: 0; pointer-events: none; }
/* Мітки лежать окремим шаром поверх зображення й не масштабуються разом з ним */
.pins { position: absolute; inset: 0; pointer-events: none; }
.pins > * { pointer-events: auto; }

.canvas-host { position: relative; height: calc(100vh - 52px); height: calc(100dvh - 52px); }
.canvas-host.with-banner { height: calc(100vh - 52px - 37px); height: calc(100dvh - 52px - 37px); }

/* Мітка. Розмір не залежить від зуму — інакше при віддаленні її не натиснеш. */
.pin {
  position: absolute; transform: translate(-50%, -50%);
  display: grid; place-items: center;
  min-width: 28px; height: 28px; padding: 0 6px;
  border-radius: 14px; border: 2px solid var(--bg);
  font: 600 12px var(--mono); cursor: pointer;
  background: var(--ok); color: #06231c;
}
.pin.warn { background: var(--warn); color: #241700; }
.pin.crit { background: var(--crit); color: #fff; }
.pin.oos  { background: var(--dim);  color: #0e141b; }
.pin.zone { min-width: 36px; height: 36px; border-radius: 18px; font-size: 13px; }
.pin .lbl { position: absolute; top: 100%; left: 50%; transform: translateX(-50%); margin-top: 4px;
  font: 500 10px var(--sans); color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 0 4px; white-space: nowrap; pointer-events: none;
  max-width: 120px; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
/* Підпис, що наїжджав би на сусіда, ховається (cluster.js). */
.pin.nolbl .lbl { display: none; }
/* Злиті мітки: число й подвійне кільце — щоб не сплутати з однією міткою. */
.pin.cluster { min-width: 32px; height: 32px; border-radius: 16px;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px currentColor; font-size: 12.5px; }
.pin.crit::after {
  content: ""; position: absolute; inset: -7px; border-radius: 50%;
  border: 2px solid var(--crit); animation: ping 1.8s ease-out infinite;
}
@keyframes ping { 0% { transform: scale(.75); opacity: .9; } 100% { transform: scale(1.5); opacity: 0; } }

.stage-ui { position: absolute; z-index: 5; display: flex; gap: var(--gap-xs); }
.stage-ui.tl { top: var(--gap-sm); left: var(--gap-sm); }
.stage-ui.tr { top: var(--gap-sm); right: var(--gap-sm); }
.stage-ui.bl { bottom: var(--gap-sm); left: var(--gap-sm); flex-direction: column; }
.stage-ui.br { bottom: var(--gap-sm); right: var(--gap-sm); flex-direction: column; }
.stage-ui .icon-btn { background: var(--surface); border-color: var(--line-str); color: var(--ink); }
.legend {
  display: flex; flex-wrap: wrap; gap: var(--gap-sm);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--line); border-radius: var(--r);
  padding: 7px 11px; font-size: 12px; color: var(--muted);
}
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.hint {
  background: var(--action-soft); border: 1px solid var(--action); color: var(--action);
  border-radius: var(--r); padding: 8px 12px; font-size: 13.5px;
  display: flex; align-items: center; gap: var(--gap-sm);
}

/* ─── панель властивостей мітки ───
   Збоку від полотна, без затемнення: полотно лишається видимим і живим.
   На телефоні — знизу, не вище за половину полотна. */
.sheet.propanel {
  position: absolute; top: var(--gap-sm); right: var(--gap-sm); z-index: 6;
  width: 340px; max-width: calc(100% - var(--gap-sm) * 2);
  max-height: calc(100% - var(--gap-sm) * 2);
  border-radius: var(--r-lg); border-color: var(--line-str);
}
/* Дії панелі завжди на виду: форма може бути довшою за панель. */
.sheet.propanel .acts { position: sticky; bottom: 0; background: var(--surface);
  padding-top: var(--gap-sm); border-top: 1px solid var(--line); }
@media (max-width: 619px) {
  /* fixed, а не absolute: на телефоні сторінка редактора прокручується
     (список лягає під полотно), і панель мусить лишатись на екрані. */
  .sheet.propanel {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; width: auto; max-width: none;
    max-height: 60dvh; border-radius: var(--r-lg) var(--r-lg) 0 0; z-index: 30;
  }
}

/* ─── огляд: полотно й колонка панелей ───
   Колонка — своя зона поруч із полотном, а не шар поверх плану: план
   лишається видимим цілком, список не закриває мітки. */
.split { display: flex; height: calc(100vh - 52px); height: calc(100dvh - 52px); }
.split.with-banner { height: calc(100vh - 52px - 37px); height: calc(100dvh - 52px - 37px); }
.split > .canvas-host { flex: 1 1 auto; min-width: 0; height: auto; }
.sidecol { flex: none; width: 340px; display: flex; flex-direction: column;
  border-left: 1px solid var(--line); background: var(--surface); overflow-y: auto; }
.sidecol-box { display: flex; flex-direction: column; min-height: 0; }
.sidecol-head { display: flex; align-items: center; gap: var(--gap-sm);
  padding: var(--gap-sm) var(--gap); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: var(--surface); z-index: 1; }
.sidecol-head h2 { margin: 0; flex: 1; font-size: 15px; font-weight: 600; }
.sidecol-empty { padding: var(--gap); margin: 0; color: var(--muted); font-size: 14px; }
.sidecol-body .list { margin: 0; }
/* Вузький екран: колонка лягає під полотно, сторінка гортається. */
@media (max-width: 760px) {
  .split, .split.with-banner { flex-direction: column; height: auto; }
  .split > .canvas-host { flex: none; height: 62vh; height: 62dvh; }
  .sidecol { width: auto; border-left: 0; border-top: 1px solid var(--line); overflow: visible; }
}

/* Редактор: смуга дій, далі полотно з колонкою на весь залишок екрана. */
.editor { display: flex; flex-direction: column; height: calc(100vh - 52px); height: calc(100dvh - 52px); }
.editor > .split { flex: 1 1 auto; min-height: 0; height: auto; }
@media (max-width: 760px) {
  .editor { height: auto; }
}
.sidecol-cta { padding: var(--gap); border-bottom: 1px solid var(--line); }
.propanel input[type=range] { width: 100%; accent-color: var(--action); }

/* ─── вкладки налаштування заходу ─── */
.tabs { display: flex; gap: 2px; padding: 0 var(--gap); height: 41px; align-items: flex-end;
  border-bottom: 1px solid var(--line); background: var(--surface); overflow-x: auto; flex: none; }
.tab { padding: 0 14px; height: 36px; display: inline-flex; align-items: center; white-space: nowrap;
  color: var(--muted); text-decoration: none; font-size: 14px; border-radius: var(--r-sm) var(--r-sm) 0 0;
  border: 1px solid transparent; border-bottom: 0; }
.tab:hover { color: var(--ink); }
.tab.on { color: var(--ink); background: var(--bg); border-color: var(--line); margin-bottom: -1px; height: 37px; font-weight: 600; }
.has-tabs .editor { height: calc(100vh - 52px - 41px); height: calc(100dvh - 52px - 41px); }
/* Запуск і завершення заходу — у правому кінці смуги, подалі від
   інструментів: випадковий натиск поруч із «Точка» вже траплявся. */
.editbar .grow { flex: 1 1 auto; }

/* ─── перелік у колонці редактора ─── */
.sidegrp-head { display: flex; align-items: center; justify-content: space-between;
  padding: 10px 10px 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); border-bottom: 1px solid var(--line); background: var(--raised); }
/* Точок багато — рядок в одну лінію: назва, праворуч код і кемп. */
.sideitem.thin { min-height: 32px; padding: 4px 10px; gap: 8px; }
.sideitem.thin b { display: inline; flex: 1 1 auto; min-width: 0; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.sideitem.thin small { display: inline; flex: none; font-size: 11.5px; font-family: var(--mono); }
.sortsel { width: auto; min-height: 30px; padding: 2px 26px 2px 8px; font-size: 12.5px; }
